当前位置: 首页>>代码示例>>PHP>>正文


PHP diff2函数代码示例

本文整理汇总了PHP中diff2函数的典型用法代码示例。如果您正苦于以下问题:PHP diff2函数的具体用法?PHP diff2怎么用?PHP diff2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了diff2函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: count

if (!isset($_REQUEST["newver"])) {
    $_REQUEST["newver"] = count($history);
}
if (isset($_REQUEST["compare"])) {
    foreach ($history as $old) {
        if ($old["version"] == $_REQUEST["oldver"]) {
            break;
        }
    }
    $smarty->assign_by_ref('old', $old);
    foreach ($history as $new) {
        if ($new["version"] == $_REQUEST["newver"]) {
            break;
        }
    }
    $smarty->assign_by_ref('new', $new);
    if (!isset($_REQUEST["diff_style"]) || $_REQUEST["diff_style"] == "old") {
        $_REQUEST["diff_style"] = 'unidiff';
    }
    $smarty->assign('diff_style', $_REQUEST["diff_style"]);
    if ($_REQUEST["diff_style"] != "sideview") {
        require_once 'lib/diff/difflib.php';
        $html = diff2($old["data"], $new["data"], $_REQUEST["diff_style"]);
        $smarty->assign_by_ref('diffdata', $html);
    }
} else {
    $smarty->assign('diff_style', '');
}
// Get templates from the templates/modules directori
$smarty->assign('mid', 'map/tiki-map_history.tpl');
$smarty->display("tiki.tpl");
开发者ID:noikiy,项目名称:owaspbwa,代码行数:31,代码来源:tiki-map_history.php

示例2: update_comment

 function update_comment($threadId, $title, $comment_rating, $data, $type = 'n', $summary = '', $smiley = '', $objectId = '', $contributions = '')
 {
     global $prefs;
     $comments = $this->table('tiki_comments');
     $hash = md5($title . $data);
     $existingThread = $comments->fetchColumn('threadId', array('hash' => $hash));
     // if exactly same title and data comment does not already exist, and is not the current thread
     if (empty($existingThread) || in_array($threadId, $existingThread)) {
         $object = explode(":", $objectId, 2);
         if ($prefs['feature_actionlog'] == 'y') {
             $comment = $this->get_comment($threadId);
             include_once 'lib/diff/difflib.php';
             $bytes = diff2($comment['data'], $data, 'bytes');
             global $logslib;
             include_once 'lib/logs/logslib.php';
             if ($object[0] == 'forum') {
                 $logslib->add_action('Updated', $object[1], $object[0], "comments_parentId={$threadId}&{$bytes}#threadId{$threadId}", '', '', '', '', $contributions);
             } else {
                 $logslib->add_action('Updated', $object[1], 'comment', "type=" . $object[0] . "&{$bytes}#threadId{$threadId}", '', '', '', '', $contributions);
             }
         }
         $comments->update(array('title' => $title, 'comment_rating' => (int) $comment_rating, 'data' => $data, 'type' => $type, 'summary' => $summary, 'smiley' => $smiley, 'hash' => $hash), array('threadId' => (int) $threadId));
         if ($prefs['feature_contribution'] == 'y') {
             $contributionlib = TikiLib::lib('contribution');
             $contributionlib->assign_contributions($contributions, $threadId, 'comment', $title, '', '');
         }
         $type = $this->update_index($object[0], $threadId);
         $href = $this->getHref($object[0], $object[1], $threadId);
         global $tikilib;
         $tikilib->object_post_save(array('type' => $type, 'object' => $threadId, 'description' => '', 'href' => $href, 'name' => $title), array('content' => $data));
         $this->update_comment_links($data, $object[0], $threadId);
     }
     // end hash check
 }
开发者ID:railfuture,项目名称:tiki-website,代码行数:34,代码来源:commentslib.php

示例3: update_page


