Beispiel #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;
     }
 }
Beispiel #2
0
<?php

/*
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
// Load needed modules ...
TPL::setHeaderKey(URL::rewriteURL(new A(array(ADMIN_SUBPAGE)), new A(array(ADMIN_WELCOME_PAGE))), new S('Location'));
Beispiel #3
0
 /**
  * Will output a given XML string, discarding output, and exiting right after. This can be used for example to output RSS or
  * an XML Sitemap (sitemaps.org) or any other kind of XML data you need to throw back from where it came from;
  *
  * @param S $objStringToOutput The string to output
  * @return S Outputs the string, using echo
  * @author Catalin Z. Alexandru <*****@*****.**>
  * @copyright Under the terms of the GNU General Public License v3
  * @version $Id: 10_TPL.php 315 2009-10-11 07:11:31Z catalin.zamfir $
  * @since Version 1.0
  * @access public
  * @static
  * @final
  */
 public static final function outputXMLString(S $objStringToOutput)
 {
     // Clean-up around the house ...
     TPL::setHeaderKey(new S('text/xml'), new S('Content-Type'));
     TPL::discardOutputStream(new B(TRUE));
     TPL::switchHTML();
     // Do an XML echo ...
     echo $objStringToOutput;
     // Unset _SESSION['POST'];
     if (isset($_SESSION['POST'])) {
         unset($_SESSION['POST']);
     }
     // Unset _SESSION['FILES'];
     if (isset($_SESSION['FILES'])) {
         unset($_SESSION['FILES']);
     }
     // DIE;
     TPL::disableFurtherOutput();
 }
 /**
  * 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;
     }
 }
Beispiel #5
0
 /**
  * Will set the given cookie information;
  *
  * This method will set the key/var pair of cookie information needed for the given module. In case of _SESSION it will store
  * the information by arrays, while cookies will have an identifier string that's long enough to be unique. Each module that
  * requests a cookie object has its own cookie scope;
  *
  * @param S $objKey The key to set;
  * @param S $objContent The content to set;
  * @param B $objExpTime The expire time to take in account;
  */
 public function setKey(S $objKey, S $objContent, B $objExpTime)
 {
     // Switch ...
     switch ($this->objObjectCookie->getConfigKey(new S('authentication_cookie_store_type'))) {
         case 'cookie':
             // Set the expire time, to current + SESSION_COOKIE_LIFETIME;
             $objExpTime->toBoolean() != TRUE ? $expTme = new I(0) : ($expTme = new I($_SERVER['REQUEST_TIME'] + SESSION_COOKIE_LIFETIME));
             // Trigger the browser cookie setter, and set the proper key/vars;
             setcookie($this->objProjectString . _U . $this->objObjectCookie->getObjectCLASS() . _U . $objKey, $objContent, $expTme->toInt(), new S('/'));
             // Redirect to same page, each time;
             TPL::setHeaderKey(URL::rewriteURL(), new S('Location'));
             break;
         case 'session':
             // Just use the _SESSION to store it;
             $_SESSION[$this->objProjectString->toString()][$this->objObjectCookie->getObjectCLASS()->toString()][$objKey->toString()] = $objContent;
             break;
         default:
             // Make an error on it, cause yeah ...
             self::renderScreenOfDeath(new S(__CLASS__), new S(SESSION_TYPE_ERROR), new S(SESSION_TYPE_ERROR_FIX));
             break;
     }
 }
Beispiel #6
0
 /**
  * Will do necessary URL routing and clean-up;
  *
  * While most of the times we will relly on static URLs, generated by our URL mechanism, most of the times we will need to be
  * able to modify the URL or redirect an user to a proper URL, if he has gone haywire. This method does just that, manages
  * the URL of the current requested page;
  */
 public function doURLRoutingAndCLEANUp()
 {
     // Redirect to HOME, if nothing set;
     if ($_GET->doCount()->toInt() == 0) {
         // Set the header key and go home my man ...
         TPL::setHeaderStr(new S(HDR::HEADER_MOVED_PERMANENTLY));
         TPL::setHeaderKey(URL::rewriteURL(new A(array(FRONTEND_SECTION_URL)), new A(array(FRONTEND_HOME))), new S('Location'));
     }
     // -- Fix the double www. and non-www;
     if (strpos(URL::rewriteURL(), '://www.') !== FALSE) {
         // Moved me permanently ...
         $this->setHeaderStr(new S(HDR::HEADER_MOVED_PERMANENTLY));
         $this->setHeaderKey(URL::rewriteURL()->doToken('://www.', '://'), new S('Location'));
     }
     // -- Fix the OLD to NEW moving of REWRITE_ENGINE;
     if (strpos($_SERVER['REQUEST_URI'], 'index.php/') !== FALSE && REWRITE_ENGINE == TRUE) {
         // Moved me permanently ...
         $this->setHeaderStr(new S(HDR::HEADER_MOVED_PERMANENTLY));
         $this->setHeaderKey(URL::rewriteURL()->doToken('index.php/', _NONE), new S('Location'));
     }
 }