예제 #1
0
파일: dcslib.php 프로젝트: linuxwhy/tiki-1
 /**
  * @param $page
  * @param null $lang
  * @return string
  */
 private function get_content_from_page($page, $lang = null)
 {
     global $prefs;
     $info = $this->get_page_info($page);
     if ($prefs['feature_multilingual'] == 'y') {
         $multilinguallib = TikiLib::lib('multilingual');
         if ($lang && $info['lang'] && $lang != $info['lang']) {
             $bestLangPageId = $multilinguallib->selectLangObj('wiki page', $info['page_id'], $lang);
             if ($info['page_id'] != $bestLangPageId) {
                 $info = $this->get_page_info_from_id($bestLangPageId);
             }
         }
     }
     if ($info) {
         return TikiLib::htmldecode($info['data']);
     }
 }
function smarty_modifier_htmldecode($s)
{
    return TikiLib::htmldecode($s);
}
예제 #3
0
    $info = $tikilib->get_page_info($_REQUEST['page']);
    if (empty($info)) {
        $smarty->assign('msg', tra("Page cannot be found"));
        $smarty->display("error.tpl");
        die;
    }
    $name = $_REQUEST['page'];
    $type = "wiki page";
    $objId = $info['page_id'];
    $langpage = $info['lang'];
    $fullLangName = $langmapping[$langpage][0];
    $smarty->assign('languageName', $fullLangName);
    $cat_type = 'wiki page';
    $cat_objid = $name;
    $edit_data = $info['data'];
    $smarty->assign('pagedata', TikiLib::htmldecode($edit_data));
    if ($prefs['feature_translation_incomplete_notice'] == 'y') {
        $smarty->assign('translate_message', "^" . tra("Translation of this page is incomplete.") . "^\n\n");
    }
} else {
    if ($_REQUEST['id']) {
        $smarty->assign('msg', tra("Only wiki pages are supported."));
        $smarty->display("error.tpl");
        die;
    }
}
$smarty->assign('name', $name);
$smarty->assign('type', $type);
$smarty->assign('id', $objId);
include_once 'categorize_list.php';
if (isset($_REQUEST['langpage']) && !empty($_REQUEST['langpage']) && $_REQUEST['langpage'] != "NULL" && $langpage != $_REQUEST['langpage']) {
        header("location: tiki-view_blog.php?blogId={$blogId}");
        die;
    }
    $parsed_data = $tikilib->apply_postedit_handlers($edit_data);
    $parsed_data = $tikilib->parse_data($parsed_data);
    $smarty->assign('data', TikiLib::htmldecode($edit_data));
    if ($prefs['feature_freetags'] == 'y') {
        $smarty->assign('taglist', $_REQUEST["freetag_string"]);
    }
    $smarty->assign('title', isset($_REQUEST["title"]) ? $_REQUEST['title'] : '');
    $smarty->assign('parsed_data', $parsed_data);
}
if ($contribution_needed) {
    $smarty->assign('title', $_REQUEST["title"]);
    $smarty->assign('parsed_data', $tikilib->parse_data($_REQUEST['data']));
    $smarty->assign('data', TikiLib::htmldecode($_REQUEST['data']));
    if ($prefs['feature_freetags'] == 'y') {
        $smarty->assign('taglist', $_REQUEST["freetag_string"]);
    }
}
if ($tiki_p_blog_admin == 'y') {
    $blogsd = $bloglib->list_blogs(0, -1, 'created_desc', '');
    $blogs = $blogsd['data'];
} else {
    $blogs = $bloglib->list_blogs_user_can_post($user);
}
if (count($blogs) == 0) {
    $smarty->assign('msg', tra("You can't post in any blog maybe you have to create a blog first"));
    $smarty->display("error.tpl");
    die;
}
function wikiplugin_rss($data, $params)
{
    global $smarty;
    global $tikilib;
    global $dbTiki;
    global $rsslib;
    if (!isset($rsslib)) {
        include_once 'lib/rss/rsslib.php';
    }
    extract($params, EXTR_SKIP);
    if (!isset($max)) {
        $max = '10';
    }
    if (!isset($id)) {
        return tra('You need to specify a RSS Id');
    }
    if (!isset($date)) {
        $date = 0;
    }
    if (!isset($desc)) {
        $desc = 0;
    }
    if (!isset($author)) {
        $author = 0;
    }
    $ids = explode(':', $id);
    $repl = '';
    $items = array();
    foreach ($ids as $val) {
        if (!($rssdata = $rsslib->get_rss_module_content($val))) {
            $repl = tra('RSS Id incorrect:') . ' ' . $val;
        }
        $itemsrss = $rsslib->parse_rss_data($rssdata, $val);
        $items = array_merge($items, $itemsrss);
    }
    if (isset($items[0]) && $items[0]['isTitle'] == 'y') {
        $repl .= '<div class="wiki"><a target="_blank" href="' . $items[0]['link'] . '">' . TikiLib::htmldecode($items[0]['title']) . '</a></div><br />';
        $items = array_slice($items, 1);
    }
    usort($items, 'rss_sort');
    if (count($ids) > 1) {
        $items = array_slice($items, count($ids));
    }
    if (count($items) < $max) {
        $max = count($items);
    }
    $repl .= '<table class="normal">';
    for ($j = 0; $j < $max; $j++) {
        $repl .= '<tr><td class="heading"><a class="tableheading" target="_blank" href="' . $items[$j]['link'] . '"><b>' . TikiLib::htmldecode($items[$j]['title']) . '</b></a>';
        if ($author == 1 || $date == 1) {
            $repl_author = '';
            if ($author == 1 && isset($items[$j]['author']) && $items[$j]['author'] != '') {
                $repl_author .= $items[$j]['author'];
                if ($date == 1) {
                    $repl_author .= ', ';
                }
            }
            if ($date == 1 && isset($items[$j]['pubDate']) && $items[$j]['pubDate'] != '') {
                $repl_author .= '' . $items[$j]['pubDate'];
            }
            if ($repl_author != '') {
                $repl .= '&nbsp;&nbsp;&nbsp;(' . $repl_author . ')';
            }
        }
        $repl .= '</td></tr>';
        if ($desc == 1) {
            $repl .= '<tr><td class="even" colspan="2">' . TikiLib::htmldecode($items[$j]['description']) . '</td></tr>';
            $repl .= '</tr>';
        }
        if ($desc > 1) {
            $repl .= '<tr><td class="even" colspan="2">' . substr(strip_tags(TikiLib::htmldecode($items[$j]['description'])), 0, $desc) . ' <a class="wiki" href="' . $items[$j]['link'] . '">[[...]</a></td></tr>';
            $repl .= '</tr>';
        }
    }
    $repl .= '</table>';
    return $repl;
}
	include_once ('lib/freetag/freetaglib.php');
	$post_info['freetags'] = $freetaglib->get_tags_on_object($postId, "blog post");

	if ($blog_data['show_related'] == 'y' && !empty($post_info['freetags'])) {
		$post_info['related_posts'] = $bloglib->get_related_posts($postId, $blog_data['related_max']);
	}
}

