/** * Adds elements from the model to the bridge that creates the form. * * @param \MUtil_Model_Bridge_FormBridgeInterface $bridge * @param \MUtil_Model_ModelAbstract $model */ protected function addFormElements(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model) { $this->mailElements->setForm($bridge->getForm()); $this->initItems(); $this->addItems($bridge, 'gct_name'); $this->addItems($bridge, 'gct_id_template', 'gct_target'); $this->addItems($bridge, 'gct_code'); $bridge->getForm()->getElement('gct_target')->setAttrib('onchange', 'this.form.submit()'); $defaultTab = $this->project->getLocaleDefault(); $this->mailElements->addFormTabs($bridge, 'gctt', 'active', $defaultTab, 'tabcolumn', 'gctt_lang', 'selectedTabElement', 'send_language'); $config = array('extraPlugins' => 'bbcode,availablefields', 'toolbar' => array(array('Source', '-', 'Undo', 'Redo'), array('Find', 'Replace', '-', 'SelectAll', 'RemoveFormat'), array('Link', 'Unlink', 'Image', 'SpecialChar'), '/', array('Bold', 'Italic', 'Underline'), array('NumberedList', 'BulletedList', '-', 'Blockquote'), array('Maximize'), array('availablefields'))); $mailfields = $this->mailer->getMailFields(); foreach ($mailfields as $field => $value) { $mailfields[$field] = utf8_encode($value); } $config['availablefields'] = $mailfields; $config['availablefieldsLabel'] = $this->_('Fields'); $this->view->inlineScript()->prependScript("\n CKEditorConfig = " . \Zend_Json::encode($config) . ";\n "); $bridge->addFakeSubmit('preview', array('label' => $this->_('Preview'))); $bridge->addElement($this->mailElements->createEmailElement('to', $this->_('To (test)'), false)); $bridge->addElement($this->mailElements->createEmailElement('from', $this->_('From'), false)); //$bridge->addRadio('send_language', array('label' => $this->_('Test language'), 'multiOptions' => )) $bridge->addHidden('send_language'); $bridge->addFakeSubmit('sendtest', array('label' => $this->_('Send (test)'))); $bridge->addElement($this->getSaveButton($bridge->getForm())); $bridge->addElement($this->mailElements->createPreviewHtmlElement('Preview HTML')); $bridge->addElement($this->mailElements->createPreviewTextElement('Preview Text')); $bridge->addHtml('available_fields', array('label' => $this->_('Available fields'))); }
/** * Adds elements from the model to the bridge that creates the form. * * Overrule this function to add different elements to the browse table, without * having to recode the core table building code. * * @param \MUtil_Model_Bridge_FormBridgeInterface $bridge * @param \MUtil_Model_ModelAbstract $model */ protected function addFormElements(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model) { if (!$bridge->getForm() instanceof \Gems_TabForm) { parent::addFormElements($bridge, $model); return; } //Get all elements in the model if not already done $this->initItems(); // Add 'tooltip' to the allowed displayoptions $displayOptions = $bridge->getAllowedOptions(\MUtil_Model_Bridge_FormBridge::DISPLAY_OPTIONS); if (!array_search('tooltip', $displayOptions)) { $displayOptions[] = 'tooltip'; $bridge->setAllowedOptions(\MUtil_Model_Bridge_FormBridge::DISPLAY_OPTIONS, $displayOptions); } $tab = 0; $group = 0; $oldTab = null; // \MUtil_Echo::track($model->getItemsOrdered()); foreach ($model->getItemsOrdered() as $name) { // Get all options at once $modelOptions = $model->get($name); $tabName = $model->get($name, 'tab'); if ($tabName && $tabName !== $oldTab) { if (isset($modelOptions['elementClass']) && 'tab' == strtolower($modelOptions['elementClass'])) { $bridge->addTab('tab' . $tab, $modelOptions + array('value' => $tabName)); } else { $bridge->addTab('tab' . $tab, 'value', $tabName); } $oldTab = $tabName; $tab++; } if ($model->has($name, 'label')) { $bridge->add($name); if ($theName = $model->get($name, 'startGroup')) { //We start a new group here! $groupElements = array(); $groupElements[] = $name; $groupName = $theName; } elseif ($theName = $model->get($name, 'endGroup')) { //Ok, last element define the group $groupElements[] = $name; $bridge->addDisplayGroup('grp_' . $groupElements[0], $groupElements, 'description', $groupName, 'showLabels', $theName == 'showLabels', 'class', 'grp' . $group); $group++; unset($groupElements); unset($groupName); } else { //If we are in a group, add the elements to the group if (isset($groupElements)) { $groupElements[] = $name; } } } else { $bridge->addHidden($name); } unset($this->_items[$name]); } }
/** * Display a header * * @param \MUtil_Model_Bridge_FormBridgeInterface $bridge * @param mixed $header Header content * @param string $tagName */ protected function displayHeader(\MUtil_Model_Bridge_FormBridgeInterface $bridge, $header, $tagName = 'h2') { static $count = 0; $count += 1; $element = $bridge->getForm()->createElement('html', 'step_header_' . $count); $element->{$tagName}($header); $bridge->addElement($element); }