Exemple #1
0
 function renderOutput($context = array())
 {
     $smarty = TikiLib::lib('smarty');
     $url = $this->getConfiguration('value');
     if (empty($url) || $context['list_mode'] == 'csv' || $this->getOption('linkToURL') == 1) {
         return $url;
     } elseif ($this->getOption('linkToURL') == 2) {
         // Site title as link
         $smarty->loadPlugin('smarty_function_object_link');
         return smarty_function_object_link(array('type' => 'external', 'id' => $url), $smarty);
     } elseif ($this->getOption('linkToURL') == 0) {
         // URL as link
         $parsedUrl = trim(str_replace('<br />', '', TikiLib::lib('tiki')->parse_data($url)));
         if ($parsedUrl != $url) {
             return $parsedUrl;
         }
         $smarty->loadPlugin('smarty_function_object_link');
         return smarty_function_object_link(array('type' => 'external', 'id' => $url, 'title' => $url), $smarty);
     } elseif ($this->getOption('linkToURL') == 3) {
         // URL + site title
         $smarty->loadPlugin('smarty_function_object_link');
         return smarty_function_object_link(array('type' => 'external_extended', 'id' => $url), $smarty);
     } elseif ($this->getOption('linkToURL') == 4) {
         // URL as link
         $smarty->loadPlugin('smarty_function_object_link');
         return smarty_function_object_link(array('type' => 'external', 'id' => $url, 'title' => tr($this->getOption('other'))), $smarty);
     } else {
         return $url;
     }
 }
Exemple #2
0
 function render($name, $value, array $entry)
 {
     $smarty = TikiLib::lib('smarty');
     $smarty->loadPlugin('smarty_function_object_link');
     foreach ((array) $value as $id) {
         $params = array('type' => $this->type, 'id' => $id);
         $links[] = smarty_function_object_link($params, $smarty);
     }
     return '~np~' . implode($this->separator, $links) . '~/np~';
 }
Exemple #3
0
 function render($name, $value, array $entry)
 {
     global $smarty;
     $smarty->loadPlugin('smarty_function_object_link');
     $params = array('type' => $entry['object_type'], 'id' => $entry['object_id'], 'title' => $value);
     if (isset($entry['url'])) {
         $params['url'] = $entry['url'];
     }
     return '~np~' . smarty_function_object_link($params, $smarty) . '~/np~';
 }
Exemple #4
0
 function renderOutput($context = array())
 {
     $value = $this->getConfiguration('value');
     if ($value) {
         if ($this->getOption('link') === 'n' || $context['list_mode'] === 'csv') {
             return $value;
         } else {
             $smarty = TikiLib::lib('smarty');
             $smarty->loadPlugin('smarty_function_object_link');
             return smarty_function_object_link(array('type' => 'wikipage', 'id' => $value), $smarty);
         }
     }
 }
