Example #1
0
 /**
  * Import DB fields into the form object
  */
 public function importdbfieldsAction()
 {
     $connection = Request::post('connection', 'string', false);
     $table = Request::post('table', 'string', false);
     $conType = Request::post('type', 'integer', false);
     $importFields = Request::post('importfields', 'array', array());
     if ($connection === false || !$table || empty($importFields) || $conType === false) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $conManager = new Backend_Orm_Connections_Manager($this->_configMain->get('db_configs'));
     $cfg = $conManager->getConnection($conType, $connection);
     if (!$cfg) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $cfg = $cfg->__toArray();
     $tableFields = Backend_Designer_Import::getTableFields($cfg, $table);
     if ($tableFields === false) {
         Response::jsonError($this->_lang->CANT_CONNECT);
     }
     foreach ($importFields as $name) {
         if (isset($tableFields[$name]) && !empty($tableFields[$name])) {
             $this->_importDbField($name, $tableFields[$name]);
         }
     }
     $this->_storeProject();
     Response::jsonSuccess();
 }
Example #2
0
 public function updateAction()
 {
     $this->_checkCanEdit();
     $data = Request::post('data', 'raw', false);
     if ($data === false) {
         Response::jsonError($this->_lang->INVALID_VALUE);
     }
     $data = json_decode($data, true);
     if (!isset($data[0])) {
         $data = array($data);
     }
     $manager = new Backend_Fmodules_Manager();
     $manager->removeAll();
     if (!empty($data)) {
         foreach ($data as $v) {
             if (empty($v)) {
                 continue;
             }
             $name = $v['name'];
             unset($v['name']);
             $manager->addModule($name, $v);
         }
     }
     if ($manager->save()) {
         Response::jsonSuccess();
     } else {
         Response::jsonError($this->_lang->CANT_WRITE_FS);
     }
 }
Example #3
0
 protected function _getEvent()
 {
     $event = Request::post('event', 'string', false);
     if (!strlen($event) || $event === false) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     return $event;
 }
Example #4
0
File: Vc.php Project: vgrish/dvelum
 public function getModule()
 {
     $dataObject = Request::post('d_object', 'string', false);
     if (!$dataObject || !Db_Object_Config::configExists($dataObject)) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     return ucfirst($dataObject);
 }
Example #5
0
 /**
  * Send JSON error message
  *
  * @return string
  */
 protected function _errorResponse($msg)
 {
     if (Request::isAjax()) {
         Response::jsonError($msg);
     } else {
         Response::redirect(Request::url(array('index'), true));
     }
 }
Example #6
0
 /**
  * Check requested object
  * Get requested object from project
  * @return Ext_Object
  */
 protected function _getObject()
 {
     $name = Request::post('object', 'string', '');
     $project = $this->_getProject();
     if (!strlen($name) || !$project->objectExists($name)) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     return $project->getObject($name);
 }
Example #7
0
 public function resetAction()
 {
     $this->_checkCanDelete();
     if (Backend_Cache_Manager::resetAll()) {
         Response::jsonSuccess();
     } else {
         Response::jsonError($this->_lang->CANT_RESET_CACHE);
     }
 }
Example #8
0
 /**
  * Update object
  * @param Db_Object $object
  * @return void
  */
 public function updateObject(Db_Object $object)
 {
     $changeVal = Request::post('changeVal', 'bool', false);
     if ($changeVal) {
         $object->set('hash', Utils::hash($object->get('hash')));
     }
     if (!$object->save()) {
         Response::jsonError($this->_lang->CANT_EXEC);
     }
     Response::jsonSuccess(array('id' => $object->getId()));
 }
Example #9
0
 public function actionsAction()
 {
     $controller = Request::post('controller', 'string', '');
     if (!strlen($controller)) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     if (strpos($controller, '.php') !== false) {
         $controller = Utils::classFromPath($controller);
     }
     $actions = Backend_Designer_Code::getPossibleActions($controller);
     Response::jsonSuccess($actions);
 }
Example #10
0
 /**
  * Save permissions action
  */
 public function savepermissionsAction()
 {
     $this->_checkCanEdit();
     $data = Request::post('data', 'raw', false);
     $groupId = Request::post('group_id', 'int', false);
     $data = json_decode($data, true);
     if (empty($data) || !$groupId) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     if (Model::factory('acl_simple')->updateGroupPermissions($groupId, $data)) {
         Response::jsonSuccess();
     } else {
         Response::jsonError($this->_lang->CANT_EXEC);
     }
 }
