Example #1
0
 /**
  * function __construct
  * <pre>
  * Initialize the Class ...
  * </pre>
  * @param $module_id [INTEGER] value used to initialize the list.
  * @param $sortBy [STRING] the field name to sort list by
  * @return [void]
  */
 function __construct($module_id = -1, $sortBy = '')
 {
     $searchManager = new RowManager_StateVarManager();
     // NOTE: if you need to narrow the field of the search then uncommnet
     // the following and set the proper search criteria.
     $searchManager->setValueByFieldName("module_id", $module_id);
     //$searchManager->setValueByFieldName('module_isCommonLook', '1' );
     $searchManager->setSortOrder($sortBy);
     $this->resultSet = $searchManager->find();
 }
 /**
  * function createTableManagerObject
  * <pre>
  * Creates a new Table Manager Object for the given daObj Object. This 
  * function returns the name of the file it creates.
  * </pre>
  * @param $daObj [OBJECT] Current Data Access Object.
  * @param $fieldList [STRING] list of fields in this da object
  * @param $primaryKeyFieldName [STRING] name of the field that is the primary key.
  * @param $labelFieldName [STRING] name of the field used for labels
  * @param $dbTableDescriptionDoc [STRING] the documentation for the db fields
  * @param $dbTableDescriptionSQL [STRING] SQL code to create the db table
  * @return [STRING]
  */
 function createTableManagerObject($daObj, $fieldList, $primaryKeyFieldName, $labelFieldName, $dbTableDescriptionDoc, $dbTableDescriptionSQL)
 {
     // get path/Name of template
     $pathToDATemplate = $this->values[ModuleCreator::KEY_PATH_RAD_ROOT];
     $pathToDATemplate .= 'data/' . ModuleCreator::PATH_OBJECT_DA;
     $fileName = $pathToDATemplate . ModuleCreator::FILE_DA_ROWMANAGER;
     $fileContents = file_get_contents($fileName);
     // update sections:
     // Module Name
     // Creator Name
     $fileContents = $this->replaceCommonTags($fileContents);
     // DAObj Name
     $tag = ModuleCreator::TAG_DAOBJ_NAME;
     $data = $daObj->getManagerName();
     $fileContents = str_replace($tag, $data, $fileContents);
     // DAObj Desc
     $tag = ModuleCreator::TAG_DAOBJ_DESC;
     $data = $daObj->getDescription();
     $fileContents = str_replace($tag, $data, $fileContents);
     // DB Table Name
     $tag = ModuleCreator::TAG_DAOBJ_DBTABLE;
     $data = $daObj->getDBTableName();
     $fileContents = str_replace($tag, $data, $fileContents);
     // DB Table Field Documentation
     $tag = ModuleCreator::TAG_DAOBJ_DBTABLE_DOC;
     $data = $dbTableDescriptionDoc;
     $fileContents = str_replace($tag, $data, $fileContents);
     // DB Table SQL code
     $tag = ModuleCreator::TAG_DAOBJ_DBTABLE_SQL;
     $data = $dbTableDescriptionSQL;
     $fileContents = str_replace($tag, $data, $fileContents);
     // Field List
     $tag = ModuleCreator::TAG_DAOBJ_DBFIELDLIST;
     $data = $fieldList;
     $fileContents = str_replace($tag, $data, $fileContents);
     // XML_NODE_NAME
     $tag = ModuleCreator::TAG_DAOBJ_XMLNODENAME;
     $data = strtolower($daObj->getName());
     $fileContents = str_replace($tag, $data, $fileContents);
     // State Variable Information
     $stateVarID = $daObj->getManagerInitVarID();
     $stateVar = new RowManager_StateVarManager($stateVarID);
     if ($stateVar->isLoaded()) {
         $data = $stateVar->getName();
     } else {
         $data = 'initValue';
     }
     $tag = ModuleCreator::TAG_DAOBJ_STATEVAR;
     $fileContents = str_replace($tag, $data, $fileContents);
     // DAOBJ Primary Key Field Name
     $tag = ModuleCreator::TAG_DAOBJ_PRIMARYKEY;
     $data = $primaryKeyFieldName;
     $fileContents = str_replace($tag, $data, $fileContents);
     // Insert return value for getLabel() function
     // if a labelFieldName was given
     if ($labelFieldName != '') {
         // return function result
         $data = $labelFieldName;
     } else {
         // else
         // return error message
         $data = 'No Field Label Marked';
     }
     // endif
     $tag = ModuleCreator::TAG_DAOBJ_GETLABEL;
     $fileContents = str_replace($tag, $data, $fileContents);
     // save new file
     $modulePath = $this->values[ModuleCreator::KEY_PATH_MODULE_ROOT];
     $modulePath .= ModuleCreator::PATH_OBJECT_DA;
     $name = $daObj->getManagerName() . '.php';
     $fileName = $modulePath . $name;
     file_put_contents($fileName, $fileContents);
     return $name;
 }