if ($prefs['feature_categories'] == 'y') {
	$cat_type = 'blog post';
	$cat_objid = $postId;
	require_once('categorize_list.php');	
}
$smarty->assign('ownsblog', $ownsblog);
if ($post_info['wysiwyg'] !== 'y') {
	$post_info['data'] = TikiLib::htmldecode($post_info['data']);
}
$smarty->assign('postId', $postId);
$smarty->assign('blog_data', $blog_data);
$smarty->assign('blogId', $blogId);
$smarty->assign('headtitle', $post_info['title'] . ' : ' . $blog_data['title']);
$smarty->assign('title', $post_info['title'] . ' : ' . $blog_data['title']);
if (!isset($_REQUEST['offset'])) $_REQUEST['offset'] = 0;
if (!isset($_REQUEST['sort_mode'])) $_REQUEST['sort_mode'] = 'created_desc';
if (!isset($_REQUEST['find'])) $_REQUEST['find'] = '';
$smarty->assign('offset', $_REQUEST["offset"]);
$smarty->assign('sort_mode', $_REQUEST["sort_mode"]);
$smarty->assign('find', $_REQUEST["find"]);
$offset = $_REQUEST["offset"];
$sort_mode = $_REQUEST["sort_mode"];
$find = $_REQUEST["find"];
예제 #7
0
파일: Wiki.php 프로젝트: rjsmelo/tiki
 private function applyFilters()
 {
     global $tikilib;
     $default = TikiFilter::get(isset($this->info['defaultfilter']) ? $this->info['defaultfilter'] : 'xss');
     // Apply filters on the body
     $filter = isset($this->info['filter']) ? TikiFilter::get($this->info['filter']) : $default;
     $this->body = $filter->filter($this->body);
     if (!$this->parser->getOption('is_html')) {
         $noparsed = array('data' => array(), 'key' => array());
         //$this->striUnparsedBlock($this->body, $noparsed);
         $body = str_replace(array('<', '>'), array('&lt;', '&gt;'), $this->body);
         foreach ($noparsed['data'] as &$instance) {
             $instance = '~np~' . $instance . '~/np~';
         }
         unset($instance);
         $this->body = str_replace($noparsed['key'], $noparsed['data'], $body);
     }
     // Make sure all arguments are declared
     $params =& $this->info['params'];
     if (!isset($this->info['extraparams']) && is_array($params)) {
         $this->args = array_intersect_key($this->args, $params);
     }
     // Apply filters on values individually
     if (!empty($this->args)) {
         foreach ($this->args as $argKey => &$argValue) {
             $paramInfo = $params[$argKey];
             $filter = isset($paramInfo['filter']) ? TikiFilter::get($paramInfo['filter']) : $default;
             $argValue = TikiLib::htmldecode($argValue);
             if (isset($paramInfo['separator'])) {
                 $vals = $tikilib->array_apply_filter($tikilib->multi_explode($paramInfo['separator'], $argValue), $filter);
                 $argValue = array_values($vals);
             } else {
                 $argValue = $filter->filter($argValue);
             }
         }
     }
 }
