예제 #1
1
 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);
 }
예제 #2
0
 /**
  * @covers TikiLib::parse_data
  * @dataProvider provider
  */
 public function testWikiParser($input, $output, $options = array())
 {
     global $prefs;
     $prefs['feature_page_title'] = 'y';
     $prefs['feature_wiki_paragraph_formatting'] = 'n';
     $prefs['pass_chr_special'] = 'n';
     $o = new TikiLib();
     $this->assertEquals($output, $o->parse_data($input, $options));
 }
예제 #3
0
function getSubGraph($params)
{
    global $wikilib, $dbTiki;
    $nodeName = $params->getParam(0);
    $nodeName = $nodeName->scalarVal();
    $depth = $params->getParam(1);
    $depth = $depth->scalarVal();
    $nodes = array();
    $passed = array($nodeName => true);
    $queue = array($nodeName);
    $i = 0;
    $tikilib = new TikiLib($dbTiki);
    $existing_color = $tikilib->get_preference("wiki_3d_existing_page_color", '#00BB88');
    $missing_color = $tikilib->get_preference("wiki_3d_missing_page_color", '#FF6666');
    while ($i <= $depth && sizeof($queue) > 0) {
        $nextQueue = array();
        foreach ($queue as $nodeName) {
            $neighbours = $wikilib->wiki_get_neighbours($nodeName);
            $temp_max = sizeof($neighbours);
            for ($j = 0; $j < $temp_max; $j++) {
                if (!isset($passed[$neighbours[$j]])) {
                    $nextQueue[] = $neighbours[$j];
                    $passed[$neighbours[$j]] = true;
                }
                $neighbours[$j] = new XML_RPC_Value($neighbours[$j]);
            }
            $node = array();
            $base_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
            $base_url = preg_replace('/\\/tiki-wiki3d_xmlrpc.php.*$/', '', $base_url);
            if ($wikilib->page_exists($nodeName)) {
                $color = $existing_color;
                $actionUrl = "{$base_url}/tiki-index.php?page={$nodeName}";
            } else {
                $color = $missing_color;
                $actionUrl = "{$base_url}/tiki-editpage.php?page={$nodeName}";
            }
            $node['neighbours'] = new XML_RPC_Value($neighbours, "array");
            if (!empty($color)) {
                $node['color'] = new XML_RPC_Value($color, "string");
            }
            $node['actionUrl'] = new XML_RPC_Value($actionUrl, "string");
            $nodes[$nodeName] = new XML_RPC_Value($node, "struct");
        }
        $i++;
        $queue = $nextQueue;
    }
    $response = array("graph" => new XML_RPC_Value($nodes, "struct"));
    return new XML_RPC_Response(new XML_RPC_Value($response, "struct"));
}
예제 #4
0
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;
}
예제 #5
0
/**
 * @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;
}
예제 #6
0
파일: Url.php 프로젝트: rjsmelo/tiki
 function renderOutput($context = array())
 {
     $smarty = TikiLib::lib('smarty');
     $url = $this->getConfiguration('value');
     if (empty($url) || $context['list_mode'] == 'csv' || $this->getOption('linkToURL') == 1) {
         return $url;
     } elseif ($this->getOption('linkToURL') == 2) {
         // Site title as link
         $smarty->loadPlugin('smarty_function_object_link');
         return smarty_function_object_link(array('type' => 'external', 'id' => $url), $smarty);
     } elseif ($this->getOption('linkToURL') == 0) {
         // URL as link
         $parsedUrl = trim(str_replace('<br />', '', TikiLib::lib('tiki')->parse_data($url)));
         if ($parsedUrl != $url) {
             return $parsedUrl;
         }
         $smarty->loadPlugin('smarty_function_object_link');
         return smarty_function_object_link(array('type' => 'external', 'id' => $url, 'title' => $url), $smarty);
     } elseif ($this->getOption('linkToURL') == 3) {
         // URL + site title
         $smarty->loadPlugin('smarty_function_object_link');
         return smarty_function_object_link(array('type' => 'external_extended', 'id' => $url), $smarty);
     } elseif ($this->getOption('linkToURL') == 4) {
         // URL as link
         $smarty->loadPlugin('smarty_function_object_link');
         return smarty_function_object_link(array('type' => 'external', 'id' => $url, 'title' => tr($this->getOption('other'))), $smarty);
     } else {
         return $url;
     }
 }
예제 #7
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $profileName = $input->getArgument('profile');
     $repository = $input->getArgument('repository');
     $force = $input->getOption('force');
     $profile = \Tiki_Profile::fromNames($repository, $profileName);
     if (!$profile) {
         $output->writeln('<error>Profile not found.</error>');
         return;
     }
     $tikilib = \TikiLib::lib('tiki');
     $installer = new \Tiki_Profile_Installer();
     $isInstalled = $installer->isInstalled($profile);
     if ($isInstalled && $force) {
         $installer->forget($profile);
         $isInstalled = false;
     }
     if (!$isInstalled) {
         $transaction = $tikilib->begin();
         if ($installer->install($profile)) {
             $transaction->commit();
             $output->writeln('Profile applied.');
         } else {
             $output->writeln("<error>Installation failed:</error>");
             foreach ($installer->getFeedback() as $error) {
                 $output->writeln("<error>{$error}</error>");
             }
         }
     } else {
         $output->writeln('<info>Profile was already applied. Nothing happened.</info>');
     }
 }
예제 #8
0
function smarty_function_favorite($params, $smarty)
{
    global $prefs, $user;
    // Disabled, do nothing
    if (empty($user) || $prefs['user_favorites'] != 'y') {
        return;
    }
    $servicelib = TikiLib::lib('service');
    $smarty = TikiLib::lib('smarty');
    $smarty->loadPlugin('smarty_modifier_escape');
    $url = $servicelib->getUrl(array('controller' => 'favorite', 'action' => 'toggle', 'type' => $params['type'], 'object' => $params['object']));
    $url = smarty_modifier_escape($url, 'url');
    $e_user = smarty_modifier_escape($user);
    if (isset($params['label'])) {
        $label = $params['label'];
    } else {
        $label = tr('Favorite');
    }
    if (isset($params['button_classes'])) {
        $button_classes = $params['button_classes'];
    } else {
        $button_classes = "btn btn-default";
    }
    return '<a class="' . $button_classes . ' favorite-toggle" href="' . $url . '" data-key="favorite_' . $e_user . '"> ' . $label . '</a>';
}
예제 #9
0
function wikiplugin_shopperinfo($data, $params)
{
    global $user;
    $smarty = TikiLib::lib('smarty');
    if ($user && $params['showifloggedin'] != 'y' || empty($params['values'])) {
        return '';
    }
    if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['shopperinfo'])) {
        foreach ($params['values'] as $v) {
            // Check all filled in
            if (empty($_POST[$v])) {
                $access = TikiLib::lib('access');
                $access->redirect($_SERVER['REQUEST_URI'], tr('Please fill in all fields'));
                die;
            }
        }
        foreach ($params['values'] as $v) {
            $_SESSION['shopperinfo'][$v] = $_POST[$v];
        }
    }
    $values = array();
    foreach ($params['values'] as $k => $v) {
        $t['name'] = $v;
        if (!empty($_SESSION['shopperinfo'][$v])) {
            $t['current'] = $_SESSION['shopperinfo'][$v];
        }
        if (!empty($params['labels'][$k])) {
            $t['label'] = $params['labels'][$k];
        }
        $values[] = $t;
    }
    $smarty->assign('values', $values);
    $form = $smarty->fetch('wiki-plugins/wikiplugin_shopperinfo.tpl');
    return $form;
}
예제 #10
0
/**
 * @param $mod_reference
 * @param $module_params
 */
