Exemplo n.º 1
0
 /**
  * Will get the siteURL, concatenated or not with a pageSuffix, which can be NULL. The method will return the current URL, which
  * can be used to determine the current page the client is on. Either you can use this function from inside a child of the
  * current one or you can use the {@link URL::rewriteURL} method to retrieve such information.
  *
  * @return S Will return the current website URL string
  * @author Elena Ramona <*****@*****.**>
  * @copyright Under the terms of the GNU General Public License v3
  * @version $Id: 09_URL.php 313 2009-10-09 13:27:52Z catalin.zamfir $
  * @since Version 1.0
  * @access protected
  * @static
  * @final
  */
 protected static final function getSiteURL(S $websiteURL = NULL, S $pageSuffix = NULL)
 {
     // Make a switch ...
     switch ($pageSuffix != NULL) {
         case TRUE:
             $objURL = new S(DOCUMENT_HOST . $pageSuffix . _WS . $websiteURL);
             break;
         case FALSE:
             $pageSuffix = new S(str_replace(DOCUMENT_ROOT, _NONE, $_SERVER['SCRIPT_FILENAME']));
             $objURL = new S(DOCUMENT_HOST . $pageSuffix . _WS . $websiteURL);
             break;
     }
     // Do return ...
     return REWRITE_ENGINE == TRUE && strpos($_SERVER['REQUEST_URI'], _WS . ADMIN_DIR . _WS) === FALSE ? $objURL->doToken($pageSuffix . _WS, _NONE) : $objURL;
 }
