public function render()
 {
     $params = array($this->_pageID, &$this->_data);
     ptc_log($params, 'Website metatags are been compiled!', \App::option('website.debug_category') . ' Action');
     if ($this->_callback) {
         ptc_log($params, 'Website metatags is beeing fired!', \App::option('website.debug_category') . ' Action');
         \Event::fire('metatags.callback', $params);
     }
     if (empty($this->_data)) {
         return null;
     }
     $tag = null;
     foreach ($this->_data as $k => $v) {
         if (!$v) {
             continue;
         }
         $v = preg_replace('/\\s+/', ' ', $v);
         if ('title' === $k) {
             $tag .= "\t" . '<title>' . trim($v) . '</title>' . "\n";
         } else {
             if (0 === strpos(strtolower($k), 'og:')) {
                 $tag .= "\t" . '<meta property="' . $k . '" content="' . trim($v) . '">' . "\n";
             } else {
                 $tag .= "\t" . '<meta name="' . $k . '" content="' . trim($v) . '">' . "\n";
             }
         }
     }
     return $tag;
 }
 protected static function _initialize()
 {
     $options = \App::options('logger.' . (\App::option('test_env') ? 'develop' : 'prod'));
     static::$_connectionName = $options['connection'];
     static::$_table = $options['table'];
     $class = parent::_initialize();
     static::$_connectionName = 'default';
     static::$_table = null;
     return $class;
 }
Beispiel #3
0
 public function __get($key)
 {
     if (!array_key_exists($key, $this->_storage)) {
         throw new \Exception('View element "' . $key . '" does not exist!');
         return false;
     }
     if ($this->_useCache && array_key_exists($key, $this->_cache)) {
         return $this->_cache[$key];
     }
     $this->_vars[\App::option('website.elements_param')] = $this;
     return $this->_cache[$key] = \View::make(\App::option('website.views_path') . '/' . $this->_storage[$key], $this->_vars)->compile();
     $this->_useCache = true;
 }
 /**
  *
  */
 protected function _parseXML()
 {
     $xml_block = $this->_xml->xpath("//page[@id='" . $this->_page . "']");
     if (!$xml_block) {
         trigger_error('Page block "' . $this->_page . '" was not set in pages.xml file!', E_USER_ERROR);
         return false;
     }
     $data = array(\App::option('website.resources_param') => null, \App::option('website.lang_param') => null, \App::option('website.data_param') => null, \App::option('website.meta_tags_param') => Manager::getMetaTags(), \App::option('website.router_param') => new models\Router($this->_page));
     //$data[ \App::option( 'website.current_route_param' ) . 'raw' ] =
     //		( Manager::currentRoute( ) && Manager::getLang( 'suffix' ) ) ?
     //			str_replace( '_' . Manager::getLang( 'suffix' ) , '' ,  Manager::currentRoute( ) ) : null;
     $views = $xml_block[0]->views->view;
     if ($resources = $xml_block[0]->resources) {
         $blocks = array();
         foreach ($resources[0] as $block) {
             $blocks[] = (string) $block;
         }
         $data[\App::option('website.resources_param')] = new models\Resources($blocks, $this->_page);
     }
     $data[\App::option('website.lang_param')] = $this->_getTranslator();
     $params = array($this->_page, &$data[\App::option('website.data_param')], $data[\App::option('website.lang_param')]);
     if ($call = (string) $xml_block[0]->attributes()->callback) {
         \Event::listen('view.callback', $call);
     }
     $events = \Event::getEvent('view');
     if (@$events['callback']) {
         \Event::fire('view.callback', $params);
     }
     $elements = $this->_xml->xpath("//elements");
     if ($elements) {
         $storage = array();
         foreach ($elements[0]->element as $element) {
             $storage[(string) $element->attributes()->name] = (string) $element;
         }
         $data[\App::option('website.elements_param')] = new models\Elements($storage, $data);
     }
     $view = \View::make(\App::option('website.views_path') . '/' . $views[0], $data);
     if (count($views) > 1) {
         unset($views[0]);
         foreach ($views as $file) {
             $child = (string) $file->attributes()->child;
             $view = $view->nest($child, \App::option('website.views_path') . '/' . $file, $view->getPageVars());
         }
     }
     return $view;
 }
 /**
  *
  */
 public static function getLanguages()
 {
     if (!static::$_languages) {
         $xml = simplexml_load_file(\App::option('website.xml_config_path') . '/languages.xml');
         if ($languages = $xml->xpath("//lang")) {
             $path = \App::option('website.language_files_path');
             foreach ($languages as $language) {
                 $array = array('prefix' => (string) $language->prefix, 'suffix' => (string) $language->suffix, 'controller' => (string) $language->attributes()->controller);
                 if ($language->xml) {
                     $array['xml'] = $path . '/' . (string) $language->xml;
                 }
                 if ($language->js) {
                     $array['js'] = (string) $language->js;
                     $array['script'] = $path . '/' . (string) $language->js;
                 }
                 if ($language->attributes()->main) {
                     static::$_fallbackLang = (string) $language->attributes()->controller;
                 }
                 \App::storage('website.languages.' . $language->attributes()->controller, $array);
             }
         }
     }
     static::$_languages = true;
     return \App::storage('website.languages');
 }
Beispiel #6
0
 /**
  *
  */
 protected static function _initialize()
 {
     if (!static::$_xml) {
         static::$_xml = simplexml_load_file(\App::option('website.xml_config_path') . '/resources.xml');
         $resources = static::$_xml->xpath("//resources");
         foreach ($resources[0]->file as $file) {
             $id = (string) $file->attributes()->id;
             if (isset(static::$_resources[$id])) {
                 trigger_error('Resource id "' . $id . '" already set!', E_USER_ERROR);
                 return false;
             }
             if (\App::option('app.test_env')) {
                 $resource = $file->attributes()->rand ? $file->{0} . '?rand=' . rand(100, 999) : $file->{0};
             } else {
                 $resource = ($rev = \App::option('revision.number')) ? $file->{0} . '?rev=' . $rev : $file->{0};
             }
             static::$_resources[$id] = array('file' => $resource, 'external' => false);
             if ($external = (string) $file->attributes()->external) {
                 static::$_resources[$id]['external'] = true;
             }
         }
         return static::$_xml;
     }
     return true;
 }