/** * Will render a requested widget; * * This method is used to render a widget that usually is used in the frontend part of any website done with the help of this * platform. What are widgets you ask?! Well, it's quite simple. They are pieces of PHP code, usually tied to some * configuration options that control the way the widget functions or showns; * * Usually, configured widgets have enough power to be used in any way you want or need. For most of the times, the widgets * are called in the proper section of the frontend, but this method must permit the use of widgets, independent of the place * the developer needs them; * * @param $objW The widget to render; * @return mixed Depends on the widget; */ public function renderWidget(S $objW, A $objWA = NULL) { // Make an empty array if NULL ... if ($objWA == NULL) { $objWA = new A(); } // XML & RSS: Do a switch ... switch ($objW) { case 'widgetXML': // BK; break; case 'widgetRSS': // BK; break; } // HTML: Do a switch ... switch ($objW) { case 'widgetCategoryList': // Set some requirements ... if ($objWA == NULL) { $objWA = new A(); } // Get the category to start from ... if (isset($objWA['start_from_category'])) { // Get the category LIST; $objCategoryList = $this->getCategories(NULL, $objWA['start_from_category']); } else { // Get the category LIST; $objCategoryList = $this->getCategories(NULL, NULL); } // Set the template file ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION); TPL::tpSet($objCategoryList, new S('objCategoryList'), $tpF); TPL::tpSet($objWA, new S('objWidgetArray'), $tpF); TPL::tpSet($this, new S('ART'), $tpF); TPL::tpExe($tpF); break; case 'widgetList': // Check some needed requirements ... if ($_GET[FRONTEND_SECTION_URL] == FRONTEND_PRODUCTS_URL) { // Set some requirements ... $objPag = isset($_GET[PRODUCTS_PAGE_URL]) ? $_GET[PRODUCTS_PAGE_URL] : new S((string) 1); if (isset($_GET[PRODUCTS_ITEM_URL])) { // Check that the article exists, before doing anything stupid ... if ($this->checkProductURLIsUnique($objURL = $_GET[PRODUCTS_ITEM_URL])->toBoolean() == TRUE) { // Make the proper header, at first ... $this->setHeaderStr(new S(HDR::HEADER_404_NOT_FOUND)); // Give me back my free hardcore, Quoth the server, '404' ... $this->setHeaderKey(URL::staticURL(new A(array(FRONTEND_ERROR_URL)), new A(array('404'))), new S('Location')); } else { // Do me SEO, yah baby! ... TPL::manageTTL($this->getProductInfoByURL($objURL, self::$objProductsTableFName)); TPL::manageTAG(new S('description'), $this->getProductInfoByURL($objURL, self::$objProductsTableFDescription)->entityDecode(ENT_QUOTES)->stripTags()->doToken(_QOT, _NONE)); // Set some requirements ... $objPathToItem = self::$objMPTT->mpttGetSinglePath($this->getCategoryInfoById($this->getProductInfoByURL($objURL, self::$objProductsTableFCategoryId), self::$objCategoryTableFName)); $objItemPpties = $this->getPropertiesByProductURL($objURL); $objItemImages = $this->getImagesByProductURL($objURL); if ($objItemImages->doCount()->toInt() != 0) { $objItemHasImg = new B(TRUE); } else { $objItemHasImg = new B(FALSE); } // Set the template file ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . '-Item.tp'); TPL::tpSet($objPathToItem, new S('objPathToItem'), $tpF); TPL::tpSet($objItemPpties, new S('objItemPpties'), $tpF); TPL::tpSet($objItemImages, new S('objItemImages'), $tpF); TPL::tpSet($objItemHasImg, new S('objItemHasImg'), $tpF); TPL::tpSet($objWA, new S('objWidgetArray'), $tpF); TPL::tpSet($objURL, new S('objURL'), $tpF); TPL::tpSet($this->ATH, new S('ATH'), $tpF); TPL::tpSet($this->STG, new S('STG'), $tpF); TPL::tpSet($this, new S('PRD'), $tpF); TPL::tpExe($tpF); } } else { if (isset($_GET[PRODUCTS_CATEGORY_URL])) { // Check that the category exists, before doing anything stupid ... if ($this->checkCategoryURLIsUnique($objCat = $_GET[PRODUCTS_CATEGORY_URL])->toBoolean() == TRUE) { // Make the proper header, at first ... $this->setHeaderStr(new S(HDR::HEADER_404_NOT_FOUND)); // Give me back my free hardcore, Quoth the server, '404' ... $this->setHeaderKey(URL::staticURL(new A(array(FRONTEND_ERROR_URL)), new A(array('404'))), new S('Location')); } else { // Do me SEO, yah baby! ... err('Here'); } } else { // Do me SEO, yah baby! ... TPL::manageTTL(_S(FRONTEND_PRODUCTS_URL)); TPL::manageTTL(_S(PRODUCTS_PAGE_URL)->appendString(_SP)->appendString($objPag)); // Set some requirements ... $objCnt = $this->getProductCount(); $objArt = $this->getProductsByPage($objPag); } // Set the template file ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION); TPL::tpSet($objWA, new S('objWidgetArray'), $tpF); TPL::tpSet($objArt, new S('objAr'), $tpF); TPL::tpSet($this, new S('PRD'), $tpF); TPL::tpExe($tpF); // Set them paginations ... if ($objCnt->toInt() > (int) self::$objItemsPerPage->toString()) { self::$objFrontend->setPagination($objCnt, new I((int) self::$objItemsPerPage->toString())); } } } else { // Do the biggest error on the PLANET ... self::renderScreenOfDeath(new S(__CLASS__), new S(ARTICLES_NEED_PROPER_SECTION), new S(ARTICLES_NEED_PROPER_SECTION_FIX)); } // BK; break; } }
/** * Will render a requested widget; * * This method is used to render a widget that usually is used in the frontend part of any website done with the help of this * platform. What are widgets you ask?! Well, it's quite simple. They are pieces of PHP code, usually tied to some * configuration options that control the way the widget functions or showns; * * Usually, configured widgets have enough power to be used in any way you want or need. For most of the times, the widgets * are called in the proper section of the frontend, but this method must permit the use of widgets, independent of the place * the developer needs them; * * @param $objW The widget to render; * @return mixed Depends on the widget; */ public function renderWidget(S $objW, A $objWA = NULL) { // Make an empty array if NULL ... if ($objWA == NULL) { $objWA = new A(); } // XML & RSS: Do a switch ... switch ($objW) { case 'widgetXML': // Yo man ... woohoooooo ... foreach ($this->getPublishedArticles(new S('ORDER BY %objArticleTableFDatePublished DESC')) as $k => $v) { // Set some requirements ... $objDTE = date('Y-m-d', (int) $v[self::$objArticleTableFDatePublished]->toString()); $objLOC = URL::staticURL(new A(array(ARTICLES_ARTICLES_URL, FRONTEND_SECTION_URL)), new A(array($v[self::$objArticleTableFSEO], FRONTEND_ARTICLE_URL))); // Get the (INNER) CHILD of every young SEO freak ... $objURL = $objWA['objXML']->addCHILD(Frontend::XML_URL); // Set the XML Sitemap kids ... $objURL->addCHILD(Frontend::XML_LOCATION, $objLOC); $objURL->addCHILD(Frontend::XML_LAST_MOD, $objDTE); $objURL->addCHILD(Frontend::XML_CHANGE_FREQ, self::XML_SITEMAP_FREQUENCY); $objURL->addCHILD(Frontend::XML_PRIORITY, self::XML_SITEMAP_PRIORITY); } // BK; break; case 'widgetRSS': // Yo man ... woohoooooo ... if ($_GET[FRONTEND_FEED_URL] == __CLASS__) { // Get'em 30 ... foreach ($this->getPublishedArticles(new S('ORDER BY %objArticleTableFDatePublished DESC LIMIT 0, 30')) as $k => $v) { // Set some requirements ... $objDTE = date(DATE_RFC822, (int) $v[self::$objArticleTableFDatePublished]->toString()); $objLOC = URL::staticURL(new A(array(ARTICLES_ARTICLES_URL, FRONTEND_SECTION_URL)), new A(array($v[self::$objArticleTableFSEO], FRONTEND_ARTICLE_URL))); $objDSC = $v[self::$objArticleTableFExcerpt]->entityEncode(ENT_QUOTES)->entityDecode(ENT_QUOTES)->stripTags(); $objTTL = $v[self::$objArticleTableFTitle]; // Get the (INNER) CHILD of every young SEO freak ... $objURL = $objWA['objXML']->addCHILD(Frontend::RSS_ITEM); // Set the RSS kids ... $objURL->addCHILD(Frontend::RSS_TITLE, $objTTL); $objURL->addCHILD(Frontend::RSS_LINK, $objLOC); $objURL->addCHILD(Frontend::RSS_GUID, $objLOC); $objURL->addCHILD(Frontend::RSS_PUBLISHED_DATE, $objDTE); $objURL->addCHILD(Frontend::RSS_DESCRIPTION, $objDSC); } } // BK; break; } // HTML: Do a switch ... switch ($objW) { case 'widgetCategoryList': // Set the template file ... if ($cId = TPL::tpIni($tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION), new I(180))) { // Get the category to start from ... if (isset($objWA['start_from_category'])) { // Get the category LIST; $objCategoryList = $this->getCategories(NULL, $objWA['start_from_category']); } else { // Get the category LIST; $objCategoryList = $this->getCategories(NULL, NULL); } // Set the template file ... TPL::tpSet($objCategoryList, new S('objCategoryList'), $tpF); TPL::tpSet($objWA, new S('objWidgetArray'), $tpF); TPL::tpSet($this, new S('ART'), $tpF); TPL::tpExe($tpF); TPL::tpEnd($cId); } // BK; break; case 'widgetList': // Check some needed requirements ... if ($_GET[FRONTEND_SECTION_URL] == FRONTEND_ARTICLE_URL) { // Set some requirements ... $objPag = isset($_GET[ARTICLES_PAGE_URL]) ? $_GET[ARTICLES_PAGE_URL] : new S((string) 1); if (isset($_GET[ARTICLES_ARTICLES_URL])) { // Check that the article exists, before doing anything stupid ... if ($this->checkArticleURLIsUnique($objURL = $_GET[ARTICLES_ARTICLES_URL])->toBoolean() == TRUE) { // Make the proper header, at first ... $this->setHeaderStr(new S(HDR::HEADER_404_NOT_FOUND)); // Give me back my free hardcore, Quoth the server, '404' ... $this->setHeaderKey(URL::staticURL(new A(array(FRONTEND_ERROR_URL)), new A(array('404'))), new S('Location')); } else { // Update them views ... $this->_Q(_QS('doUPDATE')->doToken('%table', self::$objArticleTable)->doToken('%condition', _S('%objArticleTableFViews = %objArticleTableFViews + 1 WHERE %objArticleTableFSEO = "%Id"')->doToken('%Id', $_GET[ARTICLES_ARTICLES_URL]))); // Do me SEO, yah baby! ... (add title and category name, cause we need it) TPL::manageTTL($this->getArticleInfoByURL($objURL, self::$objArticleTableFTitle)); TPL::manageTTL(MPTT::mpttRemoveUnique($this->getCategoryInfoById($this->getArticleInfoByURL($objURL, self::$objArticleTableFCategoryId), self::$objCategoryTableFName))); // Do me SEO, yah baby! ... (add keywords and description, for something extra) TPL::manageTAG(new S('keywords'), $this->getArticleInfoByURL($objURL, self::$objArticleTableFTags)); TPL::manageTAG(new S('description'), $this->getArticleInfoByURL($objURL, self::$objArticleTableFTitle)->appendString(_DCSP)->appendString($this->getArticleInfoByURL($objURL, self::$objArticleTableFExcerpt))->doToken(_QOT, _NONE)); // Set the template file ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . '-Item.tp'); TPL::tpSet($objWA, new S('objWidgetArray'), $tpF); TPL::tpSet($this->ATH, new S('ATH'), $tpF); TPL::tpSet($this->STG, new S('STG'), $tpF); TPL::tpSet($objURL, new S('objURL'), $tpF); TPL::tpSet($this, new S('ART'), $tpF); TPL::tpExe($tpF); } } else { if (isset($_GET[ARTICLES_CATEGORY_URL])) { // Check that the category exists, before doing anything stupid ... if ($this->checkCategoryURLIsUnique($objCat = $_GET[ARTICLES_CATEGORY_URL])->toBoolean() == TRUE) { // Make the proper header, at first ... $this->setHeaderStr(new S(HDR::HEADER_404_NOT_FOUND)); // Give me back my free hardcore, Quoth the server, '404' ... $this->setHeaderKey(URL::staticURL(new A(array(FRONTEND_ERROR_URL)), new A(array('404'))), new S('Location')); } else { // Do me SEO, yah baby! ... (title and pagination to prev. duplicates) TPL::manageTTL(_S(ARTICLES_PAGE_URL)->appendString(_SP)->appendString($objPag)); TPL::manageTTL(MPTT::mpttRemoveUnique($this->getCategoryInfoByURL($objCat, self::$objCategoryTableFName))); // Do me SEO, yah baby! ... (add cat. descr) if ($this->getCategoryInfoByURL($objCat, self::$objCategoryTableFDescription)->toLength()->toInt() != 0) { TPL::manageTAG(new S('description'), $this->getCategoryInfoByURL($objCat, self::$objCategoryTableFDescription)->entityDecode(ENT_QUOTES)->stripTags()->doToken(_QOT, _NONE)->doSubStr(0, META_DESCRIPTION_MAX)->appendString(_SP)->appendString(_DTE)); } // Set some requirements ... $objCnt = $this->getPublishedArticleCountForCategoryURL($objCat); $objStk = $this->getStickyArticlesByCategoryURLAndPage($objCat, $objPag); $objArt = $this->getPublishedArticlesByCategoryURLAndPage($objCat, $objPag); $objInC = new B(TRUE); } } else { // Do me SEO, yah baby! ... TPL::manageTTL(_S(FRONTEND_ARTICLE_URL)); TPL::manageTTL(_S(ARTICLES_PAGE_URL)->appendString(_SP)->appendString($objPag)); // Set some requirements ... $objCnt = $this->getPublishedArticleCount(); $objStk = $this->getStickyArticlesByPage($objPag); $objArt = $this->getPublishedArticlesByPage($objPag); $objInC = new B(FALSE); $objCat = new S(); } // Set the template file ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION); TPL::tpSet($objWA, new S('objWidgetArray'), $tpF); TPL::tpSet($objInC, new S('objInC'), $tpF); TPL::tpSet($objCat, new S('objCat'), $tpF); TPL::tpSet($objArt, new S('objArt'), $tpF); TPL::tpSet($objStk, new S('objStk'), $tpF); TPL::tpSet($this, new S('ART'), $tpF); TPL::tpExe($tpF); // Set them paginations ... if ($objCnt->toInt() > (int) self::$objItemsPerPage->toString()) { self::$objFrontend->setPagination($objCnt, new I((int) self::$objItemsPerPage->toString())); } } } else { // Do the biggest error on the PLANET ... self::renderScreenOfDeath(new S(__CLASS__), new S(ARTICLES_NEED_PROPER_SECTION), new S(ARTICLES_NEED_PROPER_SECTION_FIX)); } // BK; break; case 'widgetComments': // Check if we have the proper URL enabled ... if (isset($_GET[ARTICLES_ARTICLES_URL])) { // Check if the comments are enabled ... if ($this->getArticleInfoByURL($_GET[ARTICLES_ARTICLES_URL], self::$objArticleTableFCanComment) == 'Y') { // Set some requirements ... $objCommentIsOk = new S(); $objShowComm = new B(TRUE); $objComments = $this->getApprovedCommentsByArticleURL($_GET[ARTICLES_ARTICLES_URL], new S('ORDER BY %objCommentsTableFDate DESC')); // Check for status ... if (isset($_GET[ARTICLES_STATUS_URL])) { if ($_GET[ARTICLES_STATUS_URL] == ARTICLES_STATUS_OK_URL) { $objCommentIsOk = new S($objWA['comment_has_been_added']); } } // Set some requirements ... $objShowFrm = new B(TRUE); // Check if we're allowed to show the comment form ... if ($this->getConfigKey(new S('article_settings_article_auth_to_comment')) == 'Y') { if ($this->ATH->checkIfUserIsLoggedIn()->toBoolean() == TRUE) { $objShowFrm = new B(TRUE); } else { $objShowFrm = new B(FALSE); } } // Set the template file ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION); TPL::tpSet($objCommentIsOk, new S('objCommentIsOk'), $tpF); TPL::tpSet($objComments, new S('objComments'), $tpF); TPL::tpSet($objShowComm, new S('objShowComm'), $tpF); TPL::tpSet($objShowFrm, new S('objShowFrm'), $tpF); TPL::tpSet($objWA, new S('objWidgetArray'), $tpF); TPL::tpSet($this->STG, new S('STG'), $tpF); TPL::tpSet($this->ATH, new S('ATH'), $tpF); TPL::tpExe($tpF); // Do some work ... if ($objShowFrm->toBoolean() == TRUE) { if ($this->checkPOST(self::$objCommentsTableFComment)->toBoolean() == TRUE) { if ($this->getPOST(self::$objCommentsTableFComment)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objCommentsTableFComment, new S($objWA['error_no_comment'])); } } if ($this->checkPOST(self::$objCommentsTableFName)->toBoolean() == TRUE) { if ($this->getPOST(self::$objCommentsTableFName)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objCommentsTableFName, new S($objWA['error_no_name'])); } } if ($this->checkPOST(self::$objCommentsTableFEML)->toBoolean() == TRUE) { if ($this->getPOST(self::$objCommentsTableFEML)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objCommentsTableFEML, new S($objWA['error_no_email'])); } } // Make the form ... (ya, outside the box ...); $this->setMethod(new S('POST'))->setFieldset(new S($objWA['comment_add']))->setSQLAction(new S('update'))->setTableName(self::$objCommentsTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objCommentsTableFId)->setRedirect(URL::rewriteURL(new A(array(ARTICLES_STATUS_URL)), new A(array(ARTICLES_STATUS_OK_URL))))->setName(new S('commentForm'))->setExtraUpdateData(self::$objCommentsTableFDate, new S((string) time()))->setExtraUpdateData(self::$objCommentsTableFArticleId, $this->getArticleInfoByURL($_GET[ARTICLES_ARTICLES_URL], self::$objArticleTableFId))->setInputType(new S('submit'))->setValue(new S($objWA['comment_submit']))->setName(new S('submit'))->setContainerDiv(new B(TRUE)); // Check if the user is authenticated ... if ($this->ATH->checkIfUserIsLoggedIn()->toBoolean() == TRUE) { // Set the RUId; $this->setExtraUpdateData(self::$objCommentsTableFRUId, $this->ATH->getCurrentUserInfoById(Authentication::$objAuthUsersTableFId)); } else { // Set the other infos; $this->setInputType(new S('text'))->setName(self::$objCommentsTableFName)->setLabel(new S($objWA['comment_name']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objCommentsTableFEML)->setLabel(new S($objWA['comment_email']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objCommentsTableFURL)->setLabel(new S($objWA['comment_website']))->setContainerDiv(new B(TRUE)); } // Continue ... $this->setInputType(new S('textarea'))->setName(self::$objCommentsTableFComment)->setLabel(new S($objWA['comment_message']))->setTinyMCETextarea(new B(TRUE))->setClass(new S('tinyMCESimple'))->setRows(new S('10'))->setContainerDiv(new B(TRUE)); // Notify ... if ($this->checkFormHasErrors()->toBoolean() == FALSE && $this->checkPOST(self::$objCommentsTableFComment)->toBoolean() == TRUE) { // Get some needed requirements .. $objURL = $_GET[ARTICLES_ARTICLES_URL]; if ($this->ATH->checkIfUserIsLoggedIn()->toBoolean() == TRUE) { // Query the authentication ... $objUSR = $this->ATH->getCurrentUserInfoById(Authentication::$objAuthUsersTableFUName); } else { // Or trust the FORM ... $objUSR = $this->getPOST(self::$objCommentsTableFName); } // Go and SP ... MAIL me ... $objMAIL = new MAIL(); $objMAIL->doMAIL($this->STG->getConfigKey(new S('settings_website_notification_email')), new S(ARTICLES_COMMENT_HAS_BEEN_POSTED), $this->getHELP(new S('widgetCommentsCommentPosted'))->doToken('%u', $objUSR)); } // End form and execute ... $this->setFormEndAndExecute(new B(TRUE)); } } } // BK; break; } }
/** * 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 renderForm(S $objFormToRender, A $objFA = NULL) { // Make them defaults ... if ($objFA == NULL) { $objFA = new A(); } // Do a switch ... switch ($objFormToRender) { case 'uploadForm': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(AUDIO_STATUS_URL)), new A(array(AUDIO_STATUS_OK_URL))); // Do some work ... if ($this->checkPOST(self::$objAudioTableFTitle)->toBoolean() == TRUE) { // Check non empty ... if ($this->getPOST(self::$objAudioTableFTitle)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objAudioTableFTitle, new S($objFA['error_title_empty'])); } } if ($this->checkPOST(self::$objAudioTableFArtist)->toBoolean() == TRUE) { // Check non empty ... if ($this->getPOST(self::$objAudioTableFArtist)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objAudioTableFArtist, new S($objFA['error_artist_empty'])); } } if ($this->checkPOST(self::$objAudioTableFAlbum)->toBoolean() == TRUE) { // Check non empty ... if ($this->getPOST(self::$objAudioTableFAlbum)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objAudioTableFAlbum, new S($objFA['error_album_empty'])); } } // Check & Get; $this->getAjaxErrors(); // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S($objFA['upload_audio_file']))->setSQLAction(new S('update'))->setTableName(self::$objAudioTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objAudioTableFId)->setExtraUpdateData(self::$objAudioTableFUploadedDate, new S((string) $_SERVER['REQUEST_TIME']))->setExtraUpdateData(self::$objAudioTableFUploaderId, $this->ATH->getCurrentUserInfoById(Authentication::$objAuthUsersTableFId))->setExtraUpdateData(self::$objAudioTableFApproved, new S('N'))->setUploadDirectory(new S('audio/mp3/' . date('Y/m/d', $_SERVER['REQUEST_TIME'])))->setUploadImageResize(new A(array(128 => 128, 640 => 480, 800 => 600))); // Add the URL ... if ($this->checkPOST(self::$objAudioTableFTitle)->toBoolean() == TRUE && $this->checkPOST(self::$objAudioTableFArtist)->toBoolean() == TRUE) { // CLONE them little monkeys ... $objURL = clone $this->getPOST(self::$objAudioTableFTitle); $objART = clone $this->getPOST(self::$objAudioTableFArtist); // CONCAT'enate them ... $this->setExtraUpdateData(self::$objAudioTableFSEO, URL::getURLFromString($objURL->appendString(_U)->appendString($objART)->appendString(_U)->appendString((string) $_SERVER['REQUEST_TIME']))); } // Continue ... $this->setName($objFormToRender)->setRedirect($objURLToGoBack)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setValue(new S($objFA['upload_audio_file']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAudioTableFTitle)->setLabel(new S($objFA['audio_file_title']))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(self::$objAudioTableFCategoryId)->setLabel(new S($objFA['audio_file_category']))->setContainerDiv(new B(TRUE)); // Categories ... foreach ($this->getCategories() as $k => $v) { $this->setInputType(new S('option'))->setName($v[self::$objMPTT->objIdField])->setValue($v[self::$objMPTT->objIdField])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . MPTT::mpttRemoveUnique($v[self::$objMPTT->objNameOfNode]))); } // Continue ... $this->setInputType(new S('text'))->setName(self::$objAudioTableFArtist)->setLabel(new S($objFA['audio_file_artist']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAudioTableFAlbum)->setLabel(new S($objFA['audio_file_album']))->setContainerDiv(new B(TRUE))->setInputType(new S('file'))->setName(self::$objAudioTableFFile)->setLabel(new S($objFA['audio_file_file']))->setContainerDiv(new B(TRUE))->setInputType(new S('file'))->setName(self::$objAudioTableFArtwork)->setLabel(new S($objFA['audio_file_artwork']))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAudioTableFLyrics)->setLabel(new S($objFA['audio_file_lyrics']))->setTinyMCETextarea(new B(TRUE))->setClass(new S('tinyMCESimple'))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAudioTableFDescription)->setLabel(new S($objFA['audio_file_description']))->setTinyMCETextarea(new B(TRUE))->setClass(new S('tinyMCESimple'))->setContainerDiv(new B(TRUE)); // Notify ... if ($this->checkFormHasErrors()->toBoolean() == FALSE) { // Go ... $objMAIL = new MAIL(); $objMAIL->doMAIL($this->STG->getConfigKey(new S('settings_website_notification_email')), new S(AUDIO_FRONT_FILE_HAS_BEEN_UPLOADED), $this->getHELP(new S('uploadFormEMLMessage'))->doToken('%t', $this->getPOST(self::$objAudioTableFTitle))->doToken('%a', $this->getPOST(self::$objAudioTableFArtist))->doToken('%b', $this->getPOST(self::$objAudioTableFAlbum))->doToken('%u', $this->ATH->getCurrentUserInfoById(Authentication::$objAuthUsersTableFUName))); } // End form and execute ... $this->setFormEndAndExecute(new B(TRUE)); break; case 'audioSearchOnFrontend': // Do the form, make it happen ... $this->setMethod(new S('POST'))->setName($objFormToRender); // Do some work ... if ($this->checkPOST(new S('search'))->toBoolean() == TRUE) { // Get the title, and check it's name ... if ($this->getPOST(new S('audio_file_title'))->toLength()->toInt() == 0) { // Well, sadly, we have an issue ... $this->setErrorOnInput(new S('audio_file_title'), new S($objFA['error_empty_search'])); } else { // Notify ... $objMAIL = new MAIL(); $objMAIL->doMAIL($this->STG->getConfigKey(new S('settings_website_notification_email')), new S(AUDIO_SEARCH_HAS_BEEN_PERFORMED), $this->getHELP(new S('audioSearchOnFrontend'))->doToken('%s', $this->getPOST(new S('audio_file_title')))); // Go ... $this->setHeaderKey($objURLToGoBack = URL::staticURL(new A(array(FRONTEND_SECTION_URL, AUDIO_SEARCH_URL)), new A(array(FRONTEND_AUDIO_URL, $this->getPOST(new S('audio_file_title'))->entityDecode(ENT_QUOTES)->stripSlashes()))), new S('Location')); } } // Continue ... $this->setInputType(new S('submit'))->setName(new S('search'))->setValue(new S($objFA['search_submit']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(new S('audio_file_title')); // If it's set ... add the VALUE ... if (isset($_GET[AUDIO_SEARCH_URL])) { $this->setValue($_GET[AUDIO_SEARCH_URL]); } // Continue ... $this->setLabel(new S($objFA['search_title']))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'audioSearch': // Get some predefines; if (isset($_GET[ADMIN_ACTION_BY])) { $objSearchBy = $_GET[ADMIN_ACTION_BY]; } else { $objSearchBy = new S(); } if (isset($_GET[ADMIN_ACTION_SEARCH])) { $objSearchWas = $_GET[ADMIN_ACTION_SEARCH]; } else { $objSearchWas = new S(); } // Do some work; if ($this->checkPOST(new S('search_submit'))->toBoolean() == TRUE) { if ($this->getPOST(new S('search_by'))->toLength()->toInt() == 0) { if (isset($_GET[ADMIN_ACTION_SEARCH])) { // Erase search terms ... $this->setHeaderKey(URL::rewriteURL(new A(array(ADMIN_ACTION_SEARCH, ADMIN_ACTION_BY))), new S('Location')); } // Set an input error; $this->setErrorOnInput(new S('search_by'), new S(AUDIO_SEARCH_FIELD_IS_EMPTY)); // Unset the post ... $this->unsetPOST(); } else { // Get what to search and where ... $objWhatToSearch = $this->getPOST(new S('search_by')); $objWhereToSearch = $this->getPOST(new S('search_field')); // And go there ... $this->setHeaderKey(URL::rewriteURL(new A(array(ADMIN_ACTION_SEARCH, ADMIN_ACTION_BY)), new A(array($objWhatToSearch, $objWhereToSearch))), new S('Location')); } } // Check the option that has been selected; $objWasSelected = new A(array(new B($objSearchBy == AUDIO_SEARCH_TITLE ? TRUE : FALSE), new B($objSearchBy == AUDIO_SEARCH_ARTIST ? TRUE : FALSE), new B($objSearchBy == AUDIO_SEARCH_ALBUM ? TRUE : FALSE))); // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(AUDIO_SEARCH_BY))->setName($objFormToRender)->setInputType(new S('text'))->setInputInfoMessage($this->getHELP($objFormToRender))->setName(new S('search_by'))->setvalue($objSearchWas)->setLabel(new S(AUDIO_SEARCH_BY))->setJSRegExpReplace(new S('[^a-zA-Z0-9 -]'))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(new S('search_field'))->setContainerDiv(new B(TRUE))->setLabel(new S(AUDIO_SEARCH_IN))->setInputType(new S('option'))->setName(new S('article_title'))->setValue(new S(AUDIO_SEARCH_TITLE))->setLabel(new S(AUDIO_SEARCH_TITLE))->setSelected($objWasSelected[0])->setInputType(new S('option'))->setName(new S('article_content'))->setValue(new S(AUDIO_SEARCH_ARTIST))->setLabel(new S(AUDIO_SEARCH_ARTIST))->setSelected($objWasSelected[1])->setInputType(new S('option'))->setName(new S('article_category'))->setValue(new S(AUDIO_SEARCH_ALBUM))->setLabel(new S(AUDIO_SEARCH_ALBUM))->setSelected($objWasSelected[2])->setInputType(new S('submit'))->setContainerDiv(new B(TRUE))->setValue(new S(AUDIO_SEARCH_BY))->setName(new S('search_submit'))->setFormEndAndExecute(new B(TRUE)); break; case 'audioCreate': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(); $objUPDirectory = date('Y/m/d', $_SERVER['REQUEST_TIME']); // Do some work ... if ($this->checkPOST(self::$objAudioTableFTitle)->toBoolean() == TRUE) { // Check non empty ... if ($this->getPOST(self::$objAudioTableFTitle)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objAudioTableFTitle, new S(AUDIO_TITLE_REQUIRED)); } } if ($this->checkPOST(self::$objAudioTableFArtist)->toBoolean() == TRUE) { // Check non empty ... if ($this->getPOST(self::$objAudioTableFArtist)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objAudioTableFArtist, new S(AUDIO_ARTIST_REQUIRED)); } } if ($this->checkPOST(self::$objAudioTableFAlbum)->toBoolean() == TRUE) { // Check non empty ... if ($this->getPOST(self::$objAudioTableFAlbum)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objAudioTableFAlbum, new S(AUDIO_ALBUM_REQUIRED)); } } // Check & Get; $this->getAjaxErrors(); // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(AUDIO_ADD_AUDIO))->setSQLAction(new S('update'))->setTableName(self::$objAudioTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objAudioTableFId)->setExtraUpdateData(self::$objAudioTableFUploaderId, $this->ATH->getCurrentUserInfoById(Authentication::$objAuthUsersTableFId))->setUploadDirectory(new S('audio/mp3/' . $objUPDirectory))->setUploadImageResize(new A(array(128 => 128, 640 => 480, 800 => 600))); // Add the URL ... if ($this->checkPOST(self::$objAudioTableFTitle)->toBoolean() == TRUE && $this->checkPOST(self::$objAudioTableFArtist)->toBoolean() == TRUE) { // CLONE them little monkeys ... $objURL = clone $this->getPOST(self::$objAudioTableFTitle); $objART = clone $this->getPOST(self::$objAudioTableFArtist); // CONCAT'enate them ... $this->setExtraUpdateData(self::$objAudioTableFSEO, URL::getURLFromString($objURL->appendString(_U)->appendString($objART)->appendString(_U)->appendString((string) $_SERVER['REQUEST_TIME']))); } // Continue ... $this->setName($objFormToRender); if ($this->checkPOST(self::$objAudioTableFTitle)->toBoolean() == TRUE) { $this->setRedirect($objURLToGoBack); } $this->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setValue(new S(AUDIO_ADD_AUDIO))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(self::$objAudioTableFApproved)->setLabel(new S(AUDIO_FILE_APPROVED))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('yes'))->setValue(new S('Y'))->setLabel(new S(AUDIO_FILE_APPROVED_YES))->setInputType(new S('option'))->setName(new S('no'))->setValue(new S('N'))->setLabel(new S(AUDIO_FILE_APPROVED_NO))->setInputType(new S('select'))->setName(self::$objAudioTableFCanComment)->setLabel(new S(AUDIO_CAN_COMMENT))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('no'))->setValue(new S('N'))->setLabel(new S(AUDIO_CAN_COMMENT_NO))->setInputType(new S('option'))->setName(new S('yes'))->setValue(new S('Y'))->setLabel(new S(AUDIO_CAN_COMMENT_YES))->setInputType(new S('text'))->setName(self::$objAudioTableFTitle)->setLabel(new S(AUDIO_FILE_TITLE))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(self::$objAudioTableFCategoryId)->setLabel(new S(AUDIO_FILE_CATEGORY))->setContainerDiv(new B(TRUE)); // Categories ... foreach ($this->getCategories() as $k => $v) { $this->setInputType(new S('option'))->setName($v[self::$objMPTT->objIdField])->setValue($v[self::$objMPTT->objIdField])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . MPTT::mpttRemoveUnique($v[self::$objMPTT->objNameOfNode]))); } // Continue ... $this->setInputType(new S('file'))->setName(self::$objAudioTableFFile)->setLabel(new S(AUDIO_FILE))->setContainerDiv(new B(TRUE))->setInputType(new S('file'))->setName(self::$objAudioTableFArtwork)->setLabel(new S(AUDIO_FILE_ARTWORK))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAudioTableFArtist)->setLabel(new S(AUDIO_FILE_ARTIST))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAudioTableFAlbum)->setLabel(new S(AUDIO_FILE_ALBUM))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAudioTableFLyrics)->setLabel(new S(AUDIO_FILE_LYRICS))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAudioTableFDescription)->setLabel(new S(AUDIO_FILE_DESCRIPTION))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'audioEdit': // God send us our info ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'audioEditInfo.tp'); TPL::tpSet($this, new S('AUD'), $tpF); TPL::tpExe($tpF); // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); $objUPDirectory = date('Y/m/d', (int) $this->getAudioFileInfoById($_GET[ADMIN_ACTION_ID], self::$objAudioTableFUploadedDate)->toString()); // Check & Get; $this->getAjaxErrors(); // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(AUDIO_EDIT_AUDIO))->setSQLAction(new S('update'))->setTableName(self::$objAudioTable)->setUpdateId($_GET[ADMIN_ACTION_ID])->setUpdateField(self::$objAudioTableFId)->setUploadDirectory(new S('audio/mp3/' . $objUPDirectory))->setUploadImageResize(new A(array(128 => 128, 640 => 480, 800 => 600))); // Add the URL ... if ($this->checkPOST(self::$objAudioTableFTitle)->toBoolean() == TRUE && $this->checkPOST(self::$objAudioTableFArtist)->toBoolean() == TRUE) { // CLONE them little monkeys ... $objURL = clone $this->getPOST(self::$objAudioTableFTitle); $objART = clone $this->getPOST(self::$objAudioTableFArtist); // CONCAT'enate them ... $this->setExtraUpdateData(self::$objAudioTableFSEO, URL::getURLFromString($objURL->appendString(_U)->appendString($objART)->appendString(_U)->appendString($this->getAudioFileInfoById($_GET[ADMIN_ACTION_ID], self::$objAudioTableFUploadedDate)))); } // Continue ... $this->setName($objFormToRender)->setRedirect($objURLToGoBack)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setValue(new S(AUDIO_EDIT_AUDIO))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(self::$objAudioTableFApproved)->setLabel(new S(AUDIO_FILE_APPROVED))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('yes'))->setValue(new S('Y'))->setLabel(new S(AUDIO_FILE_APPROVED_YES))->setInputType(new S('option'))->setName(new S('no'))->setValue(new S('N'))->setLabel(new S(AUDIO_FILE_APPROVED_NO))->setInputType(new S('select'))->setName(self::$objAudioTableFCanComment)->setLabel(new S(AUDIO_CAN_COMMENT))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('no'))->setValue(new S('N'))->setLabel(new S(AUDIO_CAN_COMMENT_NO))->setInputType(new S('option'))->setName(new S('yes'))->setValue(new S('Y'))->setLabel(new S(AUDIO_CAN_COMMENT_YES))->setInputType(new S('text'))->setName(self::$objAudioTableFTitle)->setLabel(new S(AUDIO_FILE_TITLE))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(self::$objAudioTableFCategoryId)->setLabel(new S(AUDIO_FILE_CATEGORY))->setContainerDiv(new B(TRUE)); // Categories ... foreach ($this->getCategories() as $k => $v) { $this->setInputType(new S('option'))->setName($v[self::$objMPTT->objIdField])->setValue($v[self::$objMPTT->objIdField])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . MPTT::mpttRemoveUnique($v[self::$objMPTT->objNameOfNode]))); } // Continue ... $this->setInputType(new S('file'))->setName(self::$objAudioTableFFile)->setLabel(new S(AUDIO_FILE))->setFileController(new B(TRUE))->setContainerDiv(new B(TRUE))->setInputType(new S('file'))->setName(self::$objAudioTableFArtwork)->setLabel(new S(AUDIO_FILE_ARTWORK))->setFileController(new B(TRUE))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAudioTableFArtist)->setLabel(new S(AUDIO_FILE_ARTIST))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAudioTableFAlbum)->setLabel(new S(AUDIO_FILE_ALBUM))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAudioTableFLyrics)->setLabel(new S(AUDIO_FILE_LYRICS))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAudioTableFDescription)->setLabel(new S(AUDIO_FILE_DESCRIPTION))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'audioErase': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); $objUPDirectory = date('Y/m/d/', (int) $this->getAudioFileInfoById($_GET[ADMIN_ACTION_ID], self::$objAudioTableFUploadedDate)->toString()); if ($this->getCommentCount(_S('WHERE %objCommentsTableFAudioFileId = "%Id"')->doToken('%Id', $_GET[ADMIN_ACTION_ID]))->toInt() != 0) { self::$objAdministration->setErrorMessage(new S(AUDIO_HAS_COMMENTS), $objURLToGoBack); } else { // Remove them files ... $objPath = new FilePath('upd/audio/mp3/' . $objUPDirectory); // First: check to see if file is there ... $objArtF = $this->getAudioFileInfoById($_GET[ADMIN_ACTION_ID], self::$objAudioTableFFile); // Go ... if ($objArtF->toLength()->toInt() != 0) { // Kill'em ALL ... UNLINK($objPath . $objArtF); } // Second: check to see if artwork is there ... $objArtF = $this->getAudioFileInfoById($_GET[ADMIN_ACTION_ID], self::$objAudioTableFArtwork); // Go ... if ($objArtF->toLength()->toInt() != 0) { // Kill'em ALL ... UNLINK($objPath . '' . $objArtF); UNLINK($objPath . '128_128_' . $objArtF); UNLINK($objPath . '640_480_' . $objArtF); UNLINK($objPath . '800_600_' . $objArtF); } // Do erase it ... $this->_Q(_QS('doDELETE')->doToken('%table', self::$objAudioTable)->doToken('%condition', new S('%objAudioTableFId = "%Id"'))->doToken('%Id', $_GET[ADMIN_ACTION_ID])); // Do a redirect, and get the user back where he belongs; $this->setHeaderKey($objURLToGoBack, new S('Location')); } // BK; break; case 'commentEdit': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUDIO_EDIT_COMMENT))->setAJAXEnabledForm(new B(FALSE))->setRedirect($objURLToGoBack)->setSQLAction(new S('update'))->setTableName(self::$objCommentsTable)->setUpdateId($_GET[ADMIN_ACTION_ID])->setUpdateField(self::$objCommentsTableFId)->setName($objFormToRender)->setInputType(new S('submit'))->setValue(new S(AUDIO_EDIT_COMMENT))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(self::$objCommentsTableFApproved)->setLabel(new S(AUDIO_COMMENT_APPROVED))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('no'))->setValue(new S('N'))->setLabel(new S(AUDIO_CAN_COMMENT_NO))->setInputType(new S('option'))->setName(new S('yes'))->setValue(new S('Y'))->setLabel(new S(AUDIO_CAN_COMMENT_YES))->setInputType(new S('textarea'))->setName(self::$objCommentsTableFComment)->setLabel(new S(AUDIO_COMMENT))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'commentErase': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Do erase it ... $this->_Q(_QS('doDELETE')->doToken('%table', self::$objCommentsTable)->doToken('%condition', new S('%objCommentsTableFId = "%Id"'))->doToken('%Id', $_GET[ADMIN_ACTION_ID])); // Do a redirect, and get the user back where he belongs; $this->setHeaderKey($objURLToGoBack, new S('Location')); break; case 'categoryCreate': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(); // Do some work; if ($this->checkPOST(new S('categories_show_all'))->toBoolean() == TRUE) { // Redirect to proper ... $this->setHeaderKey(URL::rewriteURL(new A(array(ADMIN_SHOW_ALL)), new A(array('1'))), new S('Location')); } if ($this->checkPOST(new S('add_category_submit'))->toBoolean() == TRUE) { // Set some requirements; $objFormHappened = new B(FALSE); $objToCheck = MPTT::mpttAddUnique($this->getPOST(new S('add_category')), new S((string) $_SERVER['REQUEST_TIME'])); if ($objToCheck->toLength()->toInt() == 0) { $this->setErrorOnInput(new S('add_category'), new S(AUDIO_CATEGORY_NAME_IS_EMPTY)); // Set the memory; $objFormHappened->switchType(); } else { if (self::$objMPTT->mpttCheckIfNodeExists($objToCheck)->toBoolean() == TRUE) { // Check to see if the group exists, and tell the user the group exists; $this->setErrorOnInput(new S('add_category'), new S(AUDIO_CATEGORY_ALREADY_EXISTS)); // Set the memory; $objFormHappened->switchType(); } if ($this->checkCategoryURLIsUnique(URL::getURLFromString($objToCheck))->toBoolean() == FALSE) { $this->setErrorOnInput(new S('add_category'), new S(AUDIO_CATEGORY_URL_MUST_BE_UNIQUE)); } } // Get AJAX; $this->getAjaxErrors(); if ($objFormHappened->toBoolean() == FALSE) { // Remember if we should add it as a brother or child; $objAddNodeAS = NULL; switch ($this->getPOST(new S('add_category_as_what'))) { case AUDIO_CATEGORY_CHILD: $objAddNodeAS = new S((string) MPTT::FIRST_CHILD); break; case AUDIO_CATEGORY_LAST_CHILD: $objAddNodeAS = new S((string) MPTT::LAST_CHILD); break; case AUDIO_CATEGORY_BROTHER: $objAddNodeAS = new S((string) MPTT::PREVIOUS_BROTHER); break; case AUDIO_CATEGORY_NEXT_BROTHER: $objAddNodeAS = new S((string) MPTT::NEXT_BROTHER); break; } // Add the node; self::$objMPTT->mpttAddNode($objToCheck, $this->getPOST(new S('add_category_parent_or_bro')), $objAddNodeAS); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUDIO_ADD_CATEGORY))->setName($objFormToRender); if ($this->checkPOST(new S('add_category_submit'))->toBoolean() == TRUE) { $this->setRedirect($objURLToGoBack); } $this->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setName(new S('categories_show_all'))->setValue(new S(AUDIO_SHOW_ALL_CATEGORIES))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('submit'))->setName(new S('add_category_submit'))->setValue(new S(AUDIO_ADD_CATEGORY))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setJSRegExpReplace(new S('[^a-zA-Z0-9 ,.!?;&-]'))->setContainerDiv(new B(TRUE))->setName(new S('add_category'))->setLabel(new S(AUDIO_CATEGORY_NAME_LABEL))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(new S('add_category_as_what'))->setLabel(new S(AUDIO_AS_A))->setInputType(new S('option'))->setName(new S('as_first_child'))->setLabel(new S(AUDIO_CATEGORY_CHILD))->setInputType(new S('option'))->setName(new S('as_last_child'))->setLabel(new S(AUDIO_CATEGORY_LAST_CHILD))->setInputType(new S('option'))->setName(new S('as_previous_brother'))->setLabel(new S(AUDIO_CATEGORY_BROTHER))->setInputType(new S('option'))->setName(new S('as_next_brother'))->setLabel(new S(AUDIO_CATEGORY_NEXT_BROTHER))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(new S('add_category_parent_or_bro'))->setLabel(new S(AUDIO_OF_CATEGORY)); // Category parent or brother of this one ... foreach ($this->getCategories() as $k => $v) { $this->setInputType(new S('option'))->setName($v[self::$objMPTT->objNameOfNode])->setValue($v[self::$objMPTT->objNameOfNode])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . MPTT::mpttRemoveUnique(clone $v[self::$objMPTT->objNameOfNode]))); } // Continue, execute the form ... $this->setFormEndAndExecute(new B(TRUE)); break; case 'categoryEdit': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Do validation and error on it if something goes wrong; if ($this->checkPOST()->toBoolean() == TRUE) { // Set some requirements; $objFormHappened = new B(FALSE); $objToCheck = MPTT::mpttAddUnique($this->getPOST(self::$objCategoryTableFName), $this->getCategoryInfoById($_GET[ADMIN_ACTION_ID], self::$objCategoryTableFDate)); if ($objToCheck->toLength()->toInt() == 0) { // Check for empty group name, and error on it. We don't allow empty group names; $this->setErrorOnInput(self::$objCategoryTableFName, new S(AUDIO_CATEGORY_NAME_IS_EMPTY)); // Set the memory; $objFormHappened->switchType(); } else { if ($this->getCategoryInfoById($_GET[ADMIN_ACTION_ID], self::$objCategoryTableFName) != $objToCheck) { if (self::$objMPTT->mpttCheckIfNodeExists($objToCheck)->toBoolean() == TRUE) { // Check to see if the group exists; $this->setErrorOnInput(self::$objCategoryTableFName, new S(AUDIO_CATEGORY_ALREADY_EXISTS)); // Set the memory; $objFormHappened->switchType(); } } } // Get AJAX; $this->getAjaxErrors(); } // Do the form, make it happen; $this->setMethod(new S('POST'))->setSQLAction(new S('update'))->setTableName(self::$objCategoryTable)->setUpdateId($_GET[ADMIN_ACTION_ID])->setUpdateField(self::$objCategoryTableFId)->setFieldset(new S(AUDIO_EDIT_CATEGORY)); if ($this->checkPOST(self::$objCategoryTableFName)->toBoolean() == TRUE && $objFormHappened->toBoolean() == FALSE) { // Add the URL processing ... $this->setExtraUpdateData(self::$objCategoryTableFSEO, URL::getURLFromString($this->getPOST(self::$objCategoryTableFName))); $this->setRedirect($objURLToGoBack); } // Continue ... $this->setName($objFormToRender)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setName(new S('edit_category_submit'))->setValue(new S(AUDIO_EDIT_CATEGORY))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objCategoryTableFName)->setLabel(new S(AUDIO_CATEGORY_NAME_LABEL))->setJSRegExpReplace(new S('[^a-zA-Z0-9 ,.!?;&-]'))->setMPTTRemoveUnique(new B(TRUE))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objCategoryTableFDescription)->setLabel(new S(AUDIO_CATEGORY_DESCRIPTION))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'categoryErase': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Do erase the group node from the table; self::$objMPTT->mpttRemoveNode($this->getCategoryInfoById($_GET[ADMIN_ACTION_ID], self::$objCategoryTableFName)); // Do a redirect, and get the user back where he belongs; $this->setHeaderKey($objURLToGoBack, new S('Location')); break; case 'categoryMove': // Set some predefines; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_TO, ADMIN_ACTION_TYPE))); // Get names, as they are unique; $objThatIsMoved = $this->getCategoryInfoById($_GET[ADMIN_ACTION_ID], self::$objCategoryTableFName); $objWhereToMove = $this->getCategoryInfoById($_GET[ADMIN_ACTION_TO], self::$objCategoryTableFName); // Get the node subtree, that's move, make sure the node we move to ain't a child; $objMovedNodeSubTree = self::$objMPTT->mpttGetTree($objThatIsMoved); // Memorize; $objIsChild = new B(FALSE); foreach ($objMovedNodeSubTree as $k => $v) { if ($v[self::$objMPTT->objNameOfNode] == $objWhereToMove) { $objIsChild->switchType(); } } // Check if it's a child or not; if ($objIsChild->toBoolean() == TRUE) { // Set an error message; self::$objAdministration->setErrorMessage(new S(AUDIO_CATEGORY_MOVED_TO_CHILD), $objURLToGoBack); } else { // Move nodes; self::$objMPTT->mpttMoveNode($objThatIsMoved, $objWhereToMove, $_GET[ADMIN_ACTION_TYPE]); $this->setHeaderKey($objURLToGoBack, new S('Location')); } // BK; break; case 'categoryMoveOperation': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_SUBPAGE)), new A(array(AUDIO_MANAGE_AUDIO))); // Do some work; $this->checkPOST()->toBoolean() == TRUE ? $objOLDCategoryId = $this->getPOST(new S('old_category_id')) : ($objOLDCategoryId = new S('0')); // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUDIO_MOVE_ARTICLE))->setSQLAction(new S('update'))->setTableName(self::$objAudioTable)->setUpdateField(self::$objAudioTableFId)->setUpdateWhere($this->doModuleToken(_S('%objAudioTableFCategoryId = "%Id"')->doToken('%Id', $objOLDCategoryId)))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(AUDIO_MOVE_ARTICLE))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(new S('old_category_id'))->setLabel(new S(AUDIO_OLD_CATEGORY))->setContainerDiv(new B(TRUE)); // Cateories; foreach ($this->getCategories() as $k => $v) { $this->setInputType(new S('option'))->setName($v[self::$objMPTT->objIdField])->setValue($v[self::$objMPTT->objIdField])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . MPTT::mpttRemoveUnique($v[self::$objMPTT->objNameOfNode]))); } // Categories; $this->setInputType(new S('select'))->setName(self::$objAudioTableFCategoryId)->setLabel(new S(AUDIO_NEW_CATEGORY))->setContainerDiv(new B(TRUE)); foreach ($this->getCategories() as $k => $v) { $this->setInputType(new S('option'))->setName($v[self::$objMPTT->objIdField])->setValue($v[self::$objMPTT->objIdField])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . MPTT::mpttRemoveUnique($v[self::$objMPTT->objNameOfNode]))); } // Continue; $this->setFormEndAndExecute(new B(TRUE)); break; case 'configurationEdit': // Do some work; if ($this->checkPOST()->toBoolean() == TRUE) { $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION)), new A(array($this->getPOST(new S('what'))))); } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUDIO_UPDATE_CONFIGURATION))->setName($objFormToRender); // Set redirect; if ($this->checkPOST()->toBoolean() == TRUE) { $this->setRedirect($objURLToGoBack); } // Continue; $this->setInputType(new S('submit'))->setValue(new S(ADMIN_ACTION))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(new S('what'))->setLabel(new S(AUDIO_CONFIG_CHOOSE))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('configurationEdit-message_on_top_of_upload_form_page'))->setValue(new S('configurationEdit-message_on_top_of_upload_form_page'))->setLabel(new S(AUDIO_CONFIG_MESSAGE_ON_UPLOAD))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('configurationEdit-message_upon_upload_ok'))->setValue(new S('configurationEdit-message_upon_upload_ok'))->setLabel(new S(AUDIO_CONFIG_MESSAGE_ON_UPLOAD_OK))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('configurationEdit-message_if_not_auth'))->setValue(new S('configurationEdit-message_if_not_auth'))->setLabel(new S(AUDIO_CONFIG_MESSAGE_USER_NOT_AUTH))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('configurationEdit-items_per_page'))->setValue(new S('configurationEdit-items_per_page'))->setLabel(new S(AUDIO_CONFIG_ITEMS_PER_PAGE))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('configurationEdit-users_should_be_auth_to_comment'))->setValue(new S('configurationEdit-users_should_be_auth_to_comment'))->setLabel(new S(AUDIO_CONFIG_USER_LOGGED_TO_COMM))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'configurationEdit-message_on_top_of_upload_form_page': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION))); // Do some work; if ($this->checkPOST()->toBoolean() == TRUE) { foreach ($this->getPOST() as $k => $v) { $this->setConfigKey(new S($k), $v); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUDIO_UPDATE_CONFIGURATION))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(AUDIO_UPDATE_CONFIGURATION))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(new S('audio_settings_audio_form_page'))->setLabel(new S(AUDIO_CONFIG_DEFAULT))->setValue($this->getConfigKey(new S('audio_settings_audio_form_page')))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'configurationEdit-message_upon_upload_ok': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION))); // Do some work; if ($this->checkPOST()->toBoolean() == TRUE) { foreach ($this->getPOST() as $k => $v) { $this->setConfigKey(new S($k), $v); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUDIO_UPDATE_CONFIGURATION))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(AUDIO_UPDATE_CONFIGURATION))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(new S('audio_settings_audio_form_page_status_ok'))->setLabel(new S(AUDIO_CONFIG_DEFAULT))->setValue($this->getConfigKey(new S('audio_settings_audio_form_page_status_ok')))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'configurationEdit-message_if_not_auth': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION))); // Do some work; if ($this->checkPOST()->toBoolean() == TRUE) { foreach ($this->getPOST() as $k => $v) { $this->setConfigKey(new S($k), $v); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUDIO_UPDATE_CONFIGURATION))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(AUDIO_UPDATE_CONFIGURATION))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(new S('audio_settings_audio_form_not_authenticated'))->setLabel(new S(AUDIO_CONFIG_DEFAULT))->setValue($this->getConfigKey(new S('audio_settings_audio_form_not_authenticated')))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'configurationEdit-items_per_page': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION))); // Do some work; if ($this->checkPOST()->toBoolean() == TRUE) { foreach ($this->getPOST() as $k => $v) { $this->setConfigKey(new S($k), $v); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUDIO_UPDATE_CONFIGURATION))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(AUDIO_UPDATE_CONFIGURATION))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(new S('audio_settings_audio_items_per_page'))->setLabel(new S(AUDIO_CONFIG_DEFAULT))->setValue($this->getConfigKey(new S('audio_settings_audio_items_per_page')))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'configurationEdit-users_should_be_auth_to_comment': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION))); // Do some work; if ($this->checkPOST()->toBoolean() == TRUE) { foreach ($this->getPOST() as $k => $v) { $this->setConfigKey(new S($k), $v); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUDIO_UPDATE_CONFIGURATION))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(AUDIO_UPDATE_CONFIGURATION))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(new S('audio_settings_audio_auth_to_comment'))->setLabel(new S(AUDIO_CONFIG_CHOOSE))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('yes'))->setValue(new S('Y'))->setLabel(new S('Yes'))->setSelected($this->getConfigKey(new S('audio_settings_audio_auth_to_comment')) == 'Y' ? new B(TRUE) : new B(FALSE))->setInputType(new S('option'))->setName(new S('no'))->setValue(new S('N'))->setLabel(new S('No'))->setSelected($this->getConfigKey(new S('audio_settings_audio_auth_to_comment')) == 'N' ? new B(TRUE) : new B(FALSE))->setFormEndAndExecute(new B(TRUE)); break; } }
/** * 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. * 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 best; * * @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 renderForm(S $objFormToRender, A $objFA = NULL) { // Make them defaults ... if ($objFA == NULL) { $objFA = new A(); } // Do a switch ... switch ($objFormToRender) { case 'adminLoginScreen': // Do some URL mangling, redirect back to a pure index; URL::doCleanURLPath(); // Add a <title> tag, saying we need to log in; $this->manageTTL(new S(AUTHENTICATION_LOGIN_FORM)); // Get the personalized CSS; $this->manageCSS(new FilePath($this->getPathToSkin()->toRelativePath() . SKIN_CSS_DIR . _S . 'renderAdminLoginScreen.css'), new S(__FUNCTION__)); // Do the authentication mechanism, check the _POST; if ($this->checkPOST()->toBoolean() == TRUE) { if ($this->doLogIn($this->getPOST(self::$objAuthUsersTableFUName), $this->getPOST(self::$objAuthUsersTableFUPass))->toBoolean() == TRUE) { // OK; $this->setHeaderKey(URL::rewriteURL(new A(array(ADMIN_PAGE)), new A(array(ADMIN_DASHBOARD))), new S('Location')); } else { // Do an error, and retain the user; $this->setErrorOnInput(self::$objAuthUsersTableFUName, new S(AUTHENTICATION_ACCESS_DENIED)); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setName($objFormToRender)->setFieldset(new S(AUTHENTICATION_LOGIN_FORM))->setInputType(new S('submit'))->setName(new S('submit'))->setValue(new S(AUTHENTICATION_LOGIN_GO))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFUName)->setLabel(new S(AUTHENTICATION_USERNAME))->setJSRegExpReplace(new S('[^a-zA-Z0-9 .-]'))->setTooltip($this->getHELP(new S('adminLoginScreenU')))->setContainerDiv(new B(TRUE))->setInputType(new S('password'))->setName(self::$objAuthUsersTableFUPass)->setLabel(new S(AUTHENTICATION_PASSWORD))->setTooltip($this->getHELP(new S('adminLoginScreenP')))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'userLogIn': // Do the authentication mechanism, check the _POST; if ($this->checkPOST(new S('submit_log_in'))->toBoolean() == TRUE) { // ELSE ... go authenticate us ... if ($this->doLogIn($this->getPOST(new S('user_username')), $this->getPOST(new S('user_password')))->toBoolean() == TRUE) { // Set the proper POST ... $this->setPOST(self::$objAuthUsersTableFIp, new S($_SERVER['REMOTE_ADDR'])); // Make and auto-executing form ... $this->setMethod(new S('POST'))->setSQLAction(new S('update'))->setTableName(self::$objAuthUsersTable)->setUpdateId($this->getUserInfoByName($this->getPOST(new S('user_username')), self::$objAuthUsersTableFId))->setUpdateField(self::$objAuthUsersTableFId)->setName($objFormToRender)->setInputType(new S('text'))->setName(self::$objAuthUsersTableFIp)->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); // Ok ... do nothin' ... $this->setHeaderKey(URL::staticURL(new A(array(FRONTEND_SECTION_URL)), new A(array(FRONTEND_HOME))), new S('Location')); } else { // Do an error, and retain the user; $this->setErrorOnInput(new S('user_username'), new S($objFA['log_in_failed'])); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setName($objFormToRender)->setInputType(new S('submit'))->setName(new S('submit_log_in'))->setValue(new S($objFA['log_in']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(new S('user_username'))->setLabel(new S($objFA['log_in_username']))->setJSRegExpReplace(new S('[^a-zA-Z0-9 .-]'))->setContainerDiv(new B(TRUE))->setInputType(new S('password'))->setName(new S('user_password'))->setLabel(new S($objFA['log_in_password']))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'userSignUp': // Set some predefines; $objURLToGoBack = URL::rewriteURL(new A(array(AUTHENTICATION_STATUS_URL)), new A(array(AUTHENTICATION_STATUS_OK_URL))); // Check if both password fields have been entered correctly; if ($this->checkPOST(new S('submit_signup'))->toBoolean() == TRUE) { // Check username ... if ($this->getPOST(self::$objAuthUsersTableFUName)->toLength()->toInt() == 0) { //Check non-empty username, and error if the username is empty; $this->setErrorOnInput(self::$objAuthUsersTableFUName, new S($objFA['error_username_mandatory'])); } else { // Check USERNAME; if ($this->checkUserNameExists($this->getPOST(self::$objAuthUsersTableFUName))->toBoolean() == TRUE) { $this->setErrorOnInput(self::$objAuthUsersTableFUName, new S($objFA['error_username_exists'])); } // Check EMAIL; if ($this->checkUserMailExists($this->getPOST(self::$objAuthUsersTableFEML))->toBoolean() == TRUE) { $this->setErrorOnInput(self::$objAuthUsersTableFEML, new S($objFA['error_email_exists'])); } } // Check password; if ($this->getPOST(self::$objAuthUsersTableFUPass) != $this->getPOST(new S('confirmation_password'))) { // Check password mismatch, and error on it if so; $this->setErrorOnInput(self::$objAuthUsersTableFUPass, new S($objFA['error_passwords_do_not_match'])); } // Check phone number has 10 chars, only if it is required; if (self::PHONE_IS_REQUIRED == 1) { if ($this->getPOST(self::$objAuthUsersTableFPhone)->toLength()->toInt() != 10) { $this->setErrorOnInput(self::$objAuthUsersTableFPhone, new S($objFA['error_phone_ten_chars'])); } } } // Get AJAX; $this->getAjaxErrors(); // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S($objFA['form_signup']))->setSQLAction(new S('update'))->setTableName(self::$objAuthUsersTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objAuthUsersTableFId)->setExtraUpdateData(self::$objAuthUsersTableFRegOn, new S((string) $_SERVER['REQUEST_TIME']))->setExtraUpdateData(self::$objAuthUsersTableFUGId, $objFA['default_group_id'])->setExtraUpdateData(self::$objAuthUsersTableFActivated, new S('N'))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setName(new S('submit_signup'))->setValue(new S($objFA['form_submit']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFUName)->setLabel(new S($objFA['form_username']))->setContainerDiv(new B(TRUE))->setJSRegExpReplace(new S('[^a-zA-Z0-9 .-]'))->setInputType(new S('password'))->setName(self::$objAuthUsersTableFUPass)->setLabel(new S($objFA['form_password']))->setContainerDiv(new B(TRUE))->setInputType(new S('password'))->setName(new S('confirmation_password'))->setLabel(new S($objFA['form_password_confirm']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFEML)->setRegExpType(new S('preg'))->setRegExpErrMsg(new S($objFA['form_regexp_invalid_email']))->setPHPRegExpCheck(new S(self::REGEXP_PHP_CHECK_EMAIL))->setJSRegExpReplace(new S('[^a-zA-Z0-9.@_-]'))->setLabel(new S($objFA['form_email']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFPhone)->setLabel(new S($objFA['form_phone']))->setContainerDiv(new B(TRUE))->setJSRegExpReplace(new S('[^0-9]'))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFLName)->setLabel(new S($objFA['form_last_name']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFFName)->setLabel(new S($objFA['form_first_name']))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthUsersTableFCountry)->setLabel(new S($objFA['form_country'])); // Get the COUNTRIES; foreach ($this->STG->getCountries() as $k => $v) { $this->setInputType(new S('option'))->setName($v[Settings::$objSettingsCountryTableFIso])->setValue($v[Settings::$objSettingsCountryTableFIso])->setLabel($v[Settings::$objSettingsCountryTableFPrnt]); } // Continue; $this->setInputType(new S('text'))->setName(self::$objAuthUsersTableFCity)->setLabel(new S($objFA['form_city']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFYM)->setLabel(new S($objFA['form_ym']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFMSN)->setLabel(new S($objFA['form_msn']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFICQ)->setLabel(new S($objFA['form_icq']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFAOL)->setLabel(new S($objFA['form_aol']))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAuthUsersTableFDesc)->setLabel(new S($objFA['form_description']))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAuthUsersTableFSignature)->setLabel(new S($objFA['form_signature']))->setContainerDiv(new B(TRUE)); // Encrypt the data; if ($this->checkFormHasErrors()->toBoolean() == FALSE) { // Make them passwords OK ... if ($this->checkPOST()->toBoolean() == TRUE) { $this->setPOST(self::$objAuthUsersTableFUPass, $this->getPOST(self::$objAuthUsersTableFUPass)->encryptIt(sha1($this->getPOST(self::$objAuthUsersTableFUPass)))); $this->setPOST(new S('confirmation_password'), $this->getPOST(self::$objAuthUsersTableFUPass)); } $this->setExtraUpdateData(self::$objAuthUsersTableFHash, new S(sha1(md5($this->getPOST(self::$objAuthUsersTableFEML))))); // Send the activation EML ... $objEML = new MAIL(); $objEML->doMAIL($this->getPOST(self::$objAuthUsersTableFEML), $objFA['form_activation_subject'], $this->getHELP(new S('activationEMLMessage'))->doToken('%u', $this->getPOST(self::$objAuthUsersTableFUName))->doToken('%a', URL::staticURL(new A(array(FRONTEND_SECTION_URL, AUTHENTICATION_ACTION_URL, AUTHENTICATION_HASH_URL)), new A(array(FRONTEND_AUTHENTICATION_URL, AUTHENTICATION_ACTIVATE_URL, sha1(md5($this->getPOST(self::$objAuthUsersTableFEML)))))))); } // Continue; $this->setFormEndAndExecute(new B(TRUE)); break; case 'userProfile': // Set some predefines; $objURLToGoBack = URL::rewriteURL(new A(array(AUTHENTICATION_STATUS_URL)), new A(array(AUTHENTICATION_STATUS_OK_URL))); // Check if both password fields have been entered correctly; if ($this->checkPOST(new S('submit_signup'))->toBoolean() == TRUE) { // Check username ... if ($this->getPOST(self::$objAuthUsersTableFUName)->toLength()->toInt() == 0) { //Check non-empty username, and error if the username is empty; $this->setErrorOnInput(self::$objAuthUsersTableFUName, new S($objFA['error_username_mandatory'])); } else { if ($this->getPOST(self::$objAuthUsersTableFUName) != $this->getCurrentUserInfoById(self::$objAuthUsersTableFUName)) { // Check USERNAME; if ($this->checkUserNameExists($this->getPOST(self::$objAuthUsersTableFUName))->toBoolean() == TRUE) { $this->setErrorOnInput(self::$objAuthUsersTableFUName, new S($objFA['error_username_exists'])); } } if ($this->getPOST(self::$objAuthUsersTableFEML) != $this->getCurrentUserInfoById(self::$objAuthUsersTableFEML)) { // Check EMAIL; if ($this->checkUserMailExists($this->getPOST(self::$objAuthUsersTableFEML))->toBoolean() == TRUE) { $this->setErrorOnInput(self::$objAuthUsersTableFEML, new S($objFA['error_email_exists'])); } } } // Check password; if ($this->getPOST(self::$objAuthUsersTableFUPass) != $this->getPOST(new S('confirmation_password'))) { // Check password mismatch, and error on it if so; $this->setErrorOnInput(self::$objAuthUsersTableFUPass, new S($objFA['error_passwords_do_not_match'])); } // Check phone number has 10 chars, only if it is required; if (self::PHONE_IS_REQUIRED == 1) { if ($this->getPOST(self::$objAuthUsersTableFPhone)->toLength()->toInt() != 10) { $this->setErrorOnInput(self::$objAuthUsersTableFPhone, new S($objFA['error_phone_ten_chars'])); } } } // Get AJAX; $this->getAjaxErrors(); // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S($objFA['form_signup']))->setSQLAction(new S('update'))->setTableName(self::$objAuthUsersTable)->setUpdateId(new S($this->getCurrentUserInfoById(self::$objAuthUsersTableFId)))->setUpdateField(self::$objAuthUsersTableFId)->setUploadDirectory(new S('users/avatars'))->setUploadImageResize(new A(array(128 => 128)))->setExtraUpdateData(self::$objAuthUsersTableFActivated, new S('N'))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setName(new S('submit_signup'))->setValue(new S($objFA['form_submit']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFUName)->setLabel(new S($objFA['form_username']))->setReadOnly(new B(TRUE))->setContainerDiv(new B(TRUE))->setJSRegExpReplace(new S('[^a-zA-Z0-9 .-]'))->setInputType(new S('password'))->setName(self::$objAuthUsersTableFUPass)->setLabel(new S($objFA['form_password']))->setContainerDiv(new B(TRUE))->setInputType(new S('password'))->setName(new S('confirmation_password'))->setValue($this->getCurrentUserInfoById(self::$objAuthUsersTableFUPass))->setLabel(new S($objFA['form_password_confirm']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFEML)->setRegExpType(new S('preg'))->setRegExpErrMsg(new S($objFA['form_regexp_invalid_email']))->setPHPRegExpCheck(new S(self::REGEXP_PHP_CHECK_EMAIL))->setJSRegExpReplace(new S('[^a-zA-Z0-9.@_-]'))->setLabel(new S($objFA['form_email']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFPhone)->setLabel(new S($objFA['form_phone']))->setContainerDiv(new B(TRUE))->setJSRegExpReplace(new S('[^0-9]'))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFLName)->setLabel(new S($objFA['form_last_name']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFFName)->setLabel(new S($objFA['form_first_name']))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthUsersTableFCountry)->setLabel(new S($objFA['form_country'])); // Get the COUNTRIES; foreach ($this->STG->getCountries() as $k => $v) { $this->setInputType(new S('option'))->setName($v[Settings::$objSettingsCountryTableFIso])->setValue($v[Settings::$objSettingsCountryTableFIso])->setLabel($v[Settings::$objSettingsCountryTableFPrnt]); } // Continue; $this->setInputType(new S('text'))->setName(self::$objAuthUsersTableFCity)->setLabel(new S($objFA['form_city']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFYM)->setLabel(new S($objFA['form_ym']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFMSN)->setLabel(new S($objFA['form_msn']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFICQ)->setLabel(new S($objFA['form_icq']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFAOL)->setLabel(new S($objFA['form_aol']))->setContainerDiv(new B(TRUE))->setInputType(new S('file'))->setFileController(new B(TRUE))->setName(self::$objAuthUsersTableFAvatar)->setLabel(new S($objFA['form_avatar']))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAuthUsersTableFDesc)->setLabel(new S($objFA['form_description']))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAuthUsersTableFSignature)->setLabel(new S($objFA['form_signature']))->setContainerDiv(new B(TRUE)); // Encrypt the data; if ($this->checkFormHasErrors()->toBoolean() == FALSE) { // Make them passwords OK ... if ($this->checkPOST(self::$objAuthUsersTableFUPass)->toBoolean() == TRUE) { // If they differ ... if ($this->getPOST(self::$objAuthUsersTableFUPass) != $this->getCurrentUserInfoById(self::$objAuthUsersTableFUPass)) { $this->setPOST(self::$objAuthUsersTableFUPass, $this->getPOST(self::$objAuthUsersTableFUPass)->encryptIt(sha1($this->getPOST(self::$objAuthUsersTableFUPass)))); $this->setPOST(new S('confirmation_password'), $this->getPOST(self::$objAuthUsersTableFUPass)); } } $this->setExtraUpdateData(self::$objAuthUsersTableFHash, new S(sha1(md5($this->getPOST(self::$objAuthUsersTableFEML))))); // Send the activation EML ... $objEML = new MAIL(); $objEML->doMAIL($this->getPOST(self::$objAuthUsersTableFEML), $objFA['form_activation_subject'], $this->getHELP(new S('activationEMLMessage'))->doToken('%u', $this->getPOST(self::$objAuthUsersTableFUName))->doToken('%a', URL::staticURL(new A(array(FRONTEND_SECTION_URL, AUTHENTICATION_ACTION_URL, AUTHENTICATION_HASH_URL)), new A(array(FRONTEND_AUTHENTICATION_URL, AUTHENTICATION_ACTIVATE_URL, sha1(md5($this->getPOST(self::$objAuthUsersTableFEML)))))))); } // Continue; $this->setFormEndAndExecute(new B(TRUE)); break; case 'userCreate': // Set some predefines; $objURLToGoBack = URL::rewriteURL(); // Check if both password fields have been entered correctly; if ($this->checkPOST(self::$objAuthUsersTableFUName)->toBoolean() == TRUE) { // Check username ... if ($this->getPOST(self::$objAuthUsersTableFUName)->toLength()->toInt() == 0) { //Check non-empty username, and error if the username is empty; $this->setErrorOnInput(self::$objAuthUsersTableFUName, new S(AUTHENTICATION_USERNAME_IS_MANDATORY)); } else { // Check USERNAME; if ($this->checkUserNameExists($this->getPOST(self::$objAuthUsersTableFUName))->toBoolean() == TRUE) { $this->setErrorOnInput(self::$objAuthUsersTableFUName, new S(AUTHENTICATION_USERNAME_ALREADY_EXISTS)); } // Check EMAIL; if ($this->checkUserMailExists($this->getPOST(self::$objAuthUsersTableFEML))->toBoolean() == TRUE) { $this->setErrorOnInput(self::$objAuthUsersTableFEML, new S(AUTHENTICATION_EMAIL_ALREADY_EXISTS)); } } // Check password; if ($this->getPOST(self::$objAuthUsersTableFUPass) != $this->getPOST(new S('confirmation_password'))) { // Check password mismatch, and error on it if so; $this->setErrorOnInput(self::$objAuthUsersTableFUPass, new S(AUTHENTICATION_USER_PASSWORDS_DONT_MATCH)); } // Check phone number has 10 chars, only if it is required; if (self::PHONE_IS_REQUIRED == 1) { if ($this->getPOST(self::$objAuthUsersTableFPhone)->toLength()->toInt() != 10) { $this->setErrorOnInput(self::$objAuthUsersTableFPhone, new S(AUTHENTICATION_PHONE_TEN_CHARS)); } } } // Get AJAX; $this->getAjaxErrors(); // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(AUTHENTICATION_PROFILE_ADD))->setSQLAction(new S('update'))->setTableName(self::$objAuthUsersTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objAuthUsersTableFId)->setUploadDirectory(new S('users/avatars'))->setUploadImageResize(new A(array(128 => 128)))->setExtraUpdateData(self::$objAuthUsersTableFRegOn, new S((string) $_SERVER['REQUEST_TIME'])); if ($this->checkPOST(self::$objAuthUsersTableFUName)->toBoolean() == TRUE) { $this->setRedirect($objURLToGoBack); } $this->setName($objFormToRender)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setName(new S('submit'))->setValue(new S(AUTHENTICATION_PROFILE_ADD))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFUName)->setLabel(new S(AUTHENTICATION_PROFILE_USERNAME))->setContainerDiv(new B(TRUE))->setJSRegExpReplace(new S('[^a-zA-Z0-9 .-]'))->setInputType(new S('password'))->setName(self::$objAuthUsersTableFUPass)->setLabel(new S(AUTHENTICATION_PROFILE_PASSWORD))->setContainerDiv(new B(TRUE))->setInputType(new S('password'))->setName(new S('confirmation_password'))->setLabel(new S(AUTHENTICATION_PROFILE_PASSWORD_CONFIRM))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFEML)->setRegExpType(new S('preg'))->setRegExpErrMsg(new S(AUTHENTICATION_INVALID_EMAIL))->setPHPRegExpCheck(new S(self::REGEXP_PHP_CHECK_EMAIL))->setJSRegExpReplace(new S('[^a-zA-Z0-9.@_-]'))->setLabel(new S(AUTHENTICATION_PROFILE_EMAIL))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFPhone)->setLabel(new S(AUTHENTICATION_PROFILE_PHONE))->setContainerDiv(new B(TRUE))->setJSRegExpReplace(new S('[^0-9]'))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFLName)->setLabel(new S(AUTHENTICATION_PROFILE_LAST_NAME))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFFName)->setLabel(new S(AUTHENTICATION_PROFILE_FIRST_NAME))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthUsersTableFCountry)->setLabel(new S(AUTHENTICATION_PROFILE_COUNTRY)); // Get the COUNTRIES; foreach ($this->STG->getCountries() as $k => $v) { $this->setInputType(new S('option'))->setName($v[Settings::$objSettingsCountryTableFIso])->setValue($v[Settings::$objSettingsCountryTableFIso])->setLabel($v[Settings::$objSettingsCountryTableFPrnt]); } // Continue; $this->setInputType(new S('text'))->setName(self::$objAuthUsersTableFCity)->setLabel(new S(AUTHENTICATION_PROFILE_CITY))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthUsersTableFUGId)->setLabel(new S(AUTHENTICATION_PROFILE_GROUP)); // Get the groups of the user; foreach (self::$objMPTT->mpttGetTree() as $k => $v) { $this->setInputType(new S('option'))->setName($v['id'])->setValue($v['id'])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . $v['name'])); } // Continue; $this->setInputType(new S('text'))->setName(self::$objAuthUsersTableFYM)->setLabel(new S(AUTHENTICATION_PROFILE_YM))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFMSN)->setLabel(new S(AUTHENTICATION_PROFILE_MSN))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFICQ)->setLabel(new S(AUTHENTICATION_PROFILE_ICQ))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFAOL)->setLabel(new S(AUTHENTICATION_PROFILE_AOL))->setContainerDiv(new B(TRUE))->setInputType(new S('file'))->setFileController(new B(TRUE))->setName(self::$objAuthUsersTableFAvatar)->setLabel(new S(AUTHENTICATION_PROFILE_AVATAR))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAuthUsersTableFDesc)->setLabel(new S(AUTHENTICATION_PROFILE_DESCRIPTION))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAuthUsersTableFSignature)->setLabel(new S(AUTHENTICATION_PROFILE_SIGNATURE))->setContainerDiv(new B(TRUE)); // Encrypt the data; if ($this->checkFormHasErrors()->toBoolean() == FALSE) { if ($this->checkPOST(self::$objAuthUsersTableFUPass)->toBoolean() == TRUE) { $this->setPOST(self::$objAuthUsersTableFUPass, $this->getPOST(self::$objAuthUsersTableFUPass)->encryptIt(sha1($this->getPOST(self::$objAuthUsersTableFUPass)))); $this->setPOST(new S('confirmation_password'), $this->getPOST(self::$objAuthUsersTableFUPass)); } } // Continue; $this->setFormEndAndExecute(new B(TRUE)); break; case 'userEdit': // Set some predefines; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Check if both password fields have been entered correctly; if ($this->checkPOST()->toBoolean() == TRUE) { // Check username ... if ($this->getPOST(self::$objAuthUsersTableFUName)->toLength()->toInt() == 0) { //Check non-empty username, and error if the username is empty; $this->setErrorOnInput(self::$objAuthUsersTableFUName, new S(AUTHENTICATION_USERNAME_IS_MANDATORY)); } // Check password mismatch; if ($this->getPOST(self::$objAuthUsersTableFUPass) == $this->getUserInfoById($_GET[ADMIN_ACTION_ID], self::$objAuthUsersTableFUPass) && $this->getPOST(new S('confirmation_password')) == $this->getPOST(self::$objAuthUsersTableFUPass)) { // Unset ... $this->unsetPOST(self::$objAuthUsersTableFUPass); } else { if ($this->getPOST(self::$objAuthUsersTableFUPass) != $this->getPOST(new S('confirmation_password'))) { $this->setErrorOnInput(self::$objAuthUsersTableFUPass, new S(AUTHENTICATION_USER_PASSWORDS_DONT_MATCH)); } } // Check phone number has 10 chars, only if it's required; if (self::PHONE_IS_REQUIRED == 1) { if ($this->getPOST(self::$objAuthUsersTableFPhone)->toLength()->toInt() != 10) { $this->setErrorOnInput(self::$objAuthUsersTableFPhone, new S(AUTHENTICATION_PHONE_TEN_CHARS)); } } } // Get AJAX; $this->getAjaxErrors(); // Make the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(AUTHENTICATION_PROFILE_EDIT))->setSQLAction(new S('update'))->setUpdateId($_GET[ADMIN_ACTION_ID])->setUploadDirectory(new S('users/avatars'))->setUploadImageResize(new A(array(128 => 128)))->setTableName(self::$objAuthUsersTable)->setUpdateField(self::$objAuthUsersTableFId)->setAJAXEnabledForm(new B(FALSE))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setName(new S('submit'))->setValue(new S(AUTHENTICATION_PROFILE_EDIT))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE)); // ONLY if we're NOT the BIG MAN, we cand de-activate; if ((int) $this->getUserInfoById($_GET[ADMIN_ACTION_ID], self::$objAuthUsersTableFId)->toString() != 1) { $this->setInputType(new S('select'))->setName(self::$objAuthUsersTableFActivated)->setContainerDiv(new B(TRUE))->setLabel(new S(AUTHENTICATION_PROFILE_ACTIVATED))->setInputType(new S('option'))->setName(new S('yes'))->setValue(new S('Y'))->setLabel(new S(AUTHENTICATION_PROFILE_ACTIVATED_YES))->setInputType(new S('option'))->setName(new S('no'))->setValue(new S('N'))->setLabel(new S(AUTHENTICATION_PROFILE_ACTIVATED_NO)); } $this->setInputType(new S('text'))->setName(self::$objAuthUsersTableFUName)->setLabel(new S(AUTHENTICATION_PROFILE_USERNAME))->setContainerDiv(new B(TRUE))->setJSRegExpReplace(new S('[^a-zA-Z0-9 .-]'))->setInputType(new S('password'))->setName(self::$objAuthUsersTableFUPass)->setValue($this->getUserInfoById($_GET[ADMIN_ACTION_ID], self::$objAuthUsersTableFUPass))->setLabel(new S(AUTHENTICATION_PROFILE_PASSWORD))->setContainerDiv(new B(TRUE))->setInputType(new S('password'))->setName(new S('confirmation_password'))->setValue($this->getUserInfoById($_GET[ADMIN_ACTION_ID], self::$objAuthUsersTableFUPass))->setLabel(new S(AUTHENTICATION_PROFILE_PASSWORD_CONFIRM))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFEML)->setJSRegExpReplace(new S('[^a-zA-Z0-9.@_-]'))->setLabel(new S(AUTHENTICATION_PROFILE_EMAIL))->setContainerDiv(new B(TRUE))->setRegExpType(new S('preg'))->setRegExpErrMsg(new S(AUTHENTICATION_INVALID_EMAIL))->setPHPRegExpCheck(new S(self::REGEXP_PHP_CHECK_EMAIL))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFPhone)->setLabel(new S(AUTHENTICATION_PROFILE_PHONE))->setContainerDiv(new B(TRUE))->setJSRegExpReplace(new S('[^0-9]'))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFLName)->setLabel(new S(AUTHENTICATION_PROFILE_LAST_NAME))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFFName)->setLabel(new S(AUTHENTICATION_PROFILE_FIRST_NAME))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthUsersTableFCountry)->setLabel(new S(AUTHENTICATION_PROFILE_COUNTRY)); // Countries ... foreach ($this->STG->getCountries() as $k => $v) { $this->setInputType(new S('option'))->setName($v[Settings::$objSettingsCountryTableFIso])->setValue($v[Settings::$objSettingsCountryTableFIso])->setLabel($v[Settings::$objSettingsCountryTableFPrnt]); } // Continue ... $this->setInputType(new S('text'))->setName(self::$objAuthUsersTableFCity)->setLabel(new S(AUTHENTICATION_PROFILE_CITY))->setContainerDiv(new B(TRUE)); // ONLY if we're not the BIG MAN, can we change the group; if ((int) $this->getUserInfoById($_GET[ADMIN_ACTION_ID], self::$objAuthUsersTableFId)->toString() != 1) { $this->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthUsersTableFUGId)->setLabel(new S(AUTHENTICATION_PROFILE_GROUP)); foreach (self::$objMPTT->mpttGetTree() as $k => $v) { $this->setInputType(new S('option'))->setName($v['id'])->setValue($v['id'])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . $v['name'])); } } // Execute the form, make it happen; $this->setInputType(new S('text'))->setName(self::$objAuthUsersTableFYM)->setLabel(new S(AUTHENTICATION_PROFILE_YM))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFMSN)->setLabel(new S(AUTHENTICATION_PROFILE_MSN))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFICQ)->setLabel(new S(AUTHENTICATION_PROFILE_ICQ))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFAOL)->setLabel(new S(AUTHENTICATION_PROFILE_AOL))->setContainerDiv(new B(TRUE))->setInputType(new S('file'))->setFileController(new B(TRUE))->setName(self::$objAuthUsersTableFAvatar)->setLabel(new S(AUTHENTICATION_PROFILE_AVATAR))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAuthUsersTableFDesc)->setLabel(new S(AUTHENTICATION_PROFILE_DESCRIPTION))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAuthUsersTableFSignature)->setLabel(new S(AUTHENTICATION_PROFILE_SIGNATURE))->setContainerDiv(new B(TRUE)); // Encrypt the data; if ($this->checkFormHasErrors()->toBoolean() == FALSE) { if ($this->checkPOST(self::$objAuthUsersTableFUPass)->toBoolean() == TRUE) { $this->setPOST(self::$objAuthUsersTableFUPass, $this->getPOST(self::$objAuthUsersTableFUPass)->encryptIt(sha1($this->getPOST(self::$objAuthUsersTableFUPass)))); $this->setPOST(new S('confirmation_password'), $this->getPOST(self::$objAuthUsersTableFUPass)); } } // Continue; $this->setFormEndAndExecute(new B(TRUE)); break; case 'userErase': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Check if it's administrator user, and don't delete it; if ((int) $_GET[ADMIN_ACTION_ID]->toString() == 1) { // Do not permit the deletion of the administrator user; self::$objAdministration->setErrorMessage(new S(CANNOT_DELETE_ADMINISTRATOR_USER), $objURLToGoBack); } else { // Check to see if there are any zone mappings, for the current zone; if ($this->_Q(_QS('doSELECT')->doToken('%what', new S('*'))->doToken('%table', self::$objAuthZoneMTable)->doToken('%condition', new S('WHERE %objAuthZoneMTableFUGId = "%Id" AND %objAuthZoneMTableFIUG = "N"'))->doToken('%Id', $_GET[ADMIN_ACTION_ID]))->doCount()->toInt() != 0) { // Do not delete users that have specific mappings; self::$objAdministration->setErrorMessage(new S(CANNOT_DELETE_MAPPED_USERS), $objURLToGoBack); } else { // Go further ... and erase the user ... $this->_Q(_QS('doDELETE')->doToken('%table', self::$objAuthUsersTable)->doToken('%condition', new S('%objAuthUsersTableFId = "%Id"'))->doToken('%Id', $_GET[ADMIN_ACTION_ID])); // Do a redirect, and get the user back where he belongs; $this->setHeaderKey($objURLToGoBack, new S('Location')); } } break; case 'userSearch': // Get some predefines; if (isset($_GET[ADMIN_ACTION_SEARCH])) { $objSearchWas = $_GET[ADMIN_ACTION_SEARCH]; } else { $objSearchWas = new S(); } if (isset($_GET[ADMIN_ACTION_BY])) { $objSearchBy = $_GET[ADMIN_ACTION_BY]; } else { $objSearchBy = new S(); } // Do some work; if ($this->checkPOST(new S('search_submit'))->toBoolean() == TRUE) { if ($this->getPOST(new S('search_user_by'))->toLength()->toInt() == 0) { if (isset($_GET[ADMIN_ACTION_SEARCH])) { // Erase search terms ... $this->setHeaderKey(URL::rewriteURL(new A(array(ADMIN_ACTION_SEARCH, ADMIN_ACTION_BY))), new S('Location')); } // Set an error, notify me ... $this->setErrorOnInput(new S('search_user_by'), new S(AUTHENTICATION_SEARCH_FIELD_IS_EMPTY)); // Unset the post ... $this->unsetPOST(); } else { // Get what to search and where ... $objWhatToSearch = $this->getPOST(new S('search_user_by')); $objWhereToSearch = $this->getPOST(new S('search_user_field')); // And go there ... $this->setHeaderKey(URL::rewriteURL(new A(array(ADMIN_ACTION_SEARCH, ADMIN_ACTION_BY)), new A(array($objWhatToSearch, $objWhereToSearch))), new S('Location')); } } $objWasSelected = new A(array(new B($objSearchBy == AUTHENTICATION_PROFILE_USERNAME ? TRUE : FALSE), new B($objSearchBy == AUTHENTICATION_PROFILE_EMAIL ? TRUE : FALSE), new B($objSearchBy == AUTHENTICATION_PROFILE_GROUP ? TRUE : FALSE))); // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(AUTHENTICATION_SEARCH_USER_BY))->setName($objFormToRender)->setInputType(new S('text'))->setInputInfoMessage($this->getHELP($objFormToRender))->setName(new S('search_user_by'))->setvalue($objSearchWas)->setLabel(new S(AUTHENTICATION_SEARCH_USER_BY))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(new S('search_user_field'))->setContainerDiv(new B(TRUE))->setLabel(new S(AUTHENTICATION_SEARCH_USER_IN))->setInputType(new S('option'))->setName(new S('username_search'))->setValue(new S(AUTHENTICATION_PROFILE_USERNAME))->setLabel(new S(AUTHENTICATION_PROFILE_USERNAME))->setSelected($objWasSelected[0])->setInputType(new S('option'))->setName(new S('email_search'))->setValue(new S(AUTHENTICATION_PROFILE_EMAIL))->setLabel(new S(AUTHENTICATION_PROFILE_EMAIL))->setSelected($objWasSelected[1])->setInputType(new S('option'))->setName(new S('group_serach'))->setValue(new S(AUTHENTICATION_PROFILE_GROUP))->setLabel(new S(AUTHENTICATION_PROFILE_GROUP))->setSelected($objWasSelected[2])->setInputType(new S('submit'))->setContainerDiv(new B(TRUE))->setValue(new S(AUTHENTICATION_SEARCH_USER_BY))->setName(new S('search_submit'))->setFormEndAndExecute(new B(TRUE)); break; case 'groupCreate': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(); // Do some work ... if ($this->checkPOST(new S('categories_show_all'))->toBoolean() == TRUE) { // Redirect to proper ... $this->setHeaderKey(URL::rewriteURL(new A(array(ADMIN_SHOW_ALL)), new A(array('1'))), new S('Location')); } // Do some work; if ($this->checkPOST(new S('submit_add_group'))->toBoolean() == TRUE) { // Set some requirements; $objFormHappened = new B(FALSE); if ($this->getPOST(new S('group'))->toLength()->toInt() == 0) { // Check for empty group name, and error on it. We don't allow empty group names; $this->setErrorOnInput(new S('group'), new S(GROUP_NAME_CANNOT_BE_EMPTY)); // Set to memory; $objFormHappened->switchType(); } else { if (self::$objMPTT->mpttCheckIfNodeExists($this->getPOST(new S('group')))->toBoolean() == TRUE) { // Check to see if the group exists, and tell the user the group exists; $this->setErrorOnInput(new S('group'), new S(GROUP_ALREADY_EXISTS)); // Set to memory; $objFormHappened->switchType(); } } // Get AJAX; $this->getAjaxErrors(); if ($objFormHappened->toBoolean() == FALSE) { // Remember if we should add it as a brother or child; $objAddNodeAS = NULL; // Switch ... switch ($this->getPOST(new S('group_as_what'))) { case AUTHENTICATION_GROUP_CHILD: $objAddNodeAS = new S((string) MPTT::FIRST_CHILD); break; case AUTHENTICATION_GROUP_LAST_CHILD: $objAddNodeAS = new S((string) MPTT::LAST_CHILD); break; case AUTHENTICATION_GROUP_BROTHER: $objAddNodeAS = new S((string) MPTT::PREVIOUS_BROTHER); break; case AUTHENTICATION_GROUP_NEXT_BROTHER: $objAddNodeAS = new S((string) MPTT::NEXT_BROTHER); break; } // Add the node; self::$objMPTT->mpttAddNode($this->getPOST(new S('group')), $this->getPOST(new S('group_parent_or_bro')), $objAddNodeAS); // Do a redirect back; $this->setHeaderKey($objURLToGoBack, new S('Location')); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(ADD_NEW_GROUP_OF_USERS))->setName(new S($objFormToRender))->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setName(new S('categories_show_all'))->setValue(new S(AUTHENTICATION_SHOW_ALL_CATEGORIES))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('submit'))->setContainerDiv(new B(TRUE))->setName(new S('submit_add_group'))->setValue(new S(AUTHENTICATION_ADD_GROUP))->setInputType(new S('text'))->setContainerDiv(new B(TRUE))->setName(new S('group'))->setLabel(new S(AUTHENTICATION_GROUP_NAME_LABEL))->setRegExpType(new S('ereg'))->setJSRegExpReplace(new S('[^a-zA-Z0-9 -]'))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(new S('group_as_what'))->setLabel(new S(AUTHENTICATION_AS_A))->setInputType(new S('option'))->setName(new S('as_child'))->setLabel(new S(AUTHENTICATION_GROUP_CHILD))->setInputType(new S('option'))->setName(new S('as_child'))->setLabel(new S(AUTHENTICATION_GROUP_LAST_CHILD))->setInputType(new S('option'))->setName(new S('as_brother'))->setLabel(new S(AUTHENTICATION_GROUP_BROTHER))->setInputType(new S('option'))->setName(new S('as_brother'))->setLabel(new S(AUTHENTICATION_GROUP_NEXT_BROTHER))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(new S('group_parent_or_bro'))->setLabel(new S(AUTHENTICATION_OF_GROUP)); // Do a foreach on the already existing groups; foreach (self::$objMPTT->mpttGetTree() as $k => $v) { $this->setInputType(new S('option'))->setName($v['name'])->setValue($v['name'])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . $v['name'])); } // Execute the form; $this->setFormEndAndExecute(new B(TRUE)); break; case 'groupEdit': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Do validation and error on it if something goes wrong; if ($this->checkPOST(self::$objAuthGroupTableFName)->toBoolean() == TRUE) { // Set some requirements; $objFormHappened = new B(FALSE); if ($this->getPOST(self::$objAuthGroupTableFName)->toLength()->toInt() == 0) { // Check for empty group name, and error on it. We don't allow empty group names; $this->setErrorOnInput(self::$objAuthGroupTableFName, new S(GROUP_NAME_CANNOT_BE_EMPTY)); // Set to memory; $objFormHappened->switchType(); } else { if (self::$objMPTT->mpttCheckIfNodeExists($this->getPOST(self::$objAuthGroupTableFName))->toBoolean() == TRUE) { // Check to see if the group exists, and tell the user the group exists; $this->setErrorOnInput(self::$objAuthGroupTableFName, new S(GROUP_ALREADY_EXISTS)); // Set to memory; $objFormHappened->switchType(); } } // Get AJAX; $this->getAjaxErrors(); } else { // Set some requirements; $objFormHappened = new B(FALSE); } // Do the form, make it happen; $this->setMethod(new S('POST'))->setSQLAction(new S('update'))->setTableName(self::$objAuthGroupTable)->setUpdateField(self::$objAuthGroupTableFId)->setUpdateId($_GET[ADMIN_ACTION_ID]); if ($this->checkPOST(self::$objAuthGroupTableFName)->toBoolean() == TRUE && $objFormHappened->toBoolean() == FALSE) { // Set the URL ... $this->setExtraUpdateData(self::$objAuthGroupTableFSEO, URL::getURLFromString($this->getPOST(self::$objAuthGroupTableFName)))->setRedirect($objURLToGoBack); } // Continue ... $this->setFieldset(new S(AUTHENTICATION_EDIT_GROUP))->setName($objFormToRender)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setName(new S('submit'))->setValue(new S(AUTHENTICATION_EDIT_GROUP))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setInputInfoMessage($this->getHELP($objFormToRender))->setName(self::$objAuthGroupTableFName)->setLabel(new S(AUTHENTICATION_GROUP_NAME_LABEL))->setContainerDiv(new B(TRUE))->setJSRegExpReplace(new S('[^a-zA-Z0-9 -]'))->setFormEndAndExecute(new B(TRUE)); break; case 'groupErase': // The URL to go back too; $objNodeHasKids = new B(FALSE); $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Check if it's administrator group; if ((int) $_GET[ADMIN_ACTION_ID]->toString() == 1) { // Show the ERRORs; self::$objAdministration->setErrorMessage(new S(CANNOT_ERASE_AUTHENTICATION_GROUP), $objURLToGoBack); } else { // Check to see if there are any zone mappings; if ($this->_Q(_QS('doSELECT')->doToken('%what', new S('*'))->doToken('%table', self::$objAuthZoneMTable)->doToken('%condition', new S('WHERE %objAuthZoneMTableFUGId = "%Id" AND %objAuthZoneMTableFIUG = "Y"'))->doToken('%Id', $_GET[ADMIN_ACTION_ID]))->doCount()->toInt() != 0) { // Do not delete groups with users in them; self::$objAdministration->setErrorMessage(new S(CANNOT_DELETE_MAPPED_GROUPS), $objURLToGoBack); } else { // Do erase the group node from the table; self::$objMPTT->mpttRemoveNode($this->getGroupInfoById($_GET[ADMIN_ACTION_ID], self::$objAuthGroupTableFName)); // Redirect back; $this->setHeaderKey($objURLToGoBack, new S('Location')); } } // BK; break; case 'groupMove': // Set some predefines; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_TO, ADMIN_ACTION_TYPE))); // Get names, as they are unique; $objThatIsMoved = $this->getGroupInfoById($_GET[ADMIN_ACTION_ID], self::$objAuthGroupTableFName); $objWhereToMove = $this->getGroupInfoById($_GET[ADMIN_ACTION_TO], self::$objAuthGroupTableFName); // Get the node subtree, that's move, make sure the node we move to ain't a child; $objMovedNodeSubTree = self::$objMPTT->mpttGetTree($objThatIsMoved); // Memorize; $objIsChild = new B(FALSE); foreach ($objMovedNodeSubTree as $k => $v) { if ($v[self::$objMPTT->objNameOfNode] == $objWhereToMove) { $objIsChild->switchType(); } } // Check if it's a child or not; if ($objIsChild->toBoolean() == TRUE) { // Set an error message; self::$objAdministration->setErrorMessage(new S(AUTHENTICATION_GROUP_MOVED_TO_CHILD), $objURLToGoBack); } else { // Move nodes; self::$objMPTT->mpttMoveNode($objThatIsMoved, $objWhereToMove, $_GET[ADMIN_ACTION_TYPE]); $this->setHeaderKey($objURLToGoBack, new S('Location')); } break; case 'zoneCreate': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(); // Do some work; if ($this->checkPOST()->toBoolean() == TRUE) { # Check that the zone name is not empty! if ($this->getPOST(self::$objAuthZonesTableFName)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objAuthZonesTableFName, new S(AUTHENTICATION_ZONE_NAME_CANNOT_BE_EMPTY)); } // Get AJAX; $this->getAjaxErrors(); } // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(AUTHENTICATION_ADD_ZONE))->setSQLAction(new S('update'))->setTableName(self::$objAuthZonesTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objAuthZonesTableFId)->setName($objFormToRender)->setRedirect($objURLToGoBack)->setAJAXEnabledForm(new B(FALSE))->setContainerDiv(new B(TRUE))->setInputType(new S('submit'))->setContainerDiv(new B(TRUE))->setValue(new S(AUTHENTICATION_ADD_ZONE))->setInputInfoMessage($this->getHELP($objFormToRender))->setInputType(new S('text'))->setName(self::$objAuthZonesTableFName)->setLabel(new S(AUTHENTICATION_ZONE_NAME))->setContainerDiv(new B(TRUE))->setJSRegExpReplace(new S('[^a-zA-Z0-9 ]'))->setInputType(new S('text'))->setName(self::$objAuthZonesTableFPrice)->setLabel(new S(AUTHENTICATION_ZONE_PRICE))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthZonesTableFDesc)->setLabel(new S(AUTHENTICATION_ZONE_DESCRIPTION))->setTinyMCETextarea(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'zoneEdit': // Set some predefines; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Do some validation, beforehand; if ($this->checkPOST()->toBoolean() == TRUE) { if ($this->checkPOST(self::$objAuthZonesTableFName)->toBoolean() == TRUE) { // Check that the zone name is not empty! if ($this->getPOST(self::$objAuthZonesTableFName)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objAuthZonesTableFName, new S(AUTHENTICATION_ZONE_NAME_CANNOT_BE_EMPTY)); } } // Get AJAX; $this->getAjaxErrors(); } // Add some restrictions ... if ($this->_Q(_QS('doSELECT')->doToken('%what', new S('*'))->doToken('%table', self::$objAuthZoneMTable)->doToken('%condition', new S('WHERE %objAuthZoneMTableFZId = "%Id"'))->doToken('%Id', $_GET[ADMIN_ACTION_ID]))->doCount()->toInt() != 0) { // The name should not be changed, due to mapping; $objNameChangeDisabled = new B(TRUE); } else { // The name can be changed; $objNameChangeDisabled = new B(FALSE); } // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(AUTHENTICATION_EDIT_ZONE))->setSQLAction(new S('update'))->setTableName(self::$objAuthZonesTable)->setUpdateId($_GET[ADMIN_ACTION_ID])->setUpdateField(self::$objAuthZonesTableFId)->setName($objFormToRender)->setRedirect($objURLToGoBack)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setContainerDiv(new B(TRUE))->setValue(new S(AUTHENTICATION_EDIT_ZONE))->setInputInfoMessage($this->getHELP($objFormToRender))->setInputType(new S('text'))->setName(self::$objAuthZonesTableFName)->setLabel(new S(AUTHENTICATION_ZONE_NAME))->setContainerDiv(new B(TRUE))->setReadOnly($objNameChangeDisabled)->setJSRegExpReplace(new S('[^a-zA-Z0-9 .]'))->setInputType(new S('text'))->setName(self::$objAuthZonesTableFPrice)->setLabel(new S(AUTHENTICATION_ZONE_PRICE))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAuthZonesTableFDesc)->setLabel(new S(AUTHENTICATION_ZONE_DESCRIPTION))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'zoneErase': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Check to see if there are any zone mappings, for the current zone; $objSQLCondition = new S('WHERE %s = %i'); // Erase it; $this->_Q(_QS('doDELETE')->doToken('%table', self::$objAuthZonesTable)->doToken('%condition', new S('%objAuthZonesTableFId = "%Id"'))->doToken('%Id', $_GET[ADMIN_ACTION_ID])); // Redirect the user back; $this->setHeaderKey($objURLToGoBack, new S('Location')); break; case 'zoneMappingCreateForGroups': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(); // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(AUTHENTICATION_ADD_ACL))->setSQLAction(new S('update'))->setTableName(self::$objAuthZoneMTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objAuthZoneMTableFId)->setExtraUpdateData(self::$objAuthZoneMTableFIUG, new S('Y'))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(AUTHENTICATION_ADD_ACL))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthZoneMTableFUGId)->setLabel(new S(AUTHENTICATION_ACL_ENTITY)); // Get the groups; foreach (self::$objMPTT->mpttGetTree() as $k => $v) { $this->setInputType(new S('option'))->setName($v[self::$objAuthGroupTableFId])->setValue($v[self::$objAuthGroupTableFId])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . $v[self::$objAuthGroupTableFName])); } // Continue; $this->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthZoneMTableFZId)->setLabel(new S(AUTHENTICATION_ZONE_NAME)); // Get the zones; foreach ($this->getZones(NULL) as $k => $v) { $this->setInputType(new S('option'))->setName($v[self::$objAuthZonesTableFId])->setValue($v[self::$objAuthZonesTableFId])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . $v[self::$objAuthZonesTableFName])); } // Continue; $this->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthZoneMTableFAorD)->setLabel(new S(AUTHENTICATION_ACL_ACCESS_TYPE))->setInputType(new S('option'))->setName(new S('deny_or_allow_allow'))->setValue(new S('A'))->setLabel(new S(AUTHENTICATION_ACL_ALLOWED))->setInputType(new S('option'))->setName(new S('deny_or_allow_deny'))->setValue(new S('D'))->setLabel(new S(AUTHENTICATION_ACL_DENIED))->setFormEndAndExecute(new B(TRUE)); break; case 'zoneMappingCreateForUsers': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(); // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(AUTHENTICATION_ADD_ACL))->setSQLAction(new S('update'))->setTableName(self::$objAuthZoneMTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objAuthZoneMTableFId)->setExtraUpdateData(self::$objAuthZoneMTableFIUG, new S('N'))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setInputInfoMessage($this->getHELP($objFormToRender))->setValue(new S(AUTHENTICATION_ADD_ACL))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthZoneMTableFUGId)->setLabel(new S(AUTHENTICATION_ACL_ENTITY)); // Get the users; foreach ($this->getUsers() as $k => $v) { $this->setInputType(new S('option'))->setName($v[self::$objAuthUsersTableFId])->setValue($v[self::$objAuthUsersTableFId])->setLabel($v[self::$objAuthUsersTableFUName]); } // Continue; $this->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthZoneMTableFZId)->setLabel(new S(AUTHENTICATION_ZONE_NAME)); // Get zones; foreach ($this->getZones(NULL) as $k => $v) { $this->setInputType(new S('option'))->setName($v[self::$objAuthZonesTableFId])->setValue($v[self::$objAuthZonesTableFId])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . $v[self::$objAuthZonesTableFName])); } // Continue; $this->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthZoneMTableFAorD)->setLabel(new S(AUTHENTICATION_ACL_ACCESS_TYPE))->setInputType(new S('option'))->setName(new S('deny_or_allow_allow'))->setValue(new S('A'))->setLabel(new S(AUTHENTICATION_ACL_ALLOWED))->setInputType(new S('option'))->setName(new S('deny_or_allow_deny'))->setValue(new S('D'))->setLabel(new S(AUTHENTICATION_ACL_DENIED))->setFormEndAndExecute(new B(TRUE)); break; case 'zoneMappingEdit': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(AUTHENTICATION_EDIT_ACL))->setSQLAction(new S('update'))->setTableName(self::$objAuthZoneMTable)->setUpdateId($_GET[ADMIN_ACTION_ID])->setUpdateField(self::$objAuthZoneMTableFId)->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(AUTHENTICATION_EDIT_ACL))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthZoneMTableFAorD)->setLabel(new S(AUTHENTICATION_ACL_ACCESS_TYPE))->setInputType(new S('option'))->setName(new S('deny_or_allow_allow'))->setValue(new S('A'))->setLabel(new S(AUTHENTICATION_ACL_ALLOWED))->setInputType(new S('option'))->setName(new S('deny_or_allow_deny'))->setValue(new S('D'))->setLabel(new S(AUTHENTICATION_ACL_DENIED))->setFormEndAndExecute(new B(TRUE)); break; case 'zoneMappingErase': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Erase it; $this->_Q(_QS('doDELETE')->doToken('%table', self::$objAuthZoneMTable)->doToken('%condition', new S('%objAuthZoneMTableFId = "%Id"'))->doToken('%Id', $_GET[ADMIN_ACTION_ID])); // Do a redirect, and get the user back where he belongs; $this->setHeaderKey($objURLToGoBack, new S('Location')); break; case 'configurationEdit': // Set some requirements; $objURLToGoBack = URL::rewriteURL(); // Do form validation; if ($this->checkPOST()->toBoolean() == TRUE) { // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION)), new A(array($this->getPOST(new S('what'))))); } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUTHENTICATION_MANAGE_CONFIGURATION))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S('Do'))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(new S('what'))->setLabel(new S('Choose'))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('configurationEdit-register_page_content'))->setValue(new S('configurationEdit-register_page_content'))->setLabel(new S(AUTHENTICATION_REG_PAGE_FORM_CONTENT))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('configurationEdit-register_ok_page_content'))->setValue(new S('configurationEdit-register_ok_page_content'))->setLabel(new S(AUTHENTICATION_REG_PAGE_FORM_SUCCESS_CONTENT))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('configurationEdit-activation_page_content'))->setValue(new S('configurationEdit-activation_page_content'))->setLabel(new S(AUTHENTICATION_REG_PAGE_FORM_ACTIVATE_CONTENT))->setInputType(new S('option'))->setName(new S('configurationEdit-activation_not_ok_page_content'))->setValue(new S('configurationEdit-activation_not_ok_page_content'))->setLabel(new S(AUTHENTICATION_REG_PAGE_FORM_ACTIVATE_NOTOK))->setFormEndAndExecute(new B(TRUE)); break; case 'configurationEdit-register_page_content': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION))); // Do some work; if ($this->checkPOST()->toBoolean() == TRUE) { foreach ($this->getPOST() as $k => $v) { $this->setConfigKey(new S($k), $v); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUTHENTICATION_MANAGE_CONFIGURATION))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(AUTHENTICATION_MANAGE_CONFIGURATION))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(new S('authentication_page_register_message'))->setLabel(new S(AUTHENTICATION_CONFIG_DEFAULT))->setTinyMCETextarea(new B(TRUE))->setValue($this->getConfigKey(new S('authentication_page_register_message')))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'configurationEdit-register_ok_page_content': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION))); // Do some work; if ($this->checkPOST()->toBoolean() == TRUE) { foreach ($this->getPOST() as $k => $v) { $this->setConfigKey(new S($k), $v); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUTHENTICATION_MANAGE_CONFIGURATION))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(AUTHENTICATION_MANAGE_CONFIGURATION))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(new S('authentication_page_register_ok_message'))->setLabel(new S(AUTHENTICATION_CONFIG_DEFAULT))->setTinyMCETextarea(new B(TRUE))->setValue($this->getConfigKey(new S('authentication_page_register_ok_message')))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'configurationEdit-activation_page_content': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION))); // Do some work; if ($this->checkPOST()->toBoolean() == TRUE) { foreach ($this->getPOST() as $k => $v) { $this->setConfigKey(new S($k), $v); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUTHENTICATION_MANAGE_CONFIGURATION))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(AUTHENTICATION_MANAGE_CONFIGURATION))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(new S('authentication_page_activation_ok_message'))->setLabel(new S(AUTHENTICATION_CONFIG_DEFAULT))->setTinyMCETextarea(new B(TRUE))->setValue($this->getConfigKey(new S('authentication_page_activation_ok_message')))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'configurationEdit-activation_not_ok_page_content': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION))); // Do some work; if ($this->checkPOST()->toBoolean() == TRUE) { foreach ($this->getPOST() as $k => $v) { $this->setConfigKey(new S($k), $v); } } // Do the form, make it happen; $this->setMethod(new S('POST'))->setFieldset(new S(AUTHENTICATION_MANAGE_CONFIGURATION))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(AUTHENTICATION_MANAGE_CONFIGURATION))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(new S('authentication_page_activation_not_ok_message'))->setLabel(new S(AUTHENTICATION_CONFIG_DEFAULT))->setTinyMCETextarea(new B(TRUE))->setValue($this->getConfigKey(new S('authentication_page_activation_not_ok_message')))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; } }
/** * Will render a requested widget; * * This method is used to render a widget that usually is used in the frontend part of any website done with the help of this * platform. What are widgets you ask?! Well, it's quite simple. They are pieces of PHP code, usually tied to some * configuration options that control the way the widget functions or showns; * * Usually, configured widgets have enough power to be used in any way you want or need. For most of the times, the widgets * are called in the proper section of the frontend, but this method must permit the use of widgets, independent of the place * the developer needs them; * * @param $objW The widget to render; * @return mixed Depends on the widget; */ public function renderWidget(S $objW, A $objWA = NULL) { // Make an empty array if NULL ... if ($objWA == NULL) { $objWA = new A(); } // XML & RSS: Do a switch ... switch ($objW) { case 'widgetXML': // Yo man ... woohoooooo ... foreach ($this->getTexts(new S('ORDER BY %objTextTableFDatePublished DESC')) as $k => $v) { // Set some requirements ... $objSEC = $this->getCategoryInfoById($v[self::$objTextTableFCategoryId], self::$objCategoryTableFSEO); $objDTE = date('Y-m-d', (int) $v[self::$objTextTableFDatePublished]->toString()); $objLOC = URL::staticURL(new A(array(TEXTS_TEXTS_URL, FRONTEND_SECTION_URL)), new A(array($v[self::$objTextTableFSEO], $objSEC))); // Get the (INNER) CHILD of every young SEO freak ... $objURL = $objWA['objXML']->addCHILD(Frontend::XML_URL); // Set the XML Sitemap kids ... $objURL->addCHILD(Frontend::XML_LOCATION, $objLOC); $objURL->addCHILD(Frontend::XML_LAST_MOD, $objDTE); $objURL->addCHILD(Frontend::XML_CHANGE_FREQ, self::XML_SITEMAP_FREQUENCY); $objURL->addCHILD(Frontend::XML_PRIORITY, self::XML_SITEMAP_PRIORITY); } // BK; break; case 'widgetRSS': // Yo man ... woohoooooo ... if ($_GET[FRONTEND_FEED_URL] == __CLASS__) { // Get'em 30 ... foreach ($this->getTexts(new S('ORDER BY %objTextTableFDatePublished DESC LIMIT 0, 30')) as $k => $v) { // Set some requirements ... $objSEC = $this->getCategoryInfoById($v[self::$objTextTableFCategoryId], self::$objCategoryTableFSEO); $objDTE = date(DATE_RFC822, (int) $v[self::$objTextTableFDatePublished]->toString()); $objLOC = URL::staticURL(new A(array(TEXTS_TEXTS_URL, FRONTEND_SECTION_URL)), new A(array($v[self::$objTextTableFSEO], $objSEC))); $objDSC = $v[self::$objTextTableFContent]->entityEncode(ENT_QUOTES)->entityDecode(ENT_QUOTES)->stripTags(); $objTTL = $v[self::$objTextTableFTitle]; // Get the (INNER) CHILD of every young SEO freak ... $objURL = $objWA['objXML']->addCHILD(Frontend::RSS_ITEM); // Set the RSS kids ... $objURL->addCHILD(Frontend::RSS_TITLE, $objTTL); $objURL->addCHILD(Frontend::RSS_LINK, $objLOC); $objURL->addCHILD(Frontend::RSS_GUID, $objLOC); $objURL->addCHILD(Frontend::RSS_PUBLISHED_DATE, $objDTE); $objURL->addCHILD(Frontend::RSS_DESCRIPTION, $objDSC); } } // BK; break; } // HTML: Do a switch ... switch ($objW) { case 'widgetCategoryList': // Set some requirements, if not set ... if ($objWA == NULL) { $objWA = new A(); } // Get the category to start from ... if (isset($objWA['start_from_category'])) { // Get the category LIST; $objCategoryList = $this->getCategories(NULL, $objWA['start_from_category']); } else { // Get the category LIST; $objCategoryList = $this->getCategories(NULL, NULL); } // Set the template file ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION); TPL::tpSet($objCategoryList, new S('objCategoryList'), $tpF); TPL::tpSet($objWA, new S('objWidgetArray'), $tpF); TPL::tpSet($this, new S('TXT'), $tpF); TPL::tpExe($tpF); break; case 'widgetList': // Do some checking ... before anything ... if (isset($_GET[TEXTS_TEXTS_URL])) { // Check or redirect ... if ($this->checkTextExistsByURL($_GET[TEXTS_TEXTS_URL])->toBoolean() == FALSE) { // The text does not exist, than redirect to 404; $this->setHeaderStr(new S(HDR::HEADER_MOVED_PERMANENTLY)); $this->setHeaderKey(URL::staticURL(new A(array(FRONTEND_ERROR_URL)), new A(array('404'))), new S('Location')); } else { // Get the TEXT ... $objTextCNT = $this->getTextInfoByURL($_GET[TEXTS_TEXTS_URL], self::$objTextTableFContent); $objTextTTL = $this->getTextInfoByURL($_GET[TEXTS_TEXTS_URL], self::$objTextTableFTitle); $objTextKEY = $this->getTextInfoByURL($_GET[TEXTS_TEXTS_URL], self::$objTextTableFTags); $objTextDSC = clone $objTextTTL; // Set the title, keywords, description ... TPL::manageTTL($objTextTTL); TPL::manageTAG(new S('keywords'), $objTextKEY->entityEncode(ENT_QUOTES)); TPL::manageTAG(new S('description'), $objTextDSC->entityEncode(ENT_QUOTES)); // Set the template file ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . '-Item' . TPL_EXTENSION); TPL::tpSet($objTextTTL, new S('objTextTTL'), $tpF); TPL::tpSet($objTextCNT, new S('objTextCNT'), $tpF); TPL::tpSet($this, new S('TXT'), $tpF); TPL::tpExe($tpF); } } else { // Get the CATEGORY ... if ($this->checkCategoryExistsByURL($_GET[FRONTEND_SECTION_URL])->toBoolean() == FALSE) { // The category does not exist, than redirect to 404; $this->setHeaderStr(new S(HDR::HEADER_MOVED_PERMANENTLY)); $this->setHeaderKey(URL::staticURL(new A(array(FRONTEND_ERROR_URL)), new A(array('404'))), new S('Location')); } else { // Get something from db ... $objCategoryArray = $this->getTextsByCategoryURL($_GET[FRONTEND_SECTION_URL]); // Check how many texts are defined for it ... switch ($objCategoryArray->doCount()->toInt()) { // If we have only ONE text, defined for a category, // we then recommend moving to that text ... case 1: // MOVED ... permanently ... $this->setHeaderStr(new S(HDR::HEADER_MOVED_PERMANENTLY)); $this->setHeaderKey(URL::rewriteURL(new A(array(TEXTS_TEXTS_URL, FRONTEND_SECTION_URL)), new A(array($objCategoryArray[0][self::$objTextTableFSEO], $_GET[FRONTEND_SECTION_URL]))), new S('Location')); break; // In case we don't have any text defined, // we recommend showing a default message. // In case we don't have any text defined, // we recommend showing a default message. case 0: break; // And finally, if we have more than one, then // we recommend showing a LIST, by default reversed ... // And finally, if we have more than one, then // we recommend showing a LIST, by default reversed ... default: // Set the title, keywords, description ... TPL::manageTTL($objCategoryNME = $this->getCategoryInfoByURL($objCategoryURL = $_GET[FRONTEND_SECTION_URL], self::$objCategoryTableFName)); TPL::manageTAG(new S('description'), $objCategoryNME); // Set the template file ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION); TPL::tpSet($objCategoryArray->arrayReverse(), new S('objCategoryArray'), $tpF); TPL::tpSet($objCategoryURL, new S('objCategory'), $tpF); TPL::tpSet($objWA, new S('objWidgetArray'), $tpF); TPL::tpSet($this, new S('TXT'), $tpF); TPL::tpExe($tpF); break; } } } // Break out ... break; case 'widgetComments': // Check if we have the proper URL enabled ... if (isset($_GET[TEXTS_TEXTS_URL])) { // Check if the comments are enabled ... if ($this->getTextInfoByURL($objURL = $_GET[TEXTS_TEXTS_URL], self::$objTextTableFCanComment) == 'Y') { // Set some requirements ... $objCommentIsOk = new S(); $objComments = $this->getApprovedCommentsByTextURL($_GET[TEXTS_TEXTS_URL], new S('ORDER BY %objCommentsTableFDate DESC')); // Check for status ... if (isset($_GET[TEXTS_STATUS_URL])) { if ($_GET[TEXTS_STATUS_URL] == TEXTS_STATUS_OK_URL) { $objCommentIsOk = new S($objWA['comment_has_been_added']); } } // Set the template file ... $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION); TPL::tpSet($objCommentIsOk, new S('objCommentIsOk'), $tpF); TPL::tpSet($objComments, new S('objComments'), $tpF); TPL::tpSet($this->ATH, new S('ATH'), $tpF); TPL::tpSet($this->STG, new S('STG'), $tpF); TPL::tpExe($tpF); // Set some requirements ... $objShowFrm = new B(TRUE); // Check if we're allowed to show the comment form ... if ($this->getConfigKey(new S('texts_settings_authenticated_to_comment')) == 'Y') { if ($this->ATH->checkIfUserIsLoggedIn()->toBoolean() == TRUE) { $objShowFrm = new B(TRUE); } else { $objShowFrm = new B(FALSE); } } // Do some work ... if ($objShowFrm->toBoolean() == TRUE) { if ($this->checkPOST(self::$objCommentsTableFComment)->toBoolean() == TRUE) { if ($this->getPOST(self::$objCommentsTableFComment)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objCommentsTableFComment, new S($objWA['error_no_comment'])); } } if ($this->checkPOST(self::$objCommentsTableFName)->toBoolean() == TRUE) { if ($this->getPOST(self::$objCommentsTableFName)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objCommentsTableFName, new S($objWA['error_no_name'])); } } if ($this->checkPOST(self::$objCommentsTableFEML)->toBoolean() == TRUE) { if ($this->getPOST(self::$objCommentsTableFEML)->toLength()->toInt() == 0) { $this->setErrorOnInput(self::$objCommentsTableFEML, new S($objWA['error_no_email'])); } } // Make the form ... (ya, outside the box ...); $this->setMethod(new S('POST'))->setFieldset(new S($objWA['comment_add']))->setSQLAction(new S('update'))->setTableName(self::$objCommentsTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objCommentsTableFId); if ($this->checkPOST(self::$objCommentsTableFComment)->toBoolean() == TRUE) { $this->setRedirect(URL::rewriteURL(new A(array(TEXTS_STATUS_URL)), new A(array(TEXTS_STATUS_OK_URL)))); } $this->setName(new S('commentForm'))->setExtraUpdateData(self::$objCommentsTableFDate, new S((string) time()))->setExtraUpdateData(self::$objCommentsTableFTextId, $this->getTextInfoByURL($_GET[TEXTS_TEXTS_URL], self::$objTextTableFId))->setInputType(new S('submit'))->setValue(new S($objWA['comment_submit']))->setName(new S('submit'))->setContainerDiv(new B(TRUE)); // Check if the user is authenticated ... if ($this->ATH->checkIfUserIsLoggedIn()->toBoolean() == TRUE) { // Set the RUId; $this->setExtraUpdateData(self::$objCommentsTableFRUId, $this->ATH->getCurrentUserInfoById(Authentication::$objAuthUsersTableFId)); } else { // Set the other infos; $this->setInputType(new S('text'))->setName(self::$objCommentsTableFName)->setLabel(new S($objWA['comment_name']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objCommentsTableFEML)->setLabel(new S($objWA['comment_email']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objCommentsTableFURL)->setLabel(new S($objWA['comment_website']))->setContainerDiv(new B(TRUE)); } // Continue ... $this->setInputType(new S('textarea'))->setName(self::$objCommentsTableFComment)->setLabel(new S($objWA['comment_message']))->setRows(new S('10'))->setTinyMCETextarea(new B(TRUE))->setClass(new S('tinyMCESimple'))->setContainerDiv(new B(TRUE)); // Notify ... if ($this->checkFormHasErrors()->toBoolean() == FALSE && $this->checkPOST(self::$objCommentsTableFComment)->toBoolean() == TRUE) { if ($this->ATH->checkIfUserIsLoggedIn()->toBoolean() == TRUE) { // Query the authentication ... $objUSR = $this->ATH->getCurrentUserInfoById(Authentication::$objAuthUsersTableFUName); } else { // Or trust the FORM ... $objUSR = $this->getPOST(self::$objCommentsTableFName); } // Go and SP ... MAIL me ... $objMAIL = new MAIL(); $objMAIL->doMAIL($this->STG->getConfigKey(new S('settings_website_notification_email')), new S(TEXTS_COMMENT_HAS_BEEN_POSTED), $this->getHELP(new S('widgetCommentsEMLNotifyAdmin'))->doToken('%u', $objUSR)); // Go deeper and notify them users ... $objCommentsForItem = $this->getCommentsByTextURL($objURL); foreach ($objCommentsForItem as $k => $v) { $objMAIL = new MAIL(); $objMAIL->doMAIL($this->ATH->getUserInfoById($v[Texts::$objCommentsTableFRUId], Authentication::$objAuthUsersTableFEML), new S(TEXTS_COMMENT_HAS_BEEN_POSTED), $this->getHELP(new S('widgetCommentsEMLNotifyUsers'))->doToken('%u', $objUSR)->doToken('%k', URL::rewriteURL())); } } // End form and execute ... $this->setFormEndAndExecute(new B(TRUE)); } } } // Break out ... break; } }
/** * 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 better; * * @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 renderForm(S $objFormToRender, A $objFormArray = NULL) { // Make them defaults ... if ($objFormArray == NULL) { $objFormArray = new A(); } // Do a switch ... switch ($objFormToRender) { case 'widgetSearch': // Do the form, make it happen ... $this->setMethod(new S('POST'))->setName($objFormToRender); // Do some work ... if ($this->checkPOST(new S('search_lyrics'))->toBoolean() == TRUE) { // Get the title, and check it's name ... if ($this->getPOST(new S('lyrics_search_keyword'))->toLength()->toInt() == 0) { // Well, sadly, we have an issue ... $this->setErrorOnInput(new S('lyrics_search_keyword'), new S('Nu ai completat cautarea!')); } else { // Go ... $this->setHeaderKey($objURLToGoBack = URL::staticURL(new A(array(FRONTEND_SECTION_URL, LYRICS_SEARCH_URL)), new A(array(FRONTEND_LYRICS_URL, $this->getPOST(new S('lyrics_search_keyword'))->entityDecode(ENT_QUOTES)->stripSlashes()))), new S('Location')); } } // Continue ... $this->setInputType(new S('text'))->setName(new S('lyrics_search_keyword')); // If it's set ... add the VALUE ... if (isset($_GET[LYRICS_SEARCH_URL])) { $this->setValue($_GET[LYRICS_SEARCH_URL]); } // Continue ... $this->setLabel(new S('Cuvant'))->setContainerDiv(new B(TRUE))->setInputType(new S('submit'))->setName(new S('search_lyrics'))->setValue(new S('Cauta'))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'lyricCreate': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(); $objErrorHappen = new B(FALSE); // Do some work; if ($this->checkPOST(self::$objLyricsTableFTitle)->toBoolean() == TRUE) { // Check != 0 ... if ($this->getPOST(self::$objLyricsTableFTitle)->toLength()->toInt() == 0) { self::setErrorOnInput(self::$objLyricsTableFTitle, new S(LYRICS_TITLE_CANNOT_BE_EMPTY)); $objErrorHappen = new B(TRUE); } } if ($this->checkPOST(self::$objLyricsTableFArtist)->toBoolean() == TRUE) { // Check != 0 ... if ($this->getPOST(self::$objLyricsTableFArtist)->toLength()->toInt() == 0) { self::setErrorOnInput(self::$objLyricsTableFArtist, new S(LYRICS_ARTIST_CANNOT_BE_EMPTY)); $objErrorHappen = new B(TRUE); } } if ($this->checkPOST(self::$objLyricsTableFAlbum)->toBoolean() == TRUE) { // Check != 0 ... if ($this->getPOST(self::$objLyricsTableFAlbum)->toLength()->toInt() == 0) { self::setErrorOnInput(self::$objLyricsTableFAlbum, new S(LYRICS_ALBUM_CANNOT_BE_EMPTY)); $objErrorHappen = new B(TRUE); } } // Get AJAX; $this->getAjaxErrors(); // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(LYRICS_ADD_LYRIC))->setSQLAction(new S('update'))->setTableName(self::$objLyricsTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objLyricsTableFId)->setExtraUpdateData(self::$objLyricsTableFDateAdded, new S((string) $_SERVER['REQUEST_TIME'])); if ($this->checkPOST(self::$objLyricsTableFTitle)->toBoolean() == TRUE && $objErrorHappen->toBoolean() == FALSE) { $this->setExtraUpdateData(self::$objLyricsTableFSEO, URL::getURLFromString(new S($this->getPOST(self::$objLyricsTableFTitle) . _U . $this->getPOST(self::$objLyricsTableFArtist) . _U . $this->getPOST(self::$objLyricsTableFAlbum) . _U . $_SERVER['REQUEST_TIME']))); } $this->setName($objFormToRender)->setRedirect($objURLToGoBack)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setInputInfoMessage($this->getHELP($objFormToRender))->setValue(new S(LYRICS_ADD_LYRIC))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objLyricsTableFTitle)->setLabel(new S(LYRICS_TITLE))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objLyricsTableFArtist)->setLabel(new S(LYRICS_ARTIST))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objLyricsTableFAlbum)->setLabel(new S(LYRICS_ALBUM))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objLyricsTableFLyrics)->setLabel(new S(LYRICS_LYRIC))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'lyricEdit': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); $objErrorHappen = new B(FALSE); // Do some work; if ($this->checkPOST(self::$objLyricsTableFTitle)->toBoolean() == TRUE) { // Check != 0 ... if ($this->getPOST(self::$objLyricsTableFTitle)->toLength()->toInt() == 0) { self::setErrorOnInput(self::$objLyricsTableFTitle, new S(LYRICS_TITLE_CANNOT_BE_EMPTY)); $objErrorHappen = new B(TRUE); } } if ($this->checkPOST(self::$objLyricsTableFArtist)->toBoolean() == TRUE) { // Check != 0 ... if ($this->getPOST(self::$objLyricsTableFArtist)->toLength()->toInt() == 0) { self::setErrorOnInput(self::$objLyricsTableFArtist, new S(LYRICS_ARTIST_CANNOT_BE_EMPTY)); $objErrorHappen = new B(TRUE); } } if ($this->checkPOST(self::$objLyricsTableFAlbum)->toBoolean() == TRUE) { // Check != 0 ... if ($this->getPOST(self::$objLyricsTableFAlbum)->toLength()->toInt() == 0) { self::setErrorOnInput(self::$objLyricsTableFAlbum, new S(LYRICS_ALBUM_CANNOT_BE_EMPTY)); $objErrorHappen = new B(TRUE); } } // Get AJAX; $this->getAjaxErrors(); // Do the form, make it happen; $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(LYRICS_EDIT_LYRIC))->setSQLAction(new S('update'))->setTableName(self::$objLyricsTable)->setUpdateId($_GET[ADMIN_ACTION_ID])->setUpdateField(self::$objLyricsTableFId); if ($this->checkPOST(self::$objLyricsTableFTitle)->toBoolean() == TRUE && $objErrorHappen->toBoolean() == FALSE) { $this->setExtraUpdateData(self::$objLyricsTableFSEO, URL::getURLFromString(new S($this->getPOST(self::$objLyricsTableFTitle) . _U . $this->getPOST(self::$objLyricsTableFArtist) . _U . $this->getPOST(self::$objLyricsTableFAlbum) . _U . $this->getLyricInfoById($_GET[ADMIN_ACTION_ID], self::$objLyricsTableFDateAdded)))); } $this->setName($objFormToRender)->setRedirect($objURLToGoBack)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setInputInfoMessage($this->getHELP($objFormToRender))->setValue(new S(LYRICS_EDIT_LYRIC))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objLyricsTableFTitle)->setLabel(new S(LYRICS_TITLE))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objLyricsTableFArtist)->setLabel(new S(LYRICS_ARTIST))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objLyricsTableFAlbum)->setLabel(new S(LYRICS_ALBUM))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objLyricsTableFLyrics)->setLabel(new S(LYRICS_LYRIC))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE)); break; case 'lyricErase': // The URL to go back too; $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID))); // Do erase it ... $this->_Q(_QS('doDELETE')->doToken('%table', self::$objLyricsTable)->doToken('%condition', new S('%objLyricsTableFId = "%Id"'))->doToken('%Id', $_GET[ADMIN_ACTION_ID])); // Do a redirect back; $this->setHeaderKey($objURLToGoBack, new S('Location')); break; } }
/** * 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; } }