Пример #1
0
 /**
  * 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 renderBackendPage(S $objPageToRender)
 {
     // Get a specific CSS file for this controller ...
     TPL::manageCSS(new FilePath($this->getPathToSkinCSS()->toRelativePath() . $objPageToRender . CSS_EXTENSION), $objPageToRender);
     // Do pagination ...
     if (isset($_GET[ADMIN_PAGINATION])) {
         $objLowerLimit = (int) $_GET[ADMIN_PAGINATION]->toString() * 10 - 10;
         $objUpperLimit = 10;
     } else {
         $objLowerLimit = 0;
         $objUpperLimit = 10;
     }
     // Do a switch on the rendered page ...
     switch ($objPageToRender) {
         case 'manageArticles':
             // Check if there's an action to take;
             if (isset($_GET[ADMIN_ACTION])) {
                 // Do a switch ...
                 switch ($_GET[ADMIN_ACTION]) {
                     case ADMIN_ACTION_EDIT:
                         $this->renderForm(new S('articleEdit'));
                         break;
                     case ADMIN_ACTION_ERASE:
                         $this->renderForm(new S('articleErase'));
                         break;
                 }
             } else {
                 // Redirect to DescByPublished ...
                 if (!isset($_GET[ADMIN_ACTION_SORT])) {
                     $this->setHeaderKey(URL::rewriteURL(new A(array(ADMIN_ACTION_SORT)), new A(array('DescByPublished'))), new S('Location'));
                 }
                 // Set some requirements ...
                 $objGetCondition = new S();
                 if (isset($_GET[ADMIN_ACTION_BY])) {
                     // Do a switch ...
                     switch ($_GET[ADMIN_ACTION_BY]) {
                         case ARTICLES_SEARCH_TITLE:
                             $objGetCondition->appendString(_SP)->appendString('WHERE %objArticleTableFTitle');
                             break;
                         case ARTICLES_SEARCH_CONTENT:
                             $objGetCondition->appendString(_SP)->appendString('WHERE %objArticleTableFContent');
                             break;
                         case ARTICLES_SEARCH_TAGS:
                             $objGetCondition->appendString(_SP)->appendString('WHERE %objArticleTableFTags');
                             break;
                         case ARTICLES_SEARCH_EXCERPT:
                             $objGetCondition->appendString(_SP)->appendString('WHERE %objArticleTableFExcerpt');
                             break;
                         case ARTICLES_SEARCH_CATEGORY:
                             $objGetCondition->appendString('AS t1 INNER JOIN %objCategoryTable AS t2
                             ON t1.%objArticleTableFCategoryId = t2.%objCategoryTableFId
                             WHERE %objCategoryTableFName');
                             break;
                     }
                     // Add LIKE searching ...
                     $objGetCondition->appendString(_SP)->appendString('LIKE "%%Search%"')->doToken('%Search', $_GET[ADMIN_ACTION_SEARCH]);
                     // Get the count ...
                     $objSearchCount = $this->getArticleCount($objGetCondition);
                 }
                 // Do a sorting, before anything else;
                 if (isset($_GET[ADMIN_ACTION_SORT])) {
                     // Do a switch ...
                     switch ($_GET[ADMIN_ACTION_SORT]) {
                         case 'AscByTitle':
                         case 'DescByTitle':
                             // Make the ordered condition;
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objArticleTableFTitle');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByTitle':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByTitle':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             break;
                         case 'AscByPublished':
                         case 'DescByPublished':
                             // Make the ordered condition;
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objArticleTableFDatePublished');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByPublished':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByPublished':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             break;
                         case 'AscByUpdated':
                         case 'DescByUpdated':
                             // Make the ordered condition;
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objArticleTableFDateUpdated');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByUpdated':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByUpdated':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             break;
                         case 'AscByViews':
                         case 'DescByViews':
                             // Make the ordered condition;
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objArticleTableFViews');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByViews':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByViews':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             break;
                         case 'AscByCategory':
                         case 'DescByCategory':
                             if (isset($_GET[ADMIN_ACTION_BY])) {
                                 if ($_GET[ADMIN_ACTION_BY] == ARTICLES_SEARCH_CATEGORY) {
                                     // Make the ordered condition;
                                     $objGetCondition->appendString(_SP)->appendString('ORDER BY t2.%objCategoryTableFName');
                                 } else {
                                     // Make the ordered condition;
                                     $objGetCondition->doToken('WHERE', _SP . 'AS t1 INNER JOIN %objCategoryTable AS t2
                                     ON t1.%objArticleTableFCategoryId = t2.%objCategoryTableFId WHERE');
                                     $objGetCondition->appendString(_SP)->appendString('ORDER BY t2.%objCategoryTableFName');
                                 }
                             } else {
                                 // Make the ordered condition;
                                 $objGetCondition->appendString(_SP)->appendString('AS t1 INNER JOIN %objCategoryTable AS t2
                                 ON t1.%objArticleTableFCategoryId = t2.%objCategoryTableFId
                                 ORDER BY t2.%objCategoryTableFName');
                             }
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByCategory':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByCategory':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             break;
                     }
                 }
                 // Add some LIMITs
                 $objGetCondition->appendString(_SP)->appendString('LIMIT %LowerLimit, %UpperLimit')->doToken('%LowerLimit', $objLowerLimit)->doToken('%UpperLimit', $objUpperLimit);
                 // Get based on SQL condtion ...
                 $objArticleTable = $this->getArticles($objGetCondition);
                 if (isset($_GET[ADMIN_ACTION_BY])) {
                     $objArticleTableCount = $objSearchCount;
                 } else {
                     $objArticleTableCount = $this->getArticleCount();
                 }
                 // Fix pagination when count is LESS than 10;
                 if (isset($_GET[ADMIN_ACTION_BY]) && isset($_GET[ADMIN_PAGINATION])) {
                     if ($objArticleTableCount->toInt() < 10) {
                         // Remove paging ... & redirect to proper ...
                         TPL::setHeaderKey(URL::rewriteURL(new A(array(ADMIN_PAGINATION))), new S('Location'));
                     } else {
                         if (CEIL($objArticleTableCount->toInt() / 10) < (int) $_GET[ADMIN_PAGINATION]->toString()) {
                             // Redirect to proper ...
                             TPL::setHeaderKey(URL::rewriteURL(new A(array(ADMIN_PAGINATION)), new A(array(CEIL($objArticleTableCount->toInt() / 10)))), new S('Location'));
                         }
                     }
                 }
                 // Set the template file ...
                 $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'manageArticles.tp');
                 TPL::tpSet($objArticleTable, new S('articleTable'), $tpF);
                 TPL::tpSet($this, new S('ART'), $tpF);
                 TPL::tpSet($this->STG, new S('STG'), $tpF);
                 TPL::tpExe($tpF);
                 // Do pagination ...
                 if ($objArticleTableCount->toInt() > 10) {
                     self::$objAdministration->setPagination($objArticleTableCount);
                 }
                 // Do the form, make it happen;
                 $this->renderForm(new S('articleSearch'));
                 $this->renderForm(new S('articleCreate'));
             }
             // BK;
             break;
         case 'manageCategories':
             // Add some requirements;
             TPL::manageJSS(new FilePath($this->getPathToSkinJSS()->toRelativePath() . 'manageCategories.js'), new S('manageCategories'));
             // Check if there's an action to take;
             if (isset($_GET[ADMIN_ACTION])) {
                 // Do a switch ...
                 switch ($_GET[ADMIN_ACTION]) {
                     case ADMIN_ACTION_EDIT:
                         $this->renderForm(new S('categoryEdit'));
                         break;
                     case ADMIN_ACTION_ERASE:
                         $this->renderForm(new S('categoryErase'));
                         break;
                     case ADMIN_ACTION_MOVE:
                         $this->renderForm(new S('categoryMove'));
                         break;
                 }
             } else {
                 // Set some requirements ...
                 $objGetCondition = new S();
                 // Do a sorting, before anything else;
                 if (isset($_GET[ADMIN_ACTION_SORT])) {
                     // Do a switch ...
                     switch ($_GET[ADMIN_ACTION_SORT]) {
                         case 'AscByCategory':
                             // Make the ordered condition;
                             $objGetCondition->appendString(_SP)->appendString('ASC');
                             break;
                         case 'DescByCategory':
                             // Make the ordered condition;
                             $objGetCondition->appendString(_SP)->appendString('DESC');
                             break;
                     }
                 }
                 // Add some LIMITs
                 $objGetCondition->appendString(_SP)->appendString('LIMIT %LowerLimit, %UpperLimit')->doToken('%LowerLimit', $objLowerLimit)->doToken('%UpperLimit', $objUpperLimit);
                 // Set some requirements ...
                 $objCategoryTreeCount = $this->getCategoryCount();
                 $objCategoryTree = $this->getCategories(isset($_GET[ADMIN_SHOW_ALL]) ? new S() : $objGetCondition);
                 // Set the template file ...
                 $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'manageCategories.tp');
                 TPL::tpSet($objCategoryTree, new S('categoryTree'), $tpF);
                 TPL::tpExe($tpF);
                 // Do pagination ...
                 if ($objCategoryTreeCount->toInt() > 10 && !isset($_GET[ADMIN_SHOW_ALL])) {
                     self::$objAdministration->setPagination($objCategoryTreeCount);
                 }
                 // Do the form, make it happen;
                 $this->renderForm(new S('categoryCreate'));
             }
             // BK;
             break;
         case 'manageComments':
             // Check if there's an action to take;
             if (isset($_GET[ADMIN_ACTION])) {
                 // Switch between actions;
                 switch ($_GET[ADMIN_ACTION]) {
                     case ADMIN_ACTION_EDIT:
                         $this->renderForm(new S('commentEdit'));
                         break;
                     case ADMIN_ACTION_ERASE:
                         $this->renderForm(new S('commentErase'));
                         break;
                 }
             } else {
                 // Do a redirect ...
                 if (!isset($_GET[ADMIN_ACTION_SORT])) {
                     $this->setHeaderKey(URL::rewriteURL(new A(array(ADMIN_ACTION_SORT)), new A(array('DescByDate'))), new S('Location'));
                 }
                 // Set some requirements ...
                 $objGetCondition = new S();
                 // Do a sorting, before anything else;
                 if (isset($_GET[ADMIN_ACTION_SORT])) {
                     // Do a switch ...
                     switch ($_GET[ADMIN_ACTION_SORT]) {
                         case 'AscByName':
                         case 'DescByName':
                             // Make the ordered condition;
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objCommentsTableFName');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByName':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByName':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             break;
                         case 'AscByTitle':
                         case 'DescByTitle':
                             // Make the ordered condition;
                             $objGetCondition->appendString(_SP)->appendString('AS t1 LEFT JOIN %objArticleTable
                             AS t2 ON t1.%objCommentsTableFArticleId = t2.%objArticleTableFId
                             ORDER BY t2.%objArticleTableFTitle');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByTitle':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByTitle':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             break;
                         case 'AscByApproved':
                         case 'DescByApproved':
                             // Make the ordered condition;
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objCommentsTableFApproved');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByApproved':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByApproved':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             break;
                         case 'AscByDate':
                         case 'DescByDate':
                             // Make the ordered condition;
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objCommentsTableFDate');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByDate':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByDate':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             break;
                     }
                 }
                 // Add some LIMITs
                 $objGetCondition->appendString(_SP)->appendString('LIMIT %LowerLimit, %UpperLimit')->doToken('%LowerLimit', $objLowerLimit)->doToken('%UpperLimit', $objUpperLimit);
                 // Set some requirements;
                 $objComments = $this->getComments($objGetCondition);
                 $objCommentsCount = $this->getCommentCount();
                 // Process them arrays;
                 foreach ($objComments as $k => $v) {
                     if ($v[self::$objCommentsTableFRUId] != new S('0')) {
                         $v[self::$objCommentsTableFName] = $this->ATH->getUserInfoById($v[self::$objCommentsTableFRUId], Authentication::$objAuthUsersTableFUName);
                     }
                 }
                 // Set the template file ...
                 $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'manageComments.tp');
                 TPL::tpSet($objComments, new S('articleTable'), $tpF);
                 TPL::tpSet($this->STG, new S('STG'), $tpF);
                 TPL::tpSet($this, new S('ART'), $tpF);
                 TPL::tpExe($tpF);
                 // Do some pagination ...
                 if ($objCommentsCount->toInt() > 10) {
                     self::$objAdministration->setPagination($objCommentsCount);
                 }
             }
             // BK;
             break;
         case 'manageOperations':
             // Do the form, make it happen;
             $this->renderForm(new S('categoryMoveOperation'));
             break;
         case 'manageConfiguration':
             // Do the form, make it happen ...
             if (isset($_GET[ADMIN_ACTION])) {
                 $this->renderForm($_GET[ADMIN_ACTION]);
             } else {
                 $this->renderForm(new S('configurationEdit'));
             }
             break;
     }
 }
Пример #2
0
 /**
  * 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 renderBackendPage(S $objPageToRender)
 {
     # Get a specific CSS file for this controller ...
     TPL::manageCSS(new FilePath($this->getPathToSkinCSS()->toRelativePath() . $objPageToRender . CSS_EXTENSION), $objPageToRender);
     # Do pagination ...
     if (isset($_GET[ADMIN_PAGINATION])) {
         $objLowerLimit = (int) $_GET[ADMIN_PAGINATION]->toString() * 10 - 10;
         $objUpperLimit = 10;
     } else {
         $objLowerLimit = 0;
         $objUpperLimit = 10;
     }
     // Do a switch on the rendered page ...
     switch ($objPageToRender) {
         case 'manageMessages':
             // Set some predefines;
             $objGetCondition = new S();
             // Check if there's an action to take;
             if (isset($_GET[ADMIN_ACTION])) {
                 // Switch between actions;
                 switch ($_GET[ADMIN_ACTION]) {
                     case ADMIN_ACTION_VIEW:
                         // Set the template file ...
                         $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'viewMessage.tp');
                         TPL::tpSet($_GET[ADMIN_ACTION_ID], new S('objGETId'), $tpF);
                         TPL::tpSet($this, new S('CNT'), $tpF);
                         TPL::tpExe($tpF);
                         // Do the form, make it happen ...
                         $this->renderForm(new S('messageOperations'));
                         $this->renderForm(new S('messageSend'));
                         break;
                     case ADMIN_ACTION_ERASE:
                         $this->renderForm(new S('messageErase'));
                         break;
                 }
             } else {
                 if (!isset($_GET[ADMIN_ACTION_SORT])) {
                     $this->setHeaderKey(URL::rewriteURL(new A(array(ADMIN_ACTION_SORT)), new A(array('DescByReceived'))), new S('Location'));
                 }
                 // Set some requirements;
                 $objGetCondition = new S();
                 // Check if there's an action to take;
                 if (isset($_GET[ADMIN_ACTION_SORT])) {
                     // Switch ...
                     switch ($_GET[ADMIN_ACTION_SORT]) {
                         case 'AscByReceived':
                         case 'DescByReceived':
                             // Set some requirements;
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objContactTableFReceived');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByReceived':
                                     $objGetCondEFEFEFition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByReceived':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             break;
                         case 'AscByLastEdited':
                         case 'DescByLastEdited':
                             // Set some requirements;
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objContactTableFLastEdited');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByLastEdited':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByLastEdited':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             break;
                         case 'AscBySubject':
                         case 'DescBySubject':
                             // Set some requirements;
                             $objGetCondition->appendString('AS t1 INNER JOIN %objContactSubjectTable AS t2
                             ON t1.%objContactTableFSubjectId = t2.%objContactSubjectFId
                             ORDER BY %objContactSubjectFTitle');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscBySubject':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescBySubject':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             break;
                     }
                 }
                 // Add some LIMITS;
                 $objGetCondition->appendString(_SP)->appendString('LIMIT %LowerLimit, %UpperLimit')->doToken('%LowerLimit', $objLowerLimit)->doToken('%UpperLimit', $objUpperLimit);
                 // Set some requirements;
                 $objArticleTable = $this->getMessages($objGetCondition);
                 $objArticleTableCount = $this->getMessageCount();
                 // Set the template file ...
                 $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'manageMessages.tp');
                 TPL::tpSet($objArticleTable, new S('articleTable'), $tpF);
                 TPL::tpSet($this, new S('CNT'), $tpF);
                 TPL::tpSet($this->STG, new S('STG'), $tpF);
                 TPL::tpExe($tpF);
                 // Do pagination;
                 if ($objArticleTableCount->toInt() > 10) {
                     self::$objAdministration->setPagination($objArticleTableCount);
                 }
             }
             // Break out;
             break;
         case 'manageSubjects':
             // Set some predefines;
             $objGetCondition = new S();
             // Check if there's an action to take;
             if (isset($_GET[ADMIN_ACTION])) {
                 // Switch between actions;
                 switch ($_GET[ADMIN_ACTION]) {
                     case ADMIN_ACTION_EDIT:
                         $this->renderForm(new S('subjectEdit'));
                         break;
                     case ADMIN_ACTION_ERASE:
                         $this->renderForm(new S('subjectErase'));
                         break;
                 }
             } else {
                 // Do a sorting, before anything else;
                 if (isset($_GET[ADMIN_ACTION_SORT])) {
                     switch ($_GET[ADMIN_ACTION_SORT]) {
                         case 'AscByTitle':
                         case 'DescByTitle':
                             // Make the ordered condition;
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objContactSubjectFTitle');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByTitle':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByTitle':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             break;
                     }
                 }
                 // Add some LIMITs;
                 $objGetCondition->appendString(_SP)->appendString('LIMIT %LowerLimit, %UpperLimit')->doToken('%LowerLimit', $objLowerLimit)->doToken('%UpperLimit', $objUpperLimit);
                 // Set some requirements;
                 $objArticleTable = $this->getSubjects($objGetCondition);
                 $objArticleTableCount = $this->getSubjectCount();
                 // Set the template file ...
                 $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'manageSubjects.tp');
                 TPL::tpSet($objArticleTable, new S('articleTable'), $tpF);
                 TPL::tpExe($tpF);
                 // Do pagination ...
                 if ($objArticleTableCount->toInt() > 10) {
                     self::$objAdministration->setPagination($objArticleTableCount);
                 }
                 // Do the form, make it happen;
                 $this->renderForm(new S('subjectCreate'));
             }
             break;
         case 'manageConfiguration':
             // Do the form, make it happen;
             if (isset($_GET[ADMIN_ACTION])) {
                 $this->renderForm($_GET[ADMIN_ACTION]);
             } else {
                 $this->renderForm(new S('configurationEdit'));
             }
             break;
     }
 }
Пример #3
0
 /**
  * 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 renderBackendPage(S $objPageToRender)
 {
     // Get a specific CSS file for this controller ...
     TPL::manageCSS(new FilePath($this->getPathToSkinCSS()->toRelativePath() . $objPageToRender . CSS_EXTENSION), $objPageToRender);
     // Do pagination ...
     if (isset($_GET[ADMIN_PAGINATION])) {
         $objLowerLimit = (int) $_GET[ADMIN_PAGINATION]->toString() * 10 - 10;
         $objUpperLimit = 10;
     } else {
         $objLowerLimit = 0;
         $objUpperLimit = 10;
     }
     // Do a switch on the rendered page ...
     switch ($objPageToRender) {
         case 'manageConfiguration':
             if (isset($_GET[ADMIN_ACTION])) {
                 $this->renderForm($_GET[ADMIN_ACTION]);
             } else {
                 $this->renderForm(new S('configurationEdit'));
             }
             break;
         case 'manageCountries':
             // Do some work;
             if (isset($_GET[ADMIN_ACTION])) {
                 // Do a switch;
                 switch ($_GET[ADMIN_ACTION]) {
                     case ADMIN_ACTION_EDIT:
                         $this->renderForm(new S('countryEdit'));
                         break;
                     case ADMIN_ACTION_ERASE:
                         $this->renderForm(new S('countryErase'));
                         break;
                 }
             } else {
                 // Set some requirements ...
                 $objGetCondition = new S();
                 // Do a sorting beforehand;
                 if (isset($_GET[ADMIN_ACTION_SORT])) {
                     // Do a switch ...
                     switch ($_GET[ADMIN_ACTION_SORT]) {
                         case 'AscByName':
                         case 'DescByName':
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objSettingsCountryTableFName');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByName':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByName':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             // Break out ...
                             break;
                     }
                 }
                 // Add some LIMITs
                 $objGetCondition->appendString(_SP)->appendString('LIMIT %LowerLimit, %UpperLimit')->doToken('%LowerLimit', $objLowerLimit)->doToken('%UpperLimit', $objUpperLimit);
                 // Set some requirements ...
                 $objCountries = $this->getCountries($objGetCondition);
                 $objCountriesCount = $this->getCountryCount();
                 // Set the template file ...
                 $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'manageCountries.tp');
                 TPL::tpSet($objCountries, new S('articleTable'), $tpF);
                 TPL::tpExe($tpF);
                 // Do some pagination;
                 if ($objCountriesCount->toInt() > 10) {
                     self::$objAdministration->setPagination($objCountriesCount);
                 }
                 // Do the form, make it happen;
                 $this->renderForm(new S('countryCreate'));
             }
             // Break out ...
             break;
         case 'manageErrorPages':
             // Do some work;
             if (isset($_GET[ADMIN_ACTION])) {
                 // Do a switch;
                 switch ($_GET[ADMIN_ACTION]) {
                     case ADMIN_ACTION_EDIT:
                         $this->renderForm(new S('errorPageEdit'));
                         break;
                     case ADMIN_ACTION_ERASE:
                         $this->renderForm(new S('errorPageErase'));
                         break;
                 }
             } else {
                 // Set some requirements ...
                 $objGetCondition = new S();
                 // Do a sorting beforehand;
                 if (isset($_GET[ADMIN_ACTION_SORT])) {
                     // Do a switch ...
                     switch ($_GET[ADMIN_ACTION_SORT]) {
                         case 'AscByErrorCode':
                         case 'DescByErrorCode':
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objSettingsErrTableFCode');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByErrorCode':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByErrorCode':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             // Break out ...
                             break;
                         case 'AscByErrorPageTitle':
                         case 'DescByErrorPageTitle':
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objSettingsErrTableFTitle');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByErrorPageTitle':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByErrorPageTitle':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             // Break out ...
                             break;
                     }
                 }
                 // Add some LIMITs
                 $objGetCondition->appendString(_SP)->appendString('LIMIT %LowerLimit, %UpperLimit')->doToken('%LowerLimit', $objLowerLimit)->doToken('%UpperLimit', $objUpperLimit);
                 // Set some requirements ...
                 $objCountries = $this->getErrorPages($objGetCondition);
                 $objCountriesCount = $this->getErrorPageCount();
                 // Set the template file ...
                 $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'manageErrorPages.tp');
                 TPL::tpSet($objCountries, new S('articleTable'), $tpF);
                 TPL::tpExe($tpF);
                 // Do some pagination;
                 if ($objCountriesCount->toInt() > 10) {
                     self::$objAdministration->setPagination($objCountriesCount);
                 }
                 // Do the form, make it happen;
                 $this->renderForm(new S('errorPageCreate'));
             }
             // Break out ...
             break;
     }
 }
Пример #4
0
 /**
  * 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 renderBackendPage(S $objPageToRender)
 {
     // Get a specific CSS file for this controller ...
     TPL::manageCSS(new FilePath($this->getPathToSkinCSS()->toRelativePath() . $objPageToRender . CSS_EXTENSION), $objPageToRender);
     // Do pagination ...
     if (isset($_GET[ADMIN_PAGINATION])) {
         $objLowerLimit = (int) $_GET[ADMIN_PAGINATION]->toString() * 10 - 10;
         $objUpperLimit = 10;
     } else {
         $objLowerLimit = 0;
         $objUpperLimit = 10;
     }
     // Do a switch on the rendered page ...
     switch ($objPageToRender) {
         case 'manageNewsletter':
             // Do some work;
             if (isset($_GET[ADMIN_ACTION])) {
                 // Do a switch;
                 switch ($_GET[ADMIN_ACTION]) {
                     case ADMIN_ACTION_EDIT:
                         $this->renderForm(new S('newsletterEdit'));
                         break;
                     case ADMIN_ACTION_ERASE:
                         $this->renderForm(new S('newsletterErase'));
                         break;
                 }
             } else {
                 // Redirect to DescBySubscribed ...
                 if (!isset($_GET[ADMIN_ACTION_SORT])) {
                     $this->setHeaderKey(URL::rewriteURL(new A(array(ADMIN_ACTION_SORT)), new A(array('DescBySubscribed'))), new S('Location'));
                 }
                 // Set some requirements ...
                 $objGetCondition = new S();
                 // Check for sorting ...
                 if (isset($_GET[ADMIN_ACTION_BY])) {
                     // Do a switch ...
                     switch ($_GET[ADMIN_ACTION_BY]) {
                     }
                     // Add LIKE searching ...
                     $objGetCondition->appendString(_SP)->appendString('LIKE "%%Search%"')->doToken('%Search', $_GET[ADMIN_ACTION_SEARCH]);
                     // Get the count, on SQL ...
                     $objSearchCount = $this->getSubscriberCount($objGetCondition);
                 }
                 // Do a sorting beforehand;
                 if (isset($_GET[ADMIN_ACTION_SORT])) {
                     // Do a switch ...
                     switch ($_GET[ADMIN_ACTION_SORT]) {
                         case 'AscByEmail':
                         case 'DescByEmail':
                             // Make the ordered condition;
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objLetterTableFEML');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByEmail':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByEmail':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             // Break out ...
                             break;
                         case 'AscByFirstName':
                         case 'DescByFirstName':
                             // Make the ordered condition;
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objLetterTableFFirstName');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByFirstName':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByFirstName':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             // Break out ...
                             break;
                         case 'AscByLastName':
                         case 'DescByLastName':
                             // Make the ordered condition;
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objLetterTableFLastName');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByLastName':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByLastName':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             // Break out ...
                             break;
                         case 'AscBySubscribed':
                         case 'DescBySubscribed':
                             // Make the ordered condition;
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objLetterTableFSubscribed');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscBySubscribed':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescBySubscribed':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             // Break out ...
                             break;
                     }
                 }
                 // Add some LIMITs
                 $objGetCondition->appendString(_SP)->appendString('LIMIT %LowerLimit, %UpperLimit')->doToken('%LowerLimit', $objLowerLimit)->doToken('%UpperLimit', $objUpperLimit);
                 // Set some requirements ...
                 $objLetterTable = $this->getSubscribers($objGetCondition);
                 $objLetterTableCount = $this->getSubscriberCount();
                 // Set the template file ...
                 $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'manageNewsletter.tp');
                 TPL::tpSet($objLetterTable, new S('newsletterTable'), $tpF);
                 TPL::tpSet($this->STG, new S('STG'), $tpF);
                 TPL::tpExe($tpF);
                 // Do some pagination;
                 if ($objLetterTableCount->toInt() > 10) {
                     self::$objAdministration->setPagination($objLetterTableCount);
                 }
                 // Do the form, make it happen;
                 $this->renderForm(new S('newsletterSearch'));
                 $this->renderForm(new S('newsletterCreate'));
             }
             // Break out ...
             break;
         case 'manageCategories':
             // Add some requirements;
             TPL::manageJSS(new FilePath($this->getPathToSkinJSS()->toRelativePath() . 'manageCategories.js'), new S('manageCategories'));
             // Check if there's an action to take;
             if (isset($_GET[ADMIN_ACTION])) {
                 // Do a switch ...
                 switch ($_GET[ADMIN_ACTION]) {
                     case ADMIN_ACTION_EDIT:
                         $this->renderForm(new S('categoryEdit'));
                         break;
                     case ADMIN_ACTION_ERASE:
                         $this->renderForm(new S('categoryErase'));
                         break;
                     case ADMIN_ACTION_MOVE:
                         $this->renderForm(new S('categoryMove'));
                         break;
                 }
             } else {
                 // Set some requirements ...
                 $objGetCondition = new S();
                 // Do a sorting, before anything else;
                 if (isset($_GET[ADMIN_ACTION_SORT])) {
                     // Do a switch ...
                     switch ($_GET[ADMIN_ACTION_SORT]) {
                         case 'AscByCategory':
                             // Make the ordered condition;
                             $objGetCondition->appendString(_SP)->appendString('ASC');
                             break;
                         case 'DescByCategory':
                             // Make the ordered condition;
                             $objGetCondition->appendString(_SP)->appendString('DESC');
                             break;
                     }
                 }
                 // Add some LIMITs
                 $objGetCondition->appendString(_SP)->appendString('LIMIT %LowerLimit, %UpperLimit')->doToken('%LowerLimit', $objLowerLimit)->doToken('%UpperLimit', $objUpperLimit);
                 // Set some requirements ...
                 $objCategoryTreeCount = $this->getCategoryCount();
                 $objCategoryTree = $this->getCategories(isset($_GET[ADMIN_SHOW_ALL]) ? new S() : $objGetCondition);
                 // Set the template file ...
                 $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'manageCategories.tp');
                 TPL::tpSet($objCategoryTree, new S('categoryTree'), $tpF);
                 TPL::tpExe($tpF);
                 // Do pagination ...
                 if ($objCategoryTreeCount->toInt() > 10 && !isset($_GET[ADMIN_SHOW_ALL])) {
                     self::$objAdministration->setPagination($objCategoryTreeCount);
                 }
                 // Do the form, make it happen;
                 $this->renderForm(new S('categoryCreate'));
             }
             // Break out ...
             break;
         case 'manageOperations':
             // Do the form, make it happen;
             $this->renderForm(new S('categoryMoveOperation'));
             break;
         case 'manageConfiguration':
             // Do the form, make it happen ...
             if (isset($_GET[ADMIN_ACTION])) {
                 $this->renderForm($_GET[ADMIN_ACTION]);
             } else {
                 $this->renderForm(new S('configurationEdit'));
             }
             break;
     }
 }
Пример #5
0
 /**
  * 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 renderBackendPage(S $objPageToRender)
 {
     // Get a specific CSS file for this controller ...
     TPL::manageCSS(new FilePath($this->getPathToSkinCSS()->toRelativePath() . $objPageToRender . CSS_EXTENSION), $objPageToRender);
     // Do pagination ...
     if (isset($_GET[ADMIN_PAGINATION])) {
         $objLowerLimit = (int) $_GET[ADMIN_PAGINATION]->toString() * 10 - 10;
         $objUpperLimit = 10;
     } else {
         $objLowerLimit = 0;
         $objUpperLimit = 10;
     }
     // Do a switch on the rendered page ...
     switch ($objPageToRender) {
         case 'manageImages':
             // Make an IF;
             if (isset($_GET[PRODUCTS_ACTION_IMAGE])) {
                 // Do a switch ...
                 switch ($_GET[PRODUCTS_ACTION_IMAGE]) {
                     case ADMIN_ACTION_EDIT:
                         $this->renderForm(new S('imageEdit'));
                         break;
                     case ADMIN_ACTION_ERASE:
                         $this->renderForm(new S('imageErase'));
                         break;
                 }
             } else {
                 // Set some requirements ...
                 $objGetCondition = new S();
                 // Do a sorting beforehand;
                 if (isset($_GET[ADMIN_ACTION_SORT])) {
                     // Do a switch ...
                     switch ($_GET[ADMIN_ACTION_SORT]) {
                         case 'AscByImage':
                         case 'DescByImage':
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objProductsIMGTableFURL');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByImage':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByImage':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             // Break out ...
                             break;
                         case 'AscByTitle':
                         case 'DescByTitle':
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objProductsIMGTableFTitle');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByTitle':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByTitle':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             // Break out ...
                             break;
                     }
                 } else {
                     // Set some requirements ...
                     $objGetCondition->appendString(_SP)->appendString('ORDER BY %objProductsIMGTableFId DESC');
                 }
                 // Add some LIMITs
                 $objGetCondition->appendString(_SP)->appendString('LIMIT %LowerLimit, %UpperLimit')->doToken('%LowerLimit', $objLowerLimit)->doToken('%UpperLimit', $objUpperLimit);
                 // Set some requirements ...
                 $objImageTable = $this->getImagesByProductId($_GET[ADMIN_ACTION_ID], $objGetCondition);
                 $objImageTableCount = $this->getImageCountByProductId($_GET[ADMIN_ACTION_ID]);
                 // Set the template file ...
                 $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'manageImages.tp');
                 TPL::tpSet($objImageTable, new S('imageTable'), $tpF);
                 TPL::tpSet($this, new S('thisObj'), $tpF);
                 TPL::tpExe($tpF);
                 // Do some pagination;
                 if ($objImageTableCount->toInt() > 10) {
                     self::$objAdministration->setPagination($objImageTableCount);
                 }
                 // Do the form, make it happen;
                 $this->renderForm(new S('imageCreate'));
             }
             // Break out ...
             break;
         case 'manageProperties':
             if (isset($_GET[PRODUCTS_ACTION_PROPERTY])) {
                 // Do a switch ...
                 switch ($_GET[PRODUCTS_ACTION_PROPERTY]) {
                     case ADMIN_ACTION_EDIT:
                         $this->renderForm(new S('propertyEdit'));
                         break;
                     case ADMIN_ACTION_ERASE:
                         $this->renderForm(new S('propertyErase'));
                         break;
                 }
             } else {
                 // Set some requirements ...
                 $objGetCondition = new S();
                 // Do a sorting beforehand;
                 if (isset($_GET[ADMIN_ACTION_SORT])) {
                     // Do a switch ...
                     switch ($_GET[ADMIN_ACTION_SORT]) {
                         case 'AscByKey':
                         case 'DescByKey':
                             // Set some requiremenst;
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objProductsPropertyTableFKey');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByKey':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByKey':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             // Break out ...
                             break;
                         case 'AscByVar':
                         case 'DescByVar':
                             // Set some requiremenst;
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objProductsPropertyTableFVar');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByVar':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByVar':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             // Break out ...
                             break;
                     }
                 } else {
                     // Set some requirements ...
                     $objGetCondition->appendString(_SP)->appendString('ORDER BY %objProductsPropertyTableFId DESC');
                 }
                 // Add some LIMITs
                 $objGetCondition->appendString(_SP)->appendString('LIMIT %LowerLimit, %UpperLimit')->doToken('%LowerLimit', $objLowerLimit)->doToken('%UpperLimit', $objUpperLimit);
                 // Set some requirements ...
                 $objPropertyTable = $this->getPropertiesByProductId($_GET[ADMIN_ACTION_ID], $objGetCondition);
                 $objPropertyTableCount = $this->getPropertyCountByProductId($_GET[ADMIN_ACTION_ID]);
                 // Set the template file ...
                 $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'manageProperties.tp');
                 TPL::tpSet($objPropertyTable, new S('propertyTable'), $tpF);
                 TPL::tpSet($this, new S('thisObj'), $tpF);
                 TPL::tpExe($tpF);
                 // Do some pagination;
                 if ($objPropertyTableCount->toInt() > 10) {
                     self::$objAdministration->setPagination($objPropertyTableCount);
                 }
                 // Do the form, make it happen;
                 $this->renderForm(new S('propertyCreate'));
             }
             // Break out ...
             break;
         case 'manageProducts':
             // Set some requirements;
             TPL::manageJSS(new FilePath($this->getPathToSkinJSS()->toRelativePath() . 'manageProducts.js'), new S('manageProducts'));
             // Do some work;
             if (isset($_GET[ADMIN_ACTION])) {
                 // Do a switch;
                 switch ($_GET[ADMIN_ACTION]) {
                     case ADMIN_ACTION_EDIT:
                         $this->renderForm(new S('productEdit'));
                         break;
                     case ADMIN_ACTION_ERASE:
                         $this->renderForm(new S('productErase'));
                         break;
                     case ADMIN_ACTION_IMAGES:
                         // Specific ...
                         $this->renderBackendPage(new S('manageImages'));
                         break;
                     case ADMIN_ACTION_PROPERTIES:
                         // Specific ...
                         $this->renderBackendPage(new S('manageProperties'));
                         break;
                 }
             } else {
                 // Set some requirements ...
                 $objGetCondition = new S();
                 // Do a sorting beforehand;
                 if (isset($_GET[ADMIN_ACTION_SORT])) {
                     // Do a switch ...
                     switch ($_GET[ADMIN_ACTION_SORT]) {
                         case 'AscByCode':
                         case 'DescByCode':
                             // Set some requirements;
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objProductsTableFCode');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByCode':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByCode':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             // Break out ...
                             break;
                         case 'AscByName':
                         case 'DescByName':
                             // Set some requirements;
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objProductsTableFName');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByName':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByName':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             // Break out ...
                             break;
                         case 'AscByStoc':
                         case 'DescByStoc':
                             // Set somre requirements;
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objProductsTableFStoc');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByStoc':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByStoc':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             // Break out ...
                             break;
                         case 'AscByPrice':
                         case 'DescByPrice':
                             // Set some requirements;
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objProductsTableFPrice');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByPrice':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByPrice':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             // Break out ...
                             break;
                         case 'AscByCategory':
                         case 'DescByCategory':
                             // Set some requirements;
                             $objGetCondition->appendString(_SP)->appendString('INNER JOIN %objProductsCategoryTable AS t2
                             ON t1.%objProductsTableFCategoryId = t2.%objCategoryTableFId
                             ORDER BY t2.%objCategoryTableFName');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByCategory':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByCategory':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             // Break out ...
                             break;
                     }
                 }
                 // Add some LIMITs
                 $objGetCondition->appendString(_SP)->appendString('LIMIT %LowerLimit, %UpperLimit')->doToken('%LowerLimit', $objLowerLimit)->doToken('%UpperLimit', $objUpperLimit);
                 // Set some requirements ...
                 $objProductTable = $this->getProducts($objGetCondition);
                 $objProductTableCount = $this->getProductCount();
                 // Set the template file ...
                 $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'manageProducts.tp');
                 TPL::tpSet($objProductTable, new S('productTable'), $tpF);
                 TPL::tpSet($this, new S('thisObj'), $tpF);
                 TPL::tpExe($tpF);
                 // Do some pagination;
                 if ($objProductTableCount->toInt() > 10) {
                     self::$objAdministration->setPagination($objPropertyTableCount);
                 }
                 // Do the form, make it happen;
                 $this->renderForm(new S('productCreate'));
             }
             // Break out ...
             break;
         case 'manageCategories':
             // Add some requirements;
             TPL::manageJSS(new FilePath($this->getPathToSkinJSS()->toRelativePath() . 'manageCategories.js'), new S('manageCategories'));
             // Check if there's an action to take;
             if (isset($_GET[ADMIN_ACTION])) {
                 // Do a switch ...
                 switch ($_GET[ADMIN_ACTION]) {
                     case ADMIN_ACTION_EDIT:
                         $this->renderForm(new S('categoryEdit'));
                         break;
                     case ADMIN_ACTION_ERASE:
                         $this->renderForm(new S('categoryErase'));
                         break;
                     case ADMIN_ACTION_MOVE:
                         $this->renderForm(new S('categoryMove'));
                         break;
                 }
             } else {
                 // Set some requirements ...
                 $objGetCondition = new S();
                 // Do a sorting, before anything else;
                 if (isset($_GET[ADMIN_ACTION_SORT])) {
                     // Do a switch ...
                     switch ($_GET[ADMIN_ACTION_SORT]) {
                         case 'AscByCategory':
                             // Make the ordered condition;
                             $objGetCondition->appendString(_SP)->appendString('ASC');
                             break;
                         case 'DescByCategory':
                             // Make the ordered condition;
                             $objGetCondition->appendString(_SP)->appendString('DESC');
                     }
                 }
                 // Add some LIMITs
                 $objGetCondition->appendString(_SP)->appendString('LIMIT %LowerLimit, %UpperLimit')->doToken('%LowerLimit', $objLowerLimit)->doToken('%UpperLimit', $objUpperLimit);
                 // Set some requirements ...
                 $objCategoryTreeCount = $this->getCategoryCount();
                 $objCategoryTree = $this->getCategories(isset($_GET[ADMIN_SHOW_ALL]) ? new S() : $objGetCondition);
                 // Set the template file ...
                 $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'manageCategories.tp');
                 TPL::tpSet($objCategoryTree, new S('categoryTree'), $tpF);
                 TPL::tpExe($tpF);
                 // Do pagination ...
                 if ($objCategoryTreeCount->toInt() > 10 && !isset($_GET[ADMIN_SHOW_ALL])) {
                     self::$objAdministration->setPagination($objCategoryTreeCount);
                 }
                 // Do the form, make it happen;
                 $this->renderForm(new S('categoryCreate'));
             }
             // Break out ...
             break;
         case 'manageOperations':
             // Do the form, make it happen;
             $this->renderForm(new S('categoryMoveOperation'));
             break;
         case 'manageConfiguration':
             // Do the form, make it happen ...
             if (isset($_GET[ADMIN_ACTION])) {
                 $this->renderForm($_GET[ADMIN_ACTION]);
             } else {
                 $this->renderForm(new S('configurationEdit'));
             }
             break;
     }
 }
Пример #6
0
 /**
  * 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;
     }
 }
Пример #7
0
 /**
  * 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 renderBackendPage(S $objPageToRender)
 {
     // Get a specific CSS file for this controller ...
     TPL::manageCSS(new FilePath($this->getPathToSkinCSS()->toRelativePath() . $objPageToRender . CSS_EXTENSION), $objPageToRender);
     // Do pagination ...
     if (isset($_GET[ADMIN_PAGINATION])) {
         $objLowerLimit = (int) $_GET[ADMIN_PAGINATION]->toString() * 10 - 10;
         $objUpperLimit = 10;
     } else {
         $objLowerLimit = 0;
         $objUpperLimit = 10;
     }
     // Do a switch on the rendered page ...
     switch ($objPageToRender) {
         case 'welcomePage':
             // Set the template file ...
             $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'welcomePage.tp');
             TPL::tpSet(self::$objAdministration->getWidget(NULL), new S('objWidgets'), $tpF);
             TPL::tpExe($tpF);
             break;
         case 'manageUsers':
             // Do specific actions, based on _GET parameters;
             if (isset($_GET[ADMIN_ACTION])) {
                 // Switch ...
                 switch ($_GET[ADMIN_ACTION]) {
                     case ADMIN_ACTION_EDIT:
                         $this->renderForm(new S('userEdit'));
                         break;
                     case ADMIN_ACTION_ERASE:
                         $this->renderForm(new S('userErase'));
                         break;
                 }
             } else {
                 // Show them ordered by DESC;
                 if (!isset($_GET[ADMIN_ACTION_SORT])) {
                     $this->setHeaderKey(URL::rewriteURL(new A(array(ADMIN_ACTION_SORT)), new A(array('DescByRegistered'))), new S('Location'));
                 }
                 // Set some requirements;
                 $objGetCondition = new S();
                 if (isset($_GET[ADMIN_ACTION_BY])) {
                     // Do a switch ...
                     switch ($_GET[ADMIN_ACTION_BY]) {
                         case AUTHENTICATION_PROFILE_USERNAME:
                             $objGetCondition->appendString('WHERE %objAuthUsersTableFUName');
                             break;
                         case AUTHENTICATION_PROFILE_EMAIL:
                             $objGetCondition->appendString('WHERE %objAuthUsersTableFEML');
                             break;
                         case AUTHENTICATION_PROFILE_GROUP:
                             $objGetCondition->appendString('AS t1 LEFT JOIN %objAuthGroupTable
                             AS t2 ON t1.%objAuthUsersTableFUGId = t2.%objAuthGroupTableFId
                             WHERE t2.%objAuthGroupTableFName');
                             break;
                     }
                     // Add LIKE searching ...
                     $objGetCondition->appendString(_SP)->appendString('LIKE "%%Search%"')->doToken('%Search', $_GET[ADMIN_ACTION_SEARCH]);
                 }
                 if (isset($_GET[ADMIN_ACTION_SORT])) {
                     // Switch ...
                     switch ($_GET[ADMIN_ACTION_SORT]) {
                         case 'AscByUsername':
                         case 'DescByUsername':
                             // Set the order ...
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objAuthUsersTableFUName');
                             // Switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByUsername':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByUsername':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             break;
                         case 'AscByEMail':
                         case 'DescByEMail':
                             // Set the order ...
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objAuthUsersTableFEML');
                             // Switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByEMail':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByEMail':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             break;
                         case 'AscByGroup':
                         case 'DescByGroup':
                             // Set the order ...
                             if (isset($_GET[ADMIN_ACTION_BY])) {
                                 $objGetCondition->appendString(_SP)->prependString('AS t1 LEFT JOIN %objAuthGroupTable
                                 AS t2 ON t1.%objAuthUsersTableFUGId = t2.%objAuthGroupTableFId ');
                             } else {
                                 $objGetCondition->appendString(_SP)->appendString('AS t1 LEFT JOIN %objAuthGroupTable
                                 AS t2 ON t1.%objAuthUsersTableFUGId = t2.%objAuthGroupTableFId ');
                             }
                             // Add order by ...
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY t2.%objAuthGroupTableFName');
                             // Switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByGroup':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByGroup':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             break;
                         case 'AscByRegistered':
                         case 'DescByRegistered':
                             // Set the order ...
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objAuthUsersTableFRegOn');
                             // Switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByRegistered':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByRegistered':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             break;
                     }
                 }
                 // Make the unordered condition;
                 $objGetCondition = $objGetCondition->appendString(_SP)->appendString('LIMIT %LowerLimit, %UpperLimit')->doToken('%LowerLimit', $objLowerLimit)->doToken('%UpperLimit', $objUpperLimit);
                 // Get the users ...
                 $objUsersTable = $this->getUsers($objGetCondition);
                 if (isset($_GET[ADMIN_ACTION_BY])) {
                     $objUsersTableCount = $objUsersTable->doCount();
                 } else {
                     $objUsersTableCount = $this->getUserCount();
                 }
                 // Get each group for each user ...
                 foreach ($objUsersTable as $k => $v) {
                     $v['group_name'] = $this->getGroupInfoById($v[Authentication::$objAuthUsersTableFUGId], Authentication::$objAuthGroupTableFName);
                 }
                 // Fix pagination when count is LESS than 10;
                 if (isset($_GET[ADMIN_ACTION_BY]) && isset($_GET[ADMIN_PAGINATION])) {
                     if ($objUsersTableCount->toInt() < 10) {
                         // Remove paging ... & redirect to proper ...
                         TPL::setHeaderKey(URL::rewriteURL(new A(array(ADMIN_PAGINATION))), new S('Location'));
                     } else {
                         if (CEIL($objUsersTableCount->toInt() / 10) < (int) $_GET[ADMIN_PAGINATION]->toString()) {
                             // Redirect to proper ...
                             TPL::setHeaderKey(URL::rewriteURL(new A(array(ADMIN_PAGINATION)), new A(array(CEIL($objUsersTableCount->toInt() / 10)))), new S('Location'));
                         }
                     }
                 }
                 // Set the template file ...
                 $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'manageUsers.tp');
                 TPL::tpSet($objUsersTable, new S('usersTable'), $tpF);
                 TPL::tpSet($this->STG, new S('STG'), $tpF);
                 TPL::tpExe($tpF);
                 // Do them pagination ...
                 if ($objUsersTableCount->toInt() > 10) {
                     self::$objAdministration->setPagination($objUsersTableCount);
                 }
                 // Set a search form;
                 $this->renderForm(new S('userSearch'));
                 $this->renderForm(new S('userCreate'));
             }
             break;
         case 'manageGroups':
             // Add some requirements;
             TPL::manageJSS(new FilePath($this->getPathToSkinJSS()->toRelativePath() . 'manageGroups.js'), new S('manageCategories'));
             // Do specific actions, based on _GET parameters;
             if (isset($_GET[ADMIN_ACTION])) {
                 switch ($_GET[ADMIN_ACTION]) {
                     case ADMIN_ACTION_EDIT:
                         $this->renderForm(new S('groupEdit'));
                         break;
                     case ADMIN_ACTION_ERASE:
                         $this->renderForm(new S('groupErase'));
                         break;
                     case ADMIN_ACTION_MOVE:
                         $this->renderForm(new S('groupMove'));
                         break;
                 }
             } else {
                 // Do an empty SQL string;
                 $objGetCondition = new S();
                 // Do a sorting, before anything else;
                 if (isset($_GET[ADMIN_ACTION_SORT])) {
                     switch ($_GET[ADMIN_ACTION_SORT]) {
                         case 'DescByGroup':
                             $objGetCondition->appendString(_SP)->appendString('DESC');
                             break;
                         case 'AscByGroup':
                             $objGetCondition->appendString(_SP)->appendString('ASC');
                             break;
                     }
                 }
                 // Add some LIMITs;
                 $objGetCondition->appendString(_SP)->appendString('LIMIT %LowerLimit, %UpperLimit')->doToken('%LowerLimit', $objLowerLimit)->doToken('%UpperLimit', $objUpperLimit);
                 // Set some requirements;
                 $objGroupTable = $this->getGroups(isset($_GET[ADMIN_SHOW_ALL]) ? new S() : $objGetCondition);
                 $objGroupTableCount = $this->getGroupCount();
                 // Set the template file ...
                 $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'manageGroups.tp');
                 TPL::tpSet($objGroupTable, new S('groupTree'), $tpF);
                 TPL::tpExe($tpF);
                 // Do them paginations ...
                 if ($objGroupTableCount->toInt() > 10 && !isset($_GET[ADMIN_SHOW_ALL])) {
                     self::$objAdministration->setPagination($objGroupTableCount);
                 }
                 // Do the form, make it happen;
                 $this->renderForm(new S('groupCreate'));
             }
             break;
         case 'manageZones':
             // Do specific actions, based on _GET parameters;
             if (isset($_GET[ADMIN_ACTION])) {
                 // Switch ...
                 switch ($_GET[ADMIN_ACTION]) {
                     case ADMIN_ACTION_EDIT:
                         $this->renderForm(new S('zoneEdit'));
                         break;
                     case ADMIN_ACTION_ERASE:
                         $this->renderForm(new S('zoneErase'));
                         break;
                 }
             } else {
                 // Do a sorting beforehand;
                 $objGetCondition = new S();
                 if (isset($_GET[ADMIN_ACTION_SORT])) {
                     switch ($_GET[ADMIN_ACTION_SORT]) {
                         case 'AscByZone':
                         case 'DescByZone':
                             // Switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByZone':
                                     $objGetCondition->appendString(_SP)->appendString(new S('ASC'));
                                     break;
                                 case 'DescByZone':
                                     $objGetCondition->appendString(_SP)->appendString(new S('DESC'));
                                     break;
                             }
                             break;
                     }
                 }
                 // Add some LIMITs
                 $objGetCondition->appendString(_SP)->appendString('LIMIT %LowerLimit, %UpperLimit')->doToken('%LowerLimit', $objLowerLimit)->doToken('%UpperLimit', $objUpperLimit);
                 // Set some requirements;
                 $objZonesTable = $this->getZones($objGetCondition);
                 $objZonesTableCount = $this->getZoneCount();
                 // Set the template file ...
                 $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'manageZones.tp');
                 TPL::tpSet($objZonesTable, new S('zonesTable'), $tpF);
                 TPL::tpExe($tpF);
                 // Do them paginations ...
                 if ($objZonesTableCount->toInt() > 10) {
                     self::$objAdministration->setPagination($objZonesTableCount);
                 }
             }
             break;
         case 'manageMappings':
             // Do specific actions, based on _GET parameters;
             if (isset($_GET[ADMIN_ACTION])) {
                 switch ($_GET[ADMIN_ACTION]) {
                     case ADMIN_ACTION_EDIT:
                         $this->renderForm(new S('zoneMappingEdit'));
                         break;
                     case ADMIN_ACTION_ERASE:
                         $this->renderForm(new S('zoneMappingErase'));
                         break;
                 }
             } else {
                 // Do a sorting beforehand;
                 $objGetCondition = new S();
                 if (isset($_GET[ADMIN_ACTION_SORT])) {
                     // Switch ...
                     switch ($_GET[ADMIN_ACTION_SORT]) {
                         case 'AscByGroup':
                         case 'DescByGroup':
                             // Set some requirements;
                             $objGetCondition->appendString(_SP)->appendString('AS t1 LEFT JOIN %objAuthGroupTable
                             AS t2 ON t1.%objAuthZoneMTableFUGId = t2.%objAuthGroupTableFId
                             ORDER BY t2.%objAuthGroupTableFName');
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByGroup':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByGroup':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             break;
                         case 'AscByZoneForGroup':
                         case 'DescByZoneForGroup':
                             // Set some requirements;
                             $objGetCondition = new S('AS t1 LEFT JOIN %objAuthZonesTable
                             AS t2 ON t1.%objAuthZoneMTableFZId = t2.%objAuthGroupTableFId
                             ORDER BY t2.%objAuthZonesTableFName');
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByZoneForGroup':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByZoneForGroup':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             break;
                     }
                 }
                 // LIMIT only TO GROUP;
                 if ($objGetCondition->toLength()->toInt() != 0) {
                     $objGetCondition->doToken('ORDER', new S('WHERE %objAuthZoneMTableFIUG = "Y" ORDER'));
                 } else {
                     $objGetCondition = new S('WHERE %objAuthZoneMTableFIUG = "Y"');
                 }
                 // Add SOME LIMITs;
                 $objGetCondition->appendString(_SP)->appendString('LIMIT %LowerLimit, %UpperLimit')->doToken('%LowerLimit', $objLowerLimit)->doToken('%UpperLimit', $objUpperLimit);
                 // Set some requirements;
                 $objZoneMappings = $this->getZoneMappings($objGetCondition);
                 $objMappingsTableCount = $this->getMappingCount(new S('WHERE %objAuthZoneMTableFIUG = "Y"'));
                 // Set the template file ...
                 $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'manageMappings.tp');
                 TPL::tpSet($objZoneMappings, new S('zonesMappingsTableForGroup'), $tpF);
                 TPL::tpExe($tpF);
                 // Do pagination;
                 if ($objMappingsTableCount->toInt() > 10) {
                     self::$objAdministration->setPagination($objMappingsTableCount);
                 }
                 // Do the form, make it happen;
                 $this->renderForm(new S('zoneMappingCreateForGroups'));
             }
             break;
         case 'manageMappingsForUsers':
             // Do specific actions, based on _GET parameters;
             if (isset($_GET[ADMIN_ACTION])) {
                 switch ($_GET[ADMIN_ACTION]) {
                     case ADMIN_ACTION_EDIT:
                         $this->renderForm(new S('zoneMappingEdit'));
                         break;
                     case ADMIN_ACTION_ERASE:
                         $this->renderForm(new S('zoneMappingErase'));
                         break;
                 }
             } else {
                 // Do a sorting beforehand;
                 $objGetUCondition = new S();
                 if (isset($_GET[ADMIN_ACTION_SORT])) {
                     switch ($_GET[ADMIN_ACTION_SORT]) {
                         case 'AscByZone':
                         case 'DescByZone':
                             // Set some requirements;
                             $objGetUCondition = new S('AS t1 LEFT JOIN %objAuthZonesTable
                             AS t2 ON t1.%objAuthZoneMTableFZId = t2.%objAuthUsersTableFId
                             ORDER BY t2.%objAuthZonesTableFName');
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByZone':
                                     $objGetUCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByZone':
                                     $objGetUCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             break;
                         case 'AscByUsername':
                         case 'DescByUsername':
                             // Set some requirements;
                             $objGetUCondition = new S('AS t1 LEFT JOIN %objAuthUsersTable
                             AS t2 ON t1.%objAuthZoneMTableFUGId = t2.%objAuthUsersTableFId
                             ORDER BY t2.%objAuthUsersTableFUName');
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByUsername':
                                     $objGetUCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByUsername':
                                     $objGetUCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             break;
                     }
                 }
                 // LIMIT ONLY to USERS;
                 if ($objGetUCondition->toLength()->toInt() != 0) {
                     $objGetUCondition->doToken('ORDER', new S('WHERE %objAuthZoneMTableFIUG = "N" ORDER'));
                 } else {
                     $objGetUCondition = new S('WHERE %objAuthZoneMTableFIUG = "N"');
                 }
                 // Set some requirements;
                 $objMappingsTableCount = $this->getMappingCount(new S('WHERE %objAuthZoneMTableFIUG = "N"'));
                 $objZoneMappings = $this->getZoneMappings($objGetUCondition);
                 // Set the template file;
                 $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'manageMappingsForUsers.tp');
                 TPL::tpSet($objZoneMappings, new S('zonesMappingsTableForUsers'), $tpF);
                 TPL::tpExe($tpF);
                 // Do pagination;
                 if ($objMappingsTableCount->toInt() > 10) {
                     self::$objAdministration->setPagination($objMappingsTableCount);
                 }
                 // Do the form, make it happen;
                 $this->renderForm(new S('zoneMappingCreateForUsers'));
             }
             // Break out;
             break;
         case 'manageConfiguration':
             if (isset($_GET[ADMIN_ACTION])) {
                 $this->renderForm($_GET[ADMIN_ACTION]);
             } else {
                 $this->renderForm(new S('configurationEdit'));
             }
             break;
     }
 }
Пример #8
0
 /**
  * Will tie in ALL registered administrator interfaces in the framework;
  *
  * This method will do a scan of all modules defined in the framework, and WILL do a CALL to each bonding method of those
  * respective methods; For the Authentication and Administration module, proper code is implemented, because of the strict
  * bonding between these two modules;
  * @return void Will not return a thing, but probably error if something goes wrong;
  */
 private function tieALLRegisteredAdminInterfaces()
 {
     // Set some predefined defaults, just to be sure we have something;
     TPL::manageTTL(self::$objHeaderText);
     TPL::switchTTL();
     // Add the current page, or subpage to the <title> ...
     TPL::manageTTL(isset($_GET[ADMIN_PAGE]) ? $_GET[ADMIN_PAGE] : new S());
     TPL::manageTTL(isset($_GET[ADMIN_SUBPAGE]) ? $_GET[ADMIN_SUBPAGE] : new S());
     // Do a for-each on ALL registered modules within' the framework;
     $objRegisteredModules = $this->getRegisteredModules();
     foreach ($objRegisteredModules as $k => $v) {
         // IGNORE: Administration, because it's manually tied;
         if ($this->getPathToModule()->toRelativePath() == $v['dir']->toString()) {
             $this->tieInWithAdministration($this);
             continue;
         }
         // IGNORE: Authentication, because it's manually tied;
         if ($this->getObjectCLASS(self::$objAuthenticationMech) == $v['obj']) {
             if (self::$objAuthenticationMech->checkCurrentUserZoneACL($this->getObjectCLASS(self::$objAuthenticationMech))->toBoolean() == TRUE) {
                 self::$objAuthenticationMech->tieInWithAdministration($this);
             }
             continue;
         } else {
             // Make the object, and store it;
             $objMod = $this->activateModule(new FilePath($v['dir']), new B(TRUE));
             $objMod->tieInWithAuthentication(self::$objAuthenticationMech);
             if (self::$objAuthenticationMech->checkCurrentUserZoneACL($this->getObjectCLASS($objMod))->toBoolean() == TRUE) {
                 // Do the tie;
                 $objMod->tieInWithAdministration($this);
             }
         }
     }
     // Set some predefines;
     if (self::$objMenuArray == NULL) {
         self::$objMenuArray = new A();
     }
     if (self::$objSubMArray == NULL) {
         self::$objSubMArray = new A();
     }
     // Set the script end;
     self::setExeTime(new S('administration_end'));
     // After we know all the details, execute the viewer whit these parameters;
     $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'administration.tp');
     TPL::tpSet(new F(self::getExeTime(new S('administration_start'), new S('administration_end'))), new S('objExeTime'), $tpF);
     TPL::tpSet(self::$objSwitcherLink, new S('objSwitcherLink'), $tpF);
     TPL::tpSet(self::$objHeaderText, new S('objHeaderText'), $tpF);
     TPL::tpSet(self::$objFooterText, new S('objFooterText'), $tpF);
     TPL::tpSet(self::$objMenuArray, new S('objMenuArray'), $tpF);
     TPL::tpSet(self::$objSubMArray, new S('objSubMArray'), $tpF);
     TPL::tpSet(self::$objLogOutLink, new S('objLogOutLink'), $tpF);
     TPL::tpExe($tpF);
 }
