Changeset 100

Show
Ignore:
Timestamp:
30/05/05 21:01:28 (4 years ago)
Author:
welshbyte
Message:

Refixed the fixes that got unfixed yesterday. Will stop using :retab in vim in future.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • admin.lib.php

    r96 r100  
    195195                        $shortsubject = $this->blog->makeCleanString($subject); 
    196196                        // need to check if there are any short titles like this one already 
    197                         $sql = db_query("SELECT shortsubject from entries where user_id = ".$this->id." and (shortsubject = '".$shortsubject."' or shortsubject like '".$shortsubject."\\\_%') order by char_length(shortsubject) desc, shortsubject desc;"); 
    198                         $sqlNum = db_num_rows($sql); 
    199                         //if so we grab the last one, and add 1 to it.. 
    200                         if ($sqlNum != 0) { 
    201                                 $sqlRow = db_getrow($sql); 
    202                                 (int)$newNum = array_shift(array_reverse(explode('_',$sqlRow['shortsubject']))); 
    203                                 $shortsubject .= '_'.++$newNum; //new non-colliding short subject 
    204                         } 
     197                        $sql = db_query("SELECT shortsubject FROM entries WHERE user_id = {$this->id} AND shortsubject ~ '{$shortsubject}(_[0-9]{1,3}$|$)' ORDER BY char_length(shortsubject) DESC, shortsubject DESC;"); 
     198            $sqlNum = db_num_rows($sql); 
     199 
     200            //if so we grab the last one, and add 1 to it.. 
     201            if ($sqlNum != 0) { 
     202                $sqlRow = db_getrow($sql); 
     203                // Put the matched _number into $matches[0] if there is one 
     204                if (preg_match("/\_[0-9]{1,3}$/",$sqlRow['shortsubject'],$matches)) { 
     205                    // Remove the _ to get the number, add 1 and append 
     206                    $shortsubject .= '_' . ((int)substr($matches[0],1) + 1); 
     207                } else { 
     208                    $shortsubject .= '_1'; 
     209                } 
     210            } 
    205211                        //shortsubject is now safe.. 
    206212                        //insert our new entry 
     
    309315                echo "</p>\n"; 
    310316                echo "<p>\n"; 
    311                 echo "<select name=\"category\" id=\"category\">"; 
     317                echo "<select name=\"category\" id=\"category\" tabindex=\"2\">"; 
    312318                //pull in the list of catogories from the database 
    313319                $sql = db_query("SELECT id, name FROM categories ORDER BY name ASC;");