示例#1
0
 public function __construct()
 {
     parent::__construct();
     // Set the module configuration file, based on the CLASS name, adding a .cfg;
     $this->setModuleConfigFile($this->getObjectCLASS()->appendString('.cfg'));
     if (!TheFactoryMethodOfSingleton::checkHasInstance(__CLASS__)) {
         self::setExeTime(new S(__CLASS__));
         if ($this->objIdentificationString == __CLASS__) {
             // Instantiate some types;
             self::$objRegisteredModules = new A();
             self::$objRegisteredClasses = new A();
             // Scan for module directory, in the MOD_DIR dir;
             if (!isset($_SESSION[PROJECT_NAME]['RA_mod_reg'])) {
                 $scannedModuleDirectory = new FileDirectory(MOD_DIR);
                 $_SESSION[PROJECT_NAME]['RA_mod_reg']['scandir'] = $scannedModuleDirectory->scanDirectory($_SESSION[PROJECT_NAME]['RA_mod_reg']['f_count']);
             }
             // Do the FOR;
             for ($i = 0; $i < $_SESSION[PROJECT_NAME]['RA_mod_reg']['f_count']; ++$i) {
                 // Register new module;
                 $this->registerModule(new FileDirectory(MOD_DIR . _S . $_SESSION[PROJECT_NAME]['RA_mod_reg']['scandir'][$i]));
             }
         }
     } else {
         // Return the instantiated object;
         return TheFactoryMethodOfSingleton::getInstance(__CLASS__);
     }
 }
示例#2
0
 public function __construct(S $databaseIndex = NULL)
 {
     parent::__construct();
     // Do the rest ...
     if (!TheFactoryMethodOfSingleton::checkHasInstance(__CLASS__)) {
         // Set execution time for SQLHandler;
         self::setExeTime(new S(__CLASS__));
         // Make a default databaseIndex ...
         switch ($databaseIndex == NULL) {
             case TRUE:
                 // Yes, we set the default ...
                 $databaseIndex = new S('db_0');
                 break;
         }
         # Set ALL object properties to some defaults ...
         self::$objSQLH = new S($GLOBALS['H'][$databaseIndex->toString()]);
         self::$objSQLU = new S($GLOBALS['U'][$databaseIndex->toString()]);
         self::$objSQLP = new S($GLOBALS['P'][$databaseIndex->toString()]);
         self::$objSQLD = new S($GLOBALS['D'][$databaseIndex->toString()]);
         self::$objSQLR = new S($GLOBALS['R'][$databaseIndex->toString()]);
         // Use a switch, to clean the code;
         if (SQL_PERSISTENT_CONNECTION == 1) {
             // Do return ...
             return (mysql_pconnect(self::$objSQLH, self::$objSQLU, self::$objSQLP) or self::renderSQLScreenOfDeath()) && (mysql_select_db(self::$objSQLD) or self::renderSQLScreenOfDeath());
         } else {
             // Do return ...
             return (mysql_connect(self::$objSQLH, self::$objSQLU, self::$objSQLP) or self::renderSQLScreenOfDeath()) && (mysql_select_db(self::$objSQLD) or self::renderSQLScreenOfDeath());
         }
     } else {
         // Return the instantiated object;
         return TheFactoryMethodOfSingleton::getInstance(__CLASS__);
     }
 }
