function getDocument($objectId, Search_Type_Factory_Interface $typeFactory) { $filegallib = Tikilib::lib('filegal'); $file = $filegallib->get_file_info($objectId, true, false); $data = array('title' => $typeFactory->sortable(empty($file['name']) ? $file['filename'] : $file['name']), 'language' => $typeFactory->identifier('unknown'), 'creation_date' => $typeFactory->timestamp($file['created']), 'modification_date' => $typeFactory->timestamp($file['lastModif']), 'contributors' => $typeFactory->multivalue(array_unique(array($file['author'], $file['user'], $file['lastModifUser']))), 'description' => $typeFactory->plaintext($file['description']), 'filename' => $typeFactory->identifier($file['filename']), 'filetype' => $typeFactory->sortable(preg_replace('/^([\\w-]+)\\/([\\w-]+).*$/', '$1/$2', $file['filetype'])), 'filesize' => $typeFactory->plaintext($file['filesize']), 'gallery_id' => $typeFactory->identifier($file['galleryId']), 'file_comment' => $typeFactory->plaintext($file['comment']), 'file_content' => $typeFactory->plaintext($file['search_data']), 'parent_object_type' => $typeFactory->identifier('file gallery'), 'parent_object_id' => $typeFactory->identifier($file['galleryId']), 'parent_view_permission' => $typeFactory->identifier('tiki_p_download_files')); return $data; }
function wikiplugin_friend($data, $params) { extract($params, EXTR_SKIP); global $user; if (empty($other_user)) { return; } if (empty($add_button_text)) { $add_button_text = tra("Add to Friend Network"); } if (empty($remove_button_text)) { $remove_button_text = tra("Remove from Friend Network"); } $relationlib = Tikilib::lib('relation'); $is_friend = $relationlib->get_relation_id("tiki.friend.follow", "user", $user, "user", $other_user); if ($is_friend) { $action = 'remove'; } else { $action = 'add'; } $smarty = TikiLib::lib('smarty'); $smarty->assign('add_button_text', $add_button_text); $smarty->assign('remove_button_text', $remove_button_text); $smarty->assign('userwatch', $other_user); $smarty->assign('action', $action); return $smarty->fetch('wiki-plugins/wikiplugin_friend.tpl'); }
function wikiplugin_favorite($data, $params) { $smarty = TikiLib::lib('smarty'); if ($params['objectType'] == 'usertracker') { $objectType = 'trackeritem'; $objectId = 0; if ($userid = Tikilib::lib('tiki')->get_user_id($params['objectId'])) { $tracker = TikiLib::lib('user')->get_usertracker($userid); if ($tracker && $tracker['usersTrackerId']) { $objectId = TikiLib::lib('trk')->get_item_id($tracker['usersTrackerId'], $tracker['usersFieldId'], $params['objectId']); } } } else { $objectType = $params['objectType']; $objectId = $params['objectId']; } $smarty->assign('wikiplugin_favorite_objectId', urlencode($objectId)); $smarty->assign('wikiplugin_favorite_objectType', urlencode($objectType)); $ret = $smarty->fetch('wiki-plugins/wikiplugin_favorite.tpl'); return $ret; }
protected function getPage($message, $routing = false) { $page = $message->getSubject(); $wikilib = Tikilib::lib('wiki'); $page = $wikilib->remove_badchars($page); if ($this->namespace) { return $wikilib->include_namespace($page, $this->namespace); } elseif ($routing) { if ($route = $this->getRoute($message)) { $nsName = $wikilib->get_namespace($route['structName']); if (!empty($nsName)) { return $wikilib->include_namespace($page, $nsName); } } } return $page; }
/** * @param $focus * @param string $view * @return array */ function focusNext($focus, $view = 'month') { $nbMonths = array('day' => 0, 'week' => 0, 'month' => 1, 'bimester' => 2, 'trimester' => 3, 'quarter' => 4, 'semester' => 6, 'year' => 12); $nbDays = array('day' => 1, 'week' => 7, 'month' => 0, 'bimester' => 0, 'trimester' => 0, 'quarter' => 0, 'semester' => 0, 'year' => 0); $next = $focus; $next['day'] += $nbDays[$view]; if ($next['month'] + $nbMonths[$view] > 12) { $next['month'] = ($next['month'] - 1 + $nbMonths[$view]) % 12 + 1; $next['year'] += 1; } else { $next['month'] += $nbMonths[$view]; } $next['daysInMonth'] = Date_Calc::daysInMonth($next['month'], $next['year']); if ($next['day'] > $next['daysInMonth']) { $next['day'] = $next['daysInMonth']; } $next['date'] = Tikilib::make_time(0, 0, 0, $next['month'], $next['day'], $next['year']); $next = $this->infoDate($next['date']); // get back real day, month, year return $next; }
/** * user cdn and feature multi_cdn see r46854 * @param string $file * @param string $rank * @return string $file */ function convert_cdn($file, $rank = null) { global $prefs, $tikiroot; // using this method, also reverse proxy / ssl offloading will continue to work $httpScheme = Tikilib::httpScheme(); $https_mode = $httpScheme == 'https' ? true : false; $cdn_ssl_uri = array_filter(preg_split('/\\s+/', $prefs['tiki_cdn_ssl'])); $cdn_uri = array_filter(preg_split('/\\s+/', $prefs['tiki_cdn'])); if ($https_mode && !empty($cdn_ssl_uri)) { $cdn_pref =& $cdn_ssl_uri; } elseif (!empty($cdn_uri)) { $cdn_pref =& $cdn_uri; } // feature multi_cdn see r46854 - quote from commit: // filename hash is used to select/assign one CDN URI from the list. // It ensure a same file will always point/use the same CDN and ensure proper caching. if (!empty($cdn_pref) && 'http' != substr($file, 0, 4) && $rank !== 'dynamic') { $index = hexdec(hash("crc32b", $file)) % count($cdn_pref); $file = $cdn_pref[$index] . $tikiroot . $file; } return $file; }
} } else { include_once 'lib/wiki-plugins/wikiplugin_split.php'; list($real_start, $real_len) = wikiplugin_split_cell($info['data'], $_REQUEST['pos'], $_REQUEST['cell']); } if ($edit[strlen($edit) - 1] !== "\n") { $edit .= "\r\n"; } $edit = substr($info['data'], 0, $real_start) . $edit . substr($info['data'], $real_start + $real_len); } if (isset($_REQUEST['jisonWyisywg']) && $_REQUEST['jisonWyisywg'] == 'true' && $prefs['feature_jison_wiki_parser'] == 'y' && $prefs['feature_wysiwyg'] === 'y') { $parser = new JisonParser_Html_Handler(); print_r($edit); $edit = $parser->parse($edit); print_r($edit); print_r(Tikilib::getOne('select data from tiki_pages where pageName = ?', array($page))); die; } else { if ($_SESSION['wysiwyg'] === 'y' && $prefs['wysiwyg_wiki_parsed'] === 'y' && $prefs['wysiwyg_ckeditor'] === 'y') { $edit = $editlib->partialParseWysiwygToWiki($edit); } } $tikilib->update_page($_REQUEST["page"], $edit, $_REQUEST["comment"], $user, $tikilib->get_ip_address(), $description, $minor, $pageLang, $is_html, $hash, null, $_REQUEST['wysiwyg'], $wiki_authors_style); $info_new = $tikilib->get_page_info($page); // Handle translation bits if ($prefs['feature_multilingual'] === 'y' && !$minor) { global $multilinguallib; include_once "lib/multilingual/multilinguallib.php"; $tikilib->cache_page_info = array(); if ($editlib->isUpdateTranslationMode()) { if ($editlib->aTranslationWasSavedAs('complete')) {
<?php // $Header: /cvsroot/tikiwiki/tiki/commxmlrpc.php,v 1.14.2.2 2005/08/18 09:13:33 mose Exp $ // Copyright (c) 2002-2005, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. // All Rights Reserved. See copyright.txt for details and a complete list of authors. // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. # $Header: /cvsroot/tikiwiki/tiki/commxmlrpc.php,v 1.14.2.2 2005/08/18 09:13:33 mose Exp $ include_once "lib/init/initlib.php"; include_once 'db/tiki-db.php'; include_once 'lib/tikilib.php'; include_once 'lib/userslib.php'; include_once "XML/Server.php"; include_once 'lib/commcenter/commlib.php'; $tikilib = new Tikilib($dbTiki); $userlib = new Userslib($dbTiki); if ($tikilib->get_preference("feature_comm", 'n') != 'y') { die; } $map = array("sendPage" => array("function" => "sendPage"), "sendArticle" => array("function" => "sendArticle")); $s = new XML_RPC_Server($map); /* Validates the user and returns user information */ function sendPage($params) { // Get the page and store it in received_pages global $tikilib, $userlib, $commlib; $pp = $params->getParam(0); $site = $pp->scalarval(); $pp = $params->getParam(1); $username = $pp->scalarval(); $pp = $params->getParam(2); $password = $pp->scalarval();
/** * Transform a last period to a 2 dates * */ public function period2dates($when) { global $prefs; $tikilib = TikiLib::lib('tiki'); $now = $tikilib->now; $sec = TikiLib::date_format("%s", $now); $min = TikiLib::date_format("%i", $now); $hour = TikiLib::date_format("%H", $now); $day = TikiLib::date_format("%d", $now); $month = TikiLib::date_format("%m", $now); $year = TikiLib::date_format("%Y", $now); switch ($when) { case 'lasthour': $begin = $now - 60 * 60; break; case 'day': $begin = TikiLib::make_time(0, 0, 0, $month, $day, $year); break; case 'lastday': $begin = Tikilib::make_time($hour - 24, $min, $sec, $month, $day, $year); break; case 'week': $iweek = TikiLib::date_format("%w", $now); // 0 for Sunday... $calendarlib = TikiLib::lib('calendar'); $firstDayofWeek = $calendarlib->firstDayofWeek(); $iweek -= $firstDayofWeek; if ($iweek < 0) { $iweek += 7; } $begin = TikiLib::make_time(0, 0, 0, $month, $day - $iweek, $year); break; case 'lastweek': $begin = Tikilib::make_time($hour, $min, $sec, $month, $day - 7, $year); break; case 'month': $begin = TikiLib::make_time(0, 0, 0, $month, 1, $year); break; case 'lastmonth': $begin = TikiLib::make_time($hour, $min, $sec, $month - 1, $day, $year); break; case 'year': $begin = TikiLib::make_time(0, 0, 0, 1, 1, $year); break; case 'lastyear': $begin = TikiLib::make_time($hour, $min, $sec, $month, $day, $year - 1); break; default: $begin = $now; break; } return array((int) $begin, (int) $now); }
<?php # $Header: /cvsroot/tikiwiki/tiki/xmlrpc.php,v 1.18.2.4 2005/11/15 14:57:50 mose Exp $ include_once "lib/init/initlib.php"; require_once 'db/tiki-db.php'; require_once 'lib/tikilib.php'; require_once 'lib/userslib.php'; require_once "XML/Server.php"; include_once 'lib/blogs/bloglib.php'; $tikilib = new Tikilib($dbTiki); $userlib = new Userslib($dbTiki); if ($tikilib->get_preference("feature_xmlrpc", 'n') != 'y') { die; } $map = array("blogger.newPost" => array("function" => "newPost"), "blogger.getUserInfo" => array("function" => "getUserInfo"), "blogger.getPost" => array("function" => "getPost"), "blogger.editPost" => array("function" => "editPost"), "blogger.deletePost" => array("function" => "deletePost"), "blogger.getRecentPosts" => array("function" => "getRecentPosts"), "blogger.getUserInfo" => array("function" => "getUserInfo"), "blogger.getUsersBlogs" => array("function" => "getUserBlogs")); $s = new XML_RPC_Server($map); function check_individual($user, $blogid, $permName) { global $userlib; // If the user is admin he can do everything if ($userlib->user_has_permission($user, 'tiki_p_blog_admin')) { return true; } // If no individual permissions for the object then ok if (!$userlib->object_has_one_permission($blogid, 'blog')) { return true; } // If the object has individual permissions then check // Now get all the permissions that are set for this type of permissions 'image gallery' if ($userlib->object_has_permission($user, $blogId, 'blog', $permName)) { return true;
/** * Transform a last period to a 2 dates * */ function period2dates($when) { global $tikilib, $prefs; $now = $tikilib->now; $sec = TikiLib::date_format("%s", $now); $min = TikiLib::date_format("%i", $now); $hour = TikiLib::date_format("%H", $now); $day = TikiLib::date_format("%d", $now); $month = TikiLib::date_format("%m", $now); $year = TikiLib::date_format("%Y", $now); switch ($when) { case 'lasthour': $begin = $now - 60 * 60; break; case 'day': $begin = TikiLib::make_time(0, 0, 0, $month, $day, $year); break; case 'lastday': $begin = Tikilib::make_time($hour - 24, $min, $sec, $month, $day, $year); break; case 'week': $iweek = TikiLib::date_format("%w", $now); // 0 for Sunday... if ($prefs['calendar_firstDayofWeek'] == 'user') { $firstDayofWeek = (int) tra('First day of week: Sunday (its ID is 0) - translators you need to localize this string!'); if ($firstDayofWeek < 1 || $firstDayofWeek > 6) { $firstDayofWeek = 0; } } else { $firstDayofWeek = $prefs['calendar_firstDayofWeek']; } $iweek -= $firstDayofWeek; if ($iweek < 0) { $iweek += 7; } $begin = TikiLib::make_time(0, 0, 0, $month, $day - $iweek, $year); break; case 'lastweek': $begin = Tikilib::make_time($hour, $min, $sec, $month, $day - 7, $year); break; case 'month': $begin = TikiLib::make_time(0, 0, 0, $month, 1, $year); break; case 'lastmonth': $begin = TikiLib::make_time($hour, $min, $sec, $month - 1, $day, $year); break; case 'year': $begin = TikiLib::make_time(0, 0, 0, 1, 1, $year); break; case 'lastyear': $begin = TikiLib::make_time($hour, $min, $sec, $month, $day, $year - 1); break; default: $begin = $now; break; } return array((int) $begin, (int) $now); }