//.........这里部分代码省略.........
         if (!empty($hash['lock_it']) && ($hash['lock_it'] == 'y' || $hash['lock_it'] == 'on')) {
             $queryData['flag'] = 'L';
             $queryData['lockedby'] = $user;
         } else {
             if (empty($hash['lock_it']) || $hash['lock_it'] == 'n') {
                 $queryData['flag'] = '';
                 $queryData['lockedby'] = '';
             }
         }
     }
     if ($prefs['wiki_comments_allow_per_page'] != 'n') {
         if (!empty($hash['comments_enabled']) && $hash['comments_enabled'] == 'y') {
             $queryData['comments_enabled'] = 'y';
         } else {
             if (empty($hash['comments_enabled']) || $hash['comments_enabled'] == 'n') {
                 $queryData['comments_enabled'] = 'n';
             }
         }
     }
     if (empty($hash['contributions'])) {
         $hash['contributions'] = '';
     }
     if (empty($hash['contributors'])) {
         $hash2 = '';
     } else {
         foreach ($hash['contributors'] as $c) {
             $hash3['contributor'] = $c;
             $hash2[] = $hash3;
         }
     }
     $this->table('tiki_pages')->update($queryData, array('pageName' => $pageName));
     // Synchronize object comment
     if ($prefs['feature_wiki_description'] == 'y') {
         $query = 'update `tiki_objects` set `description`=? where `itemId`=? and `type`=?';
         $this->query($query, array($edit_description, $pageName, 'wiki page'));
     }
     //update status, page storage was updated in tiki 9 to be non html encoded
     $wikilib = TikiLib::lib('wiki');
     $converter = new convertToTiki9();
     $converter->saveObjectStatus($this->getOne("SELECT page_id FROM tiki_pages WHERE pageName = ?", array($pageName)), 'tiki_pages');
     // Parse edit_data updating the list of links from this page
     $this->clear_links($pageName);
     // Pages collected above
     foreach ($pages as $page => $types) {
         $this->replace_link($pageName, $page, $types);
     }
     if (strtolower($pageName) != 'sandbox' && !$edit_minor) {
         $maxversions = $prefs['maxVersions'];
         if ($maxversions && ($nb = $histlib->get_nb_history($pageName)) > $maxversions) {
             // Select only versions older than keep_versions days
             $keep = $prefs['keep_versions'];
             $oktodel = $saveLastModif - $keep * 24 * 3600 + 1;
             $history = $this->table('tiki_history');
             $result = $history->fetchColumn('version', array('pageName' => $pageName, 'lastModif' => $history->lesserThan($oktodel)), $nb - $maxversions, 0, array('lastModif' => 'ASC'));
             foreach ($result as $toRemove) {
                 $histlib->remove_version($pageName, $toRemove);
             }
         }
     }
     // This if no longer checks for minor-ness of the change; sendWikiEmailNotification does that.
     if ($willDoHistory) {
         $this->replicate_page_to_history($pageName);
         if (strtolower($pageName) != 'sandbox') {
             if ($prefs['feature_contribution'] == 'y') {
                 // transfer page contributions to the history
                 $contributionlib = TikiLib::lib('contribution');
                 $history = $this->table('tiki_history');
                 $historyId = $history->fetchOne($history->max('historyId'), array('pageName' => $pageName, 'version' => (int) $old_version));
                 $contributionlib->change_assigned_contributions($pageName, 'wiki page', $historyId, 'history', '', $pageName . '/' . $old_version, "tiki-pagehistory.php?page={$pageName}&preview={$old_version}");
             }
         }
         include_once 'lib/diff/difflib.php';
         if (strtolower($pageName) != 'sandbox') {
             $logslib = TikiLib::lib('logs');
             $bytes = diff2($data, $edit_data, 'bytes');
             $logslib->add_action('Updated', $pageName, 'wiki page', $bytes, $edit_user, $edit_ip, '', $this->now, $hash['contributions'], $hash2);
             if ($prefs['feature_contribution'] == 'y') {
                 $contributionlib = TikiLib::lib('contribution');
                 $contributionlib->assign_contributions($hash['contributions'], $pageName, 'wiki page', $edit_description, $pageName, "tiki-index.php?page=" . urlencode($pageName));
             }
         }
         if ($prefs['feature_multilingual'] == 'y' && $lang) {
             // Need to update the translated objects table when an object's language changes.
             $this->table('tiki_translated_objects')->update(array('lang' => $lang), array('type' => 'wiki page', 'objId' => $info['page_id']));
         }
         if ($prefs['wiki_watch_minor'] != 'n' || !$edit_minor) {
             //  Deal with mail notifications.
             include_once 'lib/notifications/notificationemaillib.php';
             $histlib = TikiLib::lib('hist');
             $old = $histlib->get_version($pageName, $old_version);
             $foo = parse_url($_SERVER["REQUEST_URI"]);
             $machine = self::httpPrefix(true) . dirname($foo["path"]);
             $diff = diff2($old["data"], $edit_data, "unidiff");
             sendWikiEmailNotification('wiki_page_changed', $pageName, $edit_user, $edit_comment, $old_version, $edit_data, $machine, $diff, $edit_minor, $hash['contributions'], 0, 0, $lang);
         }
     }
     $tx = $this->begin();
     TikiLib::events()->trigger('tiki.wiki.update', array('type' => 'wiki page', 'object' => $pageName, 'namespace' => $wikilib->get_namespace($pageName), 'reply_action' => 'comment', 'user' => $GLOBALS['user'], 'page_id' => $info['page_id'], 'version' => $version, 'data' => $edit_data, 'old_data' => $info['data']));
     $tx->commit();
 }
开发者ID:rjsmelo,项目名称:tiki,代码行数:101,代码来源:tikilib.php

示例4: _diff

 /**
  * Return the difference of to strings.
  *
  * @param $original original string
  * @param $new new string
  * @return string
  */
 protected function _diff($original, $new)
 {
     return diff2($original, $new, 'htmldiff');
 }
开发者ID:ameoba32,项目名称:tiki,代码行数:11,代码来源:LanguageTranslations.php

示例5: verif_url