function module_top_quizzes($mod_reference, $module_params)
{
    $smarty = TikiLib::lib('smarty');
    $quizlib = TikiLib::lib('quiz');
    $ranking = $quizlib->list_quiz_sum_stats(0, $mod_reference["rows"], 'timesTaken_desc', '');
    $smarty->assign('modTopQuizzes', $ranking["data"]);
}
예제 #11
0
/**
 * @param $mod_reference
 * @param $module_params
 */
function module_top_active_blogs($mod_reference, $module_params)
{
    $smarty = TikiLib::lib('smarty');
    $bloglib = TikiLib::lib('blog');
    $ranking = $bloglib->list_blogs(0, $mod_reference["rows"], 'activity_desc', '');
    $smarty->assign('modTopActiveBlogs', $ranking["data"]);
}
예제 #12
0
 function execute($params)
 {
     $userlib = TikiLib::lib('user');
     $smarty = TikiLib::lib('smarty');
     $this->set_result_type(TPL_RESULT);
     $this->set_result_tpl('debug/tiki-debug_permissions.tpl');
     // Is regex to match against var name given?
     $p = explode(' ', trim($params));
     $mask = count($p) > 0 ? str_replace('$', '', trim($p[0])) : '';
     // Get list of all vars
     $tpl_vars = $smarty->getTemplateVars();
     // Get descriptions for all permissions
     $pd = $userlib->get_permissions();
     $descriptions = array();
     foreach ($pd['data'] as $p) {
         $descriptions[$p['permName']] = $p['permDesc'];
     }
     // convert to vector of names, filter permissions only
     $perms = array();
     $len = strlen($mask);
     foreach ($tpl_vars as $key => $val) {
         if ((!$len || $len && preg_match('/' . $mask . '/', $key)) && preg_match('/tiki_p_/', $key)) {
             $perms[] = array('name' => $key, 'value' => $val, 'description' => isset($descriptions[$key]) ? $descriptions[$key] : 'No description');
         }
     }
     return $perms;
 }
