From 780f83a118146cf67509574ac88024c2cb03cf3a Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Sat, 25 Jun 2016 06:27:14 -0500 Subject: Post generation about new wiki is optional, default is NOT to post. Fixed bug in wiki creation. Added embed image dialog and album browser. --- include/wiki.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/wiki.php b/include/wiki.php index a89db3358..fdbc704dc 100644 --- a/include/wiki.php +++ b/include/wiki.php @@ -51,7 +51,7 @@ function wiki_init_wiki($channel, $wiki) { return null; } // Create GitRepo object - $git = new GitRepo($channel['channel_address'], null, false, $name, __DIR__ . '/../' . $path); + $git = new GitRepo($channel['channel_address'], null, false, $wiki['urlName'], __DIR__ . '/../' . $path); if(!$git->initRepo()) { logger('Error creating new git repo in ' . $git->path); return null; @@ -82,7 +82,7 @@ function wiki_create_wiki($channel, $observer_hash, $wiki, $acl) { $ac = $acl->get(); $mid = item_message_id(); $arr = array(); // Initialize the array of parameters for the post - $item_hidden = 0; // TODO: Allow form creator to send post to ACL about new game automatically + $item_hidden = ((intval($wiki['postVisible']) === 0) ? 1 : 0); $wiki_url = z_root() . '/wiki/' . $channel['channel_address'] . '/' . $wiki['urlName']; $arr['aid'] = $channel['channel_account_id']; $arr['uid'] = $channel['channel_id']; @@ -240,13 +240,11 @@ function wiki_rename_page($arr) { return array('message' => 'Wiki not found.', 'success' => false); } $page_path_old = $w['path'].'/'.$pageUrlName.'.md'; - logger('$page_path_old: ' . $page_path_old); if (!is_readable($page_path_old) === true) { return array('message' => 'Cannot read wiki page: ' . $page_path_old, 'success' => false); } $page = array('rawName' => $pageNewName, 'htmlName' => escape_tags($pageNewName), 'urlName' => urlencode(escape_tags($pageNewName)), 'fileName' => urlencode(escape_tags($pageNewName)).'.md'); $page_path_new = $w['path'] . '/' . $page['fileName'] ; - logger('$page_path_new: ' . $page_path_new); if (is_file($page_path_new)) { return array('message' => 'Page already exists.', 'success' => false); } -- cgit v1.2.3 From 2dc1236dcae487bf3887942a2e58a240157bb896 Mon Sep 17 00:00:00 2001 From: Treer Date: Sat, 25 Jun 2016 22:38:15 +1000 Subject: Allow absolute links to css and js files --- include/plugin.php | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/plugin.php b/include/plugin.php index c95f8cbf9..3f60e5e04 100755 --- a/include/plugin.php +++ b/include/plugin.php @@ -551,15 +551,21 @@ function head_get_css() { } function format_css_if_exists($source) { - if (strpos($source[0], '/') !== false) + $path_prefix = script_path() . '/'; + + if (strpos($source[0], '/') !== false) { + // The source is a URL $path = $source[0]; - else + // If the url starts with // then it's an absolute URL + if($source[0][0] === '/' && $source[0][1] === '/') $path_prefix = ''; + } else { + // It's a file from the theme $path = theme_include($source[0]); + } if($path) { - $path = script_path() . '/' . $path; $qstring = ((parse_url($path, PHP_URL_QUERY)) ? '&' : '?') . 'v=' . STD_VERSION; - return '' . "\r\n"; + return '' . "\r\n"; } } @@ -643,14 +649,20 @@ function head_get_main_js() { } function format_js_if_exists($source) { - if(strpos($source,'/') !== false) + $path_prefix = script_path() . '/'; + + if(strpos($source,'/') !== false) { + // The source is a URL $path = $source; - else + // If the url starts with // then it's an absolute URL + if($source[0][0] === '/' && $source[0][1] === '/') $path_prefix = ''; + } else { + // It's a file from the theme $path = theme_include($source); + } if($path) { - $path = script_path() . '/' . $path; $qstring = ((parse_url($path, PHP_URL_QUERY)) ? '&' : '?') . 'v=' . STD_VERSION; - return '' . "\r\n" ; + return '' . "\r\n" ; } } -- cgit v1.2.3 From 0df3978cc5891f1383dd0dbcdc1c6b4c0010e645 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Sat, 25 Jun 2016 14:29:52 -0500 Subject: A page name wrapped in double brackets is converted into a link to another page in the current wiki --- include/wiki.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'include') diff --git a/include/wiki.php b/include/wiki.php index fdbc704dc..63cf70f3c 100644 --- a/include/wiki.php +++ b/include/wiki.php @@ -473,4 +473,24 @@ function wiki_generate_page_filename($name) { } else { return $file . '.md'; } +} + +function wiki_convert_links($s, $wikiURL) { + + if (strpos($s,'[[') !== false) { + preg_match_all("/\[\[(.*?)\]\]/", $s, $match); + $pages = $pageURLs = array(); + foreach ($match[1] as $m) { + // TODO: Why do we need to double urlencode for this to work? + $pageURLs[] = urlencode(urlencode(escape_tags($m))); + $pages[] = $m; + } + $idx = 0; + while(strpos($s,'[[') !== false) { + $replace = ''.$pages[$idx].''; + $s = preg_replace("/\[\[(.*?)\]\]/", $replace, $s, 1); + $idx++; + } + } + return $s; } \ No newline at end of file -- cgit v1.2.3 From e0a76376265937a62c48fde03c7947cde972f8b7 Mon Sep 17 00:00:00 2001 From: Treer Date: Sun, 26 Jun 2016 13:08:40 +1000 Subject: fix absolute .js urls --- include/plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/plugin.php b/include/plugin.php index 3f60e5e04..6dfda1cc9 100755 --- a/include/plugin.php +++ b/include/plugin.php @@ -655,7 +655,7 @@ function format_js_if_exists($source) { // The source is a URL $path = $source; // If the url starts with // then it's an absolute URL - if($source[0][0] === '/' && $source[0][1] === '/') $path_prefix = ''; + if($source[0] === '/' && $source[1] === '/') $path_prefix = ''; } else { // It's a file from the theme $path = theme_include($source); -- cgit v1.2.3