//.........这里部分代码省略.........
        switch (strtolower($url->getAttribute('method'))) {
            case 'get':
                curl_setopt($curl, CURLOPT_HTTPGET, true);
                break;
            case 'post':
                curl_setopt($curl, CURLOPT_POST, true);
                $post_string = '';
                foreach ($post as $p => $v) {
                    if ($post_string != '') {
                        $post_string .= '&';
                    }
                    $post_string .= "{$p}={$v}";
                }
                curl_setopt($curl, CURLOPT_POSTFIELDS, $post_string);
        }
        // Close the session to avoid timeout
        session_write_close();
        $http_response = curl_exec($curl);
        $header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
        $header = substr($http_response, 0, $header_size);
        $body = substr($http_response, $header_size);
        preg_match_all('|Set-Cookie: (.*);|U', $header, $cookies_array);
        foreach ($cookies_array[1] as $c) {
            $cookies_tmp .= "&{$c}";
        }
        TikiLib::parse_str($cookies_tmp, $cookies_titi);
        if (!is_array($cookies)) {
            $cookies = array();
        }
        $cookies = array_merge($cookies, $cookies_titi);
        $buffer = $body;
        curl_close($curl);
    }
    if (extension_loaded('tidy')) {
        $data = tidy_parse_string($data, array(), 'utf8');
        $buffer = tidy_parse_string($buffer, array(), 'utf8');
        if ($use_tidy) {
            tidy_diagnose($data);
            $result['ref_error_count'] = tidy_error_count($data);
            $result['ref_error_msg'] = tidy_get_error_buffer($data);
            tidy_diagnose($buffer);
            $result['replay_error_count'] = tidy_error_count($buffer);
            $result['replay_error_msg'] = tidy_get_error_buffer($buffer);
        }
    } else {
        if (!$loaded) {
            require_once 'lib/htmlpurifier_tiki/HTMLPurifier.tiki.php';
            $config = getHTMLPurifierTikiConfig();
            $purifier = new HTMLPurifier($config);
            $loaded = true;
        }
        if ($purifier) {
            $data = '<html><body>' . $purifier->purify($data) . '</body></html>';
            $buffer = '<html><body>' . $purifier->purify($buffer) . '</body></html>';
        }
        $result['ref_error_msg'] = tra('The Tidy extension is not present');
        $result['replay_error_msg'] = tra('The Tidy extension is not present');
    }
    // If we have a XPath then we extract the new DOM and print it in HTML
    if (trim($xpath) != '') {
        $dom_ref = DOMDocument::loadHTML($data);
        $xp_ref = new DomXPath($dom_ref);
        $res_ref = $xp_ref->query($xpath);
        $new_data = new DOMDocument('1.0');
        $root = $new_data->createElement('html');
        $root = $new_data->appendChild($root);
        $body = $new_data->createElement('html');
        $body = $root->appendChild($body);
        foreach ($res_ref as $ref) {
            $tmp = $new_data->importNode($ref, TRUE);
            $body->appendChild($tmp);
        }
        $data = $new_data->saveHTML();
        $dom_buffer = DOMDocument::loadHTML($buffer);
        $xp_buffer = new DomXPath($dom_buffer);
        $res_buffer = $xp_buffer->query($xpath);
        $new_buffer = new DOMDocument('1.0');
        $root = $new_buffer->createElement('html');
        $root = $new_buffer->appendChild($root);
        $body = $new_buffer->createElement('html');
        $body = $root->appendChild($body);
        foreach ($res_buffer as $ref) {
            $tmp = $new_buffer->importNode($ref, TRUE);
            $body->appendChild($tmp);
        }
        $buffer = $new_buffer->saveHTML();
    }
    $tmp = diff2($data, $buffer, "htmldiff");
    if (trim($xpath) != '') {
        $result['html'] = preg_replace(array("/<html>/", "/<\\/html>/"), array("<div style='overflow: auto; width:500px; text-align: center'> ", "</div>"), $tmp);
    } else {
        $result['html'] = preg_replace(array("/<html.*<body/U", "/<\\/body><\\/html>/U"), array("<div style='overflow: auto; width:500px; text-align: center' ", "</div>"), $tmp);
    }
    $result['url'] = $urlstr;
    $result['method'] = $url->getAttribute('method');
    if (strtolower($result['method']) == 'post') {
        $result['post'] = $post;
    }
    return $result;
}
开发者ID:rjsmelo,项目名称:tiki,代码行数:101,代码来源:tiki-tests_replay.php

