function smarty_modifier_avatarize($user) { global $tikilib; global $userlib; $avatar = $tikilib->get_user_avatar($user); if ($avatar != '' && $tikilib->get_user_preference($user, 'user_information', 'public') == 'public') { $id = $userlib->get_user_id($user); include_once 'tiki-sefurl.php'; $url = "tiki-user_information.php?userId={$id}"; $url = filter_out_sefurl($url); $avatar = "<a title=\"" . htmlspecialchars($user, ENT_QUOTES) . "\" href=\"{$url}\">" . $avatar . '</a>'; } return $avatar; }
$base_uri = $base_host; // maybe better than nothing } } if (strpos($base_uri, $tikiroot . 'route.php') !== false && !empty($inclusion)) { $base_uri = $base_url . $inclusion; if (!empty($_GET)) { $base_uri .= '?' . http_build_query($_GET, '', '&'); } global $section, $sections; include_once 'tiki-sefurl.php'; if (isset($sections[$section]['objectType'])) { $objectType = $sections[$section]['objectType']; } else { $objectType = $section; } if ($objectType === 'wiki page') { $objectType = 'wiki'; } $base_uri = TikiLib::tikiUrlOpt(filter_out_sefurl($base_uri, $objectType)); } // SSL options if (isset($_REQUEST['stay_in_ssl_mode_present']) || isset($_REQUEST['stay_in_ssl_mode'])) { // We stay in HTTPS / SSL mode if 'stay_in_ssl_mode' has an 'y' or 'on' value $stay_in_ssl_mode = isset($_REQUEST['stay_in_ssl_mode']) && $_REQUEST['stay_in_ssl_mode'] == 'y' || isset($_REQUEST['stay_in_ssl_mode']) && $_REQUEST['stay_in_ssl_mode'] == 'on' ? 'y' : 'n'; } else { // Set default value of 'stay_in_ssl_mode' to the current mode state $stay_in_ssl_mode = $https_mode ? 'y' : 'n'; } // Show the 'Stay in SSL mode' checkbox only if we are already in HTTPS $show_stay_in_ssl_mode = $https_mode || $prefs['https_login'] == 'required' ? 'y' : 'n';
if ($tracker_info['useAttachments'] == 'y') { ++$cookietab; } if ($tracker_info['useComments'] == 'y') { ++$cookietab; } $smarty->assign('input_err', '1'); // warning to display // can't go back if there are errors if (isset($_REQUEST['save_return'])) { $_REQUEST['save'] = 'save'; unset($_REQUEST['save_return']); } } if (isset($_REQUEST['save_return']) && isset($_REQUEST['from'])) { $fromUrl = filter_out_sefurl('tiki-index.php?page=' . urlencode($_REQUEST['from'])); header("Location: {$fromUrl}"); exit; } } } // remove image from an image field if (isset($_REQUEST["removeImage"])) { $img_field = array('data' => array()); $img_field['data'][] = array('fieldId' => $_REQUEST["fieldId"], 'type' => 'i', 'name' => $_REQUEST["fieldName"], 'value' => 'blank'); $trklib->replace_item($_REQUEST["trackerId"], $_REQUEST["itemId"], $img_field); $_REQUEST['show'] = "mod"; } // ************* return to list *************************** if (isset($_REQUEST["returntracker"]) || isset($_REQUEST["save_return"])) { require_once 'lib/smarty_tiki/block.self_link.php';
} if (!$article_data) { $smarty->assign('msg', tra('Article not found')); $smarty->display('error.tpl'); die; } } else { $articleId = 0; } if (isset($_REQUEST['cancel_edit'])) { if (empty($articleId)) { header('location: tiki-view_articles.php'); die; } include_once 'tiki-sefurl.php'; header('location: ' . filter_out_sefurl("tiki-read_article.php?articleId={$articleId}", 'article', $artice_data['title'])); die; } // We need separate numbering of previews, since we access preview images by this number if (isset($_REQUEST['previewId'])) { $previewId = $_REQUEST['previewId']; } else { $previewId = rand(); } $smarty->assign('articleId', $articleId); $smarty->assign('previewId', $previewId); $smarty->assign('imageIsChanged', isset($_REQUEST['imageIsChanged']) && $_REQUEST['imageIsChanged'] == 'y' ? 'y' : 'n'); if (isset($_REQUEST['templateId']) && $_REQUEST['templateId'] > 0) { global $templateslib; require_once 'lib/templates/templateslib.php'; $template_data = $templateslib->get_template($_REQUEST['templateId'], $prefs['language']);
// - pref 'Go to group homepage only if login from default homepage' (limitedGoGroupHome) is disabled, // - referer url (e.g. http://example.com/tiki/tiki-index.php?page=Homepage ) is the homepage (tikiIndex), // - referer url complete path ( e.g. /tiki/tiki-index.php?page=Homepage ) is the homepage, // - referer url relative path ( e.g. tiki-index.php?page=Homepage ) is the homepage // - referer url SEF page ( e.g. /tiki/Homepage ) is the homepage // - one of the three cases listed above, but compared to anonymous page instead of global homepage // - first login after registration // - last case ($tikiIndex_full != '') : // wiki homepage could have been saved as 'tiki-index.php' instead of 'tiki-index.php?page=Homepage'. // ... so we also need to check against : homepage + '?page=' + default wiki pagename // include_once 'tiki-sefurl.php'; if ($url == '' || preg_match('/(tiki-register|tiki-login_validate|tiki-login_scr)\\.php/', $url) || $prefs['limitedGoGroupHome'] == 'n' || $url == $prefs['site_tikiIndex'] || $url_path == $prefs['site_tikiIndex'] || basename($url_path) == $prefs['site_tikiIndex'] || $anonymous_homepage != '' && ($url == $anonymous_homepage || $url_path == $anonymous_homepage || basename($url_path) == $anonymous_homepage) || filter_out_sefurl($anonymous_homepage) == basename($url_path) || $tikiIndex_full != '' && basename($url_path) == $tikiIndex_full) { $groupHome = $userlib->get_user_default_homepage($user); if ($groupHome != '') { $url = preg_match('/^(\\/|https?:)/', $groupHome) ? $groupHome : filter_out_sefurl('tiki-index.php?page=' . urlencode($groupHome)); } } } // Unset session variable in case user su's unset($_SESSION['loginfrom']); // No sense in sending user to registration page or no page at all // This happens if the user has just registered and it's first login if ($url == '' || preg_match('/(tiki-register|tiki-login_validate|tiki-login_scr)\\.php/', $url)) { $url = $prefs['tikiIndex']; } // Now if the remember me feature is on and the user checked the rememberme checkbox then ... if ($prefs['rememberme'] != 'disabled' && isset($_REQUEST['rme']) && $_REQUEST['rme'] == 'on') { $userInfo = $userlib->get_user_info($user); $userId = $userInfo['userId']; $secret = $userlib->create_user_cookie($userId);
public function list_menu_options($menuId, $offset = 0, $maxRecords = -1, $sort_mode = 'position_asc', $find = '', $full = false, $level = 0, $do_not_parse = false) { global $user, $tiki_p_admin, $prefs; $wikilib = TikiLib::lib('wiki'); include_once 'tiki-sefurl.php'; $options = $this->table('tiki_menu_options'); $conditions = array('menuId' => $menuId); if ($find) { $conditions['search'] = $options->expr('(`name` like ? or `url` like ?)', array("%{$find}%", "%{$find}%")); } if ($level && $prefs['feature_userlevels'] == 'y') { $conditions['userlevel'] = $options->lesserThan($level + 1); } $menu = $this->get_menu($menuId); $sort = $options->expr($this->convertSortMode($sort_mode)); $result = $options->fetchAll($options->all(), $conditions, $maxRecords, $offset, $sort); $cant = $options->fetchCount($conditions); $ret = array(); foreach ($result as $res) { $res['canonic'] = $res['url']; $resourceGroups = array_filter(explode(',', $res['groupname'] ?: '')); if (!$do_not_parse && isset($menu['parse']) && $menu['parse'] === 'y') { $res['name'] = $wikilib->parse_data($res['name'], array('is_html' => $prefs['menus_item_names_raw'] === 'y')); } if (preg_match('|^\\(\\((.+?)\\)\\)$|', $res['url'], $matches)) { $res['url'] = 'tiki-index.php?page=' . rawurlencode($matches[1]); $res['sefurl'] = $wikilib->sefurl($matches[1]); $perms = Perms::get(array('type' => 'wiki page', 'object' => $matches[1])); if (!$perms->view && !$perms->wiki_view_ref) { continue; } } else { $res['sefurl'] = filter_out_sefurl($res['url']); } if (!$full) { $display = true; if (isset($res['section']) and $res['section']) { if (strstr($res['section'], '|')) { $display = false; $sections = preg_split('/\\s*\\|\\s*/', $res['section']); foreach ($sections as $sec) { if (!isset($prefs[$sec]) or $prefs[$sec] != 'y') { $display = true; break; } } } else { $display = true; $sections = preg_split('/\\s*,\\s*/', $res['section']); foreach ($sections as $sec) { if (!isset($prefs[$sec]) or $prefs[$sec] != 'y') { $display = false; break; } } } } if ($display && $tiki_p_admin != 'y') { if (isset($res['perm']) and $res['perm']) { if (strstr($res['perm'], '|')) { $display = false; $sections = preg_split('/\\s*\\|\\s*/', $res['perm']); foreach ($sections as $sec) { if (isset($GLOBALS[$sec]) && $GLOBALS[$sec] == 'y') { $display = true; break; } } } else { $sections = preg_split('/\\s*,\\s*/', $res['perm']); $display = true; foreach ($sections as $sec) { if (!isset($GLOBALS[$sec]) or $GLOBALS[$sec] != 'y') { $display = false; break; } } } } $userGroups = $this->get_user_groups($user); if (count($resourceGroups) > 0) { $intersect = array_intersect($resourceGroups, $userGroups); if (count($intersect) < 1) { $display = false; } } } if ($display) { $pos = $res['position']; if (empty($ret[$pos]) || empty($ret[$pos]['url'])) { $ret[$pos] = $res; } } } else { $ret[] = $res; } } return array('data' => array_values($ret), 'cant' => $cant); }
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); }
} catch (Exception $e) { switch ($e->getCode()) { case 1: $smarty->assign('page_badchars_display', $wikilib->get_badchars()); break; case 2: $smarty->assign('msg', tra("Page already exists")); break; default: throw $e; } } } if ($result) { global $perspectivelib; require_once 'lib/perspectivelib.php'; $perspectivelib->replace_preference('wsHomepage', $page, $newName); if ($prefs['feature_sefurl'] == 'y') { include_once 'tiki-sefurl.php'; header('location: ' . urlencode(filter_out_sefurl("tiki-index.php?page={$newName}", 'wiki'))); } else { header('location: tiki-index.php?page=' . urlencode($newName)); } } } ask_ticket('rename-page'); include_once 'tiki-section_options.php'; // disallow robots to index page: $smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW'); $smarty->assign('mid', 'tiki-rename_page.tpl'); $smarty->display("tiki.tpl");
/** * @param $mod_reference * @param null $params * @return bool */ function module_since_last_visit_new($mod_reference, $params = null) { global $user; $smarty = TikiLib::lib('smarty'); include_once 'tiki-sefurl.php'; if (!$user) { return false; } if (!isset($params['use_jquery_ui']) || $params['use_jquery_ui'] != 'y') { $smarty->assign('use_jquery_ui', 'n'); } else { $smarty->assign('use_jquery_ui', 'y'); } if (!isset($params['date_as_link']) || $params['date_as_link'] != 'n') { $smarty->assign('date_as_link', 'y'); } else { $smarty->assign('date_as_link', 'n'); } if (!isset($params['fold_sections']) || $params['fold_sections'] != 'y') { $smarty->assign('default_folding', 'block'); $smarty->assign('opposite_folding', 'none'); } else { $smarty->assign('default_folding', 'none'); $smarty->assign('opposite_folding', 'block'); } if (empty($params['commentlength'])) { $params['commentlength'] = 40; } $resultCount = $mod_reference['rows']; global $prefs; $userlib = TikiLib::lib('user'); $tikilib = TikiLib::lib('tiki'); $smarty->loadPlugin('smarty_modifier_username'); $ret = array(); if ($params == null) { $params = array(); } if ((empty($params['calendar_focus']) || $params['calendar_focus'] != 'ignore') && strpos($_SERVER['SCRIPT_NAME'], 'tiki-calendar.php') !== false && !empty($_REQUEST['todate'])) { $last = $_REQUEST['todate']; $_SESSION['slvn_last_login'] = $last; $smarty->assign('tpl_module_title', tra('Changes since')); } else { if (isset($_SESSION['slvn_last_login'])) { $last = $_SESSION['slvn_last_login']; $smarty->assign('tpl_module_title', tra('Changes since')); } else { $last = $tikilib->getOne('select `lastLogin` from `users_users` where `login`=?', array($user)); $smarty->assign('tpl_module_title', tra('Since your last visit...')); if (!$last || !empty($params['daysAtLeast'])) { $now = TikiLib::lib('tiki')->now; if (!$last) { $last = $now; } if (!empty($params['daysAtLeast']) && $now - $last < $params['daysAtLeast'] * 60 * 60 * 24) { $last = $now - $params['daysAtLeast'] * 60 * 60 * 24; $smarty->assign('tpl_module_title', tr('In the last %0 days...', $params['daysAtLeast'])); } } } } $ret['lastLogin'] = $last; $ret['items']['comments']['label'] = tra('new comments'); $ret['items']['comments']['cname'] = 'slvn_comments_menu'; //TODO: should be a function on commentslib.php or use one of the existent functions $query = 'select `object`,`objectType`,`title`,`commentDate`,`userName`,`threadId`, `parentId`, `approved`, `archived`, `data`' . " from `tiki_comments` where `commentDate`>? and `objectType` != 'forum' order by `commentDate` desc"; $result = $tikilib->query($query, array((int) $last), $resultCount); $count = 0; while ($res = $result->fetchRow()) { $ret['items']['comments']['list'][$count]['href'] = TikiLib::lib('comments')->getHref($res['objectType'], $res['object'], $res['threadId']); switch ($res['objectType']) { case 'article': $perm = 'tiki_p_read_article'; $ret['items']['comments']['list'][$count]['href'] = filter_out_sefurl($ret['items']['comments']['list'][$count]['href'], 'article', $res['title']); break; case 'post': $perm = 'tiki_p_read_blog'; $ret['items']['comments']['list'][$count]['href'] = filter_out_sefurl($ret['items']['comments']['list'][$count]['href'], 'blogpost', $res['title']); break; case 'blog': $perm = 'tiki_p_read_blog'; $ret['items']['comments']['list'][$count]['href'] = filter_out_sefurl($ret['items']['comments']['list'][$count]['href'], 'blog', $res['title']); break; case 'faq': $perm = 'tiki_p_view_faqs'; break; case 'file gallery': $perm = 'tiki_p_view_file_gallery'; break; case 'image gallery': $perm = 'tiki_p_view_image_gallery'; break; case 'poll': // no perm check for viewing polls, only a perm for taking them break; case 'wiki page': $perm = 'tiki_p_view'; break; default: // note trackeritme needs more complex perms checking due to status and ownership $perm = 'tiki_p_read_comments'; break; } if ($res['approved'] == 'n' || $res['archived'] == 'y') { $visible = $userlib->user_has_perm_on_object($user, $res['object'], $res['objectType'], 'tiki_p_admin_comments'); } else { if ($res['objectType'] === 'trackeritem') { $item = Tracker_Item::fromId($res['object']); $visible = $item->canView(); } else { $visible = !isset($perm) || $userlib->user_has_perm_on_object($user, $res['object'], $res['objectType'], $perm); } } if ($visible) { $ret['items']['comments']['list'][$count]['title'] = $tikilib->get_short_datetime($res['commentDate']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['userName']); $ret['items']['comments']['list'][$count]['label'] = TikiLib::lib('comments')->process_comment_title($res, $params['commentlength']); if ($res['archived'] == 'y') { $ret['items']['comments']['list'][$count]['label'] .= tra(' (archived)'); } $count++; } } $ret['items']['comments']['count'] = $count; ///////////////////////////////////////////////////////////////////////// // FORUMS if ($prefs['feature_forums'] == 'y') { $ret['items']['posts']['label'] = tra('new posts'); $ret['items']['posts']['cname'] = 'slvn_posts_menu'; $query = 'select `posts`.`object`,`posts`.`objectType`,`posts`.`title`,`posts`.`commentDate`,' . ' `posts`.`userName`,`posts`.`threadId`, `posts`.`parentId`,`topics`.`title` `topic_title`' . ' from `tiki_comments` `posts`' . ' left join `tiki_comments` `topics` ON `posts`.`parentId` = `topics`.`threadId`' . " where `posts`.`commentDate`>? and `posts`.`objectType` = 'forum'" . ' order by `posts`.`commentDate` desc'; $result = $tikilib->query($query, array((int) $last), $resultCount); $count = 0; while ($res = $result->fetchRow()) { if ($userlib->user_has_perm_on_object($user, $res['object'], $res['objectType'], 'tiki_p_forum_read')) { $ret['items']['posts']['list'][$count]['href'] = 'tiki-view_forum_thread.php?forumId=' . $res['object'] . '&comments_parentId='; if ($res['parentId']) { $ret['items']['posts']['list'][$count]['href'] .= $res['parentId'] . '#threadId' . $res['threadId']; } else { $ret['items']['posts']['list'][$count]['href'] .= $res['threadId']; } $ret['items']['posts']['list'][$count]['title'] = $tikilib->get_short_datetime($res['commentDate']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['userName']); if ($res['parentId'] == 0 || $prefs['forum_reply_notitle'] != 'y') { $ret['items']['posts']['list'][$count]['label'] = $res['title']; } else { $ret['items']['posts']['list'][$count]['label'] = $res['topic_title']; } ++$count; } } $ret['items']['posts']['count'] = $count; } ///////////////////////////////////////////////////////////////////////// // WIKI PAGES if ($prefs['feature_wiki'] == 'y') { $ret['items']['pages']['label'] = tra('wiki pages changed'); $ret['items']['pages']['cname'] = 'slvn_pages_menu'; $query = 'select `pageName`, `user`, `lastModif` from `tiki_pages` where `lastModif`>? order by `lastModif` desc'; $result = $tikilib->query($query, array((int) $last), $resultCount); $count = 0; while ($res = $result->fetchRow()) { if ($userlib->user_has_perm_on_object($user, $res['pageName'], 'wiki page', 'tiki_p_view')) { $ret['items']['pages']['list'][$count]['href'] = filter_out_sefurl('tiki-index.php?page=' . urlencode($res['pageName'])); $ret['items']['pages']['list'][$count]['title'] = $tikilib->get_short_datetime($res['lastModif']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['user']); $ret['items']['pages']['list'][$count]['label'] = $res['pageName']; $count++; } } $ret['items']['pages']['count'] = $count; } ///////////////////////////////////////////////////////////////////////// // ARTICLES if ($prefs['feature_articles'] == 'y') { $ret['items']['articles']['label'] = tra('new articles'); $ret['items']['articles']['cname'] = 'slvn_articles_menu'; if ($userlib->user_has_permission($user, 'tiki_p_edit_article')) { $query = 'select `articleId`,`title`,`publishDate`,`authorName` from `tiki_articles` where `created`>? and `expireDate`>? order by `articleId` desc'; $bindvars = array((int) $last, time()); } else { $query = 'select `articleId`,`title`,`publishDate`,`authorName` from `tiki_articles` where `publishDate`>? and `publishDate`<=? and `expireDate`>? order by `articleId` desc'; $bindvars = array((int) $last, time(), time()); } $result = $tikilib->query($query, $bindvars, $resultCount); $count = 0; while ($res = $result->fetchRow()) { if ($userlib->user_has_perm_on_object($user, $res['articleId'], 'article', 'tiki_p_read_article')) { $ret['items']['articles']['list'][$count]['href'] = filter_out_sefurl('tiki-read_article.php?articleId=' . $res['articleId'], 'article', $res['title']); $ret['items']['articles']['list'][$count]['title'] = $tikilib->get_short_datetime($res['publishDate']) . ' ' . tra('by') . ' ' . $res['authorName']; $ret['items']['articles']['list'][$count]['label'] = $res['title']; $count++; } } $ret['items']['articles']['count'] = $count; } ///////////////////////////////////////////////////////////////////////// // FAQs if ($prefs['feature_faqs'] == 'y') { $ret['items']['faqs']['label'] = tra('new FAQs'); $ret['items']['faqs']['cname'] = 'slvn_faqs_menu'; $query = 'select `faqId`, `title`, `created` from `tiki_faqs` where `created`>? order by `created` desc'; $result = $tikilib->query($query, array((int) $last), $resultCount); $count = 0; while ($res = $result->fetchRow()) { if ($userlib->user_has_perm_on_object($user, $res['faqId'], 'faq', 'tiki_p_view_faq')) { $ret['items']['faqs']['list'][$count]['href'] = 'tiki-view_faq.php?faqId=' . $res['faqId']; $ret['items']['faqs']['list'][$count]['title'] = $tikilib->get_short_datetime($res['created']); $ret['items']['faqs']['list'][$count]['label'] = $res['title']; $count++; } } $ret['items']['faqs']['count'] = $count; } ///////////////////////////////////////////////////////////////////////// // BLOGS if ($prefs['feature_blogs'] == 'y') { $ret['items']['blogs']['label'] = tra('new blogs'); $ret['items']['blogs']['cname'] = 'slvn_blogs_menu'; $query = "select `blogId`, `title`, `user`, `created` from `tiki_blogs` where `created`>? order by `created` desc"; $result = $tikilib->query($query, array((int) $last), $resultCount); $count = 0; while ($res = $result->fetchRow()) { if ($userlib->user_has_perm_on_object($user, $res['blogId'], 'blog', 'tiki_p_read_blog')) { $ret['items']['blogs']['list'][$count]['href'] = filter_out_sefurl('tiki-view_blog.php?blogId=' . $res['blogId'], 'blog', $res['title']); $ret['items']['blogs']['list'][$count]['title'] = $tikilib->get_short_datetime($res['created']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['user']); $ret['items']['blogs']['list'][$count]['label'] = $res['title']; $count++; } } $ret['items']['blogs']['count'] = $count; $ret['items']['blogPosts']['label'] = tra('new blog posts'); $ret['items']['blogPosts']['cname'] = 'slvn_blogPosts_menu'; $query = 'select `postId`, `blogId`, `title`, `user`, `created` from `tiki_blog_posts` where `created`>? order by `created` desc'; $result = $tikilib->query($query, array((int) $last), $resultCount); $count = 0; while ($res = $result->fetchRow()) { if ($userlib->user_has_perm_on_object($user, $res['blogId'], 'blog', 'tiki_p_read_blog')) { $ret['items']['blogPosts']['list'][$count]['href'] = filter_out_sefurl('tiki-view_blog_post.php?postId=' . $res['postId'], 'blogpost', $res['title']); $ret['items']['blogPosts']['list'][$count]['title'] = $tikilib->get_short_datetime($res['created']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['user']); $ret['items']['blogPosts']['list'][$count]['label'] = $res['title']; $count++; } } $ret['items']['blogPosts']['count'] = $count; } ///////////////////////////////////////////////////////////////////////// // IMAGE GALLERIES if ($prefs['feature_galleries'] == 'y') { // image galleries $ret['items']['imageGalleries']['label'] = tra('new image galleries'); $ret['items']['imageGalleries']['cname'] = 'slvn_imageGalleries_menu'; $query = "select `galleryId`,`name`,`created`,`user` from `tiki_galleries` where `created`>? order by `created` desc"; $result = $tikilib->query($query, array((int) $last), $resultCount); $count = 0; while ($res = $result->fetchRow()) { if ($userlib->user_has_perm_on_object($user, $res['galleryId'], 'image gallery', 'tiki_p_view_image_gallery')) { $ret['items']['imageGalleries']['list'][$count]['href'] = 'tiki-browse_gallery.php?galleryId=' . $res['galleryId']; $ret['items']['imageGalleries']['list'][$count]['title'] = $tikilib->get_short_datetime($res['created']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['user']); $ret['items']['imageGalleries']['list'][$count]['label'] = $res['name']; $count++; } } $ret['items']['imageGalleries']['count'] = $count; // images $ret['items']['images']['label'] = tra('new images'); $ret['items']['images']['cname'] = 'slvn_images_menu'; $query = 'select `imageId`,`galleryId`,`name`,`created`,`user` from `tiki_images` where `created`>? order by `created` desc'; $result = $tikilib->query($query, array((int) $last), $resultCount); $count = 0; while ($res = $result->fetchRow()) { if ($userlib->user_has_perm_on_object($user, $res['galleryId'], 'image gallery', 'tiki_p_view_image_gallery')) { $ret['items']['images']['list'][$count]['href'] = 'tiki-browse_image.php?galleryId=' . $res['galleryId'] . '&imageId=' . $res['imageId']; $ret['items']['images']['list'][$count]['title'] = $tikilib->get_short_datetime($res['created']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['user']); $ret['items']['images']['list'][$count]['label'] = $res['name']; $count++; } } $ret['items']['images']['count'] = $count; } ///////////////////////////////////////////////////////////////////////// // FILE GALLERIES if ($prefs['feature_file_galleries'] == 'y') { // file galleries $ret['items']['fileGalleries']['label'] = tra('new file galleries'); $ret['items']['fileGalleries']['cname'] = 'slvn_fileGalleries_menu'; $query = 'select `galleryId`,`name`,`created`,`user` from `tiki_file_galleries` where `created`>? order by `created` desc'; $result = $tikilib->query($query, array((int) $last), $resultCount); $count = 0; while ($res = $result->fetchRow()) { if ($userlib->user_has_perm_on_object($user, $res['galleryId'], 'file gallery', 'tiki_p_view_file_gallery')) { $ret['items']['fileGalleries']['list'][$count]['href'] = filter_out_sefurl('tiki-list_file_gallery.php?galleryId=' . $res['galleryId'], 'file gallery'); $ret['items']['fileGalleries']['list'][$count]['title'] = $tikilib->get_short_datetime($res['created']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['user']); $ret['items']['fileGalleries']['list'][$count]['label'] = $res['name']; $count++; } } $ret['items']['fileGalleries']['count'] = $count; // files $ret['items']['files']['label'] = tra('new files'); //get_strings tra('new files'); $ret['items']['files']['cname'] = 'slvn_files_menu'; $query = 'select `fileId`, `galleryId`,`name`,`filename`,`created`,`user` from `tiki_files` where `created`>? order by `created` desc'; $result = $tikilib->query($query, array((int) $last), $resultCount); $count = 0; while ($res = $result->fetchRow()) { if ($userlib->user_has_perm_on_object($user, $res['galleryId'], 'file gallery', 'tiki_p_view_file_gallery')) { $ret['items']['files']['list'][$count]['href'] = filter_out_sefurl('tiki-list_file_gallery.php?galleryId=' . $res['galleryId'] . '&fileId=' . $res['fileId'] . '&view=page', 'file gallery'); $ret['items']['files']['list'][$count]['title'] = $tikilib->get_short_datetime($res['created']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['user']); $ret['items']['files']['list'][$count]['label'] = $res['name'] . ' (' . $res['filename'] . ')'; $count++; } } $ret['items']['files']['count'] = $count; } ///////////////////////////////////////////////////////////////////////// // POLLS if ($prefs['feature_polls'] == 'y') { $ret['items']['polls']['label'] = tra('new polls'); $ret['items']['polls']['cname'] = 'slvn_polls_menu'; $query = 'select `pollId`, `title`, `publishDate` from `tiki_polls` where `publishDate`>? order by `publishDate` desc'; $result = $tikilib->query($query, array((int) $last), $resultCount); $count = 0; while ($res = $result->fetchRow()) { $ret['items']['polls']['list'][$count]['href'] = 'tiki-poll_results.php?pollId=' . $res['pollId']; $ret['items']['polls']['list'][$count]['title'] = $tikilib->get_short_datetime($res['publishDate']); $ret['items']['polls']['list'][$count]['label'] = $res['title']; $count++; } $ret['items']['polls']['count'] = $count; } ///////////////////////////////////////////////////////////////////////// // NEW USERS if (!isset($params['showuser']) || $params['showuser'] != 'n') { $ret['items']['users']['label'] = tra('new users'); $ret['items']['users']['cname'] = 'slvn_users_menu'; $query = 'select `login`, `registrationDate` from `users_users` where `registrationDate`>? and `provpass`=?'; $result = $tikilib->query($query, array((int) $last, ''), $resultCount); $count = 0; $slvn_tmp_href = $userlib->user_has_permission($user, 'tiki_p_admin') ? 'tiki-assignuser.php?assign_user='******'tiki-user_information.php?view_user='******'items']['users']['list'][$count]['href'] = $slvn_tmp_href . rawurlencode($res['login']); $ret['items']['users']['list'][$count]['title'] = $tikilib->get_short_datetime($res['registrationDate']); $ret['items']['users']['list'][$count]['label'] = smarty_modifier_username($res['login']); $count++; } $ret['items']['users']['count'] = $count; } ///////////////////////////////////////////////////////////////////////// // TRACKER ITEMS // This breaks out tracker updates into sub-sections, by tracker, separating new items and updated items. // NEW TRACKER ITEMS if ($prefs['feature_trackers'] == 'y' && (!isset($params['showtracker']) || $params['showtracker'] != 'n')) { $ret['items']['trackers']['label'] = tra('new tracker items'); $ret['items']['trackers']['cname'] = 'slvn_trackers_menu'; $query = 'select `itemId`, `trackerId`, `created`, `lastModif` from `tiki_tracker_items` where `created`>? order by `created` desc'; $result = $tikilib->query($query, array((int) $last), $resultCount); $count = 0; $counta = array(); $tracker_name = array(); $cachelib = TikiLib::lib('cache'); while ($res = $result->fetchRow()) { if ($userlib->user_has_perm_on_object($user, $res['trackerId'], 'tracker', 'tiki_p_view_trackers')) { // Initialize tracker counter if needed. if (!isset($counta[$res['trackerId']])) { $counta[$res['trackerId']] = 0; } // Pull Tracker Name if ($res['trackerId'] > 0 && !isset($tracker_name[$res['trackerId']])) { $query = "select `name` from `tiki_trackers` where `trackerId` = ?"; $tracker_name[$res['trackerId']] = $tikilib->getOne($query, $res['trackerId']); } $ret['items']['trackers']['tid'][$res['trackerId']]['label'] = tra('in') . ' ' . tra($tracker_name[$res['trackerId']]); $ret['items']['trackers']['tid'][$res['trackerId']]['cname'] = 'slvn_tracker' . $res['trackerId'] . '_menu'; $ret['items']['trackers']['tid'][$res['trackerId']]['list'][$counta[$res['trackerId']]]['href'] = filter_out_sefurl('tiki-view_tracker_item.php?itemId=' . $res['itemId'], 'trackeritem'); $ret['items']['trackers']['tid'][$res['trackerId']]['list'][$counta[$res['trackerId']]]['title'] = $tikilib->get_short_datetime($res['created']); // routine to verify field in tracker that's used as label $cacheKey = 'trackerItemLabel' . $res['itemId']; if (!($label = $cachelib->getCached($cacheKey))) { $query = 'select `fieldId` from `tiki_tracker_fields` where `isMain` = ? and `trackerId` = ? order by `position`'; $fieldId = $tikilib->getOne($query, array('y', $res['trackerId'])); $query = 'select `value` from `tiki_tracker_item_fields` where `fieldId` = ? and `itemId` = ?'; $label = $tikilib->getOne($query, array($fieldId, $res['itemId'])); $cachelib->cacheItem($cacheKey, $label); } // If the label is empty (b:0;), then use the item ID if ($label == 'b:0;' || $label == '') { $label = 'Trk i' . $res['trackerId'] . ' - ID: ' . $res['itemId']; } $ret['items']['trackers']['tid'][$res['trackerId']]['list'][$counta[$res['trackerId']]]['label'] = $label; $counta[$res['trackerId']]++; $ret['items']['trackers']['tid'][$res['trackerId']]['count'] = $counta[$res['trackerId']]; $count++; } } $ret['items']['trackers']['count'] = $count; ///////////////////////////////////////////////////////////////////////// // UPDATED TRACKER ITEMS - ignore updates on same day as creation $ret['items']['utrackers']['label'] = tra('updated tracker items'); $ret['items']['utrackers']['cname'] = 'slvn_utrackers_menu'; $query = 'select `itemId`, `trackerId`, `created`, `lastModif`' . ' from `tiki_tracker_items` where `lastModif`>? and `lastModif`!=`created`' . ' order by `lastModif` desc'; $result = $tikilib->query($query, array((int) $last), $resultCount); $count = 0; $countb = array(); $cachelib = TikiLib::lib('cache'); while ($res = $result->fetchRow()) { if ($userlib->user_has_perm_on_object($user, $res['trackerId'], 'tracker', 'tiki_p_view_trackers')) { // Initialize tracker counter if needed. if (!isset($countb[$res['trackerId']])) { $countb[$res['trackerId']] = 0; } // Pull Tracker Name if (!isset($tracker_name[$res['trackerId']])) { $query = 'select `name` from `tiki_trackers` where `trackerId` = ?'; $tracker_name[$res['trackerId']] = $tikilib->getOne($query, $res['trackerId']); } $ret['items']['utrackers']['tid'][$res['trackerId']]['label'] = tra('in') . ' ' . tra($tracker_name[$res['trackerId']]); $ret['items']['utrackers']['tid'][$res['trackerId']]['cname'] = 'slvn_utracker' . $res['trackerId'] . '_menu'; $ret['items']['utrackers']['tid'][$res['trackerId']]['list'][$countb[$res['trackerId']]]['href'] = filter_out_sefurl('tiki-view_tracker_item.php?itemId=' . $res['itemId'], 'trackeritem'); $ret['items']['utrackers']['tid'][$res['trackerId']]['list'][$countb[$res['trackerId']]]['title'] = $tikilib->get_short_datetime($res['lastModif']); // routine to verify field in tracker that's used as label $cacheKey = 'trackerItemLabel' . $res['itemId']; if (!($label = $cachelib->getCached($cacheKey))) { $query = 'select `fieldId` from `tiki_tracker_fields` where `isMain` = ? and `trackerId` = ? order by `position`'; $fieldId = $tikilib->getOne($query, array('y', $res['trackerId'])); $query = 'select `value` from `tiki_tracker_item_fields` where `fieldId` = ? and `itemId` = ?'; $label = $tikilib->getOne($query, array($fieldId, $res['itemId'])); $cachelib->cacheItem($cacheKey, $label); } // If the label is empty (b:0;), then use the item ID if ($label == 'b:0;' || $label == '') { $label = 'Trk i' . $res['trackerId'] . ' - ID: ' . $res['itemId']; } $ret['items']['utrackers']['tid'][$res['trackerId']]['list'][$countb[$res['trackerId']]]['label'] = $label; $countb[$res['trackerId']]++; $ret['items']['utrackers']['tid'][$res['trackerId']]['count'] = $countb[$res['trackerId']]; $count++; } } $ret['items']['utrackers']['count'] = $count; } ///////////////////////////////////////////////////////////////////////// // CALENDARS & THEIR EVENTS if ($prefs['feature_calendar'] == 'y') { $ret['items']['calendar']['label'] = tra('new calendars'); $ret['items']['calendar']['cname'] = 'slvn_calendar_menu'; $query = "select `calendarId`, `name`, `user`, `created` from `tiki_calendars` where `created`>? order by `created` desc"; $result = $tikilib->query($query, array((int) $last), $resultCount); $count = 0; while ($res = $result->fetchRow()) { if ($userlib->user_has_perm_on_object($user, $res['calendarId'], 'calendar', 'tiki_p_view_calendar')) { $ret['items']['calendar']['list'][$count]['href'] = filter_out_sefurl('tiki-calendar.php?calIds[]=' . $res['calendarId'], 'calendar', $res['name']); $ret['items']['calendar']['list'][$count]['title'] = $tikilib->get_short_datetime($res['created']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['user']); $ret['items']['calendar']['list'][$count]['label'] = $res['name']; $count++; } } $ret['items']['calendar']['count'] = $count; $ret['items']['events']['label'] = tra('new events'); $ret['items']['events']['cname'] = 'slvn_events_menu'; $query = "select `calitemId`, `calendarId`, `name`, `user`, `created`, `start` from `tiki_calendar_items` where `created`>? order by `created` desc"; $result = $tikilib->query($query, array((int) $last), $resultCount); $count = 0; while ($res = $result->fetchRow()) { if ($userlib->user_has_perm_on_object($user, $res['calendarId'], 'calendar', 'tiki_p_view_events')) { $ret['items']['events']['list'][$count]['href'] = filter_out_sefurl('tiki-calendar_edit_item.php?viewcalitemId=' . $res['calitemId'], 'event', $res['name']); $ret['items']['events']['list'][$count]['title'] = $tikilib->get_short_datetime($res['created']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['user']) . ', ' . tra('starting on') . ' ' . $tikilib->get_short_datetime($res['start']); $ret['items']['events']['list'][$count]['label'] = $res['name']; $count++; } } $ret['items']['events']['count'] = $count; } ////////////////////////////////////////////////////////////////////////// // SUMMARY //get the total of items $ret['cant'] = 0; $ret['nonempty'] = 0; foreach ($ret['items'] as $item) { $ret['cant'] += $item['count']; if ($item['count'] > 0) { $ret['nonempty']++; } } if ($ret['nonempty'] > 0) { $ret['li_width'] = min(22, (int) 90 / $ret['nonempty']); } else { $ret['li_width'] = 90; } $smarty->assign('slvn_info', $ret); }
function wikiplugin_img($data, $params, $offset, $parseOptions = '') { global $tikidomain, $prefs, $section, $smarty, $tikiroot; $imgdata = array(); $imgdata['src'] = ''; $imgdata['id'] = ''; $imgdata['fileId'] = ''; $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['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.*/ //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=;'; //////////////////////////////////////////////////Old IMAGE code for default and mandatory parameters//////////////////////////////////////////////////// // Start processing... first defaults, then given parameters, then mandatory settings. // Get parameters once in case there is a 'default' parameter. // This will be done again later so parameters can override defaults. $imgdata = array_merge($imgdata, $params); if (!empty($imgdata['default'])) { // If defaults have been specified $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 ($_REQUEST['mode'] == "mobile") { $img_condition_status = true; } break; case "module_*": if (!empty($smarty)) { $image_module_params = $smarty->get_template_vars('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->get_template_vars('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->get_template_vars('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->get_template_vars('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->get_template_vars('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 '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 '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) ) } // if( !empty($imgdata['default']) ) // merge specified parameters over default values $imgdata = array_merge($imgdata, $params); if (!empty($imgdata['mandatory'])) { // If defaults have been specified $imgdata['mandatory'] = trim($imgdata['mandatory']) . ';'; // trim whitespace and ensure at least one semicolon $img_conditions_array = explode(";", $imgdata['mandatory']); // 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 ($_REQUEST['mode'] == "mobile") { $img_condition_status = true; } break; case "module_*": if (!empty($smarty)) { $image_module_params = $smarty->get_template_vars('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->get_template_vars('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->get_template_vars('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->get_template_vars('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->get_template_vars('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 '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 '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) ) } // if( !empty($imgdata['default']) ) //////////////////////////////////////////////////////////End of old IMAGE code for default and mandatory parameters//////////////////////////////////// //////////////////////////////////////////////////// Error messages and clean javascript ///////////////////////////////////////////////// // Must set at least one image identifier if (empty($imgdata['fileId']) and empty($imgdata['id']) and empty($imgdata['src']) and empty($imgdata['attId'])) { return tra("''No image specified. Either the fileId, attId, id, or src parameter must be specified.''"); } // Can't set more than one image identifier if (!(!empty($imgdata['fileId']) xor !empty($imgdata['id']) xor !empty($imgdata['src']) xor !empty($imgdata['attId']))) { return tra("''Use one and only one of the following parameters: fileId, 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'] = ''; } include_once 'tiki-sefurl.php'; ///////////////////////////////////// If only old img parameters used, use old code and get out of program quickly /////////////////// if (!empty($imgdata['src']) && strpos($imgdata['src'], '|') == FALSE && strpos($imgdata['src'], ',') == FALSE && empty($imgdata['thumb']) && empty($imgdata['button']) && empty($imgdata['max']) && empty($imgdata['styleimage']) && empty($imgdata['stylebox']) && empty($imgdata['styledesc']) && empty($imgdata['block']) && $imgdata['desc'] != 'desc' && $imgdata['desc'] != 'idesc' && $imgdata['desc'] != 'name' && $imgdata['desc'] != 'ititle' && $imgdata['rel'] != 'box') { if ($tikidomain && !preg_match('|^https?:|', $imgdata['src'])) { $imgdata['src'] = preg_replace("~img/wiki_up/~", "img/wiki_up/{$tikidomain}/", $imgdata['src']); } // Handle absolute links (e.g. to send a newsletter with images that remains on the tiki site) $absolute_links = isset($parseOptions['absolute_links']) ? $parseOptions['absolute_links'] : false; if ($imgdata['src'] != '' && $absolute_links && !preg_match('|^[a-zA-Z]+:\\/\\/|', $imgdata['src'])) { global $base_host, $url_path; $imgdata['src'] = $base_host . ($imgdata['src'][0] == '/' ? '' : $url_path) . $imgdata['src']; } $imgdata_dim = ''; if ($prefs['feature_filegals_manager'] == 'y') { global $detected_lib; include_once 'lib/images/images.php'; } else { $detected_lib = ''; } if ($detected_lib != '' && ereg('^' . $tikiroot . 'tiki-download_file.php\\?', $imgdata['src'])) { // If an image lib has been detected and if we are using an image from a file gallery, // then also resize the image server-side, because it will generally imply less data to download from the user // (i.e. speed up the page download) and a better image quality (browser resize algorithms are quick but bad) // // Note: ctype_digit is used to ensure there is only digits in width and height strings (e.g. to avoid '50%', ...) // if ((int) $imgdata['width'] > 0 && ctype_digit($imgdata['width'])) { $imgdata['src'] .= '&x=' . $imgdata['width']; } if ((int) $imgdata['height'] > 0 && ctype_digit($imgdata['height'])) { $imgdata['src'] .= '&y=' . $imgdata['height']; } } $imgdata["src"] = filter_out_sefurl(htmlentities($imgdata["src"]), $smarty); if ($imgdata['width']) { $imgdata_dim .= ' width="' . $imgdata['width'] . '"'; } if ($imgdata['height']) { $imgdata_dim .= ' height="' . $imgdata['height'] . '"'; } $repl = '<img alt="' . $imgdata["alt"] . '" src="' . $imgdata["src"] . '" border="0" ' . $imgdata_dim; if ($imgdata['imalign']) { $repl .= ' style="float: ' . $imgdata['imalign'] . '"'; } if ($imgdata['usemap']) { $repl .= ' usemap="#' . $imgdata['usemap'] . '"'; } if ($imgdata['class']) { $repl .= ' class="' . $imgdata['class'] . '"'; } $repl .= ' />'; if ($imgdata['link']) { $imgtarget = ''; if ($prefs['popupLinks'] == 'y' && (preg_match('#^([a-z0-9]+?)://#i', $imgdata['link']) || preg_match('#^www\\.([a-z0-9\\-]+)\\.#i', $imgdata['link']))) { $imgtarget = ' target="_blank"'; } if ($imgdata['rel']) { $linkrel = ' rel="' . $imgdata['rel'] . '"'; } else { $linkrel = ''; } if ($imgdata['title']) { $linktitle = ' title="' . $imgdata['title'] . '"'; } else { $linktitle = ''; } $repl = '<a href="' . $imgdata['link'] . '"' . $linkrel . $imgtarget . $linktitle . '>' . $repl . '</a>'; } if ($imgdata['desc']) { $repl = '<table cellpadding="0" cellspacing="0"><tr><td>' . $repl . '</td></tr><tr><td class="mini">' . $imgdata['desc'] . '</td></tr></table>'; } if ($imgdata['align']) { $repl = '<div class="img" align="' . $imgdata["align"] . '">' . $repl . "</div>"; } elseif (!$imgdata['desc']) { $repl = '<span class="img">' . $repl . "</span>"; } return $repl; ///////////end of old IMG code//////////////////// } else { ////////////////////////////////////////////// Default parameter and variable settings.////////////////////////////////////////////// // Set styling defaults $thumbdef = 84; //Thumbnail height max when none is set if (!empty($imgdata['fileId'])) { $thumbdef = 120; // filegals thumbnails size is hard-coded in lib/images/abstract.php } $descdef = 'font-size:12px; line-height:1.5em;'; //default text style for description $descheightdef = 'height:15px;'; //To set room for enlarge button under image if there is no description $borderdef = 'border:1px solid darkgray;'; //default border when styleimage set to border $borderboxdef = 'border:1px solid darkgray; padding:5px; background-color: #f9f9f9;'; //default border when stylebox set to border or y $center = 'display:block; margin-left:auto; margin-right:auto;'; //used to center image and box $enlargedef = 'float:right; padding-top:.1cm;'; //styling for the enlarge button div $captiondef = 'padding-top:2px;'; //styling for the caption div //Variable for identifying if javascript mouseover is set if ($imgdata['thumb'] == 'mouseover' || $imgdata['thumb'] == 'mousesticky') { $javaset = 'true'; } else { $javaset = ''; } if (!isset($data) or !$data) { $data = ' '; } //Set variables for the base path for images in file galleries, image galleries and attachments $imagegalpath = 'show_image.php?id='; $filegalpath = 'tiki-download_file.php?fileId='; $attachpath = 'tiki-download_wiki_attachment.php?attId='; $repl = ''; /////////////////////////////////////////////// Label images and set id variable based on location//////////////////////////// // Set id's if user set path in src instead of id for images in file galleries, image galleries and attachments //This is so we can get db info if (strlen(strstr($imgdata['src'], $imagegalpath)) > 0) { //if the src parameter contains an image gallery path $imgdata['id'] = substr(strstr($imgdata['src'], $imagegalpath), strlen($imagegalpath)); //then isolate id number and put it into $imgdata['id'] } elseif (strlen(strstr($imgdata['src'], $filegalpath)) > 0) { //if file gallery path $imgdata['fileId'] = substr(strstr($imgdata['src'], $filegalpath), strlen($filegalpath)); //then put fileId into $imgdata['fileId'] } elseif (strlen(strstr($imgdata['src'], $attachpath)) > 0) { //if attachment path $imgdata['attId'] = substr(strstr($imgdata['src'], $attachpath), strlen($attachpath)); //then put attId into $imgdata['attId'] } //Identify location of source image and id for use later $sourcetype = ''; $id = ''; if (!empty($imgdata['id'])) { $sourcetype = 'imagegal'; $id = 'id'; } elseif (!empty($imgdata['fileId'])) { $sourcetype = 'filegal'; $id = 'fileId'; } elseif (!empty($imgdata['attId'])) { $sourcetype = 'attach'; $id = 'attId'; } else { $sourcetype = 'url'; $id = 'src'; } //////////////////////////////////////// Process lists of images //////////////////////////////////////////////////////// //Process "|" or "," separated images $separator = ''; if (!empty($imgdata[$id]) && (strpos($imgdata[$id], '|') !== FALSE || strpos($imgdata[$id], ',') !== FALSE)) { if (strpos($imgdata[$id], '|') !== FALSE) { $separator = '|'; } elseif (strpos($imgdata[$id], ',') !== FALSE) { $separator = ','; } $repl = ''; $id_list = array(); $id_list = explode($separator, $imgdata[$id]); $params[$id] = ''; foreach ($id_list as $i => $value) { $params[$id] = trim($value); $repl .= wikiplugin_img($data, $params, $offset, $parseOptions); } $repl = "\n\r" . '<br style="clear:both" />' . "\r" . $repl . "\n\r" . '<br style="clear:both" />' . "\r"; return $repl; // return the multiple images } //////////////////////////////////////////////////// Set image src /////////////////////////////////////////////////////////// // Clean up src URLs to exclude javascript if (stristr(str_replace(' ', '', $imgdata['src']), 'javascript:')) { $imgdata['src'] = ''; } if (strstr($imgdata['src'], 'javascript:')) { $imgdata['src'] = ''; } //Deal with images in tiki databases (file and image galleries and attachments) if (!empty($sourcetype)) { //Try to get image from database switch ($sourcetype) { case 'imagegal': global $imagegallib; include_once 'lib/imagegals/imagegallib.php'; $dbinfo = $imagegallib->get_image_info($imgdata['id'], 'o'); $basepath = $prefs['gal_use_dir']; break; case 'filegal': global $filegallib; include_once 'lib/filegals/filegallib.php'; $dbinfo = $filegallib->get_file($imgdata['fileId']); $basepath = $prefs['fgal_use_dir']; break; case 'attach': global $atts; global $wikilib; include_once 'lib/wiki/wikilib.php'; $dbinfo = $wikilib->get_item_attachment($imgdata['attId']); $basepath = $prefs['w_use_dir']; break; } //Give error messages if it doesn't exist or isn't an image if (empty($imgdata['src'])) { if (!$dbinfo) { return '^' . tra('File not found.') . '^'; } elseif (substr($dbinfo['filetype'], 0, 5) != 'image') { return '^' . tra('File is not an image.') . '^'; } else { require_once 'lib/images/images.php'; if (!class_exists('Image')) { return '^' . tra('Server does not support image manipulation.') . '^'; } } } //Now that we know it exists, finish getting info for image gallery files since the path and blob are in two different tables if ($sourcetype == 'imagegal') { global $imagegallib; include_once 'lib/imagegals/imagegallib.php'; $dbinfo2 = $imagegallib->get_image($imgdata['id'], 'o'); $dbinfo = array_merge($dbinfo, $dbinfo2); } //Set other variables from db info if (!empty($dbinfo['comment'])) { //attachment database uses comment instead of description or name $desc = $dbinfo['comment']; $imgname = $dbinfo['comment']; } else { $desc = $dbinfo['description']; $imgname = $dbinfo['name']; } } //finished getting info from db for images in image or file galleries or attachments //Set src (for html) and base path (for getimagesize) $absolute_links = !empty($parseOptions['absolute_links']) ? $parseOptions['absolute_links'] : false; $thumbstring = ''; if (empty($imgdata['src'])) { switch ($sourcetype) { case 'imagegal': $imgdata['src'] = $imagegalpath . $imgdata['id']; if (!empty($imgdata['thumb'])) { $thumbstring = '&thumb=1'; } break; case 'filegal': $imgdata['src'] = $filegalpath . $imgdata['fileId']; if (!empty($imgdata['thumb'])) { $thumbstring = '&thumbnail'; } break; case 'attach': $imgdata['src'] = $attachpath . $imgdata['attId']; if (!empty($imgdata['thumb'])) { } break; } } elseif (!empty($imgdata['src']) && $absolute_links && !preg_match('|^[a-zA-Z]+:\\/\\/|', $imgdata['src'])) { global $base_host, $url_path; $imgdata['src'] = $base_host . ($imgdata['src'][0] == '/' ? '' : $url_path) . $imgdata['src']; } elseif (!empty($imgdata['src']) && $tikidomain && !preg_match('|^https?:|', $imgdata['src'])) { $imgdata['src'] = preg_replace("~img/wiki_up/~", "img/wiki_up/{$tikidomain}/", $imgdata['src']); } elseif (!empty($imgdata['src'])) { $imgdata['src'] = $imgdata['src']; } //Now get height, width, iptc data from actual image //First get the data. Images in db handled differently than those in directories or path global $imagesize, $iptc, $otherinfo; $otherinfo = array(); if (!empty($dbinfo['data'])) { getimagesize_raw($dbinfo['data']); //images in databases, calls function in this program } else { if (!empty($dbinfo['path'])) { $imagesize = getimagesize($basepath . $dbinfo['path'], $otherinfo); //images in tiki directories } else { $imagesize = getimagesize($imgdata['src'], $otherinfo); //wiki_up and external images } if (isset($otherinfo['APP13'])) { $iptc = iptcparse($otherinfo['APP13']); } } //Set variables for height, width and iptc data from image data $fwidth = $imagesize[0]; $fheight = $imagesize[1]; $idesc = isset($iptc['2#120'][0]) ? trim($iptc['2#120'][0]) : ''; //description from image iptc $ititle = isset($iptc['2#005'][0]) ? trim($iptc['2#005'][0]) : ''; //title from image iptc // URL of original full size image $pos = strpos($imgdata['src'], '&thumb'); if ($pos > 0) { //Strip off any thumbnail parameter $len = strlen($imgdata['src']); $browse_full_image = substr_replace($imgdata['src'], '', $pos, $len - ($len - $pos)); } else { $browse_full_image = $imgdata['src']; } /////////////////////////////////////Add image dimensions to src string//////////////////////////////////////////////////////////////// // Adjust for max setting, keeping aspect ratio if (!empty($imgdata['max']) && ctype_digit($imgdata['max'])) { if ($fwidth > $imgdata['max'] || $fheight > $imgdata['max']) { if ($fwidth > $fheight) { $width = $imgdata['max']; $height = floor($width * $fheight / $fwidth); } else { $height = $imgdata['max']; $width = floor($height * $fwidth / $fheight); } } else { //cases where max is set but image is smaller than max $height = $fheight; $width = $fwidth; } // Adjust for user settings for height and width if max isn't set. } elseif (!empty($imgdata['height']) && ctype_digit($imgdata['height'])) { $height = $imgdata['height']; if (empty($imgdata['width'])) { $width = floor($height * $fwidth / $fheight); } else { $width = $imgdata['width']; } } elseif (!empty($imgdata['width']) && ctype_digit($imgdata['width'])) { $width = $imgdata['width']; if (empty($imgdata['height'])) { $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'])) { 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 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 $imgdata["src"] = filter_out_sefurl(htmlentities($imgdata["src"] . $thumbstring), $smarty); $replimg = "\r\t" . '<img src="' . $imgdata['src'] . '"'; $replimg .= $imgdata_dim; //Create style attribute allowing for shortcut inputs //First set alignment string $imalign = ''; $border = ''; $style = ''; if (!empty($imgdata['imalign'])) { if ($imgdata['imalign'] == 'center') { $imalign = $center; } else { $imalign = 'float:' . $imgdata['imalign'] . ';'; } } //set entire style string if (!empty($imgdata['styleimage']) || !empty($imalign)) { if (!empty($imgdata['styleimage'])) { if (!empty($imalign)) { if (strpos(trim($imgdata['styleimage'], ' '), 'float:') > 0 || strpos(trim($imgdata['styleimage'], ' '), 'display:') > 0) { $imalign = ''; //override imalign setting is 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'] . '"'; } //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'])) { switch ($imgdata['desc']) { case 'desc': $desconly = $desc; break; case 'idesc': $desconly = $idesc; break; case 'name': $desconly = $imgname; break; case 'ititle': $desconly = $ititle; break; default: $desconly = $imgdata['desc']; } } //now set title if (!empty($imgdata['title']) || !empty($desconly)) { $imgtitle = ' title="'; if (!empty($imgdata['title'])) { $titleonly = $imgdata['title']; } else { //use desc setting for title if title is empty $titleonly = $desconly; } $imgtitle .= $titleonly . '"'; $replimg .= $imgtitle; } $replimg .= ' />'; ////////////////////////////////////////// Create the HTML link //////////////////////////////////////////////////////////////////////// // Set link to user setting or to image itself if thumb is set if (!empty($imgdata['link']) || !empty($imgdata['thumb'])) { $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; } require_once $smarty->_get_plugin_filepath('function', 'popup'); $mouseover = ' ' . smarty_function_popup($popup_params, $smarty); } else { if ($sourcetype == 'filegal' && $imgdata['thumb'] != 'download') { $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 if (!empty($imgdata['rel'])) { if ($imgdata['rel'] == 'box') { $linkrel = ' rel="box'; if (!empty($fwidth) && !empty($fheight)) { $linkrel .= ";width={$fwidth};height={$fheight}"; } /*if (!empty($desconly)) { $linkrel .= ";title=$desconly"; }*/ $linkrel .= '"'; } else { $linkrel = ' rel="' . $imgdata['rel'] . '"'; } } else { $linkrel = ''; } // title if (!empty($imgtitle)) { $linktitle = $imgtitle; } else { $linktitle = ''; } $link = filter_out_sefurl(htmlentities($link), $smarty); //Final link string $replimg = '<a href="' . $link . '" class="internal"' . $linkrel . $imgtarget . $linktitle . $mouseover . '>' . $replimg . '</a>'; } //Add link string to rest of string $repl .= $replimg; ///////////////////////////////// Create enlarge button, 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'])) { $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" style="' . $captiondef . '" >'; //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 ($sourcetype == 'filegal' && $imgdata['button'] != 'download') { $link_button = $browse_full_image . '&display'; } else { $link_button = $browse_full_image; } } } else { $link_button = $link; } //Set button rel if (empty($linkrel) || !empty($javaset)) { $linkrel_button = ''; } else { $linkrel_button = $linkrel; } //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="' . $enlargedef . '">'; $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 src="./img/magnifying-glass-micro-icon.png" width="10" height="10" alt="Enlarge" /></a>' . "\r\t\t\t</div>"; } //Add description based on user setting (use $desconly from above) and close divs $repl .= $desconly; $repl .= "\r\t\t</div>"; $repl .= "\r\t</div>"; } ///////////////////////////////Wrap in overall div that includes image if stylebox or button is set///////////////////////////////////// //Need a box if either button, desc or stylebox is set if (!empty($imgdata['button']) || !empty($imgdata['desc']) || !empty($imgdata['stylebox']) || !empty($imgdata['align'])) { //Make the div surrounding the image 2 pixels bigger than the image $boxwidth = $width + 2; $boxheight = $height + 2; $alignbox = ''; if (!empty($imgdata['align'])) { if ($imgdata['align'] == 'center') { $alignbox = $center; } else { $alignbox = 'float:' . $imgdata['align'] . ';'; } } //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') { $borderbox = $borderboxdef; if (!empty($alignbox)) { if (strpos(trim($imgdata['stylebox'], ' '), 'float:') > 0 || strpos(trim($imgdata['stylebox'], ' '), 'display:') > 0) { $alignbox = ''; //override imalign setting is style image contains alignment syntax } } } else { $styleboxinit = $imgdata['stylebox']; } } if (empty($imgdata['button']) && empty($imgdata['desc']) && empty($styleboxinit)) { $styleboxplus = $alignbox . $borderbox . ' width:' . $boxwidth . 'px; height:' . $boxheight . 'px'; } elseif (!empty($styleboxinit)) { $styleboxplus = $styleboxinit; } else { $styleboxplus = $alignbox . $borderbox . $descdef . ' width:' . $boxwidth . 'px'; } } elseif (!empty($imgdata['button']) || !empty($imgdata['desc'])) { $styleboxplus = $descdef . ' width:' . $boxwidth . 'px;'; } } if (!empty($styleboxplus)) { $repl = "\r" . '<div class="img" 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=' . $imgdata['src'] . "\"}\n<p>" . $imgdata['desc'] . '</p>'; } return '~np~' . $repl . '~/np~'; } }
function smarty_modifier_sefurl($source, $type = 'wiki', $with_next = '', $all_langs = '', $with_title = 'y', $title = '') { global $prefs; $wikilib = TikiLib::lib('wiki'); $tikilib = TikiLib::lib('tiki'); $smarty = TikiLib::lib('smarty'); $sefurl = $prefs['feature_sefurl'] == 'y'; switch ($type) { case 'wiki page': case 'wikipage': $type = 'wiki'; break; case 'blog post': $type = 'blogpost'; break; } switch ($type) { case 'wiki': return TikiLib::tikiUrlOpt($wikilib->sefurl($source, $with_next, $all_langs)); case 'blog': $href = $sefurl ? "blog{$source}" : "tiki-view_blog.php?blogId={$source}"; break; case 'blogpost': $href = $sefurl ? "blogpost{$source}" : "tiki-view_blog_post.php?postId={$source}"; break; case 'calendar': $href = $sefurl ? "cal{$source}" : "tiki-calendar.php?calIds[]={$source}"; break; case 'gallery': $href = 'tiki-browse_gallery.php?galleryId=' . $source; break; case 'article': $href = $sefurl ? "article{$source}" : "tiki-read_article.php?articleId={$source}"; break; case 'topic': $href = "tiki-view_articles.php?topic={$source}"; break; case 'file': case 'thumbnail': case 'display': case 'preview': $attributelib = TikiLib::lib('attribute'); $attributes = $attributelib->get_attributes('file', $source); if ($type == 'file') { $prefix = 'dl'; $suffix = null; } else { $prefix = $type; $suffix = '&' . $type; } if (isset($attributes['tiki.content.url'])) { $href = $attributes['tiki.content.url']; } else { $href = $sefurl ? "{$prefix}{$source}" : "tiki-download_file.php?fileId={$source}{$suffix}"; } break; case 'draft': $href = 'tiki-download_file.php?fileId=' . $source . '&draft'; break; case 'tracker item': $type = 'trackeritem'; case 'trackeritem': $replacementpage = ''; if ($prefs["feature_sefurl_tracker_prefixalias"] == 'y') { $trklib = TikiLib::lib('trk'); $replacementpage = $trklib->get_trackeritem_pagealias($source); } if ($replacementpage) { return TikiLib::tikiUrlOpt($wikilib->sefurl($replacementpage, $with_next, $all_langs)); } else { $href = 'tiki-view_tracker_item.php?itemId=' . $source; } break; case 'tracker': if ($source) { $href = 'tiki-view_tracker.php?trackerId=' . $source; } else { $href = 'tiki-list_trackers.php'; } break; case 'filegallery': case 'file gallery': $href = 'tiki-list_file_gallery.php?galleryId=' . $source; break; case 'forum': $href = $sefurl ? "forum{$source}" : 'tiki-view_forum.php?forumId=' . $source; break; case 'forumthread': case 'forum post': // used in unified search getSupportedTypes() $href = $sefurl ? "forumthread{$source}" : 'tiki-view_forum_thread.php?comments_parentId=' . $source; break; case 'image': $href = 'tiki-browse_image.php?imageId=' . $source; break; case 'sheet': $href = $sefurl ? "sheet{$source}" : "tiki-view_sheets.php?sheetId={$source}"; break; case 'category': $href = $sefurl ? "cat{$source}" : "tiki-browse_categories.php?parentId={$source}"; break; case 'freetag': $href = "tiki-browse_freetags.php?tag=" . urlencode($source); break; case 'newsletter': $href = "tiki-newsletters.php?nlId=" . urlencode($source); break; case 'survey': $href = "tiki-take_survey.php?surveyId=" . urlencode($source); break; default: $href = $source; break; } if ($with_next && ($with_title != 'y' || $prefs['feature_sefurl'] !== 'y')) { $href .= '&'; } if ($prefs['feature_sefurl'] == 'y' && $smarty) { include_once 'tiki-sefurl.php'; return TikiLib::tikiUrlOpt(filter_out_sefurl($href, $type, $title, $with_next, $with_title)); } else { return TikiLib::tikiUrlOpt($href); } }
$errmsg = tra('You do not have permission to view this section'); require_once 'tiki-rss_error.php'; } $feed = 'blog'; $id = 'blogId'; $uniqueid = "{$feed}.{$id}=" . $_REQUEST["{$id}"]; $output = $rsslib->get_from_cache($uniqueid); if ($output['data'] == 'EMPTY') { $tmp = $bloglib->get_blog($_REQUEST["{$id}"]); $title = $prefs['feed_' . $feed . '_title']; $title .= $tmp['title']; $desc = $prefs['feed_' . $feed . '_desc']; $desc .= $tmp['description']; $dateId = 'created'; $authorId = 'user'; $titleId = 'title'; $readrepl = 'tiki-view_blog_post.php?postId=%s'; $changes = $bloglib->list_blog_posts($_REQUEST["{$id}"], false, 0, $prefs['feed_blog_max'], $dateId . '_desc', '', '', $tikilib->now); $tmp = array(); include_once 'tiki-sefurl.php'; foreach ($changes['data'] as $data) { $data['data'] = $tikilib->parse_data($data['data'], array('print' => true, 'is_html' => $data['wysiwyg'] === 'y' && $prefs['wysiwyg_htmltowiki'] !== 'y')); $data['sefurl'] = filter_out_sefurl(sprintf($readrepl, $data['postId']), 'blogpost', urlencode($data['title'])); $tmp[] = $data; } $changes['data'] = $tmp; $tmp = null; $output = $rsslib->generate_feed($feed, $uniqueid, '', $changes, $readrepl, 'blogId', '', $title, $titleId, $desc, 'data', $dateId, $authorId, false); } header('Content-type: ' . $output['content-type']); print $output['data'];
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'); $url = filter_out_sefurl("tiki-view_blog_post.php?postId=$postId", 'blogpost'); header("location: $url"); die; } 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;
$tikilib->get_perm_object($_REQUEST['galleryId'], 'file gallery', $gal_info); if ($userlib->object_has_one_permission($_REQUEST['galleryId'], 'file gallery')) { $smarty->assign('individual', 'y'); } $podCastGallery = $filegallib->isPodCastGallery($_REQUEST['galleryId'], $gal_info); } else { $smarty->assign('msg', tra('Non-existent gallery')); $smarty->display('error.tpl'); die; } $gal_info['usedSize'] = $filegallib->getUsedSize($_REQUEST['galleryId']); $gal_info['maxQuota'] = $filegallib->getQuota($gal_info['parentId']); $gal_info['minQuota'] = $filegallib->getMaxQuotaDescendants($_REQUEST['galleryId']); if ($_REQUEST['galleryId'] == $prefs['fgal_root_user_id'] && $tiki_p_admin_file_galleries !== 'y') { include_once 'tiki-sefurl.php'; header('Location: ' . filter_out_sefurl('tiki-list_file_gallery.php?galleryId=' . $filegallib->get_user_file_gallery())); } } $galleryId = $_REQUEST['galleryId']; if (($galleryId != 0 || $tiki_p_list_file_galleries != 'y') && ($galleryId == 0 || $tiki_p_view_file_gallery != 'y')) { $smarty->assign('errortype', 401); $smarty->assign('msg', tra('You do not have permission to view this section')); $smarty->display('error.tpl'); die; } if ($prefs['feature_use_fgal_for_user_files'] === 'y' && $gal_info['type'] === 'user' && $gal_info['visible'] !== 'y' && $gal_info['user'] !== $user && $tiki_p_admin_file_galleries !== 'y') { $smarty->assign('errortype', 401); $smarty->assign('msg', tra('You do not have permission to view this gallery')); $smarty->display('error.tpl'); die; }
if (!isset($tracker_info["writerGroupCanModify"]) or (isset($gtid) and ($_REQUEST['trackerId'] != $gtid['groupTrackerId']))) { $tracker_info["writerGroupCanModify"] = 'n'; } $tikilib->get_perm_object($_REQUEST['trackerId'], 'tracker', $tracker_info); if (! $itemObject->canView()) { $smarty->assign('errortype', 401); $smarty->assign('msg', tra("Permission denied")); $smarty->display("error.tpl"); die; } if (!empty($_REQUEST['moveto']) && $tiki_p_admin_trackers == 'y') { // mo to another tracker fields with same name $perms = Perms::get('tracker', $_REQUEST['moveto']); if ($perms->create_tracker_items) { $trklib->move_item($_REQUEST['trackerId'], $_REQUEST['itemId'], $_REQUEST['moveto']); header('Location: '.filter_out_sefurl('tiki-view_tracker_item.php?itemId=' . $_REQUEST['itemId'])); exit; } else { $smarty->assign('errortype', 401); $smarty->assign('msg', tra("Permission denied")); $smarty->display("error.tpl"); die; } } if (isset($_REQUEST["removeattach"])) { check_ticket('view-trackers-items'); $owner = $trklib->get_item_attachment_owner($_REQUEST["removeattach"]); if (($user && ($owner == $user)) || ($tiki_p_admin_trackers == 'y')) { $access->check_authenticity(tra('Are you sure you want to remove this attachment?')); $trklib->remove_item_attachment($_REQUEST["removeattach"]); }
function smarty_function_query($params, $smarty) { global $auto_query_args, $prefs; static $request = NULL; // Modify explicit params to be prefixed if they need to (used in a plugin, module, ...) if (!empty($smarty->url_overriding_prefix)) { foreach ($smarty->url_overriding_prefix[1] as $v) { if (isset($params[$v])) { $params[$smarty->url_overriding_prefix[0] . $v] = $params[$v]; unset($params[$v]); } } } if (isset($params['_noauto']) && $params['_noauto'] == 'y') { $query = array(); foreach ($params as $param_name => $param_value) { if ($param_name[0] == '_' || $param_value == 'NULL' || $param_value == NULL) { continue; } $query[$param_name] = $param_value; } // Even if _noauto is set, 'filegals_manager' is a special param that has to be kept all the time if (!isset($params['filegals_manager']) && isset($_REQUEST['filegals_manager'])) { $query['filegals_manager'] = $_REQUEST['filegals_manager']; } // Even if _noauto is set, 'insertion_syntax' is a special param that has to be kept all the time if (!isset($params['insertion_syntax']) && isset($_REQUEST['insertion_syntax'])) { $query['insertion_syntax'] = $_REQUEST['insertion_syntax']; } } else { // Not using _REQUEST here, because it is sometimes directly modified in scripts if ($request === NULL) { if (!empty($_GET) && !empty($_POST)) { $request = array_merge($_GET, $_POST); } else { if (!empty($_GET)) { $request = $_GET; } else { if (!empty($_POST)) { $request = $_POST; } else { $request = array(); } } } } $query = $request; if (is_array($params)) { foreach ($params as $param_name => $param_value) { // Arguments starting with an underscore are special and must not be included in URL if ($param_name[0] == '_') { continue; } if ($param_name == 'page') { $list = array($param_value); } else { $list = explode(",", $param_value); } if (isset($_REQUEST[$param_name]) and in_array($_REQUEST[$param_name], $list)) { $query[$param_name] = $list[(array_search($_REQUEST[$param_name], $list) + 1) % count($list)]; if ($query[$param_name] === NULL or $query[$param_name] == 'NULL') { unset($query[$param_name]); } } elseif (isset($query[$param_name]) and in_array($query[$param_name], $list)) { $query[$param_name] = $list[(array_search($query[$param_name], $list) + 1) % count($list)]; if ($query[$param_name] === NULL or $query[$param_name] == 'NULL') { unset($query[$param_name]); } } else { if ($list[0] !== NULL and $list[0] != 'NULL') { $query[$param_name] = $list[0]; } else { unset($query[$param_name]); } } } } } if (is_array($query)) { // Only keep params explicitely specified when calling this function or specified in the $auto_query_args global var // This is to avoid including unwanted params (like actions : remove, save...) if ((!isset($params['_keepall']) || $params['_keepall'] != 'y') && is_array($auto_query_args)) { foreach ($query as $k => $v) { if (!in_array($k, $auto_query_args) && !(is_array($params) && array_key_exists($k, $params))) { unset($query[$k]); } } } $ret = ''; if (isset($params['_type']) && $params['_type'] == 'form_input') { foreach ($query as $k => $v) { $rtag = '<input type="hidden"'; $rname = htmlspecialchars($k, ENT_QUOTES, 'UTF-8'); if (is_array($v)) { foreach ($v as $vk => $vv) { $vrname = $rname . '[' . htmlspecialchars($vk, ENT_QUOTES, 'UTF-8') . ']'; $ret .= $rtag . ' name="' . $vrname . '" value="' . htmlspecialchars($vv, ENT_QUOTES, 'UTF-8') . '" />' . "\n"; } } else { $ret .= $rtag . ' name="' . $rname . '" value="' . htmlspecialchars($v, ENT_QUOTES, 'UTF-8') . '" />' . "\n"; } } } else { if (isset($params['controller'], $params['action']) && $prefs['feature_sefurl'] == 'y') { unset($query['controller'], $query['action']); } if (!isset($params['_urlencode'])) { $params['_urlencode'] = 'y'; } $sep = $params['_urlencode'] == 'n' ? '&' : '&'; $ret = http_build_query($query, '', $sep); } } if (is_array($params) && isset($params['_type'])) { global $base_host; // Check for anchor used as script if (!empty($params['_script']) && $params['_script'][0] == '#') { if (empty($params['_anchor'])) { $params['_anchor'] = substr($params['_script'], 1); } if (empty($params['_anchor'])) { $params['_type'] = 'anchor'; } unset($params['_script']); } // If specified, use _script argument to determine the php script to link to // ... else, use PHP_SELF server var if (isset($params['_script']) && $params['_script'] != '') { $php_self = $params['_script']; // If _script does not already specifies the directory and if there is one in PHP_SELF server var, use it if ($php_self != 'javascript:void(0)' && strpos($php_self, '/') === false && $_SERVER['PHP_SELF'][0] == '/' && stripos($params['_script'], 'mailto:') !== 0) { $php_self = str_replace('\\', '/', dirname($_SERVER['PHP_SELF'])) . '/' . $php_self; } } elseif (empty($params['_anchor']) || !empty($ret)) { // Use current script explicitely, except if there is only an anchor (i.e. no script and no URL argument) which is enough // This also implies that if no anchor, every current URL params will be loosed // if (isset($params['controller'], $params['action'])) { $smarty->loadPlugin('smarty_function_service'); $php_self = smarty_function_service(array('controller' => $params['controller'], 'action' => $params['action']), $smarty); } else { $php_self = htmlspecialchars($_SERVER['PHP_SELF']); } } else { // If we just have an anchor, return only this anchor, usual types other than 'anchor' are irrelevant $params['_type'] = 'anchor'; } if (isset($php_self) && basename($php_self) === 'route.php') { global $inclusion; $php_self = str_replace('route.php', $inclusion, $php_self); } switch ($params['_type']) { case 'absolute_uri': $ret = $base_host . $php_self . ($ret == '' ? '' : '?' . $ret); break; case 'absolute_path': $ret = $php_self . ($ret == '' ? '' : '?' . $ret); break; case 'relative': $ret = basename($php_self) . ($ret == '' ? '' : '?' . $ret); break; case 'form_input': case 'arguments': case 'anchor': /* default */ } } if (isset($params['_anchor'])) { $ret .= '#' . $params['_anchor']; } if ($prefs['feature_sefurl'] == 'y') { include_once 'tiki-sefurl.php'; $ret = filter_out_sefurl($ret); } return $ret; }
$title = $prefs['feed_articles_title']; $desc = $prefs['feed_articles_desc']; $id = "articleId"; $titleId = "title"; $descId = "heading"; $dateId = "publishDate"; $authorId = "author"; $readrepl = "tiki-read_article.php?{$id}=%s"; $tmp = $prefs['feed__' . $feed . '_title']; if ($tmp != '') { $title = $tmp; } $tmp = $prefs['feed_' . $feed . '_desc']; if ($desc != '') { $desc = $tmp; } $changes = $artlib->list_articles(0, $prefs['feed_articles_max'], $dateId . '_desc', '', 0, $tikilib->now, $user, $type, $topic, 'y', '', $categId, '', '', $articleLang, '', '', false, 'y'); $tmp = array(); include_once 'tiki-sefurl.php'; foreach ($changes["data"] as $data) { $data["{$descId}"] = $tikilib->parse_data($data[$descId], array('print' => true)); $data["body"] = null; $data['sefurl'] = filter_out_sefurl(sprintf($readrepl, $data['articleId']), 'article', $data['title']); $tmp[] = $data; } $changes["data"] = $tmp; $tmp = null; $output = $rsslib->generate_feed($feed, $uniqueid, '', $changes, $readrepl, '', $id, $title, $titleId, $desc, $descId, $dateId, $authorId); } header("Content-type: " . $output["content-type"]); print $output["data"];
/** * @param $mod_reference * @param $module_params */ function module_categories($mod_reference, &$module_params) { global $prefs; global $user; $smarty = TikiLib::lib('smarty'); $categlib = TikiLib::lib('categ'); if (isset($module_params['type'])) { $type = $module_params['type']; $urlEnd = '&type=' . urlencode($type); } else { $type = ''; $urlEnd = ''; } if (isset($module_params['deep'])) { $deep = $module_params['deep']; } else { $deep = 'on'; } if ($deep === 'on') { $urlEnd .= "&deep={$deep}"; } $name = ""; if (isset($module_params['categId'])) { $categId = $module_params['categId']; $categories = $categlib->getCategories(array('identifier' => $categId, 'type' => 'descendants')); foreach ($categories as $cat) { if ($cat['categId'] == $categId) { $name = $cat['name']; } } } else { $categories = $categlib->getCategories(); $categId = 0; } if (empty($categories)) { $smarty->clearAssign('tree'); return; } if (isset($module_params['categParentIds'])) { $categParentIds = explode(',', $module_params['categParentIds']); $filtered_categories = array(); foreach ($categParentIds as $c) { foreach ($categories as $cat) { if ($cat['categId'] == $c || $cat['parentId'] == $c) { $filtered_categories[] = $cat; } } } $categories = $filtered_categories; unset($filtered_categories); } include_once 'lib/tree/BrowseTreeMaker.php'; $tree_nodes = array(); include_once 'tiki-sefurl.php'; foreach ($categories as $cat) { if (!empty($module_params['hideEmpty']) && $module_params['hideEmpty'] === 'y' && $cat['objects'] == 0) { $has_children = false; foreach ($cat['children'] as $child) { if (!empty($categories[$child]['objects'])) { $has_children = true; break; } } if (!$has_children) { continue; } } if (isset($module_params['selflink']) && $module_params['selflink'] == 'y') { $url = filter_out_sefurl('tiki-index.php?page=' . urlencode($cat['name'])); } else { $url = filter_out_sefurl('tiki-browse_categories.php?parentId=' . $cat['categId'], 'category', $cat['name'], !empty($urlEnd)) . $urlEnd; } $tree_nodes[] = array("id" => $cat["categId"], "parent" => $cat["parentId"], 'parentId' => $cat['parentId'], 'categId' => $cat['categId'], "data" => '<span style="float: left; cursor: pointer; visibility: hidden;" class="ui-icon ui-icon-triangle-1-e"></span><a class="catname" href="' . $url . '">' . htmlspecialchars($cat['name']) . '</a><br />'); } $res = ''; $tm = new BrowseTreeMaker('mod_categ' . $mod_reference['position'] . $mod_reference['ord']); foreach ($categlib->findRoots($tree_nodes) as $node) { $res .= $tm->make_tree($node, $tree_nodes); } $smarty->assign('tree', $res); }
/** * @param array $result object list * @param int $cant size of list * @param int $offset start of list * @param int $maxRecords size of page - NB: -1 will check perms etc on every object and can be very slow * @return array */ private function filter_object_list($result, $cant, $offset, $maxRecords) { global $user, $prefs; $permMap = TikiLib::lib('object')->map_object_type_to_permission(); $groupList = $this->get_user_groups($user); // Filter based on permissions $contextMap = array('type' => 'type', 'object' => 'itemId'); $contextMapMap = array_fill_keys(array_keys($permMap), $contextMap); if ($maxRecords == -1) { $requiredResult = $result; } else { $requiredResult = array_slice($result, $offset, $maxRecords); } $requiredResult = Perms::mixedFilter(array(), 'type', 'object', $requiredResult, $contextMapMap, $permMap); if ($maxRecords != -1) { // if filtered result is less than what's there look for more while (count($requiredResult) < $maxRecords && count($requiredResult) < $cant) { $nextResults = array_slice($result, $maxRecords, $maxRecords - count($requiredResult)); $nextResults = Perms::mixedFilter(array(), 'type', 'object', $nextResults, $contextMapMap, $permMap); if (empty($nextResults)) { break; } $requiredResult = array_merge($requiredResult, $nextResults); } } else { $cant = count($requiredResult); } $result = $requiredResult; $ret = array(); $objs = array(); foreach ($result as $res) { if (!in_array($res['catObjectId'] . '-' . $res['categId'], $objs)) { // same object and same category if (preg_match('/trackeritem/', $res['type']) && $res['description'] == '') { $trklib = TikiLib::lib('trk'); $trackerId = preg_replace('/^.*trackerId=([0-9]+).*$/', '$1', $res['href']); $res['name'] = $trklib->get_isMain_value($trackerId, $res['itemId']); $filed = $trklib->get_field_id($trackerId, "description"); $res['description'] = $trklib->get_item_value($trackerId, $res['itemId'], $filed); if (empty($res['description'])) { $res['description'] = $this->getOne("select `name` from `tiki_trackers` where `trackerId`=?", array((int) $trackerId)); } } if ($prefs['feature_sefurl'] == 'y') { $type = $res['type'] == 'wiki page' ? 'wiki' : $res['type']; $res['sefurl'] = filter_out_sefurl($res['href'], $type); } if (empty($res['name'])) { $res['name'] = '#' . $res['itemId']; } $ret[] = $res; $objs[] = $res['catObjectId'] . '-' . $res['categId']; } } return array("data" => $ret, "cant" => $cant); }
/** * get the wiki_syntax - use parent's if none * * @param int $galleryId gallery to get syntax from * @param array $fileinfo optional file info to process syntax on * @return string wiki markup */ function getWikiSyntax($galleryId = 0, $fileinfo = null, $params = null) { if (!$params) { $params = $_REQUEST; } if (isset($params['insertion_syntax']) && $params['insertion_syntax'] == 'file') { // for use in 'Choose or Upload' toolbar item (tikifile) $syntax = '{file type="gallery" fileId="%fileId%" showicon="y"}'; } else { if (isset($params['filegals_manager'])) { // for use in plugin edit popup if ($params['filegals_manager'] === 'fgal_picker_id') { $syntax = '%fileId%'; // for use in plugin edit popup } else { if ($params['filegals_manager'] === 'fgal_picker') { $href = 'tiki-download_file.php?fileId=123&display'; // dummy id as sefurl expects a (/d+) pattern global $smarty; include_once 'tiki-sefurl.php'; $href = filter_out_sefurl($href); $syntax = str_replace('123', '%fileId%', $href); } } } } if (empty($syntax)) { $syntax = $this->table('tiki_file_galleries')->fetchOne('wiki_syntax', array('galleryId' => $galleryId)); $list = $this->getGalleryParentsColumns($galleryId, array('wiki_syntax')); foreach ($list as $fgal) { if (!empty($fgal['wiki_syntax'])) { $syntax = $fgal['wiki_syntax']; break; } } } // and no syntax set, return default if (empty($syntax)) { $syntax = '{img fileId="%fileId%" thumb="box"}'; // should be a pref } if ($fileinfo) { // if fileinfo provided then process it now $syntax = $this->process_fgal_syntax($syntax, $fileinfo); } return $syntax; }
function getWikiSyntax($galleryId = 0) { if (isset($_REQUEST['insertion_syntax']) && $_REQUEST['insertion_syntax'] == 'file') { // for use in 'Choose or Upload' toolbar item (tikifile) return '{file type="gallery" fileId="%fileId%" showicon="y"}'; } if (isset($_REQUEST['filegals_manager'])) { // for use in plugin edit popup if ($_REQUEST['filegals_manager'] === 'fgal_picker_id') { return '%fileId%'; // for use in plugin edit popup } else { if ($_REQUEST['filegals_manager'] === 'fgal_picker') { $href = 'tiki-download_file.php?fileId=123&display'; // dummy id as sefurl expects a (/d+) pattern global $smarty; include_once 'tiki-sefurl.php'; $href = filter_out_sefurl($href); return str_replace('123', '%fileId%', $href); } } } $syntax = $this->table('tiki_file_galleries')->fetchOne('wiki_syntax', array('galleryId' => $galleryId)); if (!empty($syntax)) { return $syntax; } $list = $this->getGalleryParentsColumns($galleryId, array('wiki_syntax')); foreach ($list as $fgal) { if (!empty($fgal['wiki_syntax'])) { return $fgal['wiki_syntax']; } } // and no syntax set, return default $syntax = '{img fileId="%fileId%" thumb="y" rel="box[g]"}'; // should be a pref return $syntax; }
/** * @param string $words * @param int $offset * @param $maxRecords * @param bool $fulltext * @param string $filter * @param string $boolean * @param int $searchDate * @param int $categId * @return array */ function find_trackers($words = '', $offset = 0, $maxRecords = -1, $fulltext = false, $filter = '', $boolean = 'n', $searchDate = 0, $categId = 0) { global $trklib; require_once 'lib/trackers/trackerlib.php'; global $tiki_p_view_trackers_pending; global $tiki_p_view_trackers_closed; static $search_trackers = array('from' => '`tiki_tracker_item_fields` ttif LEFT JOIN `tiki_tracker_items` tti ON (ttif.`itemId`=tti.`itemId`) LEFT JOIN `tiki_trackers` tt ON (tti.`trackerId`= tt.`trackerId`) LEFT JOIN `tiki_tracker_fields` ttf ON (ttf.`fieldId`= ttif.`fieldId`)', 'name' => 'ttif.`itemId`', 'data' => 'tt.`name`', 'hits' => 'tt.`trackerId`', 'lastModif' => 'tti.`lastModif`', 'href' => 'tiki-view_tracker_item.php?itemId=%d', 'id' => array('tti.`itemId`'), 'pageName' => 'tti.`itemId`', 'search' => array('`value`'), 'filter' => 'ttf.`isSearchable` = \'y\'', 'permName' => 'tiki_p_view_trackers', 'objectType' => 'tracker', 'objectKey' => 'tt.`trackerId`', 'objectKeyPerm' => 'tt.`trackerId`', 'objectKeyCat' => 'tt.`trackerId`', 'objectKeyGroup' => 'ttif.`itemId`'); if ($tiki_p_view_trackers_closed != 'y') { $search_trackers['filter'] .= " AND tti.`status` != 'c'"; } if ($tiki_p_view_trackers_pending != 'y') { $search_trackers['filter'] .= " AND tti.`status` != 'p'"; } $ret = $this->_find($search_trackers, $words, $offset, $maxRecords, $fulltext, $filter, $boolean, tra('Tracker item'), $searchDate, $categId); $retFinal = array(); $itemFinal = array(); foreach ($ret['data'] as $i => $res) { global $smarty; include_once 'tiki-sefurl.php'; $res['href'] = filter_out_sefurl($res['href'], 'trackeritem', $res['name']); if (($j = array_search($res['name'], $itemFinal)) === false) { $res['pageName'] = '(#' . $res['pageName'] . ') ' . $trklib->get_isMain_value($res['hits'], $res['pageName']); $res['hits'] = 'Unknown'; $itemFinal[] = $res['name']; $retFinal[] = $res; } else { $retFinal[$j]['relevance'] += $res['relevance']; } } return array('cant' => count($retFinal), 'data' => $retFinal); }
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; // $full defined in route.php if ($data['entry'] != $entry && ($prefs['feature_sefurl'] !== 'y' || $data['entry'] !== urldecode($full))) { return null; } $registered = (array) json_decode($data['parameters'], true); if ($prefs['feature_sefurl'] === 'y') { // filter out the usual sefurl parameters that would be missing from the URI $usedInRequest = ['page', 'articleId', 'blogId', 'postId', 'parentId', 'fileId', 'galleryId', 'forumId', 'nlId', 'trackerId', 'itemId', 'sheetId', 'userId', 'calIds']; $usedInRequest = array_diff($usedInRequest, array_keys($registered)); // params that are actually used and need to be checked $parameters = array_diff_key($parameters, array_flip($usedInRequest)); // remove params that aren't used } 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'] . $data['tokenId']; $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); }
/** * get_objects_with_tag_combo * * Returns an array of object ID's that have all the tags passed in the * tagArray parameter. Use this to provide tag combo services to your users. * * @param mixed $tagArray: array of normalized form tags along to the function. * @param string $type * @param string $thisUser: Restrict the result to objects tagged by a particular user * @param int $offset: The numerical offset to begin display at. Defaults to 0 * @param int $maxRecords: The number of results per page to show. Defaults to 100 * @param string $sort_mode * @param string $find * @param string $broaden * @access public * @return An array of Object ID numbers that reference your original objects * * Notes by nkoth: * 1. The reason why using two queries here is because we can't get one query to work * properly to return the right count of number of objects returned with duplicated objects * 2. If you can fix this with subquery that works as far back as MSSQL 4.1, may be worth * doing. But my experience with subquery is that it may be slower anyway. */ function get_objects_with_tag_combo($tagArray, $type = '', $thisUser = '', $offset = 0, $maxRecords = -1, $sort_mode = 'name_asc', $find = '', $broaden = 'n', $objectId = null) { global $tiki_p_admin, $user, $smarty, $prefs; $objectIds = explode(':', $objectId); if (!isset($tagArray) || !is_array($tagArray)) { return false; } if (count($tagArray) == 0) { return array('data' => array(), 'cant' => 0); } $bindvals = $tagArray; $numTags = count($tagArray); if (isset($thisUser) && !empty($thisUser)) { $mid = ' AND `user` = ?'; $bindvals[] = $thisUser; } else { $mid = ''; } $tag_sql = ' t.`tag` IN (?'; for ($i = 1; $i < $numTags; $i++) { $tag_sql .= ',?'; } $tag_sql .= ')'; if ($broaden == 'n') { $bindvals_t = $bindvals; $mid_t = ''; if (isset($thisUser) && !empty($thisUser)) { $mid_t = ' AND `user` = ?'; $bindvals_t[] = $thisUser; } if (isset($type) && !empty($type)) { $mid_t .= ' AND `type` = ?'; $bindvals_t[] = $type; } if (isset($find) && !empty($find)) { $findesc = '%' . $find . '%'; $mid_t .= ' AND (o.`name` like ? OR o.`description` like ?)'; $bindvals_t = array_merge($bindvals_t, array($findesc, $findesc)); } $bindvals_t[] = $numTags; $query_t = 'SELECT o.`objectId`, COUNT(DISTINCT t.`tag`) AS uniques '; $query_end_t = ' FROM `tiki_objects` o, `tiki_freetagged_objects` fto, `tiki_freetags` t' . ' WHERE ' . $tag_sql . ' AND fto.`tagId` = t.`tagId` AND o.`objectId` = fto.`objectId` ' . $mid_t . ' GROUP BY o.`objectId`' . ' HAVING uniques = ?'; $query_t .= $query_end_t; $result = $this->query($query_t, $bindvals_t, -1, 0); $ret = array(); while ($row = $result->fetchRow()) { $ret[] = $row; } if ($numCats = count($ret)) { $tag_sql .= ' AND o.`objectId` IN (?'; $bindvals[] = $ret[0]['objectId']; for ($i = 1; $i < $numCats; $i++) { $tag_sql .= ',?'; $bindvals[] = $ret[$i]['objectId']; } $tag_sql .= ')'; } else { return array('data' => array(), 'cant' => 0); } } $mid = ''; if (isset($thisUser) && !empty($thisUser)) { $mid = ' AND `user` = ?'; $bindvals[] = $thisUser; } if (isset($type) && !empty($type)) { $mid .= ' AND `type` = ?'; $bindvals[] = $type; } if (isset($find) && !empty($find)) { $findesc = '%' . $find . '%'; $mid .= ' AND (o.`name` like ? OR o.`description` like ?)'; $bindvals = array_merge($bindvals, array($findesc, $findesc)); } // We must adjust for duplicate normalized tags appearing multiple times in the join by // counting only the distinct tags. It should also work for an individual user. $query = 'SELECT DISTINCT o.*'; $query_cant = 'SELECT COUNT(DISTINCT o.`objectId`)'; $query_end = ' FROM `tiki_objects` o, `tiki_freetagged_objects` fto, `tiki_freetags` t' . ' WHERE fto.`tagId` = t.`tagId` AND o.`objectId` = fto.`objectId`' . ' AND ' . $tag_sql . $mid . ' ORDER BY ' . $this->convertSortMode($sort_mode); // note the original line was originally here to fix ambiguous 'created' column for default sort. // Not a neat fix the o. prefix is ugly. So changed default order instead. $query .= $query_end; $query_cant .= $query_end; $result = $this->query($query, $bindvals, $maxRecords, $offset); $cant = $this->getOne($query_cant, $bindvals); $ret = array(); $permMap = TikiLib::lib('object')->map_object_type_to_permission(); while ($row = $result->fetchRow()) { $ok = false; if ($row['type'] == 'blog post') { $bloglib = TikiLib::lib('blog'); $post_info = $bloglib->get_post($row['itemId']); if (!empty($objectId) && !in_array($post_info['blogId'], $objectIds)) { } elseif ($tiki_p_admin == 'y' || $this->user_has_perm_on_object($user, $post_info['blogId'], 'blog', 'tiki_p_read_blog')) { $ok = true; } } elseif ($tiki_p_admin == 'y') { $ok = true; } elseif ($this->user_has_perm_on_object($user, $row['itemId'], $row['type'], $permMap[$row['type']])) { $ok = true; } if ($ok) { global $tikilib; if (!empty($row['description'])) { $row['description'] = $tikilib->parse_data($row['description'], array('absolute_links' => true)); } if ($prefs['feature_sefurl'] == 'y') { include_once 'tiki-sefurl.php'; if ($row['type'] == 'blog post' && !empty($post_info)) { $row['href'] = filter_out_sefurl($row['href'], 'blogpost', $post_info['title']); } else { $type = $row['type'] == 'wiki page' ? 'wiki' : ($row['type'] == 'blog post' ? 'blogpost' : $row['type']); $row['href'] = filter_out_sefurl($row['href'], $type); } } $ret[] = $row; } else { --$cant; } } return array('data' => $ret, 'cant' => $cant); }
require_once 'lib/setup/tikiIndex.php'; if ($prefs['useGroupHome'] == 'y') { require_once 'lib/setup/default_homepage.php'; } // change $prefs['tikiIndex'] if feature_sefurl is enabled (e.g. tiki-index.php?page=HomePage becomes HomePage) if ($prefs['feature_sefurl'] == 'y') { //TODO: need a better way to know which is the type of the tikiIndex URL (wiki page, blog, file gallery etc) //TODO: implement support for types other than wiki page and blog if ($prefs['tikiIndex'] == 'tiki-index.php' && $prefs['wikiHomePage']) { global $wikilib; include_once 'lib/wiki/wikilib.php'; $prefs['tikiIndex'] = $wikilib->sefurl($userlib->best_multilingual_page($prefs['wikiHomePage'])); } else { if (substr($prefs['tikiIndex'], 0, strlen('tiki-view_blog.php')) == 'tiki-view_blog.php') { include_once 'tiki-sefurl.php'; $prefs['tikiIndex'] = filter_out_sefurl($prefs['tikiIndex'], 'blog'); } } } require_once 'lib/setup/theme.php'; if ($prefs['feature_babelfish'] == 'y' || $prefs['feature_babelfish_logo'] == 'y') { require_once 'lib/setup/babelfish.php'; } if (!empty($varcheck_errors)) { $smarty->assign('msg', $varcheck_errors); $smarty->display('error_raw.tpl'); die; } if ($prefs['feature_challenge'] == 'y') { require_once 'lib/setup/challenge.php'; }
die; } } else { $info = $tikilib->get_page_info($page); } } // If the page doesn't exist then display an error if (empty($info) && !($user && $prefs['feature_wiki_userpage'] == 'y' && strcasecmp($prefs['feature_wiki_userpage_prefix'] . $user, $page) == 0)) { if (!empty($prefs['url_anonymous_page_not_found']) && empty($user)) { $access->redirect($prefs['url_anonymous_page_not_found']); } if ($user && $prefs['feature_wiki_userpage'] == 'y' && strcasecmp($prefs['feature_wiki_userpage_prefix'], $page) == 0) { $url = 'tiki-index.php?page=' . $prefs['feature_wiki_userpage_prefix'] . $user; if ($prefs['feature_sefurl'] == 'y') { include_once 'tiki-sefurl.php'; header('location: ' . urlencode(filter_out_sefurl($url, 'wiki'))); } else { header("Location: {$url}"); } die; } if ($prefs['feature_wiki_userpage'] == 'y' && strcasecmp($prefs['feature_wiki_userpage_prefix'], substr($page, 0, strlen($prefs['feature_wiki_userpage_prefix']))) == 0) { $isUserPage = true; } else { $isUserPage = false; } $referencedPages = $wikilib->get_pages_by_alias($page); $likepages = $wikilib->get_like_pages($page); if ($prefs['feature_wiki_pagealias'] == 'y' && count($referencedPages) == 1) { $newPage = $referencedPages[0]; } else {
$id = "postId"; $descId = "data"; $dateId = "created"; $titleId = "title"; $authorId = "user"; $readrepl = "tiki-view_blog_post.php?postId=%s"; $tmp = $prefs['feed_' . $feed . '_title']; if ($tmp <> '') $title = $tmp; $tmp = $prefs['feed_' . $feed . '_desc']; if ($desc <> '') $desc = $tmp; $changes = $bloglib->list_all_blog_posts(0, $prefs['feed_blogs_max'], $dateId . '_desc', '', $now); $tmp = array(); include_once ('tiki-sefurl.php'); foreach ($changes["data"] as $data) { global $bloglib; $data["$descId"] = $tikilib->parse_data( $data[$descId], array( 'print' => true ) ); $data['sefurl'] = filter_out_sefurl(sprintf($readrepl, $data['postId'], $data['blogId']), 'blogpost', $data['title']); $tmp[] = $data; } $changes["data"] = $tmp; $tmp = null; $output = $rsslib->generate_feed($feed, $uniqueid, '', $changes, $readrepl, '', $id, $title, $titleId, $desc, $descId, $dateId, $authorId); } header("Content-type: " . $output["content-type"]); print $output["data"];
$bestLangPageId = $multilinguallib->selectLangObj($type, $pageId, $_REQUEST['language']); if ($pageId != $bestLangPageId) { if (!empty($param['page_id'])) { $orig_url = preg_replace('/(.*[&?]page_id=)' . $pageId . '(.*)/', '${1}' . $bestLangPageId . '$2', $orig_url); } elseif (!empty($param['articleId'])) { $orig_url = preg_replace('/(.*[&?]articleId=)' . $pageId . '(.*)/', '${1}' . $bestLangPageId . '$2', $orig_url); } else { $newPage = urlencode($tikilib->get_page_name_from_id($bestLangPageId)); $orig_url = preg_replace('/(.*[&?]page=)' . preg_quote($page) . '(.*)/', '${1}' . "{$newPage}" . '$2', $orig_url); $orig_url = preg_replace('/(.*)(tiki-index.php)$/', "\$1\$2?page={$newPage}", $orig_url); } } $orig_url = preg_replace('/(.*)no_bl=y&(.*)/', '$1$2', $orig_url); $orig_url = preg_replace('/(.*)&no_bl=y(.*)/', '$1$2', $orig_url); if ($prefs['feature_sefurl'] == 'y') { include_once 'tiki-sefurl.php'; $orig_url = filter_out_sefurl($orig_url); } if ($item_url) { if ($prefs['feature_sefurl'] == 'y') { $orig_url = $orig_url . "?" . $item_url; } elseif (!strstr($_SERVER['HTTP_REFERER'], 'tiki-index.php') && !strstr($_SERVER['HTTP_REFERER'], 'tiki-read_article.php')) { $orig_url = $orig_url . "&" . $item_url; } } } if (isset($_GET['language'])) { setLanguage($_GET['language']); } header("location: {$orig_url}"); exit;
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~'; }
/** * Creates DOM tag for user info with popup or not depending on prefs etc * @param string $auser user to find info for (current user if empty) * @param string $body content of the anchor tag (user name if empty) * @param string $class add a class to the a tag (default userlink) * @return string HTML anchor tag */ function build_userinfo_tag($auser = '', $body = '', $class = 'userlink') { global $user, $prefs; if (!$auser) { $auser = $user; } $realn = $this->clean_user($auser); if (!$body) { $body = $realn; } $isSelf = $auser == $user ? true : false; // Only process if feature_friends enabled, user_information public or we query ourselfs if ($this->get_user_preference($auser, 'user_information', 'public') != 'public' && $prefs['feature_friends'] != 'y' && !$isSelf) { return $body; } $id = $this->get_user_id($auser); if ($id == -1) { return $body; } include_once 'tiki-sefurl.php'; $url = "tiki-user_information.php?userId={$id}"; $url = filter_out_sefurl($url); $extra = ''; if ($prefs['feature_community_mouseover'] == 'y' && ($this->get_user_preference($auser, 'show_mouseover_user_info', 'y') == 'y' || $prefs['feature_friends'] == 'y')) { $rel = TikiLib::lib('service')->getUrl(array('controller' => 'user', 'action' => 'info', 'username' => $auser)); $extra .= ' rel="' . htmlspecialchars($rel, ENT_QUOTES) . '"'; $class .= ' ajaxtips'; if ($auser === $user) { $title = tra('Your Information'); } else { $title = tra('User Information'); } } else { if ($prefs['user_show_realnames'] == 'y') { $title = $realn; } else { $title = $auser; } } if (empty($prefs['urlOnUsername'])) { $url = 'tiki-user_information.php?userId=' . $id; if ($prefs['feature_sefurl'] == 'y') { include_once 'tiki-sefurl.php'; $url = filter_out_sefurl($url); } } else { $url = preg_replace(array('/%userId%/', '/%user%/'), array($id, $auser), $prefs['urlOnUsername']); } $lat = $this->get_user_preference($auser, 'lat'); $lon = $this->get_user_preference($auser, 'lon'); $zoom = $this->get_user_preference($auser, 'zoom'); if (!($lat == 0 && $lon == 0)) { $class .= " geolocated"; $extra .= " data-geo-lat='{$lat}' data-geo-lon='{$lon}'"; if ($zoom) { $extra .= " data-geo-zoom='{$zoom}'"; } } $body = "<a title=\"" . htmlspecialchars($title, ENT_QUOTES) . "\" href=\"{$url}\" class=\"{$class}\"{$extra}>" . $body . '</a>'; return $body; }