public function __construct($pageID, $data) { $this->_pageID = $pageID; if (array_key_exists('@attributes', $data)) { if (array_key_exists('callback', $data['@attributes'])) { $this->_callback = ptc_array_get($data, '@attributes.callback'); \Event::listen('metatags.callback', $this->_callback); } unset($data['@attributes']); } $this->_data = $data; }
/** * */ 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; }
/** * */ public static function inputs($type) { $case = explode('.', $type); $key = isset($case[1]) ? str_replace($case[0] . '.', '', $type) : null; switch (strtolower($case[0])) { case '_get': $inputs = $_GET; break; case '_session': $inputs = $_SESSION; break; case '_cookies': $inputs = $_COOKIE; break; case '_request': $inputs = $_REQUEST; break; case '_post': $inputs = $_POST; break; case '_put': case '_delete': parse_str(file_get_contents('php://input'), $inputs); break; case '_raw': $inputs = file_get_contents('php://input'); break; default: trigger_error('Input type "' . $case[0] . '" is not supported!', E_USER_ERROR); return false; } return $key ? ptc_array_get($inputs, $key) : $inputs; }
/** * */ 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; }
/** * Load module config files that are not in root config */ protected static function _loadModulesConfig() { $config = array('..', '.'); foreach (static::options() as $key => $val) { $config[] = $key . '.php'; } foreach (Module::all() as $k => $module) { $scanned_directory = array_diff(scandir(ptc_path('root') . '/modules/' . $k . '/config'), $config); if (!empty($scanned_directory)) { foreach ($scanned_directory as $file) { $option_name = str_replace('.php', '', $file); $options = (require ptc_path('root') . '/modules/' . $k . '/config/' . $file); if (ptc_array_get($options, '_load')) { $options = call_user_func(ptc_array_get($options, '_load'), $options); } static::option($option_name, $options); } } } }