Exemplo n.º 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 better;
  *
  * @param string $objFormToRender The name of the form to render;
  * @return mixed Depends on the rendered form if it returns something or not;
  */
 public function renderForm(S $objFormToRender, A $objFormArray = NULL)
 {
     // Make them defaults ...
     if ($objFormArray == NULL) {
         $objFormArray = new A();
     }
     // Do a switch ...
     switch ($objFormToRender) {
         case 'countryCreate':
             // The URL to go back too;
             $objURLToGoBack = URL::rewriteURL();
             // Do the form, make it happen;
             $this->setMethod(new S('POST'))->setFieldset(new S(SETTINGS_ADD_COUNTRY))->setSQLAction(new S('update'))->setTableName(self::$objSettingsCountryTable);
             // Make the ISO ...
             if ($this->checkPOST()->toBoolean() == TRUE) {
                 $this->setUpdateId($this->getPOST(self::$objSettingsCountryTableFIso))->setExtraUpdateData(self::$objSettingsCountryTableFName, $this->getPOST(self::$objSettingsCountryTableFPrnt)->toUpper());
             }
             // Continue;
             $this->setUpdateField(self::$objSettingsCountryTableFIso)->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(SETTINGS_ADD_COUNTRY))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objSettingsCountryTableFIso)->setLabel(new S(SETTINGS_COUNTRY_ISO))->setInputType(new S('text'))->setName(self::$objSettingsCountryTableFPrnt)->setLabel(new S(SETTINGS_COUNTRY_NAME))->setInputType(new S('text'))->setName(self::$objSettingsCountryTableFIsoT)->setJSRegExpReplace(new S('[^A-Z]'))->setLabel(new S(SETTINGS_COUNTRY_ISO3))->setInputType(new S('text'))->setName(self::$objSettingsCountryTableFCode)->setJSRegExpReplace(new S('[^0-9]'))->setLabel(new S(SETTINGS_COUNTRY_CODE))->setFormEndAndExecute(new B(TRUE));
             break;
         case 'countryEdit':
             // 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(SETTINGS_EDIT_COUNTRY))->setSQLAction(new S('update'))->setTableName(self::$objSettingsCountryTable)->setUpdateId($_GET[ADMIN_ACTION_ID]);
             // Set the printable country name;
             if ($this->checkPOST()->toBoolean() == TRUE) {
                 $objCountryName = clone $this->getPOST(self::$objSettingsCountryTableFPrnt);
                 $this->setExtraUpdateData(self::$objSettingsCountryTableFName, $objCountryName->toUpper());
             }
             // Continue;
             $this->setUpdateField(self::$objSettingsCountryTableFIso)->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(SETTINGS_EDIT_COUNTRY))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objSettingsCountryTableFPrnt)->setLabel(new S(SETTINGS_COUNTRY_NAME))->setInputType(new S('text'))->setName(self::$objSettingsCountryTableFIsoT)->setJSRegExpReplace(new S('[^A-Z]'))->setLabel(new S(SETTINGS_COUNTRY_ISO3))->setInputType(new S('text'))->setName(self::$objSettingsCountryTableFCode)->setJSRegExpReplace(new S('[^0-9]'))->setLabel(new S(SETTINGS_COUNTRY_CODE))->setFormEndAndExecute(new B(TRUE));
             break;
         case 'countryErase':
             // The URL to go back too;
             $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID)));
             // Set some requirements;
             $objSQLConditionForUsers = new S('WHERE %objAuthUsersTableFCountry = "%cId"');
             if (self::$objAuthenticationMech->getUserCount($objSQLConditionForUsers->doToken('%cId', $_GET[ADMIN_ACTION_ID]))->toInt() == 0) {
                 // Do ERASE;
                 $this->_Q(_QS('doDELETE')->doToken('%table', self::$objSettingsCountryTable)->doToken('%condition', new S('%objSettingsCountryTableFIso = "%sId"'))->doToken('%sId', $_GET[ADMIN_ACTION_ID]));
                 // Redirect;
                 $this->setHeaderKey($objURLToGoBack, new S('Location'));
             } else {
                 // Do me, ERROR;
                 self::$objAdministration->setErrorMessage(new S(SETTINGS_CANNOT_DELETE_COUNTRY), $objURLToGoBack);
             }
             break;
         case 'errorPageCreate':
             // The URL to go back too;
             $objURLToGoBack = URL::rewriteURL();
             // Check CODE is unique;
             if ($this->checkPOST(self::$objSettingsErrTableFCode)->toBoolean() == TRUE) {
                 if ($this->checkErrorPageCodeIsUnique($this->getPOST(self::$objSettingsErrTableFCode))->toBoolean() == FALSE) {
                     $this->setErrorOnInput(self::$objSettingsErrTableFCode, new S(SETTINGS_ERROR_CODE_MUST_BE_UNIQUE));
                 }
             }
             // Do the form, make it happen;
             $this->setMethod(new S('POST'))->setFieldset(new S(SETTINGS_ADD_ERROR_PAGE))->setSQLAction(new S('update'))->setTableName(self::$objSettingsErrTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objSettingsErrTableFId)->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(SETTINGS_ADD_ERROR_PAGE))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objSettingsErrTableFCode)->setLabel(new S(SETTINGS_ERROR_PAGE_CODE))->setJSRegExpReplace(new S('[^0-9]'))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objSettingsErrTableFTitle)->setLabel(new S(SETTINGS_ERROR_PAGE_TITLE))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objSettingsErrTableFContent)->setLabel(new S(SETTINGS_ERROR_PAGE_CONTENT))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE));
             break;
         case 'errorPageEdit':
             // The URL to go back too;
             $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID)));
             // Check CODE is unique;
             if ($this->checkPOST(self::$objSettingsErrTableFCode)->toBoolean() == TRUE) {
                 if ($this->getPOST(self::$objSettingsErrTableFCode) != $this->getErrorPageById($_GET[ADMIN_ACTION_ID], self::$objSettingsErrTableFCode)) {
                     if ($this->checkErrorPageCodeIsUnique($this->getPOST(self::$objSettingsErrTableFCode))->toBoolean() == FALSE) {
                         $this->setErrorOnInput(self::$objSettingsErrTableFCode, new S(SETTINGS_ERROR_CODE_MUST_BE_UNIQUE));
                     }
                 }
             }
             // Do the form, make it happen;
             $this->setMethod(new S('POST'))->setFieldset(new S(SETTINGS_EDIT_ERROR_PAGE))->setSQLAction(new S('update'))->setTableName(self::$objSettingsErrTable)->setUpdateId($_GET[ADMIN_ACTION_ID])->setUpdateField(self::$objSettingsErrTableFId)->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(SETTINGS_EDIT_ERROR_PAGE))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objSettingsErrTableFCode)->setLabel(new S(SETTINGS_ERROR_PAGE_CODE))->setJSRegExpReplace(new S('[^0-9]'))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objSettingsErrTableFTitle)->setLabel(new S(SETTINGS_ERROR_PAGE_TITLE))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objSettingsErrTableFContent)->setLabel(new S(SETTINGS_ERROR_PAGE_CONTENT))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE));
             break;
         case 'errorPageErase':
             // The URL to go back too;
             $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID)));
             // Make the erase, than redirect;
             $this->_Q(_QS('doDELETE')->doToken('%table', self::$objSettingsErrTable)->doToken('%condition', new S('%objSettingsErrTableFId = "%sId"'))->doToken('%sId', $_GET[ADMIN_ACTION_ID]));
             // Redirect;
             $this->setHeaderKey($objURLToGoBack, new S('Location'));
             break;
         case 'configurationEdit':
             // The URL to go back too;
             $objURLToGoBack = URL::rewriteURL();
             // 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(SETTINGS_MANAGE_CONFIG))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(SETTINGS_DO))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(new S('what'))->setLabel(new S(SETTINGS_CHOOSE))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('configurationEditAdminApplicationTitle'))->setValue(new S('configurationEditAdminApplicationTitle'))->setLabel(new S(SETTINGS_ADMIN_TITLE))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('configurationEditApplicationTitle'))->setValue(new S('configurationEditApplicationTitle'))->setLabel(new S(SETTINGS_FRONTEND_TITLE))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('configurationEditWebsiteNotificationEmail'))->setValue(new S('configurationEditWebsiteNotificationEmail'))->setLabel(new S(SETTINGS_WEBSITE_NOTIFICATION_EMAIL))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('configurationEditDefaultDateType'))->setValue(new S('configurationEditDefaultDateType'))->setLabel(new S(SETTINGS_DEFAULT_DATE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE));
             break;
         case 'configurationEditAdminApplicationTitle':
             // 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(SETTINGS_UPDATE_SETTINGS))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(SETTINGS_UPDATE_SETTINGS))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setInputInfoMessage($this->getHELP($objFormToRender))->setName(new S('administration_header_text'))->setLabel(new S(SETTINGS_ADMIN_APPLICATION_TITLE))->setValue($this->getConfigKey(new S('administration_header_text')))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE));
             break;
         case 'configurationEditApplicationTitle':
             // The URL to go back too;
             $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION)));
             // Do form validation;
             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(SETTINGS_UPDATE_SETTINGS))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(SETTINGS_UPDATE_SETTINGS))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setInputInfoMessage($this->getHELP($objFormToRender))->setName(new S('settings_website_default_title'))->setLabel(new S(SETTINGS_ADMIN_APPLICATION_TITLE))->setValue($this->getConfigKey(new S('settings_website_default_title')))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE));
             break;
         case 'configurationEditWebsiteNotificationEmail':
             // The URL to go back too;
             $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION)));
             // Do form validation;
             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(SETTINGS_UPDATE_SETTINGS))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(SETTINGS_UPDATE_SETTINGS))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setInputInfoMessage($this->getHELP($objFormToRender))->setName(new S('settings_website_notification_email'))->setLabel(new S(SETTINGS_NOTIFICATION_EMAIL_LABEL))->setValue($this->getConfigKey(new S('settings_website_notification_email')))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE));
             break;
         case 'configurationEditDefaultDateType':
             // The URL to go back too;
             $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION)));
             // Do form validation;
             if ($this->checkPOST()->toBoolean() == TRUE) {
                 foreach ($this->getPOST() as $k => $v) {
                     $this->setConfigKey(new S($k), $v);
                 }
             }
             // Get the date format used for now ...
             $objDateFormat = $this->getConfigKey(new S('settings_default_date_format'));
             // Do the form, make it happen;
             $this->setMethod(new S('POST'))->setFieldset(new S(SETTINGS_UPDATE_SETTINGS))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(SETTINGS_UPDATE_SETTINGS))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(new S('settings_default_date_format'))->setLabel(new S(SETTINGS_DEFAULT_DATE_FORMAT))->setInputType(new S('option'))->setName(new S('date_format_1'))->setLabel(new S(date('F j, Y, g:i a')))->setValue(new S('F j, Y, g:i a'))->setSelected(new B($objDateFormat == new S('F j, Y, g:i a') ? TRUE : FALSE))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('date_format_2'))->setLabel(new S(date('D M j G:i:s T Y')))->setValue(new S('D M j G:i:s T Y'))->setSelected(new B($objDateFormat == new S('D M j G:i:s T Y') ? TRUE : FALSE))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('date_format_3'))->setLabel(new S(date('r')))->setValue(new S('r'))->setSelected(new B($objDateFormat == new S('r') ? TRUE : FALSE))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('date_format_4'))->setLabel(new S(date('d-m-Y H:i:s')))->setValue(new S('d-m-Y H:i:s'))->setSelected(new B($objDateFormat == new S('d-m-Y H:i:s') ? TRUE : FALSE))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('date_format_5'))->setLabel(new S(date('Y-m-d H:i:s')))->setValue(new S('Y-m-d H:i:s'))->setSelected(new B($objDateFormat == new S('Y-m-d H:i:s') ? TRUE : FALSE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE));
             break;
     }
 }
