Example #1
0
 /**
  * Users list action
  */
 public function userlistAction()
 {
     $pager = Request::post('pager', 'array', array());
     $filter = Request::post('filter', 'array', array());
     $query = Request::post('search', 'string', false);
     $model = Model::factory('User');
     $count = $model->getCount($filter, $query);
     $data = $model->getListVc($pager, $filter, $query, array('id', 'group_id', 'name', 'login', 'email', 'enabled', 'admin'));
     /*
      * Fillin group titles Its faster then using join
      */
     $groups = Model::factory('Group')->getGroups();
     if (!empty($data) && !empty($groups)) {
         foreach ($data as $k => &$v) {
             if (array_key_exists($v['group_id'], $groups)) {
                 $v['group_title'] = $groups[$v['group_id']];
             } else {
                 $v['group_title'] = '';
             }
         }
     }
     unset($v);
     $result = array('success' => true, 'count' => $count, 'data' => $data);
     Response::jsonArray($result);
 }
Example #2
0
 /**
  * Get list of media library items
  */
 public function listAction()
 {
     $pager = Request::post('pager', 'array', array());
     $filter = Request::post('filter', 'array', array());
     $query = Request::post('search', 'string', false);
     if (isset($filter['category']) && !intval($filter['category'])) {
         $filter['category'] = null;
     }
     $media = Model::factory('Medialib');
     $data = $media->getListVc($pager, $filter, $query, '*', 'user_name');
     $wwwRoot = $this->_configMain->get('wwwroot');
     if (!empty($data)) {
         foreach ($data as $k => &$v) {
             if ($v['type'] == 'image') {
                 $v['srcpath'] = Model_Medialib::addWebRoot(str_replace($v['ext'], '', $v['path']));
                 $v['thumbnail'] = Model_Medialib::getImgPath($v['path'], $v['ext'], 'thumbnail', true);
                 $v['icon'] = Model_Medialib::getImgPath($v['path'], $v['ext'], 'icon', true);
             } else {
                 $v['icon'] = $wwwRoot . 'i/unknown.png';
                 $v['thumbnail'] = $wwwRoot . 'i/unknown.png';
                 $v['srcpath'] = '';
             }
             $v['path'] = Model_Medialib::addWebRoot($v['path']);
         }
         unset($v);
     }
     $result = array('success' => true, 'count' => $media->getCount($filter, $query), 'data' => $data);
     Response::jsonArray($result);
 }
Example #3
0
 public function listAction()
 {
     $pager = Request::post('pager', 'array', array());
     $query = Request::post('search', 'string', false);
     $result = array('success' => true, 'count' => 0, 'data' => array());
     $dataModel = Model::factory('Blocks');
     $vc = Model::factory('Vc');
     $fields = array('id', 'title', 'date_created', 'published', 'published_version', 'date_updated', 'is_system', 'sys_name', 'params');
     $data = $dataModel->getListVc($pager, false, $query, $fields, 'user', 'updater');
     if (empty($data)) {
         Response::jsonArray($result);
     }
     $ids = array();
     foreach ($data as $k => $v) {
         $ids[] = $v['id'];
     }
     $maxRevisions = $vc->getLastVersion('blocks', $ids);
     foreach ($data as $k => &$v) {
         if (isset($maxRevisions[$v['id']])) {
             $v['last_version'] = $maxRevisions[$v['id']];
         } else {
             $v['last_version'] = 0;
         }
     }
     unset($v);
     $result = array('success' => true, 'count' => $dataModel->getCount(array('is_system' => 0), $query), 'data' => $data);
     Response::jsonArray($result);
 }
Example #4
0
 public function importAction()
 {
     $result = array('success' => true, 'success_records' => 123);
     for ($i = 0; $i < 10; $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));
     }
     Response::jsonArray($result);
 }
Example #5
0
 public function listAction()
 {
     $object = Request::post('object', 'string', false);
     if (!$object) {
         Response::jsonSuccess(array());
     }
     $pager = Request::post('pager', 'array', array());
     $filter = Request::post('filter', 'array', array());
     $filter['object_name'] = $object;
     $model = Model::factory('Vc');
     $data = $model->getListVc($pager, $filter, false, array('version', 'date', 'id', 'record_id'), 'user_name');
     $result = array('success' => true, 'count' => $model->getCount($filter), 'data' => $data);
     Response::jsonArray($result);
 }
