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
1=== modified file 'data/inc/editpage.php'
2--- data/inc/editpage.php 2012-10-11 19:52:57 +0000
3+++ data/inc/editpage.php 2012-10-21 14:28:19 +0000
4@@ -28,22 +28,23 @@
5 if (!isset($_POST['hidden']))
6 $_POST['hidden'] = 'yes';
7
8- //Save the page, but only if a title has been entered.
9- if (!empty($_POST['title'])) {
10+ //Save the page, but only if a title has been entered and it's seo url is not empty.
11+ if (!empty($_POST['title']) && seo_url($_POST['title'])) {
12 //If we are editing an existing page, pass current seo-name.
13 if (isset($_GET['page'])) {
14 $seoname = save_page($_POST['title'], $_POST['content'], $_POST['hidden'], $_POST['sub_page'], $_POST['description'], $_POST['keywords'], $module_additional_data, $_GET['page']);
15- }
16+ } else {
17 //If we are creating a new page, don't pass seo-name.
18- else
19 $seoname = save_page($_POST['title'], $_POST['content'], $_POST['hidden'], $_POST['sub_page'], $_POST['description'], $_POST['keywords'], $module_additional_data);
20+ }
21+ //If seoname is false, a file already exists with the same name
22 if (empty($seoname)) {
23 $error = show_error($lang['page']['name_exists'], 1, true);
24 }
25- }
26- //If no title has been chosen, set error.
27- else
28+ } else {
29+ //If no title has been chosen or the seo url for the title is empty, set error.
30 $error = show_error($lang['page']['no_title'], 1, true);
31+ }
32
33 //Redirect to the new title only if it is a plain save.
34 if (isset($_POST['save']) && !isset($error)) {
35
36=== modified file 'data/inc/functions.admin.php'
37--- data/inc/functions.admin.php 2012-10-08 13:53:04 +0000
38+++ data/inc/functions.admin.php 2012-10-21 14:28:19 +0000
39@@ -175,7 +175,7 @@
40 sort($files, SORT_NUMERIC);
41 foreach ($files as $file) {
42 $pages[] = $patch.'/'.$file;
43- if (file_exists(PAGE_DIR.'/'.get_page_seoname($patch.'/'.$file)))
44+ if (is_dir(PAGE_DIR.'/'.get_page_seoname($patch.'/'.$file)))
45 get_pages(PAGE_DIR.'/'.get_page_seoname($patch.'/'.$file), $pages);
46 }
47 unset($file);
48@@ -504,6 +504,9 @@
49 run_hook('admin_save_page_meta', array(&$description, &$keywords));
50 run_hook('admin_save_page_module_additional_data', array(&$module_additional_data));
51
52+ //Check if the seo url of the title is empty.
53+ if (!seo_url($title))
54+ return false;
55 //Check if a page already exists with the name.
56 if ((!isset($current_seoname) || $current_seoname != $subpage.seo_url($title)) && get_page_filename($subpage.seo_url($title)) != false)
57 return false;
58
59=== modified file 'data/inc/functions.all.php'
60--- data/inc/functions.all.php 2012-10-08 13:53:04 +0000
61+++ data/inc/functions.all.php 2012-10-21 14:28:19 +0000
62@@ -250,8 +250,8 @@
63 require ('data/inc/lib/url_replace.php');
64 //replace some non-ASCII international characters with their ASCII substitute
65 $url = strtr($url, $lang_url_replace);
66- //replace all sequences of characters that would have to be urlencoded (incl. "-" and ".") to a single "-"
67- $url = preg_replace('/[^0-9A-Za-z_]+/', '-', $url);
68+ //replace all sequences of characters that would have to be urlencoded (incl. "-" and ".", excl. intl. chars) to a single "-"
69+ $url = preg_replace('/[^0-9A-Za-z_\x80-\xFF]+/', '-', $url);
70 //remove "-" from the beginning and end of the string
71 $url = trim($url, '-');
72 //only use lower case

Subscribers

People subscribed via source and target branches