Exemplo n.º 3
0
 /**
  * Will return an array containing field names of the given string table name. This method is used to find out what fields a table
  * has so we can use that information for example in the development of our auto-forms. Other uses can also be found easily when
  * knowing or not knowing the table structure;
  *
  * @param S $queryTable The table to query for fields
  * @return A An array containing the fields from the table
  * @author Catalin Z. Alexandru <*****@*****.**>
  * @copyright Under the terms of the GNU General Public License v3
  * @version $Id: 11_SQL.php 313 2009-10-09 13:27:52Z catalin.zamfir $
  * @since Version 1.0
  * @access protected
  * @static
  */
 protected static function getFieldsFromTable(S $queryTable)
 {
     $ex = new R(mysql_list_fields(self::$objSQLD, $queryTable->doToken(SQL_PREFIX, self::$objSQLR)));
     $tableFieldColumns = new I(mysql_num_fields($ex->toResource()));
     for ($i = 0, $tableFieldArray = new A(); $i < $tableFieldColumns->toInt(); ++$i) {
         $tableFieldArray[$i] = new S(mysql_field_name($ex->toResource(), $i));
     }
     // We already know what it is, return it;
     return $tableFieldArray;
 }
Exemplo n.º 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 '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;
     }
 }
Exemplo n.º 5
0
 /**
  * Will execute necessary SQL operations on the current form ...
  *
  * This method, setSQLOperationsOnForm, you don't need to know the internal workings of it. This is because, as you can see
  * it is a private method, and thus, it's used internally by the class, to achieve it's goals of execution. Just pass on
  * and read any other 'public' or 'protected' method out there ...
  *
  * @param array $inputAttributes The core attributes (found in every HTML element) that can be set;
  * @param string $tp The path to the .tp file where to set those variables;
  */
 private static final function updateObjectPropertiesonSQLUpdateorInsert()
 {
     if (isset(self::$objFormDataContainer['update_or_insert']) && isset(self::$objFormDataContainer['table_name'])) {
         if (isset(self::$objFormDataContainer['update_where'])) {
             // Set it to what ever the developer wants it set to ...
             self::$objUpdateWhere = self::$objFormDataContainer['update_where'];
         } else {
             self::$objUpdateWhere = new S('%who = "%what"');
             self::$objUpdateWhere->doToken('%who', self::$objUpdateUpdateField);
             self::$objUpdateWhere->doToken('%what', self::$objUpdateUpdateId);
         }
         // Check to see which operation to execute ...
         if (self::$objFormDataContainer['update_or_insert'] == new S('update')) {
             // Do we have multiple or simple updates ...
             if (isset(self::$objFormDataContainer['table_join_on']) && isset(self::$objFormDataContainer['table_save_into'])) {
                 self::$objUpdateTableName = new S(self::$objFormDataContainer['table_name'] . _SP . self::$objFormDataContainer['table_join_on']);
                 $updateTable = self::$objFormDataContainer['table_save_into']->toValues();
                 $updateTableCount = count($updateTable);
                 $updateTable[$updateTableCount++] = self::$objFormDataContainer['table_name'];
                 for ($i = 0; $i < $updateTableCount; ++$i) {
                     self::$objUpdateTableFields = new A(array_merge(self::$objUpdateTableFields->toArray(), self::getFieldsFromTable(new S($updateTable[$i]))->toArray()));
                 }
             } else {
                 self::$objUpdateTableName = self::$objFormDataContainer['table_name'];
                 self::$objUpdateTableFields = self::getFieldsFromTable(self::$objUpdateTableName);
             }
         }
         if (!self::checkPOST()->toBoolean() == TRUE) {
             $q = new S('SELECT * FROM %table WHERE %condition LIMIT 1');
             $q->doToken('%table', self::$objUpdateTableName)->doToken('%condition', self::$objUpdateWhere);
             self::$objUpdateSELECTData = self::getQuery($q);
         }
     }
 }