Dotclear

Changeset 1492:a7112dcc916c for inc/core


Ignore:
Timestamp:
08/20/13 11:01:52 (12 years ago)
Author:
Dsls
Branch:
twig
Parents:
1491:2b9253624dbe (diff), 1486:602b24e80834 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Fusion avec default

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • inc/core/class.dc.blog.php

    r1468 r1492  
    44# This file is part of Dotclear 2. 
    55# 
    6 # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear 
     6# Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear 
    77# Licensed under the GPL version 2.0 license. 
    88# See LICENSE file or 
     
    8181               $this->desc = $b->blog_desc; 
    8282               $this->url = $b->blog_url; 
    83                $this->host = http::getHostFromURL($this->url); 
     83               $this->host = preg_replace('|^([a-z]{3,}://)(.*?)/.*$|','$1$2',$this->url); 
    8484               $this->creadt = strtotime($b->blog_creadt); 
    8585               $this->upddt = strtotime($b->blog_upddt); 
     
    842842           
    843843          if (!empty($params['user_id'])) { 
    844                $strReq .= "AND U.user_id = '".$this->con->escape($params['user_id'])."' "; 
     844               $strReq .= "AND U.user_id ".$this->con->in($params['user_id'])." "; 
    845845          } 
    846846           
     
    926926                    $strReq .= 'ORDER BY post_dt DESC '; 
    927927               } 
    928           } 
    929            
    930           if (!$count_only && !empty($params['limit'])) { 
    931                $strReq .= $this->con->limit($params['limit']); 
     928               if (!empty($params['limit'])) { 
     929                    $strReq .= $this->con->limit($params['limit']); 
     930               } 
    932931          } 
    933932           
  • inc/core/class.dc.blog.php

    r1491 r1492  
    634634     private function checkCategory($title,$url,$id=null) 
    635635     { 
    636           $strReq = 'SELECT cat_id '. 
    637                     'FROM '.$this->prefix.'category '. 
    638                     "WHERE cat_url = '".$this->con->escape($url)."' ". 
    639                     "AND blog_id = '".$this->con->escape($this->id)."' "; 
    640            
    641           if ($id !== null) { 
    642                $strReq .= 'AND cat_id <> '.(integer) $id.' '; 
    643           } 
     636          # Let's check if URL is taken... 
     637          $strReq =  
     638               'SELECT cat_url FROM '.$this->prefix.'category '. 
     639               "WHERE cat_url = '".$this->con->escape($url)."' ". 
     640               ($id ? 'AND cat_id <> '.(integer) $id. ' ' : ''). 
     641               "AND blog_id = '".$this->con->escape($this->id)."' ". 
     642               'ORDER BY cat_url DESC'; 
    644643           
    645644          $rs = $this->con->select($strReq); 
    646645           
    647           if (!$rs->isEmpty()) { 
    648                throw new Exception(__('Category URL must be unique.')); 
    649           } 
     646          if (!$rs->isEmpty()) 
     647          { 
     648               if ($this->con->driver() == 'mysql') { 
     649                    $clause = "REGEXP '^".$this->con->escape($url)."[0-9]+$'"; 
     650               } elseif ($this->con->driver() == 'pgsql') { 
     651                    $clause = "~ '^".$this->con->escape($url)."[0-9]+$'"; 
     652               } else { 
     653                    $clause = "LIKE '".$this->con->escape($url)."%'"; 
     654               } 
     655               $strReq =  
     656                    'SELECT cat_url FROM '.$this->prefix.'category '. 
     657                    "WHERE cat_url ".$clause.' '. 
     658                    ($id ? 'AND cat_id <> '.(integer) $id. ' ' : ''). 
     659                    "AND blog_id = '".$this->con->escape($this->id)."' ". 
     660                    'ORDER BY cat_url DESC '; 
     661                
     662               $rs = $this->con->select($strReq); 
     663               $a = array(); 
     664               while ($rs->fetch()) { 
     665                    $a[] = $rs->cat_url; 
     666               } 
     667                
     668               natsort($a); 
     669               $t_url = end($a); 
     670                
     671               if (preg_match('/(.*?)([0-9]+)$/',$t_url,$m)) { 
     672                    $i = (integer) $m[2]; 
     673                    $url = $m[1]; 
     674               } else { 
     675                    $i = 1; 
     676               } 
     677                
     678               return $url.($i+1); 
     679          } 
     680           
     681          # URL is empty? 
     682          if ($url == '') { 
     683               throw new Exception(__('Empty category URL')); 
     684          } 
     685           
     686          return $url; 
    650687     } 
    651688      
     
    669706           
    670707          # Check if title or url are unique 
    671           $this->checkCategory($cur->cat_title,$cur->cat_url,$id); 
     708          $cur->cat_url = $this->checkCategory($cur->cat_title,$cur->cat_url,$id); 
    672709           
    673710          if ($cur->cat_desc !== null) { 
Note: See TracChangeset for help on using the changeset viewer.

Sites map