public function action_admin_list() { //-------------------------- // Datagrid configuration //-------------------------- $ColumnSets = array(); $ColumnSets[] = array('Alias' => 'Select', 'ResultSet' => 'cat_id', 'Name' => _('[x]'), 'Type' => 'Checkbox'); $ColumnSets[] = array('Alias' => 'Name', 'ResultSet' => array('name' => 'name', 'id' => 'cat_id'), 'Name' => _('Name'), 'Sort' => 'DESC', 'SortCol' => 'name', 'Type' => 'Link'); $ColumnSets[] = array('Alias' => 'Description', 'ResultSet' => 'description', 'Name' => _('Description'), 'Sort' => 'DESC', 'SortCol' => 'description', 'Type' => 'String'); $ColumnSets[] = array('Alias' => 'Module', 'ResultSet' => 'module', 'Name' => _('Module'), 'Sort' => 'DESC', 'SortCol' => 'module', 'Type' => 'String'); $ColumnSets[] = array('Alias' => 'Image', 'ResultSet' => 'image', 'Name' => _('Image'), 'Type' => 'Image'); $ColumnSets[] = array('Alias' => 'Icon', 'ResultSet' => 'icon', 'Name' => _('Icon'), 'Type' => 'Image'); $ColumnSets[] = array('Alias' => 'Color', 'ResultSet' => 'color', 'Name' => _('Color'), 'Sort' => 'DESC', 'SortCol' => 'color', 'Type' => 'String'); // Batchactions $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('Datatable' => Doctrine::getTable('CsCategories'), 'NamedQuery' => 'fetchAllCategories', 'ColumnSets' => $ColumnSets, 'url' => 'index.php?mod=categories&sub=admin')); $datagrid->setBatchActions($BatchActions); $datagrid->disableFeature(array('Label', 'Caption', 'Description')); $datagrid->getColumn('Select')->disableFeature('Search'); $datagrid->getColumn('Name')->getRenderer()->linkFormat = '&action=edit&id=%{id}'; $datagrid->getColumn('Name')->getRenderer()->linkTitle = _('Edit this category'); // Assign to tpl $this->getView()->assign('datagrid', $datagrid->render()); $this->display(); }
/** * 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(); }