예제 #8
0
 /**
  * @param $page
  * @param $lang
  * @return string
  */
 private function get_template_from_page($page, $lang)
 {
     global $prefs;
     $info = $this->get_page_info($page);
     if ($prefs['feature_multilingual'] == 'y') {
         global $multilinguallib;
         require_once 'lib/multilingual/multilinguallib.php';
         if ($lang && $info['lang'] && $lang != $info['lang']) {
             $bestLangPageId = $multilinguallib->selectLangObj('wiki page', $info['page_id'], $lang);
             if ($info['page_id'] != $bestLangPageId) {
                 $info = $this->get_page_info_from_id($bestLangPageId);
             }
         }
     }
     if ($info) {
         return TikiLib::htmldecode($info['data']);
     }
 }
/** \brief send the email notifications dealing with wiki page  changes to
 * admin notification addresses + watching users addresses (except editor is configured)
 * \$event: 'wiki_page_created'|'wiki_page_changed'
 */
function sendWikiEmailNotification($event, $pageName, $edit_user, $edit_comment, $oldver, $edit_data, $machine, $diff = '', $minor = false, $contributions = '', $structure_parent_id = 0)
{
    global $tikilib, $prefs, $smarty, $userlib;
    global $notificationlib;
    include_once 'lib/notifications/notificationlib.php';
    $nots = array();
    $defaultLanguage = $prefs['site_language'];
    if ($prefs['feature_user_watches'] == 'y') {
        $nots = $tikilib->get_event_watches($event, $pageName);
    }
    if ($prefs['feature_user_watches'] == 'y' && $event == 'wiki_page_changed') {
        global $structlib;
        include_once 'lib/structures/structlib.php';
        $nots2 = $structlib->get_watches($pageName);
        if (!empty($nots2)) {
            $nots = array_merge($nots, $nots2);
        }
        if ($prefs['wiki_watch_editor'] != "y") {
            for ($i = count($nots) - 1; $i >= 0; --$i) {
                if ($nots[$i]['user'] == $edit_user) {
                    unset($nots[$i]);
                    break;
                }
            }
        }
        foreach (array_keys($nots) as $i) {
            $nots[$i]['language'] = $tikilib->get_user_preference($nots[$i]['user'], "language", $defaultLanguage);
        }
    }
    if ($prefs['feature_user_watches'] == 'y' && $event == 'wiki_page_created' && $structure_parent_id) {
        global $structlib;
        include_once 'lib/structures/structlib.php';
        $nots = array_merge($nots, $structlib->get_watches('', $structure_parent_id));
    }
    // admin notifications
    // If it's a minor change, get only the minor change watches.
    if ($minor) {
        $emails = $notificationlib->get_mail_events('wiki_page_changes_incl_minor', 'wikipage' . $pageName);
        // look for pageName and any page
    } else {
        // else if it's not minor change, get both watch types.
        $emails1 = $notificationlib->get_mail_events('wiki_page_changes', 'wikipage' . $pageName);
        // look for pageName and any page
        $emails2 = $notificationlib->get_mail_events('wiki_page_changes_incl_minor', 'wikipage' . $pageName);
        // look for pageName and any page
        $emails = array_merge($emails1, $emails2);
    }
    foreach ($emails as $email) {
        if ($prefs['wiki_watch_editor'] != "y" && $email == $edit_user) {
            continue;
        }
        if (!testEmailInList($nots, $email)) {
            $not = array('email' => $email);
            if ($not['user'] = $userlib->get_user_by_email($email)) {
                $not['language'] = $tikilib->get_user_preference($not['user'], "language", $defaultLanguage);
            } else {
                $not['language'] = $defaultLanguage;
            }
            $nots[] = $not;
        }
    }
    if ($edit_user == '') {
        $edit_user = tra('Anonymous');
    }
    if (count($nots)) {
        $edit_data = TikiLib::htmldecode($edit_data);
        include_once 'lib/webmail/tikimaillib.php';
        $mail = new TikiMail();
        $smarty->assign('mail_site', $_SERVER["SERVER_NAME"]);
        $smarty->assign('mail_page', $pageName);
        $smarty->assign('mail_date', $tikilib->now);
        $smarty->assign('mail_user', $edit_user);
        $smarty->assign('mail_comment', $edit_comment);
        $newver = $oldver + 1;
        $smarty->assign('mail_oldver', $oldver);
        $smarty->assign('mail_newver', $newver);
        $smarty->assign('mail_data', $edit_data);
        $foo = parse_url($_SERVER["REQUEST_URI"]);
        $machine = $tikilib->httpPrefix() . dirname($foo["path"]);
        $smarty->assign('mail_machine', $machine);
        if ($prefs['feature_contribution'] == 'y' && !empty($contributions)) {
            global $contributionlib;
            include_once 'lib/contribution/contributionlib.php';
            $smarty->assign('mail_contributions', $contributionlib->print_contributions($contributions));
        }
        $parts = explode('/', $foo['path']);
        if (count($parts) > 1) {
            unset($parts[count($parts) - 1]);
        }
        $smarty->assign('mail_machine_raw', $tikilib->httpPrefix() . implode('/', $parts));
        $smarty->assign_by_ref('mail_pagedata', $edit_data);
        $smarty->assign_by_ref('mail_diffdata', $diff);
        if ($event == 'wiki_page_created') {
            $smarty->assign('new_page', 'y');
        }
        foreach ($nots as $not) {
            if (isset($not['hash'])) {
                $smarty->assign('mail_hash', $not['hash']);
            }
            $mail->setUser($not['user']);
            $mail_data = $smarty->fetchLang($not['language'], "mail/user_watch_wiki_page_changed_subject.tpl");
            $mail->setSubject(sprintf($mail_data, $pageName));
            $mail_data = $smarty->fetchLang($not['language'], "mail/user_watch_wiki_page_changed.tpl");
            $mail->setText($mail_data);
            $mail->buildMessage();
            $mail->send(array($not['email']));
        }
    }
}
예제 #10
0
 private function plugin_apply_filters($name, &$data, &$args, $parseOptions)
 {
     global $tikilib;
     $info = $this->plugin_info($name);
     $default = TikiFilter::get(isset($info['defaultfilter']) ? $info['defaultfilter'] : 'xss');
     // Apply filters on the body
     $filter = isset($info['filter']) ? TikiFilter::get($info['filter']) : $default;
     //$data = TikiLib::htmldecode($data);		// jb 9.0 commented out in fix for html entitles
     $data = $filter->filter($data);
     if (isset($parseOptions) && (!empty($parseOptions['is_html']) && !$parseOptions['is_html'])) {
         $noparsed = array('data' => array(), 'key' => array());
         $this->strip_unparsed_block($data, $noparsed);
         $data = str_replace(array('<', '>'), array('&lt;', '&gt;'), $data);
         foreach ($noparsed['data'] as &$instance) {
             $instance = '~np~' . $instance . '~/np~';
         }
         unset($instance);
         $data = str_replace($noparsed['key'], $noparsed['data'], $data);
     }
     // Make sure all arguments are declared
     $params = $info['params'];
     if (!isset($info['extraparams']) && is_array($params)) {
         $args = array_intersect_key($args, $params);
     }
     // Apply filters on values individually
     if (!empty($args)) {
         foreach ($args as $argKey => &$argValue) {
             if (!isset($params[$argKey])) {
                 continue;
                 // extra params
             }
             $paramInfo = $params[$argKey];
             $filter = isset($paramInfo['filter']) ? TikiFilter::get($paramInfo['filter']) : $default;
             $argValue = TikiLib::htmldecode($argValue);
             if (isset($paramInfo['separator'])) {
                 $vals = array();
                 $vals = $tikilib->array_apply_filter($tikilib->multi_explode($paramInfo['separator'], $argValue), $filter);
                 $argValue = array_values($vals);
             } else {
                 $argValue = $filter->filter($argValue);
             }
         }
     }
 }
