예제 #1
0
 public function fieldcreateAction()
 {
     $conn = Common_Db_Doctrine::getConnection(Common_Config::get('common')->database->master->dsn);
     $field_table = 'field_data_' . $this->_params['typeid'];
     $table_column = 'field_' . $this->_params['field_name'];
     $_fc = new Common_Data_Field_Config();
     $conf = array('entity_type' => $this->_params['typeid'], 'field_name' => $this->_params['field_name']);
     $count = $_fc->getCount($conf);
     if ($count == 0) {
         $conf['field_type'] = $this->_params['field_type'];
         $conf['field_label'] = $this->_params['field_label'];
         $conf['storage_type'] = $field_table;
         $_fc->insert($conf);
     }
     try {
         if (!$conn->import->tableExists($field_table)) {
             $cols = array('entityid' => array('type' => 'string', 'length' => 36, 'primary' => true), "{$table_column}" => array('type' => 'string'));
             $sql = $conn->export->createTableSql($field_table, $cols);
             $_fc->getAdapter()->query($sql[0]);
         } else {
             $cols = $conn->import->listTableColumns($field_table);
             if (!isset($cols[$table_column])) {
                 $alter = array("add" => array("{$table_column}" => array('type' => 'string')));
                 $sql = $conn->export->alterTableSql($field_table, $alter);
                 $_fc->getAdapter()->query($sql);
             }
         }
     } catch (Exception $e) {
     } catch (PDOException $e) {
     }
     return $this->fieldsAction();
 }
예제 #2
0
 public function indexAction()
 {
     $type = $this->_request->getParam('type');
     $cfg = Common_Config::get("cm/{$type}.ini")->index->index;
     if (isset($cfg->session)) {
         $this->view->session = Common_Session::getInstance();
     }
     foreach ($cfg->datax as $k => $v) {
         $items = Cm_Model_Datax::getFeed($v->query);
         $block = APPLICATION_PATH . '/modules/cm/views/blocks/' . $v->block;
         $out = Cm_Model_Datax::getBlock($block, $items);
         $this->view->{'datax_' . $k} = $out;
     }
     $this->render('layout/simple', null, true);
 }