diff --git a/class-MenuEntry.php b/class-MenuEntry.php index ca8b0c4..22860a5 100644 --- a/class-MenuEntry.php +++ b/class-MenuEntry.php @@ -1,129 +1,155 @@ . /** * Define a menu entry * * Some menu entries define a menu tree and can be displayed later. */ class MenuEntry { /** * Menu user identifier * * e.g. 'home' * * @var string */ public $uid; /** * Identifier of the parent menu * * @var array|string|null */ public $parentUid; /** * URI of the menu * * @var string */ public $url; /** * Menu title * * @var string */ public $name; /** * Permission to show this menu * * @var string */ public $permission; /** * Extra metadata */ public $extra; /** * Constructor * * @param string $uid Menu user identifier e.g. 'home' * @param string $url Page URL e.g. 'home.html' * @param string $name Page name * @param string $parent_uid Parent menu user identifier * @param string $permission Permission required to see this page (true: always, false: never, string: check the permission name) * @param string $extram Extra metadata */ function __construct( $uid, $url = null, $name = null, $parent_uid = null, $permission = true, $extra = null ) { $this->uid = $uid; $this->url = $url; $this->name = $name; $this->parentUid = $parent_uid; // backward compatibility if( is_array( $permission ) ) { error( "deprecated use of MenuEntry: now the #5 argument is \$permission and not $extra" ); $extra = $permission; $permission = null; } $this->permission = $permission; $this->extra = $extra; } /** - * Call site_page() on the URL + * Get the URL * - * @param $full_url boolean + * @param $absolute boolean * @return string * @see site_page() */ - public function getSitePage( $full_url = false ) { - return site_page( $this->url, $full_url ); + public function getURL( $absolute = false ) { + return site_page( $this->url, $absolute ); + } + + /** + * Get an URL that should be absolute + * + * @return string + * @see site_page() + */ + public function getAbsoluteURL() { + return $this->getURL( true ); } /** * Check if the user has the permission to see this page * * @return boolean */ public function isVisible() { if( is_string( $this->permission ) ) { return has_permission( $this->permission ); } return $this->permission; } /** * Get a metadata by name (alias) + * + * @param string $arg + * @param $default + * @return mixed */ - public function getExtra( $arg, $default = null ) { - return $this->get($arg, $default); - } - public function get( $arg, $default = null ) { if( isset( $this->extra[ $arg ] ) ) { return $this->extra[ $arg ]; } return $default; } + + /** + * @deprecated + */ + public function getSitePage( $full_url = false ) { + error( "deprecated MenuEntry#getSitePage(), use getURL() instead" ); + return $this->getURL( $full_url ); + } + + /** + * @deprecated + */ + public function getExtra( $arg, $default = null ) { + error( "MenuEntry->getExtra() deprecated" ); + return $this->get($arg, $default); + } }