public function action_admin_list()
 {
     // fetch modulenames as numeric indexed array
     $modules = Clansuite_ModuleInfoController::getModuleNames(false, true);
     $themes = Clansuite_Theme::getThemeDirectories();
     // create a new form
     $form = new Clansuite_Form('module_select_dropdown_form', 'post', '/templatemanager/admin/edit');
     $form->setLegend(_('Select Module or Theme to edit'));
     // select dropdown for modules
     $form->addElement('select')->setName('select_form[module]')->setLabel(_('Module'))->setOptions($modules)->withValuesAsKeys();
     // select dropdown for themes
     $form->addElement('select')->setName('select_form[theme]')->setLabel(_('Theme'))->setOptions($themes)->withValuesAsKeys();
     // add the buttonbar
     $form->addElement('buttonbar')->setCancelButtonURL('index.php?mod=templatemanager&sub=admin');
     // assign the html of the form to the view
     $this->getView()->assign('module_select_dropdown_form', $form->render());
     $this->display();
 }
 /**
  * Edit News
  *
  * @todo autoloader/di for forms
  */
 public function action_admin_edit()
 {
     // get id
     $news_id = $this->request->getParameter('id');
     // fetch news data by id
     $news = $this->getModel()->fetchSingleNews($news_id);
     // create a new form
     $form = new Clansuite_Form('news_form', 'post', 'index.php?mod=news&sub=admin&action=update&type=edit');
     $form->setLegend('News Editor')->setClass('News');
     // news_id as hidden field
     $form->addElement('hidden')->setName('news_form[news_id]')->setValue($news['news_id']);
     // user_id as hidden field
     $form->addElement('hidden')->setName('news_form[user_id]')->setValue($news['user_id']);
     $form->addElement('text')->setName('news_form[news_title]')->setLabel(_('Title'))->setValue($news['news_title']);
     $categories = $this->getModel()->fetchAllNewsCategoriesDropDown();
     $form->addElement('multiselect')->setName('news_form[cat_id]')->setLabel(_('Category'))->setOptions($categories)->setDefaultValue($news['cat_id']);
     $form->addElement('multiselect')->setName('news_form[news_status]')->setLabel(_('Status'))->setOptions($this->publishing_status_map)->setDefaultValue($news['news_status']);
     $form->addElement('textarea')->setName('news_form[news_body]')->setID('news_form[news_body]')->setCols('30')->setRows('12')->setLabel(_('Your Article:'))->setValue($news['news_body'])->setEditor();
     // add the buttonbar
     $form->addElement('buttonbar')->getButton('cancelbutton')->setCancelURL('index.php?mod=news/admin');
     // assign the html of the form to the view
     $this->getView()->assign('form', $form->render());
     $this->display();
 }
 /**
  *
  */
 public function action_admin_new()
 {
     Clansuite_Breadcrumb::add(_('Add language'), '/languages/admin/new');
     // handle get request
     if ($this->request->getRequestMethod() == 'GET') {
         $module = $this->request->getParameter('modulename', 'GET');
         $form = new Clansuite_Form('languages_dropdown', 'post', WWW_ROOT . 'index.php?mod=languages&sub=admin&action=new');
         $form->setLegend(_('Select the language to add'));
         // $_POST['locale']
         $form->addElement('selectlocale')->setDescription('Use the dropdown to select a locale by name or abbreviation.');
         // $_POST['module']
         $form->addElement('hidden')->setName('module')->setValue($module);
         $form->addElement('buttonbar');
         $view = $this->getView();
         $view->assign('modulename', $module);
         $view->assign('form_languages_dropdown', $form->render());
         $this->display();
     }
 }
示例#4
0
 public function testGetLegend()
 {
     $this->form->setLegend('legend-get');
     // via getter - returns string
     $this->assertEqual('legend-get', $this->form->getLegend());
 }