MODX Revolution PHP Cross Reference Content Management Systems

Source: /core/model/modx/processors/element/tv/renders/web/output/htmltag.class.php - 53 lines - 2123 bytes - Summary - Text - Print

   1  <?php
   2  /**
   3   * @package modx
   4   * @subpackage processors.element.tv.renders.mgr.output
   5   */
   6  class modTemplateVarOutputRenderHtmlTag extends modTemplateVarOutputRender {
   7      public function process($value,array $params = array()) {
   8          $value= $this->tv->parseInput($value, "||", "array");
   9          $tagid = !empty($params['tagid']) ? $params['tagid'] : '';
  10          $tagname = !empty($params['tagname']) ? $params['tagname'] : 'div';
  11          $id = 'tv'.$this->tv->get('name');
  12          $tagvalue = '';
  13          $o = '';
  14          /* Loop through a list of tags */
  15          for ($i = 0; $i < count($value); $i++) {
  16              $tagvalue = is_array($value[$i]) ? implode(' ', $value[$i]) : $value[$i];
  17              if (!$tagvalue) continue;
  18  
  19              $domId = $tagid ? $tagid : $id;
  20              $domId .= count($value) > 1 ? $i : '';
  21  
  22              $attributes = '';
  23              $attr = array(
  24                  'id' => $domId, /* 'tv' already added to id */
  25                  'class' => !empty($params['class']) ? $params['class'] : null,
  26                  'style' => !empty($params['style']) ? $params['style'] : null,
  27              );
  28              foreach ($attr as $k => $v) $attributes.= ($v ? ' '.$k.'="'.$v.'"' : '');
  29              if (!empty($params['attrib'])) {
  30                  $attributes .= ' '.$params['attrib'];
  31              }
  32  
  33              /* Output the HTML Tag */
  34              $o .= '<'.$tagname.rtrim($attributes).'>'.$tagvalue.'</'.$tagname.'>';
  35          }
  36          if (empty($o)) {
  37              $attributes = '';
  38              $attr = array(
  39                  'class' => !empty($params['class']) ? $params['class'] : null,
  40                  'style' => !empty($params['style']) ? $params['style'] : null,
  41              );
  42              foreach ($attr as $k => $v) $attributes.= ($v ? ' '.$k.'="'.$v.'"' : '');
  43              if (!empty($params['attrib'])) {
  44                  $attributes .= ' '.$params['attrib']; /* add extra */
  45              }
  46  
  47              /* Output the HTML Tag */
  48              $o .= '<'.$tagname.rtrim($attributes).'>'.$tagvalue.'</'.$tagname.'>';
  49          }
  50          return $o;
  51      }
  52  }
  53  return 'modTemplateVarOutputRenderHtmlTag';

title

Description

title

Description

title

Description

title

title

Body