function handleSave($value, $oldValue) { global $prefs, $user; $tikilib = TikiLib::lib('tiki'); $trackerId = $this->getConfiguration('trackerId'); $file_name = $this->getConfiguration('file_name'); $file_size = $this->getConfiguration('file_size'); $file_type = $this->getConfiguration('file_type'); $perms = Perms::get('tracker', $trackerId); if ($perms->attach_trackers && $file_name) { if ($prefs['t_use_db'] == 'n') { $fhash = md5($file_name . $tikilib->now); if (file_put_contents($prefs['t_use_dir'] . $fhash, $value) === false) { $smarty = TikiLib::lib('smarty'); $smarty->assign('msg', tra('Cannot write to this file:') . $fhash); $smarty->display("error.tpl"); die; } $value = ''; } else { $fhash = 0; } $trklib = TikiLib::lib('trk'); $value = $trklib->replace_item_attachment($oldValue, $file_name, $file_type, $file_size, $value, '', $user, $fhash, '', '', $trackerId, $this->getItemId(), '', false); } return array('value' => $value); }
function smarty_function_memusage($params, $smarty) { if (function_exists('memory_get_peak_usage')) { // PHP 5.2+ $memusage = memory_get_peak_usage(); } elseif (function_exists('memory_get_usage')) { //PHP 4 >= 4.3.2, PHP 5 $memusage = memory_get_usage(); } else { $memusage = 0; } if ($memusage > 0) { $memunit = "B"; if ($memusage > 1024) { $memusage = $memusage / 1024; $memunit = "kB"; } if ($memusage > 1024) { $memusage = $memusage / 1024; $memunit = "MB"; } if ($memusage > 1024) { $memusage = $memusage / 1024; $memunit = "GB"; } print number_format($memusage, 2) . $memunit; } else { print tra("Unknown"); } }
/** * Returns an array of notification types * * @param boolean $checkPermission If enabled, only return types for which the user has the permission needed so that they are effective. * @return A string-indexed bidimensional array of watch types. The first index is the watch event name. * Second-level array are also string-indexed with elements label (description of the event), * type (usually the type of watched objects) and url (a relevant script to access when an event happens, if any). */ function get_global_watch_types($checkPermission = false) { global $prefs, $tiki_p_admin, $tiki_p_admin_file_galleries; $watches['user_registers'] = array('label' => tra('A user registers'), 'type' => 'users', 'url' => 'tiki-adminusers.php', 'available' => $prefs['allowRegister'] == 'y', 'permission' => $tiki_p_admin == 'y'); $watches['article_submitted'] = array('label' => tra('A user submits an article'), 'type' => 'article', 'url' => 'tiki-list_submissions.php', 'available' => $prefs['feature_articles'] == 'y'); $watches['article_edited'] = array('label' => tra('A user edits an article'), 'type' => 'article', 'url' => 'tiki-list_articles.php', 'available' => $prefs['feature_articles'] == 'y'); $watches['article_deleted'] = array('label' => tra('A user deletes an article'), 'type' => 'article', 'url' => 'tiki-list_submissions.php', 'available' => $prefs['feature_articles'] == 'y'); $watches['article_*'] = array('label' => tra('An article is submitted, edited, deleted or commented on.'), 'type' => 'article', 'url' => '', 'available' => $prefs['feature_articles'] == 'y'); $watches['blog_post'] = array('label' => tra('A new blog post is published'), 'type' => 'blog', 'url' => '', 'available' => $prefs['feature_blogs'] == 'y', 'object' => '*'); $watches['wiki_page_changes'] = array('label' => tra('A wiki page is created, deleted or edited, except for minor changes.'), 'type' => 'wiki page', 'url' => 'tiki-lastchanges.php', 'available' => $prefs['feature_wiki'] == 'y'); $watches['wiki_page_changes_incl_minor'] = array('label' => tra('A wiki page is created, deleted or edited, even for minor changes.'), 'type' => 'wiki page', 'url' => 'tiki-lastchanges.php', 'available' => $prefs['feature_wiki'] == 'y'); $watches['wiki_comment_changes'] = array('label' => tra('A comment in a wiki page is posted or edited'), 'type' => 'wiki page', 'url' => '', 'available' => $prefs['feature_wiki'] == 'y' && $prefs['feature_wiki_comments'] == 'y'); $watches['article_commented'] = array('label' => tra('A comment in an article is posted or edited'), 'type' => 'article', 'url' => '', 'available' => $prefs['feature_articles'] == 'y' && $prefs['feature_article_comments'] == 'y'); $watches['fgal_quota_exceeded'] = array('label' => tra('File gallery quota exceeded'), 'type' => 'file gallery', 'url' => '', 'available' => $prefs['feature_file_galleries'] == 'y', 'permission' => $tiki_p_admin == 'y'); $watches['auth_token_called'] = array('label' => tra('Token is called'), 'type' => 'security', 'url' => '', 'object' => '*'); $watches['user_joins_group'] = array('label' => tra('User joins a group'), 'type' => 'users', 'url' => '', 'object' => '*'); foreach ($watches as $key => $watch) { if (array_key_exists('available', $watch) && !$watch['available']) { unset($watches[$key]); } else { $watches[$key]['object'] = '*'; unset($watches['available']); if ($checkPermission && array_key_exists('permission', $watch) && !$watch['permission']) { unset($watches[$key]); } } } return $watches; }
function smarty_function_show_sort($params, $smarty) { global $url_path; if (isset($_REQUEST[$params['sort']])) { $p = $_REQUEST[$params['sort']]; } elseif ($s = $smarty->getTemplateVars($params['sort'])) { $p = $s; } if (isset($params['sort']) and isset($params['var']) and isset($p)) { $prop = substr($p, 0, strrpos($p, '_')); $order = substr($p, strrpos($p, '_') + 1); if (strtolower($prop) == strtolower(trim($params['var']))) { $smarty->loadPlugin('smarty_function_icon'); $icon_params = array('alt' => tra('Invert Sort'), 'style' => 'vertical-align:middle'); switch ($order) { case 'asc': case 'nasc': $icon_params['_id'] = 'resultset_up'; return smarty_function_icon($icon_params, $smarty); break; case 'desc': case 'ndesc': $icon_params['_id'] = 'resultset_down'; return smarty_function_icon($icon_params, $smarty); break; } } } }
function scrambleEmail($email, $method='unicode') { switch ($method) { case 'strtr': $trans = array( "@" => tra("(AT)"), "." => tra("(DOT)") ); return strtr($email, $trans); case 'x' : $encoded = $email; for ($i = strpos($email, "@") + 1, $istrlen_email = strlen($email); $i < $istrlen_email; $i++) { if ($encoded[$i] != ".") $encoded[$i] = 'x'; } return $encoded; case 'unicode': case 'y':// for previous compatibility $encoded = ''; for ($i = 0, $istrlen_email = strlen($email); $i < $istrlen_email; $i++) { $encoded .= '&#' . ord($email[$i]). ';'; } return $encoded; case 'n': default: return $email; } }
function wikiplugin_flash($data, $params) { global $prefs, $user; $userlib = TikiLib::lib('user'); $tikilib = TikiLib::lib('tiki'); // Handle file from a podcast file gallery if (isset($params['fileId']) && !isset($params['movie'])) { $filegallib = TikiLib::lib('filegal'); $file_info = $filegallib->get_file_info($params['fileId']); if (!$userlib->user_has_perm_on_object($user, $file_info['galleryId'], 'file gallery', 'tiki_p_view_file_gallery')) { return tra('Permission denied'); } $params['movie'] = $prefs['fgal_podcast_dir'] . $file_info['path']; } // Handle Youtube video if (isset($params['youtube']) && preg_match('|http(s)?://(\\w+\\.)?youtube\\.com/watch\\?v=([\\w-]+)|', $params['youtube'], $matches)) { $params['movie'] = "//www.youtube.com/v/" . $matches[3]; } // Handle Vimeo video if (isset($params['vimeo']) && preg_match('|http(s)?://(www\\.)?vimeo\\.com/(clip:)?(\\d+)|', $params['vimeo'], $matches)) { $params['movie'] = '//vimeo.com/moogaloop.swf?clip_id=' . $matches[4]; } if ((isset($params['youtube']) || isset($params['vimeo'])) && !isset($params['movie'])) { return tra('Invalid URL'); } unset($params['type']); $code = $tikilib->embed_flash($params); if ($code === false) { return tra('Missing parameter movie to the plugin flash'); } return $code; }
function getDirContent($sub) { global $allowed_types; global $a_img; global $a_path; global $imgdir, $smarty; $allimg = array(); $tmp = $imgdir; if ($sub <> "") $tmp.= '/' . $sub; if (!@($dimg = opendir($tmp))) { $msg = tra("Invalid directory name"); $smarty->assign('msg', $msg); $smarty->display("error.tpl"); die; } while ((false !== ($imgf = readdir($dimg)))) { if ($imgf != "." && $imgf != ".." && substr($imgf, 0, 1) != ".") { $allimg[] = $imgf; } } sort($allimg); foreach ($allimg as $imgfile) { if (is_dir($tmp . "/" . $imgfile)) { if ((substr($sub, -1) <> "/") && (substr($sub, -1) <> "\\")) { $sub.= '/'; } getDirContent($sub . $imgfile); } elseif (in_array(strtolower(substr($imgfile, -(strlen($imgfile) - strrpos($imgfile, ".")))), $allowed_types)) { $a_img[] = $imgfile; $a_path[] = $sub; } } closedir($dimg); }
function wikiplugin_showpages($data, $params) { global $tikilib, $prefs; extract($params, EXTR_SKIP); if (!isset($find)) { return "<b>missing find parameter for plugin SHOWPAGES</b><br />"; } if (!isset($max)) { $max = -1; } if (!isset($display) || strpos($display, 'name') === false && strpos($display, 'desc') === false) { $display = 'name|desc'; } $data = $tikilib->list_pages(0, $max, 'pageName_asc', $find); $text = ''; foreach ($data["data"] as $page) { if (isset($prefs['feature_wiki_description']) && $prefs['feature_wiki_description'] == 'y' && strpos($display, 'desc') !== false) { $desc = $tikilib->page_exists_desc($page["pageName"]); } else { $desc = ''; } $text .= "<a href=\"tiki-index.php?page=" . $page["pageName"] . "\" title=\"" . tra("Last modified by") . " " . $page["user"] . "\" class=\"wiki\">"; $text .= strpos($display, 'name') !== false || strlen($desc) == 0 ? $page["pageName"] : $desc; $text .= "</a>"; $text .= strpos($display, 'name') !== false && $desc !== $page["pageName"] && strlen($desc) > 0 ? " - {$desc}" : ""; $text .= "<br />"; } return $text; }
function wikiplugin_jq_info() { return array( 'name' => tra('jQuery'), 'documentation' => 'PluginJQ', 'description' => tra('Add JavaScript code'), 'prefs' => array( 'wikiplugin_jq' ), 'body' => tra('JavaScript code'), 'validate' => 'all', 'filter' => 'none', 'icon' => 'img/icons/script_code_red.png', 'params' => array( 'notonready' => array( 'required' => false, 'name' => tra('Not On Ready'), 'description' => tra('Do not execute on document ready (execute inline)'), ), 'nojquery' => array( 'required' => false, 'name' => tra('No JavaScript'), 'description' => tra('Optional markup for when JavaScript is off'), ) ) ); }
function verifySecurity(&$pParamHash) { if ($pParamHash['security_id'] != 'public' && !empty($pParamHash['access_level'])) { // if we have an access level, we know we are trying to save/update, // else perhaps we are just assigning security_id to content_id if (empty($pParamHash['security_description']) && (empty($pParamHash['security_id']) || $pParamHash['security_id'] == 'new')) { // default name to security access level instead of throwing an error $pParamHash['security_store']['security_description'] = $pParamHash['access_level']; } elseif (!empty($pParamHash['security_description'])) { // we need to load the existing security_id to verify we user owns the security_id & if anything has changed $pParamHash['security_store']['security_description'] = substr($pParamHash['security_description'], 0, 160); } if (!empty($pParamHash['access_level'])) { $pParamHash['security_store']['is_hidden'] = $pParamHash['access_level'] == 'hidden' ? 'y' : NULL; $pParamHash['security_store']['is_private'] = $pParamHash['access_level'] == 'private' ? 'y' : NULL; // If we have an answer, store the question. if ($pParamHash['access_level'] == 'protected' && empty($pParamHash['access_answer'])) { $this->mErrors['security'] = tra("You must enter an answer for your security question."); } else { $pParamHash['security_store']['access_question'] = !empty($pParamHash['access_answer']) ? $pParamHash['access_question'] : NULL; $pParamHash['security_store']['access_answer'] = !empty($pParamHash['access_answer']) ? trim($pParamHash['access_answer']) : NULL; } // $pParamHash['security_store']['group_id'] = !empty( $pParamHash['access_group_id'] ) ? $pParamHash['access_group_id'] : NULL; } } return count($this->mErrors) == 0; }
/** * @param $mod_reference * @param null $params */ function module_since_last_visit($mod_reference, $params = null) { global $user, $tikilib, $smarty; $nvi_info = $tikilib->get_news_from_last_visit($user); $smarty->assign('nvi_info', $nvi_info); $smarty->assign('tpl_module_title', tra('Since your last visit')); }
function galaxia_execute_activity($activityId = 0, $iid = 0, $auto = 1) { // Now execute the code for the activity but we are in a method! // so just use an fopen with http mode global $tikilib; $parsed = parse_url($_SERVER["REQUEST_URI"]); $URI = $tikilib->httpPrefix() . $parsed["path"]; $parts = explode('/', $URI); $parts[count($parts) - 1] = "tiki-g-run_activity.php?activityId={$activityId}&iid={$iid}&auto={$auto}"; $URI = implode('/', $parts); $fp = fopen($URI, "r"); $data = ''; if (!$fp) { trigger_error(tra("Fatal error: cannot execute automatic activity {$activityId}"), E_USER_WARNING); die; } while (!feof($fp)) { $data .= fread($fp, 8192); } /* if(!empty($data)) { trigger_error(tra("Fatal error: automatic activity produced some output:$data"), E_USER_WARNING); } */ fclose($fp); }
function smarty_function_error_report($params, $smarty) { $errorreportlib = TikiLib::lib('errorreport'); $errors = $errorreportlib->get_errors(); $pre = '<div id="error_report">'; $post = '</div>'; TikiLib::lib('header')->add_js(' $("#error_report").ajaxComplete(function (e, jqxhr) { var error = jqxhr.getResponseHeader("X-Tiki-Error"); if (error) { if ($("ul", this).length === 0) { $(this).append($(error)[0].childNodes); } else { $("ul", this).append($(error).find("li")); } } }); $("#error_report .clear").live("click", function () { $("#error_report").empty(); return false; }); '); if (count($errors)) { $smarty->loadPlugin('smarty_block_remarksbox'); $repeat = false; return $pre . smarty_block_remarksbox(array('type' => 'errors', 'title' => tra('Error(s)')), '<a class="clear" style="float: right;" href="#">' . tr('Clear errors') . '</a><ul><li>' . implode('</li><li>', $errors) . '</li></ul>', $smarty, $repeat) . $post; } else { return $pre . $post; } }
private function gatherVoteData() { global $user; $field = $this->getBaseFieldData(); $trackerId = $this->getConfiguration('trackerId'); $itemId = $this->getItemId(); $votings = TikiDb::get()->table('tiki_user_votings'); if ($field['type'] == 's' && $field['name'] == tra('Rating')) { // global rating to an item - value is the sum of the votes $key = 'tracker.' . $trackerId . '.' . $itemId; } elseif ($field['type'] == '*' || $field['type'] == 'STARS') { // field rating - value is the average of the votes $key = "tracker.{$trackerId}.{$itemId}." . $field['fieldId']; } $data = $votings->fetchRow(array('count' => $votings->count(), 'total' => $votings->sum('optionId')), array('id' => $key)); $field['numvotes'] = $data['count']; $field['total'] = $data['total']; if ($field['numvotes']) { $field['voteavg'] = round($field['total'] / $field['numvotes'], 2); } else { $field['voteavg'] = 0; } // be careful optionId is the value - not the optionId $field['my_rate'] = $votings->fetchOne('optionId', array('id' => $key, 'user' => $user)); return $field; }
function wikiplugin_map_info() { return array('name' => tra('Map'), 'format' => 'html', 'documentation' => 'PluginMap', 'description' => tra('Display a map'), 'prefs' => array('wikiplugin_map', 'feature_search'), 'iconname' => 'map', 'introduced' => 1, 'tags' => array('basic'), 'filter' => 'wikicontent', 'body' => tr('Instructions to load content'), 'params' => array('scope' => array('required' => false, 'name' => tra('Scope'), 'description' => tr('Display the geolocated items represented in the page (%0all%1, %0center%1, or %0custom%1 as a CSS selector). Default: %0center%1', '<code>', '</code>'), 'since' => '8.0', 'filter' => 'text', 'default' => 'center'), 'controls' => array('required' => false, 'name' => tra('Controls'), 'description' => tr('Comma-separated list of map controls will be displayed on the map and around it'), 'since' => '9.0', 'filter' => 'word', 'accepted' => 'controls, layers, search_location, levels, current_location, scale, streetview, navigation, coordinates, overview', 'separator' => ',', 'default' => wp_map_default_controls()), 'width' => array('required' => false, 'name' => tra('Width'), 'description' => tra('Width of the map in pixels'), 'since' => '1', 'filter' => 'digits'), 'height' => array('required' => false, 'name' => tra('Height'), 'description' => tra('Height of the map in pixels'), 'since' => '1', 'filter' => 'digits'), 'center' => array('requied' => false, 'name' => tra('Center'), 'description' => tr('Format: %0x,y,zoom%1 where %0x%1 is the longitude, and %0y%1 is the latitude. %0zoom%1 is between %00%1 (view Earth) and %019%1.', '<code>', '</code>'), 'since' => '9.0', 'filter' => 'text'), 'popupstyle' => array('required' => false, 'name' => tr('Popup Style'), 'description' => tr('Alter the way the information is displayed when objects are loaded on the map.'), 'since' => '10.0', 'filter' => 'word', 'default' => 'bubble', 'options' => array(array('text' => '', 'value' => ''), array('text' => tr('Bubble'), 'value' => 'bubble'), array('text' => tr('Dialog'), 'value' => 'dialog'))), 'mapfile' => array('required' => false, 'name' => tra('MapServer File'), 'description' => tra('MapServer file identifier. Only fill this in if you are using MapServer.'), 'since' => '1', 'filter' => 'url', 'advanced' => true), 'extents' => array('required' => false, 'name' => tra('Extents'), 'description' => tra('Extents'), 'since' => '1', 'filter' => 'text', 'advanced' => true), 'size' => array('required' => false, 'name' => tra('Size'), 'description' => tra('Size of the map'), 'since' => '1', 'filter' => 'digits', 'advanced' => true), 'tooltips' => array('required' => false, 'name' => tra('Tooltips'), 'description' => tra('Show item name in a tooltip on hover'), 'since' => '12.1', 'default' => 'n', 'filter' => 'alpha', 'options' => array(array('text' => '', 'value' => ''), array('text' => tra('Yes'), 'value' => 'y'), array('text' => tra('No'), 'value' => 'n')), 'advanced' => true))); }
function wikiplugin_proposal($data, $params) { $voteData = explode("\n", $data); $votes = array(); foreach ($voteData as $entry) { $entry = trim($entry); if (preg_match("/^(([\\+\\-]1)|0)\\s+(\\w+)/", $entry, $parts)) { list($full, $vote, $null, $voter) = $parts; $votes[$voter] = $vote; } } $counts = array('+1' => array(), '0' => array(), '-1' => array()); foreach ($votes as $voter => $vote) { $counts[$vote][] = $voter; } global $smarty, $user, $tiki_p_edit; $smarty->assign('counts', $counts); if ($user && $tiki_p_edit == 'y') { $availableVotes = array(tra('Accept proposal') => "{$data}\n+1 {$user}", tra('Still undecided') => "{$data}\n0 {$user}", tra('Reject proposal') => "{$data}\n-1 {$user}"); $smarty->assign('available_votes', $availableVotes); } static $passes; $smarty->assign('passes', ++$passes); $smarty->assign('params', $params); $content = $smarty->fetch('wiki-plugins/wikiplugin_proposal.tpl'); return "~np~{$content}~/np~"; }
/** * @param $mod_reference * @param $module_params */ function module_groups_emulation($mod_reference, $module_params) { global $smarty, $user, $tiki_p_admin, $userlib; $smarty->assign('groups_are_emulated', isset($_SESSION['groups_are_emulated']) ? $_SESSION['groups_are_emulated'] : 'n'); if (isset($_SESSION['groups_emulated'])) { $smarty->assign('groups_emulated', unserialize($_SESSION['groups_emulated'])); } // Admins can see all existing groups if ($tiki_p_admin == 'y') { $allGroups = array(); $alls = $userlib->get_groups(); foreach ($alls['data'] as $g) { $allGroups[$g['groupName']] = "real"; } $smarty->assign_by_ref('allGroups', $allGroups); } // Extract list of groups of user, including included groups $userGroups = $userlib->get_user_groups_inclusion($user); $chooseGroups = $userGroups; $chooseGroups["Anonymous"] = "included"; if (isset($user)) { $chooseGroups["Registered"] = "included"; } $smarty->assign_by_ref('userGroups', $userGroups); $smarty->assign_by_ref('chooseGroups', $chooseGroups); $smarty->assign('tpl_module_title', tra("Emulate Groups")); }
function wikiplugin_button($data, $params) { global $tikilib,$smarty; $parserlib = TikiLib::lib('parser'); if (empty($params['href'])) { return tra('Incorrect param'); } $path = 'lib/smarty_tiki/function.button.php'; if (!file_exists($path)) { return tra('lib/smarty_tiki/function.button.php is missing or unreadable'); } // for some unknown reason if a wikiplugin param is named _text all whitespaces from // its value are removed, but we need to rename the param to _text for smarty_functin if (isset($params['text'])) { $params['_text'] = $params['text']; unset($params['text']); } // Parse wiki argument variables in the url, if any (i.e.: {{itemId}} for it's numeric value). $parserlib->parse_wiki_argvariable($params['href']); include_once($path); $func = 'smarty_function_button'; $content = $func($params, $smarty); return '~np~'.$content.'~/np~'; }
/** * @param $url * @param bool $use_tidy * @return array */ function get_url($url, $use_tidy = TRUE) { global $cookies; $smarty = TikiLib::lib('smarty'); $result = array(); $get = get_from_dom($url->getElementsByTagName('get')->item(0)); $post = get_from_dom($url->getElementsByTagName('post')->item(0)); $xpath = $url->getElementsByTagName('xpath')->item(0)->textContent; $data = $url->getElementsByTagName('data')->item(0)->textContent; $urlstr = $url->getAttribute("src"); $referer = $url->getAttribute("referer"); $result['data'] = $data; if (extension_loaded("tidy")) { $data = tidy_parse_string($data, array(), 'utf8'); tidy_diagnose($data); if ($use_tidy) { $result['ref_error_count'] = tidy_error_count($data); $result['ref_error_msg'] = tidy_get_error_buffer($data); } } else { $result['ref_error_msg'] = tra("Tidy Extension not present"); } $result['url'] = $urlstr; $result['xpath'] = $xpath; $result['method'] = $url->getAttribute("method"); $result['post'] = $post; $result['get'] = $get; $result['referer'] = $referer; return $result; }
function wikiplugin_html_info() { return array( 'name' => tra('HTML'), 'documentation' => 'PluginHTML', 'description' => tra('Add HTML to a page'), 'prefs' => array('wikiplugin_html'), 'body' => tra('HTML code'), 'validate' => 'all', 'filter' => 'rawhtml_unsafe', 'icon' => 'img/icons/mime/html.png', 'tags' => array( 'basic' ), 'params' => array( 'wiki' => array( 'required' => false, 'name' => tra('Wiki Syntax'), 'description' => tra('Parse wiki syntax within the HTML code.'), 'options' => array( array('text' => '', 'value' => ''), array('text' => tra('No'), 'value' => 0), array('text' => tra('Yes'), 'value' => 1), ), 'filter' => 'int', 'default' => '0', ), ), ); }
function smarty_modifier_kbsize($string, $bytes = false, $nb_decimals = 2, $unit_separator = ' ') { if ($string == '') { return ''; } if ($string > 1099511627776) { // 1024 x 1024 x 1024 x 1024 = 1099511627776 $string = number_format($string / 1099511627776, $nb_decimals); $kb_string = 'T'; } elseif ($string > 1073741824) { // 1024 x 1024 x 1024 = 1073741824 $string = number_format($string / 1073741824, $nb_decimals); $kb_string = 'G'; } elseif ($string > 1048576) { // 1024 x 1024 = 1048576 $string = number_format($string / 1048576, $nb_decimals); $kb_string = 'M'; } elseif ($string > 1024) { $string = number_format($string / 1024, $nb_decimals); $kb_string = 'K'; } else { $string = $string; $kb_string = ''; } $kb_string = $kb_string . ($bytes ? 'B' : 'b'); return $string . $unit_separator . tra($kb_string); }
function wikiplugin_googleanalytics($data, $params) { global $feature_no_cookie; // set according to cookie_consent_feature pref in tiki-setup.php extract($params, EXTR_SKIP); if (empty($account)) { return tra('Missing parameter'); } if ($feature_no_cookie) { return ''; } $ret = <<<JS <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-{$account}']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> JS; return $ret; }
function smarty_function_phplayers($params, &$smarty) { global $prefs, $tikiphplayers; include_once 'lib/phplayers_tiki/tiki-phplayers.php'; if ($prefs['feature_phplayers'] != 'y') { echo tra("phplayers are not available on this site"); return; } //$smarty->assign('uses_phplayers','y'); doesn't seem to be use extract($params); if (empty($type)) { $type = 'tree'; } if (!isset($sectionLevel)) { $sectionLevel = ''; } if (!empty($id)) { $output = $tikiphplayers->mkMenuEntry($id, $curOption, $sectionLevel); } $name = 'usermenu' . $id; if (!isset($file)) { $file = ''; } echo $tikiphplayers->mkMenu($output, $name, $type, $file, $curOption); }
function wikiplugin_alink($data, $params) { global $prefs; $multilinguallib = TikiLib::lib('multilingual'); $tikilib = TikiLib::lib('tiki'); extract($params, EXTR_SKIP); if (!isset($aname)) { return "<b>missing parameter for aname</b><br />"; } // the following replace is necessary to maintain compliance with XHTML 1.0 Transitional // and the same behavior as tikilib.php. This will change when the world arrives at XHTML 1.0 Strict. $aname = preg_replace('/[^a-zA-Z0-9]+/', '_', $aname); if (isset($pagename) && $pagename) { // Stolen, with some modifications, from tikilib.php line 4717-4723 if ($desc = $tikilib->page_exists_desc($pagename)) { // to choose the best page language $bestLang = $prefs['feature_multilingual'] == 'y' && $prefs['feature_best_language'] == 'y' ? "&bl" : ""; // $bestLang = $prefs['feature_best_language'] == 'y' ? "&bl" : ""; return "<a title=\"{$desc}\" href='tiki-index.php?page=" . urlencode($pagename) . $bestLang . "#" . $aname . "' class='wiki'>{$data}</a>"; } else { return $data . '<a href="tiki-editpage.php?page=' . urlencode($pagename) . '" title="' . tra("Create page:") . ' ' . urlencode($pagename) . '" class="wiki wikinew">?</a>'; } } elseif (isset($_REQUEST['page'])) { $urlPrefix = "tiki-index.php?page="; if ($prefs['feature_sefurl'] == 'y') { $urlPrefix = ""; } return "<a href=\"" . $urlPrefix . $_REQUEST["page"] . "#{$aname}\">{$data}</a>"; } else { return "<a href=\"#{$aname}\">{$data}</a>"; } }
function wikiplugin_cclite($data, $params) { global $prefs, $user; $userlib = TikiLib::lib('user'); $smarty = TikiLib::lib('smarty'); $headerlib = TikiLib::lib('header'); global $cclitelib; require_once 'lib/payment/cclitelib.php'; if (empty($user)) { return '{REMARKSBOX(type=note, title=Cclite)}' . tra('You need to be logged in to view this information.') . '{REMARKSBOX}'; } $default = array('mode' => 'summary', 'registry' => ''); if (is_array($default['registry']) && !empty($default['registry'])) { $default['registry'] = $default['registry'][0]; } $params = array_merge($default, $params); switch ($params['mode']) { case 'recent': $result = $cclitelib->cclite_send_request('recent'); break; case 'summary': default: $result = $cclitelib->cclite_send_request('summary'); break; } //$r = $cclitelib->cclite_send_request('logoff'); $result = '<em>In development...</em><br />' . $result; $smarty->assign('wp_cclite_result', $result); return '~np~' . $smarty->fetch('wiki-plugins/wikiplugin_cclite.tpl') . '~/np~'; }
function module_user_tasks($mod_reference, $module_params) { global $user, $tasklib, $tikilib, $smarty, $tiki_p_tasks; include_once('lib/tasks/tasklib.php'); if ($user && isset($tiki_p_tasks) && $tiki_p_tasks == 'y') { if (isset($_REQUEST["modTasksDel"])) { foreach (array_keys($_REQUEST["modTasks"]) as $task) { $tasklib->mark_task_as_trash($task, $user); } } if (isset($_REQUEST["modTasksCom"])) { foreach (array_keys($_REQUEST["modTasks"]) as $task) { $tasklib->mark_complete_task($task, $user); } } if (isset($_REQUEST["modTasksSave"])) { $task = $tasklib->get_default_new_task($user); if (strlen($_REQUEST["modTasksTitle"]) > 2) { $tasklib->new_task($user, $user, null, null, date('U'), array('title' => $_REQUEST["modTasksTitle"])); } else { $smarty->assign('msg', tra("The task title must have at least 3 characters")); $smarty->display("error.tpl"); die; } } $smarty->assign('ownurl', $_SERVER["REQUEST_URI"]); $modTasks = $tasklib->list_tasks($user, 0, -1, null, 'priority_desc', true, false, true, false); $smarty->assign('modTasks', $modTasks['data']); $smarty->clear_assign('tpl_module_title'); } }
function module_login_box_info() { return array( 'name' => tra('Log In'), 'description' => tra('Log-in box'), 'prefs' => array(), 'documentation' => 'Module login_box', 'params' => array( 'input_size' => array( 'name' => tra('Input size'), 'description' => tra('Number of characters for username and password input fields.'), 'filter' => 'int' ), 'mode' => array( 'name' => tra('Mode'), 'description' => tra('Display mode: module, header or popup. Leave empty for module mode'), ), 'register' => array( 'name' => tra('Show Register'), 'description' => tra('Show the register link') . ' (y/n)', 'filter' => 'alpha', ), 'forgot' => array( 'name' => tra('Show I Forgot'), 'description' => tra('Show the "I forgot my password" link') . ' (y/n)', 'filter' => 'alpha', ), 'remember' => array( 'name' => tra('Show Remember me'), 'description' => tra('Show the "Remember me" checkbox') . ' (y/n)', 'filter' => 'alpha', ), ) ); }
function module_freetags_current($mod_reference, $module_params) { global $user, $page, $smarty; global $freetaglib; include_once 'lib/freetag/freetaglib.php'; $objectperms = Perms::get(array('type' => 'wiki page', 'object' => $page)); if (! empty($page) && $objectperms->view) { if ($objectperms->edit && $objectperms->freetags_tag) { if (isset($_POST['mod_add_tags'])) { $freetaglib->tag_object($user, $page, 'wiki page', $_POST['tags']); header("Location: {$_SERVER['REQUEST_URI']}"); exit; } $smarty->assign('addFreetags', "y"); $canTag = true; } else { $canTag = false; } $smarty->assign('tpl_module_title', tra('Freetags')); $currenttags = $freetaglib->get_tags_on_object($page, 'wiki page'); if (count($currenttags['data']) || $canTag) { $smarty->assign('modFreetagsCurrent', $currenttags); } } }
function wikiplugin_registermemberpayment_info() { require_once 'lib/wiki-plugins/wikiplugin_memberpayment.php'; $infoFromParent = wikiplugin_memberpayment_info(); return array('name' => tra('Register Member Payment'), 'documentation' => 'PluginRegisterMemberPayment', 'validate' => 'all', 'description' => tra('Register and make a member payment at the same time'), 'prefs' => array('wikiplugin_registermemberpayment', 'payment_feature'), 'body' => tra('NA'), 'iconname' => 'money', 'introduced' => 9.1, 'params' => array_merge($infoFromParent['params'], array('fixedperiods' => array('required' => false, 'name' => tra('Fixed Periods'), 'description' => tra('Give specific periods that can be chosen with a dropdown list. Example:') . " <code>name:value;name:value;value;value;</code>", 'since' => '9.1', 'filter' => 'text', 'default' => 'Number of periods:')))); }
function evaluate($element) { $default = 0; $allowed = array('object', 'list'); if ($extra = $element->getExtraValues($allowed)) { $this->error(tr('Unexpected values: %0', implode(', ', $extra))); } $object = $element->object; if (!$object || count($object) != 2) { $this->error(tra('Item must be provided and contain one argument: type, object-id')); } $type = $this->evaluateChild($object[0]); $object = $this->evaluateChild($object[1]); $list = $element->list; if (!$list || count($list) == 0) { $this->error(tra('List must be provided and contain at least one argument: category IDs')); } $categlib = TikiLib::lib('categ'); $categories = $categlib->get_object_categories($type, $object, -1, false); $score = 0; foreach ($list as $entry) { if (in_array($entry, $categories)) { ++$score; } } return $score; }