protected function renderHtmlAndTextContentElement($model, $attribute, $form)
 {
     $this->registerContentTabsHeightScripts();
     $params = array(EmailTemplateHtmlAndTextContentElement::SELECTIVE_TAB_LOAD_KEY => true);
     $element = new EmailTemplateHtmlAndTextContentElement($model, $attribute, $form, $params);
     return ZurmoHtml::tag('div', array('class' => 'email-template-combined-content'), $element->render());
 }
 protected function renderPlainTextAndHtmlContent(&$content)
 {
     $params = array(EmailTemplateHtmlAndTextContentElement::SELECTIVE_TAB_LOAD_KEY => true);
     $element = new EmailTemplateHtmlAndTextContentElement($this->model, null, $this->form, $params);
     $element->editableTemplate = '{label}{content}{error}';
     $right = ZurmoHtml::tag('div', array('class' => 'email-template-combined-content right-column'), $element->render());
     //todo: placed last so redactor is already initialized first. just a trick for the css right now
     $title = ZurmoHtml::tag('h3', array(), Zurmo::t('Default', 'Merge Tags'));
     $left = $this->renderMergeTagsView();
     $left = ZurmoHtml::tag('div', array('class' => 'left-column'), $title . $left);
     $content .= $left . $right;
 }
Example #3
0
 /**
  * Validates the attribute of the model.
  * If there is any error, the error message is added to the model.
  * @param RedBeanModel $object the model being validated
  * @param string $attribute the attribute being validated
  * @return boolean true if validation passed
  */
 protected function validateAttribute($object, $attribute)
 {
     $this->resolveMergeTagValidatorProperties($object);
     $passedValidation = true;
     if (!empty($object->{$attribute}) && @class_exists($this->modelClassName)) {
         $model = new $this->modelClassName(false);
         $mergeTagsUtil = MergeTagsUtilFactory::make($this->type, $this->language, $object->{$attribute});
         $invalidTags = array();
         $mergeTagCount = $mergeTagsUtil->extractMergeTagsPlaceHolders();
         if ($mergeTagCount && !$mergeTagsUtil->resolveMergeTagsArrayToAttributes($model, $invalidTags, null)) {
             $passedValidation = false;
             if (!empty($invalidTags)) {
                 foreach ($invalidTags as $tag) {
                     $errorMessage = EmailTemplateHtmlAndTextContentElement::renderModelAttributeLabel($attribute) . ': Invalid MergeTag({mergeTag}) used.';
                     $this->addError($object, $attribute, Zurmo::t('EmailTemplatesModule', $errorMessage, array('{mergeTag}' => $tag)));
                 }
             } else {
                 $this->addError($object, $attribute, Zurmo::t('EmailTemplatesModule', 'Provided content contains few invalid merge tags.'));
             }
         }
     }
     return $passedValidation;
 }