public static function load($template, $builder = null)
 {
     $pnav = new Project_Navigator();
     $dir = $pnav->getRelative('tpl_dir');
     $cdir = $pnav->getRelative('tpl.php_dir');
     $pconf = new Project_Config();
     $ext = $pconf->templates['extension'];
     $compile = $pconf->templates['compile'];
     $cext = $pconf->templates['compiled_extension'];
     $t_file = $dir . $template . $ext;
     $ct_file = $cdir . $template . $cext;
     if ($t_file_exists = file_exists($t_file)) {
         $tf_time = filemtime($t_file);
     }
     if ($ct_file_exists = file_exists($ct_file)) {
         $ctf_time = filemtime($ct_file);
     }
     if ($builder === null) {
         $builder = new HTML_Builder();
     }
     $ct_file_available = $ct_file_exists && (!$t_file_exists || $ctf_time >= $tf_time);
     if ($ct_file_available) {
         return self::loadCompiled($ct_file, $builder);
     } elseif ($t_file_exists) {
         if ($compile) {
             self::compile($t_file, $ct_file);
             return self::loadCompiled($ct_file, $builder);
         } else {
             return self::build($t_file, $builder);
         }
     } else {
         throw new File_Not_Found_Exception($t_file);
     }
 }
    protected function getResubscriptionHtml($urlBase, $client)
    {
        $nav = new Project_Navigator();
        $code = $client ? $client['Code'] : 'XXXXXXXXXXXXXXXX';
        $resubscriptionLink = $urlBase . $nav->get('newsletters_resubscription') . '?code=' . urlencode($code);
        return <<<EOT
<p>You can confirm your subscription for our newsletters service by clicking on <a href="{$resubscriptionLink}">this link</a>.</p>
EOT;
    }
 protected function _handleRedirection()
 {
     if ($this->_redirection !== null) {
         if ($this->navpoint !== null && $this->navpoint !== '') {
             $navigator = new Project_Navigator();
             $to = $navigator->get($this->navpoint);
         } else {
             $to = $this->target;
         }
         if ($this->qs !== null) {
             if ($this->qs[0] !== '?') {
                 $to .= '?';
             }
             $to .= $this->qs;
         }
         Redirection::redirectPage($to, $this->code, $this->schema, $this->host);
     }
 }
 protected function _handleInput()
 {
     if ($this->autodetect) {
         $this->current = Project_Navigator::getNavPoint(Server::get('REQUEST_URL'));
     } elseif ($this->current !== null) {
         Project_Navigator::get($this->current);
     }
     // check if registered
 }
 protected static function populateNavigator()
 {
     $config_file = 'navigator_config.inc.php';
     require 'include/config/' . $config_file;
     if (!isset($navigator_config)) {
         throw new Config_Exception("Config file \"{$config_file}\" did not define the \"\$navigator_config\" variable!");
     }
     if (!array_key_exists('base', $navigator_config)) {
         throw new Config_Exception("Config file \"{$config_file}\" did not define the \"\\base\" array field!");
     }
     if (!array_key_exists('navpoints', $navigator_config) || !is_array($navigator_config['navpoints'])) {
         throw new Config_Exception("Config file \"{$config_file}\" did not define the \"navpoints\" subarray!");
     }
     self::$_navigator = new Navigator();
     self::$_navigator->base = $navigator_config['base'];
     foreach ($navigator_config['navpoints'] as $pkey => $pitem) {
         self::$_navigator->register($pkey, $pitem);
     }
     self::$_navigator->lock();
 }
 protected function resolveHRef()
 {
     if ($this->page !== null) {
         if ($this->page == 'current') {
             $page = Server::get('REQUEST_URL');
             $qs = Server::get('REQUEST_QUERY_STRING');
             if ($qs !== '') {
                 $qs = "?{$qs}";
             }
         } else {
             $page = Project_Navigator::getPage($this->page, $this->nobase !== null);
             $qs = $this->qs === null ? '' : "?{$this->qs}";
         }
         $link = $page . $qs;
         $this->_a->href = $link;
         if ($this->popup !== null) {
             $onclick = $this->_a->onclick;
             if ($onclick === null) {
                 $onclick = '';
             }
             if ($onclick !== '' && substr($onclick, -1) != ';') {
                 $onclick .= ';';
             }
             if (substr($onclick, -13) == 'return false;') {
                 $onclick = substr($onclick, 0, -13);
             }
             $onclick .= "window.open('{$link}','_blank','{$this->popup}');return false";
             $this->_a->onclick = $onclick;
         }
         if ($this->content !== null) {
             $this->_a->clear();
             $this->_a->add($this->content, false);
         }
     } else {
         throw new Data_Insufficient_Exception('page');
     }
 }
 protected function updateNewsListTemplate()
 {
     $vars = array('novinka_vzor', 'ma_detail', 'nema_detail', 'detail', 'nadpis', 'obsah', 'datum', 'autor', 'autor_jako_link', 'zadne_novinky', 'prazdna_stranka', 'horni_paginace', 'novinky', 'dolni_paginace');
     foreach ($vars as $varname) {
         ${$varname} = $this->_index->{$varname};
     }
     if (!$novinka_vzor) {
         throw new Template_Element_Missing_Exception('novinka_vzor');
     }
     if (count($novinka_vzor) != 1) {
         throw new Template_Invalid_Structure_Exception('The "novinka_vzor" element duplicity');
     }
     if ($horni_paginace && count($horni_paginace) != 1) {
         throw new Template_Invalid_Structure_Exception('The "horni_paginace" element duplicity');
     }
     if ($dolni_paginace && count($dolni_paginace) != 1) {
         throw new Template_Invalid_Structure_Exception('The "dolni_paginace" element duplicity');
     }
     $novinka_vzor = $novinka_vzor[0];
     if ($horni_paginace) {
         $horni_paginace = $horni_paginace[0];
     }
     if ($dolni_paginace) {
         $dolni_paginace = $dolni_paginace[0];
     }
     $detailpage = $this->detailpage ? Project_Navigator::getPage($this->detailpage) : '';
     $this->resolveQS();
     $this->_qs->remove($this->nsd . 'ni');
     $this->_qs->set($this->nsd . 'ni', '');
     // nastavi query string tak, aby koncil na "ni="
     $detail_link = $detailpage . $this->qs;
     if (!empty($novinky)) {
         foreach ($this->_items as &$item) {
             $ma_detail_val = $item->Content !== '';
             foreach ($ma_detail as $elem) {
                 $elem->active = $ma_detail_val;
             }
             foreach ($nema_detail as $elem) {
                 $elem->active = !$ma_detail_val;
             }
             foreach ($nadpis as $elem) {
                 $elem->text = $item->Name;
             }
             foreach ($detail as $elem) {
                 $elem->href = $detail_link . $item->ID;
             }
             foreach ($obsah as $elem) {
                 switch ($this->listmode) {
                     case 'S':
                         $content = $item->Sample;
                         break;
                     case 'C':
                         $content = $item->Content;
                         break;
                     default:
                         throw new Template_Invalid_Argument_Exception('listmode', $this->listmode);
                 }
                 $content_elem = new HTML_Text(Images_JS_Support::updateHTMLRaw($this->images, $content));
                 $content_elem->raw = true;
                 $elem->clear();
                 $elem->add($content_elem);
             }
             foreach ($datum as $elem) {
                 try {
                     $elem->timestamp = $item->When;
                     // nikoli view_object, protoze se to bude jeste klonovat
                 } catch (HTML_No_Such_Element_Attribute_Exception $e) {
                     $datum_spec = null;
                     try {
                         $datum_spec = $elem->specification;
                     } catch (HTML_No_Such_Element_Attribute_Exception $e) {
                     }
                     $datetime = new Date_Time($item->When);
                     $elem->add(new HTML_Text($datetime->format($datum_spec === null ? 'j.n. Y' : $datum_spec)));
                 }
             }
             foreach ($autor as $elem) {
                 $elem->text = $item->Author;
             }
             if (!empty($autor_jako_link)) {
                 $autor_jako_link->clear();
                 $a = new HTML_A();
                 $a->href = 'http://' . $item->Author;
                 $a->add(new HTML_Text($item->Author));
                 foreach ($autor_jako_link as $elem) {
                     $elem->add($a);
                 }
             }
             foreach ($novinky as $elem) {
                 $elem->add(clone $novinka_vzor);
             }
         }
     }
     foreach ($zadne_novinky as $elem) {
         $elem->active = empty($this->_items) && $this->_total == 0;
     }
     foreach ($prazdna_stranka as $elem) {
         $elem->active = empty($this->_items) && $this->_total > 0;
     }
     $pages = (int) ($this->_total / $this->size);
     if ($pages * $this->size < $this->_total) {
         $pages++;
     }
     if ($horni_paginace) {
         $horni_paginace->vo->total = $pages;
         $horni_paginace->vo->current = $this->page;
         $horni_paginace->vo->qsvar = $this->ns . 'pg';
         $horni_paginace->active = $this->pagination && $this->pagination != 'bottom';
     }
     if ($dolni_paginace) {
         $dolni_paginace->vo->total = $pages;
         $dolni_paginace->vo->current = $this->page;
         $dolni_paginace->vo->qsvar = $this->ns . 'pg';
         $dolni_paginace->active = $this->pagination && $this->pagination != 'top';
     }
 }
 protected static function getImageNotFound()
 {
     return Project_Navigator::get('image_not_found');
 }
 protected function _getSuccessPageNavPoint()
 {
     return $this->successPage !== NULL ? $this->successPage : Project_Navigator::getNavPoint(Server::get('REQUEST_URL'));
 }
 protected function updateTemplate_Picture(Var_Pool $picture, $directory = '')
 {
     $vars = array('ma_vlastni_obrazek', 'nema_vlastni_obrazek', 'vlastni_obrazek', 'vlastni_obrazek_jako_link', 'puvodni_vlastni_obrazek', 'puvodni_vlastni_obrazek_jako_link', 'nahradni_obrazek_vzor', 'nahradni_obrazek', 'tag_obrazku');
     foreach ($vars as $varname) {
         ${$varname} = $this->_index->{$varname};
     }
     $vlastni_obrazek_val = $picture->GPFileName !== '' ? "{$directory}/{$picture->GPFileName}" : $picture->FileName;
     $puvodni_vlastni_obrazek_val = $picture->FileName;
     $nadpis_val = $picture->GPTitle !== '' ? $picture->GPTitle : $picture->Title;
     $puvodni_nadpis_val = $picture->Title;
     foreach ($ma_vlastni_obrazek as $elem) {
         $elem->active = $vlastni_obrazek_val !== '';
     }
     foreach ($nema_vlastni_obrazek as $elem) {
         $elem->active = $vlastni_obrazek_val === '';
     }
     $pnav = new Project_Navigator();
     $galleries_directory = $pnav->images_dir . $pnav->get('galleries_dir', true);
     if ($vlastni_obrazek_val === '') {
         $img = clone $nahradni_obrazek_vzor[0];
         $thumb = $this->getThumbnailFileName($img->src, $this->thumbs);
         $img->src = $galleries_directory . $thumb;
         $img->alt = basename($thumb);
         foreach ($nahradni_obrazek as $elem) {
             $elem->add($img);
         }
     } elseif (!empty($vlastni_obrazek_jako_link) || !empty($vlastni_obrazek)) {
         if (!empty($obrazek_img_vzor)) {
             $img = clone $obrazek_img_vzor[0];
         } else {
             $img = new HTML_Img();
         }
         $thumb = $this->getThumbnailFileName($vlastni_obrazek_val, $this->thumbs);
         $img->src = $galleries_directory . $thumb;
         $img->alt = basename($thumb);
         if (!empty($obrazek_a_vzor)) {
             $a = clone $obrazek_a_vzor[0];
             $a->clear();
         } else {
             $a = new HTML_A();
         }
         $a->href = $galleries_directory . $vlastni_obrazek_val;
         $a->title = $nadpis_val;
         Images_JS_Support::updateElement($this->images, $a);
         $a->add($img);
         foreach ($vlastni_obrazek_jako_link as $elem) {
             $elem->clear();
             $elem->add($a);
         }
         foreach ($vlastni_obrazek as $elem) {
             $elem->clear();
             $elem->add($img);
         }
     }
     if ($puvodni_vlastni_obrazek_val !== '' && (!empty($puvodni_vlastni_obrazek_jako_link) || !empty($puvodni_vlastni_obrazek))) {
         $img = new HTML_Img();
         $thumb = $this->getThumbnailFileName($puvodni_vlastni_obrazek_val, $this->thumbs);
         $img->src = $galleries_directory . $thumb;
         $img->alt = basename($thumb);
         $a = new HTML_A();
         $a->href = $galleries_directory . $puvodni_vlastni_obrazek_val;
         $a->title = $puvodni_nadpis_val;
         Images_JS_Support::updateElement($this->images, $a);
         $a->add($img);
     }
     foreach ($puvodni_vlastni_obrazek_jako_link as $elem) {
         $elem->add($a);
     }
     foreach ($puvodni_vlastni_obrazek_jako_link as $elem) {
         $elem->add($img);
     }
     $this->updateTemplate_PictureTitles($picture);
     $this->updateTemplate_PictureDescriptions($picture);
     $this->updateTemplate_PictureAuthors($picture);
     $this->updateTemplate_PictureDate($picture);
 }
 protected function _spamDetected()
 {
     $this->saveSessionVars();
     $this->_redirection = Project_Navigator::getNavPoint(Server::get('REQUEST_URL'));
 }
