Example #1
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 #2
0
 /**
  * Get controllers list for tree 
  * @return array
  */
 public function getControllersTree()
 {
     $data = array();
     foreach ($this->_configs as $path => $config) {
         if (isset($config['CLASSES'])) {
             foreach ($config['CLASSES'] as $name => $srcPath) {
                 if (substr($name, -10) == 'Controller') {
                     if (strpos($name, 'Frontend') === 0) {
                         $data[$config['INFO']['namespace']][$config['INFO']['name']]['Frontend'][] = $name;
                     } elseif (strpos($name, 'Backend') === 0) {
                         $data[$config['INFO']['namespace']][$config['INFO']['name']]['Backend'][] = $name;
                     }
                 }
             }
         }
     }
     $objRoot = '';
     if (!empty($data)) {
         foreach ($data as $vendor => $module) {
             $vendorItems = array();
             foreach ($module as $name => $item) {
                 $moduleItems = array();
                 if (isset($item['Frontend'])) {
                     $obj = new stdClass();
                     $obj->id = $this->_externalsPath . $vendor . '/' . $name . '/frontend/';
                     $obj->text = 'Frontend';
                     $obj->expanded = false;
                     $obj->leaf = false;
                     $classList = array();
                     foreach ($item['Frontend'] as $class) {
                         $obj2 = new stdClass();
                         $obj2->id = $class;
                         $obj2->text = $class;
                         $obj2->leaf = true;
                         $obj2->url = Backend_Designer_Code::getControllerUrl($class);
                         $classList[] = $obj2;
                     }
                     $obj->children = $classList;
                     $moduleItems[] = $obj;
                 }
                 if (isset($item['Backend'])) {
                     $obj = new stdClass();
                     $obj->id = $this->_externalsPath . $vendor . '/' . $name . '/backend/';
                     $obj->text = 'Backend';
                     $obj->expanded = false;
                     $obj->leaf = false;
                     $classList = array();
                     foreach ($item['Backend'] as $class) {
                         $obj2 = new stdClass();
                         $obj2->id = $class;
                         $obj2->text = $class;
                         $obj2->leaf = true;
                         $obj2->url = Backend_Designer_Code::getControllerUrl($class);
                         $classList[] = $obj2;
                     }
                     $obj->children = $classList;
                     $moduleItems[] = $obj;
                 }
                 $obj = new stdClass();
                 $obj->id = $this->_externalsPath . $vendor . '/' . $name;
                 $obj->text = $name;
                 $obj->expanded = false;
                 $obj->leaf = false;
                 $obj->children = $moduleItems;
                 $vendorItems[] = $obj;
             }
             $obj = new stdClass();
             $obj->id = $this->_externalsPath . $vendor;
             $obj->text = $vendor;
             $obj->expanded = false;
             $obj->leaf = false;
             $obj->children = $vendorItems;
         }
         $objRoot = new stdClass();
         $objRoot->id = 'externalroot';
         $objRoot->text = Lang::lang()->get('EXTERNAL');
         $objRoot->expanded = false;
         $objRoot->leaf = false;
         $objRoot->children = array($obj);
     }
     return $objRoot;
 }