예제 #13
0
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' ? "&amp;bl" : "";
            // $bestLang = $prefs['feature_best_language'] == 'y' ? "&amp;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>";
    }
}
예제 #14
0
파일: Category.php 프로젝트: rjsmelo/tiki
 public static function export(Tiki_Profile_Writer $writer, $categId, $deep, $includeObjectCallback)
 {
     $categlib = TikiLib::lib('categ');
     if (!($info = $categlib->get_category($categId))) {
         return false;
     }
     $items = array();
     foreach ($categlib->get_category_objects($categId) as $row) {
         if ($includeObjectCallback($row['type'], $row['itemId'])) {
             $items[] = array($row['type'], $writer->getReference($row['type'], $row['itemId']));
         }
     }
     $data = array('name' => $info['name']);
     if (!empty($info['parentId'])) {
         $data['parent'] = $writer->getReference('category', $info['parentId']);
     }
     if (!empty($items)) {
         $data['items'] = $items;
     }
     $writer->addObject('category', $categId, $data);
     if ($deep) {
         $descendants = $categlib->get_category_descendants($categId);
         array_shift($descendants);
         foreach ($descendants as $children) {
             self::export($writer, $children, $deep, $includeObjectCallback);
         }
     }
     return true;
 }
예제 #15
0
 function __toString()
 {
     $this->applyOptions();
     $smarty = \TikiLib::lib('smarty');
     $smarty->assign('control', ['field' => $this->fieldName, 'options' => $this->options, 'values' => array_fill_keys($this->values, true)]);
     return $smarty->fetch('filter_control/inline_checkboxes.tpl');
 }
