/**
  * Constructs a new scaffold manager
  * @param string $modelName Name of the model to scaffold
  * @param string $nameTranslation Translation key of the manager name
  * @param string $icon Path to the icon of the manager
  * @param boolean $isReadOnly Set to true to make the scaffolding read only
  * @param boolean|array $search Boolean to enable or disable the search functionality, an array of field names to query is also allowed to enable the search
  * @param boolean|array $order Boolean to enable or disable the order functionality, an array of field names to order is also allowed to enable the order
  * @param boolean|array $pagination Boolean to enable or disable the pagination functionality, an array of pagination options is also allowed to enable the pagination
  * @return null
  */
 public function __construct($modelName, $nameTranslation, $icon = null, $isReadOnly = false, $search = true, $order = true, $pagination = true)
 {
     parent::__construct($modelName, $isReadOnly, $search, $order, $pagination);
     $this->name = $this->getTranslator()->translate($nameTranslation);
     $this->icon = $icon;
     $this->translationTitle = $nameTranslation;
 }
 /**
  * Action to scaffold a model
  * @param string $modelName Name of the model to scaffold
  * @return null
  */
 public function scaffoldAction($modelName = null)
 {
     if (!SecurityManager::getInstance()->isPermissionAllowed(Module::PERMISSION_MODELS)) {
         $this->response->setRedirect($this->request->getBasePath());
         return;
     }
     if (!$modelName) {
         $this->response->setRedirect($this->request->getBasePath());
         return;
     }
     $controllerClass = ScaffoldController::generateScaffoldController($modelName);
     return $this->forward($controllerClass, null, 2);
 }
示例#3
0
 /**
  * Gets the index view for the scaffold
  * @param zibo\library\html\table\ExtendedTable $table Table with the model data
  * @param array $actions Array with the URL of the action as key and the label for the action as value
  * @return zibo\core\View
  */
 protected function getIndexView(ExtendedTable $table, array $actions = null)
 {
     $view = parent::getIndexView($table, $actions);
     if ($this->filterForm) {
         $filterView = new LogFilterView($this->filterForm);
         $view->getSidebar()->addPanel($filterView);
     }
     return $view;
 }
 /**
  * Gets a data table for the model
  * @param string $formAction URL where the table form will point to
  * @return zibo\library\html\table\Table
  */
 protected function getTable($formAction)
 {
     $table = parent::getTable($formAction);
     $table->addDecorator(new ZebraDecorator(new PermissionDecorator($this->request->getBasePath() . '/' . self::ACTION_EDIT . '/')));
     return $table;
 }
 /**
  * Gets a data table for the model
  * @param string $formAction URL where the table form will point to
  * @return zibo\library\html\table\ExtendedTable
  */
 protected function getTable($formAction)
 {
     $table = parent::getTable($formAction);
     $table->addDecorator(new ZebraDecorator(new UserDecorator($this->request->getBasePath() . '/' . self::ACTION_EDIT . '/')));
     if ($this->user && !$this->user->isSuperUser()) {
         $query = $table->getModelQuery();
         $query->setDistinct(true);
         $query->addCondition('{roles.isSuperRole} = 0 OR {roles.isSuperRole} IS NULL');
         $hiddenRoleIds = $this->getHiddenRoleIds();
         if ($hiddenRoleIds) {
             foreach ($hiddenRoleIds as $roleId) {
                 $query->addCondition('{roles.id} <> %1%', $roleId);
             }
         }
     }
     return $table;
 }