[pLog-svn] r3316 - in plog/trunk: class/dao locale templates/admin
jondaley at devel.lifetype.net
jondaley at devel.lifetype.net
Tue May 2 00:50:46 GMT 2006
Author: jondaley
Date: 2006-05-02 00:50:46 +0000 (Tue, 02 May 2006)
New Revision: 3316
Modified:
plog/trunk/class/dao/articles.class.php
plog/trunk/locale/locale_en_UK.php
plog/trunk/templates/admin/globalsettings_url.template
Log:
the rest of the code to force post slugs to be unique within one blog.
Modified: plog/trunk/class/dao/articles.class.php
===================================================================
--- plog/trunk/class/dao/articles.class.php 2006-05-02 00:31:56 UTC (rev 3315)
+++ plog/trunk/class/dao/articles.class.php 2006-05-02 00:50:46 UTC (rev 3316)
@@ -135,6 +135,8 @@
/**
* @private
+ * onlyCheck == true means to not bother actually getting the row, but
+ * just check if the article exists
*/
function _getBlogArticleFromQuery( $query, $includeHiddenFields, $onlyCheck=false )
{
@@ -779,20 +781,26 @@
*/
function addArticle( &$newArticle )
{
-
- $slug = $newArticle->getPostSlug();
- $i = 1;
- // check if there already is a blog with the same mangled name
- while($this->checkBlogArticleTitle($slug, $newArticle->getBlog())){
- $i++;
- // and if so, assign a new one
- // if we already tried with blogname+"i" we have
- // to strip "i" before adding it again!
- $slug = substr($slug, 0,
- ($i > 2) ? strlen($slug)-strlen($i-1) : strlen($slug)).$i;
+ // Check if we need to force the article slug to be unique
+ include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
+ $config =& Config::getConfig();
+ if($config->getValue("force_posturl_unique"))
+ {
+ $slug = $newArticle->getPostSlug();
+ $i = 1;
+ // check if there already is a blog with the same mangled name
+ while($this->checkBlogArticleTitle($slug, $newArticle->getBlog()))
+ {
+ $i++;
+ // and if so, assign a new one
+ // if we already tried with blogname+"i" we have
+ // to strip "i" before adding it again!
+ $slug = substr($slug, 0,
+ ($i > 2) ? strlen($slug)-strlen($i-1) : strlen($slug)).$i;
+ }
+ $newArticle->setPostSlug($slug);
}
- $newArticle->setPostSlug($slug);
-
+
include_once( PLOG_CLASS_PATH.'class/dao/customfields/customfields.class.php' );
include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
@@ -928,19 +936,26 @@
*/
function updateArticle( $article )
{
- $slug = $article->getPostSlug();
- $i = 1;
- // check if there already is a blog with the same mangled name
- while($this->checkBlogArticleTitle($slug, $article->getBlog(),
- $article->getId())){
- $i++;
- // and if so, assign a new one
- // if we already tried with slug+"i" we have
- // to strip "i" before adding it again!
- $slug = substr($slug, 0,
- ($i > 2) ? strlen($slug)-strlen($i-1) : strlen($slug)).$i;
+ // Check if we need to force the article slug to be unique
+ include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
+ $config =& Config::getConfig();
+ if($config->getValue("force_posturl_unique"))
+ {
+ $slug = $article->getPostSlug();
+ $i = 1;
+ // check if there already is a blog with the same mangled name
+ while($this->checkBlogArticleTitle($slug, $article->getBlog(),
+ $article->getId()))
+ {
+ $i++;
+ // and if so, assign a new one
+ // if we already tried with slug+"i" we have
+ // to strip "i" before adding it again!
+ $slug = substr($slug, 0,
+ ($i > 2) ? strlen($slug)-strlen($i-1) : strlen($slug)).$i;
+ }
+ $article->setPostSlug($slug);
}
- $article->setPostSlug($slug);
// keep the old version, since we're going to need it to udpate the category counters
$oldArticle = $this->getArticle( $article->getId());
Modified: plog/trunk/locale/locale_en_UK.php
===================================================================
--- plog/trunk/locale/locale_en_UK.php 2006-05-02 00:31:56 UTC (rev 3315)
+++ plog/trunk/locale/locale_en_UK.php 2006-05-02 00:50:46 UTC (rev 3316)
@@ -1014,4 +1014,7 @@
$messages['blog_categories'] = 'Blog Categories';
$messages['global_article_categories'] = 'Global Article Categories';
+
+$messages['help_force_posturl_unique'] = 'Force all post URLs within a blog to be unique. This is only needed if you are changing the URLs and are removing the date portions of the URL. [Default = no]';
+
?>
\ No newline at end of file
Modified: plog/trunk/templates/admin/globalsettings_url.template
===================================================================
--- plog/trunk/templates/admin/globalsettings_url.template 2006-05-02 00:31:56 UTC (rev 3315)
+++ plog/trunk/templates/admin/globalsettings_url.template 2006-05-02 00:50:46 UTC (rev 3316)
@@ -16,6 +16,13 @@
<div class="formHelp">{$locale->tr("help_urlize_word_separator")}</div>
<input style="width:100%" type="text" id="config[urlize_word_separator]" name="config[urlize_word_separator]" value="{$urlize_word_separator}"/>
</div>
+ <!-- force posturl unique -->
+ <div class="field">
+ <label for="config[force_posturl_unique]">force_posturl_unique</label>
+ <div class="formHelp">{$locale->tr("help_force_posturl_unique")}</div>
+ <input class="radio" type="radio" id="config[force_posturl_unique]" name="config[force_posturl_unique]" value="1" {if $force_posturl_unique == 1 } checked="checked" {/if} />{$locale->tr("yes")}
+ <input class="radio" type="radio" id="config[force_posturl_unique]" name="config[force_posturl_unique]" value="0" {if $force_posturl_unique == 0 } checked="checked" {/if} />{$locale->tr("no")}
+ </div>
<!-- permalink_format -->
<div class="field">
<label for="config[permalink_format]">permalink_format</label>
@@ -94,4 +101,4 @@
<div class="formHelp">{$locale->tr("help_page_suffix_format")}</div>
<input style="width:100%" type="text" id="config[page_suffix_format]" name="config[page_suffix_format]" value="{$page_suffix_format}"/>
</div>
-</div>
\ No newline at end of file
+</div>
More information about the pLog-svn
mailing list