Exemple #5
0
 function renderOutput($context = array())
 {
     global $prefs;
     global $mimetypes;
     include 'lib/mime/mimetypes.php';
     $galleryId = (int) $this->getOption('galleryId');
     if (!isset($context['list_mode'])) {
         $context['list_mode'] = 'n';
     }
     $value = $this->getValue();
     if ($context['list_mode'] === 'csv') {
         return $value;
     }
     $ret = '';
     if (!empty($value)) {
         if ($this->getOption('displayMode')) {
             // images etc
             $params = array('fileId' => $value);
             if ($context['list_mode'] === 'y') {
                 $otherParams = $this->getOption('displayParamsForLists');
             } else {
                 $otherParams = $this->getOption('displayParams');
             }
             if ($otherParams) {
                 parse_str($otherParams, $otherParams);
                 $params = array_merge($params, $otherParams);
             }
             $params['fromFieldId'] = $this->getConfiguration('fieldId');
             $params['fromItemId'] = $this->getItemId();
             $item = Tracker_Item::fromInfo($this->getItemData());
             $params['checkItemPerms'] = $item->canModify() ? 'n' : 'y';
             if ($this->getOption('displayMode') == 'img') {
                 // img
                 if ($context['list_mode'] === 'y') {
                     $params['thumb'] = $context['list_mode'];
                     $params['rel'] = 'box[' . $this->getInsertId() . ']';
                 }
                 include_once 'lib/wiki-plugins/wikiplugin_img.php';
                 $ret = wikiplugin_img('', $params);
             } else {
                 if ($this->getOption('displayMode') == 'vimeo') {
                     // Vimeo videos stored as filegal REMOTEs
                     include_once 'lib/wiki-plugins/wikiplugin_vimeo.php';
                     $ret = wikiplugin_vimeo('', $params);
                 } else {
                     if ($this->getOption('displayMode') == 'moodlescorm') {
                         include_once 'lib/wiki-plugins/wikiplugin_playscorm.php';
                         foreach ($this->getConfiguration('files') as $fileId => $file) {
                             $params['fileId'] = $fileId;
                             $ret .= wikiplugin_playscorm('', $params);
                         }
                     } else {
                         if ($this->getOption('displayMode') == 'googleviewer') {
                             if ($prefs['auth_token_access'] != 'y') {
                                 $ret = tra('Token access needs to be enabled for Google viewer to be used');
                             } else {
                                 $files = array();
                                 foreach ($this->getConfiguration('files') as $fileId => $file) {
                                     global $base_url, $tikiroot, $https_mode;
                                     if ($https_mode) {
                                         $scheme = 'https';
                                     } else {
                                         $scheme = 'http';
                                     }
                                     $googleurl = $scheme . "://docs.google.com/viewer?url=";
                                     $fileurl = urlencode($base_url . "tiki-download_file.php?fileId=" . $fileId);
                                     require_once 'lib/auth/tokens.php';
                                     $tokenlib = AuthTokens::build($prefs);
                                     $token = $tokenlib->createToken($tikiroot . "tiki-download_file.php", array('fileId' => $fileId), array('Registered'), array('timeout' => 300, 'hits' => 3));
                                     $fileurl .= urlencode("&TOKEN=" . $token);
                                     $url = $googleurl . $fileurl . '&embedded=true';
                                     $title = $file['name'];
                                     $files[] = array('url' => $url, 'title' => $title, 'id' => $fileId);
                                 }
                                 $smarty = TikiLib::lib('smarty');
                                 $smarty->assign('files', $files);
                                 $ret = $smarty->fetch('trackeroutput/files_googleviewer.tpl');
                             }
                         }
                     }
                 }
             }
             $ret = preg_replace('/~\\/?np~/', '', $ret);
         } else {
             $smarty = TikiLib::lib('smarty');
             $smarty->loadPlugin('smarty_function_object_link');
             $ret = '<ol class="tracker-item-files">';
             foreach ($this->getConfiguration('files') as $fileId => $file) {
                 $ret .= '<li>';
                 $ret .= smarty_function_object_link(array('type' => 'file', 'id' => $fileId, 'title' => $file['name']), $smarty);
                 $globalperms = Perms::get(array('type' => 'file gallery', 'object' => $galleryId));
                 if ($prefs['feature_draw'] == 'y' && $globalperms->upload_files == 'y' && ($file['filetype'] == $mimetypes["svg"] || $file['filetype'] == $mimetypes["gif"] || $file['filetype'] == $mimetypes["jpg"] || $file['filetype'] == $mimetypes["png"] || $file['filetype'] == $mimetypes["tiff"])) {
                     $ret .= " <a href='tiki-edit_draw.php?fileId=" . $file['fileId'] . "' onclick='return \$(this).ajaxEditDraw();'  title='Edit: " . $file['name'] . "' data-fileid='" . $file['fileId'] . "' data-galleryid='" . $galleryId . "'>\n\t\t\t\t\t\t\t<img width='16' height='16' class='icon' alt='Edit' src='img/icons/page_edit.png' />\n\t\t\t\t\t\t</a>";
                 }
                 $ret .= '</li>';
             }
             $ret .= '</ol>';
         }
     }
     return $ret;
 }
