/** * */ protected static function _getBlock($page, $blockID, $type) { if (!static::_initialize()) { return false; } $block = static::$_xml->xpath("//block[@id='" . $blockID . "']"); if (!$block) { trigger_error('Block id "' . $blockID . '" not found in xml config file!', E_USER_ERROR); return false; } $children = $block[0]->{$type}; $string = null; if (isset($children->resource)) { for ($i = 0; $i < count($children); $i++) { $items = array(); for ($a = 0; $a < count($children->{$i}->resource); $a++) { $resource_id = (string) $children->{$i}->resource->{$a}; $items[] = $resource_id; } if ($comment = $children->{$i}->attributes()) { $comment = $comment->type; } $string .= static::_build($items, $type, $comment); } } if ($listener = $block[0]->listener) { for ($b = 0; $b < count($listener); $b++) { $listener_type = (string) $listener->{$b}->attributes()->type; if ($type === $listener_type || 'any' === $listener_type) { $params = array($page, &$string, $type); if (false === ptc_fire('website.' . (string) $listener->{$b}[0], $params)) { static::$_fireEvent = false; } } } } $event = \Event::getEvents('website'); if ($page && static::$_fireEvent && is_array($event) && ptc_array_get($event, 'resources', false)) { ptc_fire('website.resources', array($page, &$string, $type, $blockID)); } if ($raw = $block[0]->{$type}->raw) { $string .= 'js' === $type ? '<script>' . "\n" : '<style>' . "\n"; for ($c = 0; $c < count($raw); $c++) { $string .= "\t" . $raw->{$c} . (';' !== substr(trim($raw->{$c}), -1) ? ';' : null) . "\n"; } $string .= 'js' === $type ? '</script>' . "\n" : '</style>' . "\n"; } return $string; }
/** * */ public static function setLang($controllerID) { static::getLanguages(); if ($lang = \App::storage('website.languages.' . $controllerID)) { $event = \Event::getEvents('website'); if (is_array($event) && ptc_array_get($event, 'setlang', false)) { ptc_fire('website.setlang', array($controllerID, &$lang)); } \App::storage('website.current_lang', $lang); $fallback_key = static::$_fallbackLang; $fallback_lang = $fallback_key && $fallback_key != $controllerID ? \App::storage('website.languages.' . $fallback_key) : null; \App::storage('website.fallback_lang', $fallback_lang); return true; } return false; }
/** * */ protected static function _shutdown($response, $print, $obj) { $event = Event::getEvent('app'); if (is_array($event) && ptc_array_get($event, 'stop', false)) { ptc_fire('app.stop', array($obj, &$response)); } if (!$print) { return $response; } echo $response; }