Skip to content

Commit

Permalink
fixes #1002
Browse files Browse the repository at this point in the history
  • Loading branch information
tablatronix committed Jan 26, 2015
1 parent 048cc39 commit 526ed37
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
3 changes: 2 additions & 1 deletion admin/base.php
Expand Up @@ -12,7 +12,8 @@
$id = str_replace ('/','',$id);
$id = lowercase($id);
} else {
$id = "index";
$id = getDef('GSINDEXSLUG');
if(!pageExists($id)) $id = 'index';
}

// filter to modify page id request
Expand Down
30 changes: 23 additions & 7 deletions admin/inc/basic.php
Expand Up @@ -508,7 +508,6 @@ function createPageXml($title, $url = null, $data = array(), $overwrite = false)

// setup url, falls back to title if not set
if(!isset($url)) $url = $title;
debugLog(gettype($url));
$url = prepareSlug($url); // prepare slug, clean it, translit, truncate

$title = truncate($title,GSTITLEMAX); // truncate long titles
Expand Down Expand Up @@ -596,6 +595,21 @@ function pageHasDraft($id){
return file_exists(GSDATADRAFTSPATH . $id .".xml");
}

/**
* check if a page exists.
* check pagecache first then check page file exist
*
* @since 3.4
* @param str $id slug id
* @return bool true if page exists
*/
function pageExists($id){
GLOBAL $pagesArray;
if(isset($pagesArray[$id])) return true;
return file_exists(GSDATAPAGESPATH . $id .'.xml');
return false;
}

/**
* prepare a slug to gs standads
* sanitizes, performs translist for filename, truncates to GSFILENAMEMAX
Expand Down Expand Up @@ -1000,13 +1014,15 @@ function generate_url($slug, $absolute = false){
$path = tsl(getSiteURL($absolute));
$url = $path; // var to build url into

if ($PRETTYURLS == '1' && $slug != 'index'){
$url .= generate_permalink($slug);
}
else if (!empty($PERMALINK) && $slug != 'index'){
$url .= generate_permalink($slug,$PERMALINK);
if($slug != getDef('GSINDEXSLUG')){
if ($PRETTYURLS == '1'){
$url .= generate_permalink($slug);
}
else if (!empty($PERMALINK)){
$url .= generate_permalink($slug,$PERMALINK);
}
else $url .= 'index.php?id='.$slug;
}
else if ($slug != 'index') $url .= 'index.php?id='.$slug;

$url = exec_filter('generate_url',$url); // @filter generate_url (str) for generating urls after processing, for use with custom tokens etc
return $url;
Expand Down
1 change: 1 addition & 0 deletions admin/inc/common.php
Expand Up @@ -87,6 +87,7 @@
'GSSITEURLREL' => true, // (bool) Use root relative urls for $SITEURL
'GSEMAILLINKBACK' => 'http://get-simple.info/', // (str) url used in email template
'GSAJAXSAVE' => true, // (bool) use ajax for saving themes, components, and pages
'GSINDEXSLUG' => 'index', // (str) slug to use as index when no slug provided
# STYLES -------------------------------------------------------------------------------------------------------------------------------------------
'GSSTYLE' => 'wide,sbfixed', // (str-csv) default style modifiers
'GSWIDTH' => '1024px', // (str) pagewidth on backend,(max-width), null,'none','' for 100% width
Expand Down
2 changes: 1 addition & 1 deletion admin/inc/template_functions.php
Expand Up @@ -975,7 +975,7 @@ function getPagesRow($page,$level,$index,$parent,$children){
if ($page['menuStatus'] != '' ) { $pagemenustatus = ' <span class="label label-ghost">'.i18n_r('MENUITEM_SUBTITLE').'</span>'; }
if ($page['private'] != '' ) { $pageprivate = ' <span class="label label-ghost">'.i18n_r('PRIVATE_SUBTITLE').'</span>'; }
if (pageHasDraft($page['url'])) { $pagedraft = ' <span class="label label-ghost">'.lowercase(i18n_r('LABEL_DRAFT')).'</span>'; }
if ($page['url'] == 'index' ) { $pageindex = ' <span class="label label-ghost">'.i18n_r('HOMEPAGE_SUBTITLE').'</span>'; }
if ($page['url'] == getDef('GSINDEXSLUG')) { $pageindex = ' <span class="label label-ghost">'.i18n_r('HOMEPAGE_SUBTITLE').'</span>'; }
if(dateIsToday($page['pubDate'])) { $pagepubdate = ' <span class="datetoday">'. output_date($page['pubDate']) . '</span>';} else { $pagepubdate = '<span>'. output_date($page['pubDate']) . "</span>";}

$pagetitle = cl($pagetitle);
Expand Down

0 comments on commit 526ed37

Please sign in to comment.