Example #11
0
 /**
  * Get JS code for object
  */
 public function objectcodeAction()
 {
     $object = Request::post('object', 'string', '');
     $project = $this->_getProject();
     if (!$project->objectExists($object)) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $projectCfg = $project->getConfig();
     Ext_Code::setRunNamespace($projectCfg['runnamespace']);
     Ext_Code::setNamespace($projectCfg['namespace']);
     $templates = $this->_config->get('templates');
     $replaces = array(array('tpl' => $templates['wwwroot'], 'value' => $this->_configMain->get('wwwroot')), array('tpl' => $templates['adminpath'], 'value' => $this->_configMain->get('adminPath')), array('tpl' => $templates['urldelimiter'], 'value' => $this->_configMain->get('urlDelimiter')));
     $code = $project->getObjectCode($object, $replaces);
     Response::jsonSuccess($code);
 }
Example #12
0
 /**
  * Save ActionJs code
  */
 public function saveAction()
 {
     $code = Request::post('code', 'raw', false);
     if ($code === false) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $project = $this->_getProject();
     $actionjs = str_replace('../', '', $project->actionjs);
     if ($actionjs[0] !== '.') {
         $actionjs = '.' . $actionjs;
     }
     if (!@file_put_contents($actionjs, $code)) {
         Response::jsonError($this->_lang->CANT_WRITE_FS . ' ' . $actionjs);
     }
     Response::jsonSuccess();
 }
Example #13
0
 /**
  * Set object property
  */
 public function setpropertyAction()
 {
     $id = Request::post('id', 'string', false);
     $property = Request::post('name', 'string', false);
     $value = Request::post('value', 'raw', false);
     if (!$id || !$this->_object->getFiltersFeature()->filterExists($id)) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $object = $this->_object->getFiltersFeature()->getFilter($id);
     if (!$object->isValidProperty($property)) {
         Response::jsonError();
     }
     $object->{$property} = $value;
     $this->_storeProject();
     Response::jsonSuccess();
 }
Example #14
0
 /**
  * Set object property
  */
 public function setpropertyAction()
 {
     $this->_checkColumn();
     $action = Request::post('id', 'string', false);
     if ($action === false || !$this->_column->actionExists($action)) {
         Response::jsonError($this->_lang->WRONG_REQUEST . ' invalid action');
     }
     $action = $this->_column->getAction($action);
     $property = Request::post('name', 'string', false);
     $value = Request::post('value', 'raw', false);
     if (!$action->isValidProperty($property)) {
         Response::jsonError();
     }
     $action->{$property} = $value;
     $this->_storeProject();
     Response::jsonSuccess();
 }
Example #15
0
 /**
  * Import fields into the form object
  */
 public function importfieldsAction()
 {
     $importObject = Request::post('importobject', 'string', false);
     $importFields = Request::post('importfields', 'array', array());
     if (!$importObject || empty($importFields) || !Db_Object_Config::configExists($importObject)) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $importObjectConfig = Db_Object_Config::getInstance($importObject);
     foreach ($importFields as $name) {
         if ($importObjectConfig->fieldExists($name)) {
             $this->_importOrmField($name, $importObjectConfig);
         }
     }
     $this->_object->objectName = $importObject;
     $this->_storeProject();
     Response::jsonSuccess();
 }
Example #16
0
 /**
  * Get object properties
  */
 public function listAction()
 {
     $id = Request::post('id', 'string', false);
     if (!method_exists($this->_object, 'fieldExists')) {
         Response::jsonError(get_class($this->_object) . '[' . $this->_object->getName() . '] deprecated type');
     }
     if (!$id || !$this->_object->fieldExists($id)) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $field = $this->_object->getField($id);
     $config = $field->getConfig();
     $properties = $config->__toArray();
     if (isset($properties['isExtended'])) {
         unset($properties['isExtended']);
     }
     Response::jsonSuccess($properties);
 }
