Permalink
Browse files

More parser fixes

  • Loading branch information...
1 parent abd7048 commit 3ad08cf231c7b8aa69dc1bded4704594b1ccf240 @nikop nikop committed Oct 19, 2011
@@ -159,11 +159,14 @@ static protected function __boolean_trim($content)
static function toText($content, $single_line = true)
{
$return = '';
+
foreach ($content as $c)
{
switch ($c['type'])
{
case WikiParser::ELEMENT_SEMI_COLON:
+ case WikiParser::CONTROL_BLOCK_LEVEL_OPEN:
+ case WikiParser::NO_PARSE:
case WikiParser::TEXT:
$return .= $c['content'];
break;
@@ -419,7 +422,7 @@ private function __parseTableOfContent($sections, $main = true, $tlevel = 2)
/**
* Parser page into another WikiParser (used for templates)
*/
- public function parseTo(WikiParser $target, $text, $is_template = true)
+ public function parseTo($target, $text, $is_template = true)
{
$this->__parse($target, $text, $is_template);
}
@@ -1475,7 +1478,7 @@ public function throwContentTo($target)
$value = WikiExtension::getFunction($function);
if (isset($value['callback']))
- call_user_func($value['callback'], $this->wikiparser, $params);
+ call_user_func($value['callback'], $target, $params);
else
$target->throwContent(WikiParser::WARNING, 'unknown_function', $this->getUnparsed(), array($function));
}
@@ -1546,7 +1549,7 @@ public function throwContentTo($target)
elseif ($value === false && count($params) == 1)
$this->wikiparser->page->variables[$variable] = WikiParser::toText($params[0]);
elseif ($value !== false)
- $target->throwContent(WikiParser::ELEMENT, new WikiVariable($this->wikiparser, $value['callback'], $params), $unparsed);
+ $target->throwContent(WikiParser::ELEMENT, new WikiVariable($target, $value['callback'], $params), $unparsed);
else
$target->throwContent(WikiParser::WARNING, 'unknown_variable', $unparsed);
}
@@ -1914,7 +1917,7 @@ class WikiVariable extends WikiElement
var $params;
var $value;
- function __construct(Wikiparser $wikiparser, $callback, $params)
+ function __construct($wikiparser, $callback, $params)
{
$this->wikiparser = $wikiparser;
$this->callback = $callback;
@@ -1941,6 +1944,11 @@ function getHtml()
return is_string($value) ? $value : '';
}
+
+ function toBoolean()
+ {
+ return !empty($this->value);
+ }
/**
* Returns if this is block level tag
View
@@ -319,25 +319,23 @@ function Wiki($standalone = false, $prefix = null)
// Don't index pages with invalid subaction
if (!empty($_REQUEST['sa']) && $subaction != $_REQUEST['sa'])
$context['robot_no_index'] = true;
- else
+
+ foreach ($context['wikimenu'] as $id => $menu_item)
{
- foreach ($context['wikimenu'] as $id => $menu_item)
+ if (!$menu_item['show'])
{
- if (!$menu_item['show'])
+ if ($menu_item['selected'])
{
- if ($menu_item['selected'])
- {
- $context['wikimenu'][$id]['selected'] = false;
-
- // Use view action then
- $subaction = 'view';
- $context['wikimenu'][$subaction]['selected'] = true;
- }
+ $context['wikimenu'][$id]['selected'] = false;
- unset($context['wikimenu'][$id]);
-
- continue;
+ // Use view action then
+ $subaction = 'view';
+ $context['wikimenu'][$subaction]['selected'] = true;
}
+
+ unset($context['wikimenu'][$id]);
+
+ continue;
}
}
@@ -204,7 +204,7 @@ static function registerExtension()
* @param <type> $parameters
* @return <type>
*/
- static function variable_WikiVersion(WikiParser $wikiparser, $parameters)
+ static function variable_WikiVersion($wikiparser, $parameters)
{
global $wiki_version;
@@ -232,13 +232,12 @@ static function variable_DisplayTitle(WikiParser $wikiparser, $parameters)
* @param WikiParser $wikiparser
* @param <type> $parameters
*/
- static function function_if(WikiParser $wikiparser, $parameters)
+ static function function_if($wikiparser, $parameters)
{
$result = WikiParser::toBoolean($parameters[0]);
$true_cond = $parameters[1];
if (!empty($parameters[2]))
$false_cond = $parameters[2];
-
$wikiparser->throwContentArray($result ? $true_cond : (isset($false_cond) ? $false_cond : array()));
}
@@ -1,5 +1,11 @@
<?php
-// Version: 0.2; Wiki
+/**
+ *
+ *
+ * @package SMFWiki
+ * @version 0.3
+ * @license http://download.smfwiki.net/license.php SMF Wiki license
+ */
function wiki_render(array $content)
{
@@ -93,7 +99,7 @@ function template_wiki_above()
{
if (!empty($item['url']))
echo '
- <li', $item['selected'] ? ' class="selected"' : '', '><a href="', $item['url'], '">', $item['title'], '</a></li>';
+ <li><a href="', $item['url'], '"', $item['selected'] ? ' class="current_page"' : '', '>', $item['title'], '</a></li>';
else
echo '
<li>', $item['title'], '</li>';
@@ -1,5 +1,11 @@
<?php
-// Version: 0.2; WikiAdmin
+/**
+ *
+ *
+ * @package SMFWiki
+ * @version 0.3
+ * @license http://download.smfwiki.net/license.php SMF Wiki license
+ */
function template_wiki_admin_main()
{
@@ -1,5 +1,11 @@
<?php
-// Version: 0.2; WikiFiles
+/**
+ *
+ *
+ * @package SMFWiki
+ * @version 0.3
+ * @license http://download.smfwiki.net/license.php SMF Wiki license
+ */
function template_wiki_file_upload()
{
@@ -1,5 +1,11 @@
<?php
-// Version: 0.2; WikiPage
+/**
+ *
+ *
+ * @package SMFWiki
+ * @version 0.3
+ * @license http://download.smfwiki.net/license.php SMF Wiki license
+ */
function output_toc($baseurl, $blevel, $toc)
{
@@ -1,7 +1,5 @@
<?php
-// Version: 2.0 RC1; Modifications
-
-// Important! Before editing these language files please read the text at the topic of index.english.php.
+// Version: 2.0; Modifications
// SMF Wiki
$txt['wiki'] = 'Wiki';
@@ -70,7 +70,6 @@
// Special pages
$txt['wiki_special_pages'] = 'Special Pages';
-
// Admin
$txt['wiki_settings'] = 'Wiki Settings';
$txt['wiki_admin_title'] = 'Wiki';
View
@@ -1,9 +1,10 @@
<?php
/**
- * Wiki install
- *
- * @package Wiki
- * @subpackage Install
+ * Wiki Installer
+ *
+ * @package SMFWiki
+ * @version 0.3
+ * @license http://download.smfwiki.net/license.php SMF Wiki license
*/
// If SSI.php is in the same place as this file, and SMF isn't defined, this is being run standalone.
View
@@ -1,24 +1,11 @@
<?php
-/**********************************************************************************
-* wikistandalone.php *
-***********************************************************************************
-* SMF Wiki *
-* =============================================================================== *
-* Software Version: SMF Wiki 0.2 *
-* Software by: Niko Pahajoki (http://www.madjoki.com) *
-* Copyright 2008-2009 by: Niko Pahajoki (http://www.madjoki.com) *
-* Support, News, Updates at: http://www.smfarcade.info *
-***********************************************************************************
-* This program is free software; you may redistribute it and/or modify it under *
-* the terms of the provided license as published by Simple Machines LLC. *
-* *
-* This program is distributed in the hope that it is and will be useful, but *
-* WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY *
-* or FITNESS FOR A PARTICULAR PURPOSE. *
-* *
-* See the "license.txt" file for details of the Simple Machines license. *
-* The latest version can always be found at http://www.simplemachines.org. *
-**********************************************************************************/
+/**
+ *
+ *
+ * @package SMFWiki
+ * @version 0.3
+ * @license http://download.smfwiki.net/license.php SMF Wiki license
+ */
/*
This file is for running wiki in standalone mode, where Wiki is not located inside forum.

0 comments on commit 3ad08cf

Please sign in to comment.