예제 #11
0
function wikiplugin_rss($data, $params)
{
    global $smarty;
    global $tikilib;
    global $dbTiki;
    global $rsslib;
    if (!isset($rsslib)) {
        include_once 'lib/rss/rsslib.php';
    }
    extract($params, EXTR_SKIP);
    if (!isset($max)) {
        $max = '10';
    }
    if (!isset($id)) {
        return tra('You need to specify a RSS Id');
    }
    if (!isset($date)) {
        $date = 0;
    }
    if (!isset($desc)) {
        $desc = 0;
    }
    if (!isset($author)) {
        $author = 0;
    }
    $ids = explode(':', $id);
    $repl = '';
    $items = array();
    $filter = new DeclFilter();
    $filter->addStaticKeyFilters(array('link' => 'url', 'title' => 'striptags', 'author' => 'striptags', 'pubDate' => 'striptags', 'description' => 'striptags'));
    foreach ($ids as $val) {
        if (!($rssdata = $rsslib->get_rss_module_content($val))) {
            $repl = tra('RSS Id incorrect:') . ' ' . $val;
        }
        $itemsrss = $rsslib->parse_rss_data($rssdata, $val, $rssdata);
        foreach ($itemsrss as &$item) {
            foreach ($item as &$v) {
                $v = TikiLib::htmldecode($v);
            }
            $item = $filter->filter($item);
            if ($desc > 1 && strlen($item['description']) > $desc) {
                $item['description'] = substr($item['description'], 0, $desc) . ' [...]';
            }
        }
        $items = array_merge($items, $itemsrss);
    }
    $title = null;
    if (isset($items[0]) && $items[0]['isTitle'] == 'y') {
        $title = array_shift($items);
    }
    // No need to waste time sorting with only one feed
    if (count($ids) > 1) {
        usort($items, 'rss_sort');
    }
    $items = array_slice($items, 0, $max);
    if (count($items) < $max) {
        $max = count($items);
    }
    global $smarty;
    $smarty->assign('title', $title);
    $smarty->assign('items', $items);
    $smarty->assign('showdate', $date > 0);
    $smarty->assign('showdesc', $desc > 0);
    $smarty->assign('showauthor', $author > 0);
    return '~np~' . $smarty->fetch('wiki-plugins/wikiplugin_rss.tpl') . '~/np~';
}
예제 #12
0
/**
 *\brief send the email notifications dealing with wiki page  changes to
 * admin notification addresses + watching users addresses (except editor is configured)
 * \$event: 'wiki_page_created'|'wiki_page_changed'|wiki_page_deleted |wiki_file_attached
 *
 */
