Server : Apache System : Linux indy02.toastserver.com 3.10.0-962.3.2.lve1.5.85.el7.x86_64 #1 SMP Thu Apr 18 15:18:36 UTC 2024 x86_64 User : palandch ( 1163) PHP Version : 7.1.33 Disable Function : NONE Directory : /home/palandch/public_html/core/model/modx/processors/element/tv/renders/web/output/ |
<?php /** * @var modX $modx * @var array $params * @var string $value * * @package modx * @subpackage processors.element.tv.renders.mgr.output */ class modTemplateVarOutputRenderUrl extends modTemplateVarOutputRender { public function process($value,array $params = array()) { if (empty($value)) return $value; $value= $this->tv->parseInput($value, "||", "array"); $o = ''; for ($i = 0; $i < count($value); $i++) { $s = is_array($value[$i]) ? $value[$i] : explode("==",$value[$i]); if (!isset($s[1])) $s[1] = $s[0]; list($name,$url) = $s; if (!$url) $url = $name; if ((empty($name) || $name == $url) && $this->tv->get('type') == 'resourcelist') { /** @var modResource $resource */ $resource = $this->modx->getObject('modResource',$url); if ($resource) { $name = $resource->get('pagetitle'); } } /* handle types that return IDs of resources */ $rid =intval($url); if (!empty($rid)) { $url = '[[~'.$rid.']]'; } if ($url) { if($o) $o.='<br />'; $attributes = ''; /* setup the link attributes */ $attr = array( 'href' => $url, 'title' => !empty($params['title']) ? htmlspecialchars($params['title']) : $name, 'class' => !empty($params['class']) ? $params['class'] : null, 'style' => !empty($params['style']) ? $params['style'] : null, 'target' => !empty($params['target']) ? $params['target'] : null, ); foreach ($attr as $k => $v) $attributes .= ($v ? ' '.$k.'="'.$v.'"' : ''); if (!empty($params['attrib'])) { $attributes .= ' '.$params['attrib']; /* add extra */ } /* Output the link */ $o .= '<a'.rtrim($attributes).'>'. (!empty($params['text']) ? htmlspecialchars($params['text']) : $name) .'</a>'; } } return $o; } } return 'modTemplateVarOutputRenderUrl';