function smarty_function_object_link_relation_end($smarty, $end, $relationId, $title = null)
{
    $relationlib = TikiLib::lib('relation');
    $attributelib = TikiLib::lib('attribute');
    $cachelib = TikiLib::lib('cache');
    $cacheKey = "{$relationId}:{$end}:{$title}";
    if (!($out = $cachelib->getCached($cacheKey, 'relation_link'))) {
        $relation = $relationlib->get_relation($relationId);
        if ($relation) {
            if (!$title) {
                $attributes = $attributelib->get_attributes('relation', $relationId);
                $key = 'tiki.relation.' . $end;
                if (isset($attributes[$key]) && !empty($attributes[$key])) {
                    $title = $attributes[$key];
                }
            }
            $type = $relation[$end . '_type'];
            $object = $relation[$end . '_itemId'];
            $out = smarty_function_object_link(array('type' => $type, 'id' => $object, 'title' => $title), $smarty);
            $cachelib->cacheItem($cacheKey, $out, 'relation_link');
        } else {
            $out = tra('Relation not found.');
        }
    }
    return $out;
}
function wikiplugin_objectlink($data, $params)
{
    $smarty = TikiLib::lib('smarty');
    $smarty->loadPlugin('smarty_function_object_link');
    return smarty_function_object_link(array('type' => $params['type'], 'id' => $params['id']), $smarty);
}
 public function info($target, $newdesc = '')
 {
     $path = $this->decode($target);
     $id = $this->pathToId($path);
     $isGal = $path[0] !== 'f';
     $smarty = TikiLib::lib('smarty');
     $smarty->loadPlugin('smarty_function_object_link');
     if ($isGal) {
         $info = $this->filegallib->get_file_gallery($id);
         $allowed = array('galleryId', 'name', 'type', 'description', 'created', 'visible', 'lastModif', 'user', 'hits', 'votes', 'public', 'icon_field');
         // clever way of filtering by keys from http://stackoverflow.com/questions/4260086
         $info = array_intersect_key($info, array_flip($allowed));
         $info['link'] = smarty_function_object_link(array('id' => $info['galleryId'], 'type' => 'file gallery', 'title' => $info['name']), $smarty);
         $perms = TikiLib::lib('tiki')->get_perm_object($id, 'file gallery', $info);
     } else {
         $info = $this->filegallib->get_file($id);
         $allowed = array('fileId', 'galleryId', 'name', 'description', 'created', 'filename', 'filesize', 'filetype', 'user', 'author', 'hits', 'maxhits', 'votes', 'points', 'metadata', 'lastModif', 'lastModifUser', 'lockedby', 'comment', 'archiveId');
         $info = array_intersect_key($info, array_flip($allowed));
         $info['wiki_syntax'] = $this->filegallib->getWikiSyntax($info['galleryId'], $info);
         if (in_array($info['filetype'], array('image/jpeg', 'image/gif', 'image/png'))) {
             $type = 'display';
         } else {
             $type = 'file';
         }
         $info['link'] = smarty_function_object_link(array('id' => $info['fileId'], 'type' => $type, 'title' => $info['name']), $smarty);
         $perms = TikiLib::lib('tiki')->get_perm_object($id, 'file', $info);
     }
     if ($perms['tiki_p_download_files'] === 'y') {
         global $user;
         if ($newdesc && $perms['tiki_p_edit_gallery_file'] === 'y') {
             if ($isGal) {
                 unset($info['link']);
                 $info['description'] = $newdesc;
                 $this->filegallib->replace_file_gallery($info);
             } else {
                 $this->filegallib->update_file($id, $info['name'], $newdesc, $user, $info['comment']);
             }
         }
         return array_filter($info);
     }
     return '';
 }
