コード例 #1
0
 /**
  *
  * @see EditorController::getHtml()
  */
 public function getHtml(EditableElement $element, Content $record, array $options = null)
 {
     $contentid = $element->getElementContentId();
     $encparms = htmlspecialchars(json_encode($element));
     $html = "<section class=\"bolt-ext-editable\" data-content_id=\"{$contentid}\"";
     $html .= $options ? " data-options=\"" . htmlspecialchars(json_encode($options)) . "\"" : '';
     $html .= " data-parameters=\"{$encparms}\">" . $record->values[$element->fieldname] . "</section>";
     return $html;
 }
コード例 #2
0
 /**
  *
  * @param string $fieldname
  * @param string $record
  * @param unknown $options
  * @return \Twig_Markup
  */
 public function twigEditable($fieldname, $record = null, $options = array())
 {
     $html = '';
     $record = $record ?: $this->getDefaultRecord();
     if ($this->authorized) {
         if ($record && $record instanceof \Bolt\Content) {
             $element = new EditableElement($this->app);
             $element->applyRecord($record, $fieldname);
             $html = $this->controller->getHtml($element, $record, $options);
         }
     } else {
         $html = $record ? $record->values[$fieldname] : '';
     }
     return new \Twig_Markup($html, 'UTF-8');
 }