예제 #1
0
 private function endValue($item, $implodeOn = '')
 {
     if (isset($item) && is_array($item)) {
         $item = end($item);
         $item = $item['Value'];
     }
     if (!empty($implodeOn)) {
         $item = implode(JisonParser_Phraser_Handler::sanitizeToWords($item), ',');
     }
     return $item;
 }
예제 #2
0
 public function stack($level, $content)
 {
     JisonParser_Wiki_Handler::deleteEntities($content);
     $id = implode('_', JisonParser_Phraser_Handler::sanitizeToWords($content));
     if (isset($this->idCount[$id])) {
         $this->idCount[$id]++;
         $id .= $this->idCount[$id];
     } else {
         $this->idCount[$id] = 0;
     }
     if ($level == 1) {
         $this->stack[] = array('content' => $content, 'id' => $id, 'children' => array());
     } else {
         $this->addToStack($this->stack, 1, $level, $content, $id);
     }
     return $id;
 }
예제 #3
0
 function appendToContents(&$contents, $item)
 {
     global $prefs, $_REQUEST;
     $replace = false;
     //lets remove the newentry if it has already been accepted in the past
     foreach ($contents->entry as $i => $existingEntry) {
         foreach ($item->feed->entry as $j => $newEntry) {
             if ($existingEntry->textlink->text == $newEntry->textlink->text && $existingEntry->textlink->href == $newEntry->textlink->href) {
                 unset($item->feed->entry[$j]);
             }
         }
     }
     //lets check if the hash is correct and that the phrase actually exists within the wiki page
     $checks = array();
     foreach ($item->feed->entry as $i => $newEntry) {
         $checks[$i] = array();
         $checks[$i]['titleHere'] = utf8_encode(implode('', JisonParser_Phraser_Handler::sanitizeToWords($prefs['browsertitle'])));
         $checks[$i]['phraseThere'] = utf8_encode(implode('', JisonParser_Phraser_Handler::sanitizeToWords($newEntry->forwardlink->text)));
         $checks[$i]['hashHere'] = hash_hmac('md5', $checks[$i]['titleHere'], $checks[$i]['phraseThere']);
         $checks[$i]['hashThere'] = $newEntry->forwardlink->hash;
         $checks[$i]['exists'] = JisonParser_Phraser_Handler::hasPhrase(TikiLib::lib('wiki')->get_parse($_REQUEST['page']), utf8_encode($newEntry->forwardlink->text));
         $checks[$i]['reason'] = '';
         if ($checks[$i]['hashHere'] != $checks[$i]['hashThere']) {
             $checks[$i]['reason'] .= '_hash_';
             unset($item->feed->entry[$i]);
         }
         if ($newEntry->forwardlink->websiteTitle != $prefs['browsertitle']) {
             $checks[$i]['reason'] .= '_title_';
             unset($item->feed->entry[$i]);
         }
         if (!$checks[$i]['exists']) {
             if (empty($checks[$i]['reason'])) {
                 $checks[$i]['reason'] .= '_no_existence_hash_pass_';
             } else {
                 $checks[$i]['reason'] .= '_no_existence_';
             }
             unset($item->feed->entry[$i]);
         }
     }
     if ($this->debug) {
         print_r($checks);
     }
     if (count($item->feed->entry) > 0) {
         $replace = true;
         $contents->entry += $item->feed->entry;
     }
     return $replace;
 }
function wikiplugin_textlink($data, $params)
{
    global $tikilib, $headerlib, $caching, $page;
    static $textlinkI = 0;
	++$textlinkI;
	$i = $textlinkI;
	
	$params = array_merge(array("clipboarddata" => ""), $params);
	extract($params, EXTR_SKIP);
	
	$clipboarddata = json_decode(stripslashes(trim(urldecode($clipboarddata))));
	if (empty($clipboarddata)) return $data;
	
	$clipboarddata->href = urldecode($clipboarddata->href);
	
	$phraser = new JisonParser_Phraser_Handler();
	$id = implode("", $phraser->sanitizeToWords($data));
	
	Feed_ForwardLink_Send::add(
					array(
						"page"=> $page,
						"forwardlink"=> $clipboarddata,
						"textlink"=> array(
							"text"=> 	$data,
							"href"=> 	$tikilib->tikiUrl() . "tiki-index.php?page=$page#" . $id,
							"id"=>		$clipboarddata->hash. "_" . $page . "_" . $id
						)
					)
	);
	$data = addslashes(htmlspecialchars($data));
	$date = $tikilib->get_short_date($clipboarddata->date);

	$clipboarddata->href = addslashes(htmlspecialchars($clipboarddata->href));
	$clipboarddata->text = addslashes(htmlspecialchars($clipboarddata->text));

	if (!empty($clipboarddata->href)) {
		$headerlib
			->add_jsfile("lib/jquery/tablesorter/jquery.tablesorter.js")
			->add_cssfile("lib/jquery_tiki/tablesorter/themes/tiki/style.css")
			->add_jq_onready(<<<JQ
				$('#page-data').bind('rangyDone', function() {
					$('#$id').click(function() {
						var table = $('<div><table class="tablesorter">' +
							'<thead>' + 
								'<tr>' +
									'<th>' + tr('Date') + '</th>' +
									'<th>' + tr('Click below to read Citing blocks') + '</th>' +
								'</tr>' +
							'</thead>' +
							'<tbody>' +
								'<tr>' +
									'<td>$date</td>' +
									'<td><a href="$clipboarddata->href" class="read">Read</a></td>' +
								'</tr>' +
							'</tbody>' +
						'</table></div>')
							.dialog({
								title: tr("ForwardLinks To: ") + "$data",
								modal: true
							})
							.tablesorter();
						
						table.find('.read').click(function() {
							$('<form action="$clipboarddata->href" method="post">' + 
								'<input type="hidden" name="phrase" value="$clipboarddata->text" />' +
							'</form>')
								.appendTo('body')
								.submit();
							return false;
						});
						return false;
					});
				});
JQ
			);
		
    	return "~np~<span class='textlink'>~/np~".$data."~np~</span><a href='" .$clipboarddata->href ."' id='" . $id . "'>*</a>~/np~";
	} else {
    	return $data;
	}
}