Dotclear

Changeset 1468:3132a0aca046 for inc/core


Ignore:
Timestamp:
08/19/13 09:55:29 (12 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Parents:
1466:e67efe636ce1 (diff), 1467:917fc08f3a59 (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:

Merge 2.5 commits into default branch (should be verified)

Location:
inc/core
Files:
4 edited

Legend:

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

    r1353 r1468  
    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) { 
  • inc/core/class.dc.blog.php

    r1429 r1468  
    8181               $this->desc = $b->blog_desc; 
    8282               $this->url = $b->blog_url; 
    83                $this->host = preg_replace('|^([a-z]{3,}://)(.*?)/.*$|','$1$2',$this->url); 
     83               $this->host = http::getHostFromURL($this->url); 
    8484               $this->creadt = strtotime($b->blog_creadt); 
    8585               $this->upddt = strtotime($b->blog_upddt); 
     
    9191               $this->public_path = path::fullFromRoot($this->settings->system->public_path,DC_ROOT); 
    9292                
    93                $this->post_status['-2'] = __('pending'); 
    94                $this->post_status['-1'] = __('scheduled'); 
    95                $this->post_status['0'] = __('unpublished'); 
    96                $this->post_status['1'] = __('published'); 
    97                 
    98                $this->comment_status['-2'] = __('junk'); 
    99                $this->comment_status['-1'] = __('pending'); 
    100                $this->comment_status['0'] = __('unpublished'); 
    101                $this->comment_status['1'] = __('published'); 
     93               $this->post_status['-2'] = __('Pending'); 
     94               $this->post_status['-1'] = __('Scheduled'); 
     95               $this->post_status['0'] = __('Unpublished'); 
     96               $this->post_status['1'] = __('Published'); 
     97                
     98               $this->comment_status['-2'] = __('Junk'); 
     99               $this->comment_status['-1'] = __('Pending'); 
     100               $this->comment_status['0'] = __('Unpublished'); 
     101               $this->comment_status['1'] = __('Published'); 
    102102                
    103103               # --BEHAVIOR-- coreBlogConstruct 
     
    203203     @param    ids       <b>mixed</b>        Comment(s) ID(s) 
    204204     @param    del       <b>boolean</b>      If comment is delete, set this to true 
    205      @param    affected_posts      <b>mixed</b>        Posts(s) ID(s) 
    206      */ 
    207      public function triggerComments($ids, $del=false, $affected_posts=null) 
     205     */ 
     206     public function triggerComments($ids,$del=false) 
    208207     { 
    209208          $co_ids = dcUtils::cleanIds($ids); 
    210           $a_ids = dcUtils::cleanIds($affected_posts); 
    211           $a_tbs = array(); 
    212209           
    213210          # a) Retrieve posts affected by comments edition 
    214           if (empty($a_ids)) { 
    215                $strReq =  
    216                     'SELECT post_id, comment_trackback '. 
    217                     'FROM '.$this->prefix.'comment '. 
    218                     'WHERE comment_id'.$this->con->in($co_ids). 
    219                     'GROUP BY post_id,comment_trackback'; 
    220                 
    221                $rs = $this->con->select($strReq); 
    222                 
    223                while ($rs->fetch()) { 
    224                     $a_ids[] = (integer) $rs->post_id; 
    225                     $a_tbs[] = (integer) $rs->comment_trackback; 
    226                } 
     211          $strReq =  
     212               'SELECT post_id, comment_trackback '. 
     213               'FROM '.$this->prefix.'comment '. 
     214               'WHERE comment_id'.$this->con->in($co_ids). 
     215               'GROUP BY post_id,comment_trackback'; 
     216           
     217          $rs = $this->con->select($strReq); 
     218           
     219          $a_ids = $a_tbs = array(); 
     220          while ($rs->fetch()) { 
     221               $a_ids[] = (integer) $rs->post_id; 
     222               $a_tbs[] = (integer) $rs->comment_trackback; 
    227223          } 
    228224           
     
    259255          { 
    260256               $nb_comment = $nb_trackback = 0; 
    261                //$cur->nb_comment = $nb_comment; 
    262257               foreach($b_ids as $b_key => $b_id) 
    263258               { 
     
    510505          $this->core->callBehavior('coreBeforeCategoryCreate',$this,$cur); 
    511506           
    512           $id = $this->categories()->addNode($cur,$parent); 
    513           # Update category's cursor 
    514           $rs = $this->getCategory($id); 
    515           if (!$rs->isEmpty()) { 
    516                $cur->cat_lft = $rs->cat_lft; 
    517                $cur->cat_rgt = $rs->cat_rgt; 
    518           } 
     507          $this->categories()->addNode($cur,$parent); 
    519508           
    520509          # --BEHAVIOR-- coreAfterCategoryCreate 
     
    22292218          $co_ids = dcUtils::cleanIds($ids); 
    22302219           
    2231           if (empty($co_ids)) { 
     2220          if (empty($ids)) { 
    22322221               throw new Exception(__('No such comment ID')); 
    2233           } 
    2234            
    2235           # Retrieve posts affected by comments edition 
    2236           $affected_posts = array(); 
    2237           $strReq = 
    2238                'SELECT distinct(post_id) '. 
    2239                'FROM '.$this->prefix.'comment '. 
    2240                'WHERE comment_id'.$this->con->in($co_ids); 
    2241            
    2242           $rs = $this->con->select($strReq); 
    2243            
    2244           while ($rs->fetch()) { 
    2245                $affected_posts[] = (integer) $rs->post_id; 
    22462222          } 
    22472223           
     
    22732249           
    22742250          $this->con->execute($strReq); 
    2275           $this->triggerComments($co_ids, true, $affected_posts); 
     2251          $this->triggerComments($co_ids,true); 
    22762252          $this->triggerBlog(); 
    22772253     } 
     
    23282304           
    23292305          if ($cur->comment_site !== null && $cur->comment_site != '') { 
    2330                if (!preg_match('|^http(s?)://|i',$cur->comment_site, $matches)) { 
     2306               if (!preg_match('|^http(s?)://|',$cur->comment_site)) { 
    23312307                    $cur->comment_site = 'http://'.$cur->comment_site; 
    2332                }else{ 
    2333                     $cur->comment_site = strtolower($matches[0]).substr($cur->comment_site, strlen($matches[0])); 
    23342308               } 
    23352309          } 
  • inc/core/class.dc.media.php

    r1280 r1468  
    3030      
    3131     public $thumb_tp = '%s/.%s_%s.jpg';     ///< <b>string</b> Thumbnail file pattern 
     32     public $thumb_tp_alpha = '%s/.%s_%s.png'; ///< <b>string</b> Thumbnail file pattern (with alpha layer) 
    3233      
    3334     /** 
     
    298299               $f->media_thumb = array(); 
    299300               $p = path::info($f->relname); 
    300                $thumb = sprintf($this->thumb_tp,$this->root.'/'.$p['dirname'],$p['base'],'%s'); 
    301                $thumb_url = sprintf($this->thumb_tp,$this->root_url.$p['dirname'],$p['base'],'%s'); 
     301               $alpha = ($p['extension'] == 'png') || ($p['extension'] == 'PNG'); 
     302               $thumb = sprintf(($alpha ? $this->thumb_tp_alpha : $this->thumb_tp),$this->root.'/'.$p['dirname'],$p['base'],'%s'); 
     303               $thumb_url = sprintf(($alpha ? $this->thumb_tp_alpha : $this->thumb_tp),$this->root_url.$p['dirname'],$p['base'],'%s'); 
    302304                
    303305               # Cleaner URLs 
     
    920922           
    921923          $p = path::info($file); 
    922           $thumb = sprintf($this->thumb_tp,$p['dirname'],$p['base'],'%s'); 
     924          $alpha = ($p['extension'] == 'png') || ($p['extension'] == 'PNG'); 
     925          $thumb = sprintf(($alpha ? $this->thumb_tp_alpha : $this->thumb_tp),$p['dirname'],$p['base'],'%s'); 
    923926           
    924927          try 
     
    939942                         $rate = ($s[0] < 100 ? 95 : ($s[0] < 600 ? 90 : 85)); 
    940943                         $img->resize($s[0],$s[0],$s[1]); 
    941                          $img->output('jpeg',$thumb_file,$rate); 
     944                         $img->output(($alpha ? 'png' : 'jpeg'),$thumb_file,$rate); 
    942945                         $img->loadImage($file); 
    943946                    } 
     
    958961          { 
    959962               $p = path::info($file->relname); 
    960                $thumb_old = sprintf($this->thumb_tp,$p['dirname'],$p['base'],'%s'); 
     963               $alpha = ($p['extension'] == 'png') || ($p['extension'] == 'PNG'); 
     964               $thumb_old = sprintf(($alpha ? $this->thumb_tp_alpha : $this->thumb_tp),$p['dirname'],$p['base'],'%s'); 
    961965                
    962966               $p = path::info($newFile->relname); 
    963                $thumb_new = sprintf($this->thumb_tp,$p['dirname'],$p['base'],'%s'); 
     967               $alpha = ($p['extension'] == 'png') || ($p['extension'] == 'PNG'); 
     968               $thumb_new = sprintf(($alpha ? $this->thumb_tp_alpha : $this->thumb_tp),$p['dirname'],$p['base'],'%s'); 
    964969                
    965970               foreach ($this->thumb_sizes as $suffix => $s) { 
     
    974979     { 
    975980          $p = path::info($f); 
    976           $thumb = sprintf($this->thumb_tp,'',$p['base'],'%s'); 
     981          $alpha = ($p['extension'] == 'png') || ($p['extension'] == 'PNG'); 
     982          $thumb = sprintf(($alpha ? $this->thumb_tp_alpha : $this->thumb_tp),'',$p['base'],'%s'); 
    977983           
    978984          foreach ($this->thumb_sizes as $suffix => $s) { 
  • inc/core/class.dc.media.php

    r1381 r1468  
    499499     @param    post_id   <b>integer</b>      Post ID 
    500500     @param    media_id  <b>integer</b>      Optionnal media ID 
    501      @param    return_rs <b>boolean</b>      Whether to return a resultset (true) or an array (false, default value). 
    502      @return   <b>array</b> Array or ResultSet of fileItems 
    503      */ 
    504      public function getPostMedia($post_id,$media_id=null,$return_rs=false) 
     501     @return   <b>array</b> Array of fileItems 
     502     */ 
     503     public function getPostMedia($post_id,$media_id=null) 
    505504     { 
    506505          $params = array( 
     
    518517               $f = $this->fileRecord($rs); 
    519518               if ($f !== null) { 
    520                     $res[] = $return_rs ? new ArrayObject($f) : $f; 
    521                } 
    522           } 
    523            
    524           return $return_rs ? staticRecord::newFromArray($res) : $res; 
     519                    $res[] = $f; 
     520               } 
     521          } 
     522           
     523          return $res; 
    525524     } 
    526525      
Note: See TracChangeset for help on using the changeset viewer.

Sites map