Changeset 1620:542c321dc040 for inc/core
- Timestamp:
- 08/30/13 10:37:08 (12 years ago)
- Branch:
- default
- Parents:
- 1619:5d925866b5b3 (diff), 1593:0c884219a872 (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. - Files:
-
- 2 edited
-
inc/core/class.dc.blog.php (modified) (4 diffs)
-
inc/core/class.dc.blog.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
inc/core/class.dc.blog.php
r1570 r1620 81 81 $this->desc = $b->blog_desc; 82 82 $this->url = $b->blog_url; 83 $this->host = preg_replace('|^([a-z]{3,}://)(.*?)/.*$|','$1$2',$this->url);83 $this->host = http::getHostFromURL($this->url); 84 84 $this->creadt = strtotime($b->blog_creadt); 85 85 $this->upddt = strtotime($b->blog_upddt); … … 91 91 $this->public_path = path::fullFromRoot($this->settings->system->public_path,DC_ROOT); 92 92 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'); 102 102 103 103 # --BEHAVIOR-- coreBlogConstruct … … 300 300 $counter = $this->getCategoriesCounter($c_params); 301 301 302 $without_empty = $this->core->auth->userID() == false; # For public display 302 if (isset($params['without_empty']) && ($params['without_empty'] == false)) { 303 $without_empty = false; 304 } else { 305 $without_empty = $this->core->auth->userID() == false; # Get all categories if in admin display 306 } 303 307 304 308 $start = isset($params['start']) ? (integer) $params['start'] : 0; … … 550 554 $this->triggerBlog(); 551 555 } 556 557 /** 558 Set category position 559 560 @param id <b>integer</b> Category ID 561 @param left <b>integer</b> Category ID before 562 @param right <b>integer</b> Category ID after 563 */ 564 public function updCategoryPosition($id,$left,$right) 565 { 566 $this->categories()->updatePosition($id,$left,$right); 567 $this->triggerBlog(); 568 } 552 569 553 570 /** -
inc/core/class.dc.blog.php
r1610 r1620 203 203 @param ids <b>mixed</b> Comment(s) ID(s) 204 204 @param del <b>boolean</b> If comment is delete, set this to true 205 */ 206 public function triggerComments($ids,$del=false) 207 { 208 $co_ids = dcUtils::cleanIds($ids); 209 210 # a) Retrieve posts affected by comments edition 205 @param affected_posts <b>mixed</b> Posts(s) ID(s) 206 */ 207 public function triggerComments($ids, $del=false, $affected_posts=null) 208 { 209 $comments_ids = dcUtils::cleanIds($ids); 210 211 # Get posts affected by comments edition 212 if (empty($affected_posts)) { 213 $strReq = 214 'SELECT post_id '. 215 'FROM '.$this->prefix.'comment '. 216 'WHERE comment_id'.$this->con->in($comments_ids). 217 'GROUP BY post_id'; 218 219 $rs = $this->con->select($strReq); 220 221 $affected_posts = array(); 222 while ($rs->fetch()) { 223 $affected_posts[] = (integer) $rs->post_id; 224 } 225 } 226 227 if (!is_array($affected_posts) || empty($affected_posts)) { 228 return; 229 } 230 231 # Count number of comments if exists for affected posts 211 232 $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; 223 } 224 225 # b) Count comments of each posts previously retrieved 226 # Note that this does not return posts without comment 227 $strReq = 228 'SELECT post_id, COUNT(post_id) AS nb_comment,comment_trackback '. 233 'SELECT post_id, COUNT(post_id) AS nb_comment, comment_trackback '. 229 234 'FROM '.$this->prefix.'comment '. 230 235 'WHERE comment_status = 1 '. 231 (count($a_ids) > 0 ? 'AND post_id'.$this->con->in($a_ids) : ' '); 232 233 if ($del) { 234 $strReq .= 235 'AND comment_id NOT'.$this->con->in($co_ids); 236 } 237 238 $strReq .= 236 'AND post_id'.$this->con->in($affected_posts). 239 237 'GROUP BY post_id,comment_trackback'; 240 238 241 239 $rs = $this->con->select($strReq); 242 240 243 $ b_ids = $b_tbs = $b_nbs = array();241 $posts = array(); 244 242 while ($rs->fetch()) { 245 $b_ids[] = (integer) $rs->post_id; 246 $b_tbs[] = (integer) $rs->comment_trackback; 247 $b_nbs[] = (integer) $rs->nb_comment; 248 } 249 250 # c) Update comments numbers on posts 251 # This compare previous requests to update also posts without comment 243 if ($rs->comment_trackback) { 244 $posts[$rs->post_id]['trackback'] = $rs->nb_comment; 245 } else { 246 $posts[$rs->post_id]['comment'] = $rs->nb_comment; 247 } 248 } 249 250 # Update number of comments on affected posts 252 251 $cur = $this->con->openCursor($this->prefix.'post'); 253 254 foreach($a_ids as $a_key => $a_id) 255 { 256 $nb_comment = $nb_trackback = 0; 257 foreach($b_ids as $b_key => $b_id) 258 { 259 if ($a_id != $b_id || $a_tbs[$a_key] != $b_tbs[$b_key]) { 260 continue; 261 } 262 263 if ($b_tbs[$b_key]) { 264 $nb_trackback = $b_nbs[$b_key]; 265 } else { 266 $nb_comment = $b_nbs[$b_key]; 267 } 268 } 269 270 if ($a_tbs[$a_key]) { 271 $cur->nb_trackback = $nb_trackback; 252 foreach($affected_posts as $post_id) 253 { 254 $cur->clean(); 255 256 if (!array_key_exists($post_id,$posts)) { 257 $cur->nb_trackback = 0; 258 $cur->nb_comment = 0; 272 259 } else { 273 $cur->nb_comment = $nb_comment; 274 } 275 $cur->update('WHERE post_id = '.$a_id); 260 $cur->nb_trackback = empty($posts[$post_id]['trackback']) ? 0 : $posts[$post_id]['trackback']; 261 $cur->nb_comment = empty($posts[$post_id]['comment']) ? 0 : $posts[$post_id]['comment']; 262 } 263 264 $cur->update('WHERE post_id = '.$post_id); 276 265 } 277 266 } … … 509 498 $this->core->callBehavior('coreBeforeCategoryCreate',$this,$cur); 510 499 511 $this->categories()->addNode($cur,$parent); 500 $id = $this->categories()->addNode($cur,$parent); 501 # Update category's cursor 502 $rs = $this->getCategory($id); 503 if (!$rs->isEmpty()) { 504 $cur->cat_lft = $rs->cat_lft; 505 $cur->cat_rgt = $rs->cat_rgt; 506 } 512 507 513 508 # --BEHAVIOR-- coreAfterCategoryCreate … … 739 734 - no_content: Don't retrieve entry content (excerpt and content) 740 735 - post_type: Get only entries with given type (default "post", array for many types and '' for no type) 741 - post_id: (integer ) Get entry with given post_id736 - post_id: (integer or array) Get entry with given post_id 742 737 - post_url: Get entry with given post_url field 743 738 - user_id: (integer) Get entries belonging to given user ID … … 759 754 - limit: Limit parameter 760 755 - sql_only : return the sql request instead of results. Only ids are selected 756 - exclude_post_id : (integer or array) Exclude entries with given post_id 761 757 762 758 Please note that on every cat_id or cat_url, you can add ?not to exclude … … 852 848 } 853 849 $strReq .= 'AND P.post_id '.$this->con->in($params['post_id']); 850 } 851 852 if (isset($params['exclude_post_id']) && $params['exclude_post_id'] !== '') { 853 if (is_array($params['exclude_post_id'])) { 854 array_walk($params['exclude_post_id'],create_function('&$v,$k','if($v!==null){$v=(integer)$v;}')); 855 } else { 856 $params['exclude_post_id'] = array((integer) $params['exclude_post_id']); 857 } 858 $strReq .= 'AND P.post_id NOT '.$this->con->in($params['exclude_post_id']); 854 859 } 855 860 … … 2235 2240 $co_ids = dcUtils::cleanIds($ids); 2236 2241 2237 if (empty($ ids)) {2242 if (empty($co_ids)) { 2238 2243 throw new Exception(__('No such comment ID')); 2244 } 2245 2246 # Retrieve posts affected by comments edition 2247 $affected_posts = array(); 2248 $strReq = 2249 'SELECT post_id '. 2250 'FROM '.$this->prefix.'comment '. 2251 'WHERE comment_id'.$this->con->in($co_ids). 2252 'GROUP BY post_id'; 2253 2254 $rs = $this->con->select($strReq); 2255 2256 while ($rs->fetch()) { 2257 $affected_posts[] = (integer) $rs->post_id; 2239 2258 } 2240 2259 … … 2266 2285 2267 2286 $this->con->execute($strReq); 2268 $this->triggerComments($co_ids, true);2287 $this->triggerComments($co_ids, true, $affected_posts); 2269 2288 $this->triggerBlog(); 2270 2289 } … … 2321 2340 2322 2341 if ($cur->comment_site !== null && $cur->comment_site != '') { 2323 if (!preg_match('|^http(s?)://| ',$cur->comment_site)) {2342 if (!preg_match('|^http(s?)://|i',$cur->comment_site, $matches)) { 2324 2343 $cur->comment_site = 'http://'.$cur->comment_site; 2344 }else{ 2345 $cur->comment_site = strtolower($matches[0]).substr($cur->comment_site, strlen($matches[0])); 2325 2346 } 2326 2347 }
Note: See TracChangeset
for help on using the changeset viewer.
