Ejemplo n.º 1
0
 /**
  * Clansuite_Module_News_Admin -> action_admin_index()
  *
  * Show all news entries and give the possibility to edit/delete
  * Show DropDown with possibility to select the news category
  */
 public function action_admin_index()
 {
     // Get Render Engine
     $view = $this->getView();
     //--------------------------
     // Datagrid configuration
     //--------------------------
     $ColumnSets = array();
     $ColumnSets[] = array('Alias' => 'Select', 'ResultSet' => 'news_id', 'Name' => '[x]', 'Type' => 'Checkbox');
     $ColumnSets[] = array('Alias' => 'Title', 'ResultSet' => array('name' => 'news_title', 'id' => 'news_id', 'comments' => 'nr_news_comments'), 'Name' => _('Title'), 'Sort' => 'DESC', 'SortCol' => 'news_title', 'Type' => 'Link');
     $ColumnSets[] = array('Alias' => 'Preview', 'ResultSet' => array('preview' => 'news_preview', 'body' => 'news_body'), 'Name' => _('Preview'), 'Sort' => 'DESC', 'SortCol' => 'news_body', 'Type' => 'String');
     $ColumnSets[] = array('Alias' => 'Date', 'ResultSet' => 'created_at', 'Name' => _('Created at'), 'Sort' => 'DESC', 'SortCol' => 'created_at', 'Type' => 'Date');
     $ColumnSets[] = array('Alias' => 'Category', 'ResultSet' => 'CsCategories.name', 'Name' => _('Category'), 'Sort' => 'DESC', 'SortCol' => 'c.name', 'Type' => 'String');
     $ColumnSets[] = array('Alias' => 'Status', 'ResultSet' => 'news_status', 'Name' => _('Status'), 'Sort' => 'DESC', 'SortCol' => 'news_status', 'Type' => 'Integer');
     $ColumnSets[] = array('Alias' => 'User', 'ResultSet' => array('CsUsers.email', 'CsUsers.nick'), 'Name' => _('User'), 'Sort' => 'DESC', 'SortCol' => 'u.nick', 'Type' => 'Email');
     /*$ColumnSets[] = array(  'Alias'     => 'Action',
       'ResultSet' => 'news_id',
       'Name'      => _('Action'),
       'Type'      => 'Editbutton' );*/
     $BatchActions = array();
     $BatchActions[] = array('Alias' => 'create', 'Name' => _('Create a news'), 'Action' => 'create');
     $BatchActions[] = array('Alias' => 'delete', 'Name' => _('Delete selected items'), 'Action' => 'delete');
     // Instantiate the datagrid
     $datagrid = new Clansuite_Datagrid(array('Entity' => $this->getEntityNameFromClassname(), 'ColumnSets' => $ColumnSets, 'Url' => '?mod=news&sub=admin'));
     $datagrid->setBatchActions($BatchActions);
     $datagrid->getColumn('Select')->disableFeature('Search');
     $datagrid->getColumn('Title')->getRenderer()->linkFormat = '&action=edit&id=%{id}';
     $datagrid->getColumn('Title')->getRenderer()->linkTitle = _('Edit this news');
     $datagrid->getColumn('Title')->getRenderer()->nameFormat = '%{name} - %{comments} Comment(s)';
     $datagrid->getColumn('Preview')->disableFeature('Sorting');
     $datagrid->getColumn('Preview')->getRenderer()->stringFormat = '<div title="%{body}">%{preview}</div>';
     $datagrid->modifyResultSetViaHook($this, 'manipulateResultSet');
     $datagrid->setResultsPerPage(self::getConfigValue('resultsPerPage_adminshow', '5'));
     // Assing datagrid
     $view->assign('datagrid', $datagrid->render());
     $this->display();
 }