Ejemplo n.º 1
0
 /**
  * Loads the dataGrids
  */
 private function loadDatagrids()
 {
     // load all categories
     $categories = BackendFaqModel::getCategories(true);
     // loop categories and create a dataGrid for each one
     foreach ($categories as $categoryId => $categoryTitle) {
         $dataGrid = new BackendDataGridDB(BackendFaqModel::QRY_DATAGRID_BROWSE, array(BL::getWorkingLanguage(), $categoryId));
         $dataGrid->setAttributes(array('class' => 'dataGrid sequenceByDragAndDrop'));
         $dataGrid->setColumnsHidden(array('category_id', 'sequence'));
         $dataGrid->addColumn('dragAndDropHandle', null, '<span>' . BL::lbl('Move') . '</span>');
         $dataGrid->setColumnsSequence('dragAndDropHandle');
         $dataGrid->setColumnAttributes('question', array('class' => 'title'));
         $dataGrid->setColumnAttributes('dragAndDropHandle', array('class' => 'dragAndDropHandle'));
         $dataGrid->setRowAttributes(array('id' => '[id]'));
         // check if this action is allowed
         if (BackendAuthentication::isAllowedAction('Edit')) {
             $dataGrid->setColumnURL('question', BackendModel::createURLForAction('Edit') . '&amp;id=[id]');
             $dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('Edit') . '&amp;id=[id]', BL::lbl('Edit'));
         }
         // add dataGrid to list
         $this->dataGrids[] = array('id' => $categoryId, 'title' => $categoryTitle, 'content' => $dataGrid->getContent());
     }
     // set empty datagrid
     $this->emptyDatagrid = new BackendDataGridArray(array(array('dragAndDropHandle' => '', 'question' => BL::msg('NoQuestionInCategory'), 'edit' => '')));
     $this->emptyDatagrid->setAttributes(array('class' => 'dataGrid sequenceByDragAndDrop emptyGrid'));
     $this->emptyDatagrid->setHeaderLabels(array('edit' => null, 'dragAndDropHandle' => null));
 }
Ejemplo n.º 2
0
 /**
  * Load the datagrid
  */
 private function loadDataGrid()
 {
     // init var
     $items = array();
     // get modules
     $modules = BackendModel::getModules();
     // loop modules
     foreach ($modules as $module) {
         // build class name
         $className = 'Backend\\Modules\\' . $module . '\\Engine\\Model';
         if ($module == 'Core') {
             $className = 'Backend\\Core\\Engine\\Model';
         }
         // check if the getByTag-method is available
         if (is_callable(array($className, 'getByTag'))) {
             // make the call and get the item
             $moduleItems = (array) call_user_func(array($className, 'getByTag'), $this->id);
             // loop items
             foreach ($moduleItems as $row) {
                 // check if needed fields are available
                 if (isset($row['url'], $row['name'], $row['module'])) {
                     // add
                     $items[] = array('module' => \SpoonFilter::ucfirst(BL::lbl(\SpoonFilter::toCamelCase($row['module']))), 'name' => $row['name'], 'url' => $row['url']);
                 }
             }
         }
     }
     // create datagrid
     $this->dgUsage = new BackendDataGridArray($items);
     $this->dgUsage->setPaging(false);
     $this->dgUsage->setColumnsHidden(array('url'));
     $this->dgUsage->setHeaderLabels(array('name' => \SpoonFilter::ucfirst(BL::lbl('Title')), 'url' => ''));
     $this->dgUsage->setColumnURL('name', '[url]', \SpoonFilter::ucfirst(BL::lbl('Edit')));
     $this->dgUsage->addColumn('edit', null, \SpoonFilter::ucfirst(BL::lbl('Edit')), '[url]', BL::lbl('Edit'));
 }
Ejemplo n.º 3
0
 /**
  * Load the data grid which contains the events.
  */
 private function loadDataGridTemplates()
 {
     // no hooks so don't bother
     if (!isset($this->information['templates'])) {
         return;
     }
     // build data for display in datagrid
     $templates = array();
     foreach ($this->information['templates'] as $template) {
         // set template name & path
         $record['name'] = $template['label'];
         $record['path'] = $template['path'];
         // set positions
         $record['positions'] = array();
         foreach ($template['positions'] as $position) {
             $record['positions'][] = $position['name'];
         }
         $record['positions'] = implode(', ', $record['positions']);
         // add template to list
         $templates[] = $record;
     }
     // create data grid
     $this->dataGridTemplates = new BackendDataGridArray($templates);
     // add label for path
     $this->dataGridTemplates->setHeaderLabels(array('path' => BL::msg('PathToTemplate')));
     // no paging
     $this->dataGridTemplates->setPaging(false);
 }
Ejemplo n.º 4
0
 /**
  * Load the data grid for installable modules.
  */
 private function loadDataGridInstallable()
 {
     // create datagrid
     $this->dataGridInstallableModules = new BackendDataGridArray($this->installableModules);
     $this->dataGridInstallableModules->setSortingColumns(array('raw_name'));
     $this->dataGridInstallableModules->setHeaderLabels(array('raw_name' => \SpoonFilter::ucfirst(BL::getLabel('Name'))));
     $this->dataGridInstallableModules->setColumnsHidden(array('installed', 'name', 'cronjobs_active'));
     // check if this action is allowed
     if (BackendAuthentication::isAllowedAction('DetailModule')) {
         $this->dataGridInstallableModules->setColumnURL('raw_name', BackendModel::createURLForAction('DetailModule') . '&amp;module=[raw_name]');
         $this->dataGridInstallableModules->addColumn('details', null, BL::lbl('Details'), BackendModel::createURLForAction('DetailModule') . '&amp;module=[raw_name]', BL::lbl('Details'));
     }
     // check if this action is allowed
     if (BackendAuthentication::isAllowedAction('InstallModule')) {
         // add install column
         $this->dataGridInstallableModules->addColumn('install', null, BL::lbl('Install'), BackendModel::createURLForAction('InstallModule') . '&amp;module=[raw_name]', BL::lbl('Install'));
         $this->dataGridInstallableModules->setColumnConfirm('install', sprintf(BL::msg('ConfirmModuleInstall'), '[raw_name]'), null, \SpoonFilter::ucfirst(BL::lbl('Install')) . '?');
     }
 }