Example #17
0
 /**
  * Change window size
  */
 public function changesizeAction()
 {
     $object = Request::post('object', 'string', false);
     $width = Request::post('width', 'integer', false);
     $height = Request::post('height', 'integer', false);
     if ($object === false || $width === false || $height === false) {
         Response::jsonError($this->_lang->WRONG_REQUEST . 'code 1');
     }
     $project = $this->_getProject();
     if (!$project->objectExists($object)) {
         Response::jsonError($this->_lang->WRONG_REQUEST . 'code 2');
     }
     $object = $project->getObject($object);
     $object->width = $width;
     $object->height = $height;
     $this->_storeProject();
     Response::jsonSuccess();
 }
Example #18
0
 public function indexAction()
 {
     $controller = Filter::filterValue('pagecode', Request::getInstance()->getPart(1));
     $action = Filter::filterValue('pagecode', Request::getInstance()->getPart(2));
     if (!strlen($controller) || !strlen($action)) {
         Response::jsonError($this->_lang->WRONG_REQUEST . ' c1');
     }
     $apiController = 'Api_' . ucfirst($controller);
     $apiAction = $action . 'Action';
     if (!class_exists($apiController)) {
         Response::jsonError($this->_lang->WRONG_REQUEST . ' c2');
     }
     $controller = new $apiController(Registry::get('main', 'config'), $this->_db);
     if (!method_exists($controller, $apiAction)) {
         Response::jsonError($this->_lang->WRONG_REQUEST . ' c3 ' . $apiAction);
     }
     $controller->{$apiAction}();
 }
Example #19
0
 /**
  * Run controller
  * @param string $controller - controller class
  * @param string $action - action name
  * @return mixed
  */
 public function runController($controller, $action = false)
 {
     if (!class_exists($controller)) {
         return false;
     }
     $controller = new $controller();
     $controller->setRouter($this);
     if ($controller instanceof Router_Interface) {
         return $controller->route();
     }
     if ($action === false || !strlen($action) || !method_exists($controller, $action . 'Action')) {
         if (strlen($action) && Request::isAjax()) {
             Response::jsonError(Lang::lang()->get('WRONG_REQUEST') . ' ' . Request::getInstance()->getUri());
         }
         $action = 'index';
     }
     return $controller->{$action . 'Action'}();
 }
Example #20
0
 /**
  * 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));
 }
Example #21
0
 public function updateAction()
 {
     $this->_checkCanEdit();
     $data = Request::post('data', 'raw', false);
     if ($data === false) {
         Response::jsonError($this->_lang->INVALID_VALUE);
     }
     $data = json_decode($data, true);
     if (!isset($data[0])) {
         $data = array($data);
     }
     $modulesCfg = Config::factory(Config::File_Array, $this->_configMain->get('configs') . 'externals.php');
     $modulesCfg->removeAll();
     foreach ($data as $v) {
         $modulesCfg->set($v['id'], array('active' => $v['active']));
     }
     if ($modulesCfg->save()) {
         Response::jsonSuccess();
     } else {
         Response::jsonError($this->_lang->CANT_WRITE_FS);
     }
 }
Example #22
0
 /**
  * Change field type
  */
 public function changetypeAction()
 {
     $this->_checkLoaded();
     $object = $this->_getObject();
     $type = Request::post('type', 'string', false);
     $adapter = Request::post('adapter', 'string', false);
     $dictionary = Request::post('dictionary', 'string', false);
     if ($type === 'Form_Field_Adapter') {
         $newObject = Ext_Factory::object($adapter);
         /*
          * Invalid adapter
          */
         if (!$adapter || !strlen($adapter) || !class_exists($adapter)) {
             Response::jsonError($this->_lang->INVALID_VALUE, array('adapter' => $this->_lang->INVALID_VALUE));
         }
         if ($adapter === 'Ext_Component_Field_System_Dictionary') {
             /*
              * Inavalid dictionary
              */
             if (!$dictionary || !strlen($dictionary)) {
                 Response::jsonError($this->_lang->INVALID_VALUE, array('dictionary' => $this->_lang->INVALID_VALUE));
             }
             $newObject->dictionary = $dictionary;
         }
     } else {
         $newObject = Ext_Factory::object($type);
         /*
          * No changes
          */
         if ($type === $object->getClass()) {
             Response::jsonSuccess();
         }
     }
     Ext_Factory::copyProperties($object, $newObject);
     $newObject->setName($object->getName());
     parent::_getObject()->setViewObject($newObject);
     $this->_storeProject();
     Response::jsonSuccess();
 }
