protected function makeQlistBody() { $this->title = '@@Categories@@'; $Renderer = new Renderer($this->Registry); $this->aPageVars['body'] = $Renderer->getNestedDivs(); return $this; }
protected function init() { /** * This is just an example how a custom validation * callback could be added to form * The callback must accept value of element * and must return error string or true * if there are no errors * * @see Form::init() */ /*$this->addValidator('title', function($val){ if(\mb_strlen($val) < 1){ return 'Title must contain at least 1 character long'; } return true; });*/ /** * Check if category is * optional/required/none * If required then add 3rd param 'true' * also set "Select Category" only * If selected is not passed here */ $categs = $this->Registry->Ini->CATEGORIES; $selectMenu = $clabel = $crequired = null; if ($categs) { $Menu = new Renderer($this->Registry); $clabel = $this->Registry->Tr->get('Select Category'); /** * If CATEGORIES in !config.ini is set to 2 * then category selection is required. * Adding validator server-side * and HTML5 'required' tag client-side */ if (2 == $categs) { $crequired = true; $err = $this->Registry->Tr->get('You must select a category'); $this->addValidator('category', function ($val) use($err) { if (strlen($val) < 1) { return $err; } return true; }); } $selectMenu = $Menu->getSelectMenu($this->selected, $clabel, $crequired); d('$selectMenu: ' . $selectMenu); } $minTags = $this->Registry->Ini->MIN_QUESTION_TAGS; $maxTags = $this->Registry->Ini->MAX_QUESTION_TAGS; $d = $this->Tr->get('Please enter between {min_tags} and {max_tags} tags, separated by spaces', array('{min_tags}' => $minTags, '{max_tags}' => $maxTags)); $this->setVar('tags_d', $d); $this->setVar('tags_l', $this->Tr['Tags']); $this->setVar('Preview', $this->Tr['Preview']); $this->setVar('Preview', $this->Tr['Preview']); $this->setVar('title_d', $this->Tr['Enter a descriptive title']); $this->setVar('title_l', $this->Tr['Title']); $this->setVar('submit', $this->Tr['Start new topic']); $this->setVar('category_menu', $selectMenu); if (0 === strlen($categs)) { $this->setVar('category_class', 'hide'); } if ($minTags > 0) { $tagsRequired = '(* %s)'; $this->setVar('tags_required', sprintf($tagsRequired, 'required')); } $minTitle = $this->Registry->Ini->MIN_TITLE_CHARS; if ($minTitle > 0) { $t = 'Please enter a descriptive title at least %s characters long'; $this->setVar('title_d', sprintf($t, $minTitle)); } }
protected function init() { /** * Skip this for when editing Answer * this init adds categories drop-down * menu and it is only used for Question. */ if (!$this->isAnswer) { $selectMenu = $clabel = $crequired = null; /** * Check if category is * optional/required/none * If required then add 3rd param 'true' * also set "Select Category" only * If selected is not passed here */ $categs = $this->Registry->Ini->CATEGORIES; if ($categs) { $Menu = new Renderer($this->Registry); $clabel = '@@Select Category@@'; /** * If CATEGORIES in !config.ini is set to 2 * then category selection is required. * Adding validator server-side * and HTML5 'required' tag client-side */ if (2 == $categs) { $crequired = true; $err = '@@You must select a category@@'; $this->addValidator('category', function ($val) use($err) { if (strlen($val) < 1) { return $err; } return true; }); } $selectMenu = $Menu->getSelectMenu($this->selected, $clabel, $crequired); d('$selectMenu: ' . $selectMenu); } $this->setVar('category_menu', $selectMenu); if (0 === strlen($categs)) { $this->setVar('category_class', 'hide'); } else { $this->setVar('category_class', 'category'); } } }