Example #6
0
 /**
  * Get list of existing form field adapters
  */
 public function listadaptersAction()
 {
     $data = array();
     $autoloaderPaths = $this->_configMain['autoloader'];
     $autoloaderPaths = $autoloaderPaths['paths'];
     $files = File::scanFiles($this->_config->get('components') . '/Field', array('.php'), true, File::Files_Only);
     if (!empty($files)) {
         foreach ($files as $item) {
             $class = Utils::classFromPath(str_replace($autoloaderPaths, '', $item));
             $data[] = array('id' => $class, 'title' => str_replace($this->_config->get('components') . '/', '', substr($item, 0, -4)));
         }
     }
     Response::jsonArray($data);
 }
Example #7
0
File: Fs.php Project: vgrish/dvelum
 /**
  * Files list
  */
 public function fslistAction()
 {
     $path = Request::post('node', 'string', '');
     //$path = str_replace('.','', $path);
     $dirPath = $this->_config->get('configs');
     if ($path === '') {
         $path = $dirPath . $path;
     }
     if (!is_dir($dirPath)) {
         Response::jsonArray(array());
     }
     $files = File::scanFiles($path, array('.dat'), false, File::Files_Dirs);
     $list = array();
     if (!empty($files)) {
         $dirs = array();
         $pfiles = array();
         foreach ($files as $k => $fpath) {
             $text = basename($fpath);
             if ($text === '.svn') {
                 continue;
             }
             if (is_dir($fpath)) {
                 $dirs[] = $fpath;
             } else {
                 $pfiles[] = $fpath;
             }
         }
         if (!empty($dirs)) {
             sort($dirs);
             foreach ($dirs as $k => $fpath) {
                 $text = basename($fpath);
                 $obj = new stdClass();
                 $obj->id = str_replace($this->_configMain->get('docroot'), './', $fpath);
                 $obj->text = $text;
                 $obj->expanded = false;
                 $obj->leaf = false;
                 $list[] = $obj;
             }
         }
         if (!empty($pfiles)) {
             sort($pfiles);
             foreach ($pfiles as $k => $fpath) {
                 $text = basename($fpath);
                 $obj = new stdClass();
                 $obj->id = str_replace($this->_configMain->get('docroot'), './', $fpath);
                 $obj->text = $text;
                 $obj->leaf = true;
                 $list[] = $obj;
             }
         }
     }
     if ($path == '') {
         if ($this->_configMain->get('allow_externals')) {
             $config = Config::factory(Config::File_Array, $this->_configMain->get('configs') . 'externals.php');
             $eExpert = new Externals_Expert($this->_configMain, $config);
             $extProjects = $eExpert->getProjects();
             if (!empty($extProjects)) {
                 foreach ($extProjects as $item) {
                     $list[] = $item;
                 }
             }
         }
     }
     Response::jsonArray($list);
 }
Example #8
0
 /**
  * Add related object selection
  */
 public function addSubAction()
 {
     $this->_checkCanEdit();
     $this->_checkLoaded();
     $baseField = Request::post('basefield', 'string', false);
     $subObject = Request::post('subobject', 'string', false);
     $subField = Request::post('subfield', 'string', false);
     $join = Request::post('join', 'integer', 1);
     if (!$baseField || !$subObject || !$subField || !$join) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $query = $this->_session->get('query');
     $basePart = $query->getRootPart();
     $childPart = $query->findChild($basePart->getId(), $baseField);
     if ($childPart !== false) {
         $query->removePart($childPart->getId());
     }
     $newPart = new Db_Query_Part();
     $newPart->setObject($subObject);
     $newPart->setParentField($baseField);
     $newPart->setChildField($subField);
     $newPart->setJoinType($join);
     if (!$query->addPart($newPart, $basePart->getId())) {
         Response::jsonArray(array('success' => false, 'msg' => $this->_lang->CANT_EXEC));
     }
     $basePart->setFieldCfg($baseField, 'selectSub', true);
     $basePart->setFieldCfg($baseField, 'isLink', true);
     $this->_session->set('query', $query);
     Response::jsonSuccess();
 }
Example #9
0
 /**
  * Get Categories tree
  */
 public function treelistAction()
 {
     $model = Model::factory('Mediacategory');
     Response::jsonArray($model->getCategoriesTree());
 }