Exemple #9
0
 function renderOutput($context = array())
 {
     global $prefs;
     global $mimetypes;
     include 'lib/mime/mimetypes.php';
     $galleryId = (int) $this->getOption('galleryId');
     if (!isset($context['list_mode'])) {
         $context['list_mode'] = 'n';
     }
     $value = $this->getValue();
     if ($context['list_mode'] === 'csv') {
         return $value;
     }
     $ret = '';
     if (!empty($value)) {
         if ($this->getOption('displayImages')) {
             // images
             $params = array('fileId' => $value);
             if ($context['list_mode'] === 'y') {
                 $params['thumb'] = $context['list_mode'];
                 $params['rel'] = 'box[' . $this->getInsertId() . ']';
                 $otherParams = $this->getOption('imageParamsForLists');
             } else {
                 $otherParams = $this->getOption('imageParams');
             }
             if ($otherParams) {
                 parse_str($otherParams, $otherParams);
                 $params = array_merge($params, $otherParams);
             }
             include_once 'lib/wiki-plugins/wikiplugin_img.php';
             $params['fromFieldId'] = $this->getConfiguration('fieldId');
             $params['fromItemId'] = $this->getItemId();
             $item = Tracker_Item::fromInfo($this->getItemData());
             $params['checkItemPerms'] = $item->canModify() ? 'n' : 'y';
             $ret = wikiplugin_img('', $params, 0);
             $ret = preg_replace('/~\\/?np~/', '', $ret);
         } else {
             $smarty = TikiLib::lib('smarty');
             $smarty->loadPlugin('smarty_function_object_link');
             $ret = '<ol>';
             foreach ($this->getConfiguration('files') as $fileId => $file) {
                 $ret .= '<li>';
                 $ret .= smarty_function_object_link(array('type' => 'file', 'id' => $fileId, 'title' => $file['name']), $smarty);
                 $globalperms = Perms::get(array('type' => 'file gallery', 'object' => $galleryId));
                 if ($prefs['feature_draw'] == 'y' && $globalperms->upload_files == 'y' && ($file['filetype'] == $mimetypes["svg"] || $file['filetype'] == $mimetypes["gif"] || $file['filetype'] == $mimetypes["jpg"] || $file['filetype'] == $mimetypes["png"] || $file['filetype'] == $mimetypes["tiff"])) {
                     $ret .= " <a href='tiki-edit_draw.php?fileId=" . $file['fileId'] . "' onclick='return \$(this).ajaxEditDraw();'  title='Edit: " . $file['name'] . "' data-fileid='" . $file['fileId'] . "' data-galleryid='" . $file['galleryId'] . "'>\n\t\t\t\t\t\t\t<img width='16' height='16' class='icon' alt='Edit' src='img/icons/page_edit.png' />\n\t\t\t\t\t\t</a>";
                 }
                 $ret .= '</li>';
             }
             $ret .= '</ol>';
         }
     }
     return $ret;
 }
 function render($name, $value, array $entry)
 {
     global $smarty;
     $smarty->loadPlugin('smarty_function_object_link');
     $arr = TikiLib::lib('categ')->getCategories();
     foreach ($arr as $arx) {
         $myArr[$arx['categId']] = array('parentId' => $arx['parentId'], 'name' => $arx['name']);
     }
     if ($this->singleList == 'y') {
         foreach ($value as $ar) {
             if ($ar == 'orphan') {
                 break;
             }
             $p_info = $myArr[$ar];
             if (($this->requiredParents == 'all' || in_array($p_info['parentId'], $this->requiredParents)) && !in_array($p_info['parentId'], $this->excludeParents)) {
                 $params = array('type' => 'category', 'id' => $ar);
                 $link = smarty_function_object_link($params, $smarty);
                 if (!empty($this->separator)) {
                     $list .= $link . $this->separator;
                 } else {
                     if (empty($list)) {
                         $list = "<ul class=\"categoryLinks\">";
                     }
                     $list .= ' <li>' . $link . "</li>";
                 }
             }
         }
         if (!empty($this->separator)) {
             $g = 0 - strlen($this->separator);
             $list = substr($list, 0, $g);
         } else {
             if (!empty($list)) {
                 $list .= "</ul>";
             }
         }
     } else {
         $parent = array();
         foreach ($value as $ar) {
             if ($ar == 'orphan') {
                 break;
             }
             $p_info = $myArr[$ar];
             if (($this->requiredParents == 'all' || in_array($p_info['parentId'], $this->requiredParents)) && !in_array($p_info['parentId'], $this->excludeParents)) {
                 $parent[$p_info['parentId']][] = $ar;
             }
         }
         foreach ($parent as $k => $v) {
             if (empty($this->separator)) {
                 $list .= "<h5>{$myArr[$k]['name']}</h5><ul class=\"categoryLinks\">";
                 foreach ($v as $t) {
                     $params = array('type' => 'category', 'id' => $t);
                     $link = smarty_function_object_link($params, $smarty);
                     $list .= "<li>" . $link . "</li>";
                 }
                 $list .= "</ul>";
             } else {
                 $list .= "{$myArr[$k]['name']}: ";
                 foreach ($v as $t) {
                     $params = array('type' => 'category', 'id' => $t);
                     $link = smarty_function_object_link($params, $smarty);
                     $list .= $link . $this->separator;
                 }
             }
             if (!empty($this->separator)) {
                 $g = 0 - strlen($this->separator);
                 $list = substr($list, 0, $g);
                 $list .= "<br />";
             }
         }
     }
     return '{HTML()}' . $list . '{HTML}';
 }