Ejemplo n.º 5
0
 /**
  * Load the form
  */
 private function loadForm()
 {
     $this->frm = new BackendForm('edit');
     // get selected permissions
     $modulePermissions = BackendGroupsModel::getModulePermissions($this->id);
     $actionPermissions = BackendGroupsModel::getActionPermissions($this->id);
     // add selected modules to array
     foreach ($modulePermissions as $permission) {
         $selectedModules[] = $permission['module'];
     }
     // loop through modules
     foreach ($this->modules as $key => $module) {
         // widgets available?
         if (isset($this->widgets)) {
             // loop through widgets
             foreach ($this->widgets as $j => $widget) {
                 // widget is present?
                 if (isset($this->dashboardSequence[$module['value']][$widget['value']]['present']) && $this->dashboardSequence[$module['value']][$widget['value']]['present'] === true && $widget['checkbox_name'] == $module['value'] . $widget['value']) {
                     $selectedWidgets[$j] = $widget['checkbox_name'];
                 }
                 // add widget checkboxes
                 $widgetBoxes[$j]['checkbox'] = '<span>' . $this->frm->addCheckbox('widgets_' . $widget['checkbox_name'], isset($selectedWidgets[$j]) ? $selectedWidgets[$j] : null)->parse() . '</span>';
                 $widgetBoxes[$j]['module'] = \SpoonFilter::ucfirst(BL::lbl($widget['module_name']));
                 $widgetBoxes[$j]['widget'] = '<label for="widgets' . \SpoonFilter::toCamelCase($widget['label']) . '">' . $widget['label'] . '</label>';
                 $widgetBoxes[$j]['description'] = $widget['description'];
             }
         }
         $selectedActions = array();
         // loop through action permissions
         foreach ($actionPermissions as $permission) {
             // add to selected actions
             if ($permission['module'] == $module['value']) {
                 $selectedActions[] = $permission['action'];
             }
         }
         // add module labels
         $permissionBoxes[$key]['label'] = $module['label'];
         // init var
         $addedBundles = array();
         // loop through actions
         foreach ($this->actions[$module['value']] as $i => $action) {
             // action is bundled?
             if (array_key_exists('group', $action)) {
                 // bundle not yet in array?
                 if (!in_array($action['group'], $addedBundles)) {
                     // assign bundled action boxes
                     $actionBoxes[$key]['actions'][$i]['checkbox'] = $this->frm->addCheckbox('actions_' . $module['label'] . '_' . 'Group_' . \SpoonFilter::ucfirst($action['group']), in_array($action['value'], $selectedActions))->parse();
                     $actionBoxes[$key]['actions'][$i]['action'] = \SpoonFilter::ucfirst($action['group']);
                     $actionBoxes[$key]['actions'][$i]['description'] = $this->actionGroups[$action['group']];
                     // add the group to the added bundles
                     $addedBundles[] = $action['group'];
                 }
             } else {
                 // assign action boxes
                 $actionBoxes[$key]['actions'][$i]['checkbox'] = $this->frm->addCheckbox('actions_' . $module['label'] . '_' . $action['label'], in_array($action['value'], $selectedActions))->parse();
                 $actionBoxes[$key]['actions'][$i]['action'] = '<label for="actions' . \SpoonFilter::toCamelCase($module['label'] . '_' . $action['label']) . '">' . $action['label'] . '</label>';
                 $actionBoxes[$key]['actions'][$i]['description'] = $action['description'];
             }
         }
         // widgetboxes available?
         if (isset($widgetBoxes)) {
             // create datagrid
             $widgetGrid = new BackendDataGridArray($widgetBoxes);
             $widgetGrid->setHeaderLabels(array('checkbox' => '<span class="checkboxHolder"><input id="toggleChecksWidgets" type="checkbox" name="toggleChecks" value="toggleChecks" /></span>'));
             // get content
             $widgets = $widgetGrid->getContent();
         }
         // create datagrid
         $actionGrid = new BackendDataGridArray($actionBoxes[$key]['actions']);
         // disable paging
         $actionGrid->setPaging(false);
         // get content of datagrids
         $permissionBoxes[$key]['actions']['dataGrid'] = $actionGrid->getContent();
         $permissionBoxes[$key]['chk'] = $this->frm->addCheckbox($module['label'], null, 'inputCheckbox checkBeforeUnload selectAll')->parse();
         $permissionBoxes[$key]['id'] = \SpoonFilter::toCamelCase($module['label']);
     }
     // create elements
     $this->frm->addText('name', $this->record['name']);
     $this->frm->addDropdown('manage_users', array('Deny', 'Allow'));
     $this->frm->addDropdown('manage_groups', array('Deny', 'Allow'));
     $this->tpl->assign('permissions', $permissionBoxes);
     $this->tpl->assign('widgets', isset($widgets) ? $widgets : false);
 }