Backend\Modules\Blog\Actions\Index::loadDataGridAllPosts PHP Method

loadDataGridAllPosts() private method

Loads the datagrid with all the posts
private loadDataGridAllPosts ( )
    private function loadDataGridAllPosts()
    {
        // filter on category?
        if ($this->categoryId != null) {
            // create datagrid
            $this->dgPosts = new BackendDataGridDB(BackendBlogModel::QRY_DATAGRID_BROWSE_FOR_CATEGORY, array($this->categoryId, 'active', BL::getWorkingLanguage()));
            // set the URL
            $this->dgPosts->setURL('&category=' . $this->categoryId, true);
        } else {
            // create datagrid
            $this->dgPosts = new BackendDataGridDB(BackendBlogModel::QRY_DATAGRID_BROWSE, array('active', BL::getWorkingLanguage()));
        }
        // set headers
        $this->dgPosts->setHeaderLabels(array('user_id' => \SpoonFilter::ucfirst(BL::lbl('Author')), 'publish_on' => \SpoonFilter::ucfirst(BL::lbl('PublishedOn'))));
        // hide columns
        $this->dgPosts->setColumnsHidden(array('revision_id'));
        // sorting columns
        $this->dgPosts->setSortingColumns(array('publish_on', 'title', 'user_id', 'comments'), 'publish_on');
        $this->dgPosts->setSortParameter('desc');
        // set column functions
        $this->dgPosts->setColumnFunction(array(new BackendDataGridFunctions(), 'getLongDate'), array('[publish_on]'), 'publish_on', true);
        $this->dgPosts->setColumnFunction(array(new BackendDataGridFunctions(), 'getUser'), array('[user_id]'), 'user_id', true);
        // our JS needs to know an id, so we can highlight it
        $this->dgPosts->setRowAttributes(array('id' => 'row-[revision_id]'));
        // check if this action is allowed
        if (BackendAuthentication::isAllowedAction('Edit')) {
            // set column URLs
            $this->dgPosts->setColumnURL('title', BackendModel::createURLForAction('Edit') . '&id=[id]&category=' . $this->categoryId);
            // add edit column
            $this->dgPosts->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('Edit') . '&id=[id]&category=' . $this->categoryId, BL::lbl('Edit'));
        }
    }