Exemple #11
0
 function getTabularSchema()
 {
     global $prefs;
     $schema = new Tracker\Tabular\Schema($this->getTrackerDefinition());
     $permName = $this->getConfiguration('permName');
     $baseKey = $this->getBaseKey();
     $name = $this->getConfiguration('name');
     $renderLink = function ($lang) {
         return function ($value, $extra) use($lang) {
             $smarty = TikiLib::lib('smarty');
             $smarty->loadPlugin('smarty_function_object_link');
             if (isset($extra['text'])) {
                 $value = $extra['text'];
             } elseif ($lang && isset($value[$lang])) {
                 $value = $lang;
             }
             if ($value) {
                 return smarty_function_object_link(['type' => 'trackeritem', 'id' => $extra['itemId'], 'title' => $value], $smarty);
             } else {
                 return '';
             }
         };
     };
     if ('y' !== $this->getConfiguration('isMultilingual', 'n')) {
         $schema->addNew($permName, 'default')->setLabel($name)->setRenderTransform(function ($value) {
             return $value;
         })->setParseIntoTransform(function (&$info, $value) use($permName) {
             $info['fields'][$permName] = $value;
         });
         $schema->addNew($permName, 'link')->setLabel($name)->setPlainReplacement('default')->addQuerySource('itemId', 'object_id')->addIncompatibility($permName, 'default')->setRenderTransform($renderLink(null));
     } else {
         $lang = $prefs['language'];
         $schema->addNew($permName, 'current')->setLabel(tr('%0 (%1)', $name, $lang))->setReadOnly(true)->addQuerySource('text', "{$baseKey}_{$lang}")->setRenderTransform(function ($value, $extra) use($lang) {
             if (isset($extra['text'])) {
                 return $extra['text'];
             } elseif ($lang && isset($value[$lang])) {
                 return $value[$lang];
             }
         });
         $schema->addNew($permName, "link-current")->setLabel($name)->setReadOnly(true)->setPlainReplacement($lang)->addQuerySource('itemId', 'object_id')->addQuerySource('text', "{$baseKey}_{$lang}")->setRenderTransform($renderLink($lang));
         foreach ($prefs['available_languages'] as $lang) {
             $schema->addNew($permName, $lang)->setLabel(tr('%0 (%1)', $name, $lang))->addQuerySource('text', "{$baseKey}_{$lang}")->setRenderTransform(function ($value, $extra) use($lang) {
                 if (isset($extra['text'])) {
                     return $extra['text'];
                 } elseif ($lang && isset($value[$lang])) {
                     return $value[$lang];
                 }
             })->setParseIntoTransform(function (&$info, $value) use($permName, $lang) {
                 $info['fields'][$permName][$lang] = $value;
             });
             $schema->addNew($permName, "link-{$lang}")->setLabel($name)->setPlainReplacement($lang)->addQuerySource('itemId', 'object_id')->addQuerySource('text', "{$baseKey}_{$lang}")->addIncompatibility($permName, 'default')->addIncompatibility($permName, $lang)->setRenderTransform($renderLink($lang));
         }
     }
     return $schema;
 }
Exemple #12
0
 function renderOutput($context = array())
 {
     $smarty = TikiLib::lib('smarty');
     $item = $this->getConfiguration('value');
     $dlist = $this->getConfiguration('listdisplay');
     $list = $this->getConfiguration('list');
     if (!is_array($item)) {
         // single value item field
         $items = array($item);
     } else {
         // item field has multiple values
         $items = $item;
     }
     $labels = array();
     foreach ($items as $key => $value) {
         if (!empty($dlist) && isset($dlist[$value])) {
             $labels[] = $dlist[$value];
         } else {
             if (isset($list[$value])) {
                 $labels[] = $list[$value];
             }
         }
     }
     $label = implode(', ', $labels);
     if ($item && !is_array($item) && $context['list_mode'] !== 'csv' && $this->getOption(2)) {
         $smarty->loadPlugin('smarty_function_object_link');
         if ($this->getOption(5)) {
             $link = smarty_function_object_link(array('type' => 'wiki page', 'id' => $this->getOption(5) . '&itemId=' . $item, 'title' => $label), $smarty);
             // decode & and = chars
             return str_replace(array('%26', '%3D'), array('&', '='), $link);
         } else {
             return smarty_function_object_link(array('type' => 'trackeritem', 'id' => $item, 'title' => $label), $smarty);
         }
     } elseif ($label) {
         return $label;
     }
 }
