Merge lp:~uranium235/pluck-cms/pluck-cms into lp:pluck-cms

Proposed by Uranium235
Status: Merged
Merged at revision: 398
Proposed branch: lp:~uranium235/pluck-cms/pluck-cms
Merge into: lp:pluck-cms
Diff against target: 72 lines (+14/-10)
3 files modified
data/inc/editpage.php (+8/-7)
data/inc/functions.admin.php (+4/-1)
data/inc/functions.all.php (+2/-2)
To merge this branch: bzr merge lp:~uranium235/pluck-cms/pluck-cms
Reviewer Review Type Date Requested Status
Anders G. Jørgensen Approve
Review via email: mp+130704@code.launchpad.net

Description of the change

Fix saving empty seo url file names.
Allow international characters in seo url again.

To post a comment you must log in.
Revision history for this message
Anders G. Jørgensen (spirit55555) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'data/inc/editpage.php'
--- data/inc/editpage.php 2012-10-11 19:52:57 +0000
+++ data/inc/editpage.php 2012-10-21 14:28:19 +0000
@@ -28,22 +28,23 @@
28 if (!isset($_POST['hidden']))28 if (!isset($_POST['hidden']))
29 $_POST['hidden'] = 'yes';29 $_POST['hidden'] = 'yes';
3030
31 //Save the page, but only if a title has been entered.31 //Save the page, but only if a title has been entered and it's seo url is not empty.
32 if (!empty($_POST['title'])) {32 if (!empty($_POST['title']) && seo_url($_POST['title'])) {
33 //If we are editing an existing page, pass current seo-name.33 //If we are editing an existing page, pass current seo-name.
34 if (isset($_GET['page'])) {34 if (isset($_GET['page'])) {
35 $seoname = save_page($_POST['title'], $_POST['content'], $_POST['hidden'], $_POST['sub_page'], $_POST['description'], $_POST['keywords'], $module_additional_data, $_GET['page']);35 $seoname = save_page($_POST['title'], $_POST['content'], $_POST['hidden'], $_POST['sub_page'], $_POST['description'], $_POST['keywords'], $module_additional_data, $_GET['page']);
36 }36 } else {
37 //If we are creating a new page, don't pass seo-name.37 //If we are creating a new page, don't pass seo-name.
38 else
39 $seoname = save_page($_POST['title'], $_POST['content'], $_POST['hidden'], $_POST['sub_page'], $_POST['description'], $_POST['keywords'], $module_additional_data);38 $seoname = save_page($_POST['title'], $_POST['content'], $_POST['hidden'], $_POST['sub_page'], $_POST['description'], $_POST['keywords'], $module_additional_data);
39 }
40 //If seoname is false, a file already exists with the same name
40 if (empty($seoname)) {41 if (empty($seoname)) {
41 $error = show_error($lang['page']['name_exists'], 1, true);42 $error = show_error($lang['page']['name_exists'], 1, true);
42 }43 }
43 }44 } else {
44 //If no title has been chosen, set error.45 //If no title has been chosen or the seo url for the title is empty, set error.
45 else
46 $error = show_error($lang['page']['no_title'], 1, true);46 $error = show_error($lang['page']['no_title'], 1, true);
47 }
4748
48 //Redirect to the new title only if it is a plain save.49 //Redirect to the new title only if it is a plain save.
49 if (isset($_POST['save']) && !isset($error)) {50 if (isset($_POST['save']) && !isset($error)) {
5051
=== modified file 'data/inc/functions.admin.php'
--- data/inc/functions.admin.php 2012-10-08 13:53:04 +0000
+++ data/inc/functions.admin.php 2012-10-21 14:28:19 +0000
@@ -175,7 +175,7 @@
175 sort($files, SORT_NUMERIC);175 sort($files, SORT_NUMERIC);
176 foreach ($files as $file) {176 foreach ($files as $file) {
177 $pages[] = $patch.'/'.$file;177 $pages[] = $patch.'/'.$file;
178 if (file_exists(PAGE_DIR.'/'.get_page_seoname($patch.'/'.$file)))178 if (is_dir(PAGE_DIR.'/'.get_page_seoname($patch.'/'.$file)))
179 get_pages(PAGE_DIR.'/'.get_page_seoname($patch.'/'.$file), $pages);179 get_pages(PAGE_DIR.'/'.get_page_seoname($patch.'/'.$file), $pages);
180 }180 }
181 unset($file);181 unset($file);
@@ -504,6 +504,9 @@
504 run_hook('admin_save_page_meta', array(&$description, &$keywords));504 run_hook('admin_save_page_meta', array(&$description, &$keywords));
505 run_hook('admin_save_page_module_additional_data', array(&$module_additional_data));505 run_hook('admin_save_page_module_additional_data', array(&$module_additional_data));
506506
507 //Check if the seo url of the title is empty.
508 if (!seo_url($title))
509 return false;
507 //Check if a page already exists with the name.510 //Check if a page already exists with the name.
508 if ((!isset($current_seoname) || $current_seoname != $subpage.seo_url($title)) && get_page_filename($subpage.seo_url($title)) != false)511 if ((!isset($current_seoname) || $current_seoname != $subpage.seo_url($title)) && get_page_filename($subpage.seo_url($title)) != false)
509 return false;512 return false;
510513
=== modified file 'data/inc/functions.all.php'
--- data/inc/functions.all.php 2012-10-08 13:53:04 +0000
+++ data/inc/functions.all.php 2012-10-21 14:28:19 +0000
@@ -250,8 +250,8 @@
250 require ('data/inc/lib/url_replace.php');250 require ('data/inc/lib/url_replace.php');
251 //replace some non-ASCII international characters with their ASCII substitute251 //replace some non-ASCII international characters with their ASCII substitute
252 $url = strtr($url, $lang_url_replace);252 $url = strtr($url, $lang_url_replace);
253 //replace all sequences of characters that would have to be urlencoded (incl. "-" and ".") to a single "-"253 //replace all sequences of characters that would have to be urlencoded (incl. "-" and ".", excl. intl. chars) to a single "-"
254 $url = preg_replace('/[^0-9A-Za-z_]+/', '-', $url);254 $url = preg_replace('/[^0-9A-Za-z_\x80-\xFF]+/', '-', $url);
255 //remove "-" from the beginning and end of the string255 //remove "-" from the beginning and end of the string
256 $url = trim($url, '-');256 $url = trim($url, '-');
257 //only use lower case257 //only use lower case

Subscribers

People subscribed via source and target branches