/** * Create new version * @property Db_Object $object * @return boolean */ public function newVersion(Db_Object $object) { $object->commitChanges(); $newVersion = $this->getLastVersion($object->getName(), $object->getId()) + 1; $newData = $object->getData(); if ($object->getConfig()->hasEncrypted()) { $ivField = $object->getConfig()->getIvField(); $ivKey = $object->get($ivField); if (empty($ivKey)) { $ivKey = Utils_String::createEncryptIv(); $newData[$ivField] = $ivKey; } $newData = $this->getStore()->encryptData($object, $newData); } $newData['id'] = $object->getId(); try { $vObject = new Db_Object('vc'); $vObject->set('date', date('Y-m-d')); $vObject->set('data', base64_encode(serialize($newData))); $vObject->set('user_id', User::getInstance()->id); $vObject->set('version', $newVersion); $vObject->set('record_id', $object->getId()); $vObject->set('object_name', $object->getName()); $vObject->set('date', date('Y-m-d H:i:s')); if ($vObject->save()) { return $newVersion; } return false; } catch (Exception $e) { $this->logError('Cannot create new version for ' . $object->getName() . '::' . $object->getId() . ' ' . $e->getMessage()); return false; } }
public function __toString() { $this->_config->setXType(''); $this->_config->setFType('filters'); $this->_config->filters = "[\n\t" . Utils_String::addIndent(implode(",\n", array_values($this->_filters)), 2) . "\n]"; return parent::__toString(); }
/** * (non-PHPdoc) * @see Db_Object_Event_Manager::fireEvent() */ public function fireEvent($code, Db_Object $object) { $objectName = ucfirst($object->getName()); $triggerClass = Utils_String::classFromString('Trigger_' . $objectName); if (class_exists($triggerClass) && method_exists($triggerClass, $code)) { $trigger = new $triggerClass(); if ($this->_cache) { $trigger->setCache($this->_cache); } $trigger->{$code}($object); } elseif (method_exists('Trigger', $code)) { $trigger = new Trigger(); if ($this->_cache) { $trigger->setCache($this->_cache); } $trigger->{$code}($object); } }
/** * Route request to the Controller * @return void */ public function route() { $cfg = Registry::get('backend', 'config'); $controller = $this->_request->getPart(1); $controller = Utils_String::formatClassName(Filter::filterValue('pagecode', $controller)); if (in_array('Backend_' . $controller . '_Controller', $cfg->get('system_controllers'))) { $controller = 'Backend_' . $controller . '_Controller'; } else { $manager = new Backend_Modules_Manager(); $controller = $manager->getModuleController($controller); if ($controller === false) { if (Request::isAjax()) { Response::jsonError(Lang::lang()->get('WRONG_REQUEST') . ' ' . Request::getInstance()->getUri()); } $controller = 'Backend_Index_Controller'; } } $this->runController($controller, $this->_request->getPart(2)); }
/** * Create new module */ public function createAction() { $this->_checkCanEdit(); $object = Request::post('object', 'string', false); if (!$object) { Response::jsonError($this->_lang->WRONG_REQUEST); } $object = Utils_String::formatClassName($object); $class = 'Backend_' . $object . '_Controller'; if (class_exists($class)) { Response::jsonError($this->_lang->FILL_FORM, array('id' => 'name', 'msg' => $this->_lang->SB_UNIQUE)); } $designerConfig = Config::factory(Config::File_Array, $this->_configMain['configs'] . 'designer.php'); $projectFile = $designerConfig->get('configs') . strtolower($object) . '.designer.dat'; if (file_exists($projectFile)) { Response::jsonError($this->_lang->FILE_EXISTS . '(' . $projectFile . ')'); } $actionFile = $designerConfig->get('actionjs_path') . strtolower($object) . '.js'; if (file_exists($actionFile)) { Response::jsonError($this->_lang->FILE_EXISTS . '(' . $actionFile . ')'); } $objectConfig = Db_Object_Config::getInstance($object); // Check ACL permissions $acl = $objectConfig->getAcl(); if ($acl) { if (!$acl->can(Db_Object_Acl::ACCESS_CREATE, $object) || !$acl->can(Db_Object_Acl::ACCESS_VIEW, $object)) { Response::jsonError($this->_lang->get('ACL_ACCESS_DENIED')); } } $manager = new Db_Object_Manager(); if (!$manager->objectExists($object)) { Response::jsonError($this->_lang->FILL_FORM, array('id' => 'object', 'msg' => $this->_lang->INVALID_VALUE)); } $codeGenadApter = $this->_configBackend->get('modules_codegen'); $codeGen = new $codeGenadApter(); try { if ($objectConfig->isRevControl()) { $codeGen->createVcModule($object, $projectFile, $actionFile); } else { $codeGen->createModule($object, $projectFile, $actionFile); } } catch (Exception $e) { Response::jsonError($e->getMessage()); } $userInfo = User::getInstance()->getInfo(); $per = Model::factory('Permissions'); if (!$per->setGroupPermissions($userInfo['group_id'], $object, 1, 1, 1, 1)) { Response::jsonError($this->_lang->CANT_EXEC); } Response::jsonSuccess(array('class' => $class, 'name' => $object, 'active' => true, 'dev' => false, 'title' => $objectConfig->getTitle(), 'designer' => $projectFile)); }
public function __toString() { $this->_convertFields(); $this->_convertListeners(); $fields = array(); if (!empty($this->_fields)) { $this->fields = "[\n" . Utils_String::addIndent(implode(',', array_values($this->_fields))) . "\n]"; } if ($this->_config->isValidProperty('model') && strlen($this->_config->model)) { $model = Ext_Code::appendNamespace($this->_config->model); $this->_config->model = $model; } return $this->_config->__toString(); }
protected function _localEventsString() { $code = ''; if (isset($this->_localEvents) && !empty($this->_localEvents)) { $items = array(); foreach ($this->_localEvents as $name => $description) { $items[] = $description['jsDoc'] . "\n" . '"' . $name . '"'; } $code = "\n" . Utils_String::addIndent('this.addEvents(' . "\n" . Utils_String::addIndent(implode(",\n", $items)) . "\n);", 2) . "\n"; } return $code; }
public function createModule($object, $projectFile, $actionFile) { $lang = Lang::lang(); //prepare class name $name = Utils_String::formatClassName($object); $jsName = str_replace('_', '', $name); $runNamespace = 'app' . $jsName . 'Run'; $classNamespace = 'app' . $jsName . 'Classes'; $objectConfig = Db_Object_Config::getInstance($object); $primaryKey = $objectConfig->getPrimaryKey(); $appConfig = Registry::get('main', 'config'); $designerConfig = Config::factory(Config::File_Array, $appConfig->get('configs') . 'designer.php'); $objectFieldsConfig = $objectConfig->getFieldsConfig(false); $objectFields = array(); $searchFields = array(); $linkedObjects = array(); /* * Skip text fields */ foreach ($objectFieldsConfig as $key => $item) { if ($objectConfig->isObjectLink($key) || $objectConfig->isMultiLink($key)) { $linkedObjects[] = $objectConfig->getLinkedObject($key); } if (in_array($item['db_type'], Db_Object_Builder::$textTypes, true)) { continue; } $objectFields[] = $key; if (isset($item['is_search']) && $item['is_search']) { $searchFields[] = $key; } } $dataFields = array(); foreach ($objectConfig->getFieldsConfig(true) as $key => $item) { if (in_array($item['db_type'], Db_Object_Builder::$textTypes, true)) { continue; } $dataFields[] = $key; } array_unshift($objectFields, $primaryKey); $controllerContent = '<?php ' . "\n" . 'class Backend_' . $name . '_Controller extends Backend_Controller_Crud{' . "\n" . ' protected $_listFields = array("' . implode('","', $dataFields) . '");' . "\n" . ' protected $_canViewObjects = array("' . implode('","', $linkedObjects) . '");' . "\n" . '} '; /* * Create controller */ $controllerDir = $appConfig->get('backend_controllers') . str_replace('_', '/', $name); $this->_createControllerFile($controllerDir, $controllerContent); @chmod($controllerDir . DIRECTORY_SEPARATOR . 'Controller.php', $controllerContent, 0775); /* * Designer project */ $project = new Designer_Project(); $project->namespace = $classNamespace; $project->runnamespace = $runNamespace; /* * Project events */ $eventManager = $project->getEventManager(); $storeFields = Backend_Designer_Import::checkImportORMFields($object, $dataFields); $urlTemplates = $designerConfig->get('templates'); Request::setDelimiter($urlTemplates['urldelimiter']); $controllerUrl = Request::url(array($urlTemplates['adminpath'], $object, ''), false); $storeUrl = Request::url(array($urlTemplates['adminpath'], $object, 'list')); Request::setDelimiter($appConfig->get('urlDelimiter')); $dataStore = Ext_Factory::object('Data_Store'); $dataStore->setName('dataStore'); $dataStore->autoLoad = true; $dataStore->addFields($storeFields); $dataProxy = Ext_Factory::object('Data_Proxy_Ajax'); $dataProxy->type = 'ajax'; $dataReader = Ext_Factory::object('Data_Reader_Json'); $dataReader->root = 'data'; $dataReader->totalProperty = 'count'; $dataReader->idProperty = $primaryKey; $dataReader->type = 'json'; $dataProxy->reader = $dataReader; $dataProxy->url = $storeUrl; $dataProxy->startParam = 'pager[start]'; $dataProxy->limitParam = 'pager[limit]'; $dataProxy->sortParam = 'pager[sort]'; $dataProxy->directionParam = 'pager[dir]'; $dataProxy->simpleSortMode = true; $dataStore->proxy = $dataProxy; $dataStore->remoteSort = true; $project->addObject(0, $dataStore); /* * Data grid */ $dataGrid = Ext_Factory::object('Grid'); $dataGrid->setName('dataGrid'); $dataGrid->store = 'dataStore'; $dataGrid->columnLines = true; $dataGrid->title = $objectConfig->getTitle() . ' :: ' . $lang->HOME; $dataGrid->setAdvancedProperty('paging', true); $dataGrid->viewConfig = '{enableTextSelection: true}'; $eventManager->setEvent('dataGrid', 'itemdblclick', 'show' . $jsName . 'EditWindow(record.get("id"));'); $objectFieldList = Backend_Designer_Import::checkImportORMFields($object, $objectFields); if (!empty($objectFieldList)) { foreach ($objectFieldList as $fieldConfig) { switch ($fieldConfig->type) { case 'boolean': $column = Ext_Factory::object('Grid_Column_Boolean'); $column->renderer = 'Ext_Component_Renderer_System_Checkbox'; $column->width = 50; $column->align = 'center'; break; case 'integer': $column = Ext_Factory::object('Grid_Column'); break; case 'float': $column = Ext_Factory::object('Grid_Column_Number'); if (isset($objectFieldsConfig[$fieldConfig->name]['db_precision'])) { $column->format = '0,000.' . str_repeat('0', $objectFieldsConfig[$fieldConfig->name]['db_precision']); } break; case 'date': $column = Ext_Factory::object('Grid_Column_Date'); if ($objectFieldsConfig[$fieldConfig->name]['db_type'] == 'time') { $column->format = 'H:i:s'; } break; default: $column = Ext_Factory::object('Grid_Column'); } if ($objectConfig->fieldExists($fieldConfig->name)) { $cfg = $objectConfig->getFieldConfig($fieldConfig->name); $column->text = $cfg['title']; } else { $column->text = $fieldConfig->name; } $column->dataIndex = $fieldConfig->name; $column->setName($fieldConfig->name); $column->itemId = $column->getName(); $dataGrid->addColumn($column->getName(), $column, $parent = 0); } } $project->addObject(0, $dataGrid); /* * Top toolbar */ $dockObject = Ext_Factory::object('Docked'); $dockObject->setName($dataGrid->getName() . '__docked'); $project->addObject($dataGrid->getName(), $dockObject); $filters = Ext_Factory::object('Toolbar'); $filters->setName('filters'); $project->addObject($dockObject->getName(), $filters); /* * Top toolbar items */ $addButton = Ext_Factory::object('Button'); $addButton->setName('addButton'); $addButton->text = $lang->ADD_ITEM; $eventManager->setEvent('addButton', 'click', 'show' . $jsName . 'EditWindow(false);'); $project->addObject($filters->getName(), $addButton); $sep1 = Ext_Factory::object('Toolbar_Separator'); $sep1->setName('sep1'); $project->addObject($filters->getName(), $sep1); if (!empty($searchFields)) { $searchField = Ext_Factory::object('Component_Field_System_Searchfield'); $searchField->setName('searchField'); $searchField->width = 200; $searchField->store = $dataStore->getName(); $searchField->fieldNames = json_encode($searchFields); $fill = Ext_Factory::object('Toolbar_Fill'); $fill->setName('fill1'); $project->addObject($filters->getName(), $fill); $project->addObject($filters->getName(), $searchField); } /* * Editor window */ $editWindow = Ext_Factory::object('Component_Window_System_Crud'); $editWindow->setName('editWindow'); $editWindow->objectName = $object; $editWindow->controllerUrl = $controllerUrl; $editWindow->width = 800; $editWindow->height = 650; $editWindow->modal = true; $editWindow->resizable = true; $editWindow->extendedComponent(true); $eventManager->setEvent('editWindow', 'dataSaved', $runNamespace . '.dataStore.load();'); if (!$objectConfig->hasHistory()) { $editWindow->hideEastPanel = true; } $project->addObject(0, $editWindow); $tab = Ext_Factory::object('Panel'); $tab->setName($editWindow->getName() . '_generalTab'); $tab->frame = false; $tab->border = false; $tab->layout = 'anchor'; $tab->bodyPadding = 3; $tab->bodyCls = 'formBody'; $tab->anchor = '100%'; $tab->title = $lang->GENERAL; $tab->autoScroll = true; $tab->fieldDefaults = "{\n\t\t labelAlign: 'right',\n\t\t labelWidth: 160,\n\t\t anchor: '100%'\n\t\t }"; $project->addObject($editWindow->getName(), $tab); $objectFieldList = array_keys($objectConfig->getFieldsConfig(false)); foreach ($objectFieldList as $field) { if ($field == $primaryKey) { continue; } $newField = Backend_Designer_Import::convertOrmFieldToExtField($field, $objectConfig->getFieldConfig($field)); if ($newField === false) { continue; } $newField->setName($editWindow->getName() . '_' . $field); $fieldClass = $newField->getClass(); if ($fieldClass == 'Component_Field_System_Objectslist' || $fieldClass == 'Component_Field_System_Objectlink') { $newField->controllerUrl = $controllerUrl; } if (in_array($fieldClass, $this->tabTypes, true)) { $project->addObject($editWindow->getName(), $newField); } else { $project->addObject($tab->getName(), $newField); } } /* * Save designer project */ $designerStorage = Designer_Factory::getStorage($designerConfig); $project->actionjs = $actionFile; if (!$designerStorage->save($projectFile, $project)) { throw new Exception('Can`t create Designer project'); } /* * Create ActionJS file */ $this->_createActionJS($runNamespace, $classNamespace, $actionFile, $jsName); return true; }
/** * (non-PHPdoc) * @see Ext_Object::__toString() */ public function __toString() { $this->_convertListeners(); $lang = Lang::lang(); $plugins = array(); $features = array(); if (isset($this->_advancedPropertyValues['checkboxSelection']) && $this->_advancedPropertyValues['checkboxSelection']) { $this->_config->selModel = 'Ext.create("Ext.selection.CheckboxModel")'; } if (isset($this->_advancedPropertyValues['rowexpander']) && $this->_advancedPropertyValues['rowexpander']) { if (!empty($this->_advancedPropertyValues['expander_rowbodytpl'])) { $tpl = 'rowBodyTpl:' . $this->_advancedPropertyValues['expander_rowbodytpl']; } else { $tpl = ''; } $plugins[] = '{' . "\n" . "\t" . 'ptype: "rowexpander",' . "\n" . "\t" . 'pluginId:"rowexpander",' . "\n" . "\t" . $tpl . "\n" . '}'; } if (isset($this->_advancedPropertyValues['editable']) && $this->_advancedPropertyValues['editable']) { $plugins[] = 'Ext.create("Ext.grid.plugin.CellEditing", {' . "\n" . "\t" . 'clicksToEdit: ' . $this->_advancedPropertyValues['clicksToEdit'] . ',' . "\n" . "\t" . 'pluginId:"cellediting"' . "\n" . '})'; } if (isset($this->_advancedPropertyValues['grouping']) && $this->_advancedPropertyValues['grouping']) { if (isset($this->_advancedPropertyValues['groupsummary']) && $this->_advancedPropertyValues['groupsummary']) { $remoteRoot = ''; if (isset($this->_advancedPropertyValues['remoteRoot']) && $this->_advancedPropertyValues['remoteRoot']) { } $remoteRoot = 'remoteRoot: "' . $this->_advancedPropertyValues['remoteRoot'] . '"'; $features[] = "{" . "\t" . "id: '" . $this->getName() . "_groupingsummary'," . "\n" . "\t" . "ftype: 'groupingsummary'," . "\n" . "\t" . "groupHeaderTpl: '" . $this->_advancedPropertyValues['groupHeaderTpl'] . "'," . "\n" . "\t" . "hideGroupedHeader:" . intval($this->_advancedPropertyValues['hideGroupedHeader']) . "," . "\n" . "\t" . "startCollapsed: " . intval($this->_advancedPropertyValues['startCollapsed']) . "," . "\n" . "\t" . "enableGroupingMenu: " . intval($this->_advancedPropertyValues['enableGroupingMenu']) . "," . "\n" . "\t" . $remoteRoot . "\n" . "}"; } else { $features[] = "Ext.create('Ext.grid.feature.Grouping',{" . "\n" . "\t" . "groupHeaderTpl: '" . $this->_advancedPropertyValues['groupHeaderTpl'] . "'," . "\n" . "\t" . "startCollapsed: " . intval($this->_advancedPropertyValues['startCollapsed']) . "," . "\n" . "\t" . "enableGroupingMenu: " . intval($this->_advancedPropertyValues['enableGroupingMenu']) . "," . "\n" . "\t" . "hideGroupedHeader:" . intval($this->_advancedPropertyValues['hideGroupedHeader']) . "\n" . "})"; } } $filtersFeature = $this->getFiltersFeature(); $filters = $filtersFeature->getFilters(); if (!empty($filters)) { $features[] = $filtersFeature->__toString(); } if (isset($this->_advancedPropertyValues['summary']) && $this->_advancedPropertyValues['summary']) { $features[] = '{id:"summary" , ftype: "summary"}'; } $columns = '[]'; $columnsList = $this->getColumnsConfig(); if (!empty($columnsList)) { if (isset($this->_advancedPropertyValues['numberedRows']) && $this->_advancedPropertyValues['numberedRows']) { $columns = "[\n\tExt.create('Ext.grid.RowNumberer'),\n" . implode(",\n\t", $columnsList) . "\n]"; } else { $columns = "[\n" . implode(",\n\t", $columnsList) . "\n]"; } } unset($columnsList); if ($this->_config->isValidProperty('store') && strlen($this->_config->store)) { if (isset($this->_advancedPropertyValues['paging']) && $this->_advancedPropertyValues['paging']) { $this->_config->bbar = 'Ext.create("Ext.PagingToolbar", {' . "\n" . "\t" . 'displayInfo: true,' . "\n" . "\t" . 'displayMsg: "' . $lang->DISPLAYING_RECORDS . ' {0} - {1} ' . $lang->OF . ' {2}",' . "\n" . "\t" . 'emptyMsg:appLang.NO_RECORDS_TO_DISPLAY,' . "\n" . "\t" . "listeners:{ \n" . "\t\t" . "beforerender:{\n" . "\t\t\t" . "fn:function(cmp){\n" . "\t\t\t\t" . "cmp.bindStore(cmp.up('grid').getStore());\n" . "\t\t\t" . "}\n" . "\t\t" . "}\n" . "\t" . "}\n" . "})"; } } $this->_config->items = null; $this->_config->columns = $columns; if (!empty($plugins)) { $this->_config->plugins = '[' . "\n" . Utils_String::addIndent(implode(",\n", $plugins)) . "\n]"; } if (!empty($features)) { $this->_config->features = '[' . "\n" . Utils_String::addIndent(implode(",\n", $features)) . "\n]"; } return $this->_config->__toString(); }
public function __toString() { return "{\n" . Utils_String::addIndent(implode(",\n", $this->asStringList())) . "\n}"; }
function objectLocalMethods(array $methods, $id) { $s = '<div id="' . $id . '" style=="width:100%" class="collapsed">'; if (!empty($methods)) { foreach ($methods as $item) { $s .= '<div><pre>' . $item->getJsDoc() . '<br>' . $item->getName() . ':function(' . $item->getParamsLine() . '){' . "\n" . Utils_String::addIndent($item->getCode()) . "\n" . '}</pre></div>'; } } $s .= '</div>'; return $s; }
/** * Get random string * * @param integer $length * - string length * @return string */ static function getRandomString($length) { return Utils_String::getRandomString($length); }
/** * Get module name for class * @param string $class * @return string */ public function getModuleName($class) { return Utils_String::formatClassName(strtolower(str_replace(array('Backend_', '_Controller'), '', $class))); }
/** * Create public key * @return string */ public function createIv() { return Utils_String::createEncryptIv(); }
public function connectobjectAction() { $connectionId = Request::post('connId', 'string', false); $connectionType = Request::post('type', 'integer', false); $table = Request::post('table', 'string', false); if ($connectionId === false || $connectionType === false || $table === false) { Response::jsonError($this->_lang->WRONG_REQUEST); } $cfg = $this->_manager->getConnection($connectionType, $connectionId); if (!$cfg) { Response::jsonError($this->_lang->WRONG_REQUEST); } $cfg = $cfg->__toArray(); try { $db = Zend_Db::factory($cfg['adapter'], $cfg); $db->query('SET NAMES ' . $cfg['charset']); $tables = $db->listTables(); } catch (Exception $e) { Response::jsonError($this->_lang->CANT_CONNECT . ' ' . $e->getMessage()); } $import = new Db_Object_Import(); if (!$import->isValidPrimaryKey($db, $table)) { $errors = $import->getErrors(); if (!empty($errors)) { $errors = '<br>' . implode('<br>', $errors); } else { $errors = ''; } Response::jsonError($this->_lang->DB_CANT_CONNECT_TABLE . ' ' . $this->_lang->DB_MSG_UNIQUE_PRIMARY . ' ' . $errors); } $manager = new Db_Object_Manager(); $newObjectName = strtolower(str_replace('_', '', $table)); if ($manager->objectExists($newObjectName)) { $newObjectName = strtolower(str_replace('_', '', $cfg['dbname'])) . $newObjectName; if ($manager->objectExists($newObjectName)) { $k = 0; $alphabet = Utils_String::alphabetEn(); while ($manager->objectExists($newObjectName)) { if (!isset($alphabet[$k])) { Response::jsonError('Can not create unique object name' . $errors); } $newObjectName .= $alphabet[$k]; $k++; } } } $config = $import->createConfigByTable($db, $table, $cfg['prefix']); $config['connection'] = $connectionId; if (!$config) { $errors = $import->getErrors(); if (!empty($errors)) { $errors = '<br>' . implode('<br>', $errors); } else { $errors = ''; } Response::jsonError($this->_lang->DB_CANT_CONNECT_TABLE . ' ' . $errors); } else { $path = $this->_configMain->get('object_configs') . $newObjectName . '.php'; if (!Config_File_Array::create($path)) { Response::jsonError($this->_lang->CANT_WRITE_FS . ' ' . $path); } $cfg = Config::factory(Config::File_Array, $path); $cfg->setData($config); if (!$cfg->save()) { Response::jsonError($this->_lang->CANT_WRITE_FS . ' ' . $path); } } Response::jsonSuccess(); }
if (!doesHaveMembership() && isLoginId(getBlogId(), $_POST['loginid'])) { $showPasswordReset = true; } } else { if (!doesHaveOwnership()) { $message = _text('서비스의 회원이지만 이 블로그의 구성원이 아닙니다. 주소를 확인해 주시기 바랍니다.'); } } } } } $authResult = fireEvent('LOGIN_try_auth', false); if (doesHaveOwnership() || doesHaveMembership()) { if (doesHaveOwnership() && !empty($_POST['requestURI'])) { $url = parse_url($_POST['requestURI']); if ($url && isset($url['host']) && !Utils_String::endsWith('.' . $url['host'], '.' . $context->getProperty('service.domain'))) { $redirect = $context->getProperty('uri.blog') . "/login?requestURI=" . rawurlencode($_POST['requestURI']) . '&session=' . rawurlencode(session_id()); } else { $redirect = $_POST['requestURI']; } } else { $redirect = $_POST['refererURI']; } if (empty($_SESSION['lastloginRedirected']) || $_SESSION['lastloginRedirected'] != $redirect) { $_SESSION['lastloginRedirected'] = $redirect; } else { unset($_SESSION['lastloginRedirected']); } header('Location: ' . $redirect); exit; }
protected function _compileExtendedSubItems($parent, $mainContainer) { if (!$this->_project->hasChilds($parent)) { return array(); } $mainContainerObject = $this->_project->getItemData($mainContainer); $eventManager = $this->_project->getEventManager(); $childs = $this->_project->getChilds($parent); $items = array(); $docked = array(); $menu = array(); foreach ($childs as $k => $item) { if ($this->_project->hasChilds($item['id'])) { $this->_compileExtendedSubItems($item['id'], $mainContainer); } $itemName = 'me.childObjects.' . $item['id']; switch ($item['data']->getClass()) { case 'Docked': if (!$this->_project->hasChilds($item['id'])) { continue; } $docked[] = $item['data']; break; case 'Menu': if (!$this->_project->hasChilds($item['id'])) { continue; } $menu[] = $item['data']; break; default: $items[] = $itemName; break; } $objectEvents = $eventManager->getObjectEvents($item['id']); if (!empty($objectEvents)) { $eventsConfig = $item['data']->getConfig()->getEvents()->__toArray(); foreach ($objectEvents as $event => $config) { if (empty($config['code'])) { continue; } $params = ''; if (isset($eventsConfig[$event])) { $params = implode(',', array_keys($eventsConfig[$event])); } if ($event === 'handler') { $item['data']->addListener($event, "function(" . $params . "){\n" . Utils_String::addIndent($config['code'], 2) . "\n}"); $item['data']->scope = 'this'; } else { $item['data']->addListener($event, "{\n" . Utils_String::addIndent("fn:function(" . $params . "){\n" . Utils_String::addIndent($config['code'], 2) . "\n},\n" . Utils_String::addIndent("scope:this") . "\n}", 2) . "\n"); } } } $mainContainerObject->addElement($itemName, $item['data']); /** * Convert ActionColumn listeners */ if ($item['data']->getClass() === 'Grid') { $this->_applycolumnEvents($item['data']); $this->_applyFiltersEvents($item['data']->getFiltersFeature()); } } if ($parent !== '0') { $container = $this->_project->getItemData($parent); if (!empty($items)) { $container->items = "[\n" . Utils_String::addIndent(implode(",\n", $items), 1) . "\n]\n"; } if (!empty($docked)) { $container->dockedItems = implode(',', $docked); } if (!empty($menu)) { $container->menu = implode(',', $menu); } } }