Exemple #13
0
 function renderOutput($context = array())
 {
     $smarty = TikiLib::lib('smarty');
     $item = $this->getValue();
     if (!is_array($item)) {
         // single value item field
         $items = array($item);
     } else {
         // item field has multiple values
         $items = $item;
     }
     $labels = array();
     foreach ($items as $i) {
         $labels[] = $this->getItemLabel($i, $context);
     }
     $label = implode(', ', $labels);
     if ($item && !is_array($item) && $context['list_mode'] !== 'csv' && $this->getOption('fieldId')) {
         $smarty->loadPlugin('smarty_function_object_link');
         if ($this->getOption('linkPage')) {
             $link = smarty_function_object_link(array('type' => 'wiki page', 'id' => $this->getOption('linkPage') . '&itemId=' . $item, 'title' => $label), $smarty);
             // decode & and = chars
             return str_replace(array('%26', '%3D'), array('&', '='), $link);
         } else {
             if ($this->getOption('linkToItem')) {
                 return smarty_function_object_link(array('type' => 'trackeritem', 'id' => $item, 'title' => $label), $smarty);
             } else {
                 return $label;
             }
         }
     } elseif ($context['list_mode'] == 'csv' && $item) {
         if ($label) {
             return $label;
         } else {
             return $item;
         }
     } elseif ($label) {
         return $label;
     }
 }
