/** * Renders internally formatted value for read-only output (e.g. on listing * table). * * @param integer $rowid ID of row containing given value * @param string $column name of column * @param mixed $in value returned from DB * @param string $type defined type of value * @param boolean $mayBeSkipped if true, the method should return null if * value is unset * @param boolean $inEditor if true, the value comes from an editor's * session (important for rendering attached * files/images) * @return string code describing value for read-only output */ protected function renderValue($rowid, $column, $value, $def, $mayBeSkipped = false, $inEditor = false, $rowACL = null) { if (!$this->isAuthorizedMulti($rowACL, $def['options'], 'mayview', null, true)) { return $mayBeSkipped ? null : '<em>' . $this->getLang('hidden') . '</em>'; } if (is_null($value) && $def['type'] != 'data') { return $mayBeSkipped ? null : ''; } switch ($def['format']) { case 'text': if (trim($value) === '' && $mayBeSkipped) { return null; } if ($this->options['wikimarkup'] || $def['options']['wikimarkup']) { // apply processing of contained wiki markup $value = p_render('xhtml', p_get_instructions($value), $info); if (preg_match('#^<p>((.|\\n)+)</p>$#i', trim($value), $matches)) { $value = $matches[1]; } } // strip some special tags from text (preventing some XSS attacks) $value = $this->stripTags($value); return trim($value); case 'image': case 'file': if ($value === true) { return '<span class="info">' . $this->getLang('fileexternalfound') . '</span>'; } else { if ($value === false) { return '<span class="info">' . $this->getLang('fileexternalnotfound') . '</span>'; } else { $temp = is_array($value) ? trim(implode('', $value)) : ''; if ($temp === '') { return $mayBeSkipped ? null : '<em>' . $this->getLang('none') . '</em>'; } if ($inEditor) { $url = $this->editorSessionMediaLink($column, $def['format'] != 'image'); } else { $url = $this->mediaLink($rowid, $column, $def['format'] != 'image'); } if (!$inEditor) { $url .= '&thumb=150'; } if ($def['format'] === 'image') { return "<img src=\"{$url}\" alt=\"" . sprintf($this->getLang('fileimagealt'), $column, $value['mime']) . "\" />"; } $mayDownload = $this->isAuthorizedMulti($rowACL, $this->options, 'maydownload'); if (!$mayDownload) { return '<em>' . $this->getLang('filedenied') . '</em>'; } return "<a href=\"{$url}\" title=\"" . $this->getLang('filedlhint') . '">' . $this->getLang('cmddl') . '</a>'; } } break; case 'email': if (trim($value) === '' && $mayBeSkipped) { return null; } return DokuWiki_Plugin::email($value, $email); case 'url': if (trim($value) === '' && $mayBeSkipped) { return null; } return DokuWiki_Plugin::external_link($value); case 'phone': case 'fax': if (trim($value) === '' && $mayBeSkipped) { return null; } return $value; case 'bool': if (!$value && $mayBeSkipped) { return null; } return $value ? '✗' : '–'; case 'date': if (!$value) { return $mayBeSkipped ? null : ''; } return strftime(strtok(trim($this->getConf('dformat')), ' '), $value); case 'datetime': if (!$value) { return $mayBeSkipped ? null : ''; } return strftime($this->getConf('dformat'), $value); case 'time': if ($value && substr($value, -3) == ':00' && strlen($value) > 5) { $value = substr($value, 0, -3); } return $value; case 'integer': case 'monetary': case 'real': if (!$value && $mayBeSkipped) { return null; } return $value; case 'enum': case 'related': if (is_integer($value)) { $value = $def['options']['selectables'][$value]; } return $value; case 'acl': if (!$this->isAuthorized($this->options['mayadmin'])) { // admins may see this value, only return null; } return $value; default: return $value; } }