Example #10
0
 public function imglistAction()
 {
     $templates = $this->_config->get('templates');
     $dirPath = $this->_configMain->get('docroot');
     $dir = Request::post('dir', 'string', '');
     if (!is_dir($dirPath . $dir)) {
         Response::jsonArray(array());
     }
     $files = File::scanFiles($dirPath . $dir, array('.jpg', '.png', '.gif', '.jpeg'), false, File::Files_Only);
     if (empty($files)) {
         Response::jsonArray(array());
     }
     sort($files);
     $list = array();
     foreach ($files as $k => $fpath) {
         // ms fix
         $fpath = str_replace('\\', '/', $fpath);
         $text = basename($fpath);
         if ($text === '.svn') {
             continue;
         }
         $list[] = array('name' => $text, 'url' => str_replace($dirPath . '/', $this->_configMain->get('wwwroot'), $fpath), 'path' => str_replace($dirPath . '/', $templates['wwwroot'], $fpath));
     }
     Response::jsonSuccess($list);
 }
Example #11
0
 /**
  * Get related project items Tree list
  */
 public function relatedprojectlistAction()
 {
     $this->_checkLoaded();
     $project = $this->_getProject();
     $relatedProjects = array();
     $this->getRelatedProjects($project, $relatedProjects);
     if (empty($relatedProjects)) {
         Response::jsonSuccess(array());
     }
     $result = array();
     foreach ($relatedProjects as $item) {
         $projectConfig = $item['project']->getConfig();
         $o = new stdClass();
         $o->id = $item['file'];
         $o->text = $item['file'] . ' classes:  ' . $projectConfig['namespace'] . ' run: ' . $projectConfig['runnamespace'];
         $o->expanded = false;
         $o->objClass = '';
         $o->leaf = false;
         $o->iconCls = '';
         $o->allowDrag = false;
         $o->children = $this->_fillContainers($item['project']->getTree(), 0, false);
         $result[] = $o;
     }
     Response::jsonArray($result);
 }
Example #12
0
 /**
  * Get API tree.Panel data
  */
 public function apitreeAction()
 {
     Response::jsonArray($this->fileModel->getTreeList($this->versionIndex));
 }
Example #13
0
 public function projectlistAction()
 {
     $path = Request::post('node', 'string', '');
     $path = str_replace('.', '', $path);
     $dirPath = $this->_config->get('configs');
     if (!is_dir($dirPath)) {
         Response::jsonArray(array());
     }
     $files = File::scanFiles($dirPath . $path, array('.dat'), false, File::Files_Dirs);
     if (empty($files)) {
         Response::jsonArray(array());
     }
     $list = array();
     foreach ($files as $k => $fpath) {
         $text = basename($fpath);
         if ($text === '.svn') {
             continue;
         }
         $obj = new stdClass();
         $obj->id = str_replace($dirPath, '', $fpath);
         $obj->text = $text;
         if (is_dir($fpath)) {
             $obj->expanded = false;
             $obj->leaf = false;
         } else {
             $obj->leaf = true;
         }
         $list[] = $obj;
     }
     Response::jsonArray($list);
 }
Example #14
0
 /**
  * Get deploy history 
  */
 public function viewHistoryAction()
 {
     $serverId = Request::post('server_id', 'pagecode', '');
     $data = array();
     if (!strlen($serverId)) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     if (!is_dir($this->_deployConfig->get('datadir') . $serverId)) {
         Response::jsonArray($data);
     }
     $list = File::scanFiles($this->_deployConfig->get('datadir') . $serverId, false, false, File::Dirs_Only);
     if (!empty($list)) {
         foreach ($list as $k => $name) {
             $name = basename($name);
             $data[] = array('id' => $name, 'title' => $name);
         }
     }
     Response::jsonSuccess($data);
 }
