public function view()
 {
     if (!$this->loadData()) {
         $this->dataError();
         sendBack();
     }
     $modulecomponent = $this->_uses[$this->modeltype];
     $this->addSidebar($modulecomponent);
     switch ($modulecomponent->type) {
         case 'C':
             // set actions as an array with a null first value
             $actions = array('' => '');
             // fetch the methods for the controller
             $actions['Local Methods'] = get_final_class_methods($modulecomponent->name);
             // fetch the inherited methods
             $inherited_methods = get_class_methods($modulecomponent->name);
             $inherited_methods = array_combine($inherited_methods, $inherited_methods);
             $actions['Inherited Methods'] = array_diff($inherited_methods, $actions['Local Methods']);
             natcasesort($actions['Local Methods']);
             natcasesort($actions['Inherited Methods']);
             $this->view->set('local_methods', $actions['Local Methods']);
             $this->view->set('inherited_methods', $actions['Inherited Methods']);
             if (is_null($modulecomponent->title)) {
                 $modulecomponent->title = $modulecomponent->name;
             }
             $this->view->set('internal_type', 'Controller');
             //				$this->view->set('version', $model->version());
             break;
         case 'M':
             $model = new $modulecomponent->name();
             $fields = $model->getFields();
             $current_defaults = array();
             foreach ($modulecomponent->module_defaults as $default) {
                 $current_defaults[$default->field_name] = $default->id;
             }
             foreach ($fields as $field) {
                 if (isset($current_defaults[$field->name])) {
                     $field->id = $current_defaults[$field->name];
                 }
             }
             $this->view->set('model_class', $model);
             $this->view->set('models', array($modulecomponent->name => $model));
             $this->view->set('fields', $fields);
             $this->view->set('type', 'display');
             if (is_null($modulecomponent->title)) {
                 $modulecomponent->title = $model->getTitle();
             }
             if ($model instanceof DataObject) {
                 $this->view->set('internal_type', 'DataObject');
                 $this->view->set('system_policies', $modulecomponent->system_policies);
             } elseif ($model instanceof DataObjectCollection) {
                 $this->view->set('internal_type', 'DataObjectCollection');
             }
             $this->view->set('version', $model->version());
             break;
         case 'T':
             $controllername = $modulecomponent->controller . 'Controller';
             $controller = new $controllername('', $this->view);
             $this->view->set('models', $controller->usesModels());
             $this->view->set('type', 'input');
         default:
             $this->view->set('models', array());
     }
     $this->view->set('moduledefault', DataObjectFactory::Factory('ModuleDefault'));
 }
示例#2
0
 public function get_action_list($controller_id = '')
 {
     if (is_ajax() && is_direct_request()) {
         $controller_id = $this->_data['controller_id'];
     }
     $html = '';
     // attempt to load the controller based on the controller id
     $module_components = new ModuleComponent();
     $module_components->load($controller_id);
     // if the component hs loaded it must mean we were dealing with an id
     // set the controller_id to the controller name
     if ($module_components->loaded) {
         $controller_id = $module_components->name;
     }
     // set actions as an array with a null first value
     $actions = array('' => '');
     // fetch the methods for the controller
     $actions['Local Methods'] = get_final_class_methods($controller_id);
     // fetch the inherited methods
     $inherited_methods = get_class_methods($controller_id);
     $inherited_methods = array_combine($inherited_methods, $inherited_methods);
     $actions['Inherited Methods'] = array_diff($inherited_methods, $actions['Local Methods']);
     if (is_ajax() && is_direct_request()) {
         $output['action'] = array('data' => $actions, 'is_array' => is_array($actions));
         $this->view->set('data', $output);
         $this->setTemplateName('ajax_multiple');
     } else {
         return $actions;
     }
 }