예제 #16
0
function wikiplugin_wysiwyg($data, $params)
{
    global $wysiwyglib;
    include_once 'lib/ckeditor_tiki/wysiwyglib.php';
    // TODO refactor: defaults for plugins?
    $defaults = array();
    $plugininfo = wikiplugin_wysiwyg_info();
    foreach ($plugininfo['params'] as $key => $param) {
        $defaults["{$key}"] = $param['default'];
    }
    $params = array_merge($defaults, $params);
    $html = TikiLib::lib('tiki')->parse_data($data, array('is_html' => true));
    global $tiki_p_edit, $page, $prefs;
    static $execution = 0;
    if ($tiki_p_edit === 'y') {
        $class = "wp_wysiwyg";
        $exec_key = $class . '_' . ++$execution;
        $style = " style='min-width:{$params['width']};min-height:{$params['height']}'";
        $params['section'] = empty($params['section']) ? 'wysiwyg_plugin' : $params['section'];
        $params['_wysiwyg'] = 'y';
        $params['is_html'] = true;
        //$params['comments'] = true;
        $ckoption = $wysiwyglib->setUpEditor(true, $exec_key, $params, '', false);
        $html = "<div id='{$exec_key}' class='{$class}'{$style}>" . $html . '</div>';
        $js = '$("#' . $exec_key . '").wysiwygPlugin("' . $execution . '", "' . $page . '", ' . $ckoption . ')';
        TikiLib::lib('header')->add_jq_onready($js);
    }
    return $html;
}
예제 #17
0
파일: Article.php 프로젝트: rjsmelo/tiki
 public static function export(Tiki_Profile_Writer $writer, $id, $withTopic = false, $withType = false)
 {
     $artlib = TikiLib::lib('art');
     $info = $artlib->get_article($id, false);
     if (!$info) {
         return false;
     }
     $bodypage = "article_{$id}_body";
     $writer->writeExternal($bodypage, $writer->getReference('wiki_content', $info['body']));
     $out = array('title' => $info['title'], 'author' => $info['authorName'], 'body' => "wikicontent:{$bodypage}", 'type' => $writer->getReference('article_type', $info['type']), 'publication_date' => $info['publishDate'], 'expiration_date' => $info['expireDate'], 'topline' => $info['topline'], 'subtitle' => $info['subtitle'], 'link_to' => $info['linkto'], 'language' => $info['lang']);
     if ($info['topicId']) {
         if ($withTopic) {
             Tiki_Profile_InstallHandler_ArticleTopic::export($writer, $info['topicId']);
         }
         $out['topic'] = $writer->getReference('article_topic', $info['topicId']);
     }
     if ($info['heading']) {
         $headerpage = "article_{$id}_heading";
         $writer->writeExternal($headerpage, $writer->getReference('wiki_content', $info['heading']));
         $out['heading'] = "wikicontent:{$headerpage}";
     }
     $out = array_filter($out);
     $writer->addObject('article', $id, $out);
     if ($withType) {
         Tiki_Profile_InstallHandler_ArticleType::export($writer, $info['type']);
     }
     return true;
 }
예제 #18
0
 private function render($controller, $action, $output)
 {
     if (isset($output['FORWARD'])) {
         $loc = $_SERVER['PHP_SELF'];
         $arguments = $output['FORWARD'];
         header("Location: {$loc}?" . http_build_query($arguments, '', '&'));
         exit;
     }
     $smarty = TikiLib::lib('smarty');
     $template = "{$controller}/{$action}.tpl";
     //if template doesn't exists, simply return the array given from the action
     if ($smarty->templateExists($template) == false) {
         return json_encode($output);
     }
     $access = TikiLib::lib('access');
     foreach ($output as $key => $value) {
         $smarty->assign($key, $value);
     }
     if ($access->is_xml_http_request()) {
         $headerlib = TikiLib::lib('header');
         $content = $smarty->fetch($template);
         $content .= $headerlib->output_js();
         return $content;
     } else {
         $smarty->assign('mid', $template);
         return $smarty->fetch('tiki.tpl');
     }
 }
예제 #19
0
/**
 * @param $mod_reference
 * @param $module_params
 */
function module_top_files($mod_reference, $module_params)
{
    $smarty = TikiLib::lib('smarty');
    $filegallib = TikiLib::lib('filegal');
    $ranking = $filegallib->list_files(0, $mod_reference["rows"], 'hits_desc', '');
    $smarty->assign('modTopFiles', $ranking["data"]);
}
예제 #20
0
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~';
}
예제 #21
0
/**
 * \brief Smarty plugin to add variable dump to debug console log
 * Usage format {var_dump var="var_name_2_dump"}
 *
 * Adapted to do more than string for tiki 5
 */
