public function __toString() { $this->_convertListeners(); $combo = Ext_Factory::object('Form_Field_Combobox'); $combo->setName($this->getName()); Ext_Factory::copyProperties($this, $combo); if ($this->isValidProperty('dictionary') && strlen($this->dictionary)) { $dM = new Dictionary_Manager(); if ($dM->isValidDictionary($this->dictionary)) { $allowBlank = false; if ($this->_config->allowBlank && !$this->_config->showAll) { $allowBlank = true; } if ($this->_config->isValidProperty('showAll') && !empty($this->_config->showAllText)) { $allText = $this->_config->showAllText; } else { $allText = false; } $data = Dictionary::getInstance($this->dictionary)->__toJs($this->_config->showAll, $allowBlank, $allText); if (strlen($data)) { $combo->store = 'Ext.create("Ext.data.Store",{ model:"app.comboStringModel", data: ' . $data . ' })'; } } } return $combo->getConfig()->__toString(); }
public function listAction() { $data = $this->_tManager->getList(); if (!empty($data)) { $dict = Dictionary::getInstance('task'); foreach ($data as $k => &$v) { $v['status_code'] = $v['status']; if ($dict->isValidKey($v['status'])) { $v['status'] = $dict->getValue($v['status']); } $finish = strtotime($v['time_finished']); if ($finish <= 0) { $finish = time(); } $v['runtime'] = Utils::formatTime($finish - strtotime($v['time_started'])); $v['memory'] = Utils::formatFileSize($v['memory']); $v['memory_peak'] = Utils::formatFileSize($v['memory_peak']); if ($v['op_total'] == 0) { $v['progress'] = 0; } else { $v['progress'] = number_format($v['op_finished'] / $v['op_total'], 2) * 100; } } unset($v); } Response::jsonSuccess($data); }
/** * (non-PHPdoc) * @see Backend_Controller_Crud::indexAction() */ public function indexAction() { $this->_resource->addInlineJs(' var canEdit = ' . $this->_user->canEdit($this->_module) . '; var canDelete = ' . $this->_user->canDelete($this->_module) . '; var menuItemlinkTypes = ' . Dictionary::getInstance('link_type')->__toJs() . '; '); $modulesConfig = Config::factory(Config::File_Array, $this->_configMain->get('backend_modules')); Model::factory('Medialib')->includeScripts(); $this->_resource->addJs('/js/lib/ext_ux/SearchField.js', 0); $this->_resource->addJs('/js/app/system/SearchPanel.js', 0); $this->_resource->addJs('/js/app/system/HistoryPanel.js', 0); $this->_resource->addJs('/js/app/system/EditWindow.js', 0); $this->_resource->addJs('/js/app/system/crud/' . strtolower($this->_module) . '.js', 4); }
/** * Get data hash (all dictionaries data) * Enter description here ... */ public function getDataHash() { if ($this->_cache && ($hash = $this->_cache->load(self::CACHE_KEY_DATA_HASH))) { return $hash; } $s = ''; $list = $this->getList(); if (!empty($list)) { foreach ($list as $name) { $s .= $name . ':' . Dictionary::getInstance($name)->__toJs(); } } $s = md5($s); if ($this->_cache) { $this->_cache->save($s, self::CACHE_KEY_DATA_HASH); } return $s; }
public function __construct() { $this->_dictionaryData = Dictionary::getInstance($this->_name)->getData(); }
/** * Set the object field val * @param string $name * @param mixed $value * @return bool * @throws Exception */ public function set($name, $value) { if ($this->_acl) { $this->_checkCanEdit(); } $propConf = $this->_config->getFieldConfig($name); $validator = $this->getConfig()->getValidator($name); if ($validator && !call_user_func_array(array($validator, 'validate'), array($value))) { throw new Exception('Invalid value for field ' . $name); } /* * Validate value by fields type in config */ if ($this->_config->isMultiLink($name)) { if (is_array($value) && !empty($value[0])) { if (!$this->_validateLink($name, $value)) { throw new Exception('Invalid property value'); } $value = $this->_collectLinksData($name, $value); } else { $value = ''; } } elseif ($this->_config->isDictionaryLink($name)) { if ($this->_config->isRequired($name) && !strlen($value)) { throw new Exception('Field ' . $name . ' cannot be empty'); } if (strlen($value)) { $fieldConfig = $this->_config->getFieldConfig($name); $dictionary = Dictionary::getInstance($fieldConfig['link_config']['object']); if (!$dictionary->isValidKey($value)) { throw new Exception('Invalid dictionary value [' . $name . ']'); } } } elseif ($this->_config->isLink($name)) { if (is_object($value)) { if ($value instanceof Db_Object) { if ($this->_config->isObjectLink($name)) { if (!$value->isInstanceOf($this->getLinkedObject($name))) { throw new Exception('Invalid value type for field ' . $name . ' expects ' . $this->getLinkedObject($name) . ', ' . $value->getName() . ' passed'); } } $value = $value->getId(); } else { $value = $value->__toString(); } } if (is_array($value)) { throw new Exception('Invalid value for field ' . $name); } if ($this->_config->isRequired($name) && !strlen($value)) { throw new Exception('Field ' . $name . ' cannot be empty'); } $value = intval($value); if ($value != 0 && !$this->_validateLink($name, $value)) { throw new Exception('Invalid value for field ' . $name); } if ($value == 0) { $value = null; } } elseif ($this->_config->isBoolean($name)) { $value = intval((bool) $value); } elseif (is_null($value) && $this->_config->isNull($name)) { $value = null; } else { $value = Db_Object_Property::filter($propConf, $value); } if (isset($propConf['db_len']) && $propConf['db_len']) { if (mb_strlen($value, 'UTF-8') > $propConf['db_len']) { throw new Exception('The field value exceeds the allowable length [' . $name . ']'); } if ($propConf['db_type'] == 'bit' && (strlen($value) > $propConf['db_len'] || strlen($value) < $propConf['db_len'])) { throw new Exception('Invalid length for bit value [' . $name . ']'); } } if (isset($this->_data[$name]) && $this->_data[$name] === $value) { if (isset($this->_updates[$name])) { unset($this->_updates[$name]); } return true; } $this->_updates[$name] = $value; return true; }
/** * Get list of Query conditions */ public function conditionslistAction() { $this->_checkLoaded(); $query = $this->_session->get('query'); $result = array(); $conditions = $query->getConditions(); if (!empty($conditions)) { $dict = Dictionary::getInstance('sqloperator'); foreach ($conditions as $id => $object) { $tmp = get_object_vars($object); if ($dict->isValidKey($tmp['operator'])) { $tmp['operator'] = $dict->getValue($tmp['operator']); } $tmp['id'] = $id; $result[] = $tmp; } } Response::jsonSuccess($result); }
public function listAction() { $object = Request::post('object', 'string', false); $query = Request::post('search', 'string', false); $params = Request::post('pager', 'array', array()); if (!$object || !Db_Object_Config::configExists($object)) { Response::jsonError($this->_lang->WRONG_REQUEST); } $cfg = Db_Object_Config::getInstance($object); $fieldsCfg = $cfg->getFieldsConfig(true); $fields = array(); $dictionaries = array(); $objectLinks = $cfg->getLinks(array(Db_Object_Config::LINK_OBJECT)); $multylinks = $cfg->getLinks(array(Db_Object_Config::LINK_OBJECT_LIST)); foreach ($fieldsCfg as $name => $fCfg) { if ($cfg->isDictionaryLink($name)) { $dictionaries[$name] = $cfg->getLinkedDictionary($name); } if ($cfg->isText($name) && !$cfg->isLink($name)) { $fields[$name] = '"[ text ]"'; } else { $fields[] = $name; } } $model = Model::factory($object); $count = $model->getCount(false, $query, false); $data = array(); if ($count) { $data = $model->getList($params, false, $fields, false, $query); if (!empty($objectLinks)) { $objectIds = array(); foreach ($data as $row) { foreach ($objectLinks as $obj => $fields) { if (!isset($objectIds[$obj])) { $objectIds[$obj] = array(); } foreach ($fields as $fName => $lType) { $objectIds[$obj][] = $row[$fName]; } } } foreach ($objectIds as $oName => &$idsList) { if (empty($idsList)) { continue; } array_unique($idsList); $oCfg = Db_Object_Config::getInstance($oName); $linkedObjects = Db_Object::factory($oName, $idsList); $titleList = array(); if (!empty($linkedObjects)) { foreach ($linkedObjects as $id => $item) { $titleList[$id] = array('id' => $id, 'title' => $item->getTitle()); } } $idsList = $titleList; } } if (!empty($dictionaries) || !empty($objectLinks) || !empty($multylinks)) { foreach ($data as &$row) { if (!empty($dictionaries)) { foreach ($dictionaries as $col => $dictName) { $dictionary = Dictionary::getInstance($dictName); if ($dictionary->isValidKey($row[$col])) { $row[$col] = '[' . $row[$col] . '] ' . $dictionary->getValue($row[$col]); } else { $row[$col] = '[' . $row[$col] . ']'; } } } if (!empty($objectLinks)) { foreach ($objectLinks as $object => $fields) { foreach ($fields as $name => $type) { if (isset($objectIds[$object][$row[$name]])) { $row[$name] = '[' . $objectIds[$object][$row[$name]]['id'] . '] ' . $objectIds[$object][$row[$name]]['title']; } } } } if (!empty($multylinks)) { foreach ($multylinks as $obj => $fCfg) { foreach ($fCfg as $name => $type) { $list = array(); $rec = $row[$name]; if (strlen($rec)) { $rec = @unserialize($rec); if (!empty($rec)) { foreach ($rec as $item) { $list[] = '[' . $item['id'] . '] ' . $item['title']; } } } $row[$name] = implode(', ', $list); } } } } } } Response::jsonSuccess($data, array('count' => $count)); }
/** * Remove dictionary record */ public function removerecordsAction() { $dictionaryName = strtolower(Request::post('dictionary', 'string', false)); $name = Request::post('name', 'string', false); if (!strlen($name) || !strlen($dictionaryName)) { Response::jsonError($this->_lang->WRONG_REQUEST); } $dictionary = Dictionary::getInstance($dictionaryName); $dictionary->removeRecord($name); if (!$dictionary->saveChanges()) { Response::jsonError($this->_lang->CANT_WRITE_FS); } Response::jsonSuccess(); }
/** * Apply where conditions * @param Db_Select | Zend_Db_Select $sql */ protected function _applyConditions($sql) { $conditions = $this->getConditions(); if (empty($conditions)) { return; } $dictionary = Dictionary::getInstance('sqloperator'); foreach ($conditions as $condition) { if (!$dictionary->isValidKey($condition->operator)) { continue; } $operator = $dictionary->getValue($condition->operator); switch ($condition->operator) { case 'IS_NULL': case 'IS_NOT_NULL': $table = Db_Object_Config::getInstance($condition->object)->getTable(); $sql->where($table . '.' . $condition->field . ' ' . $operator); break; case 'BETWEEN': case 'NOT_BETWEEN': $table = Db_Object_Config::getInstance($condition->object)->getTable(); $sql->where($table . '.' . $condition->field . ' ' . $operator . ' \'' . addslashes($condition->value) . '\' AND \'' . addslashes($condition->value2) . '\' '); break; case 'IN': case 'NOT_IN': $table = Db_Object_Config::getInstance($condition->object)->getTable(); $sql->where($table . '.' . $condition->field . ' ' . $operator . ' (?)', explode(',', $condition->{$value})); break; case 'custom': $sql->where($condition->value); break; default: $table = Db_Object_Config::getInstance($condition->object)->getTable(); $sql->where($table . '.' . $condition->field . ' ' . $operator . ' ?', $condition->value); } } }
/** * Get interface config */ public function configAction() { $versionsList = array_keys($this->docConfig->get('versions')); $preparedVersions = array(); foreach ($versionsList as $k => $v) { $preparedVersions[] = array('id' => $v, 'title' => $v); } $langs = Dictionary::getInstance('sysdocs_language')->getData(); $langData = array(); foreach ($langs as $k => $v) { $langData[] = array('id' => $k, 'title' => $v); } $result = array('version' => $this->version, 'language' => $this->language, 'languages' => $langData, 'versions' => $preparedVersions); Response::jsonSuccess($result); }
public function migrateLocale() { $langDictionary = Dictionary::getInstance('sysdocs_language'); $langs = $langDictionary->getData(); $fields = $this->config->get('fields'); foreach ($langs as $k => $v) { foreach ($fields as $class => $cfg) { $t = microtime(true); $this->output('Migrate localization...' . $class . ' ' . $k); $this->migrateRecords($class, $this->vers, $k, $cfg); $this->output('OK ' . number_format(microtime(true) - $t, 3) . 's.'); } } }