<?php
namespace Moto\ClickAction; use Moto; class Page extends AbstractClickAction { protected $_defaultData = array( 'id' => null, 'target' => '_self', 'nofollow' => 0, ); protected $_url = null; public function getUrl() { $anchor = $this->get('anchor'); if (!empty($anchor)) { $anchor = trim($anchor); $anchor = trim($anchor, '#'); $anchor = '#' . $anchor; } if (null !== $this->_url) { return $this->_url . $anchor; } try { $url = Moto\Website\Pages::getRelativeUrl($this->get('id')); $url = Moto\System::getRelativeUrl($url); $this->_url = $url; } catch (\Exception $e) { $this->_url = $this->get('fallback', ''); } return $this->_url . $anchor; } public static function buildUrl($url, $query = null) { $url = trim($url); $url = trim($url, '/'); if (is_array($query)) { $query = http_build_query($query); } else { $query = ''; } if (!empty($url)) { if (self::$_usingPermalinks) { if (self::$_usingHtmlSuffix) { $url .= '.html'; } else { $url .= '/'; } } else { $url = '?url=' . $url; } } if (!empty($query)) { if (strpos($url, '?') === false) { $url .= '?'; } elseif (substr($url, -1) !== '?') { $url .= '&'; } $url .= $query; } return $url; } public function isCurrent($properties, $linker) { $currentPage = $linker->getGlobal('currentPage'); if (!$currentPage) { return false; } if ($currentPage instanceof Moto\Website\ContentPage || $currentPage instanceof Moto\Application\Pages\PageModel) { return $currentPage->isCurrent($properties); } return false; } } 