function smarty_function_var_dump($params, $smarty)
{
    global $debugger;
    require_once 'lib/debug/debugger.php';
    $smarty = TikiLib::lib('smarty');
    $v = $params['var'];
    if (!empty($v)) {
        $tmp = $smarty->getTemplateVars();
        if (is_array($tmp) && isset($tmp["{$v}"])) {
            if (is_string($tmp[$v])) {
                $debugger->msg("Smarty var_dump(" . $v . ') = ' . print_r($tmp[$v], true));
            } else {
                ob_start();
                var_dump($tmp[$v]);
                $d = ob_get_clean();
                $debugger->msg("Smarty var_dump(" . $v . ') = ' . $d);
            }
        } else {
            $debugger->msg("Smarty var_dump(" . $v . "): Variable not found");
        }
    } else {
        $debugger->msg("Smarty var_dump: Parameter 'var' not specified");
    }
    return '<!-- var_dump(' . $v . ') -->';
}
예제 #22
0
 private function doUncategorize($categId, $type, $id)
 {
     $categlib = TikiLib::lib('categ');
     if ($oId = $categlib->is_categorized($type, $id)) {
         $categlib->uncategorize($oId, $categId);
     }
 }
예제 #23
0
function smarty_function_fileinfo($params, $smarty)
{
    if (!is_array($params) || !isset($params['_id']) || !isset($params['_field'])) {
        return;
    }
    $filegallib = TikiLib::lib('filegal');
    $params['_id'] = (int) $params['_id'];
    $infos = $filegallib->get_file($params['_id']);
    if (isset($infos[$params['_field']]) && $infos[$params['_field']] != '') {
        $return = $infos[$params['_field']];
    } elseif ($params['_field'] == 'name') {
        // Fallback to filename if there is no name for the specified file
        $return = $infos['filename'];
    } else {
        $return = '';
    }
    if (isset($params['_link'])) {
        global $prefs, $filegals_manager, $url_path;
        $key_type = substr($infos['filetype'], 0, 9);
        $tmp = '<a href="' . $url_path . 'tiki-download_file.php?fileId=' . $params['_id'] . '&amp;display"';
        if ($prefs['feature_shadowbox'] == 'y') {
            $tmp .= ' rel="shadowbox[' . htmlentities($params['_link']) . '];type=' . (in_array($key_type, array('image/png', 'image/jpe', 'image/gif')) ? 'img' : 'iframe') . '"';
        }
        $return = $tmp . '>' . $return . '</a>';
        unset($tmp);
    }
    return $return;
}
예제 #24
0
function wikiplugin_code($data, $params)
{
    global $prefs;
    static $code_count;
    $defaults = array('wrap' => '1', 'mediawiki' => '0', 'ishtml' => false);
    $params = array_merge($defaults, $params);
    extract($params, EXTR_SKIP);
    $code = trim($data);
    if ($mediawiki == '1') {
        return "<code>{$code}</code>";
    }
    $code = str_replace('&lt;x&gt;', '', $code);
    $code = str_replace('<x>', '', $code);
    $id = 'codebox' . ++$code_count;
    $boxid = " id=\"{$id}\" ";
    $out = $code;
    if (isset($colors) && $colors == '1') {
        // remove old geshi setting as it upsets codemirror
        unset($colors);
    }
    //respect wrap setting when Codemirror is off and set to wrap when Codemirror is on to avoid broken view while
    //javascript loads
    if (isset($prefs['feature_syntax_highlighter']) && $prefs['feature_syntax_highlighter'] == 'y' || $wrap == 1) {
        $pre_style = 'white-space:pre-wrap;' . ' white-space:-moz-pre-wrap !important;' . ' white-space:-pre-wrap;' . ' white-space:-o-pre-wrap;' . ' word-wrap:break-word;';
    }
    $out = (isset($caption) ? '<div class="codecaption">' . $caption . '</div>' : "") . '<pre class="codelisting" ' . (isset($colors) ? ' data-syntax="' . $colors . '" ' : '') . (isset($ln) ? ' data-line-numbers="' . $ln . '" ' : '') . (isset($wrap) ? ' data-wrap="' . $wrap . '" ' : '') . ' dir="' . (isset($rtl) && $rtl == 1 ? 'rtl' : 'ltr') . '" ' . (isset($pre_style) ? ' style="' . $pre_style . '"' : '') . $boxid . '>' . (TikiLib::lib('parser')->option['ck_editor'] || $ishtml ? $out : htmlentities($out, ENT_QUOTES, 'UTF-8')) . '</pre>';
    return $out;
}
예제 #25
0
 private function parse($content)
 {
     $content = "~np~{$content}~/np~";
     $parserlib = TikiLib::lib('parser');
     $options = array('protect_email' => false);
     return trim($parserlib->parse_data($content, $options));
 }