示例6: action_preview

    function action_preview($input)
    {
        Services_Exception_Disabled::check('feature_warn_on_edit');
        global $user, $prefs, $page;
        $tikilib = TikiLib::lib('tiki');
        $autoSaveIdParts = explode(':', $input->autoSaveId->text());
        // user, section, object id
        foreach ($autoSaveIdParts as &$part) {
            $part = urldecode($part);
        }
        $page = $autoSaveIdParts[2];
        // plugins use global $page for approval
        if (!Perms::get('wiki page', $page)->edit || $user != $tikilib->get_semaphore_user($page)) {
            return '';
        }
        $info = $tikilib->get_page_info($page, false);
        if (empty($info)) {
            $info = array('data' => '');
        }
        $info['is_html'] = $input->allowHtml->int();
        if (!isset($info['wysiwyg']) && isset($_SESSION['wysiwyg'])) {
            $info['wysiwyg'] = $_SESSION['wysiwyg'];
        }
        $options = array('is_html' => $info['is_html'], 'preview_mode' => true, 'process_wiki_paragraphs' => $prefs['wysiwyg_htmltowiki'] === 'y' || $info['wysiwyg'] == 'n', 'page' => $page);
        if (count($autoSaveIdParts) === 3 && !empty($user) && $user === $autoSaveIdParts[0] && $autoSaveIdParts[1] === 'wiki_page') {
            $editlib = TikiLib::lib('edit');
            $smarty = TikiLib::lib('smarty');
            $wikilib = TikiLib::lib('wiki');
            $smarty->assign('inPage', $input->inPage->int() ? true : false);
            if ($input->inPage->int()) {
                $diffstyle = $input->diff_style->text();
                if (!$diffstyle) {
                    // use previously set diff_style
                    $diffstyle = getCookie('preview_diff_style', 'preview', '');
                }
                $data = $editlib->partialParseWysiwygToWiki(TikiLib::lib('autosave')->get_autosave($input->editor_id->text(), $input->autoSaveId->text()));
                TikiLib::lib('smarty')->assign('diff_style', $diffstyle);
                if ($diffstyle) {
                    if (!empty($info['created'])) {
                        $info = $tikilib->get_page_info($page);
                        // get page with data this time
                    }
                    if ($input->hdr->int()) {
                        // TODO refactor with code in editpage
                        if ($input->hdr->int() === 0) {
                            list($real_start, $real_len) = $tikilib->get_wiki_section($info['data'], 1);
                            $real_len = $real_start;
                            $real_start = 0;
                        } else {
                            list($real_start, $real_len) = $tikilib->get_wiki_section($info['data'], $input->hdr->int());
                        }
                        $info['data'] = substr($info['data'], $real_start, $real_len);
                    }
                    require_once 'lib/diff/difflib.php';
                    if ($info['is_html'] == 1) {
                        $diffold = $tikilib->htmldecode($info['data']);
                    } else {
                        $diffold = $info['data'];
                    }
                    if ($info['is_html']) {
                        $diffnew = $tikilib->htmldecode($data);
                    } else {
                        $diffnew = $data;
                    }
                    if ($diffstyle === 'htmldiff') {
                        $diffnew = $tikilib->parse_data($diffnew, $options);
                        $diffold = $tikilib->parse_data($diffold, $options);
                    }
                    $data = diff2($diffold, $diffnew, $diffstyle);
                    $smarty->assign_by_ref('diffdata', $data);
                    $smarty->assign('translation_mode', 'y');
                    $data = $smarty->fetch('pagehistory.tpl');
                } else {
                    $data = $tikilib->parse_data($data, $options);
                }
                $parsed = $data;
            } else {
                // popup window
                TikiLib::lib('header')->add_js('
function get_new_preview() {
	$("body").css("opacity", 0.6);
	location.reload(true);
}
$(window).on("load", function(){
	if (typeof opener != "undefined") {
		opener.ajaxPreviewWindow = this;
	}
}).on("unload", function(){
	if (typeof opener.ajaxPreviewWindow != "undefined") {
		opener.ajaxPreviewWindow = null;
	}
});
');
                $smarty->assign('headtitle', tra('Preview'));
                $data = '<div id="c1c2"><div id="wrapper"><div id="col1"><div id="tiki-center" class="wikitext">';
                if (TikiLib::lib('autosave')->has_autosave($input->editor_id->text(), $input->autoSaveId->text())) {
                    $parserlib = TikiLib::lib('parser');
                    $data .= $parserlib->parse_data($editlib->partialParseWysiwygToWiki(TikiLib::lib('autosave')->get_autosave($input->editor_id->text(), $input->autoSaveId->text())), $options);
                } else {
                    if ($autoSaveIdParts[1] == 'wiki_page') {
//.........这里部分代码省略.........
开发者ID:rjsmelo,项目名称:tiki,代码行数:101,代码来源:Controller.php

示例7: histlib_helper_setup_diff

function histlib_helper_setup_diff( $page, $oldver, $newver )
{
	global $smarty, $histlib, $tikilib, $prefs;
	$prefs['wiki_edit_section'] = 'n';
	
	$info = $tikilib->get_page_info($page);

	if ($oldver == 0 || $oldver == $info["version"]) {
		$old = & $info;
		$smarty->assign_by_ref('old', $info);
	} else {
		// fetch the required page from history, including its content
		while( $oldver > 0 && ! ($exists = $histlib->version_exists($page, $oldver) ) )
			--$oldver;

		if ( $exists ) {
			$old = $histlib->get_page_from_history($page, $oldver, true);
			$smarty->assign_by_ref('old', $old);
		}
	}
	if ($newver == 0 || $newver >= $info["version"]) {
		$new =& $info;
		$smarty->assign_by_ref('new', $info);
	} else {
		// fetch the required page from history, including its content
		while( $newver > 0 && ! ($exists = $histlib->version_exists($page, $newver) ) )
			--$newver;

		if ( $exists ) {
			$new = $histlib->get_page_from_history($page, $newver, true);
			$smarty->assign_by_ref('new', $new);
		}
	}

	$oldver_mod = $oldver;
	if ($oldver == 0) {
		$oldver_mod = 1;
	}

	$query = "SELECT `comment`, `version` from `tiki_history` WHERE `pageName`=? and `version` BETWEEN ? AND ? ORDER BY `version` DESC";
	$result = $histlib->query($query, array($page,$oldver_mod,$newver));
	$diff_summaries = array();

	if ($oldver == 0) {
		$diff_summaries[] = $old['comment'];
	}

	while ($res = $result->fetchRow()) {
		$aux = array();

		$aux["comment"] = $res["comment"];
		$aux["version"] = $res["version"];
		$diff_summaries[] = $aux;
	}

	$smarty->assign('diff_summaries', $diff_summaries);
	
	if (!isset($_REQUEST["diff_style"]) || $_REQUEST["diff_style"] == "old") {
		$_REQUEST["diff_style"] = 'unidiff';
	}

	$smarty->assign('diff_style', $_REQUEST["diff_style"]);
	if ($_REQUEST["diff_style"] == "sideview") {
		$old["data"] = $tikilib->parse_data($old["data"], array('preview_mode' => true));
		$new["data"] = $tikilib->parse_data($new["data"], array('preview_mode' => true));
	} else {
		require_once('lib/diff/difflib.php');
		if ($info['is_html'] == 1 and $_REQUEST["diff_style"] != "htmldiff") {
			$search[] = "~</(table|td|th|div|p)>~";
			$replace[] = "\n";
			$search[] = "~<(hr|br) />~";
			$replace[] = "\n";
			$old['data'] = strip_tags(preg_replace($search, $replace, $old['data']), '<h1><h2><h3><h4><b><i><u><span>');
			$new['data'] = strip_tags(preg_replace($search, $replace, $new['data']), '<h1><h2><h3><h4><b><i><u><span>');
		}
		if ($_REQUEST["diff_style"] == "htmldiff") {

			$parse_options = array('is_html' => ($old['is_html'] == 1), 'noheadinc' => true, 'suppress_icons' => true);
			$old["data"] = $tikilib->parse_data($old["data"], $parse_options);
			$new["data"] = $tikilib->parse_data($new["data"], $parse_options);

			$old['data'] = histlib_strip_irrelevant($old['data']);
			$new['data'] = histlib_strip_irrelevant($new['data']);
		}

                # If the user doesn't have permission to view 
                # source, strip out all tiki-source-based comments
                global $tiki_p_wiki_view_source;
                if ($tiki_p_wiki_view_source != 'y' && $_REQUEST["diff_style"] != "htmldiff") {
                  $old["data"] = preg_replace(';~tc~(.*?)~/tc~;s', '', $old["data"]);
                  $new["data"] = preg_replace(';~tc~(.*?)~/tc~;s', '', $new["data"]);
                }

		$html = diff2($old["data"], $new["data"], $_REQUEST["diff_style"]);
		$smarty->assign_by_ref('diffdata', $html);
	}
}
开发者ID:railfuture,项目名称:tiki-website,代码行数:97,代码来源:histlib.php

示例8: update_page


//.........这里部分代码省略.........
     if (empty($hash['contributors'])) {
         $hash2 = '';
     } else {
         foreach ($hash['contributors'] as $c) {
             $hash3['contributor'] = $c;
             $hash2[] = $hash3;
         }
     }
     $bindvars[] = $pageName;
     $query = "update `tiki_pages` set `description`=?, `data`=?, `comment`=?, `lastModif`=?, `version`=?, `user`=?, `ip`=?, `page_size`=?, `is_html`=?, `wysiwyg`=?, `wiki_authors_style`=?  {$mid} where `pageName`=?";
     $result = $this->query($query, $bindvars);
     // Parse edit_data updating the list of links from this page
     $this->clear_links($pageName);
     // Pages collected above
     foreach ($pages as $page) {
         $this->replace_link($pageName, $page);
     }
     if (strtolower($pageName) != 'sandbox' && !$minor) {
         $maxversions = $prefs['maxVersions'];
         if ($maxversions && ($nb = $histlib->get_nb_history($pageName)) > $maxversions) {
             // Select only versions older than keep_versions days
             $keep = $prefs['keep_versions'];
             $oktodel = $saveLastModif - $keep * 24 * 3600;
             $query = "select `pageName` ,`version`, `historyId` from `tiki_history` where `pageName`=? and `lastModif`<=? order by `lastModif` asc";
             $result = $this->query($query, array($pageName, $oktodel), $nb - $maxversions);
             $toelim = $result->numRows();
             while ($res = $result->fetchRow()) {
                 $page = $res["pageName"];
                 $version = $res["version"];
                 $query = "delete from `tiki_history` where `pageName`=? and `version`=?";
                 $this->query($query, array($pageName, $version));
                 if ($prefs['feature_contribution'] == 'y') {
                     global $contributionlib;
                     include_once 'lib/contribution/contributionlib.php';
                     $contributionlib->remove_history($res['historyId']);
                 }
             }
         }
     }
     // This if no longer checks for minor-ness of the change; sendWikiEmailNotification does that.
     if ($prefs['feature_wiki_history_full'] == 'y' || $data != $edit_data || $description != $info["description"] || $comment != $edit_comment) {
         if (strtolower($pageName) != 'sandbox') {
             $query = "insert into `tiki_history`(`pageName`, `version`, `lastModif`, `user`, `ip`, `comment`, `data`, `description`)\n\t\t    values(?,?,?,?,?,?,?,?)";
             # echo "<pre>";print_r(get_defined_vars());echo "</pre>";die();
             $result = $this->query($query, array($pageName, (int) $old_version, (int) $lastModif, $user, $ip, $comment, $data, $description));
             if ($prefs['feature_contribution'] == 'y') {
                 // transfer page contributions to the history
                 global $contributionlib;
                 include_once 'lib/contribution/contributionlib.php';
                 $query = 'select max(`historyId`) from `tiki_history`where `pageName`=? and `version`=?';
                 $historyId = $this->getOne($query, array($pageName, (int) $old_version));
                 $contributionlib->change_assigned_contributions($pageName, 'wiki page', $historyId, 'history', '', $pageName . '/' . $old_version, "tiki-pagehistory.php?page={$pageName}&preview={$old_version}");
             }
             /* the following doesn't work because tiki dies if the above query fails
             		if (!$result) {
             			$query2 = "delete from `tiki_history` where `pageName`=? and `version`=?";
             			$result = $this->query($query2,array($pageName,(int) $version));
             			$result = $this->query($query,array($pageName,(int) $version,(int) $lastModif,$user,$ip,$comment,$data,$description));
             		}
             		*/
         }
         if (strtolower($pageName) != 'sandbox') {
             global $logslib;
             include_once 'lib/logs/logslib.php';
             include_once 'lib/diff/difflib.php';
             $bytes = diff2($data, $edit_data, 'bytes');
             $logslib->add_action('Updated', $pageName, 'wiki page', $bytes, $edit_user, $edit_ip, '', $this->now, $hash['contributions'], $hash2);
             if ($prefs['feature_contribution'] == 'y') {
                 global $contributionlib;
                 include_once 'lib/contribution/contributionlib.php';
                 $contributionlib->assign_contributions($hash['contributions'], $pageName, 'wiki page', $description, $pageName, "tiki-index.php?page=" . urlencode($pageName));
             }
         }
         if ($prefs['feature_multilingual'] == 'y' && $lang) {
             // Need to update the translated objects table when an object's language changes.
             $this->query("UPDATE tiki_translated_objects SET lang = ? WHERE objId = ? AND type = 'wiki page'", array($lang, $info['page_id']));
         }
         if ($prefs['feature_user_watches'] == 'y' && $prefs['wiki_watch_minor'] != 'n') {
             //  Deal with mail notifications.
             include_once 'lib/notifications/notificationemaillib.php';
             global $histlib;
             include_once "lib/wiki/histlib.php";
             $old = $histlib->get_version($pageName, $old_version);
             $foo = parse_url($_SERVER["REQUEST_URI"]);
             $machine = $this->httpPrefix() . dirname($foo["path"]);
             require_once 'lib/diff/difflib.php';
             $diff = diff2($old["data"], $edit_data, "unidiff");
             sendWikiEmailNotification('wiki_page_changed', $pageName, $edit_user, $edit_comment, $old_version, $edit_data, $machine, $diff, $minor, $hash['contributions']);
         }
         $query = "delete from `tiki_page_drafts` where `user`=? and `pageName`=?";
         $this->query($query, array($GLOBALS['user'], $pageName));
         if ($prefs['feature_score'] == 'y') {
             $this->score_event($user, 'wiki_edit');
         }
     }
     if ($prefs['feature_search'] == 'y' && $prefs['feature_search_fulltext'] != 'y' && $prefs['search_refresh_index_mode'] == 'normal') {
         require_once 'lib/search/refresh-functions.php';
         refresh_index('pages', $pageName);
     }
 }
开发者ID:Kraiany,项目名称:kraiany_site_docker,代码行数:101,代码来源:tikilib.php

示例9: diff2

 // get last 2 versions of the page and parse them
 $curr_page = $tikilib->get_page_info($data["pageName"]);
 $pageversion = (int) $histlib->get_page_latest_version($data["pageName"]);
 if ($pageversion == FALSE) {
     $prev_page = $curr_page;
     $prev_page["data"] = "";
 } else {
     $prev_page = $histlib->get_page_from_history($data["pageName"], $pageversion, true);
 }
 $_REQUEST['redirectpage'] = 'y';
 //block the redirect interpretation
 $curr_page_p = $tikilib->parse_data($curr_page["{$descId}"]);
 $prev_page_p = $tikilib->parse_data($prev_page["{$descId}"]);
 // do a diff between both pages
 require_once 'lib/diff/difflib.php';
 $diff = diff2($prev_page_p, $curr_page_p, "unidiff");
 $result = "<style TYPE=\"text/css\"> .diffchar { color:red; } </style>";
 foreach ($diff as $part) {
     if ($part["type"] == "diffdeleted") {
         foreach ($part["data"] as $chunk) {
             $result .= "- " . $chunk;
         }
     }
     if ($part["type"] == "diffadded") {
         foreach ($part["data"] as $chunk) {
             $result .= "+ " . $chunk;
         }
     }
 }
 $data["{$descId}"] = $result;
 // hand over the version of the second page
开发者ID:Kraiany,项目名称:kraiany_site_docker,代码行数:31,代码来源:tiki-wiki_rss.php

示例10: update_comment

 /**
  * @param $threadId
  * @param $title
  * @param $comment_rating
  * @param $data
  * @param string $type
  * @param string $summary
  * @param string $smiley
  * @param string $objectId
  * @param string $contributions
  */
 function update_comment($threadId, $title, $comment_rating, $data, $type = 'n', $summary = '', $smiley = '', $objectId = '', $contributions = '')
 {
     global $prefs;
     $comments = $this->table('tiki_comments');
     $hash = md5($title . $data);
     $existingThread = $comments->fetchColumn('threadId', array('hash' => $hash));
     // if exactly same title and data comment does not already exist, and is not the current thread
     if (empty($existingThread) || in_array($threadId, $existingThread)) {
         $comment = $this->get_comment($threadId);
         if ($prefs['feature_actionlog'] == 'y') {
             include_once 'lib/diff/difflib.php';
             $bytes = diff2($comment['data'], $data, 'bytes');
             global $logslib;
             include_once 'lib/logs/logslib.php';
             if ($comment['objectType'] == 'forum') {
                 $logslib->add_action('Updated', $comment['object'], $comment['objectType'], "comments_parentId={$threadId}&amp;{$bytes}#threadId{$threadId}", '', '', '', '', $contributions);
             } else {
                 $logslib->add_action('Updated', $comment['object'], 'comment', "type=" . $comment['objectType'] . "&amp;{$bytes}#threadId{$threadId}", '', '', '', '', $contributions);
             }
         }
         $comments->update(array('title' => $title, 'comment_rating' => (int) $comment_rating, 'data' => $data, 'type' => $type, 'summary' => $summary, 'smiley' => $smiley, 'hash' => $hash), array('threadId' => (int) $threadId));
         if ($prefs['feature_contribution'] == 'y') {
             $contributionlib = TikiLib::lib('contribution');
             $contributionlib->assign_contributions($contributions, $threadId, 'comment', $title, '', '');
         }
         $this->update_comment_links($data, $comment['objectType'], $threadId);
         $type = $this->update_index($comment['objectType'], $threadId);
         if ($type == 'forum post') {
             TikiLib::events()->trigger('tiki.forumpost.update', array('type' => $type, 'object' => $threadId, 'forum_id' => $comment['object'], 'user' => $GLOBALS['user'], 'title' => $title, 'content' => $data, 'index_handled' => true));
         } else {
             if ($comment['objectType'] == 'trackeritem') {
                 $parentobject = TikiLib::lib('trk')->get_tracker_for_item($comment['object']);
             } else {
                 $parentobject = 'not implemented';
             }
             TikiLib::events()->trigger('tiki.comment.update', array('type' => $comment['objectType'], 'object' => $comment['object'], 'parentobject' => $parentobject, 'title' => $title, 'comment' => $threadId, 'user' => $GLOBALS['user'], 'content' => $data));
         }
     }
     // end hash check
 }
开发者ID:jkimdon,项目名称:cohomeals,代码行数:51,代码来源:commentslib.php

示例11: update_comment

 function update_comment($threadId, $title, $comment_rating, $data, $type = 'n', $summary = '', $smiley = '', $objectId = '', $contributions = '')
 {
     global $prefs;
     $hash = md5($title . $data);
     $query = "select `threadId` from `tiki_comments` where `hash`=?";
     $result = $this->query($query, array($hash));
     $existingThread = array();
     while ($res = $result->fetchRow()) {
         $existingThread[] = $res['threadId'];
     }
     // if exactly same title and data comment does not already exist, and is not the current thread
     if (!$result->numRows() || in_array($threadId, $existingThread)) {
         if ($prefs['feature_actionlog'] == 'y') {
             $object = explode(":", $objectId, 2);
             $comment = $this->get_comment($threadId);
             include_once 'lib/diff/difflib.php';
             $bytes = diff2($comment['data'], $data, 'bytes');
             global $logslib;
             include_once 'lib/logs/logslib.php';
             if ($object[0] == 'forum') {
                 $logslib->add_action('Updated', $object[1], $object[0], "comments_parentId={$threadId}&amp;{$bytes}#threadId{$threadId}", '', '', '', '', $contributions);
             } else {
                 $logslib->add_action('Updated', $object[1], 'comment', "type=" . $object[0] . "&amp;{$bytes}#threadId{$threadId}", '', '', '', '', $contributions);
             }
         }
         $query = "update `tiki_comments` set `title`=?, `comment_rating`=?,\n\t`data`=?, `type`=?, `summary`=?, `smiley`=?, `hash`=?\n\t    where `threadId`=?";
         $result = $this->query($query, array($title, (int) $comment_rating, $data, $type, $summary, $smiley, $hash, (int) $threadId));
         if ($prefs['feature_contribution'] == 'y') {
             global $contributionlib;
             include_once 'lib/contribution/contributionlib.php';
             $contributionlib->assign_contributions($contributions, $threadId, 'comment', $title, '', '');
         }
         if ($prefs['feature_search'] == 'y' && $prefs['feature_search_fulltext'] != 'y' && $prefs['search_refresh_index_mode'] == 'normal') {
             require_once 'lib/search/refresh-functions.php';
             refresh_index('comments', $threadId);
         }
         $this->update_comment_links($data, $object[0], $threadId);
     }
     // end hash check
 }
开发者ID:Kraiany,项目名称:kraiany_site_docker,代码行数:40,代码来源:commentslib.php

示例12: array

 $curr_page = $tikilib->get_page_info($data["pageName"]);
 $pageversion = (int) $histlib->get_page_latest_version($data["pageName"]);
 if ($pageversion == false) {
     $prev_page = $curr_page;
     $prev_page["data"] = "";
 } else {
     $prev_page = $histlib->get_page_from_history($data["pageName"], $pageversion, true);
 }
 $_REQUEST['redirectpage'] = 'y';
 //block the redirect interpretation
 $_REQUEST['page'] = $data["pageName"];
 $curr_page_p = $tikilib->parse_data($curr_page[$descId], array('print' => true, 'is_html' => $curr_page['is_html']));
 $prev_page_p = $tikilib->parse_data($prev_page[$descId], array('print' => true, 'is_html' => $curr_page['is_html']));
 // do a diff between both pages
 require_once 'lib/diff/difflib.php';
 $diff = diff2($prev_page_p, $curr_page_p, $curr_page['is_html'] ? 'htmldiff' : 'unidiff');
 if (is_array($diff)) {
     foreach ($diff as $part) {
         if ($part["type"] == "diffdeleted") {
             foreach ($part["data"] as $chunk) {
                 $result .= "<blockquote>- {$chunk}</blockquote>";
             }
         }
         if ($part["type"] == "diffadded") {
             foreach ($part["data"] as $chunk) {
                 $result .= "<blockquote>+ {$chunk}</blockquote>";
             }
         }
     }
 } else {
     $result = strpos($diff, '<tr>') === 0 ? '<table>' . $diff . '</table>' : $diff;
开发者ID:linuxwhy,项目名称:tiki-1,代码行数:31,代码来源:tiki-wiki_rss.php

示例13: array_merge

<html>
<head>
	<title>Parser Diff</title>
<?php 
require_once 'tiki-setup.php';
global $tikilib, $prefs;
$_REQUEST = array_merge(array("page" => "HomePage", "id" => ""), $_REQUEST);
$data = $tikilib->getOne('SELECT data FROM tiki_pages WHERE pageName = ? OR page_id = ?', array($_REQUEST['page'], $_REQUEST['id']));
$prefs['feature_jison_wiki_parser'] = '';
$oldParsed = $tikilib->parse_data($data);
$prefs['feature_jison_wiki_parser'] = 'y';
$newParsed = $tikilib->parse_data($data);
include_once 'lib/diff/difflib.php';
$diff = diff2($oldParsed, $newParsed);
?>
</head>
<body>
	<table style="width: 100%;">
		<tr>
			<td>Old Parser</td>
			<td>New Parser</td>
		</tr>
		<tr>
			<td><?php 
echo $oldParsed;
?>
</td>
			<td><?php 
echo $newParsed;
?>
</td>
开发者ID:hurcane,项目名称:tiki-azure,代码行数:31,代码来源:parser_diff.php

示例14: substr

                                }
                                $info['data'] = substr($info['data'], $real_start, $real_len);
                            }
                            require_once 'lib/diff/difflib.php';
                            if ($info['is_html'] == 1) {
                                $diffold = $tikilib->htmldecode($info['data']);
                            } else {
                                $diffold = $info['data'];
                            }
                            $_REQUEST['allowHtml'] = isset($_REQUEST['allowHtml']) ? $_REQUEST['allowHtml'] : $info['is_html'];
                            if ($_REQUEST['allowHtml']) {
                                $diffnew = $tikilib->htmldecode($data);
                            } else {
                                $diffnew = $data;
                            }
                            $data = diff2($diffold, $diffnew, $_REQUEST["diff_style"]);
                            $smarty->assign_by_ref('diffdata', $data);
                            $smarty->assign('translation_mode', 'y');
                            $data = $smarty->fetch('pagehistory.tpl');
                        }
                    } else {
                        $data = $tikilib->parse_data($data, $options);
                    }
                    echo $data;
                } else {
                    // popup window
                    TikiLib::lib('header')->add_js('function get_new_preview() {
		$("body").css("opacity", 0.6);
		location.replace("' . $tikiroot . 'tiki-auto_save.php?editor_id=' . $_REQUEST['editor_id'] . '&autoSaveId=' . $_REQUEST['autoSaveId'] . '");
	}
	$(window).load(function(){
开发者ID:hurcane,项目名称:tiki-azure,代码行数:31,代码来源:tiki-auto_save.php

示例15: histlib_helper_setup_diff

function histlib_helper_setup_diff($page, $oldver, $newver)
{
    global $smarty, $histlib, $tikilib;
    $info = $tikilib->get_page_info($page);
    if ($oldver == 0 || $oldver == $info["version"]) {
        $old =& $info;
        $smarty->assign_by_ref('old', $info);
    } else {
        // fetch the required page from history, including its content
        while ($oldver > 0 && !($exists = $histlib->version_exists($page, $oldver))) {
            --$oldver;
        }
        if ($exists) {
            $old = $histlib->get_page_from_history($page, $oldver, true);
            $smarty->assign_by_ref('old', $old);
        }
    }
    if ($newver == 0 || $newver >= $info["version"]) {
        $new =& $info;
        $smarty->assign_by_ref('new', $info);
    } else {
        // fetch the required page from history, including its content
        while ($newver > 0 && !($exists = $histlib->version_exists($page, $newver))) {
            --$newver;
        }
        if ($exists) {
            $new = $histlib->get_page_from_history($page, $newver, true);
            $smarty->assign_by_ref('new', $new);
        }
    }
    if (!isset($_REQUEST["diff_style"]) || $_REQUEST["diff_style"] == "old") {
        $_REQUEST["diff_style"] = 'unidiff';
    }
    $smarty->assign('diff_style', $_REQUEST["diff_style"]);
    if ($_REQUEST["diff_style"] == "sideview") {
        $old["data"] = $tikilib->parse_data($old["data"]);
        $new["data"] = $tikilib->parse_data($new["data"]);
    } else {
        require_once 'lib/diff/difflib.php';
        if ($info['is_html'] == 1 and $_REQUEST["diff_style"] != "htmldiff") {
            $search[] = "~</(table|td|th|div|p)>~";
            $replace[] = "\n";
            $search[] = "~<(hr|br) />~";
            $replace[] = "\n";
            $old['data'] = strip_tags(preg_replace($search, $replace, $old['data']), '<h1><h2><h3><h4><b><i><u><span>');
            $new['data'] = strip_tags(preg_replace($search, $replace, $new['data']), '<h1><h2><h3><h4><b><i><u><span>');
        }
        if ($_REQUEST["diff_style"] == "htmldiff") {
            $old["data"] = $tikilib->parse_data($old["data"], $info['is_html'] == 1);
            $new["data"] = $tikilib->parse_data($new["data"], $info['is_html'] == 1);
        }
        $html = diff2($old["data"], $new["data"], $_REQUEST["diff_style"]);
        $smarty->assign_by_ref('diffdata', $html);
    }
}
开发者ID:Kraiany,项目名称:kraiany_site_docker,代码行数:55,代码来源:histlib.php


注:本文中的diff2函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。