Example #23
0
 /**
  * Get list of ORM object fields
  */
 public function fieldsAction()
 {
     $objectName = Request::post('object', 'string', false);
     if (!$objectName) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     try {
         $config = Db_Object_Config::getInstance($objectName);
     } catch (Exception $e) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $fields = $config->getFieldsConfig();
     if (empty($fields)) {
         Response::jsonSuccess(array());
     }
     $data = array();
     foreach ($fields as $name => $cfg) {
         $type = $cfg['db_type'];
         if ($config->isLink($name)) {
             if ($config->isDictionaryLink($name)) {
                 $type = $this->_lang->DICTIONARY_LINK . '"' . $config->getLinkedDictionary($name) . '"';
             } else {
                 $obj = $config->getLinkedObject($name);
                 $oName = $obj . '';
                 try {
                     $oCfg = Db_Object_Config::getInstance($obj);
                     $oName .= ' (' . $oCfg->get('title') . ')';
                 } catch (Exception $e) {
                     //empty on error
                 }
                 $type = $this->_lang->OBJECT_LINK . ' - ' . $oName;
             }
         }
         $data[] = array('name' => $name, 'title' => $cfg['title'], 'type' => $type);
     }
     Response::jsonSuccess($data);
 }
Example #24
0
 public function uploadAction()
 {
     $object = Request::post('object', 'string', false);
     if (!$object || !Db_Object_Config::configExists($object)) {
         Response::jsonError($this->_lang->get('FILL_FORM'));
     }
     $cfg = Db_Object_Config::getInstance($object);
     $fields = $cfg->getFieldsConfig(false);
     $expectedCols = array();
     $expectedCols[] = array('id' => $cfg->getPrimaryKey(), 'text' => $this->_lang->get('PRIMARY_KEY'), 'columnIndex' => -1, 'required' => 1);
     foreach ($fields as $name => $fConfig) {
         $expectedCols[] = array('id' => $name, 'text' => $fConfig['title'], 'columnIndex' => -1, 'required' => $cfg->isRequired($name));
     }
     $result = array('success' => true, 'expectedColumns' => $expectedCols, 'data' => array(), 'uploadId' => 1);
     if (!$cfg->isSystem()) {
         $result['importTypes'][] = array('name' => 'type', 'inputValue' => 'rewrite', 'boxLabel' => $this->_iLang->get('REWRITE'));
     }
     //echo json_encode(array('success'=>false,'msg'=>'Cannot upload file')); exit;
     for ($i = 0; $i < 30; $i++) {
         $result['data'][] = array('col0' => 'Data' . rand(0, 6), 'col1' => rand(1000, 9999), 'col2' => rand(1, 700), 'col3' => rand(1, 700), 'col4' => rand(1, 700), 'col5' => rand(1, 700), 'col6' => rand(1, 700));
     }
     $result['col_count'] = sizeof($result['data'][0]);
     Response::jsonArray($result);
 }
Example #25
0
 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();
 }
Example #26
0
 /**
  * Add store field
  */
 public function addfieldAction()
 {
     $this->_checkLoaded();
     $this->_checkObject();
     $id = Request::post('id', 'string', false);
     if (!$id || $this->_object->fieldExists($id)) {
         Response::jsonError($this->_lang->FIELD_EXISTS);
     }
     if ($this->_object->addField(array('name' => $id, 'type' => 'string'))) {
         $o = $this->_object->getField($id);
         $this->_storeProject();
         Response::jsonSuccess(array('name' => $o->name, 'type' => $o->type));
     } else {
         Response::jsonError($this->_lang->CANT_EXEC);
     }
 }