예제 #26
0
/**
 * @param $mod_reference
 * @param $module_params
 */
function module_who_is_there($mod_reference, $module_params)
{
    $tikilib = TikiLib::lib('tiki');
    $smarty = TikiLib::lib('smarty');
    $count = !isset($module_params['content']) || $module_params['content'] != 'list';
    $list = !isset($module_params['content']) || $module_params['content'] != 'count';
    $smarty->assign('count', $count);
    $smarty->assign('list', $list);
    if ($count) {
        $logged_users = $tikilib->count_sessions();
        $smarty->assign('logged_users', $logged_users);
    }
    if ($list) {
        $online_users = $tikilib->get_online_users();
        $smarty->assign_by_ref('online_users', $online_users);
    }
    if (isset($module_params['cluster']) && $module_params['cluster'] == 1) {
        $smarty->assign('cluster', true);
        if ($count) {
            $logged_cluster_users = $tikilib->count_cluster_sessions();
            $smarty->assign('logged_cluster_users', $logged_cluster_users);
        }
    } else {
        $smarty->assign('cluster', false);
    }
}
예제 #27
0
/**
 * @param $mod_reference
 * @param $module_params
 */
function module_random_pages($mod_reference, $module_params)
{
    $tikilib = TikiLib::lib('tiki');
    $pages = $tikilib->list_pages(0, $mod_reference["rows"], "random", '', '', true, true);
    $smarty = TikiLib::lib('smarty');
    $smarty->assign('modRandomPages', $pages["data"]);
}
예제 #28
0
 function grabContent($url)
 {
     $tikilib = TikiLib::lib('tiki');
     $client = $tikilib->get_http_client($url);
     $response = $tikilib->http_perform_request($client);
     // Obtain the URL after redirections
     $url = (string) $client->getUri();
     $html = $response->getBody();
     // Note: PHP Readability expects UTF-8 encoded content.
     // If your content is not UTF-8 encoded, convert it
     // first before passing it to PHP Readability.
     // Both iconv() and mb_convert_encoding() can do this.
     // If we've got Tidy, let's clean up input.
     // This step is highly recommended - PHP's default HTML parser
     // often doesn't do a great job and results in strange output.
     $html = $this->tidy($html);
     // give it to Readability
     global $prefs;
     if (is_file($prefs['page_content_fetch_readability'])) {
         require_once $prefs['page_content_fetch_readability'];
     }
     if (!class_exists('Readability')) {
         return false;
     }
     $readability = new Readability($html, $url);
     $result = $readability->init();
     if ($result) {
         $content = $this->tidy($readability->getContent()->innerHTML);
         $content = $this->replacePaths($content, $url);
         return array('title' => $readability->getTitle()->textContent, 'content' => $content);
     }
 }
예제 #29
0
function smarty_function_article($params, $smarty)
{
    $tikilib = TikiLib::lib('tiki');
    $artlib = TikiLib::lib('art');
    extract($params);
    if (empty($max)) {
        $max = 99;
    }
    // skip="x,y" will not print Xth and Yth items
    // useful to avoid default first items
    if (!empty($skip) && preg_match('/^\\d+(,\\d+)*$/', $skip)) {
        $skipped_items = explode(',', $skip);
        $skip = array();
        foreach ($skipped_items as $i) {
            $skip[$i] = 1;
        }
    } else {
        $skip = array();
    }
    $list_articles = $artlib->list_articles(0, $max, 'publishDate_desc', '', '', '', '', '', '', 1);
    $x = "";
    foreach ($list_articles['data'] as $article_data) {
        $x .= "<div class=\"articles\">";
        $x .= "<a href=\"tiki-read_article.php?articleId=" . $article_data['articleId'] . "\" class=\"article\">";
        $x .= $article_data['title'] . " - " . $tikilib->date_format('%d/%m/%Y', $article_data['publishDate']) . "</a></div>\n";
    }
    echo $x;
}
예제 #30
0
function module_zotero($mod_reference, $module_params)
{
	$zoterolib = TikiLib::lib('zotero');
	$smarty = TikiLib::lib('smarty');

	$smarty->assign('zotero_authorized', $zoterolib->is_authorized());
}