Esempio n. 12
0
 protected function _updateSuccessTemplate()
 {
     //$this->__updateFormTemplate();
     $this->_redirection = Project_Navigator::getNavPoint(Server::get('REQUEST_URL'));
 }
 public static function redirectNavPoint($nav_point, $code = 303, $schema = null)
 {
     $navigator = new Project_Navigator();
     $to = $navigator->get($nav_point);
     self::redirectPage($to, $code, $schema);
 }
 protected function updateTemplate_Attachments(HTML_Indexer $index = null, Kiwi_Product $product_data = null)
 {
     if ($index === null) {
         $index = $this->_index;
     }
     if ($product_data === null) {
         $product_data = $this->_product_data;
     }
     $vars = array('priloha_vzor', 'priloha_odkaz', 'priloha_nazev', 'priloha_pripona', 'ma_prilohy', 'nema_prilohy', 'prilohy');
     foreach ($vars as $varname) {
         ${$varname} = $index->{$varname};
     }
     $attachments = $product_data->attachments;
     foreach ($ma_prilohy as $elem) {
         $elem->active = !empty($attachments);
     }
     foreach ($nema_prilohy as $elem) {
         $elem->active = empty($attachments);
     }
     if (!empty($prilohy)) {
         if (empty($priloha_vzor)) {
             throw new Template_Element_Missing_Exception('priloha_vzor');
         }
         if (count($priloha_vzor) !== 1) {
             throw new Template_Invalid_Structure_Exception('The "priloha_vzor" element duplicity');
         }
         $priloha_vzor = $priloha_vzor[0];
         if (!empty($attachments)) {
             $nav = new Project_Navigator();
             $attachments_dir = $nav->get($this->name . '_attachments');
             foreach ($attachments as $attachment) {
                 $file = $attachments_dir . $attachment['FileName'];
                 foreach ($priloha_odkaz as $elem) {
                     $elem->href = $file;
                 }
                 foreach ($priloha_nazev as $elem) {
                     $elem->clear();
                     $elem->add(new HTML_Text($attachment['Title']));
                 }
                 $path_parts = pathinfo($attachment['FileName']);
                 $ext = $path_parts['extension'];
                 $found = 0;
                 foreach ($priloha_pripona as $elem) {
                     if ($elem->active = $elem->specification === strtolower($ext)) {
                         $found += 1;
                     }
                 }
                 if ($found === 0) {
                     foreach ($priloha_pripona as $elem) {
                         $elem->active = $elem->specification === 'default';
                     }
                 }
                 $attachment_elem = clone $priloha_vzor;
                 foreach ($prilohy as $elem) {
                     $elem->add($attachment_elem);
                 }
             }
         }
     }
 }
 protected function getHRef($page)
 {
     $href = $this->link === null ? Server::get('REQUEST_URL') : Project_Navigator::getPage($this->link);
     $qso = clone $this->_qs;
     if ($page != 1) {
         $qso->set($this->qsvar, $page);
     }
     $qs = $qso->__toString();
     return $href . $qs;
 }