Beispiel #1
0
 function DisplayForm(App_Form $form, $uiName = "default")
 {
     $this->_uiName = $uiName;
     $this->_form_id = $form->getFormId();
     $this->_form = $form;
     $this->_model = $form->getModel();
     //  ->getModelName();
     $this->_modelName = $this->_model->getModelName();
     $this->_config = App_Model_Config::get($this->_modelName);
     return $this->render();
 }
Beispiel #2
0
 protected function getContentModel()
 {
     App_Log::get()->debug($this, 'begin getContentModel');
     $modelName = $this->_model->getModelName();
     $modelName .= "_Content";
     if (class_exists($modelName)) {
         $content = new $modelName();
         App_Log::get()->debug($this, 'return  ContentModel');
         return $content;
     } else {
         App_Log::get()->debug($this, 'return  false');
         return false;
     }
 }
 function displayModelInfoBasic(App_Model_Abstract $model = null)
 {
     $this->_modelName = $model->getModelName();
     $this->_model = $model;
     $this->_config = App_Model_Config::get($this->_modelName);
     return $this->render();
 }
Beispiel #4
0
 /**
  * Find a guestbook entry by id
  *
  * @param  int $id
  * @return void
  */
 public function find($id, App_Model_Abstract &$model)
 {
     try {
         $modelName = $model->getModelName();
         if (CACHE_DB_ENABLED) {
             $cache_dir = PRIVATE_PATH . '/data/cache/' . $model->getModelName();
             @mkdir($cache_dir, 0777, true);
             $backendOptions = array('cache_dir' => $cache_dir);
             $frontendOptions = array('lifetime' => 7200, 'automatic_serialization' => true);
             $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
         }
         $config = $this->getModelConfig();
         $pk = 'id';
         foreach ($config->prop as $prop) {
             //หา PK
             if ($prop->pk) {
                 $pk = $prop->column;
                 break;
             }
         }
         App_Log::get()->debug($this, "BEGIN find");
         $row = false;
         $cacheId = $model->getModelName() . "_" . $id;
         if (CACHE_DB_ENABLED) {
             $row = $cache->load($cacheId);
         }
         if ($row === false) {
             if (isset($config->config->sql)) {
                 $sql = $config->config->sql;
                 $sqlselect = " SELECT * FROM ( {$sql} )  tttt  WHERE {$pk} LIKE ? ";
                 $db = App_Env::getDb();
                 $row = $result = $db->fetchRow($sqlselect, array($id));
             } else {
                 $result = $this->getDbTable()->find($id);
                 $row = $result->current();
             }
             App_Log::get()->debug($this, "result");
             if (0 == count($result)) {
                 App_Log::get()->debug($this, "count result = 0");
                 return false;
             }
             App_Log::get()->debug($this, "count result > 0");
             if (CACHE_DB_ENABLED) {
                 $cache->save($row, $cacheId);
             }
         }
         $model = $this->bindEntry($model, $row);
         App_Log::get()->debug($this, "end for each");
         return true;
     } catch (Exception $e) {
         App_Log::get()->debug($this, "Exception" . $e->getMessage());
         //echo $e->getMessage ();
     }
 }