function sendWikiEmailNotification($wikiEvent, $pageName, $edit_user, $edit_comment, $oldver, $edit_data, $machine = '', $diff = '', $minor = false, $contributions = '', $structure_parent_id = 0, $attId = 0, $lang = '')
{
    global $prefs;
    $userlib = TikiLib::lib('user');
    $tikilib = TikiLib::lib('tiki');
    $smarty = TikiLib::lib('smarty');
    $notificationlib = TikiLib::lib('notification');
    $nots = array();
    $defaultLanguage = $prefs['site_language'];
    if ($wikiEvent == 'wiki_file_attached') {
        $event = 'wiki_page_changed';
    } else {
        $event = $wikiEvent;
    }
    if ($prefs['feature_user_watches'] == 'y') {
        $nots = $tikilib->get_event_watches($event, $pageName);
    }
    if ($prefs['feature_user_watches'] == 'y' && $event == 'wiki_page_changed') {
        $structlib = TikiLib::lib('struct');
        $nots2 = $structlib->get_watches($pageName);
        if (!empty($nots2)) {
            $nots = array_merge($nots, $nots2);
        }
        if ($prefs['wiki_watch_editor'] != "y" || $prefs['user_wiki_watch_editor'] != "y") {
            for ($i = count($nots) - 1; $i >= 0; --$i) {
                if ($nots[$i]['user'] == $edit_user) {
                    unset($nots[$i]);
                    break;
                }
            }
        }
        foreach (array_keys($nots) as $i) {
            $nots[$i]['language'] = $tikilib->get_user_preference($nots[$i]['user'], "language", $defaultLanguage);
        }
    }
    if ($prefs['feature_user_watches'] == 'y' && $event == 'wiki_page_created' && $structure_parent_id) {
        $structlib = TikiLib::lib('struct');
        $nots = array_merge($nots, $structlib->get_watches('', $structure_parent_id));
    }
    // admin notifications
    // If it's a minor change, get only the minor change watches.
    if ($minor) {
        $emails = $notificationlib->get_mail_events('wiki_page_changes_incl_minor', $pageName);
        // look for pageName and any page
    } else {
        // else if it's not minor change, get both watch types.
        $emails1 = $notificationlib->get_mail_events('wiki_page_changes', $pageName);
        // look for pageName and any page
        $emails2 = $notificationlib->get_mail_events('wiki_page_changes_incl_minor', $pageName);
        // look for pageName and any page
        $emails = array_merge($emails1, $emails2);
    }
    foreach ($emails as $email) {
        if (($prefs['wiki_watch_editor'] != "y" || $prefs['user_wiki_watch_editor'] != "y") && $email == $edit_user) {
            continue;
        }
        if (!testEmailInList($nots, $email)) {
            $not = array('email' => $email);
            if ($not['user'] = $userlib->get_user_by_email($email)) {
                $not['language'] = $tikilib->get_user_preference($not['user'], "language", $defaultLanguage);
            } else {
                $not['language'] = $defaultLanguage;
            }
            $nots[] = $not;
        }
    }
    if ($edit_user == '') {
        $edit_user = tra('Anonymous');
    }
    if ($prefs['feature_user_watches'] == 'y' && $prefs['feature_daily_report_watches'] == 'y') {
        if ($wikiEvent == 'wiki_file_attached') {
            $reportsManager = Reports_Factory::build('Reports_Manager');
            $reportsManager->addToCache($nots, array("event" => $wikiEvent, "pageName" => $pageName, 'attId' => $attId, "editUser" => $edit_user, "editComment" => $edit_comment, 'filename' => $edit_data));
        } else {
            $reportsManager = Reports_Factory::build('Reports_Manager');
            $reportsManager->addToCache($nots, array("event" => $wikiEvent, "pageName" => $pageName, "object" => $pageName, "editUser" => $edit_user, "editComment" => $edit_comment, "oldVer" => $oldver));
        }
    }
    if (count($nots)) {
        $edit_data = TikiLib::htmldecode($edit_data);
        include_once 'lib/mail/maillib.php';
        $smarty->assign('mail_site', $_SERVER["SERVER_NAME"]);
        $smarty->assign('mail_page', $pageName);
        $smarty->assign('mail_date', $tikilib->now);
        $smarty->assign('mail_user', $edit_user);
        $smarty->assign('mail_comment', $edit_comment);
        $newver = $oldver + 1;
        $smarty->assign('mail_oldver', $oldver);
        $smarty->assign('mail_newver', $newver);
        $smarty->assign('mail_data', $edit_data);
        $smarty->assign('mail_attId', $attId);
        $foo = parse_url($_SERVER["REQUEST_URI"]);
        $machine = $tikilib->httpPrefix(true) . dirname($foo["path"]);
        $smarty->assign('mail_machine', $machine);
        if ($prefs['feature_contribution'] == 'y' && !empty($contributions)) {
            $contributionlib = TikiLib::lib('contribution');
            $smarty->assign('mail_contributions', $contributionlib->print_contributions($contributions));
        }
        $parts = explode('/', $foo['path']);
        if (count($parts) > 1) {
            unset($parts[count($parts) - 1]);
        }
        $smarty->assign('mail_machine_raw', $tikilib->httpPrefix(true) . implode('/', $parts));
        $smarty->assign_by_ref('mail_pagedata', $edit_data);
        $smarty->assign_by_ref('mail_diffdata', $diff);
        if ($event == 'wiki_page_created') {
            $smarty->assign('mail_action', 'new');
        } elseif ($event == 'wiki_page_deleted') {
            $smarty->assign('mail_action', 'delete');
        } elseif ($wikiEvent == 'wiki_file_attached') {
            $smarty->assign('mail_action', 'attach');
        } else {
            $smarty->assign('mail_action', 'edit');
        }
        include_once 'lib/webmail/tikimaillib.php';
        foreach ($nots as $not) {
            if (empty($not['email'])) {
                continue;
            }
            $smarty->assign('watchId', $not['watchId']);
            $mail_subject = $smarty->fetchLang($not['language'], "mail/user_watch_wiki_page_changed_subject.tpl");
            $mail_data = $smarty->fetchLang($not['language'], "mail/user_watch_wiki_page_changed.tpl");
            $mail = new TikiMail($not['user']);
            $mail->setSubject(sprintf($mail_subject, $pageName));
            $mail->setText($mail_data);
            $mail->send(array($not['email']));
        }
    }
}
예제 #13
0
    // remove spans round img's
    $parsed = preg_replace("/src=\"img\\/smiles\\//im", "src=\"" . $tikiroot . "img/smiles/", $parsed);
    // fix smiley src's
    $smarty->assign('pagedata', $parsed);
    $prefs['wiki_edit_section'] = $secedit;
    $prefs['feature_wiki_ext_icon'] = $exticons;
    $is_html = true;
    $info['is_html'] = true;
    $info['wysiwyg'] = true;
    $smarty->assign('allowhtml', 'y');
}
if (!$parsed) {
    if (!isset($_REQUEST['edit']) && !$is_html) {
        // When we get data from database (i.e. we are not in preview mode) and if we don't allow HTML,
        //   then we need to convert database's HTML entities into their "normal chars" equivalents
        $parsed = TikiLib::htmldecode($edit_data);
    } else {
        //if ( isset($_REQUEST['edit']) && ! $is_html ) {
        // When we are in preview mode (i.e. data doesn't come from database) and if we don't allow HTML,
        //   then we need to convert HTML special chars into their HTML entities equivalent;
        //	$parsed = htmlspecialchars($edit_data);
        //} else {
        $parsed = $edit_data;
        //}
    }
}
$smarty->assign('pagedata', $parsed);
// apply the optional post edit filters before preview
if (isset($_REQUEST["preview"]) || $prefs['wiki_spellcheck'] == 'y' && isset($_REQUEST["spellcheck"]) && $_REQUEST["spellcheck"] == 'on') {
    $parsed = $tikilib->apply_postedit_handlers($parsed);
    $parsed = $tikilib->parse_data($parsed, $is_html);
function wikiplugin_code($data, $params)
{
    if (is_array($params)) {
        extract($params, EXTR_SKIP);
    }
    $code = trim($data);
    $parse_wiki = isset($wiki) && $wiki == 1;
    $escape_html = !isset($ishtml) || $ishtml != 1;
    // Detect if GeSHI (Generic Syntax Highlighter) is available
    $geshi_paths = array('lib/geshi/class.geshi.php', 'lib/geshi/geshi.php', '/usr/share/php-geshi/geshi.php');
    foreach ($geshi_paths as $gp) {
        if (file_exists($gp)) {
            require_once $gp;
            break;
        }
    }
    // If 'color' is specified and GeSHI installed, use syntax highlighting with GeSHi
    if (isset($colors) && $colors != 'highlights' && class_exists('GeSHI')) {
        $geshi =& new GeSHi(TikiLib::htmldecode($code), $colors);
        if (version_compare(GESHI_VERSION, 1.1) == -1) {
            // Old API
            if (isset($ln) && $ln > 0) {
                $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
                $geshi->start_line_numbers_at($ln);
            }
            $geshi->set_link_target('_blank');
            $out = $geshi->parse_code();
        } else {
            // New API
            $out = $geshi->parseCode();
        }
        // Remove first <pre> tag
        if ($out != '') {
            $out = ereg_replace('^<pre[^>]*>(.*)</pre>$', '\\1', $out);
            $out = trim($out);
        }
        if (!$escape_html) {
            $out = TikiLib::htmldecode($out);
        }
    } elseif (isset($colors) && ($colors == 'highlights' || $colors == 'php')) {
        $out = highlight_string(TikiLib::htmldecode($code), true);
        // Convert &nbsp; into spaces and <br /> tags into real line breaks, since it will be displayed in a <pre> tag
        $out = str_replace('&nbsp;', ' ', $out);
        $out = eregi_replace('<br[^>]+>', "\n", $out);
        // Remove first <code> tag
        $out = eregi_replace('^\\s*<code[^>]*>(.*)</code>$', '\\1', $out);
        // Remove spaces after the first tag and before the start of the code
        $out = ereg_replace("^\\s*(<[^>]+>)\n", '\\1', $out);
        $out = trim($out);
        if (!$escape_html) {
            $out = TikiLib::htmldecode($out);
        }
    } else {
        $out = trim($code);
        if (isset($ln) && $ln == 1) {
            $out = '';
            $lines = explode("\n", $code);
            $i = 1;
            foreach ($lines as $line) {
                $out .= sprintf('% 3d', $i) . ' . ' . $line . "\n";
                $i++;
            }
        } else {
            $out = $code;
        }
    }
    if (isset($wrap) && $wrap == 1) {
        // Force wrapping in <pre> tag through a CSS hack
        $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;';
    } else {
        // If there is no wrapping, display a scrollbar (only if needed) to avoid truncating the text
        $pre_style = 'overflow:auto;';
    }
    $out = '<pre class="codelisting" dir="' . (isset($rtl) && $rtl == 1 ? 'rtl' : 'ltr') . '" style="' . $pre_style . '">' . ($parse_wiki ? '' : '~np~') . $out . ($parse_wiki ? '' : '~/np~') . '</pre>';
    if (isset($caption)) {
        $out = '<div class="codecaption">' . $caption . '</div>' . $out;
    }
    return $out;
}