getCategories() public static method

Get all categories
public static getCategories ( boolean $includeCount = false ) : array
$includeCount boolean Include the count?
return array
Beispiel #1
0
 /**
  * Load the form
  */
 private function loadForm()
 {
     $this->imageIsAllowed = $this->get('fork.settings')->get($this->URL->getModule(), 'show_image_form', true);
     $this->frm = new BackendForm('add');
     // set hidden values
     $rbtHiddenValues[] = array('label' => BL::lbl('Hidden', $this->URL->getModule()), 'value' => 'Y');
     $rbtHiddenValues[] = array('label' => BL::lbl('Published'), 'value' => 'N');
     // get categories
     $categories = BackendBlogModel::getCategories();
     $categories['new_category'] = \SpoonFilter::ucfirst(BL::getLabel('AddCategory'));
     // create elements
     $this->frm->addText('title', null, null, 'inputText title', 'inputTextError title');
     $this->frm->addEditor('text');
     $this->frm->addEditor('introduction');
     $this->frm->addRadiobutton('hidden', $rbtHiddenValues, 'N');
     $this->frm->addCheckbox('allow_comments', $this->get('fork.settings')->get($this->getModule(), 'allow_comments', false));
     $this->frm->addDropdown('category_id', $categories, \SpoonFilter::getGetValue('category', null, null, 'int'));
     if (count($categories) != 2) {
         $this->frm->getField('category_id')->setDefaultElement('');
     }
     $this->frm->addDropdown('user_id', BackendUsersModel::getUsers(), BackendAuthentication::getUser()->getUserId());
     $this->frm->addText('tags', null, null, 'inputText tagBox', 'inputTextError tagBox');
     $this->frm->addDate('publish_on_date');
     $this->frm->addTime('publish_on_time');
     if ($this->imageIsAllowed) {
         $this->frm->addImage('image');
     }
     // meta
     $this->meta = new BackendMeta($this->frm, null, 'title', true);
 }
Beispiel #2
0
 /**
  * Parse all datagrids
  */
 protected function parse()
 {
     parent::parse();
     // parse the datagrid for the drafts
     $this->tpl->assign('dgDrafts', (string) $this->dgDrafts->getContent());
     // parse the datagrid for all blogposts
     $this->tpl->assign('dgPosts', (string) $this->dgPosts->getContent());
     // parse the datagrid for the most recent blogposts
     $this->tpl->assign('dgRecent', is_object($this->dgRecent) ? $this->dgRecent->getContent() : false);
     // get categories
     $categories = BackendBlogModel::getCategories(true);
     $hasMultipleCategories = count($categories) > 1;
     $this->tpl->assign('hasMultipleCategories', $hasMultipleCategories);
     // multiple categories?
     if ($hasMultipleCategories) {
         // create form
         $frm = new BackendForm('filter', null, 'get', false);
         // create element
         $frm->addDropdown('category', $categories, $this->categoryId);
         $frm->getField('category')->setDefaultElement('');
         // parse the form
         $frm->parse($this->tpl);
     }
     // parse category
     if (!empty($this->category)) {
         $this->tpl->assign('filterCategory', $this->category);
     }
 }
Beispiel #3
0
 /**
  * Load the form
  */
 private function loadForm()
 {
     // create form
     $this->frm = new BackendForm('edit');
     // set hidden values
     $rbtHiddenValues[] = array('label' => BL::lbl('Hidden'), 'value' => 'Y');
     $rbtHiddenValues[] = array('label' => BL::lbl('Published'), 'value' => 'N');
     // get categories
     $categories = BackendBlogModel::getCategories();
     $categories['new_category'] = \SpoonFilter::ucfirst(BL::getLabel('AddCategory'));
     // create elements
     $this->frm->addText('title', $this->record['title'], null, 'inputText title', 'inputTextError title');
     $this->frm->addEditor('text', $this->record['text']);
     $this->frm->addEditor('introduction', $this->record['introduction']);
     $this->frm->addRadiobutton('hidden', $rbtHiddenValues, $this->record['hidden']);
     $this->frm->addCheckbox('allow_comments', $this->record['allow_comments'] === 'Y' ? true : false);
     $this->frm->addDropdown('category_id', $categories, $this->record['category_id']);
     if (count($categories) != 2) {
         $this->frm->getField('category_id')->setDefaultElement('');
     }
     $this->frm->addDropdown('user_id', BackendUsersModel::getUsers(), $this->record['user_id']);
     $this->frm->addText('tags', BackendTagsModel::getTags($this->URL->getModule(), $this->record['id']), null, 'inputText tagBox', 'inputTextError tagBox');
     $this->frm->addDate('publish_on_date', $this->record['publish_on']);
     $this->frm->addTime('publish_on_time', date('H:i', $this->record['publish_on']));
     if ($this->imageIsAllowed) {
         $this->frm->addImage('image');
         $this->frm->addCheckbox('delete_image');
     }
     // meta object
     $this->meta = new BackendMeta($this->frm, $this->record['meta_id'], 'title', true);
     // set callback for generating a unique URL
     $this->meta->setUrlCallback('Backend\\Modules\\Blog\\Engine\\Model', 'getURL', array($this->record['id']));
 }