Example #1
0
 /**
  * Load the datagrids
  *
  * @return	void
  */
 private function loadDataGrids()
 {
     // load all categories
     $categories = BackendFaqModel::getCategories();
     // run over categories and create datagrid for each one
     foreach ($categories as $category) {
         // create datagrid
         $dataGrid = new BackendDataGridDB(BackendFaqModel::QRY_DATAGRID_BROWSE, array(BL::getWorkingLanguage(), $category['id']));
         // set attributes
         $dataGrid->setAttributes(array('class' => 'dataGrid sequenceByDragAndDrop'));
         // disable paging
         $dataGrid->setPaging(false);
         // set colum URLs
         $dataGrid->setColumnURL('question', BackendModel::createURLForAction('edit') . '&id=[id]');
         // set colums hidden
         $dataGrid->setColumnsHidden(array('category_id', 'sequence'));
         // add edit column
         $dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit') . '&id=[id]', BL::lbl('Edit'));
         // add a column for the handle, so users have something to hold while draging
         $dataGrid->addColumn('dragAndDropHandle', null, '<span>' . BL::lbl('Move') . '</span>');
         // make sure the column with the handler is the first one
         $dataGrid->setColumnsSequence('dragAndDropHandle');
         // add a class on the handler column, so JS knows this is just a handler
         $dataGrid->setColumnAttributes('dragAndDropHandle', array('class' => 'dragAndDropHandle'));
         // our JS needs to know an id, so we can send the new order
         $dataGrid->setRowAttributes(array('id' => '[id]'));
         // add datagrid to list
         $this->dataGrids[] = array('id' => $category['id'], 'name' => $category['name'], 'content' => $dataGrid->getContent());
     }
 }
Example #2
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));
 }