示例#3
0
// Include all developer files in DEVELOPER_DIR/DEVELOPER_HEADER;
$includeFiles = scandir(DOCUMENT_ROOT . DEVELOPER_DIR . _S . DEVELOPER_HEADER);
sort($includeFiles, SORT_STRING);
foreach ($includeFiles as $k => $v) {
    if ($v[0] != '.') {
        $f = DOCUMENT_ROOT . DEVELOPER_DIR . _S . DEVELOPER_HEADER . _S . $v;
        # Require ONCE;
        require_once $f;
    }
}
// We're done loading, we can make it work, now ... Yey!;
// We can either use these individual objects, to acces specific functions just from them, which should make the code
// a little bit clearer, or we can use the slower, object delegator that's setup below;
$URL = TheFactoryMethodOfSingleton::getInstance('URL');
$TPL = TheFactoryMethodOfSingleton::getInstance('TPL');
$SQL = TheFactoryMethodOfSingleton::getInstance('SQL');
$GPH = TheFactoryMethodOfSingleton::getInstance('GPH');
$FRM = TheFactoryMethodOfSingleton::getInstance('FRM');
$CNF = TheFactoryMethodOfSingleton::getInstance('CNF');
$MOD = TheFactoryMethodOfSingleton::getInstance('MOD');
### Make a common interface for ALL, with a delegator;
// Besides using each object, we can use ALL to map-out all objects in the framework;
// Because people are lazy, and they would usually want "one object to rule them all!";
$OBJ = new ObjectMethodDelegator();
$OBJ->registerObject($ERR);
$OBJ->registerObject($TPL);
$OBJ->registerObject($SQL);
$OBJ->registerObject($GPH);
$OBJ->registerObject($FRM);
$OBJ->registerObject($CNF);
$OBJ->registerObject($MOD);
示例#4
0
 /**
  * Sets anything that's needed to make the RA PHP Framework work as expected. Usually we don't document __constructors as the name
  * of the method says it all, but in this case we need to document that the 'ERR' __constructor is called to initialize the RA
  * PHP Framework as it's the first non-abstract inherited CLASS. For this purpose only, it will set the default configuration
  * options, the Ouput Buffering mechanis, the Error Handling mechanism and other properties;
  *
  * @return B Returns true if the object has been constructed properly
  * @author Catalin Z. Alexandru <*****@*****.**>
  * @copyright Under the terms of the GNU General Public License v3
  * @version $Id: 08_ERR.php 313 2009-10-09 13:27:52Z catalin.zamfir $
  * @since Version 1.0
  * @access public
  */
 public function __construct()
 {
     if (!TheFactoryMethodOfSingleton::checkHasInstance(__CLASS__)) {
         self::$objErrorHappened = new I(0);
         self::$objHT = new A();
         self::$objExecutionTime = new A();
         self::$objTokensReplace = new A();
         self::$objStringReplace = new A();
         self::$objOutputBuffer = new A();
         self::$objOutputBufferCount = new I(0);
         if (self::setRAPHPFrameworkINIObjectProps()->toBoolean()) {
             self::setExeTime(new S(__CLASS__));
             self::setOutputStreamCallbackWorker(new S(__CLASS__ . _DC . 'executionStreamedOutput'));
             self::setOutputErrorCatcherCallback(new S(__CLASS__ . _DC . 'executionCatchPHPErrors'));
             self::executeOutputStream();
             self::setCacheHeaderKeys();
             self::setHTAutoPHP();
             // If the LOAD is ok, go on!
             if (self::getRAPHPFrameworkAverageLoading()->toInt() > SYSTEM_LOAD_MAX) {
                 // SYSTEM_LOAD_TO_HIGH, show an error screen;
                 self::renderScreenOfDeath(new S(__CLASS__), new S(SYSTEM_LOAD_TOO_HIGH), new S(SYSTEM_LOAD_TOO_HIGH_FIX));
             } else {
                 // If an attempt to re-open the session is made, output an error;
                 if (!self::checkSessionVar(new S('in_session'), new O(TRUE))->toBoolean()) {
                     if (self::openSession()) {
                         // Set _SESSION variables;
                         if (self::setSessionVar(new S('in_session'), new O(TRUE)) && self::setSessionVar(new S('skin'), new O(SKIN)) && self::setSessionVar(new S('language'), new O(LANGUAGE)) && self::setSessionVar(new S('default_timezone'), new O(DATE_TIMEZONE))) {
                             // Do return;
                             return new B(TRUE);
                         } else {
                             // Error me proudly;
                             self::renderScreenOfDeath(new S(__CLASS__), new S(CANNOT_START_SESSION), new S(CANNOT_START_SESSION_FIX));
                         }
                     }
                 } else {
                     // Error me proudly;
                     self::renderScreenOfDeath(new S(__CLASS__), new S(CANNOT_START_SESSION), new S(CANNOT_START_SESSION_FIX));
                 }
             }
         }
     } else {
         // Return the object instance, from the array;
         return TheFactoryMethodOfSingleton::getInstance(__CLASS__);
     }
 }
