function action_select($input) { $categlib = TikiLib::lib('categ'); $objectlib = TikiLib::lib('object'); $smarty = TikiLib::lib('smarty'); $type = $input->type->text(); $object = $input->object->text(); $perms = Perms::get($type, $object); if (!$perms->modify_object_categories) { throw new Services_Exception_Denied('Not allowed to modify categories'); } $input->replaceFilter('subset', 'int'); $subset = $input->asArray('subset', ','); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $smarty->loadPlugin('smarty_modifier_sefurl'); $name = $objectlib->get_title($type, $object); $url = smarty_modifier_sefurl($object, $type); $targetCategories = (array) $input->categories->int(); $count = $categlib->update_object_categories($targetCategories, $object, $type, '', $name, $url, $subset, false); } $categories = $categlib->get_object_categories($type, $object); return array('subset' => implode(',', $subset), 'categories' => array_combine($subset, array_map(function ($categId) use($categories) { return array('name' => TikiLib::lib('object')->get_title('category', $categId), 'selected' => in_array($categId, $categories)); }, $subset))); }
function action_list($input) { global $prefs; $unifiedsearchlib = TikiLib::lib('unifiedsearch'); $index = $unifiedsearchlib->getIndex(); $dataSource = $unifiedsearchlib->getDataSource(); $start = 'tracker_field_' . $input->beginField->word(); $end = 'tracker_field_' . $input->endField->word(); if ($resource = $input->resourceField->word()) { $resource = 'tracker_field_' . $resource; } if ($coloring = $input->coloringField->word()) { $coloring = 'tracker_field_' . $coloring; } $query = $unifiedsearchlib->buildQuery(array()); $query->filterRange($input->start->int(), $input->end->int(), array($start, $end)); $query->setRange(0, $prefs['unified_lucene_max_result']); if ($body = $input->filters->none()) { $builder = new Search_Query_WikiBuilder($query); $builder->apply(WikiParser_PluginMatcher::match($body)); } $result = $query->search($index); $result = $dataSource->getInformation($result, array('title', $start, $end)); $response = array(); $smarty = TikiLib::lib('smarty'); $smarty->loadPlugin('smarty_modifier_sefurl'); foreach ($result as $row) { $item = Tracker_Item::fromId($row['object_id']); $response[] = array('id' => $row['object_id'], 'trackerId' => isset($row['tracker_id']) ? $row['tracker_id'] : null, 'title' => $row['title'], 'description' => '', 'url' => smarty_modifier_sefurl($row['object_id'], $row['object_type']), 'allDay' => false, 'start' => (int) $row[$start], 'end' => (int) $row[$end], 'editable' => $item->canModify(), 'color' => $this->getColor(isset($row[$coloring]) ? $row[$coloring] : ''), 'textColor' => '#000', 'resource' => $resource && isset($row[$resource]) ? $row[$resource] : ''); } return $response; }
function smarty_block_title($params, $content, $template, &$repeat) { global $prefs, $tiki_p_view_templates, $tiki_p_edit_templates, $tiki_p_admin; if ($repeat || empty($content)) { return; } $template->loadPlugin('smarty_function_icon'); $template->loadPlugin('smarty_modifier_sefurl'); $template->loadPlugin('smarty_modifier_escape'); if (!isset($params['help'])) { $params['help'] = ''; } if (!isset($params['admpage'])) { $params['admpage'] = ''; } if (!isset($params['actions'])) { $params['actions'] = ''; } // Set the variable for the HTML title tag $template->smarty->assign('headtitle', $content); $class = ''; $current = current_object(); if (!isset($params['url'])) { $params['url'] = smarty_modifier_sefurl($current['object'], $current['type']); } $metadata = ''; $coordinates = TikiLib::lib('geo')->get_coordinates($current['type'], $current['object']); if ($coordinates) { $class = ' geolocated primary'; $metadata = " data-geo-lat=\"{$coordinates['lat']}\" data-geo-lon=\"{$coordinates['lon']}\""; if (isset($coordinates['zoom'])) { $metadata .= " data-geo-zoom=\"{$coordinates['zoom']}\""; } } $html = '<h1 class="pagetitle">'; $html .= '<a class="' . $class . '"' . $metadata . ' href="' . $params['url'] . '">' . smarty_modifier_escape($content) . "</a>\n"; if ($template->getTemplateVars('print_page') != 'y') { if ($prefs['feature_help'] == 'y' && $prefs['helpurl'] != '' && $params['help'] != '') { $html .= '<a href="'; $html .= $prefs['helpurl'] . rawurlencode($params['help']) . '" class="tips btn btn-link" title="' . smarty_modifier_escape($content) . '|' . tra('Help page') . '" target="tikihelp">' . smarty_function_icon(array('name' => 'help'), $template) . "</a>\n"; } if ($prefs['feature_edit_templates'] == 'y' && $tiki_p_edit_templates == 'y' && ($tpl = $template->getTemplateVars('mid'))) { $html .= '<a href="tiki-edit_templates.php?template='; $html .= $tpl . '" class="tips btn btn-link" title="' . tra('View or edit tpl') . '|' . htmlspecialchars($content) . '">' . smarty_function_icon(array('name' => 'edit'), $template) . "</a>\n"; } elseif ($prefs['feature_view_tpl'] == 'y' && $tiki_p_view_templates == 'y' && ($tpl = $template->getTemplateVars('mid'))) { $html .= '<a href="tiki-edit_templates.php?template='; $html .= $tpl . '" class="tips btn btn-link" title="' . tra('View tpl') . '|' . htmlspecialchars($content) . '">' . smarty_function_icon(array('name' => 'view'), $template) . "</a>\n"; } if ($tiki_p_admin == 'y' && $params['admpage'] != '') { $html .= '<a class="tips btn btn-link" href="tiki-admin.php?page='; $html .= $params['admpage'] . '" title="' . htmlspecialchars($content) . '|' . tra('Settings') . '">' . smarty_function_icon(array('name' => 'settings'), $template) . "</a>\n"; } if ($params['actions'] != '') { $html .= $params['actions']; } } $html .= '</h1>'; return $html; }
function getData($objectType, $objectId, Search_Type_Factory_Interface $typeFactory, array $data = array()) { if (isset($data['url'])) { return false; } $url = smarty_modifier_sefurl($objectId, $objectType); return array('url' => $typeFactory->identifier($url)); }
function getGroups($token, $entry, $parameters) { // Process deletion of temporary users that are created via tokens $usersToDelete = $this->db->fetchAll('SELECT tokenId, userPrefix FROM tiki_auth_tokens WHERE (timeout != -1 AND UNIX_TIMESTAMP(creation) + timeout < UNIX_TIMESTAMP()) OR `hits` = 0'); foreach ($usersToDelete as $del) { TikiLib::lib('user')->remove_temporary_user($del['userPrefix'] . $del['tokenId']); } $this->db->query('DELETE FROM tiki_auth_tokens WHERE (timeout != -1 AND UNIX_TIMESTAMP(creation) + timeout < UNIX_TIMESTAMP()) OR `hits` = 0'); $data = $this->db->query('SELECT tokenId, entry, parameters, groups, email, createUser, userPrefix FROM tiki_auth_tokens WHERE token = ? AND token = ' . self::SCHEME, array($token))->fetchRow(); global $prefs, $full, $smarty, $tikiroot; // $full defined in route.php $sefurl = ''; if ($prefs['feature_sefurl'] === 'y') { $sefurl = substr($full, strlen($tikiroot)) . '?' . http_build_query($_GET); $sefurlTypeMap = $this->getSefurlTypeMap(); $smarty->loadPlugin('smarty_modifier_sefurl'); $sefurl = $tikiroot . smarty_modifier_sefurl($sefurl, $sefurlTypeMap[$_GET[0]]); } // entry doesn't match "or" sefurl feature is in use but that also doesn't match if ($data['entry'] != $entry && $sefurl && $data['entry'] !== $sefurl) { return null; } $registered = (array) json_decode($data['parameters'], true); if (!$this->allPresent($registered, $parameters) || !$this->allPresent($parameters, $registered)) { return null; } $this->db->query('UPDATE `tiki_auth_tokens` SET `hits` = `hits` - 1 WHERE `tokenId` = ? AND hits != -1', array($data['tokenId'])); // Process autologin of temporary users if ($data['createUser'] == 'y') { $userlib = TikiLib::lib('user'); $tempuser = $data['userPrefix'] . $userlib->autogenerate_login($data['tokenId'], 6); $groups = json_decode($data['groups'], true); $parameters = json_decode($data['parameters'], true); if (!$userlib->user_exists($tempuser)) { $randompass = $userlib->genPass(); $userlib->add_user($tempuser, $randompass, $data['email'], '', false, NULL, NULL, NULL, $groups); } $userlib->autologin_user($tempuser); $url = basename($data['entry']); if ($parameters) { $query = '?' . http_build_query($parameters, '', '&'); $url .= $query; } include_once 'tiki-sefurl.php'; $url = filter_out_sefurl($url); TikiLib::lib('access')->redirect($url); die; } $this->ok = true; return (array) json_decode($data['groups'], true); }
function action_list($input) { global $prefs; $unifiedsearchlib = TikiLib::lib('unifiedsearch'); $index = $unifiedsearchlib->getIndex(); $dataSource = $unifiedsearchlib->getDataSource(); $start = 'tracker_field_' . $input->beginField->word(); $end = 'tracker_field_' . $input->endField->word(); if ($resource = $input->resourceField->word()) { $resource = 'tracker_field_' . $resource; } if ($coloring = $input->coloringField->word()) { $coloring = 'tracker_field_' . $coloring; } $query = $unifiedsearchlib->buildQuery(array()); $query->filterRange($input->start->int(), $input->end->int(), array($start, $end)); $query->setRange(0, $prefs['unified_lucene_max_result']); if ($body = $input->filters->none()) { $builder = new Search_Query_WikiBuilder($query); $builder->apply(WikiParser_PluginMatcher::match($body)); } $result = $query->search($index); $result = $dataSource->getInformation($result, array('title', $start, $end)); $response = array(); $fields = array(); if ($definition = Tracker_Definition::get($input->trackerId->int())) { foreach ($definition->getPopupFields() as $fieldId) { if ($field = $definition->getField($fieldId)) { $fields[] = $field; } } } $smarty = TikiLib::lib('smarty'); $smarty->loadPlugin('smarty_modifier_sefurl'); $trklib = TikiLib::lib('trk'); foreach ($result as $row) { $item = Tracker_Item::fromId($row['object_id']); $description = ''; foreach ($fields as $field) { if ($item->canViewField($field['fieldId'])) { $val = trim($trklib->field_render_value(array('field' => $field, 'item' => $item->getData(), 'process' => 'y'))); if ($val) { if (count($fields) > 1) { $description .= "<h5>{$field['name']}</h5>"; } $description .= $val; } } } $response[] = array('id' => $row['object_id'], 'trackerId' => isset($row['tracker_id']) ? $row['tracker_id'] : null, 'title' => $row['title'], 'description' => $description, 'url' => smarty_modifier_sefurl($row['object_id'], $row['object_type']), 'allDay' => false, 'start' => $this->getTimestamp($row[$start]), 'end' => $this->getTimestamp($row[$end]), 'editable' => $item->canModify(), 'color' => $this->getColor(isset($row[$coloring]) ? $row[$coloring] : ''), 'textColor' => '#000', 'resource' => $resource && isset($row[$resource]) ? strtolower($row[$resource]) : ''); } return $response; }
public function renderOutput($context = array()) { if ($this->isLink($context)) { $itemId = $this->getItemId(); $query = $_GET; unset($query['trackerId']); if (isset($query['page'])) { $query['from'] = $query['page']; unset($query['page']); } $classList = array('tablename'); $metadata = TikiLib::lib('object')->get_metadata('trackeritem', $itemId, $classList); require_once 'lib/smarty_tiki/modifier.sefurl.php'; $href = smarty_modifier_sefurl($itemId, 'trackeritem'); $href .= strpos($href, '?') === false ? '?' : '&'; $href .= http_build_query($query, '', '&'); $arguments = array('class' => implode(' ', $classList), 'href' => $href); if (!empty($context['url'])) { if (strpos($context['url'], 'itemId') !== false) { $context['url'] = preg_replace('/([&|\\?])itemId=?[^&]*/', '\\1itemId=' . $itemId, $context['url']); } elseif (isset($context['reloff']) && strpos($context['url'], 'offset') !== false) { global $smarty; $context['url'] = preg_replace('/([&|\\?])tr_offset=?[^&]*/', '\\1tr_offset' . $smarty->tpl_vars['iTRACKERLIST'] . '=' . $context['reloff'], $context['url']); } $arguments['href'] = $context['url']; } $pre = '<a'; foreach ($arguments as $key => $value) { $pre .= ' ' . $key . '="' . htmlentities($value, ENT_QUOTES, 'UTF-8') . '"'; } if (isset($context['showpopup']) && $context['showpopup'] == 'y') { $popup = $this->renderPopup(); if ($popup) { $popup = preg_replace('/<\\!--.*?-->/', '', $popup); // remove comments added by log_tpl $popup = preg_replace('/\\s+/', ' ', $popup); $pre .= " {$popup}"; } } $pre .= $metadata; $pre .= '>'; $post = '</a>'; return $pre . $this->renderInnerOutput($context) . $post; } else { return $this->renderInnerOutput($context); } }
function smarty_function_object_link_default($smarty, $object, $title = null, $type = 'wiki page', $url = null) { global $base_url; $smarty->loadPlugin('smarty_modifier_sefurl'); $smarty->loadPlugin('smarty_modifier_escape'); if (empty($title)) { $title = TikiLib::lib('object')->get_title($type, $object); } if (empty($title) && $type == 'freetag') { // Blank freetag should not be returned with "No title specified" return ''; } $escapedPage = smarty_modifier_escape($title ? $title : tra('No title specified')); if ($url) { $escapedHref = smarty_modifier_escape($url); } else { $escapedHref = smarty_modifier_escape(smarty_modifier_sefurl($object, $type)); } $classList = array(); if ($type == "blog post") { $classList[] = "link"; } elseif ($type == "freetag") { $classList[] = 'freetag'; } $metadata = TikiLib::lib('object')->get_metadata($type, $object, $classList); $class = ' class="' . implode(' ', $classList) . '"'; $html = '<a href="' . $base_url . $escapedHref . '"' . $class . $metadata . '>' . $escapedPage . '</a>'; $attributelib = TikiLib::lib('attribute'); $attributes = $attributelib->get_attributes($type, $object); global $prefs; if (isset($attributes['tiki.content.source']) && $prefs['fgal_source_show_refresh'] == 'y') { $smarty->loadPlugin('smarty_function_icon'); $smarty->loadPlugin('smarty_function_service'); $html .= '<a class="file-refresh" href="' . smarty_function_service(array('controller' => 'file', 'action' => 'refresh', 'fileId' => intval($object)), $smarty) . '">' . smarty_function_icon(array('_id' => 'arrow_refresh'), $smarty) . '</a>'; TikiLib::lib('header')->add_js(' $(".file-refresh").removeClass("file-refresh").click(function () { $.getJSON($(this).attr("href")); $(this).remove(); return false; });'); } return $html; }
public function renderInnerOutput($context = array()) { $selected_categories = $this->getConfiguration('selected_categories'); $categories = $this->getConfiguration('list'); $ret = array(); foreach ($selected_categories as $categId) { foreach ($categories as $category) { if ($category['categId'] == $categId) { if ($this->getOption('descendants') == 2) { $str = $category['relativePathString']; } else { $str = $category['name']; } if (strpos($this->getOption('outputtype'), 'links') !== false) { TikiLib::lib('smarty')->loadPlugin('smarty_modifier_sefurl'); $deep = $this->getOption('descendants') != 0; $href = smarty_modifier_sefurl($categId, 'category', $deep, '', 'y', $str); if ($deep) { $href .= 'deep=on'; } $str = "<a href=\"{$href}\">{$str}</a>"; } $ret[] = $str; break; } } } if (strpos($this->getOption('outputtype'), 'ul') === 0) { if (count($ret)) { $out = '<ul class="tracker_field_category">'; foreach ($ret as $li) { $out .= '<li>' . $li . '</li>'; } $out .= '</ul>'; return $out; } else { return ''; } } else { return implode('<br/>', $ret); } }
private function getItemList($itemIds) { $trklib = TikiLib::lib('trk'); require_once 'lib/smarty_tiki/modifier.sefurl.php'; $out = array(); foreach ($itemIds as $itemId) { $out[] = array('itemId' => $itemId, 'title' => $trklib->get_isMain_value(null, $itemId), 'localUrl' => smarty_modifier_sefurl($itemId, 'trackeritem')); } return $out; }
function _breadcrumb_getTitle($crumbs, $loc) { global $prefs, $print_page, $info, $structure, $structure_path, $tikilib, $smarty; $len = count($crumbs); if ($prefs['feature_breadcrumbs'] == 'n' || $prefs['feature_sitetitle'] == 'title') { $smarty->loadPlugin('smarty_modifier_sefurl'); $smarty->loadPlugin('smarty_modifier_escape'); $class = "pagetitle"; $metadata = ''; $current = current_object(); $escapedHref = smarty_modifier_escape(smarty_modifier_sefurl($current['object'], $current['type'])); if ($coordinates = TikiLib::lib('geo')->get_coordinates($current['type'], $current['object'])) { $class = ' geolocated primary'; $metadata = " data-geo-lat=\"{$coordinates['lat']}\" data-geo-lon=\"{$coordinates['lon']}\""; if (isset($coordinates['zoom'])) { $metadata .= " data-geo-zoom=\"{$coordinates['zoom']}\""; } } $ret = '<strong><a class="' . $class . '"' . $metadata . ' title="' . tra("refresh") . '" href="' . $escapedHref . '">'; } else { $class = "crumblink"; $ret = '<a class="' . $class . '" title="'; if ($structure == 'y' && $info) { $cnt = count($structure_path); } else { $cnt = count($crumbs); } $ret .= tra("go back to this crumb"); $ret .= '" accesskey="' . $cnt; include_once 'tiki-sefurl.php'; $ret .= '" href="' . filter_out_sefurl($crumbs[$len - 1]->url) . '">'; } if ($prefs['feature_breadcrumbs'] == 'n' && $loc == "admin") { $ret .= tra("Administration:") . " "; } if (!empty($prefs['wiki_pagename_strip'])) { include_once 'lib/smarty_tiki/modifier.pagename.php'; $ret .= tra(smarty_modifier_pagename($crumbs[$len - 1]->title)) . '</a>'; } else { $ret .= htmlentities(tra($crumbs[$len - 1]->title), ENT_QUOTES, 'UTF-8') . '</a>'; } $ret .= help_doclink(array('crumb' => $crumbs[$len - 1])); if (isset($info['flag']) && $info['flag'] == 'L' && $print_page != 'y') { $ret .= ' <img src="img/icons/lock.png" height="16" width="16" alt="' . tra('locked') . '" title="' . tra('locked by') . ' ' . $info['user'] . '" />'; } if ($prefs['feature_breadcrumbs'] == 'n' || $prefs['feature_sitetitle'] == 'title') { $ret .= '</strong>'; } return $ret; }
function getDocumentPart(Search_Type_Factory_Interface $typeFactory) { if ($this->getOption('indexGeometry') && $this->getValue()) { TikiLib::lib('smarty')->loadPlugin('smarty_modifier_sefurl'); $urls = array(); foreach (explode(',', $this->getValue()) as $value) { $urls[] = smarty_modifier_sefurl($value, 'file'); } return array('geo_located' => $typeFactory->identifier('y'), 'geo_file' => $typeFactory->identifier(implode(',', $urls)), 'geo_file_format' => $typeFactory->identifier($this->getOption('indexGeometry'))); } else { return parent::getDocumentPart($typeFactory); } }
function _breadcrumb_getTitle($crumbs, $loc) { global $prefs, $print_page, $info, $structure, $structure_path; $smarty = TikiLib::lib('smarty'); $tikilib = TikiLib::lib('tiki'); $len = count($crumbs); if ($prefs['feature_breadcrumbs'] == 'n' || $prefs['feature_sitetitle'] == 'title') { $smarty->loadPlugin('smarty_modifier_sefurl'); $smarty->loadPlugin('smarty_modifier_escape'); $class = ""; $metadata = ''; $current = current_object(); $escapedHref = smarty_modifier_escape(smarty_modifier_sefurl($current['object'], $current['type'])); if ($coordinates = TikiLib::lib('geo')->get_coordinates($current['type'], $current['object'])) { $class = ' geolocated primary'; $metadata = " data-geo-lat=\"{$coordinates['lat']}\" data-geo-lon=\"{$coordinates['lon']}\""; if (isset($coordinates['zoom'])) { $metadata .= " data-geo-zoom=\"{$coordinates['zoom']}\""; } } $ret = '<a class="' . $class . '"' . $metadata . ' title="' . tra("refresh") . '" href="' . $escapedHref . '">'; } else { $class = "crumblink"; $ret = '<a class="' . $class . '" title="'; if ($structure == 'y' && $info) { $cnt = count($structure_path); } else { $cnt = count($crumbs); } $ret .= tra("go back to this crumb"); $ret .= '" accesskey="' . $cnt; include_once 'tiki-sefurl.php'; $ret .= '" href="' . filter_out_sefurl($crumbs[$len - 1]->url) . '">'; } if ($prefs['feature_breadcrumbs'] == 'n' && $loc == "admin") { $ret .= tra("Administration:") . " "; } // Should show alias if in structure $cur_title = $crumbs[$len - 1]->title; if ($structure == 'y') { foreach ($structure_path as $crumb) { if ($crumb['pageName'] == $cur_title && $crumb['page_alias'] != '') { $cur_title = $crumb['page_alias']; } } } if (!empty($prefs['wiki_pagename_strip'])) { include_once 'lib/smarty_tiki/modifier.pagename.php'; $ret .= tra(smarty_modifier_pagename($cur_title)) . '</a>'; } else { $ret .= htmlentities(tra($cur_title), ENT_QUOTES, 'UTF-8') . '</a>'; } $ret .= help_doclink(array('crumb' => $crumbs[$len - 1])); if (isset($info['flag']) && $info['flag'] == 'L' && $print_page != 'y') { $smarty->loadPlugin('smarty_function_icon'); $ret .= smarty_function_icon(['name' => 'lock', 'iclass' => 'tips', 'ititle' => ':' . tra('Locked by') . $info['user']], $smarty); } return $ret; }
function generate_feed_from_data($data, $feed_descriptor) { require_once 'lib/smarty_tiki/modifier.sefurl.php'; $tikilib = TikiLib::lib('tiki'); $writer = new Zend_Feed_Writer_Feed(); $writer->setTitle($feed_descriptor['feedTitle']); $writer->setDescription($feed_descriptor['feedDescription']); $writer->setLink($tikilib->tikiUrl('')); $writer->setDateModified(time()); foreach ($data as $row) { $titleKey = $feed_descriptor['entryTitleKey']; $url = $row[$feed_descriptor['entryUrlKey']]; $title = $row[$titleKey]; if (isset($feed_descriptor['entryObjectDescriptors'])) { list($typeKey, $objectKey) = $feed_descriptor['entryObjectDescriptors']; $object = $row[$objectKey]; $type = $row[$typeKey]; if (empty($url)) { $url = smarty_modifier_sefurl($object, $type); } if (empty($title)) { $title = TikiLib::lib('object')->get_title($type, $object); } } $entry = $writer->createEntry(); $entry->setTitle($title ? $title : tra('Unspecified')); $entry->setLink($tikilib->tikiUrl($url)); $entry->setDateModified($row[$feed_descriptor['entryModificationKey']]); $writer->addEntry($entry); } return $writer; }
function wikiplugin_img( $data, $params, $offset, $parseOptions='' ) { global $tikidomain, $prefs, $section, $smarty, $tikiroot, $tikilib, $userlib, $user, $tiki_p_upload_files; $imgdata = array(); $imgdata['src'] = ''; $imgdata['id'] = ''; $imgdata['fileId'] = ''; $imgdata['randomGalleryId'] = ''; $imgdata['fgalId'] = ''; $imgdata['sort_mode'] = ''; $imgdata['attId'] = ''; $imgdata['thumb'] = ''; $imgdata['button'] = ''; $imgdata['link'] = ''; $imgdata['rel'] = ''; $imgdata['usemap'] = ''; $imgdata['height'] = ''; $imgdata['width'] = ''; $imgdata['max'] = ''; $imgdata['imalign'] = ''; $imgdata['styleimage'] = ''; $imgdata['align'] = ''; $imgdata['stylebox'] = ''; $imgdata['styledesc'] = ''; $imgdata['block'] = ''; $imgdata['class'] = ''; $imgdata['desc'] = ''; $imgdata['title'] = ''; $imgdata['metadata'] = ''; $imgdata['alt'] = ''; $imgdata['default'] = ''; $imgdata['mandatory'] = ''; /*Admin default and mandatory settings (must be set by changing this fle or using plugin alias). Default will be used if not overridden by user. Mandatory will override user settings. Examples below set parameters depending on whether the image is in an article, a module, or whether mobile mode is set, etc.*/ //Uncomment the following line to set the default parameter. Later items have priority. To override align default, put align parameter first // $imgdata['default'] = 'default ? max = 200, align = right, styledesc = text-align: center; section_cms_article ? max= 400, width= , height='; // Uncomment the following line to set the default parameter. Force certain max and ignore any specified width or height. Later items have priority // $imgdata['mandatory'] = 'section_cms_article ? max = 400; module_* ? max = 150, width= , height=; mode_mobile ? max = 150, width= , height=;'; $imgdata = array_merge($imgdata, $params); //////////////////////////////////////////////////Function for processing default and mandatory parameters////////////////////////////////////// //function calls are just below function if (!function_exists('apply_default_and_mandatory')) { function apply_default_and_mandatory($imgdata, $default) { global $section, $smarty; $imgdata[$default] = trim($imgdata[$default]) . ';'; // trim whitespace and ensure at least one semicolon $img_conditions_array = explode(';', $imgdata[$default]); // conditions separated by semicolons if ( !empty($img_conditions_array) ) { foreach ($img_conditions_array as $key => $var) { // for each condition if ( !empty($var) ) { $img_condition = explode('?', $var); // condition separated from parameters by question mark if ( !empty($img_condition) ) { $img_condition_name = trim($img_condition[0]); if ( !empty($img_condition[1]) ) { // if there is at least one parameter $img_condition[1] = trim($img_condition[1]) . ','; // at least one comma $img_parameters_array = explode(',', $img_condition[1]); // separate multiple parameters if ( !empty($img_parameters_array) ) { // if a parameter has been extracted foreach ($img_parameters_array as $param_key => $param_var) { // for each parameter if ( !empty($param_var) ) { // if a parameter exists $img_parameter_array = explode('=', trim($param_var)); // separate parameters and values if ( !empty($img_parameter_array[0]) ) { // if a parameter with a value has been extracted $img_condition_status = false; // initialise condition as not being true $img_condition_name = strtolower(trim($img_condition_name)); switch ($img_condition_name) { case 'default': $img_condition_status = true; // default is always true break; case 'mode_mobile': if ( isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'mobile' ) $img_condition_status = true; break; case 'module_*': if ( !empty($smarty) ) { $image_module_params = $smarty->getTemplateVars('module_params'); if ( !empty($image_module_params) ) $img_condition_status = true; } break; case 'section_*': if ( !empty($section) ) $img_condition_status = true; break; case 'section_cms_article': if ( !empty($section) ) { if ( $section == 'cms' ) { if ( !empty($smarty) ) { $image_article_type = $smarty->getTemplateVars('type'); if ( !empty($image_article_type) ) { if ( strtolower(trim($image_article_type)) == 'article' ) $img_condition_status = true; } // if (!empty($image_article_type)) } // if (!empty($smarty)) } } break; case 'section_cms_review': if ( !empty($section) ) { if ( $section == 'cms' ) { if ( !empty($smarty) ) { $image_article_type = $smarty->getTemplateVars('type'); if ( !empty($image_article_type) ) { if ( strtolower(trim($image_article_type)) == 'review' ) $img_condition_status = true; } // if (!empty($image_article_type)) } // if (!empty($smarty)) } } break; case 'section_cms_event': if ( !empty($section) ) { if ( $section == 'cms' ) { if ( !empty($smarty) ) { $image_article_type = $smarty->getTemplateVars('type'); if ( !empty($image_article_type) ) { if ( strtolower(trim($image_article_type)) == 'event' ) $img_condition_status = true; } // if (!empty($image_article_type)) } // if (!empty($smarty)) } } break; case 'section_cms_classified': if ( !empty($section) ) { if ( $section == 'cms' ) { if ( !empty($smarty) ) { $image_article_type = $smarty->getTemplateVars('type'); if ( !empty($image_article_type) ) { if ( strtolower(trim($image_article_type)) == 'classified' ) $img_condition_status = true; } // if (!empty($image_article_type)) } // if (!empty($smarty)) } } break; } // switch ($img_condition_name) if ( $img_condition_status != true ) { // if match not found yet, examine more specific conditions if ( !empty($section) ) { // if we have a section name if ( substr($img_condition_name, 0, 8) == 'section_' ) { if ( strlen($img_condition_name) > 8 ) { $img_condition_part = substr($img_condition, 8); // get part after "section_" $img_condition_part = strtolower($img_condition_part); $img_condition_part = trim(strtr($img_condition_part, '_', ' ')); // replace underscore with spaces if ( $section == $img_condition_part ) $img_condition_status = true; } // if ( length($img_condition_name) > 8 ) } // if ( substr($img_condition_name,0,8) == "section_" ) } // if ( !empty($section) ) } if ( $img_condition_status == true ) { // set the parameters to their values switch (strtolower(trim($img_parameter_array[0]))) { case 'src': $imgdata['src'] = trim($img_parameter_array[1]); break; case 'id': $imgdata['id'] = trim($img_parameter_array[1]); break; case 'fileId': $imgdata['fileId'] = trim($img_parameter_array[1]); break; case 'randomGalleryId': $imgdata['randomGalleryId'] = trim($img_parameter_array[1]); break; case 'fgalId': $imgdata['fgalId'] = trim($img_parameter_array[1]); break; case 'sort_mode': $imgdata['sort_mode'] = trim($img_parameter_array[1]); break; case 'attId': $imgdata['attId'] = trim($img_parameter_array[1]); break; case 'thumb': $imgdata['thumb'] = trim($img_parameter_array[1]); break; case 'button': $imgdata['button'] = trim($img_parameter_array[1]); break; case 'link': $imgdata['link'] = trim($img_parameter_array[1]); break; case 'rel': $imgdata['rel'] = trim($img_parameter_array[1]); break; case 'usemap': $imgdata['usemap'] = trim($img_parameter_array[1]); break; case 'height': $imgdata['height'] = trim($img_parameter_array[1]); break; case 'width': $imgdata['width'] = trim($img_parameter_array[1]); break; case 'max': $imgdata['max'] = trim($img_parameter_array[1]); break; case 'imalign': $imgdata['imalign'] = trim($img_parameter_array[1]); break; case 'styleimage': $imgdata['styleimage'] = trim($img_parameter_array[1]); break; case 'align': $imgdata['align'] = trim($img_parameter_array[1]); break; case 'stylebox': $imgdata['stylebox'] = trim($img_parameter_array[1]); break; case 'styledesc': $imgdata['styledesc'] = trim($img_parameter_array[1]); break; case 'block': $imgdata['block'] = trim($img_parameter_array[1]); break; case 'class': $imgdata['class'] = trim($img_parameter_array[1]); break; case 'desc': $imgdata['desc'] = trim($img_parameter_array[1]); break; case 'title': $imgdata['title'] = trim($img_parameter_array[1]); break; case 'metadata': $imgdata['metadata'] = trim($img_parameter_array[1]); break; case 'alt': $imgdata['alt'] = trim($img_parameter_array[1]); break; } // switch ($img_parameter_array[0]) } // if ( $img_condition_status == true ) } // if ( !empty($img_parameter_array[0] ) } // if a parameter exists } // for each parameter } // if ( !empty($img_parameters_array) ) } // if ( !empty($img_condition[1]) ) } // if ( !empty($img_condition) ) } // if ( !empty($var) ) } // for each condition } // if ( !empty($img_conditions_array) ) return $imgdata; } } ////////////////////////////////////End of function for processing default and mandatory parameters//////////////////// //function calls if ( !empty($imgdata['default']) || !empty($imgdata['mandatory'])) { if (!empty($imgdata['default'])) { $imgdata = apply_default_and_mandatory($imgdata, 'default'); //first process defaults $imgdata = array_merge($imgdata, $params); //then apply user settings, overriding defaults } //apply mandatory settings, overriding user settings if (!empty($imgdata['mandatory'])) $imgdata = apply_default_and_mandatory($imgdata, 'mandatory'); } //////////////////////////////////////////////////// Error messages and clean javascript ////////////////////////////// // Must set at least one image identifier $set = !empty($imgdata['fileId']) + !empty($imgdata['id']) + !empty($imgdata['src']) + !empty($imgdata['attId']) + !empty($imgdata['randomGalleryId']) + !empty($imgdata['fgalId']); if ($set == 0) { return tra("''No image specified. One of the following parameters must be set: fileId, randomGalleryId, fgalId, attId, id.''"); } elseif ($set >1) { return tra("''Use one and only one of the following parameters: fileId, randomGalleryId, fgalId, attId, id, or src.''"); } // Clean up src URLs to exclude javascript if (stristr(str_replace(' ', '', $imgdata['src']), 'javascript:')) { $imgdata['src'] = ''; } if (strstr($imgdata['src'], 'javascript:')) { $imgdata['src'] = ''; } if (!isset($data) or !$data) { $data = ' '; } include_once('tiki-sefurl.php'); //////////////////////Process multiple images ////////////////////////////////////// //Process "|" or "," separated images $notice = '<!--' . tra('PluginImg: User lacks permission to view image') . '-->'; $srcmash = $imgdata['fileId'] . $imgdata['id'] . $imgdata['attId'] . $imgdata['src']; if (( strpos($srcmash, '|') !== false ) || (strpos($srcmash, ',') !== false ) || !empty($imgdata['fgalId'])) { $separator = ''; $id = ''; if (!empty($imgdata['id'])) { $id = 'id'; } elseif (!empty($imgdata['fileId'])) { $id = 'fileId'; } elseif (!empty($imgdata['attId'])) { $id = 'attId'; } else { $id = 'src'; } if ( strpos($imgdata[$id], '|') !== false ) { $separator = '|'; } elseif ( strpos($imgdata[$id], ',') !== false ) { $separator = ','; } $repl = ''; $id_list = array(); if (!empty($separator)) { $id_list = explode($separator, $imgdata[$id]); } else { //fgalId parameter - show all images in a file gallery $filegallib = TikiLib::lib('filegal'); $galdata = $filegallib->get_files(0, -1, 'created_desc', '', $imgdata['fgalId'], false, false, false, true, false, false, false, false, '', true, false, false); foreach ($galdata['data'] as $filedata) { $id_list[] = $filedata['id']; } $id = 'fileId'; } $params[$id] = ''; foreach ($id_list as $i => $value) { $params[$id] = trim($value); $params['fgalId'] = ''; $repl .= wikiplugin_img($data, $params, $offset, $parseOptions); } if (strpos($repl, $notice) !== false) { return $repl; } else { $repl = "\n\r" . '<br style="clear:both" />' . "\r" . $repl . "\n\r" . '<br style="clear:both" />' . "\r"; return $repl; // return the multiple images } } $repl = ''; //////////////////////Set src for html/////////////////////////////// //Set variables for the base path for images in file galleries, image galleries and attachments global $base_url; $absolute_links = (!empty($parseOptions['absolute_links'])) ? $parseOptions['absolute_links'] : false; $imagegalpath = ($absolute_links ? $base_url : '') . 'show_image.php?id='; $filegalpath = ($absolute_links ? $base_url : '') . 'tiki-download_file.php?fileId='; $attachpath = ($absolute_links ? $base_url : '') . 'tiki-download_wiki_attachment.php?attId='; //get random image and treat as file gallery image afterwards if (!empty($imgdata['randomGalleryId'])) { $filegallib = TikiLib::lib('filegal'); $dbinfo = $filegallib->get_file(0, $imgdata['randomGalleryId']); $imgdata['fileId'] = $dbinfo['fileId']; $basepath = $prefs['fgal_use_dir']; } if (empty($imgdata['src'])) { if (!empty($imgdata['id'])) { $src = $imagegalpath . $imgdata['id']; } elseif (!empty($imgdata['fileId'])) { $smarty->loadPlugin('smarty_modifier_sefurl'); $src = smarty_modifier_sefurl($imgdata['fileId'], 'file'); if ($absolute_links) { $src = TikiLib::tikiUrl($src); } } else { //only attachments left $src = $attachpath . $imgdata['attId']; } } elseif ( (!empty($imgdata['src'])) && $absolute_links && ! preg_match('|^[a-zA-Z]+:\/\/|', $imgdata['src']) ) { global $base_host, $url_path; $src = $base_host.( $imgdata['src'][0] == '/' ? '' : $url_path ) . $imgdata['src']; } elseif (!empty($imgdata['src']) && $tikidomain && !preg_match('|^https?:|', $imgdata['src'])) { $src = preg_replace("~img/wiki_up/~", "img/wiki_up/$tikidomain/", $imgdata['src']); } elseif (!empty($imgdata['src'])) { $src = $imgdata['src']; } $browse_full_image = $src; ///////////////////////////Get DB info for image size and metadata///////////////////////////// if (!empty($imgdata['height']) || !empty($imgdata['width']) || !empty($imgdata['max']) || !empty($imgdata['desc']) || strpos($imgdata['rel'], 'box') !== false || !empty($imgdata['stylebox']) || !empty($imgdata['styledesc']) || !empty($imgdata['button']) || !empty($imgdata['thumb']) || !empty($imgdata['align']) || !empty($imgdata['metadata']) || !empty($imgdata['fileId']) ) { //Get ID numbers for images in galleries and attachments included in src as url parameter //So we can get db info for these too $parsed = parse_url($imgdata['src']); if (empty($parsed['host']) || (!empty($parsed['host']) && strstr($base_url, $parsed['host']))) { if (strlen(strstr($imgdata['src'], $imagegalpath)) > 0) { $imgdata['id'] = substr(strstr($imgdata['src'], $imagegalpath), strlen($imagegalpath)); } elseif (strlen(strstr($imgdata['src'], $filegalpath)) > 0) { $imgdata['fileId'] = substr(strstr($imgdata['src'], $filegalpath), strlen($filegalpath)); } elseif (strlen(strstr($imgdata['src'], $attachpath)) > 0) { $imgdata['attId'] = substr(strstr($imgdata['src'], $attachpath), strlen($attachpath)); } } $imageObj = ''; require_once('lib/images/images.php'); //Deal with images with info in tiki databases (file and image galleries and attachments) if (empty($imgdata['randomGalleryId']) && (!empty($imgdata['id']) || !empty($imgdata['fileId']) || !empty($imgdata['attId'])) ) { //Try to get image from database if (!empty($imgdata['id'])) { global $imagegallib; include_once('lib/imagegals/imagegallib.php'); $dbinfo = $imagegallib->get_image_info($imgdata['id'], 'o'); $dbinfo2 = $imagegallib->get_image($imgdata['id'], 'o'); $dbinfo = isset($dbinfo) && isset($dbinfo2) ? array_merge($dbinfo, $dbinfo2) : array(); $dbinfot = $imagegallib->get_image_info($imgdata['id'], 't'); $dbinfot2 = $imagegallib->get_image($imgdata['id'], 't'); $dbinfot = isset($dbinfot) && isset($dbinfot2) ? array_merge($dbinfot, $dbinfot2) : array(); $basepath = $prefs['gal_use_dir']; } elseif (!isset($dbinfo) && !empty($imgdata['fileId'])) { $filegallib = TikiLib::lib('filegal'); $dbinfo = $filegallib->get_file($imgdata['fileId']); $basepath = $prefs['fgal_use_dir']; } else { //only attachments left global $atts; global $wikilib; include_once('lib/wiki/wikilib.php'); $dbinfo = $wikilib->get_item_attachment($imgdata['attId']); $basepath = $prefs['w_use_dir']; } //Give error messages if file doesn't exist, isn't an image. Display nothing if user lacks permission if (!empty($imgdata['fileId']) || !empty($imgdata['id']) || !empty($imgdata['attId'])) { if ( ! $dbinfo ) { return '^' . tra('File not found.') . '^'; } elseif ( substr($dbinfo['filetype'], 0, 5) != 'image' AND !preg_match('/thumbnail/i', $imgdata['fileId'])) { return '^' . tra('File is not an image.') . '^'; } elseif (!class_exists('Image')) { return '^' . tra('Server does not support image manipulation.') . '^'; } elseif (!empty($imgdata['fileId'])) { if (!$userlib->user_has_perm_on_object($user, $dbinfo['galleryId'], 'file gallery', 'tiki_p_download_files')) { return $notice; } } elseif (!empty($imgdata['id'])) { if (!$userlib->user_has_perm_on_object($user, $dbinfo['galleryId'], 'image gallery', 'tiki_p_view_image_gallery')) { return $notice; } } elseif (!empty($imgdata['attId'])) { if (!$userlib->user_has_perm_on_object($user, $dbinfo['page'], 'wiki page', 'tiki_p_wiki_view_attachments')) { return $notice; } } } } //finished getting info from db for images in image or file galleries or attachments //get image to get height and width and iptc data if (!empty($dbinfo['data'])) { $imageObj = new Image($dbinfo['data'], false); $filename = $dbinfo['filename']; } elseif (!empty($dbinfo['path'])) { $imageObj = new Image($basepath . $dbinfo['path'], true); $filename = $dbinfo['filename']; } else { $imageObj = new Image($src, true); $filename = $src; } //if we need iptc data $xmpview = !empty($imgdata['metadata']) ? true : false; if ($imgdata['desc'] == 'idesc' || $imgdata['desc'] == 'ititle' || $xmpview) { $metadata = $imageObj->getMetadata(null, null, $xmpview)->typemeta; //description from image iptc $idesc = isset($metadata['iptc_raw']['2#120'][0]) ? $metadata['iptc_raw']['2#120'][0] : ''; //title from image iptc $ititle = isset($metadata['iptc_raw']['2#005'][0]) ? $metadata['iptc_raw']['2#005'][0] : ''; } $fwidth = ''; $fheight = ''; if (isset($parseOptions['indexing']) && $parseOptions['indexing']) { $fwidth = 1; $fheight = 1; } else { $fwidth = $imageObj->get_width(); $fheight = $imageObj->get_height(); } //get image gal thumbnail image for height and width if (!empty($dbinfot['data']) || !empty($dbinfot['path'])) { if (!empty($dbinfot['data'])) { $imageObjt = new Image($dbinfot['data'], false); } elseif (!empty($dbinfot['path'])) { $imageObjt = new Image($basepath . $dbinfot['path'] . '.thumb', true); } $fwidtht = $imageObjt->get_width(); $fheightt = $imageObjt->get_height(); } /////////////////////////////////////Add image dimensions to src string//////////////////////////////////////////// //Use url resizing parameters for file gallery images to set $height and $width //since they can affect other elements; overrides plugin parameters if (!empty($imgdata['fileId']) && strpos($src, '&') !== false) { $urlthumb = strpos($src, '&thumbnail'); $urlprev = strpos($src, '&preview'); $urldisp = strpos($src, '&display'); preg_match('/(?<=\&max=)[0-9]+(?=.*)/', $src, $urlmax); preg_match('/(?<=\&x=)[0-9]+(?=.*)/', $src, $urlx); preg_match('/(?<=\&y=)[0-9]+(?=.*)/', $src, $urly); preg_match('/(?<=\&scale=)[0]*\.[0-9]+(?=.*)/', $src, $urlscale); if (!empty($urlmax[0]) && $urlmax[0] > 0) $imgdata['max'] = $urlmax[0]; if (!empty($urlx[0]) && $urlx[0] > 0) $imgdata['width'] = $urlx[0]; if (!empty($urly[0]) && $urly[0] > 0) $imgdata['height'] = $urly[0]; if (!empty($urlscale[0]) && $urlscale[0] > 0) { $height = floor($urlscale[0] * $fheight); $width = floor($urlscale[0] * $fwidth); $imgdata['width'] = ''; $imgdata['height'] = ''; } if ($urlthumb != false && empty($imgdata['height']) && empty($imgdata['width']) && empty($imgdata['max'])) $imgdata['max'] = 120; if ($urlprev != false && empty($urlscale[0]) && empty($imgdata['height']) && empty($imgdata['width']) && empty($imgdata['max']) ) $imgdata['max'] = 800; } //Note if image gal url thumb parameter is used $imgalthumb = false; if (!empty($imgdata['id'])) { preg_match('/(?<=\&thumb=1)[0-9]+(?=.*)/', $src, $urlimthumb); if (!empty($urlimthumb[0]) && $urlimthumb[0] > 0) $imgalthumb = true; } //Now set dimensions based on plugin parameter settings if (!empty($imgdata['max']) || !empty($imgdata['height']) || !empty($imgdata['width']) || !empty($imgdata['thumb']) ) { //Convert % and px in height and width $scale = ''; if (strpos($imgdata['height'], '%') !== false || strpos($imgdata['width'], '%') !== false) { if ((strpos($imgdata['height'], '%') !== false && strpos($imgdata['width'], '%') !== false) && (empty($imgdata['fileId']) || (empty($urlx[0]) && empty($urly[0])))) { $imgdata['height'] = floor(rtrim($imgdata['height'], '%') / 100 * $fheight); $imgdata['width'] = floor(rtrim($imgdata['width'], '%') / 100 * $fwidth); } elseif (strpos($imgdata['height'], '%') !== false) { if ($imgdata['fileId']) { $scale = rtrim($imgdata['height'], '%') / 100; $height = floor($scale * $fheight); } else { $imgdata['height'] = floor(rtrim($imgdata['height'], '%') / 100 * $fheight); } } else { if ($imgdata['fileId']) { $scale = rtrim($imgdata['width'], '%') / 100; $width = floor($scale * $fwidth); } else { $imgdata['width'] = floor(rtrim($imgdata['width'], '%') / 100 * $fwidth); } } } elseif (strpos($imgdata['height'], 'px') !== false || strpos($imgdata['width'], 'px') !== false) { if (strpos($imgdata['height'], 'px') !== false) { $imgdata['height'] = rtrim($imgdata['height'], 'px'); } else { $imgdata['width'] = rtrim($imgdata['width'], 'px'); } } // Adjust for max setting, keeping aspect ratio if (!empty($imgdata['max'])) { if (($fwidth > $imgdata['max']) || ($fheight > $imgdata['max'])) { //use image gal thumbs when possible if ((!empty($imgdata['id']) && $imgalthumb == false) && ($imgdata['max'] < $fwidtht || $imgdata['max'] < $fheightt) ) { $src .= '&thumb=1'; $imgalthumb == true; } if ($fwidth > $fheight) { $width = $imgdata['max']; $height = floor($width * $fheight / $fwidth); } else { $height = $imgdata['max']; $width = floor($height * $fwidth / $fheight); } //cases where max is set but image is smaller than max } else { $height = $fheight; $width = $fwidth; } // Adjust for user settings for height and width if max isn't set. } elseif (!empty($imgdata['height']) ) { //use image gal thumbs when possible if ((!empty($imgdata['id']) && $imgalthumb == false) && ($imgdata['height'] < $fheightt) ) { $src .= '&thumb=1'; $imgalthumb == true; } $height = $imgdata['height']; if (empty($imgdata['width']) && $fheight > 0) { $width = floor($height * $fwidth / $fheight); } else { $width = $imgdata['width']; } } elseif (!empty($imgdata['width'])) { //use image gal thumbs when possible if ((!empty($imgdata['id']) && $imgalthumb == false) && ($imgdata['width'] < $fwidtht) ) { $src .= '&thumb=1'; $imgalthumb == true; } $width = $imgdata['width']; if (empty($imgdata['height']) && $fwidth > 0) { $height = floor($width * $fheight / $fwidth); } else { $height = $imgdata['height']; } // If not otherwise set, use default setting for thumbnail height if thumb is set } elseif ((!empty($imgdata['thumb']) || !empty($urlthumb)) && empty($scale)) { if (!empty($imgdata['fileId'])) { $thumbdef = $prefs['fgal_thumb_max_size']; } else { $thumbdef = 84; } //handle image gal thumbs if (!empty($imgdata['id']) && !empty($fwidtht) && !empty($fheightt)) { $width = $fwidtht; $height = $fheightt; if ($imgalthumb == false) { $src .= '&thumb=1'; $imgalthumb == true; } } else { if (($fwidth > $thumbdef) || ($fheight > $thumbdef)) { if ($fwidth > $fheight) { $width = $thumbdef; $height = floor($width * $fheight / $fwidth); } else { $height = $thumbdef; $width = floor($height * $fwidth / $fheight); } } } } } //Set final height and width dimension string //handle file gallery images separately to use server-side resizing capabilities $imgdata_dim = ''; if (!empty($imgdata['fileId'])) { if (empty($urldisp) && empty($urlthumb)) { $src .= '&display'; } if (!empty($scale) && empty($urlscale[0])) { $src .= '&scale=' . $scale; } elseif ((!empty($imgdata['max']) && $imgdata['thumb'] != 'download') && (empty($urlthumb) && empty($urlmax[0]) && empty($urlprev)) ) { $src .= '&max=' . $imgdata['max']; } elseif (!empty($width) || !empty($height)) { if ((!empty($width) && !empty($height)) && (empty($urlx[0]) && empty($urly[0]) && empty($urlscale[0]))) { $src .= '&x=' . $width . '&y=' . $height; $imgdata_dim .= ' width="' . $width . '"'; $imgdata_dim .= ' height="' . $height . '"'; } elseif (!empty($width) && (empty($urlx[0]) && empty($urlthumb) && empty($urlscale[0]))) { $src .= '&x=' . $width; $height = $fheight; $imgdata_dim .= ' width="' . $width . '"'; $imgdata_dim .= ' height="' . $height . '"'; } elseif (!empty($height) && (empty($urly[0]) && empty($urlthumb) && empty($urlscale[0]))) { $src .= '&y=' . $height; $imgdata_dim = ''; $width = $fwidth; } } else { $imgdata_dim = ''; $height = $fheight; $width = $fwidth; $imgdata_dim .= ' width="' . $width . '"'; $imgdata_dim .= ' height="' . $height . '"'; } } else { if (!empty($height)) { $imgdata_dim = ' height="' . $height . '"'; } else { $imgdata_dim = ''; $height = $fheight; } if (!empty($width)) { $imgdata_dim .= ' width="' . $width . '"'; } else { $imgdata_dim = ''; $width = $fwidth; } } } ////////////////////////////////////////// Create the HTML img tag ////////////////////////////////////////////// //Start tag with src and dimensions $src = filter_out_sefurl(htmlentities($src)); include_once ('lib/mime/mimetypes.php'); global $mimetypes; $tagName = ''; if (!empty($dbinfo['filetype']) && !empty($mimetypes['svg']) && $dbinfo['filetype'] == $mimetypes['svg']) { $tagName = 'div'; $repldata = $dbinfo['data']; $replimg = '<div type="image/svg+xml" '; $imgdata['class'] .= ' svgImage pluginImg' . $imgdata['fileId']; $imgdata['class'] = trim($imgdata['class']); } else { $tagName = 'img'; $replimg = '<img src="' . $src . '" '; $imgdata['class'] .= ' regImage pluginImg' . $imgdata['fileId']; $imgdata['class'] = trim($imgdata['class']); } if (!empty($imgdata_dim)) $replimg .= $imgdata_dim; //Create style attribute allowing for shortcut inputs //First set alignment string $center = 'display:block; margin-left:auto; margin-right:auto;'; //used to center image and box if (!empty($imgdata['imalign'])) { $imalign = ''; if ($imgdata['imalign'] == 'center') { $imalign = $center; } else { $imalign = 'float:' . $imgdata['imalign'] . ';'; } } elseif ($imgdata['stylebox'] == 'border') { $imalign = $center; } //set entire style string if ( !empty($imgdata['styleimage']) || !empty($imalign) ) { $border = ''; $style = ''; $borderdef = 'border:1px solid darkgray;'; //default border when styleimage set to border if ( !empty($imgdata['styleimage'])) { if (!empty($imalign)) { if ((strpos(trim($imgdata['styleimage'], ' '), 'float:') !== false) || (strpos(trim($imgdata['styleimage'], ' '), 'display:') !== false) ) { $imalign = ''; //override imalign setting if style image contains alignment syntax } } if ($imgdata['styleimage'] == 'border') { $border = $borderdef; } else if (strpos($imgdata['styleimage'], 'hidden') === false && strpos($imgdata['styleimage'], 'position') === false ) { // quick filter for dangerous styles $style = $imgdata['styleimage']; } } $replimg .= ' style="' . $imalign . $border . $style . '"'; } //alt if ( !empty($imgdata['alt']) ) { $replimg .= ' alt="' . $imgdata['alt'] . '"'; } elseif ( !empty($imgdata['desc']) ) { $replimg .= ' alt="' . $imgdata['desc'] . '"'; } elseif (!empty($dbinfo['description'])) { $replimg .= ' alt="' . $dbinfo['description'] . '"'; } else { $replimg .= ' alt="Image"'; } //usemap if ( !empty($imgdata['usemap']) ) { $replimg .= ' usemap="#' . $imgdata['usemap'] . '"'; } //class if ( !empty($imgdata['class']) ) { $replimg .= ' class="' . $imgdata['class'] . '"'; } //title (also used for description and link title below) //first set description, which is used for title if no title is set if (!empty($imgdata['desc']) || !empty($imgdata['title'])) { $desc = ''; $imgname = ''; $desconly = ''; if ( !empty($imgdata['desc']) ) { //attachment database uses comment instead of description or name if (!empty($dbinfo['comment'])) { $desc = $dbinfo['comment']; $imgname = $dbinfo['comment']; } elseif (isset($dbinfo)) { $desc = !empty($dbinfo['description']) ? $dbinfo['description'] : ''; $imgname = !empty($dbinfo['name']) ? $dbinfo['name'] : ''; } switch ($imgdata['desc']) { case 'desc': $desconly = $desc; break; case 'idesc': $desconly = $idesc; break; case 'name': $desconly = $imgname; break; case 'ititle': $desconly = $ititle; break; case 'namedesc': $desconly = $imgname.((!empty($imgname) && !empty($desc))?' - ':'').$desc; break; default: $desconly = $imgdata['desc']; } } //now set title $imgtitle = ''; $titleonly = ''; if ( !empty($imgdata['title']) || !empty($desconly)) { $imgtitle = ' title="'; if ( !empty($imgdata['title']) ) { switch ($imgdata['title']) { case 'desc': $titleonly = $desc; break; case 'name': $titleonly = $imgname; break; case 'namedesc': $titleonly = $imgname.((!empty($imgname) && !empty($desc))?' - ':'').$desc; break; default: $titleonly = $imgdata['title']; } //use desc setting for title if title is empty } else { $titleonly = $desconly; } $imgtitle .= $titleonly . '"'; $replimg .= $imgtitle; } } if (empty($repldata)) { $replimg .= ' />' . "\r"; } else { $replimg .= '>' . $repldata . '</' . $tagName . '>'; } ////////////////////////////////////////// Create the HTML link /////////////////////////////////////////// //Variable for identifying if javascript mouseover is set if (($imgdata['thumb'] == 'mouseover') || ($imgdata['thumb'] == 'mousesticky')) { $javaset = 'true'; } else { $javaset = ''; } // Set link to user setting or to image itself if thumb is set if (!empty($imgdata['link']) || (!empty($imgdata['thumb']) && !(isset($params['link']) && empty($params['link'])))) { $mouseover = ''; if (!empty($imgdata['link'])) { $link = $imgdata['link']; } elseif ((($imgdata['thumb'] == 'browse') || ($imgdata['thumb'] == 'browsepopup')) && !empty($imgdata['id'])) { $link = 'tiki-browse_image.php?imageId=' . $imgdata['id']; } elseif ($javaset == 'true') { $link = 'javascript:void(0)'; $popup_params = array( 'text'=>$data, 'width'=>$fwidth, 'height'=>$fheight, 'background'=>$browse_full_image); if ($imgdata['thumb'] == 'mousesticky') { $popup_params['sticky'] = true; } $smarty->loadPlugin('smarty_function_popup'); $mouseover = ' ' . smarty_function_popup($popup_params, $smarty); } else { if (!empty($imgdata['fileId']) && $imgdata['thumb'] != 'download' && empty($urldisp)) { $link = $browse_full_image . '&display'; } else { $link = $browse_full_image; } } // Set other link-related attributes // target $imgtarget= ''; if (($prefs['popupLinks'] == 'y' && (preg_match('#^([a-z0-9]+?)://#i', $link) || preg_match('#^www\.([a-z0-9\-]+)\.#i', $link))) || ($imgdata['thumb'] == 'popup') || ($imgdata['thumb'] == 'browsepopup') ) { if (!empty($javaset) || ($imgdata['rel'] == 'box')) { $imgtarget= ''; } else { $imgtarget = ' target="_blank"'; } } // rel !empty($imgdata['rel']) ? $linkrel = ' rel="'.$imgdata['rel'].'"' : $linkrel = ''; // title !empty($imgtitle) ? $linktitle = $imgtitle : $linktitle = ''; $link = filter_out_sefurl(htmlentities($link)); //Final link string $replimg = "\r\t" . '<a href="' . $link . '" class="internal"' . $linkrel . $imgtarget . $linktitle . $mouseover . '>' ."\r\t\t" . $replimg . "\r\t" . '</a>'; } //Add link string to rest of string $repl .= $replimg; //////////////////////////Generate metadata dialog box and jquery (dialog icon added in next section)//////////////////////////////////// if ($imgdata['metadata'] == 'view') { //create unique id's in case of multiple pictures static $lastval = 0; $id = 'imgdialog-' . ++$lastval; $id_link = $id . '-link'; $dialog = $imageObj->metadata->dialogMetadata($imageObj->metadata, $id, $filename); $repl .= $dialog; $jq = '$(document).ready(function() { $("#' . $id . '").css(\'z-index\', \'1005\').dialog({ autoOpen: false, width: 700, zIndex: 1005 }); $("#' . $id_link . '").click(function() { $("#' . $id . '").accordion({ autoHeight: false, collapsible: true }).dialog(\'open\'); return false; }); });'; global $headerlib; $headerlib->add_jq_onready($jq); } ////////////////////// Create enlarge button, metadata icon, description and their divs//////////////////// //Start div that goes around button and description if these are set if (!empty($imgdata['button']) || !empty($imgdata['desc']) || !empty($imgdata['styledesc']) || !empty($imgdata['metadata'])) { //To set room for enlarge button under image if there is no description $descheightdef = 'height:17px;clear:left;'; $repl .= "\r\t" . '<div class="mini" style="width:' . $width . 'px;'; if ( !empty($imgdata['styledesc']) ) { if (($imgdata['styledesc'] == 'left') || ($imgdata['styledesc'] == 'right')) { $repl .= 'text-align:' . $imgdata['styledesc'] . '">'; } else { $repl .= $imgdata['styledesc'] . '">'; } } elseif ((!empty($imgdata['button'])) && (empty($desconly))) { $repl .= $descheightdef . '">'; } else { $repl .= '">'; } //Start description div that also includes enlarge button div $repl .= "\r\t\t" . '<div class="thumbcaption">'; //Enlarge button div and link string (innermost div) if (!empty($imgdata['button'])) { if (empty($link) || (!empty($link) && !empty($javaset))) { if ((($imgdata['button'] == 'browse') || ($imgdata['button'] == 'browsepopup')) && !empty($imgdata['id'])) { $link_button = 'tiki-browse_image.php?imageId=' . $imgdata['id']; } else { if (!empty($imgdata['fileId']) && $imgdata['button'] != 'download') { $link_button = $browse_full_image . '&display'; } elseif (!empty($imgdata['attId']) && $imgdata['thumb'] == 'download') { $link = $browse_full_image . '&download=y'; } else { $link_button = $browse_full_image; } } } else { $link_button = $link; } //Set button rel !empty($imgdata['rel']) ? $linkrel_button = ' rel="'.$imgdata['rel'].'"' : $linkrel_button = ''; //Set button target if (empty($imgtarget) && (empty($imgdata['thumb']) || !empty($javaset))) { if (($imgdata['button'] == 'popup') || ($imgdata['button'] == 'browsepopup')) { $imgtarget_button = ' target="_blank"'; } else { $imgtarget_button = ''; } } else { $imgtarget_button = $imgtarget; } $repl .= "\r\t\t\t" . '<div class="magnify" style="float:right">'; $repl .= "\r\t\t\t\t" . '<a href="' . $link_button . '"' . $linkrel_button . $imgtarget_button ; $repl .= ' class="internal"'; if (!empty($titleonly)) { $repl .= ' title="' . $titleonly . '"'; } $repl .= ">\r\t\t\t\t" . '<img class="magnify" src="./img/icons/magnifier.png" alt="'.tra('Enlarge').'" /></a>' . "\r\t\t\t</div>"; } //Add metadata icon if ($imgdata['metadata'] == 'view') { $repl .= '<div style="float:right; margin-right:2px"><a href="#" id="' . $id_link . '"><img src="./img/icons/tag_blue.png" alt="' . tra('Metadata') . '" title="' . tra('Metadata') . '"/></a></div>'; } //Add description based on user setting (use $desconly from above) and close divs isset($desconly) ? $repl .= $desconly : ''; $repl .= "\r\t\t</div>"; $repl .= "\r\t</div>"; } ///////////////////////////////Wrap in overall div that includes image if needed//////////////// //Need a box if any of these are set if (!empty($imgdata['button']) || !empty($imgdata['desc']) || !empty($imgdata['metadata']) || !empty($imgdata['stylebox']) || !empty($imgdata['align']) ) { //Make the div surrounding the image 2 pixels bigger than the image if (empty($height)) $height = ''; if (empty($width)) $width = ''; $boxwidth = $width + 2; $boxheight = $height + 2; $alignbox = ''; $class = ''; if (!empty($imgdata['align'])) { if ($imgdata['align'] == 'center') { $alignbox = $center; } else { $alignbox = 'float:' . $imgdata['align'] . '; margin-' . ($imgdata['align'] == 'left'? 'right': 'left') .':5px;'; } } //first set stylebox string if style box is set if (!empty($imgdata['stylebox']) || !empty($imgdata['align'])) { //create strings from shortcuts first if ( !empty($imgdata['stylebox'])) { if ($imgdata['stylebox'] == 'border') { $class = 'class="imgbox" '; if (!empty($alignbox)) { if ((strpos(trim($imgdata['stylebox'], ' '), 'float:') !== false) || (strpos(trim($imgdata['stylebox'], ' '), 'display:') !== false) ) { $alignbox = ''; //override align setting if stylebox contains alignment syntax } } } else { $styleboxinit = $imgdata['stylebox'] . ';'; } } if (empty($imgdata['button']) && empty($imgdata['desc']) && empty($styleboxinit)) { $styleboxplus = $alignbox . ' width:' . $boxwidth . 'px; height:' . $boxheight . 'px'; } elseif (!empty($styleboxinit)) { if ((strpos(trim($imgdata['stylebox'], ' '), 'height:') === false) && (strpos(trim($imgdata['stylebox'], ' '), 'width:') === false) ) { $styleboxplus = $styleboxinit . ' width:' . $boxwidth . 'px;'; } else { $styleboxplus = $styleboxinit; } } else { $styleboxplus = $alignbox . ' width:' . $boxwidth . 'px;'; } } elseif (!empty($imgdata['button']) || !empty($imgdata['desc']) || !empty($imgdata['metadata'])) { $styleboxplus = ' width:' . $boxwidth . 'px;'; } } if ( !empty($styleboxplus)) { $repl = "\r" . '<div ' . $class . 'style="' . $styleboxplus . '">' . $repl . "\r" . '</div>'; } //////////////////////////////////////Place 'clear' block/////////////////////////////////////////////////////////// if ( !empty($imgdata['block']) ) { switch ($imgdata['block']) { case 'top': $repl = "\n\r<br style=\"clear:both\" />\r" . $repl; break; case 'bottom': $repl = $repl . "\n\r<br style=\"clear:both\" />\r"; break; case 'both': $repl = "\n\r<br style=\"clear:both\" />\r" . $repl . "\n\r<br style=\"clear:both\" />\r"; break; case 'top': break; } } // Mobile if (isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'mobile') { $repl = '{img src=' . $src . "\"}\n<p>" . $imgdata['desc'] . '</p>'; } global $tiki_p_edit, $fromTracker; $globalperms = Perms::get(array( 'type' => 'file gallery', 'object' => $imgdata['galleryId'] )); if ( $prefs['feature_draw'] == 'y' && $globalperms->upload_files == 'y' && empty($src) == true && ( $tiki_p_edit == 'y' || $fromTracker == true ) ) { if ($prefs['wiki_edit_icons_toggle'] == 'y' && !isset($_COOKIE['wiki_plugin_edit_view'])) { $iconDisplayStyle = " style='display:none;'"; } else { $iconDisplayStyle = ''; } $repl .= "<a href='tiki-edit_draw.php?fileId={$imgdata['fileId']}' onclick='return $(this).ajaxEditDraw();' title='".tr("Edit: Image") . " ".tr("(experimental)") . "'" . " class='editplugin pluginImgEdit{$imgdata['fileId']}' data-fileid='{$imgdata['fileId']}' data-galleryid='{$imgdata['galleryId']}'{$iconDisplayStyle}>" . "<img width='16' height='16' class='icon' alt='Edit' src='img/icons/page_edit.png' /></a>"; } return '~np~' . $repl. "\r" . '~/np~'; }
// If the page doesn't exist then display an error if (!$tikilib->page_exists($page)) { $smarty->assign('msg', tra("Page cannot be found")); $smarty->display("error.tpl"); die; } if (isset($_REQUEST["remove"])) { if (isset($_REQUEST["all"]) && $_REQUEST["all"] == 'on') { $access->check_authenticity(tr('Are you sure you want to completely remove page "%0"', $_REQUEST['page'])); $tikilib->remove_all_versions($_REQUEST["page"]); $access->redirect(); die; } else { $smarty->loadPlugin('smarty_modifier_sefurl'); if ($version == "last") { $access->check_authenticity(tr('Are you sure you want to remove the most recent version of page "%0"', $_REQUEST['page'])); $wikilib->remove_last_version($_REQUEST["page"]); $access->redirect(smarty_modifier_sefurl($_REQUEST['page'])); } else { $access->check_authenticity(tr('Are you sure you want to remove version %0 of page "%1"', $_REQUEST['version'], $_REQUEST['page'])); $histlib->remove_version($_REQUEST['page'], $_REQUEST['version'], $_REQUEST['historyId']); $access->redirect(smarty_modifier_sefurl($_REQUEST['page'])); } } } ask_ticket('remove-page'); include_once 'tiki-section_options.php'; // disallow robots to index page: $smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW'); $smarty->assign('mid', 'tiki-removepage.tpl'); $smarty->display("tiki.tpl");
} $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, $offset, $maxRecords); $dataSource = $unifiedsearchlib->getDataSource('formatting'); $results = $dataSource->getInformation($results, $fetchFields); $smarty->loadPlugin('smarty_function_object_link'); $smarty->loadPlugin('smarty_modifier_sefurl'); foreach ($results as &$res) { $res['link'] = smarty_function_object_link(array('type' => $res['object_type'], 'id' => $res['object_id'], 'title' => $res['title']), $smarty); if (empty($res['url'])) { $appendTitle = $res['object_type'] === 'article' || $res['object_type'] === 'blog' || $res['object_type'] === 'bogpost'; $res['url'] = smarty_modifier_sefurl($res['object_id'], $res['object_type'], '', '', $appendTitle ? 'y' : 'n', $res['title']); } $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 ($prefs['feature_use_fgal_for_user_files'] === 'y' && $tiki_p_admin_file_galleries !== 'y' && $prefs['userfiles_private'] === 'y') { $gal_info = $filegallib->get_file_gallery_info($info['galleryId']); if ($gal_info['type'] === 'user' && $gal_info['visible'] !== 'y' && $gal_info['user'] !== $user) { $access->display_error('', tra('Permission denied'), 401); } } } } //if the file is remote, display, and don't cache $attributelib = TikiLib::lib('attribute'); $attributes = $attributelib->get_attributes('file', $info['fileId']); if (isset($attributes['tiki.content.url'])) { $smarty->loadPlugin('smarty_modifier_sefurl'); $src = smarty_modifier_sefurl($info['fileId'], 'file'); session_write_close(); $client = $tikilib->get_http_client($src); $response = $client->request(); header('Content-Type: ' . $response->getHeader('Content-Type')); echo $response->getBody(); exit; } // Add hits ( if download or display only ) + lock if set if (!isset($_GET['thumbnail']) && !isset($_GET['icon'])) { require_once 'lib/stats/statslib.php'; $filegallib = TikiLib::lib('filegal'); if (!$filegallib->add_file_hit($info['fileId'])) { $access->display_error('', tra('You cannot download this file right now. Your score is low or file limit was reached.'), 401); } $statslib->stats_hit($info['filename'], 'file', $info['fileId']);
/** * Smarty plugin * ------------------------------------------------------------- * Type: modifier * Name: iconify * Purpose: Returns a filetype icon or file type * ------------------------------------------------------------- * * @param $string File name with extension * @param null $filetype File type * @param null $fileId File id when using file galleries * @param int $size Icon size * @param string $return icon or filtype * @return null|string * @throws Exception * @throws SmartyException */ function smarty_modifier_iconify($string, $filetype = null, $fileId = null, $size = 1, $return = 'icon') { $smarty = TikiLib::lib('smarty'); global $prefs; $smarty->loadPlugin('smarty_function_icon'); $icon = ''; $ext = strtolower(substr($string, strrpos($string, '.') + 1)); if ($fileId && substr($filetype, 0, 6) == 'image/') { // Special handling for file gallery images, // display thumbnail $smarty->loadPlugin('smarty_modifier_sefurl'); $smarty->loadPlugin('smarty_modifier_escape'); $icon = smarty_modifier_sefurl($fileId, 'thumbnail'); $icon = smarty_modifier_escape($icon); return "<img src=\"{$icon}\" width=\"16\"/>"; } else { include_once 'lib/mime/mimetypes.php'; global $mimetypes; $mimes = array_keys($mimetypes, $filetype); if ($prefs['theme_iconset'] === 'legacy') { if (file_exists("img/icons/mime/{$ext}.png")) { $icon = $ext; } elseif (file_exists('img/icons/mime/' . substr($ext, 0, 3) . '.png')) { $icon = substr($ext, 0, 3); } else { foreach ($mimes as $m) { if (file_exists("img/icons/mime/{$m}.png")) { $icon = $m; } } if (empty($icon)) { $icon = 'default'; } } if ($return === 'filetype') { return $m; } elseif ($return === 'icon') { return smarty_function_icon(array('_id' => 'img/icons/mime/' . $icon . '.png', 'alt' => $filetype === null ? $icon : $filetype, 'class' => '', 'size' => $size), $smarty); } //iconsets introduced with Tiki14 } else { if (!empty($filetype)) { $type = $filetype; } elseif (!empty($mimetypes[$ext])) { $type = $mimetypes[$ext]; } else { $type = 'file'; } switch ($type) { case $type === 'application/msword' || strpos($type, 'application/vnd.openxmlformats-officedocument.wordprocessingml') === 0: $iconname = 'word'; break; case $type === 'application/pdf': $iconname = 'pdf'; break; case $type === 'application/vnd.ms-excel' || strpos($type, 'application/vnd.openxmlformats-officedocument.spreadsheetml') === 0: $iconname = 'excel'; break; case $type === 'application/vnd.ms-powerpoint' || strpos($type, 'application/vnd.openxmlformats-officedocument.presentationml') === 0: $iconname = 'powerpoint'; break; case strpos($type, 'audio/') === 0: $iconname = 'audio'; break; case strpos($type, 'image/') === 0: $iconname = 'image'; break; case strpos($type, 'text/') === 0: $iconname = 'textfile'; break; case strpos($type, 'video/') === 0: $iconname = 'video_file'; break; case strpos($type, 'application/') === 0: $iconname = 'code_file'; break; default: $iconname = 'file'; break; } if ($return === 'filetype') { return $type; } else { return smarty_function_icon(['name' => $iconname, 'size' => $size], $smarty); } } } }
// alternative names for subject field: if (($field_name_check == "summary") || ($field_name_check == "name") || ($field_name_check == "title") || ($field_name_check == "topic")) { $aux_subject = $data2["value"]; } elseif ($data2["type"] == 't' && !isset($first_text_field)) { $first_text_field = $data2["name"] . ": " . $data2["value"]; } } } } if (isset($_REQUEST['noId']) && $_REQUEST['noId'] == 'y') { $data[$titleId] = empty($aux_subject) ? $first_text_field : $aux_subject; } elseif (!isset($aux_subject) && isset($first_text_field)) { $data[$titleId] .= (empty($data[$titleId])?'': ' - ') . $first_text_field; } elseif (isset($aux_subject)) { $data[$titleId] .= (empty($data[$titleId])?'': ' - ') . $aux_subject; } $data["id"] = $_REQUEST["$id"]; $data["field_values"] = null; $data['sefurl'] = smarty_modifier_sefurl($data['itemId'], 'trackeritem'); $changes["data"][] = $data; $data = null; } $tmp = null; if (isset($changes['data'])) { $output = $rsslib->generate_feed($feed, $uniqueid, '', $changes, $readrepl, $urlparam, $id, $title, $titleId, $desc, $descId, $dateId, $authorId); } $changes = null; } header("Content-type: " . $output["content-type"]); print $output["data"];
$attributeArray[$att['itemId']] = $_REQUEST[$toMatch]; } } $artlib->set_article_attributes($artid, $attributeArray); } if ($prefs['geo_locate_article'] == 'y' && !empty($_REQUEST['geolocation'])) { TikiLib::lib('geo')->set_coordinates('article', $artid, $_REQUEST['geolocation']); } // Remove image cache because image may have changed, and we // don't want to show the old image @$artlib->delete_image_cache('article', $_REQUEST['id']); // Remove preview cache because it won't be used any more @$artlib->delete_image_cache('preview', $previewId); include_once 'tiki-sefurl.php'; $smarty->loadPlugin('smarty_modifier_sefurl'); $url = smarty_modifier_sefurl($artid, 'article'); header('location: ' . $url); exit; } $smarty->assign_by_ref('errors', $errors); // Set date to today before it's too late $_SESSION['thedate'] = $tikilib->now; // get list of valid types $types = $artlib->list_types_byname(); if (empty($article_data)) { // Select the first type as default selection if (empty($types)) { $type = ''; } else { $type = key($types); }
function smarty_function_object_link_default($smarty, $object, $title = null, $type = 'wiki page', $url = null, $params = array()) { global $base_url; $smarty->loadPlugin('smarty_modifier_sefurl'); $smarty->loadPlugin('smarty_modifier_escape'); $smarty->loadPlugin('smarty_modifier_addongroupname'); if (empty($title)) { $title = TikiLib::lib('object')->get_title($type, $object); } if (empty($title) && !empty($params['backuptitle'])) { $title = $params['backuptitle']; } if (empty($title) && $type == 'freetag') { // Blank freetag should not be returned with "No title specified" return ''; } // get add on object title if needed $title = smarty_modifier_addongroupname($title); $text = $title; $titleAttribute = ''; if ($type == 'wiki page') { $titleAttribute .= ' title="' . smarty_modifier_escape($title) . '"'; $text = TikiLib::lib('wiki')->get_without_namespace($title); } $escapedText = smarty_modifier_escape($text ? $text : tra('No title specified')); if ($url) { $escapedHref = smarty_modifier_escape(TikiLib::tikiUrlOpt($url)); } else { $escapedHref = smarty_modifier_escape(smarty_modifier_sefurl($object, $type)); } $classList = array(); if ($type == "blog post") { $classList[] = "link"; } elseif ($type == "freetag") { $classList[] = 'freetag'; } $metadata = TikiLib::lib('object')->get_metadata($type, $object, $classList); if (!empty($params['class'])) { $classList[] = $params['class']; } $class = ' class="' . implode(' ', $classList) . '"'; if (strpos($escapedHref, '://') === false) { //$html = '<a href="' . $base_url . $escapedHref . '"' . $class . $titleAttribute . $metadata . '>' . $escapedText . '</a>'; // When the link is created for a tiki page, then we do NOT want the baseurl included, // because it might be we are using a reverse proxy or a an ssl offloader, or we access from a public fqdn that is not // configured for teh ip adress we run our webserver. // Eaxmple: Fqdn = tiki.mydomain.com -> port forwarding/nat to: 192.168.1.110. // In this case links should NOT be generated as absolut urls pointing to 192.168.1.110 which would be the part of the baseUrl. $html = '<a href="' . $escapedHref . '"' . $class . $titleAttribute . $metadata . '>' . $escapedText . '</a>'; } else { $html = '<a rel="external" href="' . $escapedHref . '"' . $class . $titleAttribute . $metadata . '>' . $escapedText . '</a>'; } $attributelib = TikiLib::lib('attribute'); $attributes = $attributelib->get_attributes($type, $object); global $prefs; if (isset($attributes['tiki.content.source']) && $prefs['fgal_source_show_refresh'] == 'y') { $smarty->loadPlugin('smarty_function_icon'); $smarty->loadPlugin('smarty_function_service'); $html .= '<a class="file-refresh" href="' . smarty_function_service(array('controller' => 'file', 'action' => 'refresh', 'fileId' => intval($object)), $smarty) . '">' . smarty_function_icon(array('_id' => 'arrow_refresh'), $smarty) . '</a>'; TikiLib::lib('header')->add_js(' $(".file-refresh").removeClass("file-refresh").click(function () { $.getJSON($(this).attr("href")); $(this).remove(); return false; });'); } return $html; }
if ($prefs['feature_actionlog'] == 'y') { $logslib = TikiLib::lib('logs'); $logslib->add_action('Viewed', $_REQUEST['itemId'], 'trackeritem'); } // Generate validation js if ($prefs['feature_jquery'] == 'y' && $prefs['feature_jquery_validation'] == 'y') { $validatorslib = TikiLib::lib('validators'); $validationjs = $validatorslib->generateTrackerValidateJS($fields['data']); $smarty->assign('validationjs', $validationjs); } if ($itemObject->canRemove()) { $smarty->assign('editTitle', tr('Edit/Delete')); } else { $smarty->assign('editTitle', tr('Edit')); } $smarty->assign('canView', $itemObject->canView()); $smarty->assign('canModify', $itemObject->canModify()); $smarty->assign('canRemove', $itemObject->canRemove()); // Display the template $smarty->assign('mid', 'tiki-view_tracker_item.tpl'); try { if (isset($_REQUEST['print'])) { $smarty->display('tiki-print.tpl'); $smarty->assign('print', 'y'); } else { $smarty->display('tiki.tpl'); } } catch (SmartyException $e) { $message = tr('This element cannot be displayed appropriately. Template not found (%0). Contact the administrator.', $tracker_info['viewItemPretty']); $access->redirect(smarty_modifier_sefurl($info['trackerId'], 'tracker'), $message); }
private function update_item_categories($itemId, $managed_categories, $ins_categs, $override_perms) { $categlib = TikiLib::lib('categ'); $cat_desc = ''; $cat_name = $this->get_isMain_value(null, $itemId); // The following needed to ensure category field exist for item (to be readable by list_items) $smarty = TikiLib::lib('smarty'); $smarty->loadPlugin('smarty_modifier_sefurl'); $cat_href = smarty_modifier_sefurl($itemId, 'trackeritem'); $categlib->update_object_categories($ins_categs, $itemId, 'trackeritem', $cat_desc, $cat_name, $cat_href, $managed_categories, $override_perms); }
function wikiplugin_img($data, $params) { global $tikidomain, $prefs, $smarty, $userlib, $user; $imgdata = array(); $imgdata['src'] = ''; $imgdata['id'] = ''; $imgdata['fileId'] = ''; $imgdata['randomGalleryId'] = ''; $imgdata['galleryId'] = ''; $imgdata['fgalId'] = ''; $imgdata['sort_mode'] = ''; $imgdata['attId'] = ''; $imgdata['thumb'] = ''; $imgdata['button'] = ''; $imgdata['link'] = ''; $imgdata['rel'] = ''; $imgdata['usemap'] = ''; $imgdata['height'] = ''; $imgdata['width'] = ''; $imgdata['max'] = ''; $imgdata['imalign'] = ''; $imgdata['styleimage'] = ''; $imgdata['align'] = ''; $imgdata['stylebox'] = ''; $imgdata['styledesc'] = ''; $imgdata['block'] = ''; $imgdata['class'] = ''; $imgdata['desc'] = ''; $imgdata['title'] = ''; $imgdata['metadata'] = ''; $imgdata['alt'] = ''; $imgdata['default'] = ''; $imgdata['mandatory'] = ''; $imgdata['fromFieldId'] = 0; // "private" params set by Tracker_Field_Files $imgdata['fromItemId'] = 0; // ditto $imgdata['checkItemPerms'] = 'y'; // ditto $imgdata['noDrawIcon'] = 'n'; $imgdata = array_merge($imgdata, $params); //function calls if (!empty($imgdata['default']) || !empty($imgdata['mandatory'])) { require_once 'lib/images/img_plugin_default_and_mandatory.php'; if (!empty($imgdata['default'])) { $imgdata = apply_default_and_mandatory($imgdata, 'default'); //first process defaults $imgdata = array_merge($imgdata, $params); //then apply user settings, overriding defaults } //apply mandatory settings, overriding user settings if (!empty($imgdata['mandatory'])) { $imgdata = apply_default_and_mandatory($imgdata, 'mandatory'); } } //////////////////////////////////////////////////// Error messages and clean javascript ////////////////////////////// // Must set at least one image identifier $set = !empty($imgdata['fileId']) + !empty($imgdata['id']) + !empty($imgdata['src']) + !empty($imgdata['attId']) + !empty($imgdata['randomGalleryId']) + !empty($imgdata['fgalId']); if ($set == 0) { return tra("''No image specified. One of the following parameters must be set: fileId, randomGalleryId, fgalId, attId, id.''"); } elseif ($set > 1) { return tra("''Use one and only one of the following parameters: fileId, randomGalleryId, fgalId, attId, id, or src.''"); } // Clean up src URLs to exclude javascript if (stristr(str_replace(' ', '', $imgdata['src']), 'javascript:')) { $imgdata['src'] = ''; } if (strstr($imgdata['src'], 'javascript:')) { $imgdata['src'] = ''; } if (!isset($data) or !$data) { $data = ' '; } include_once 'tiki-sefurl.php'; //////////////////////Process multiple images ////////////////////////////////////// //Process "|" or "," separated images $notice = '<!--' . tra('PluginImg: User lacks permission to view image') . '-->'; $srcmash = $imgdata['fileId'] . $imgdata['id'] . $imgdata['attId'] . $imgdata['src']; if (strpos($srcmash, '|') !== false || strpos($srcmash, ',') !== false || !empty($imgdata['fgalId'])) { $separator = ''; if (!empty($imgdata['id'])) { $id = 'id'; } elseif (!empty($imgdata['fileId'])) { $id = 'fileId'; } elseif (!empty($imgdata['attId'])) { $id = 'attId'; } else { $id = 'src'; } if (strpos($imgdata[$id], '|') !== false) { $separator = '|'; } elseif (strpos($imgdata[$id], ',') !== false) { $separator = ','; } $repl = ''; $id_list = array(); if (!empty($separator)) { $id_list = explode($separator, $imgdata[$id]); } else { //fgalId parameter - show all images in a file gallery $filegallib = TikiLib::lib('filegal'); $galdata = $filegallib->get_files(0, -1, 'created_desc', '', $imgdata['fgalId'], false, false, false, true, false, false, false, false, '', true, false, false); foreach ($galdata['data'] as $filedata) { $id_list[] = $filedata['id']; } $id = 'fileId'; } $params[$id] = ''; foreach ($id_list as $i => $value) { $params[$id] = trim($value); $params['fgalId'] = ''; $repl .= wikiplugin_img($data, $params); } if (strpos($repl, $notice) !== false) { return $repl; } else { $repl = "\n\r" . '<br style="clear:both" />' . "\r" . $repl . "\n\r" . '<br style="clear:both" />' . "\r"; return $repl; // return the multiple images } } $repl = ''; //////////////////////Set src for html/////////////////////////////// //Set variables for the base path for images in file galleries, image galleries and attachments global $base_url; $absolute_links = !empty(TikiLib::lib('parser')->option['absolute_links']) ? TikiLib::lib('parser')->option['absolute_links'] : false; $imagegalpath = ($absolute_links ? $base_url : '') . 'show_image.php?id='; $filegalpath = ($absolute_links ? $base_url : '') . 'tiki-download_file.php?fileId='; $attachpath = ($absolute_links ? $base_url : '') . 'tiki-download_wiki_attachment.php?attId='; //get random image and treat as file gallery image afterwards if (!empty($imgdata['randomGalleryId'])) { $filegallib = TikiLib::lib('filegal'); $dbinfo = $filegallib->get_file(0, $imgdata['randomGalleryId']); $imgdata['fileId'] = $dbinfo['fileId']; $basepath = $prefs['fgal_use_dir']; } if (empty($imgdata['src'])) { if (!empty($imgdata['id'])) { $src = $imagegalpath . $imgdata['id']; } elseif (!empty($imgdata['fileId'])) { $smarty->loadPlugin('smarty_modifier_sefurl'); $src = smarty_modifier_sefurl($imgdata['fileId'], 'file'); if ($absolute_links) { $src = TikiLib::tikiUrl($src); } } else { //only attachments left $src = $attachpath . $imgdata['attId']; } } elseif (!empty($imgdata['src']) && $absolute_links && !preg_match('|^[a-zA-Z]+:\\/\\/|', $imgdata['src'])) { global $base_host, $url_path; $src = $base_host . ($imgdata['src'][0] == '/' ? '' : $url_path) . $imgdata['src']; } elseif (!empty($imgdata['src']) && $tikidomain && !preg_match('|^https?:|', $imgdata['src'])) { $src = preg_replace("~img/wiki_up/~", "img/wiki_up/{$tikidomain}/", $imgdata['src']); } elseif (!empty($imgdata['src'])) { $src = $imgdata['src']; } $browse_full_image = $src; $srcIsEditable = false; ///////////////////////////Get DB info for image size and metadata///////////////////////////// if (!empty($imgdata['height']) || !empty($imgdata['width']) || !empty($imgdata['max']) || !empty($imgdata['desc']) || strpos($imgdata['rel'], 'box') !== false || !empty($imgdata['stylebox']) || !empty($imgdata['styledesc']) || !empty($imgdata['button']) || !empty($imgdata['thumb']) || !empty($imgdata['align']) || !empty($imgdata['metadata']) || !empty($imgdata['fileId'])) { //Get ID numbers for images in galleries and attachments included in src as url parameter //So we can get db info for these too $parsed = parse_url($imgdata['src']); if (empty($parsed['host']) || !empty($parsed['host']) && strstr($base_url, $parsed['host'])) { if (strlen(strstr($imgdata['src'], $imagegalpath)) > 0) { $imgdata['id'] = substr(strstr($imgdata['src'], $imagegalpath), strlen($imagegalpath)); } elseif (strlen(strstr($imgdata['src'], $filegalpath)) > 0) { $imgdata['fileId'] = substr(strstr($imgdata['src'], $filegalpath), strlen($filegalpath)); } elseif (strlen(strstr($imgdata['src'], $attachpath)) > 0) { $imgdata['attId'] = substr(strstr($imgdata['src'], $attachpath), strlen($attachpath)); } } $imageObj = ''; require_once 'lib/images/images.php'; //Deal with images with info in tiki databases (file and image galleries and attachments) if (empty($imgdata['randomGalleryId']) && (!empty($imgdata['id']) || !empty($imgdata['fileId']) || !empty($imgdata['attId']))) { //Try to get image from database if (!empty($imgdata['id'])) { global $imagegallib; include_once 'lib/imagegals/imagegallib.php'; $dbinfo = $imagegallib->get_image_info($imgdata['id'], 'o'); $dbinfo2 = $imagegallib->get_image($imgdata['id'], 'o'); $dbinfo = isset($dbinfo) && isset($dbinfo2) ? array_merge($dbinfo, $dbinfo2) : array(); $dbinfot = $imagegallib->get_image_info($imgdata['id'], 't'); $dbinfot2 = $imagegallib->get_image($imgdata['id'], 't'); $dbinfot = isset($dbinfot) && isset($dbinfot2) ? array_merge($dbinfot, $dbinfot2) : array(); $basepath = $prefs['gal_use_dir']; } elseif (!isset($dbinfo) && !empty($imgdata['fileId'])) { $filegallib = TikiLib::lib('filegal'); $dbinfo = $filegallib->get_file($imgdata['fileId']); $basepath = $prefs['fgal_use_dir']; } else { //only attachments left global $atts; global $wikilib; include_once 'lib/wiki/wikilib.php'; $dbinfo = $wikilib->get_item_attachment($imgdata['attId']); $basepath = $prefs['w_use_dir']; } //Give error messages if file doesn't exist, isn't an image. Display nothing if user lacks permission if (!empty($imgdata['fileId']) || !empty($imgdata['id']) || !empty($imgdata['attId'])) { if (!$dbinfo) { return '^' . tra('File not found.') . '^'; } elseif (substr($dbinfo['filetype'], 0, 5) != 'image' and !preg_match('/thumbnail/i', $imgdata['fileId'])) { return '^' . tra('File is not an image.') . '^'; } elseif (!class_exists('Image')) { return '^' . tra('Server does not support image manipulation.') . '^'; } elseif (!empty($imgdata['fileId'])) { if (!$userlib->user_has_perm_on_object($user, $dbinfo['galleryId'], 'file gallery', 'tiki_p_download_files')) { return $notice; } } elseif (!empty($imgdata['id'])) { if (!$userlib->user_has_perm_on_object($user, $dbinfo['galleryId'], 'image gallery', 'tiki_p_view_image_gallery')) { return $notice; } } elseif (!empty($imgdata['attId'])) { if (!$userlib->user_has_perm_on_object($user, $dbinfo['page'], 'wiki page', 'tiki_p_wiki_view_attachments')) { return $notice; } } } } //finished getting info from db for images in image or file galleries or attachments //get image to get height and width and iptc data if (!empty($dbinfo['data'])) { $imageObj = new Image($dbinfo['data'], false); $filename = $dbinfo['filename']; } elseif (!empty($dbinfo['path'])) { $imageObj = new Image($basepath . $dbinfo['path'], true); $filename = $dbinfo['filename']; } else { $imageObj = new Image($src, true); $filename = $src; } //if we need metadata $xmpview = !empty($imgdata['metadata']) ? true : false; if ($imgdata['desc'] == 'idesc' || $imgdata['desc'] == 'ititle' || $xmpview) { $dbinfoparam = isset($dbinfo) ? $dbinfo : false; $metadata = getMetadataArray($imageObj, $dbinfoparam); if ($imgdata['desc'] == 'idesc') { $idesc = getMetaField($metadata, array('User Data' => 'Description')); } if ($imgdata['desc'] == 'ititle') { $ititle = getMetaField($metadata, array('User Data' => 'Title')); } } $fwidth = ''; $fheight = ''; if (isset(TikiLib::lib('parser')->option['indexing']) && TikiLib::lib('parser')->option['indexing']) { $fwidth = 1; $fheight = 1; } else { $fwidth = $imageObj->get_width(); $fheight = $imageObj->get_height(); } //get image gal thumbnail image for height and width if (!empty($dbinfot['data']) || !empty($dbinfot['path'])) { if (!empty($dbinfot['data'])) { $imageObjt = new Image($dbinfot['data'], false); } elseif (!empty($dbinfot['path'])) { $imageObjt = new Image($basepath . $dbinfot['path'] . '.thumb', true); } $fwidtht = $imageObjt->get_width(); $fheightt = $imageObjt->get_height(); } /////////////////////////////////////Add image dimensions to src string//////////////////////////////////////////// //Use url resizing parameters for file gallery images to set $height and $width //since they can affect other elements; overrides plugin parameters if (!empty($imgdata['fileId']) && strpos($src, '&') !== false) { $urlthumb = strpos($src, '&thumbnail'); $urlprev = strpos($src, '&preview'); $urldisp = strpos($src, '&display'); preg_match('/(?<=\\&max=)[0-9]+(?=.*)/', $src, $urlmax); preg_match('/(?<=\\&x=)[0-9]+(?=.*)/', $src, $urlx); preg_match('/(?<=\\&y=)[0-9]+(?=.*)/', $src, $urly); preg_match('/(?<=\\&scale=)[0]*\\.[0-9]+(?=.*)/', $src, $urlscale); if (!empty($urlmax[0]) && $urlmax[0] > 0) { $imgdata['max'] = $urlmax[0]; } if (!empty($urlx[0]) && $urlx[0] > 0) { $imgdata['width'] = $urlx[0]; } if (!empty($urly[0]) && $urly[0] > 0) { $imgdata['height'] = $urly[0]; } if (!empty($urlscale[0]) && $urlscale[0] > 0) { $height = floor($urlscale[0] * $fheight); $width = floor($urlscale[0] * $fwidth); $imgdata['width'] = ''; $imgdata['height'] = ''; } if ($urlthumb != false && empty($imgdata['height']) && empty($imgdata['width']) && empty($imgdata['max'])) { $imgdata['max'] = 120; } if ($urlprev != false && empty($urlscale[0]) && empty($imgdata['height']) && empty($imgdata['width']) && empty($imgdata['max'])) { $imgdata['max'] = 800; } } //Note if image gal url thumb parameter is used $imgalthumb = false; if (!empty($imgdata['id'])) { preg_match('/(?<=\\&thumb=1)[0-9]+(?=.*)/', $src, $urlimthumb); if (!empty($urlimthumb[0]) && $urlimthumb[0] > 0) { $imgalthumb = true; } } include_once 'lib/mime/mimetypes.php'; global $mimetypes; //Now set dimensions based on plugin parameter settings if (!empty($imgdata['max']) || !empty($imgdata['height']) || !empty($imgdata['width']) || !empty($imgdata['thumb'])) { // find svg image size if (!empty($dbinfo['filetype']) && !empty($mimetypes['svg']) && $dbinfo['filetype'] == $mimetypes['svg']) { if (preg_match('/width="(\\d+)" height="(\\d+)"/', $dbinfo['data'], $svgdim)) { $fwidth = $svgdim[1]; $fheight = $svgdim[2]; } } //Convert % and px in height and width $scale = ''; if (strpos($imgdata['height'], '%') !== false || strpos($imgdata['width'], '%') !== false) { if (strpos($imgdata['height'], '%') !== false && strpos($imgdata['width'], '%') !== false && (empty($imgdata['fileId']) || empty($urlx[0]) && empty($urly[0]))) { $imgdata['height'] = floor(rtrim($imgdata['height'], '%') / 100 * $fheight); $imgdata['width'] = floor(rtrim($imgdata['width'], '%') / 100 * $fwidth); } elseif (strpos($imgdata['height'], '%') !== false) { if ($imgdata['fileId']) { $scale = rtrim($imgdata['height'], '%') / 100; $height = floor($scale * $fheight); } else { $imgdata['height'] = floor(rtrim($imgdata['height'], '%') / 100 * $fheight); } } else { if ($imgdata['fileId']) { $scale = rtrim($imgdata['width'], '%') / 100; $width = floor($scale * $fwidth); } else { $imgdata['width'] = floor(rtrim($imgdata['width'], '%') / 100 * $fwidth); } } } elseif (strpos($imgdata['height'], 'px') !== false || strpos($imgdata['width'], 'px') !== false) { if (strpos($imgdata['height'], 'px') !== false) { $imgdata['height'] = rtrim($imgdata['height'], 'px'); } else { $imgdata['width'] = rtrim($imgdata['width'], 'px'); } } // Adjust for max setting, keeping aspect ratio if (!empty($imgdata['max'])) { if ($fwidth > $imgdata['max'] || $fheight > $imgdata['max']) { //use image gal thumbs when possible if (!empty($imgdata['id']) && $imgalthumb == false && ($imgdata['max'] < $fwidtht || $imgdata['max'] < $fheightt)) { $src .= '&thumb=1'; $imgalthumb == true; } if ($fwidth > $fheight) { $width = $imgdata['max']; $height = floor($width * $fheight / $fwidth); } else { $height = $imgdata['max']; $width = floor($height * $fwidth / $fheight); } //cases where max is set but image is smaller than max } else { $height = $fheight; $width = $fwidth; } // Adjust for user settings for height and width if max isn't set. } elseif (!empty($imgdata['height'])) { //use image gal thumbs when possible if (!empty($imgdata['id']) && $imgalthumb == false && $imgdata['height'] < $fheightt) { $src .= '&thumb=1'; $imgalthumb == true; } $height = $imgdata['height']; if (empty($imgdata['width']) && $fheight > 0) { $width = floor($height * $fwidth / $fheight); } else { $width = $imgdata['width']; } } elseif (!empty($imgdata['width'])) { //use image gal thumbs when possible if (!empty($imgdata['id']) && $imgalthumb == false && $imgdata['width'] < $fwidtht) { $src .= '&thumb=1'; $imgalthumb == true; } $width = $imgdata['width']; if (empty($imgdata['height']) && $fwidth > 0) { $height = floor($width * $fheight / $fwidth); } else { $height = $imgdata['height']; } // If not otherwise set, use default setting for thumbnail height if thumb is set } elseif ((!empty($imgdata['thumb']) || !empty($urlthumb)) && empty($scale)) { if (!empty($imgdata['fileId'])) { $thumbdef = $prefs['fgal_thumb_max_size']; } else { $thumbdef = 84; } //handle image gal thumbs if (!empty($imgdata['id']) && !empty($fwidtht) && !empty($fheightt)) { $width = $fwidtht; $height = $fheightt; if ($imgalthumb == false) { $src .= '&thumb=1'; $imgalthumb == true; } } else { if ($fwidth > $thumbdef || $fheight > $thumbdef) { if ($fwidth > $fheight) { $width = $thumbdef; $height = floor($width * $fheight / $fwidth); } else { $height = $thumbdef; $width = floor($height * $fwidth / $fheight); } } } } } //Set final height and width dimension string //handle file gallery images separately to use server-side resizing capabilities $imgdata_dim = ''; if (!empty($imgdata['fileId'])) { if (empty($urldisp) && empty($urlthumb)) { $srcIsEditable = true; $src .= '&display'; } if (!empty($scale) && empty($urlscale[0])) { $src .= '&scale=' . $scale; } elseif (!empty($imgdata['max']) && $imgdata['thumb'] != 'download' && (empty($urlthumb) && empty($urlmax[0]) && empty($urlprev))) { $src .= '&max=' . $imgdata['max']; $imgdata_dim .= ' width="' . $width . '"'; $imgdata_dim .= ' height="' . $height . '"'; } elseif (!empty($width) || !empty($height)) { if (!empty($width) && !empty($height) && (empty($urlx[0]) && empty($urly[0]) && empty($urlscale[0]))) { $src .= '&x=' . $width . '&y=' . $height; $imgdata_dim .= ' width="' . $width . '"'; $imgdata_dim .= ' height="' . $height . '"'; } elseif (!empty($width) && (empty($urlx[0]) && empty($urlthumb) && empty($urlscale[0]))) { $src .= '&x=' . $width; $height = $fheight; $imgdata_dim .= ' width="' . $width . '"'; $imgdata_dim .= ' height="' . $height . '"'; } elseif (!empty($height) && (empty($urly[0]) && empty($urlthumb) && empty($urlscale[0]))) { $src .= '&y=' . $height; $imgdata_dim = ''; $width = $fwidth; } } else { $imgdata_dim = ''; $height = $fheight; $width = $fwidth; if (!empty($width) && !empty($height)) { $imgdata_dim .= ' width="' . $width . '"'; $imgdata_dim .= ' height="' . $height . '"'; } } } else { if (!empty($height)) { $imgdata_dim = ' height="' . $height . '"'; } else { $imgdata_dim = ''; $height = $fheight; } if (!empty($width)) { $imgdata_dim .= ' width="' . $width . '"'; } else { $imgdata_dim = ''; $width = $fwidth; } } } ////////////////////////////////////////// Create the HTML img tag ////////////////////////////////////////////// //Start tag with src and dimensions $src = filter_out_sefurl($src); $tagName = ''; if (!empty($dbinfo['filetype']) && !empty($mimetypes['svg']) && $dbinfo['filetype'] == $mimetypes['svg']) { $tagName = 'div'; $repldata = $dbinfo['data']; if (!empty($fwidth) && !empty($fheight) && !empty($imgdata_dim)) { // change svg attributes to show at the correct size $svgAttributes = $imgdata_dim . ' viewBox="0 0 ' . $fwidth . ' ' . $fheight . '" preserveAspectRatio="xMinYMin meet"'; $repldata = preg_replace('/width="' . $fwidth . '" height="' . $fheight . '"/', $svgAttributes, $repldata); } $replimg = '<div type="image/svg+xml" '; $imgdata['class'] .= ' svgImage pluginImg' . $imgdata['fileId']; $imgdata['class'] = trim($imgdata['class']); } else { $tagName = 'img'; $replimg = '<img src="' . $src . '" '; $imgdata['class'] .= ' regImage pluginImg' . $imgdata['fileId']; $imgdata['class'] = trim($imgdata['class']); } if (!empty($imgdata_dim)) { $replimg .= $imgdata_dim; } //Create style attribute allowing for shortcut inputs //First set alignment string $center = 'display:block; margin-left:auto; margin-right:auto;'; //used to center image and box if (!empty($imgdata['imalign'])) { $imalign = ''; if ($imgdata['imalign'] == 'center') { $imalign = $center; } else { $imalign = 'float:' . $imgdata['imalign'] . ';'; } } elseif ($imgdata['stylebox'] == 'border') { $imalign = $center; } //set entire style string if (!empty($imgdata['styleimage']) || !empty($imalign)) { $border = ''; $style = ''; $borderdef = 'border:1px solid darkgray;'; //default border when styleimage set to border if (!empty($imgdata['styleimage'])) { if (!empty($imalign)) { if (strpos(trim($imgdata['styleimage'], ' '), 'float:') !== false || strpos(trim($imgdata['styleimage'], ' '), 'display:') !== false) { $imalign = ''; //override imalign setting if style image contains alignment syntax } } if ($imgdata['styleimage'] == 'border') { $border = $borderdef; } else { if (strpos($imgdata['styleimage'], 'hidden') === false && strpos($imgdata['styleimage'], 'position') === false) { // quick filter for dangerous styles $style = $imgdata['styleimage']; } } } $replimg .= ' style="' . $imalign . $border . $style . '"'; } //alt if (!empty($imgdata['alt'])) { $replimg .= ' alt="' . $imgdata['alt'] . '"'; } elseif (!empty($imgdata['desc'])) { $replimg .= ' alt="' . $imgdata['desc'] . '"'; } elseif (!empty($dbinfo['description'])) { $replimg .= ' alt="' . $dbinfo['description'] . '"'; } else { $replimg .= ' alt="Image"'; } //usemap if (!empty($imgdata['usemap'])) { $replimg .= ' usemap="#' . $imgdata['usemap'] . '"'; } //class if (!empty($imgdata['class'])) { $replimg .= ' class="' . $imgdata['class'] . '"'; } //title (also used for description and link title below) //first set description, which is used for title if no title is set if (!empty($imgdata['desc']) || !empty($imgdata['title'])) { $desc = ''; $imgname = ''; $desconly = ''; if (!empty($imgdata['desc'])) { //attachment database uses comment instead of description or name if (!empty($dbinfo['comment'])) { $desc = $dbinfo['comment']; $imgname = $dbinfo['comment']; } elseif (isset($dbinfo)) { $desc = !empty($dbinfo['description']) ? $dbinfo['description'] : ''; $imgname = !empty($dbinfo['name']) ? $dbinfo['name'] : ''; } switch ($imgdata['desc']) { case 'desc': $desconly = $desc; break; case 'idesc': $desconly = $idesc; break; case 'name': $desconly = $imgname; break; case 'ititle': $desconly = $ititle; break; case 'namedesc': $desconly = $imgname . (!empty($imgname) && !empty($desc) ? ' - ' : '') . $desc; break; default: $desconly = $imgdata['desc']; } } //now set title $imgtitle = ''; $titleonly = ''; if (!empty($imgdata['title']) || !empty($desconly)) { $imgtitle = ' title="'; if (!empty($imgdata['title'])) { switch ($imgdata['title']) { case 'desc': $titleonly = $desc; break; case 'name': $titleonly = $imgname; break; case 'namedesc': $titleonly = $imgname . (!empty($imgname) && !empty($desc) ? ' - ' : '') . $desc; break; default: $titleonly = $imgdata['title']; } //use desc setting for title if title is empty } else { $titleonly = $desconly; } $imgtitle .= $titleonly . '"'; $replimg .= $imgtitle; } } if (empty($repldata)) { $replimg .= ' />' . "\r"; } else { $replimg .= '>' . $repldata . '</' . $tagName . '>'; } ////////////////////////////////////////// Create the HTML link /////////////////////////////////////////// //Variable for identifying if javascript mouseover is set if ($imgdata['thumb'] == 'mouseover' || $imgdata['thumb'] == 'mousesticky') { $javaset = 'true'; } else { $javaset = ''; } // Set link to user setting or to image itself if thumb is set if (!empty($imgdata['link']) || !empty($imgdata['thumb']) && !(isset($params['link']) && empty($params['link']))) { $mouseover = ''; if (!empty($imgdata['link'])) { $link = $imgdata['link']; } elseif (($imgdata['thumb'] == 'browse' || $imgdata['thumb'] == 'browsepopup') && !empty($imgdata['id'])) { $link = 'tiki-browse_image.php?imageId=' . $imgdata['id']; } elseif ($javaset == 'true') { $link = 'javascript:void(0)'; $popup_params = array('text' => $data, 'width' => $fwidth, 'height' => $fheight, 'background' => $browse_full_image); if ($imgdata['thumb'] == 'mousesticky') { $popup_params['sticky'] = true; } $smarty->loadPlugin('smarty_function_popup'); $mouseover = ' ' . smarty_function_popup($popup_params, $smarty); } else { if (!empty($imgdata['fileId']) && $imgdata['thumb'] != 'download' && empty($urldisp)) { $link = $browse_full_image . '&display'; } else { $link = $browse_full_image; } } if ($imgdata['thumb'] == 'box' && empty($imgdata['rel'])) { $imgdata['rel'] = 'box'; } // Set other link-related attributes // target $imgtarget = ''; if ($prefs['popupLinks'] == 'y' && (preg_match('#^([a-z0-9]+?)://#i', $link) || preg_match('#^www\\.([a-z0-9\\-]+)\\.#i', $link)) || $imgdata['thumb'] == 'popup' || $imgdata['thumb'] == 'browsepopup') { if (!empty($javaset) || $imgdata['rel'] == 'box') { $imgtarget = ''; } else { $imgtarget = ' target="_blank"'; } } // rel !empty($imgdata['rel']) ? $linkrel = ' rel="' . $imgdata['rel'] . '"' : ($linkrel = ''); // title !empty($imgtitle) ? $linktitle = $imgtitle : ($linktitle = ''); $link = filter_out_sefurl($link); //Final link string $replimg = "\r\t" . '<a href="' . $link . '" class="internal"' . $linkrel . $imgtarget . $linktitle . $mouseover . '>' . "\r\t\t" . $replimg . "\r\t" . '</a>'; } //Add link string to rest of string $repl .= $replimg; //////////////////////////Generate metadata dialog box and jquery (dialog icon added in next section)//////////////////////////////////// if ($imgdata['metadata'] == 'view') { //create unique id's in case of multiple pictures static $lastval = 0; $id_meta = 'imgdialog-' . ++$lastval; $id_link = $id_meta . '-link'; //use metadata stored in file gallery db if available include_once 'lib/metadata/metadatalib.php'; $meta = new FileMetadata(); $dialog = $meta->dialogTabs($metadata, $id_meta, $id_link, $filename); $repl .= $dialog; } ////////////////////// Create enlarge button, metadata icon, description and their divs//////////////////// //Start div that goes around button and description if these are set if (!empty($imgdata['button']) || !empty($imgdata['desc']) || !empty($imgdata['styledesc']) || !empty($imgdata['metadata'])) { //To set room for enlarge button under image if there is no description $descheightdef = 'height:17px;clear:left;'; $repl .= "\r\t" . '<div class="mini" style="width:' . $width . 'px;'; if (!empty($imgdata['styledesc'])) { if ($imgdata['styledesc'] == 'left' || $imgdata['styledesc'] == 'right') { $repl .= 'text-align:' . $imgdata['styledesc'] . '">'; } else { $repl .= $imgdata['styledesc'] . '">'; } } elseif (!empty($imgdata['button']) && empty($desconly)) { $repl .= $descheightdef . '">'; } else { $repl .= '">'; } //Start description div that also includes enlarge button div $repl .= "\r\t\t" . '<div class="thumbcaption">'; //Enlarge button div and link string (innermost div) if (!empty($imgdata['button'])) { if (empty($link) || !empty($link) && !empty($javaset)) { if (($imgdata['button'] == 'browse' || $imgdata['button'] == 'browsepopup') && !empty($imgdata['id'])) { $link_button = 'tiki-browse_image.php?imageId=' . $imgdata['id']; } else { if (!empty($imgdata['fileId']) && $imgdata['button'] != 'download') { $link_button = $browse_full_image . '&display'; } elseif (!empty($imgdata['attId']) && $imgdata['thumb'] == 'download') { $link = $browse_full_image . '&download=y'; } else { $link_button = $browse_full_image; } } } else { $link_button = $link; } //Set button rel !empty($imgdata['rel']) ? $linkrel_button = ' rel="' . $imgdata['rel'] . '"' : ($linkrel_button = ''); //Set button target if (empty($imgtarget) && (empty($imgdata['thumb']) || !empty($javaset))) { if ($imgdata['button'] == 'popup' || $imgdata['button'] == 'browsepopup') { $imgtarget_button = ' target="_blank"'; } else { $imgtarget_button = ''; } } else { $imgtarget_button = $imgtarget; } $repl .= "\r\t\t\t" . '<div class="magnify" style="float:right">'; $repl .= "\r\t\t\t\t" . '<a href="' . $link_button . '"' . $linkrel_button . $imgtarget_button; $repl .= ' class="internal"'; if (!empty($titleonly)) { $repl .= ' title="' . $titleonly . '"'; } $repl .= ">\r\t\t\t\t" . '<img class="magnify" src="./img/icons/magnifier.png" alt="' . tra('Enlarge') . '" /></a>' . "\r\t\t\t</div>"; } //Add metadata icon if ($imgdata['metadata'] == 'view') { $repl .= '<div style="float:right; margin-right:2px"><a href="#" id="' . $id_link . '"><img src="./img/icons/tag_orange.png" alt="' . tra('Metadata') . '" title="' . tra('Metadata') . '"/></a></div>'; } //Add description based on user setting (use $desconly from above) and close divs isset($desconly) ? $repl .= $desconly : ''; $repl .= "\r\t\t</div>"; $repl .= "\r\t</div>"; } ///////////////////////////////Wrap in overall div that includes image if needed//////////////// //Need a box if any of these are set if (!empty($imgdata['button']) || !empty($imgdata['desc']) || !empty($imgdata['metadata']) || !empty($imgdata['stylebox']) || !empty($imgdata['align'])) { //Make the div surrounding the image 2 pixels bigger than the image if (empty($height)) { $height = ''; } if (empty($width)) { $width = ''; } $boxwidth = $width + 2; $boxheight = $height + 2; $alignbox = ''; $class = ''; if (!empty($imgdata['align'])) { if ($imgdata['align'] == 'center') { $alignbox = $center; } else { $alignbox = 'float:' . $imgdata['align'] . '; margin-' . ($imgdata['align'] == 'left' ? 'right' : 'left') . ':5px;'; } } //first set stylebox string if style box is set if (!empty($imgdata['stylebox']) || !empty($imgdata['align'])) { //create strings from shortcuts first if (!empty($imgdata['stylebox'])) { if ($imgdata['stylebox'] == 'border') { $class = 'class="imgbox" '; if (!empty($alignbox)) { if (strpos(trim($imgdata['stylebox'], ' '), 'float:') !== false || strpos(trim($imgdata['stylebox'], ' '), 'display:') !== false) { $alignbox = ''; //override align setting if stylebox contains alignment syntax } } } else { $styleboxinit = $imgdata['stylebox'] . ';'; } } if (empty($imgdata['button']) && empty($imgdata['desc']) && empty($styleboxinit)) { $styleboxplus = $alignbox . ' width:' . $boxwidth . 'px; height:' . $boxheight . 'px'; } elseif (!empty($styleboxinit)) { if (strpos(trim($imgdata['stylebox'], ' '), 'height:') === false && strpos(trim($imgdata['stylebox'], ' '), 'width:') === false) { $styleboxplus = $styleboxinit . ' width:' . $boxwidth . 'px;'; } else { $styleboxplus = $styleboxinit; } } else { $styleboxplus = $alignbox . ' width:' . $boxwidth . 'px;'; } } elseif (!empty($imgdata['button']) || !empty($imgdata['desc']) || !empty($imgdata['metadata'])) { $styleboxplus = ' width:' . $boxwidth . 'px;'; } } if (!empty($styleboxplus)) { $repl = "\r" . '<div ' . $class . 'style="' . $styleboxplus . '">' . $repl . "\r" . '</div>'; } //////////////////////////////////////Place 'clear' block/////////////////////////////////////////////////////////// if (!empty($imgdata['block'])) { switch ($imgdata['block']) { case 'top': $repl = "\n\r<br style=\"clear:both\" />\r" . $repl; break; case 'bottom': $repl = $repl . "\n\r<br style=\"clear:both\" />\r"; break; case 'both': $repl = "\n\r<br style=\"clear:both\" />\r" . $repl . "\n\r<br style=\"clear:both\" />\r"; break; case 'top': break; } } // Mobile if (isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'mobile') { $repl = '{img src=' . $src . "\"}\n<p>" . $imgdata['desc'] . '</p>'; } if (!TikiLib::lib('parser')->option['suppress_icons'] && $prefs['feature_draw'] == 'y' && !empty($dbinfo['galleryId']) && $imgdata['noDrawIcon'] !== 'y') { global $tiki_p_edit; $globalperms = Perms::get(array('type' => 'file gallery', 'object' => $dbinfo['galleryId'])); if ($imgdata['fromItemId']) { if ($imgdata['checkItemPerms'] !== 'n') { $perms_Accessor = Perms::get(array('type' => 'tracker item', 'object' => $imgdata['fromItemId'])); $trackerItemPerms = $perms_Accessor->modify_tracker_items; } else { $trackerItemPerms = true; } } else { $trackerItemPerms = false; } if ($globalperms->upload_files == 'y' && (empty($src) == true || $srcIsEditable == true) && ($tiki_p_edit == 'y' || $trackerItemPerms)) { if ($prefs['wiki_edit_icons_toggle'] == 'y' && !isset($_COOKIE['wiki_plugin_edit_view']) && !$imgdata['fromItemId']) { $iconDisplayStyle = " style=\"display:none;\""; } else { $iconDisplayStyle = ''; } $jsonParams = json_encode(array_filter($imgdata)); $repl .= "<a href=\"tiki-edit_draw.php?fileId={$imgdata['fileId']}\" onclick=\"return \$(this).ajaxEditDraw();\" title=\"" . tr("Draw on the Image") . "\"" . " class=\"editplugin pluginImgEdit{$imgdata['fileId']}\" data-fileid=\"{$imgdata['fileId']}\" " . "data-galleryid=\"{$dbinfo['galleryId']}\"{$iconDisplayStyle} data-imgparams='{$jsonParams}'>" . "<img width='16' height='16' class='icon' alt='Edit' src='img/icons/page_edit.png' /></a>"; } } return '~np~' . $repl . "\r" . '~/np~'; }
function wp_fixture_tracker_data($data, $params, $mock) { $table = new FixtureTable($data); $headings = $table->getHeadings(); $trackerId = $params->trackerId->int(); $tracker = Tracker_Definition::get($trackerId); if (!$tracker) { return '__' . tr('Tracker not found.') . '__'; } $smarty = TikiLib::lib('smarty'); $smarty->loadPlugin('smarty_modifier_sefurl'); $url = smarty_modifier_sefurl($trackerId, 'tracker'); $table->setTitle(tr('Tracker Data for [%0|%1]', $url, $tracker->getConfiguration('name'))); if (!in_array('itemId', $headings)) { return '__' . tr('Table must contain at least one field named itemId') . '__'; } foreach ($headings as $permName) { if ($permName != 'itemId' && !($field = $tracker->getFieldFromPermName($permName))) { return '__' . tr('Tracker Field not found: %0', $permName) . '__'; } } foreach ($table as $row) { $fields = array_combine($headings, $row); $itemId = $fields['itemId']; unset($fields['itemId']); $mock->addValues($itemId, $fields); } return $table; }
} if ($prefs['geo_locate_blogpost'] == 'y' && !empty($_REQUEST['geolocation'])) { TikiLib::lib('geo')->set_coordinates('blog post', $postId, $_REQUEST['geolocation']); } // TAG Stuff $cat_type = 'blog post'; $cat_objid = $postId; $cat_desc = TikiFilter::get('purifier')->filter(substr($edit_data, 0, 200)); $cat_name = $title; $cat_href = "tiki-view_blog_post.php?postId=" . urlencode($postId); $cat_lang = $_REQUEST['lang']; include_once "freetag_apply.php"; include_once "categorize.php"; require_once 'tiki-sefurl.php'; $smarty->loadPlugin('smarty_modifier_sefurl'); $url = smarty_modifier_sefurl($postId, 'blogpost'); header("location: {$url}"); exit; } if ($contribution_needed) { $smarty->assign('title', $_REQUEST["title"]); $smarty->assign('parsed_data', $tikilib->parse_data($_REQUEST['data'], array('is_html' => $is_wysiwyg))); $smarty->assign('data', $_REQUEST['data']); if ($prefs['feature_freetags'] == 'y') { $smarty->assign('taglist', $_REQUEST["freetag_string"]); } } $cat_type = 'blog post'; $cat_objid = $postId; include_once "categorize_list.php"; if ($prefs['geo_locate_blogpost'] == 'y') {
/** * Render output for this field. * IMPORTANT: This method uses the following $_GET args directly: 'page' * @TODO fixit so it does not directly access the $_GET array. Better pass it as a param. * @param array $context -keys: * <pre> * $context = array( * // required * // optional * 'url' => 'sefurl', // other values 'offset', 'tr_offset' * 'reloff' => true, // checked only if set * 'showpopup' => 'y', // wether to show that value in a mouseover popup * 'showlinks' => 'n' // NO check for 'y' but 'n' * 'list_mode' => 'csv' // * ); * </pre> * * @return string $renderedContent depending on the $context */ public function renderOutput($context = array()) { // only if this field is marked as link and the is no request for a csv export // create the link and if required the mouseover popup if ($this->isLink($context)) { $itemId = $this->getItemId(); $query = $_GET; unset($query['trackerId']); if (isset($query['page'])) { $query['from'] = $query['page']; unset($query['page']); } $classList = array('tablename'); $metadata = TikiLib::lib('object')->get_metadata('trackeritem', $itemId, $classList); require_once 'lib/smarty_tiki/modifier.sefurl.php'; $href = smarty_modifier_sefurl($itemId, 'trackeritem'); $href .= strpos($href, '?') === false ? '?' : '&'; $href .= http_build_query($query, '', '&'); $href = rtrim($href, '?&'); $arguments = array('class' => implode(' ', $classList), 'href' => $href); if (!empty($context['url'])) { if ($context['url'] == 'sefurl') { $context['url'] = 'item' . $itemId; } elseif (strpos($context['url'], 'itemId') !== false) { $context['url'] = preg_replace('/([&|\\?])itemId=?[^&]*/', '\\1itemId=' . $itemId, $context['url']); } elseif (isset($context['reloff']) && strpos($context['url'], 'offset') !== false) { $smarty = TikiLib::lib('smarty'); $context['url'] = preg_replace('/([&|\\?])tr_offset=?[^&]*/', '\\1tr_offset' . $smarty->tpl_vars['iTRACKERLIST'] . '=' . $context['reloff'], $context['url']); } $arguments['href'] = $context['url']; } $pre = '<a'; foreach ($arguments as $key => $value) { $pre .= ' ' . $key . '="' . htmlentities($value, ENT_QUOTES, 'UTF-8') . '"'; } // add the html / js for the mouseover popup if (isset($context['showpopup']) && $context['showpopup'] == 'y') { // check if trackerplugin has set popup fields using the popup parameter $pluginPopupFields = isset($context['popupfields']) ? $context['popupfields'] : null; $popup = $this->renderPopup($pluginPopupFields); if ($popup) { $popup = preg_replace('/<\\!--.*?-->/', '', $popup); // remove comments added by log_tpl $popup = preg_replace('/\\s+/', ' ', $popup); $pre .= " {$popup}"; } } $pre .= $metadata; $pre .= '>'; $post = '</a>'; return $pre . $this->renderInnerOutput($context) . $post; } else { // no link, no mouseover popup. Note: can also be a part of a csv request return $this->renderInnerOutput($context); } }