/** * Will render a specified form, the name of the form given by the first parameter; * * This method will render one of the forms for our object, invoked by giving the proper form identifier to the current form. * We have chosen this method of invoking forms, because we just had too many this->renderSomethingMethod (), which really had * an impact on code massiveness. Also, having code organized in switch/case statements leads us to be able to share common * settings between different forms, as we've done with the methods defined in the __CALL method above; * * For example, if we wanted to share some common configuration between a create and an edit form, we could have introduced * two switches in this method, one that would have set the common options, and the second, would have just passed through * again, and get the already set configuration options, using them. This means that if we needed to change behavior of * some interconnected forms, that would mean modifying the needed code one place only, which is a big advantage over * having separated methods for each form. Maybe if we extended this object, you guys could understand the functionality; * * @param string $objFormToRender The name of the form to render; * @return mixed Depends on the rendered form if it returns something or not; */ public function renderFrontendPage(S $objPageToRender, S $objTypeSwitcher) { // Do a switch on the rendered page ... switch ($objTypeSwitcher) { // Authentication ... and stuff; case FRONTEND_AUTHENTICATION_URL: // Check the mighty authenticate ... if (isset($_GET[AUTHENTICATION_ACTION_URL])) { // Do a switch ... switch ($_GET[AUTHENTICATION_ACTION_URL]) { case AUTHENTICATION_REGISTER_URL: // Set the template file ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'users-register.tp'); break; case AUTHENTICATION_ACTIVATE_URL: // Set the template file ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'users-activate.tp'); break; case AUTHENTICATION_PROFILE_URL: // Set the template file ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'users-profile.tp'); break; case AUTHENTICATION_LOGOUT_URL: // Log me OUT my wuv ... $this->ATH->doLogOut(); // Get me HOME ... I'm LOST here ... $this->setHeaderKey(URL::staticURL(new A(array(FRONTEND_SECTION_URL)), new A(array(FRONTEND_HOME))), new S('Location')); break; case AUTHENTICATION_YAHOO_BB_AUTH: return $this->renderWidget(new S(AUTHENTICATION_YAHOO_BB_AUTH)); break; } } else { // Set the template file ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'users.tp'); } // Go my baby ... GO ... TPL::tpSet($this->objURLImageDir, new S('objURLImageDir'), $tpF); TPL::tpSet($this->ATH, new S('ATH'), $tpF); TPL::tpSet($this->STG, new S('STG'), $tpF); TPL::tpSet($this->TXT, new S('TXT'), $tpF); TPL::tpSet($this->ART, new S('ART'), $tpF); TPL::tpSet($this->AUD, new S('AUD'), $tpF); TPL::tpSet($this->CNT, new S('CNT'), $tpF); TPL::tpSet($this->FAQ, new S('FAQ'), $tpF); TPL::tpSet($this->LRQ, new S('LRQ'), $tpF); TPL::tpExe($tpF); break; case FRONTEND_ARTICLE_URL: // Go my baby ... GO ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'news.tp'); TPL::tpSet($this->objURLImageDir, new S('objURLImageDir'), $tpF); TPL::tpSet($this->ATH, new S('ATH'), $tpF); TPL::tpSet($this->STG, new S('STG'), $tpF); TPL::tpSet($this->TXT, new S('TXT'), $tpF); TPL::tpSet($this->ART, new S('ART'), $tpF); TPL::tpSet($this->AUD, new S('AUD'), $tpF); TPL::tpSet($this->CNT, new S('CNT'), $tpF); TPL::tpSet($this->FAQ, new S('FAQ'), $tpF); TPL::tpSet($this->LRQ, new S('LRQ'), $tpF); TPL::tpExe($tpF); break; case FRONTEND_CONTACT_URL: // Go my baby ... GO ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'contact.tp'); TPL::tpSet($this->objURLImageDir, new S('objURLImageDir'), $tpF); TPL::tpSet($this->ATH, new S('ATH'), $tpF); TPL::tpSet($this->STG, new S('STG'), $tpF); TPL::tpSet($this->TXT, new S('TXT'), $tpF); TPL::tpSet($this->ART, new S('ART'), $tpF); TPL::tpSet($this->AUD, new S('AUD'), $tpF); TPL::tpSet($this->CNT, new S('CNT'), $tpF); TPL::tpSet($this->FAQ, new S('FAQ'), $tpF); TPL::tpSet($this->LRQ, new S('LRQ'), $tpF); TPL::tpExe($tpF); break; case FRONTEND_FAQ_URL: // Go my baby ... GO ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'faq.tp'); TPL::tpSet($this->objURLImageDir, new S('objURLImageDir'), $tpF); TPL::tpSet($this->ATH, new S('ATH'), $tpF); TPL::tpSet($this->STG, new S('STG'), $tpF); TPL::tpSet($this->TXT, new S('TXT'), $tpF); TPL::tpSet($this->ART, new S('ART'), $tpF); TPL::tpSet($this->AUD, new S('AUD'), $tpF); TPL::tpSet($this->CNT, new S('CNT'), $tpF); TPL::tpSet($this->FAQ, new S('FAQ'), $tpF); TPL::tpSet($this->LRQ, new S('LRQ'), $tpF); TPL::tpExe($tpF); break; case FRONTEND_LYRICS_URL: // Go my baby ... GO ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'lyrics.tp'); TPL::tpSet($this->objURLImageDir, new S('objURLImageDir'), $tpF); TPL::tpSet($this->ATH, new S('ATH'), $tpF); TPL::tpSet($this->STG, new S('STG'), $tpF); TPL::tpSet($this->TXT, new S('TXT'), $tpF); TPL::tpSet($this->ART, new S('ART'), $tpF); TPL::tpSet($this->AUD, new S('AUD'), $tpF); TPL::tpSet($this->CNT, new S('CNT'), $tpF); TPL::tpSet($this->FAQ, new S('FAQ'), $tpF); TPL::tpSet($this->LRQ, new S('LRQ'), $tpF); TPL::tpExe($tpF); break; case FRONTEND_AUDIO_URL: if (isset($_GET[AUDIO_ACTION_URL])) { // Do a switch ... switch ($_GET[AUDIO_ACTION_URL]) { case AUDIO_UPLOAD_URL: // Set the template file ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'audio-upload.tp'); break; } } else { // Set the template file ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'audio.tp'); } // Go my baby ... GO ... TPL::tpSet($this->objURLImageDir, new S('objURLImageDir'), $tpF); TPL::tpSet($this->ATH, new S('ATH'), $tpF); TPL::tpSet($this->STG, new S('STG'), $tpF); TPL::tpSet($this->TXT, new S('TXT'), $tpF); TPL::tpSet($this->ART, new S('ART'), $tpF); TPL::tpSet($this->AUD, new S('AUD'), $tpF); TPL::tpSet($this->CNT, new S('CNT'), $tpF); TPL::tpSet($this->FAQ, new S('FAQ'), $tpF); TPL::tpSet($this->LRQ, new S('LRQ'), $tpF); TPL::tpExe($tpF); break; case FRONTEND_PRODUCTS_URL: // Go my baby ... GO ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'products.tp'); TPL::tpSet($this->objURLImageDir, new S('objURLImageDir'), $tpF); TPL::tpSet($this->ATH, new S('ATH'), $tpF); TPL::tpSet($this->STG, new S('STG'), $tpF); TPL::tpSet($this->TXT, new S('TXT'), $tpF); TPL::tpSet($this->ART, new S('ART'), $tpF); TPL::tpSet($this->AUD, new S('AUD'), $tpF); TPL::tpSet($this->CNT, new S('CNT'), $tpF); TPL::tpSet($this->FAQ, new S('FAQ'), $tpF); TPL::tpSet($this->PRD, new S('PRD'), $tpF); TPL::tpSet($this->LRQ, new S('LRQ'), $tpF); TPL::tpExe($tpF); break; // TXTs ... them defaults; // TXTs ... them defaults; case FRONTEND_SECTION_URL: // Do a switch ... switch ($_GET[FRONTEND_SECTION_URL]) { case FRONTEND_HOME: // Damn, you're good ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'home.tp'); break; default: // Get'em tiger ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'content.tp'); break; } // Go my baby ... GO ... TPL::tpSet($this->objURLImageDir, new S('objURLImageDir'), $tpF); TPL::tpSet($this->ATH, new S('ATH'), $tpF); TPL::tpSet($this->STG, new S('STG'), $tpF); TPL::tpSet($this->TXT, new S('TXT'), $tpF); TPL::tpSet($this->ART, new S('ART'), $tpF); TPL::tpSet($this->AUD, new S('AUD'), $tpF); TPL::tpSet($this->CNT, new S('CNT'), $tpF); TPL::tpSet($this->FAQ, new S('FAQ'), $tpF); TPL::tpSet($this->LRQ, new S('LRQ'), $tpF); TPL::tpExe($tpF); break; ######################## THIS WILL NEVER - EVER - EVER - EVER - EVER - EVER CHANGE ######################## // RSS Feeds ... ######################## THIS WILL NEVER - EVER - EVER - EVER - EVER - EVER CHANGE ######################## // RSS Feeds ... case FRONTEND_RSS_XML: // Get the object ... $objRSS = TPL::getSitemapRSSOrXML(new S('RSS')); $objDTE = date(DATE_RFC822, $_SERVER['REQUEST_TIME']); $objTTL = $this->STG->getConfigKey(new S('settings_website_default_title')); $objXML = $objRSS->addCHILD(self::RSS_CHANNEL); $objXML->addCHILD(self::RSS_LINK, DOCUMENT_HOST); $objXML->addCHILD(self::RSS_PUBLISHED_DATE, $objDTE); $objXML->addCHILD(self::RSS_TITLE, $objTTL); $objXML->addCHILD(self::RSS_DESCRIPTION, $objTTL); // Go through ALL and XML my booty ... passed by reference ... yah baby! $this->AUD->renderWidget(new S('widgetRSS'), new A(array('objXML' => $objXML))); $this->ART->renderWidget(new S('widgetRSS'), new A(array('objXML' => $objXML))); $this->TXT->renderWidget(new S('widgetRSS'), new A(array('objXML' => $objXML))); $this->PRD->renderWidget(new S('widgetRSS'), new A(array('objXML' => $objXML))); // Do them XML ... TPL::outputXMLString(new S($objRSS->asXML())); break; // XML Sitemap ... // XML Sitemap ... case FRONTEND_STE_MAP: // Get the object ... $objXML = TPL::getSitemapRSSOrXML(new S('MAP')); if (isset($_GET['Type'])) { switch ($_GET['Type']) { case 'Lyrics': $this->LRQ->renderWidget(new S('widgetXML'), new A(array('objXML' => $objXML, 'objId' => $_GET['Id']))); break; } } else { // Go through ALL and XML my booty ... passed by reference ... yah baby! $this->AUD->renderWidget(new S('widgetXML'), new A(array('objXML' => $objXML))); $this->ART->renderWidget(new S('widgetXML'), new A(array('objXML' => $objXML))); $this->TXT->renderWidget(new S('widgetXML'), new A(array('objXML' => $objXML))); $this->PRD->renderWidget(new S('widgetXML'), new A(array('objXML' => $objXML))); } // Do them XML ... TPL::outputXMLString(new S($objXML->asXML())); break; // Errors ... (404, etc) // Errors ... (404, etc) case FRONTEND_ERROR_URL: // Check the code is defined ... or 404 if not ... if ($this->STG->checkErrorPageCodeIsUnique($this->objCOD = $_GET[FRONTEND_ERROR_URL])->toBoolean() == TRUE) { $this->setHeaderKey(URL::staticURL(new A(array(FRONTEND_ERROR_URL)), new A(array('404'))), new S('Location')); } // Set some requirements ... $this->objCDE = $this->STG->getErrorPageByCode($this->objCOD, Settings::$objSettingsErrTableFCode); $this->objTTL = $this->STG->getErrorPageByCode($this->objCOD, Settings::$objSettingsErrTableFTitle); $this->objCNT = $this->STG->getErrorPageByCode($this->objCOD, Settings::$objSettingsErrTableFContent); // Set the title ... TPL::manageTTL($this->objCDE); TPL::manageTTL($this->objTTL); // Set the template file ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'error.tp'); TPL::tpSet($this->objURLImageDir, new S('objURLImageDir'), $tpF); // Set'em vars ... TPL::tpSet($this->objCNT, new S('objCNT'), $tpF); TPL::tpSet($this->objTTL, new S('objTTL'), $tpF); TPL::tpSet($this->objCDE, new S('objCDE'), $tpF); TPL::tpSet($this->ATH, new S('ATH'), $tpF); TPL::tpSet($this->STG, new S('STG'), $tpF); TPL::tpSet($this->TXT, new S('TXT'), $tpF); TPL::tpSet($this->ART, new S('ART'), $tpF); TPL::tpSet($this->AUD, new S('AUD'), $tpF); TPL::tpSet($this->CNT, new S('CNT'), $tpF); TPL::tpSet($this->FAQ, new S('FAQ'), $tpF); TPL::tpExe($tpF); break; } }