示例#5
0
 /**
  * Will manage JSS FilePaths added to the header, having the same calling method as the CSS method. You can use this method to add
  * <script type='text/javascript' src='...'> - to the header section of our DOM. It's the same use as the {@link TPL::manageCSS}
  * method that you regurally use to add CSS files to the header;
  *
  * @param S $relativeWebJSSFile Relative path to the included JSS files
  * @param S $relativeWebJSSFileTag The identifier used to tag this JSS file for quick removal
  * @return O Will return the current object instance
  * @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 manageJSS(FilePath $relativeWebJSSFile, S $relativeWebJSSFileTag = NULL)
 {
     if ($relativeWebJSSFileTag != NULL) {
         if (!isset(self::$objPageJSS[$relativeWebJSSFileTag])) {
             self::$objPageJSS[$relativeWebJSSFileTag] = $relativeWebJSSFile->toRelativePath()->prependString(DOCUMENT_HOST);
             return TheFactoryMethodOfSingleton::getInstance(__CLASS__);
         }
     } else {
         // Fixed OLD code;
         if ($k = array_search($relativeWebJSSFile->toRelativePath(), self::$objPageJSS->toArray())) {
             unset(self::$objPageJSS[$k]);
             return TheFactoryMethodOfSingleton::getInstance(__CLASS__);
         } else {
             self::renderScreenOfDeath(new S(__CLASS__), new S(JSS_FILE_PATH_NOT_SET), new S(JSS_FILE_PATH_NOT_SET_FIX));
         }
     }
 }
示例#6
0
 /**
  * Will set a key/var combination of HTML tags with attributes (key) and values (vars) ...
  *
  * This method, setAttribute, will set a key/var combination of attributes/values, that are needed for form generation. It
  * will take a default action of attributes that do not have special requirements, while parsing some of those that
  * indeed need special attention. For example, for enctype, it will accept one of three possible parameters, else it will
  * output an error screen ... Other attributes may suffer the same behaviour ...
  *
  * @param string $objFormAttributeKey The key to be set;
  * @param mixed $objFormAttributeVar The var to be set for the current key;
  * @return object The current object instance;
  */
 private static final function setAttribute(S $objFormAttributeKey, M $objFormAttributeVar)
 {
     switch ($objFormAttributeKey) {
         case 'method':
         case 'action':
         case 'fieldset':
         case 'table_name':
         case 'table_join_on':
         case 'table_save_into':
         case 'update_where':
         case 'update_or_insert':
         case 'redirect_if_ok':
         case 'accepted_mime_types':
         case 'upload_error_message':
         case 'upload_dir':
         case 'upload_resize_img':
             self::$objFormDataContainer[$objFormAttributeKey] = $objFormAttributeVar;
             break;
         case 'update_id':
             if ($objFormAttributeVar == '#nextTableAutoIncrement') {
                 // Set some requirements;
                 $objSQLCondition = new S('SHOW TABLE STATUS LIKE "%t"');
                 self::$objUpdateUpdateId = self::getQuery($objSQLCondition->doToken('%t', self::$objFormDataContainer['table_name']))->offsetGet(0)->offsetGet('Auto_increment');
             } else {
                 self::$objUpdateUpdateId = $objFormAttributeVar;
             }
             break;
         case 'update_id_field':
             self::$objUpdateUpdateField = $objFormAttributeVar;
             break;
         case 'type':
             self::$objDataToForm->setInt(1);
             self::$objDataCountInput->setInt(count(self::$objDataContainer));
             if (isset(self::$objDataContainer[self::$objDataCountInput->toInt() - 1])) {
                 if (isset(self::$objDataContainer[self::$objDataCountInput->toInt() - 1]['type'])) {
                     if (self::$objDataContainer[self::$objDataCountInput->toInt() - 1]['type'] == 'option' || self::$objDataContainer[self::$objDataCountInput->toInt() - 1]['type'] == 'optgroup') {
                         if ($objFormAttributeVar == 'optgroup') {
                             self::$objDataContainer[self::$objDataCountInput] = new A(array('type' => new S('optgroup_ending'), 'name' => new S('optgroup_ending')));
                             self::$objDataCountInput->setInt(count(self::$objDataContainer));
                             self::$objOptGroupOpen->setInt(1);
                         }
                         if ($objFormAttributeVar != 'option') {
                             if ($objFormAttributeVar != 'optgroup') {
                                 if ($objFormAttributeVar != 'optgroup_ending') {
                                     if (self::$objOptGroupOpen->toInt() == 1) {
                                         self::$objDataContainer[self::$objDataCountInput] = new A(array('type' => new S('optgroup_ending'), 'name' => new S('optgroup_ending')));
                                         self::$objDataCountInput->setInt(count(self::$objDataContainer));
                                         self::$objOptGroupOpen->setInt(1);
                                     }
                                     self::$objDataContainer[self::$objDataCountInput] = new A(array('type' => new S('select_ending'), 'name' => new S('select_ending')));
                                     self::$objDataCountInput->setInt(count(self::$objDataContainer));
                                 }
                             }
                         }
                     }
                 }
             }
             // REMEMBER ME: If SELECT is empty; Added so that SELECTS with nothing in them, shoud not produce HTML errors;
             // If we experience problems, this is the place to CHECK;
             if (isset(self::$objDataContainer[self::$objDataCountInput->toInt() - 1])) {
                 if (isset(self::$objDataContainer[self::$objDataCountInput->toInt() - 1]['type'])) {
                     if (self::$objDataContainer[self::$objDataCountInput->toInt() - 1]['type'] == 'select') {
                         if ($objFormAttributeVar != 'option') {
                             if ($objFormAttributeVar != 'optgroup') {
                                 if ($objFormAttributeVar != 'optgroup_ending') {
                                     self::$objDataContainer[self::$objDataCountInput] = new A(array('type' => new S('select_ending'), 'name' => new S('select_ending')));
                                     self::$objDataCountInput->setInt(count(self::$objDataContainer));
                                 }
                             }
                         }
                     }
                 }
             }
             // Continue;
             isset(self::$objDataContainer[self::$objDataCountInput]) ? self::$objDataContainer[self::$objDataCountInput] = _NONE : (self::$objDataContainer[self::$objDataCountInput] = new A());
             self::$objDataContainer[self::$objDataCountInput][$objFormAttributeKey] = $objFormAttributeVar;
             break;
         case 'multiple':
             if (self::$objDataToForm->toInt() == 1) {
                 if (self::$objDataContainer[self::$objDataCountInput]['type'] == new S('select')) {
                     self::$objDataContainer[self::$objDataCountInput][$objFormAttributeKey] = $objFormAttributeVar;
                 } else {
                     self::renderScreenOfDeath(new S(__CLASS__), new S(CANNOT_SET_MULTIPLE_ON_NON_SELECT), new S(CANNOT_SET_MULTIPLE_ON_NON_SELECT_FIX));
                 }
             } else {
                 self::renderScreenOfDeath(new S(__CLASS__), new S(CANNOT_SET_MULTIPLE_ON_NON_SELECT), new S(CANNOT_SET_MULTIPLE_ON_NON_SELECT_FIX));
             }
             break;
         case 'accept':
             if (self::$objDataToForm->toInt() == 1) {
                 if (self::$objDataContainer[self::$objDataCountInput]['type'] == new S('file')) {
                     self::$objDataContainer[self::$objDataCountInput][$objFormAttributeKey] = $objFormAttributeVar;
                 } else {
                     self::renderScreenOfDeath(new S(__CLASS__), new S(CANNOT_SET_ACCEPT_ON_NON_FILE), new S(CANNOT_SET_ACCEPT_ON_NON_FILE_FIX));
                 }
             } else {
                 # The <form has an accept parameter you know ...
                 self::$objFormDataContainer[$objFormAttributeKey] = $objFormAttributeVar;
             }
             break;
         case 'alt':
             if (self::$objDataToForm->toInt() == 1) {
                 if (self::$objDataContainer[self::$objDataCountInput]['type'] == new S('image')) {
                     self::$objDataContainer[self::$objDataCountInput][$objFormAttributeKey] = $objFormAttributeVar;
                 } else {
                     self::renderScreenOfDeath(new S(__CLASS__), new S(CANNOT_SET_ALT_ON_NON_IMAGE), new S(CANNOT_SET_ALT_ON_NON_IMAGE_FIX));
                 }
             } else {
                 self::renderScreenOfDeath(new S(__CLASS__), new S(CANNOT_SET_ALT_ON_NON_IMAGE), new S(CANNOT_SET_ALT_ON_NON_IMAGE_FIX));
             }
             break;
         case 'src':
             if (self::$objDataToForm->toInt() == 1) {
                 if (self::$objDataContainer[self::$objDataCountInput]['type'] == new S('image')) {
                     self::$objDataContainer[self::$objDataCountInput][$objFormAttributeKey] = $objFormAttributeVar;
                 } else {
                     self::renderScreenOfDeath(new S(__CLASS__), new S(CANNOT_SET_SRC_ON_NON_IMAGE), new S(CANNOT_SET_SRC_ON_NON_IMAGE_FIX));
                 }
             } else {
                 self::renderScreenOfDeath(new S(__CLASS__), new S(CANNOT_SET_SRC_ON_NON_IMAGE), new S(CANNOT_SET_SRC_ON_NON_IMAGE_FIX));
             }
             break;
         case 'checked':
             if (self::$objDataToForm->toInt() == 1) {
                 if (self::$objDataContainer[self::$objDataCountInput]['type'] == new S('radio') || self::$objDataContainer[self::$objDataCountInput]['type'] == new S('checkbox')) {
                     self::$objDataContainer[self::$objDataCountInput][$objFormAttributeKey] = $objFormAttributeVar;
                 } else {
                     self::renderScreenOfDeath(new S(__CLASS__), new S(CANNOT_SET_CHK_ON_NON_CHKRADIO), new S(CANNOT_SET_CHK_ON_NON_CHKRADIO_FIX));
                 }
             } else {
                 self::renderScreenOfDeath(new S(__CLASS__), new S(CANNOT_SET_CHK_ON_NON_CHKRADIO), new S(CANNOT_SET_CHK_ON_NON_CHKRADIO_FIX));
             }
             break;
         case 'name':
             if (self::$objDataToForm->toInt() == 1) {
                 if (self::$objDataContainer[self::$objDataCountInput]['type'] == 'select') {
                     self::$objOpenedSelectName = $objFormAttributeVar;
                     self::$objDataContainer[self::$objDataCountInput][$objFormAttributeKey] = $objFormAttributeVar;
                 } else {
                     if (self::$objDataContainer[self::$objDataCountInput]['type'] == 'select_ending') {
                         self::$objOpenedSelectName = NULL;
                         self::$objDataContainer[self::$objDataCountInput][$objFormAttributeKey] = $objFormAttributeVar;
                     } else {
                         if (self::$objDataContainer[self::$objDataCountInput]['type'] == new S('option')) {
                             self::$objDataContainer[self::$objDataCountInput]['bound_to'] = self::$objOpenedSelectName;
                         } else {
                             self::$objDataContainer[self::$objDataCountInput][$objFormAttributeKey] = $objFormAttributeVar;
                         }
                     }
                 }
             } else {
                 self::$objFormDataContainer[$objFormAttributeKey] = $objFormAttributeVar;
             }
             break;
         case 'file_controller':
             if (self::$objDataToForm->toInt() == 1) {
                 if (self::$objDataContainer[self::$objDataCountInput]['type'] == new S('file')) {
                     self::$objDataContainer[self::$objDataCountInput][$objFormAttributeKey] = $objFormAttributeVar;
                 } else {
                     self::renderScreenOfDeath(new S(__CLASS__), new S(CANNOT_USE_FILE_CONTROLLER), new S(CANNOT_USE_FILE_CONTROLLER_FIX));
                 }
             }
             break;
         case 'label':
             // Set the LABEL;
             self::$objDataContainer[self::$objDataCountInput][$objFormAttributeKey] = $objFormAttributeVar;
             // For OPTIONs, also set the VALUE;
             if (self::$objDataContainer[self::$objDataCountInput]['type'] == new S('option')) {
                 // If NOT already set;
                 if (!isset(self::$objDataContainer[self::$objDataCountInput]['value'])) {
                     self::$objDataContainer[self::$objDataCountInput]['value'] = $objFormAttributeVar;
                 }
             }
             break;
         case 'tiny_mce_textarea':
             // Set the required TinyMCE JS Scripts;
             self::manageJSS(new FilePath(FORM_TP_DIR . _S . JAVASCRIPT_DIR . _S . 'tiny_mce/tiny_mce.js'), new S('tmce_src'));
             self::manageJSS(new FilePath(FORM_TP_DIR . _S . JAVASCRIPT_DIR . _S . 'tiny_mce/tiny_mce_exec.js'), new S('tmce_exe'));
             // Set the proper CLASS;
             if (isset(self::$objDataContainer[self::$objDataCountInput][new S('class')])) {
                 self::$objDataContainer[self::$objDataCountInput][new S('class')] = self::$objDataContainer[self::$objDataCountInput][new S('class')] . _SP . 'RA_mceRichText';
             } else {
                 self::$objDataContainer[self::$objDataCountInput][new S('class')] = 'RA_mceRichText';
             }
             break;
         case 'ajax_form':
             if (isset(self::$objFormDataContainer[new S('class')])) {
                 self::$objFormDataContainer[new S('class')] = self::$objFormDataContainer[new S('class')] . _SP . 'RA_ajax_form';
             } else {
                 self::$objFormDataContainer[new S('class')] = 'RA_ajax_form';
             }
             break;
         default:
             self::$objDataToForm->toInt() == 1 ? self::$objDataContainer[self::$objDataCountInput][$objFormAttributeKey] = $objFormAttributeVar : (self::$objFormDataContainer[$objFormAttributeKey] = $objFormAttributeVar);
             break;
     }
     # Return to chain ...
     return TheFactoryMethodOfSingleton::getInstance(__CLASS__);
 }