コード例 #1
0
ファイル: fieldgroups.php プロジェクト: kamilklkn/subrion
 protected function _entryUpdate(array $entryData, $entryId)
 {
     // first, check if administrator changed the title
     if (count($entryData) == 1 && isset($entryData['title'])) {
         if ($name = $this->_iaDb->one(array('name'), iaDb::convertIds($entryId))) {
             $phraseKey = 'fieldgroup_' . $name;
             return iaLanguage::addPhrase($phraseKey, iaSanitize::html($entryData['title']), null, '', iaLanguage::CATEGORY_COMMON, true);
         }
         return false;
     } else {
         return parent::_entryUpdate($entryData, $entryId);
     }
 }
コード例 #2
0
 protected function _update(array $entryData, $entryId)
 {
     return parent::_entryUpdate($entryData, $entryId);
 }
コード例 #3
0
ファイル: fields.php プロジェクト: kamilklkn/subrion
 private function _update(array $fieldData, $id)
 {
     $iaDb =& $this->_iaDb;
     $field = $iaDb->row(iaDb::ALL_COLUMNS_SELECTION, iaDb::convertIds($id));
     if (empty($field) || $field['type'] != $fieldData['type']) {
         return false;
     }
     // set correct relations
     if (iaField::RELATION_REGULAR == $fieldData['relation']) {
         $this->_resetRelations($field['name'], $field['item']);
     } else {
         if ($fieldData['parents']) {
             $this->_setParents($field['name'], $fieldData['parents']);
         }
         if ($fieldData['children']) {
             $this->_setChildren($field['name'], $field['item'], $fieldData['values'], $fieldData['children']);
         }
         $this->_setRelations();
     }
     unset($fieldData['parents'], $fieldData['children']);
     $iaDb->setTable(iaLanguage::getTable());
     $iaDb->delete("`key` LIKE 'field\\_" . $field['name'] . "\\_%'");
     foreach ($this->_iaCore->languages as $code => $language) {
         iaLanguage::addPhrase('field_' . $field['name'], $fieldData['title'][$code], $code, $field['extras']);
         if (isset($fieldData['annotation'][$code]) && $fieldData['annotation'][$code]) {
             iaLanguage::addPhrase('field_' . $field['name'] . '_annotation', $fieldData['annotation'][$code], $code, $field['extras']);
         }
     }
     unset($fieldData['title'], $fieldData['annotation']);
     $keys = array();
     if (isset($fieldData['values']) && is_array($fieldData['values'])) {
         $newKeys = array();
         foreach ($fieldData['values'] as $key => $value) {
             $key = $keys[$key] = isset($fieldData['keys'][$key]) ? $fieldData['keys'][$key] : $key;
             iaLanguage::addPhrase('field_' . $field['name'] . '_' . $key, $value, null, $field['extras']);
             $newKeys[] = $key;
         }
         $fieldData['values'] = implode(',', $newKeys);
     } elseif (iaField::TREE != $fieldData['type']) {
         unset($fieldData['values']);
     } elseif (iaField::TREE == $fieldData['type']) {
         $iaDb->setTable('fields_tree_nodes');
         $iaDb->delete('`field` = :name && `item` = :item', null, array('name' => $field['name'], 'item' => $field['item']));
         if ($fieldData['tree_nodes']) {
             foreach ($fieldData['tree_nodes'] as $node) {
                 // insert default language
                 iaLanguage::addPhrase('field_' . $field['item'] . '_' . $field['name'] . '_' . $node['node_id'], $node['text'], $this->_iaCore->iaView->language, $field['extras']);
                 unset($node['text']);
                 $node['field'] = $field['name'];
                 $node['item'] = $field['item'];
                 $node['extras'] = $field['extras'];
                 $iaDb->insert($node);
             }
         }
         $iaDb->resetTable();
         unset($fieldData['tree_nodes']);
     }
     unset($fieldData['keys']);
     if (isset($fieldData['lang_values']) && is_array($fieldData['lang_values'])) {
         foreach ($fieldData['lang_values'] as $languageCode => $phrases) {
             foreach ($phrases as $phraseKey => $phraseValue) {
                 iaLanguage::addPhrase('field_' . $field['name'] . '_' . $phraseKey, $phraseValue, $languageCode, $field['extras']);
             }
         }
     }
     if (isset($fieldData['lang_values'])) {
         unset($fieldData['lang_values']);
     }
     if ($fieldData['searchable'] && $fieldData['type'] == iaField::NUMBER && isset($fieldData['_numberRangeForSearch']) && is_array($fieldData['_numberRangeForSearch']) && !empty($fieldData['_numberRangeForSearch'])) {
         $iaDb->delete("`key` LIKE 'field\\_" . $field['name'] . "\\_range\\_%'");
         foreach ($fieldData['_numberRangeForSearch'] as $value) {
             iaLanguage::addPhrase('field_' . $field['name'] . '_range_' . $value, $value, null, $field['extras']);
         }
         unset($fieldData['_numberRangeForSearch']);
     } else {
         $iaDb->delete("`key` LIKE 'field\\_" . $field['name'] . "\\_range\\_%'");
     }
     $iaDb->resetTable();
     $tableName = $this->_iaCore->factory('item')->getItemTable($fieldData['item']);
     // avoid making fulltext second time
     if (!$field['searchable'] && $fieldData['searchable'] && in_array($fieldData['type'], array(iaField::TEXT, iaField::TEXTAREA))) {
         $indexes = $iaDb->getAll("SHOW INDEX FROM `{$iaDb->prefix}{$tableName}`");
         $keyExists = false;
         foreach ($indexes as $i) {
             if ($i['Key_name'] == $field['name'] && $i['Index_type'] == 'FULLTEXT') {
                 $keyExists = true;
                 break;
             }
         }
         if (!$keyExists) {
             $iaDb->query("ALTER TABLE `{$iaDb->prefix}{$tableName}` ADD FULLTEXT (`{$field['name']}`)");
         }
     }
     if ($field['searchable'] && !$fieldData['searchable'] && in_array($fieldData['type'], array(iaField::TEXT, iaField::TEXTAREA))) {
         $indexes = $iaDb->getAll("SHOW INDEX FROM `{$iaDb->prefix}{$tableName}`");
         $keyExists = false;
         foreach ($indexes as $i) {
             if ($i['Key_name'] == $field['name'] && $i['Index_type'] == 'FULLTEXT') {
                 $keyExists = true;
                 break;
             }
         }
         if ($keyExists) {
             $iaDb->query("ALTER TABLE `{$iaDb->prefix}{$tableName}` DROP INDEX `{$field['name']}`");
         }
     }
     $pagesList = $fieldData['pages'];
     unset($fieldData['pages'], $fieldData['groups'], $fieldData['item']);
     $result = parent::_entryUpdate($fieldData, $id);
     if ($pagesList) {
         $this->_setPagesList($id, $pagesList, $field['extras']);
     }
     if ($result) {
         if (in_array($fieldData['type'], array(iaField::TEXT, iaField::COMBO, iaField::RADIO, iaField::CHECKBOX))) {
             $sql = "ALTER TABLE `{$this->_iaDb->prefix}{$tableName}` ";
             $sql .= "CHANGE `{$field['name']}` `{$field['name']}` ";
             switch ($fieldData['type']) {
                 case iaField::TEXT:
                     $sql .= "VARCHAR ({$fieldData['length']}) ";
                     $sql .= $fieldData['default'] ? "DEFAULT '{$fieldData['default']}' " : '';
                     break;
                 default:
                     if (isset($fieldData['values'])) {
                         $values = explode(',', $fieldData['values']);
                         $sql .= $fieldData['type'] == iaField::CHECKBOX ? 'SET' : 'ENUM';
                         $sql .= "('" . implode("','", $values) . "')";
                         if (!empty($fieldData['default'])) {
                             $sql .= " DEFAULT '{$fieldData['default']}' ";
                         }
                     }
                     break;
             }
             $sql .= 'NOT NULL';
             $iaDb->query($sql);
         }
     }
     return $result;
 }
コード例 #4
0
ファイル: pages.php プロジェクト: bohmszi/kdbe_cms
 protected function _entryUpdate(array $entryData, $entryId)
 {
     $currentData = $this->getById($entryId);
     $entryData['last_updated'] = date(iaDb::DATETIME_FORMAT);
     $result = parent::_entryUpdate($entryData, $entryId);
     if ($result) {
         if (!empty($currentData['alias']) && $entryData['alias'] && $currentData['alias'] != $entryData['alias']) {
             $this->_massUpdateAlias($currentData['alias'], $entryData['alias'], $this->getEntryId());
         }
     }
     return $result;
 }