summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--conf/entities.conf19
-rw-r--r--inc/parser/action.php17
-rw-r--r--inc/parser/parser.php6
-rw-r--r--inc/parser/xhtml.php40
-rw-r--r--inc/utils.php86
-rw-r--r--media.php2
6 files changed, 141 insertions, 29 deletions
diff --git a/conf/entities.conf b/conf/entities.conf
new file mode 100644
index 000000000..321492fff
--- /dev/null
+++ b/conf/entities.conf
@@ -0,0 +1,19 @@
+# Typography to HTML entities
+#
+# Order does matter!
+
+<-> &harr;
+-> &rarr;
+<- &larr;
+<=> &hArr;
+=> &rArr;
+<= &lArr;
+>> &raquo;
+<< &laquo;
+--- &mdash;
+-- &ndash;
+(c) &copy;
+(tm) &trade;
+(r) &reg;
+
+
diff --git a/inc/parser/action.php b/inc/parser/action.php
index 18238a2d7..82bebf0ae 100644
--- a/inc/parser/action.php
+++ b/inc/parser/action.php
@@ -7,6 +7,8 @@
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
+require_once(DOKU_INC.'inc/utils.php');
+
function parse_to_instructions($text){
global $conf;
@@ -45,10 +47,10 @@ function parse_to_instructions($text){
$Parser->addMode('quote',new Doku_Parser_Mode_Quote());
// FIXME These need data files...
- #$Parser->addMode('acronym',new Doku_Parser_Mode_Acronym(array_keys(getAcronyms())));
+ $Parser->addMode('smiley',new Doku_Parser_Mode_Smiley(array_keys(getSmileys())));
+ $Parser->addMode('acronym',new Doku_Parser_Mode_Acronym(array_keys(getAcronyms())));
#$Parser->addMode('wordblock',new Doku_Parser_Mode_Wordblock(getBadWords()));
- #$Parser->addMode('smiley',new Doku_Parser_Mode_Smiley(array_keys(getSmileys())));
- #$Parser->addMode('entity',new Doku_Parser_Mode_Entity(array_keys(getEntities())));
+ $Parser->addMode('entity',new Doku_Parser_Mode_Entity(array_keys(getEntities())));
$Parser->addMode('multiplyentity',new Doku_Parser_Mode_MultiplyEntity());
$Parser->addMode('quotes',new Doku_Parser_Mode_Quotes());
@@ -76,10 +78,10 @@ function render_as_xhtml($instructions){
$Renderer = & new Doku_Renderer_XHTML();
//FIXME add data
- #$Renderer->smileys = getSmileys();
- #$Renderer->entities = getEntities();
- #$Renderer->acronyms = getAcronyms();
- #$Renderer->interwiki = getInterwiki();
+ $Renderer->smileys = getSmileys();
+ $Renderer->entities = getEntities();
+ $Renderer->acronyms = getAcronyms();
+ $Renderer->interwiki = getInterwiki();
#$Renderer->badwords = getBadWords();
// Loop through the instructions
@@ -94,6 +96,7 @@ function render_as_xhtml($instructions){
/**
* Returns a full page id
*
+ * @todo move to renderer?
*/
function resolve_pageid(&$page,&$exists){
global $ID;
diff --git a/inc/parser/parser.php b/inc/parser/parser.php
index 2091b2c65..25da10f9b 100644
--- a/inc/parser/parser.php
+++ b/inc/parser/parser.php
@@ -565,7 +565,7 @@ class Doku_Parser_Mode_Wordblock extends Doku_Parser_Mode {
//-------------------------------------------------------------------
/**
-* @TODO Quotes and 640x480 are note supported - just straight replacements here
+* @TODO Quotes and 640x480 are not supported - just straight replacements here
*/
class Doku_Parser_Mode_Entity extends Doku_Parser_Mode {
// A list
@@ -615,10 +615,10 @@ class Doku_Parser_Mode_Quotes extends Doku_Parser_Mode {
'(?<=\s)\'(?=\S)',$mode,'singlequoteopening'
);
$this->Lexer->addSpecialPattern(
- '(?<=\S)\'',$mode,'singlequoteclosing'
+ '(?<=^|\S)\'',$mode,'singlequoteclosing'
);
$this->Lexer->addSpecialPattern(
- '(?<=\s)"(?=\S)',$mode,'doublequoteopening'
+ '(?<=^|\s)"(?=\S)',$mode,'doublequoteopening'
);
$this->Lexer->addSpecialPattern(
'(?<=\S)"',$mode,'doublequoteclosing'
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index 5cb4b3001..63bd9a974 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -232,17 +232,25 @@ class Doku_Renderer_XHTML extends Doku_Renderer {
}
/**
- * @TODO Support optional eval of code depending on conf/dokuwiki.php
*/
function php($text) {
- $this->preformatted($text);
+ global $conf;
+ if($conf['phpok']){
+ eval($text);
+ }else{
+ $this->file($text);
+ }
}
/**
- * @TODO Support optional echo of HTML depending on conf/dokuwiki.php
*/
function html($text) {
- $this->file($text);
+ global $conf;
+ if($conf['htmlok']){
+ echo $text;
+ }else{
+ $this->file($text);
+ }
}
function preformatted($text) {
@@ -268,9 +276,9 @@ class Doku_Renderer_XHTML extends Doku_Renderer {
}
/**
- * @TODO Hook up correctly with Geshi
*/
function code($text, $language = NULL) {
+ global $conf;
if ( is_null($language) ) {
$this->preformatted($text);
@@ -282,9 +290,7 @@ class Doku_Renderer_XHTML extends Doku_Renderer {
$geshi->enable_classes();
$geshi->set_header_type(GESHI_HEADER_PRE);
$geshi->set_overall_class('code');
-
- // Fix this
- $geshi->set_link_target('_blank');
+ $geshi->set_link_target($conf['target']['extern']);
$text = $geshi->parse_code();
echo $text;
@@ -306,13 +312,11 @@ class Doku_Renderer_XHTML extends Doku_Renderer {
}
/**
- * @TODO Remove hard coded link to splitbrain.org
*/
function smiley($smiley) {
-
if ( array_key_exists($smiley, $this->smileys) ) {
$title = $this->__xmlEntities($this->smileys[$smiley]);
- echo '<img src="http://wiki.splitbrain.org/smileys/'.$this->smileys[$smiley].
+ echo '<img src="'.DOKU_BASE.'smileys/'.$this->smileys[$smiley].
'" align="middle" alt="'.
$this->__xmlEntities($smiley).'" />';
} else {
@@ -321,8 +325,7 @@ class Doku_Renderer_XHTML extends Doku_Renderer {
}
/**
- * @TODO localization?
- */
+ * not used
function wordblock($word) {
if ( array_key_exists($word, $this->badwords) ) {
echo '** BLEEP **';
@@ -330,6 +333,7 @@ class Doku_Renderer_XHTML extends Doku_Renderer {
echo $this->__xmlEntities($word);
}
}
+ */
function entity($entity) {
if ( array_key_exists($entity, $this->entities) ) {
@@ -340,23 +344,23 @@ class Doku_Renderer_XHTML extends Doku_Renderer {
}
function multiplyentity($x, $y) {
- echo "$x&#215;$y";
+ echo "$x&times;$y";
}
function singlequoteopening() {
- echo "&#8216;";
+ echo "&lsquo;";
}
function singlequoteclosing() {
- echo "&#8217;";
+ echo "&rsquo;";
}
function doublequoteopening() {
- echo "&#8220;";
+ echo "&ldquo;";
}
function doublequoteclosing() {
- echo "&#8221;";
+ echo "&rdquo;";
}
/**
diff --git a/inc/utils.php b/inc/utils.php
new file mode 100644
index 000000000..de98f35ec
--- /dev/null
+++ b/inc/utils.php
@@ -0,0 +1,86 @@
+<?php
+/**
+ * Utilities for collecting data from config files
+ *
+ * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ * @author Harry Fuecks <hfuecks@gmail.com>
+ */
+
+ if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/');
+
+/**
+ * returns a hash of acronyms
+ *
+ * @author Harry Fuecks <hfuecks@gmail.com>
+ */
+function getAcronyms() {
+ static $acronyms = NULL;
+ if ( !$acronyms ) {
+ $acronyms = confToHash(DOKU_INC . 'conf/acronyms.conf');
+ }
+ return $acronyms;
+}
+
+/**
+ * returns a hash of smileys
+ *
+ * @author Harry Fuecks <hfuecks@gmail.com>
+ */
+function getSmileys() {
+ static $smileys = NULL;
+ if ( !$smileys ) {
+ $smileys = confToHash(DOKU_INC . 'conf/smileys.conf');
+ }
+ return $smileys;
+}
+
+/**
+ * returns a hash of entities
+ *
+ * @author Harry Fuecks <hfuecks@gmail.com>
+ */
+function getEntities() {
+ static $entities = NULL;
+ if ( !$entities ) {
+ $entities = confToHash(DOKU_INC . 'conf/entities.conf');
+ }
+ return $entities;
+}
+
+/**
+ * returns a hash of interwikilinks
+ *
+ * @author Harry Fuecks <hfuecks@gmail.com>
+ */
+function getInterwiki() {
+ static $wikis = NULL;
+ if ( !$wikis ) {
+ $wikis = confToHash(DOKU_INC . 'conf/interwiki.conf');
+ }
+ return $wikis;
+}
+
+/**
+ * Builds a hash from a configfile
+ *
+ * @author Harry Fuecks <hfuecks@gmail.com>
+ */
+function confToHash($file) {
+ $conf = array();
+ $lines = @file( $file );
+ if ( !$lines ) {
+ return $conf;
+ }
+
+ foreach ( $lines as $line ) {
+ //ignore comments
+ $line = preg_replace('/[^&]#.*$/','',$line);
+ $line = trim($line);
+ if(empty($line)) continue;
+ $line = preg_split('/\s+/',$line,2);
+ // Build the associative array
+ $conf[$line[0]] = $line[1];
+ }
+
+ return $conf;
+}
diff --git a/media.php b/media.php
index 10e0b36b9..b6d33ce26 100644
--- a/media.php
+++ b/media.php
@@ -60,7 +60,7 @@ function media_upload($NS){
io_makeFileDir($fn);
umask($conf['umask']);
- if(preg_match('/\.'.$conf['uploadtypes'].'$/i',$fn)){
+ if(preg_match('/\.('.$conf['uploadtypes'].')$/i',$fn)){
if (move_uploaded_file($file['tmp_name'], $fn)) {
msg($lang['uploadsucc'],1);
return true;