Пример #9
0
 /**
  * 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 renderBackendPage(S $objPageToRender)
 {
     // Get a specific CSS file for this controller ...
     TPL::manageCSS(new FilePath($this->getPathToSkinCSS()->toRelativePath() . $objPageToRender . CSS_EXTENSION), $objPageToRender);
     // Do pagination ...
     if (isset($_GET[ADMIN_PAGINATION])) {
         $objLowerLimit = (int) $_GET[ADMIN_PAGINATION]->toString() * 10 - 10;
         $objUpperLimit = 10;
     } else {
         $objLowerLimit = 0;
         $objUpperLimit = 10;
     }
     // Do a switch on the rendered page ...
     switch ($objPageToRender) {
         case 'manageLyrics':
             // Do some work;
             if (isset($_GET[ADMIN_ACTION])) {
                 // Do a switch;
                 switch ($_GET[ADMIN_ACTION]) {
                     case ADMIN_ACTION_EDIT:
                         $this->renderForm(new S('lyricEdit'));
                         break;
                     case ADMIN_ACTION_ERASE:
                         $this->renderForm(new S('lyricErase'));
                         break;
                 }
             } else {
                 // Redirect to DescByDateAdded ...
                 if (!isset($_GET[ADMIN_ACTION_SORT])) {
                     $this->setHeaderKey(URL::rewriteURL(new A(array(ADMIN_ACTION_SORT)), new A(array('DescByDateAdded'))), new S('Location'));
                 }
                 // Set some requirements ...
                 $objGetCondition = new S();
                 // Do a sorting beforehand;
                 if (isset($_GET[ADMIN_ACTION_SORT])) {
                     // Do a switch ...
                     switch ($_GET[ADMIN_ACTION_SORT]) {
                         case 'AscByTitle':
                         case 'DescByTitle':
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objLyricsTableFTitle');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByTitle':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByTitle':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             // BK;
                             break;
                         case 'AscByArtist':
                         case 'DescByArtist':
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objLyricsTableFArtist');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByArtist':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByArtist':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             // BK;
                             break;
                         case 'AscByAlbum':
                         case 'DescByAlbum':
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objLyricsTableFAlbum');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByAlbum':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByAlbum':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             // BK;
                             break;
                         case 'AscByDateAdded':
                         case 'DescByDateAdded':
                             $objGetCondition->appendString(_SP)->appendString('ORDER BY %objLyricsTableFDateAdded');
                             // Do a switch ...
                             switch ($_GET[ADMIN_ACTION_SORT]) {
                                 case 'AscByDateAdded':
                                     $objGetCondition->appendString(_SP)->appendString('ASC');
                                     break;
                                 case 'DescByDateAdded':
                                     $objGetCondition->appendString(_SP)->appendString('DESC');
                                     break;
                             }
                             // BK;
                             break;
                     }
                 }
                 // Add some LIMITs
                 $objGetCondition->appendString(_SP)->appendString('LIMIT %LowerLimit, %UpperLimit')->doToken('%LowerLimit', $objLowerLimit)->doToken('%UpperLimit', $objUpperLimit);
                 // Set some requirements ...
                 $objLyricTable = $this->getLyrics($objGetCondition);
                 $objLyricTableCount = $this->getLyricCount();
                 // Set the template file ...
                 $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'manageLyrics.tp');
                 TPL::tpSet($objLyricTable, new S('lyricTable'), $tpF);
                 TPL::tpSet($this->ATH, new S('ATH'), $tpF);
                 TPL::tpSet($this->STG, new S('STG'), $tpF);
                 TPL::tpExe($tpF);
                 // Do some pagination;
                 if ($objLyricTableCount->toInt() > 10) {
                     self::$objAdministration->setPagination($objLyricTableCount);
                 }
                 // Do the form, make it happen;
                 $this->renderForm(new S('lyricCreate'));
             }
             // BK;
             break;
     }
 }
Пример #10
0
 /**
  * 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;
     }
 }