Example #15
0
 /**
  * Get list of available renderers
  */
 public function renderersAction()
 {
     $data = array();
     $autoloaderPaths = $this->_configMain['autoloader'];
     $autoloaderPaths = $autoloaderPaths['paths'];
     $files = File::scanFiles($this->_config->get('components') . '/Renderer', array('.php'), true, File::Files_Only);
     $data[] = array('id' => '', 'title' => $this->_lang->NO);
     /**
      * This is hard fix for windows
      */
     if (DIRECTORY_SEPARATOR == '\\') {
         foreach ($files as &$v) {
             $v = str_replace('\\', '/', $v);
             $v = str_replace('//', '/', $v);
         }
         unset($v);
     }
     if (!empty($files)) {
         foreach ($files as $item) {
             $class = Utils::classFromPath(str_replace($autoloaderPaths, '', $item));
             $data[] = array('id' => $class, 'title' => str_replace($this->_config->get('components') . '/Renderer/', '', substr($item, 0, -4)));
         }
     }
     Response::jsonArray($data);
 }
Example #16
0
 /**
  * Get list of pages as a data tree config
  */
 public function treelistAction()
 {
     $pagesModel = Model::factory('Page');
     Response::jsonArray($pagesModel->getTreeList(array('id', 'parent_id', 'published', 'code')));
 }
Example #17
0
 /**
  * Files list
  * @return void
  */
 public function fslistAction()
 {
     $srcDirs = $this->_configMain['autoloader']['paths'];
     $list = array();
     foreach ($srcDirs as $dir) {
         $list = array_merge($list, File::scanFiles($dir, array('.php'), true));
     }
     foreach ($list as $k => &$fpath) {
         if (strpos($fpath, '/.svn')) {
             unset($list[$k]);
             continue;
         }
     }
     unset($fpath);
     $existingList = array();
     foreach ($this->_packagesConfig->get('packages') as $v) {
         $existingList = array_merge($existingList, $v['paths']);
     }
     $diff = array_diff($list, $existingList);
     $tree = Utils::fileListToTree($diff);
     $data = $this->_fillChilds($tree);
     Response::jsonArray($data);
 }
Example #18
0
 /**
  * Get grid columns as tree list
  */
 public function columnlisttreeAction()
 {
     Response::jsonArray($this->_object->getColumsList());
 }
Example #19
0
 /**
  * Inerface projects list
  */
 public function fslistAction()
 {
     $path = Request::post('node', 'string', '');
     $config = $config = Config::factory(Config::File_Array, $this->_configMain['configs'] . 'designer.php');
     $dirPath = $config->get('configs');
     $list = array();
     if (!is_dir($dirPath)) {
         Response::jsonArray(array());
     }
     if ($path === '') {
         if ($this->_configMain->get('allow_externals')) {
             $config = Config::factory(Config::File_Array, $this->_configMain->get('configs') . 'externals.php');
             $eExpert = new Externals_Expert($this->_configMain, $config);
             $extProjects = $eExpert->getProjects();
             if (!empty($extProjects)) {
                 foreach ($extProjects as $item) {
                     $list[] = $item;
                 }
             }
         }
         $path = $dirPath . $path;
     }
     $files = File::scanFiles($path, array('.dat'), false, File::Files_Dirs);
     /**
      * This is hard fix for windows
      */
     if (DIRECTORY_SEPARATOR == '\\') {
         foreach ($files as &$v) {
             $v = str_replace('\\', '/', $v);
             $v = str_replace('//', '/', $v);
         }
         unset($v);
     }
     if (empty($files)) {
         Response::jsonArray(array());
     }
     foreach ($files as $k => $fpath) {
         $text = basename($fpath);
         if ($text === '.svn') {
             continue;
         }
         $obj = new stdClass();
         $obj->id = str_replace($this->_configMain->get('docroot'), './', $fpath);
         $obj->text = $text;
         if (is_dir($fpath)) {
             $obj->expanded = false;
             $obj->leaf = false;
         } else {
             $obj->leaf = true;
         }
         $list[] = $obj;
     }
     Response::jsonArray($list);
 }
Example #20
0
 public function indexesAction()
 {
     $object = Request::post('object', 'string', false);
     if (!$object) {
         Response::jsonError($this->_lang->INVALID_VALUE);
     }
     try {
         $objectConfig = Db_Object_Config::getInstance($object);
     } catch (Exception $e) {
         Response::jsonError($this->_lang->INVALID_VALUE);
     }
     $indexsesCfg = $objectConfig->getIndexesConfig();
     foreach ($indexsesCfg as $k => &$v) {
         $v['columns'] = implode(', ', $v['columns']);
         $v['name'] = $k;
     }
     unset($v);
     Response::jsonArray(array_values($indexsesCfg));
 }