Ejemplo n.º 1
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.º 2
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.º 3
0
 /**
  * Load the datagrids
  */
 private function loadDataGrids()
 {
     /*
      * Frontend datagrid
      */
     $nonExistingFrontendLocale = BackendLocaleModel::getNonExistingFrontendLocale(BL::getWorkingLanguage());
     $this->dgFrontend = new BackendDataGridArray($nonExistingFrontendLocale);
     // overrule default URL
     $this->dgFrontend->setURL(BackendModel::createURLForAction(null, null, null, array('offset' => '[offset]', 'order' => '[order]', 'sort' => '[sort]'), false));
     // sorting columns
     $this->dgFrontend->setSortingColumns(array('language', 'application', 'module', 'type', 'name'), 'name');
     // check if this action is allowed
     if (BackendAuthentication::isAllowedAction('Add')) {
         // set column URLs
         $this->dgFrontend->setColumnURL('name', BackendModel::createURLForAction('Add') . '&language=[language]&application=[application]&module=[module]&type=[type]&name=[name]');
     }
     // set column functions
     $this->dgFrontend->setColumnFunction(array(__CLASS__, 'formatFilesList'), '[used_in]', 'used_in', true);
     // check if this action is allowed
     if (BackendAuthentication::isAllowedAction('SaveTranslation')) {
         // add columns
         $this->dgFrontend->addColumn('translation', null, null, null, BL::lbl('Add'));
         // add a class for the inline edit
         $this->dgFrontend->setColumnAttributes('translation', array('class' => 'translationValue'));
         // add attributes, so the inline editing has all the needed data
         $this->dgFrontend->setColumnAttributes('translation', array('data-id' => '{language: \'[language]\', application: \'[application]\', module: \'[module]\', name: \'[name]\', type: \'[type]\'}'));
         $this->dgFrontend->setColumnAttributes('translation', array('style' => 'width: 150px'));
     }
     // disable paging
     $this->dgFrontend->setPaging(false);
     /*
      * Backend datagrid
      */
     $getNonExistingBackendLocale = BackendLocaleModel::getNonExistingBackendLocale(BL::getWorkingLanguage());
     $this->dgBackend = new BackendDataGridArray($getNonExistingBackendLocale);
     // overrule default URL
     $this->dgBackend->setURL(BackendModel::createURLForAction(null, null, null, array('offset' => '[offset]', 'order' => '[order]', 'sort' => '[sort]'), false));
     // sorting columns
     $this->dgBackend->setSortingColumns(array('language', 'application', 'module', 'type', 'name'), 'name');
     // check if this action is allowed
     if (BackendAuthentication::isAllowedAction('Add')) {
         // set column URLs
         $this->dgBackend->setColumnURL('name', BackendModel::createURLForAction('Add') . '&language=[language]&application=[application]&module=[module]&type=[type]&name=[name]');
     }
     // set column functions
     $this->dgBackend->setColumnFunction(array(__CLASS__, 'formatFilesList'), '[used_in]', 'used_in', true);
     // check if this action is allowed
     if (BackendAuthentication::isAllowedAction('SaveTranslation')) {
         // add columns
         $this->dgBackend->addColumn('translation', null, null, null, BL::lbl('Add'));
         // add a class for the inline edit
         $this->dgBackend->setColumnAttributes('translation', array('class' => 'translationValue'));
         // add attributes, so the inline editing has all the needed data
         $this->dgBackend->setColumnAttributes('translation', array('data-id' => '{language: \'[language]\', application: \'[application]\', module: \'[module]\', name: \'[name]\', type: \'[type]\'}'));
         $this->dgBackend->setColumnAttributes('translation', array('style' => 'width: 150px'));
     }
     // disable paging
     $this->dgBackend->setPaging(false);
 }
Ejemplo n.º 4
0
 /**
  * Load the data grid which contains the cronjobs.
  */
 private function loadDataGridCronjobs()
 {
     // no cronjobs = don't bother
     if (!isset($this->information['cronjobs'])) {
         return;
     }
     // create data grid
     $this->dataGridCronjobs = new BackendDataGridArray($this->information['cronjobs']);
     // hide columns
     $this->dataGridCronjobs->setColumnsHidden(array('minute', 'hour', 'day-of-month', 'month', 'day-of-week', 'action', 'description', 'active'));
     // add cronjob data column
     $this->dataGridCronjobs->addColumn('cronjob', BL::getLabel('Cronjob'), '[description]<br /><strong>[minute] [hour] [day-of-month] [month] [day-of-week]</strong> php ' . PATH_WWW . '/backend/cronjob module=<strong>' . $this->currentModule . '</strong> action=<strong>[action]</strong>', null, null, null, 0);
     // no paging
     $this->dataGridCronjobs->setPaging(false);
 }
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);
 }
Ejemplo n.º 6
0
 /**
  * Load the datagrid for unsubscriptions
  */
 private function loadUnsubscriptions()
 {
     // get results
     $results = BackendMailmotorModel::getRecentUnsubscriptions(self::PAGING_LIMIT);
     // there are some results
     if (!empty($results)) {
         $dataGrid = new BackendDataGridArray($results);
         $dataGrid->setPaging(false);
         $dataGrid->setColumnFunction(array(new BackendDataGridFunctions(), 'getTimeAgo'), array('[unsubscribed_on]'), 'unsubscribed_on', true);
         // check if this action is allowed
         if (BackendAuthentication::isAllowedAction('EditAddress')) {
             $dataGrid->setColumnURL('email', BackendModel::createURLForAction('EditAddress', 'Mailmotor') . '&amp;email=[email]');
         }
         // parse the datagrid
         $this->tpl->assign('dgMailmotorUnsubscriptions', $dataGrid->getContent());
     }
 }