Exemple #14
0
 $offset = isset($_REQUEST['offset']) ? $_REQUEST['offset'] : 0;
 $maxRecords = empty($_REQUEST['maxRecords']) ? $prefs['maxRecords'] : $_REQUEST['maxRecords'];
 if ($access->is_serializable_request(true)) {
     $jitRequest->replaceFilter('fields', 'word');
     $fetchFields = array_merge(array('title', 'modification_date', 'url'), $jitRequest->asArray('fields', ','));
     $results = tiki_searchindex_get_results($filter, $postfilter, $offset, $maxRecords);
     $smarty->loadPlugin('smarty_function_object_link');
     $smarty->loadPlugin('smarty_modifier_sefurl');
     foreach ($results as &$res) {
         foreach ($fetchFields as $f) {
             if (isset($res[$f])) {
                 $res[$f];
                 // Dynamic load if applicable
             }
         }
         $res['link'] = smarty_function_object_link(array('type' => $res['object_type'], 'id' => $res['object_id'], 'title' => $res['title']), $smarty);
         $res = array_filter($res, function ($v) {
             return !is_null($v);
         });
         // strip out null values
     }
     $access->output_serialized($results, array('feedTitle' => tr('%0: Results for "%1"', $prefs['sitetitle'], isset($filter['content']) ? $filter['content'] : ''), 'feedDescription' => tr('Search Results'), 'entryTitleKey' => 'title', 'entryUrlKey' => 'url', 'entryModificationKey' => 'modification_date', 'entryObjectDescriptors' => array('object_type', 'object_id')));
     exit;
 } else {
     $cachelib = TikiLib::lib('cache');
     $cacheType = 'search';
     $cacheName = $user . '/' . $offset . '/' . $maxRecords . '/' . serialize($filter);
     $isCached = false;
     if (!empty($prefs['unified_user_cache']) && $cachelib->isCached($cacheName, $cacheType)) {
         list($date, $html) = $cachelib->getSerialized($cacheName, $cacheType);
         if ($date > $tikilib->now - $prefs['unified_user_cache'] * 60) {
Exemple #15
0
 function render($name, $value, array $entry)
 {
     $smarty = TikiLib::lib('smarty');
     $smarty->loadPlugin('smarty_function_object_link');
     $arr = TikiLib::lib('categ')->getCategories();
     $list = '';
     foreach ($arr as $arx) {
         $myArr[$arx['categId']] = array('parentId' => $arx['parentId'], 'name' => $arx['name'], 'tepath' => $arx['tepath']);
     }
     if ($this->singleList == 'y') {
         foreach ($value as $ar) {
             if ($ar == 'orphan') {
                 break;
             }
             $p_info = $myArr[$ar];
             $showCat = $this->shouldShow($p_info['tepath']);
             if ($showCat) {
                 if ($this->useFullPath == 'y') {
                     $foundRoot = false;
                     $printedPath = "";
                     foreach ($p_info['tepath'] as $key => $value) {
                         if ($foundRoot || $this->requiredParents == "all") {
                             $params = array('type' => 'category', 'id' => $key);
                             $link = smarty_function_object_link($params, $smarty);
                             if (empty($printedPath)) {
                                 $printedPath = $link;
                             } else {
                                 $printedPath .= $this->levelSeparator . $link;
                             }
                         } elseif (in_array($key, $this->requiredParents)) {
                             $foundRoot = true;
                         }
                     }
                 } else {
                     $printedPath = $p_info['name'];
                 }
                 if (!empty($this->separator)) {
                     $list .= $printedPath . $this->separator;
                 } else {
                     if (empty($list)) {
                         $list = "<ul class=\"categoryLinks\">";
                     }
                     $list .= ' <li>' . $printedPath . "</li>";
                 }
             }
         }
         if (!empty($this->separator)) {
             $g = 0 - strlen($this->separator);
             $list = substr($list, 0, $g);
         } else {
             if (!empty($list)) {
                 $list .= "</ul>";
             }
         }
     } else {
         $parent = array();
         foreach ($value as $ar) {
             if ($ar == 'orphan') {
                 break;
             }
             $p_info = $myArr[$ar];
             $showCat = $this->shouldShow($p_info['parentId']);
             if ($showCat) {
                 $parent[$p_info['parentId']][] = $ar;
             }
         }
         foreach ($parent as $k => $v) {
             if (empty($this->separator)) {
                 $list .= "<h5>{$myArr[$k]['name']}</h5><ul class=\"categoryLinks\">";
                 foreach ($v as $t) {
                     $params = array('type' => 'category', 'id' => $t);
                     $link = smarty_function_object_link($params, $smarty);
                     $list .= "<li>" . $link . "</li>";
                 }
                 $list .= "</ul>";
             } else {
                 $list .= "{$myArr[$k]['name']}: ";
                 foreach ($v as $t) {
                     $params = array('type' => 'category', 'id' => $t);
                     $link = smarty_function_object_link($params, $smarty);
                     $list .= $link . $this->separator;
                 }
             }
             if (!empty($this->separator)) {
                 $g = 0 - strlen($this->separator);
                 $list = substr($list, 0, $g);
                 $list .= "<br />";
             }
         }
     }
     return '~np~' . $list . '~/np~';
 }
Exemple #16
0
 function getTabularSchema()
 {
     $permName = $this->getConfiguration('permName');
     $baseKey = $this->getBaseKey();
     $name = $this->getConfiguration('name');
     $schema = new Tracker\Tabular\Schema($this->getTrackerDefinition());
     $schema->addNew($permName, 'userlink')->setLabel($name)->setPlainReplacement('username')->setRenderTransform(function ($value) {
         $smarty = TikiLib::lib('smarty');
         $smarty->loadPlugin('smarty_modifier_userlink');
         if ($value) {
             return smarty_modifier_userlink($value);
         }
     });
     $schema->addNew($permName, 'realname')->setLabel($name)->setReadOnly(true)->setRenderTransform(function ($value) {
         $smarty = TikiLib::lib('smarty');
         $smarty->loadPlugin('smarty_modifier_username');
         if ($value) {
             return smarty_modifier_username($value, true, false, false);
         }
     });
     $schema->addNew($permName, 'username-itemlink')->setLabel($name)->setPlainReplacement('username')->addQuerySource('itemId', 'object_id')->setRenderTransform(function ($value, $extra) {
         $smarty = TikiLib::lib('smarty');
         $smarty->loadPlugin('smarty_function_object_link');
         if ($value) {
             return smarty_function_object_link(['type' => 'trackeritem', 'id' => $extra['itemId'], 'title' => $value], $smarty);
         }
     });
     $schema->addNew($permName, 'realname-itemlink')->setLabel($name)->setPlainReplacement('realname')->addQuerySource('itemId', 'object_id')->setRenderTransform(function ($value, $extra) {
         $smarty = TikiLib::lib('smarty');
         $smarty->loadPlugin('smarty_function_object_link');
         $smarty->loadPlugin('smarty_modifier_username');
         if ($value) {
             return smarty_function_object_link(['type' => 'trackeritem', 'id' => $extra['itemId'], 'title' => smarty_modifier_username($value, true, false, false)], $smarty);
         }
     });
     $schema->addNew($permName, 'username')->setLabel($name)->setRenderTransform(function ($value) {
         return $value;
     })->setParseIntoTransform(function (&$info, $value) use($permName) {
         $info['fields'][$permName] = $value;
     });
     return $schema;
 }