Example #27
0
 /**
  * Delete module
  */
 public function deletemoduleAction()
 {
     $this->_checkCanEdit();
     $module = Request::post('id', 'string', false);
     $removeRelated = Request::post('delete_related', 'boolean', false);
     $manager = new Backend_Modules_Manager();
     $moduleName = $manager->getModuleName($module);
     if (!$module || !strlen($module) || !$manager->isValidModule($moduleName)) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $filesToDelete = array();
     if ($removeRelated) {
         $item = $manager->getModuleConfig($moduleName);
         $classFile = './system/app/' . str_replace('_', '/', $item['class']) . '.php';
         if (file_exists($classFile)) {
             $filesToDelete[] = $classFile;
         }
         if (!empty($item['designer'])) {
             if (file_exists($item['designer'])) {
                 $filesToDelete[] = $item['designer'];
             }
             $crudJs = './js/app/system/crud/' . strtolower($manager->getModuleName($item['class'])) . '.js';
             if (file_exists($crudJs)) {
                 $filesToDelete[] = $crudJs;
             }
             $actionJs = './js/app/actions/' . strtolower($manager->getModuleName($item['class'])) . '.js';
             if (file_exists($actionJs)) {
                 $filesToDelete[] = $actionJs;
             }
         }
     }
     // check before deleting
     if (!empty($filesToDelete)) {
         $err = array();
         foreach ($filesToDelete as $file) {
             if (!is_writable($file)) {
                 $err[] = $file;
             }
         }
         if (!empty($err)) {
             Response::jsonError($this->_lang->CANT_WRITE_FS . "\n<br>" . implode(",\n<br>", $err));
         }
     }
     $manager->removeModule($moduleName);
     if (!$manager->save()) {
         Response::jsonError($this->_lang->CANT_WRITE_FS . ' ' . $manager->getConfig()->getName());
     }
     // try to delete
     if (!empty($filesToDelete)) {
         $err = array();
         foreach ($filesToDelete as $file) {
             if (!unlink($file)) {
                 $err[] = $file;
             }
         }
         if (!empty($err)) {
             Response::jsonError($this->_lang->CANT_WRITE_FS . "\n<br>" . implode(",\n<br>", $err));
         }
     }
     Response::jsonSuccess();
 }
Example #28
0
 /**
  * Rebuild all packages
  */
 public function rebuildallAction()
 {
     $this->_checkCanEdit();
     $dest = $this->_packagesConfig->get('path');
     /*
      * Returning a reference from a function
      */
     $data =& $this->_packagesConfig->dataLink();
     if ($this->_packagesConfig->get('all_in_one')) {
         $s = '';
         foreach ($data['packages'] as $item) {
             if (!$item['active']) {
                 continue;
             }
             $s .= $this->_compilePackage($item);
         }
         Utils::exportCode($dest . $this->_packagesConfig->get('main_package') . '.php', $s);
     } else {
         foreach ($data['packages'] as $name => $item) {
             $s = $this->_compilePackage($item);
             $data['packages'][$name]['checksum'] = md5($s);
             if (Utils::exportCode($dest . $name . '.php', $s) === false) {
                 Response::jsonError($this->_lang->CANT_WRITE_FS);
             }
             $data['packages'][$name]['fchecksum'] = md5_file($dest . $name . '.php');
         }
     }
     if ($this->buildmapAction() === false) {
         Response::jsonError($this->_lang->CANT_WRITE_FS);
     }
     if (!$this->_packagesConfig->save()) {
         Response::jsonError($this->_lang->CANT_WRITE_FS);
     } else {
         Response::jsonSuccess();
     }
 }
Example #29
0
File: Vc.php Project: vgrish/dvelum
 /**
  * Unpublish object
  * Sends JSON reply in the result
  * and closes the application.
  * @param Db_Object $object
  */
 public function unpublishObject(Db_Object $object)
 {
     if (!$object->get('published')) {
         Response::jsonError($this->_lang->NOT_PUBLISHED);
     }
     if (!$object->unpublish()) {
         Response::jsonError($this->_lang->CANT_EXEC);
     }
     Response::jsonSuccess();
 }
Example #30
0
 /**
  * Get list of default blocks
  */
 public function defaultblocksAction()
 {
     $blocks = Model::factory('Blockmapping');
     $list = $blocks->getList(false, array('page_id' => null), array('id' => 'block_id', 'place'));
     try {
         $config = Config::factory(Config::File_Array, $this->_configMain->get('themes') . 'default' . '/layout_cfg.php');
     } catch (Exception $e) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     if (!empty($list)) {
         $list = Utils::groupByKey('place', $list);
         foreach ($list as $key => &$value) {
             $value = array_values($this->_collectBlockLinksData($value));
         }
         unset($value);
     } else {
         $list = array();
     }
     Response::jsonSuccess(array('config' => $config->__toArray(), 'blocks' => $list));
 }