/** * Method description * * More detailed method description * @param mixed $data * @return void */ function setData(WidgetResultSet $data) { $h = Header::get(); $h->setTitleSeparator(Language::encodePair($data->get('separator'))); $h->setTitleStart(Language::encodePair($data->get('start'))); $h->setTitleEnd(Language::encodePair($data->get('end'))); if ($data->get('add')) { $h->addTitleItem(Language::encodePair($data->get('add'))); } parent::setData($data); }
public function getHeader($var) { return $this->header->get($var); }
/** * @param string $path * @param array $pages * @param string $order_by * @param array $manual * @throws \RuntimeException * @internal */ protected function buildSort($path, array $pages, $order_by = 'default', $manual = null) { $list = array(); $header_default = null; $header_query = null; // do this headery query work only once if (strpos($order_by, 'header.') === 0) { $header_query = explode('|', str_replace('header.', '', $order_by)); if (isset($header_query[1])) { $header_default = $header_query[1]; } } foreach ($pages as $key => $info) { $child = isset($this->instances[$key]) ? $this->instances[$key] : null; if (!$child) { throw new \RuntimeException("Page does not exist: {$key}"); } switch ($order_by) { case 'title': $list[$key] = $child->title(); break; case 'date': $list[$key] = $child->date(); break; case 'modified': $list[$key] = $child->modified(); break; case 'slug': $list[$key] = $child->slug(); break; case 'basename': $list[$key] = basename($key); break; case is_string($header_query[0]): $child_header = new Header((array) $child->header()); $header_value = $child_header->get($header_query[0]); if ($header_value) { $list[$key] = $header_value; } else { $list[$key] = $header_default ?: $key; } break; case 'manual': case 'default': default: $list[$key] = $key; } } // handle special case when order_by is random if ($order_by == 'random') { $list = $this->arrayShuffle($list); } else { // else just sort the list according to specified key asort($list); } // Move manually ordered items into the beginning of the list. Order of the unlisted items does not change. if (is_array($manual) && !empty($manual)) { $new_list = array(); $i = count($manual); foreach ($list as $key => $dummy) { $info = $pages[$key]; $order = array_search($info['slug'], $manual); if ($order === false) { $order = $i++; } $new_list[$key] = (int) $order; } $list = $new_list; // Apply manual ordering to the list. asort($list); } foreach ($list as $key => $sort) { $info = $pages[$key]; // TODO: order by manual needs a hash from the passed variables if we make this more general. $this->sort[$path][$order_by][$key] = $info; } }
/** * Method description * * More detailed method description * @param void * @return void */ function buildComplete() { $this->setTitle($this->getTitle() . " - " . $this->getType()); Header::get()->addLink(array('rel' => 'alternate', 'type' => Feed::getMimeType($this->getType()), 'title' => $this->getTitle(), 'href' => $this->getHREF())); parent::buildComplete(); }
/** * @param string $path * @param array $pages * @param string $order_by * @param array $manual * * @throws \RuntimeException * @internal */ protected function buildSort($path, array $pages, $order_by = 'default', $manual = null) { $list = []; $header_default = null; $header_query = null; $sort_flags = SORT_NATURAL | SORT_FLAG_CASE; // do this header query work only once if (strpos($order_by, 'header.') === 0) { $header_query = explode('|', str_replace('header.', '', $order_by)); if (isset($header_query[1])) { $header_default = $header_query[1]; } } foreach ($pages as $key => $info) { $child = isset($this->instances[$key]) ? $this->instances[$key] : null; if (!$child) { throw new \RuntimeException("Page does not exist: {$key}"); } switch ($order_by) { case 'title': $list[$key] = $child->title(); break; case 'date': $list[$key] = $child->date(); $sort_flags = SORT_REGULAR; break; case 'modified': $list[$key] = $child->modified(); $sort_flags = SORT_REGULAR; break; case 'slug': $list[$key] = $child->slug(); break; case 'basename': $list[$key] = basename($key); break; case is_string($header_query[0]): $child_header = new Header((array) $child->header()); $header_value = $child_header->get($header_query[0]); if ($header_value) { $list[$key] = $header_value; } else { $list[$key] = $header_default ?: $key; } $sort_flags = SORT_REGULAR; break; case 'manual': case 'default': default: $list[$key] = $key; $sort_flags = SORT_REGULAR; } } // handle special case when order_by is random if ($order_by == 'random') { $list = $this->arrayShuffle($list); } else { // else just sort the list according to specified key if (extension_loaded('intl')) { $locale = setlocale(LC_COLLATE, 0); //`setlocale` with a 0 param returns the current locale set $col = \Collator::create($locale); if ($col) { $col->asort($list, $sort_flags); } else { asort($list, $sort_flags); } } else { asort($list, $sort_flags); } } // Move manually ordered items into the beginning of the list. Order of the unlisted items does not change. if (is_array($manual) && !empty($manual)) { $new_list = []; $i = count($manual); foreach ($list as $key => $dummy) { $info = $pages[$key]; $order = array_search($info['slug'], $manual); if ($order === false) { $order = $i++; } $new_list[$key] = (int) $order; } $list = $new_list; // Apply manual ordering to the list. asort($list); } foreach ($list as $key => $sort) { $info = $pages[$key]; $this->sort[$path][$order_by][$key] = $info; } }
/** * Method description * * More detailed method description * @param array * @return void */ function parseParams(SimpleXMLElement $elem) { $attr = array(); if (isset($elem['http-equiv'])) { $attr['http-equiv'] = (string) $elem['http-equiv']; } if (isset($elem['name'])) { $attr['name'] = (string) $elem['name']; } if (isset($elem['content'])) { $attr['content'] = (string) $elem['content']; } if (isset($elem['scheme'])) { $attr['scheme'] = (string) $elem['scheme']; } if (!empty($attr['content'])) { // content is required Header::get()->addMeta($attr); } if (isset($elem['nofollow']) && (string) $elem['nofollow']) { Header::get()->nofollow(); } if (isset($elem['noindex']) && (string) $elem['noindex']) { Header::get()->noindex(); } $attr = array(); if (isset($elem['charset'])) { $attr['charset'] = (string) $elem['charset']; } if (isset($elem['href'])) { $attr['href'] = (string) $elem['href']; } if (isset($elem['hreflang'])) { $attr['hreflang'] = (string) $elem['hreflang']; } if (isset($elem['type'])) { $attr['type'] = (string) $elem['type']; } if (isset($elem['rel'])) { $attr['rel'] = (string) $elem['rel']; } if (isset($elem['rev'])) { $attr['rev'] = (string) $elem['rev']; } if (isset($elem['title'])) { $attr['title'] = (string) $elem['title']; } if (isset($elem['cond'])) { $attr['cond'] = (string) $elem['cond']; } if (isset($elem['media'])) { $attr['media'] = (string) $elem['media']; } if (!empty($attr)) { Header::get()->addLink($attr); } parent::parseParams($elem); }
/** * Lite version of Controller::init method. * Navigator object isn't created and step isn't added, * standard JS and CSS isn't added to the head part. * * @param null * @return nul */ function init() { $this->trigger("BeforeInit", $this); Boot::setupAll(); $this->header = Header::get(); $this->dispatcher = new WidgetEventDispatcher(); $this->display_mode_params = new DisplayModeParams(); $this->adjacency_list = new WidgetsAdjacencyList(); $full_path = $this->findPage(); $dom = new DomDocument(); if ($dom->load($full_path) === false) { throw new ControllerException("Can not load XML " . $full_path); } $this->restoreSignatures(); $this->trigger("BeforeHandlePOST", $this); if ($_SERVER['REQUEST_METHOD'] == "POST") { $this->restoreCheckers(); $this->parsePageOnPOST($this->processPage($dom)); $this->handlePOST(); exit; } $this->parsePageOnGET($this->processPage($dom)); $this->inited = true; $this->trigger("AfterInit", $this); }
/** * Get User Agent * * @return string|null */ public static function getUserAgent() { return Header::get('HTTP_USER_AGENT'); }