Example #1
0
 static function isCurrentPage($sPageName)
 {
     try {
         $sCurrentPage = AnwActionPage::getCurrentPageName();
         if ($sPageName == $sCurrentPage) {
             AnwDebug::log("isCurrentPage (" . $sPageName . ") : YES (currently " . $sCurrentPage . ")");
             return true;
         }
         //check translations if page exists
         $oPage = new AnwPageByName($sCurrentPage);
         if ($oPage->exists()) {
             $aoPages = $oPage->getPageGroup()->getPages();
             foreach ($aoPages as $oPageTranslation) {
                 if ($oPageTranslation->getName() == $sPageName) {
                     AnwDebug::log("isCurrentPage (" . $sPageName . ") : YES (currently " . $sCurrentPage . ")");
                     return true;
                 }
             }
         }
     } catch (AnwException $e) {
     }
     AnwDebug::log("isCurrentPage (" . $sPageName . ") : NO (currently " . $sCurrentPage . ")");
     return false;
 }
Example #2
0
 protected static function getCurrentPageNames()
 {
     $asCurrentPageNames = array();
     $sCurrentPageName = AnwActionPage::getCurrentPageName();
     if (!$sCurrentPageName) {
         // FS#144 - avoids AnwBadPageNameException
         return $asCurrentPageNames;
     }
     //allow currentPageNames even if it doesn't exist (useful for action_output)
     $asCurrentPageNames[] = $sCurrentPageName;
     try {
         $oCurrentPage = new AnwPageByName($sCurrentPageName);
         $oCurrentPage->setSkipLoadingTranslationsContent(true);
         $aoCurrentPageTranslations = $oCurrentPage->getPageGroup()->getPages($oCurrentPage);
         foreach ($aoCurrentPageTranslations as $oTranslation) {
             $asCurrentPageNames[] = $oTranslation->getName();
         }
     } catch (AnwPageNotFoundException $e) {
     }
     return $asCurrentPageNames;
 }
Example #3
0
 protected function getoPage()
 {
     if (!self::$oPage) {
         if (AnwEnv::_GET(self::GET_PAGENAME)) {
             //read pagename from env
             $sPageName = self::getCurrentPageName();
             if (AnwPage::isValidPageName(self::getCurrentPageName())) {
                 self::$oPage = new AnwPageByName($sPageName);
             } else {
                 //warning, doing error404() here may lead to infinite recursion in some very special cases... that's why $oPage is set to the homepage here, to prevent loop.
                 self::$oPage = new AnwPageByName(self::globalCfgHomePage());
                 self::error404();
             }
         } else {
             //load homepage
             $sPageName = self::globalCfgHomePage();
             self::$oPage = new AnwPageByName($sPageName);
             //make sure to load homepage in the session language, if available
             try {
                 $sWantedLang = AnwCurrentSession::getLang();
                 if (self::$oPage->exists() && self::$oPage->getLang() != $sWantedLang) {
                     $aoPages = self::$oPage->getPageGroup()->getPages();
                     if (isset($aoPages[$sWantedLang])) {
                         self::$oPage = $aoPages[$sWantedLang];
                         self::debug("Homepage found in current session lang");
                     } else {
                         self::debug("Homepage NOT found in current session lang");
                     }
                 }
             } catch (AnwException $e) {
             }
         }
     }
     return self::$oPage;
 }
Example #4
0
    function pageNav($aoPageNavEntries)
    {
        $HTML = <<<EOF

\t<div id="pageactions">
\t\t<ul>
EOF;
        foreach ($aoPageNavEntries as $oEntry) {
            $sLink = $oEntry->getPageLink(AnwActionPage::getCurrentPageName());
            $sTitle = $oEntry->getTitle();
            $sImg = $oEntry->getImg();
            $HTML .= <<<EOF

\t\t<li><a href="{$this->xQuote($sLink)}" class="pageaction" style="background-image:url('{$sImg}')">{$this->xText($sTitle)}</a></li>
EOF;
        }
        $HTML .= <<<EOF

\t\t</ul>
\t</div>

EOF;
        return $HTML;
    }