Changeset 11849

Show
Ignore:
Timestamp:
08/30/07 11:32:18 (1 year ago)
Author:
netblade
Message:

Fixed name check, copyed functionality from n.n.blog

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/net.nehmer.static/handler/create.php

    r11276 r11849  
    150150        $this->_article = new midcom_db_article(); 
    151151        $this->_article->topic = $this->_content_topic->id; 
    152          
     152 
    153153        if (   array_key_exists('name', $this->_defaults) 
    154154            && $this->_defaults['name'] == 'index') 
     
    195195        { 
    196196            case 'save': 
     197 
     198                $tries = 0; 
     199                $maxtries = 999; 
     200 
    197201                if (   $this->_config->get('simple_name_handling') 
    198202                    && $this->_article->name == '') 
     
    201205                    { 
    202206                        $urlgenerator = $_MIDCOM->serviceloader->load('midcom_core_service_urlgenerator'); 
    203                         $this->_article->name = $urlgenerator->from_string($this->_article->title); 
    204                         $this->_article->update(); 
     207                        $article_tmp_name = $urlgenerator->from_string($this->_article->title); 
    205208                    } 
    206209                    else 
    207210                    { 
    208                         $this->_article->name = $this->_article->title; 
     211                        $article_tmp_name = $this->_article->title; 
    209212                    } 
     213                     
    210214                } 
    211              
     215                else 
     216                { 
     217                    $article_tmp_name = $this->_article->title; 
     218                } 
     219 
     220                $this->_article->name = $article_tmp_name; 
     221 
     222                while(   !$this->_article->update() 
     223                      && $tries < $maxtries) 
     224                { 
     225                    $this->_article->name = $article_tmp_name; 
     226                    if ($tries > 0) 
     227                    { 
     228                        // Append an integer if articles with same name exist 
     229                        $this->_article->name .= sprintf("-%03d", $tries); 
     230                    } 
     231                    $tries++; 
     232                } 
     233 
    212234                // Index the article 
    213235                $indexer =& $_MIDCOM->get_service('indexer');