Changeset 873:f9ef04edef05 for inc/core
- Timestamp:
- 08/14/12 15:43:05 (13 years ago)
- Branch:
- sexy
- Location:
- inc/core
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/core/class.dc.blog.php
r852 r873 85 85 $this->settings = new dcSettings($this->core,$this->id); 86 86 87 $this->themes_path = path::fullFromRoot($this->settings->system->themes_path,DC_ROOT);88 $this->public_path = path::fullFromRoot($this->settings->system->public_path,DC_ROOT);87 //$this->themes_path = path::fullFromRoot($this->settings->system->themes_path,DC_ROOT); 88 //$this->public_path = path::fullFromRoot($this->settings->system->public_path,DC_ROOT); 89 89 90 90 $this->post_status['-2'] = __('pending'); … … 359 359 } 360 360 361 $ rs = $this->con->select($strReq);362 $ rs->core = $this->core;363 $ rs->extend('rsExtPost');361 $posts = $this->con->select($strReq); 362 $posts->core = $this->core; 363 $posts->extend('rsExtPost'); 364 364 365 365 # --BEHAVIOR-- coreBlogGetPosts 366 $this->core->callBehavior('coreBlogGetPosts',$ rs);367 368 return $ rs;366 $this->core->callBehavior('coreBlogGetPosts',$posts); 367 368 return $posts; 369 369 } 370 370 … … 406 406 } 407 407 408 $ rs = $this->getPosts($params);409 410 if ( $rs->isEmpty()) {408 $posts = $this->getPosts($params); 409 410 if (count($posts) == 0) { 411 411 return null; 412 412 } 413 413 414 return $ rs;414 return $posts; 415 415 } 416 416 … … 578 578 $limit; 579 579 580 $ rs = $this->con->select($strReq);581 $ rs->extend('rsExtDates');582 return $ rs;580 $dates = $this->con->select($strReq); 581 $dates->extend('rsExtDates'); 582 return $dates; 583 583 } 584 584 … … 600 600 { 601 601 # Get ID 602 $ rs= $this->con->select(602 $max = $this->con->select( 603 603 'SELECT MAX(post_id) '. 604 604 'FROM '.$this->prefix.'post ' 605 605 ); 606 606 607 $cur->post_id = (integer) $rs->f(0) + 1; 607 $max = $max->current(); 608 609 $cur->post_id = (integer) $max->f(0) + 1; 608 610 $cur->blog_id = (string) $this->id; 609 611 $cur->post_creadt = date('Y-m-d H:i:s'); … … 683 685 "AND user_id = '".$this->con->escape($this->core->auth->userID())."' "; 684 686 685 $ rs = $this->con->select($strReq);686 687 if ( $rs->isEmpty()) {687 $posts = $this->con->select($strReq); 688 689 if (count($posts) == 0) { 688 690 throw new Exception(__('You are not allowed to edit this entry')); 689 691 } … … 725 727 "AND user_id = '".$this->con->escape($this->core->auth->userID())."' "; 726 728 727 $ rs = $this->con->select($strReq);728 729 if ( $rs->isEmpty()) {729 $posts = $this->con->select($strReq); 730 731 if (count($posts) == 0) { 730 732 throw new Exception(__('You are not allowed to change this entry status')); 731 733 } … … 758 760 "AND user_id = '".$this->con->escape($this->core->auth->userID())."' "; 759 761 760 $ rs = $this->con->select($strReq);761 762 if ( $rs->isEmpty()) {762 $posts = $this->con->select($strReq); 763 764 if (count($posts) == 0) { 763 765 throw new Exception(__('You are not allowed to mark this entry as selected')); 764 766 } … … 803 805 "AND user_id = '".$this->con->escape($this->core->auth->userID())."' "; 804 806 805 $ rs = $this->con->select($strReq);806 807 if ( $rs->isEmpty()) {807 $posts = $this->con->select($strReq); 808 809 if (count($posts) == 0) { 808 810 throw new Exception(__('You are not allowed to delete this entry')); 809 811 } … … 829 831 "AND blog_id = '".$this->con->escape($this->id)."' "; 830 832 831 $ rs = $this->con->select($strReq);833 $posts = $this->con->select($strReq); 832 834 833 835 $now = dt::toUTC(time()); 834 836 $to_change = new ArrayObject(); 835 837 836 if ( $rs->isEmpty()) {838 if (count($posts) == 0) { 837 839 return; 838 840 } 839 841 840 while ($rs->fetch())842 foreach ($posts as $post) 841 843 { 842 844 # Now timestamp with post timezone 843 $now_tz = $now + dt::getTimeOffset($ rs->post_tz,$now);845 $now_tz = $now + dt::getTimeOffset($post->post_tz,$now); 844 846 845 847 # Post timestamp 846 $post_ts = strtotime($ rs->post_dt);848 $post_ts = strtotime($post->post_dt); 847 849 848 850 # If now_tz >= post_ts, we publish the entry 849 851 if ($now_tz >= $post_ts) { 850 $to_change[] = (integer) $ rs->post_id;852 $to_change[] = (integer) $post->post_id; 851 853 } 852 854 } … … 1040 1042 'ORDER BY post_url DESC'; 1041 1043 1042 $ rs = $this->con->select($strReq);1043 1044 if ( !$rs->isEmpty())1044 $urls = $this->con->select($strReq); 1045 1046 if (count($urls) > 0) 1045 1047 { 1046 1048 if ($this->con->driver() == 'mysql') { … … 1057 1059 'ORDER BY post_url DESC '; 1058 1060 1059 $ rs = $this->con->select($strReq);1061 $urls = $this->con->select($strReq); 1060 1062 $a = array(); 1061 while ($rs->fetch()) {1062 $a[] = $ rs->post_url;1063 foreach ($urls as $u) { 1064 $a[] = $u->post_url; 1063 1065 } 1064 1066 -
inc/core/class.dc.core.php
r852 r873 371 371 { 372 372 $strReq = 'SELECT module, version FROM '.$this->prefix.'version'; 373 $ rs = $this->con->select($strReq);373 $modules = $this->con->select($strReq); 374 374 375 while ($rs->fetch()) {376 $this->versions[$ rs->module] = $rs->version;375 foreach ($modules as $m) { 376 $this->versions[$m->module] = $m->version; 377 377 } 378 378 } … … 506 506 } 507 507 508 $ rs = $this->con->select($strReq);509 $ rs->extend('rsExtUser');510 return $ rs;508 $users = $this->con->select($strReq); 509 $users->extend('rsExtUser'); 510 return $users; 511 511 } 512 512 … … 569 569 570 570 # Updating all user's blogs 571 $ rs = $this->con->select(571 $blogs = $this->con->select( 572 572 'SELECT DISTINCT(blog_id) FROM '.$this->prefix.'post '. 573 573 "WHERE user_id = '".$this->con->escape($id)."' " 574 574 ); 575 575 576 while ($rs->fetch()) {577 $b = new dcBlog($this,$ rs->blog_id);576 foreach ($blogs as $blog) { 577 $b = new dcBlog($this,$blog->blog_id); 578 578 $b->triggerBlog(); 579 579 unset($b); … … 598 598 } 599 599 600 $ rs= $this->getUser($id);601 602 if ($ rs->nb_post > 0) {600 $user = $this->getUser($id); 601 602 if ($user->nb_post > 0) { 603 603 return; 604 604 } … … 624 624 "WHERE user_id = '".$this->con->escape($id)."' "; 625 625 626 $ rs = $this->con->select($strReq);627 628 return !$rs->isEmpty();626 $users = $this->con->select($strReq); 627 628 return (count($users) > 0); 629 629 } 630 630 … … 649 649 "WHERE user_id = '".$this->con->escape($id)."' "; 650 650 651 $ rs = $this->con->select($strReq);651 $blogs = $this->con->select($strReq); 652 652 653 653 $res = array(); 654 654 655 while ($rs->fetch())655 foreach ($blogs as $blog) 656 656 { 657 $res[$ rs->blog_id] = array(658 'name' => $ rs->blog_name,659 'url' => $ rs->blog_url,660 'p' => $this->auth->parsePermissions($ rs->permissions)657 $res[$blog->blog_id] = array( 658 'name' => $blog->blog_name, 659 'url' => $blog->blog_url, 660 'p' => $this->auth->parsePermissions($blog->permissions) 661 661 ); 662 662 } … … 829 829 } 830 830 831 $ rs = $this->con->select($strReq);831 $users = $this->con->select($strReq); 832 832 833 833 $res = array(); 834 834 835 while ($rs->fetch())835 foreach ($users as $u) 836 836 { 837 $res[$ rs->user_id] = array(838 'name' => $ rs->user_name,839 'firstname' => $ rs->user_firstname,840 'displayname' => $ rs->user_displayname,841 'super' => (boolean) $ rs->user_super,842 'p' => $this->auth->parsePermissions($ rs->permissions)837 $res[$u->user_id] = array( 838 'name' => $u->user_name, 839 'firstname' => $u->user_firstname, 840 'displayname' => $u->user_displayname, 841 'super' => (boolean) $u->user_super, 842 'p' => $this->auth->parsePermissions($u->permissions) 843 843 ); 844 844 } … … 1025 1025 "WHERE blog_id = '".$this->con->escape($id)."' "; 1026 1026 1027 $ rs = $this->con->select($strReq);1028 1029 return !$rs->isEmpty();1027 $blogs = $this->con->select($strReq); 1028 1029 return (count($blogs) > 0); 1030 1030 } 1031 1031 … … 1253 1253 $strReq = 'SELECT COUNT(post_id) '. 1254 1254 'FROM '.$this->prefix.'post'; 1255 $rs = $this->con->select($strReq); 1256 $count = $rs->f(0); 1255 $count = $this->con->select($strReq); 1256 $count = $count->current(); 1257 $count = $count->f(0); 1257 1258 1258 1259 $strReq = 'SELECT post_id, post_title, post_excerpt_xhtml, post_content_xhtml '. … … 1263 1264 } 1264 1265 1265 $ rs = $this->con->select($strReq,true);1266 $posts = $this->con->select($strReq,true); 1266 1267 1267 1268 $cur = $this->con->openCursor($this->prefix.'post'); 1268 1269 1269 while ($rs->fetch())1270 foreach ($posts as $post) 1270 1271 { 1271 $words = $ rs->post_title.' '. $rs->post_excerpt_xhtml.' '.1272 $ rs->post_content_xhtml;1272 $words = $post->post_title.' '. $post->post_excerpt_xhtml.' '. 1273 $post->post_content_xhtml; 1273 1274 1274 1275 $cur->post_words = implode(' ',text::splitWords($words)); 1275 $cur->update('WHERE post_id = '.(integer) $ rs->post_id);1276 $cur->update('WHERE post_id = '.(integer) $post->post_id); 1276 1277 $cur->clean(); 1277 1278 } -
inc/core/class.dc.meta.php
r848 r873 198 198 'WHERE post_id = '.$post_id.' '; 199 199 200 $rs = $this->con->select($strReq);200 $rsmeta = $this->con->select($strReq); 201 201 202 202 $meta = array(); 203 while ($rs->fetch()) {204 $meta[$r s->meta_type][] = $rs->meta_id;203 foreach ($rsmeta as $r) { 204 $meta[$r->meta_type][] = $r->meta_id; 205 205 } 206 206 … … 271 271 if ($meta_id != null) 272 272 $params['post_id'] = $post_id; 273 $ rs= $this->getMetadata($params, false);274 return $this->computeMetaStats($ rs);273 $meta = $this->getMetadata($params, false); 274 return $this->computeMetaStats($meta); 275 275 } 276 276 … … 345 345 } 346 346 347 $ rs= $this->con->select($strReq);348 return $ rs;347 $meta = $this->con->select($strReq); 348 return $meta; 349 349 } 350 350 … … 357 357 @return <b>record</b> the enriched recordset 358 358 */ 359 public function computeMetaStats($ rs) {360 $ rs_static = $rs->toStatic();359 public function computeMetaStats($meta) { 360 $meta_static = $meta->toStatic(); 361 361 362 362 $max = array(); 363 while ($rs_static->fetch())364 { 365 $type = $ rs_static->meta_type;363 foreach ($meta_static as $m) 364 { 365 $type = $m->meta_type; 366 366 if (!isset($max[$type])) { 367 $max[$type] = $ rs_static->count;367 $max[$type] = $m->count; 368 368 } else { 369 if ($ rs_static->count > $max[$type]) {370 $max[$type] = $ rs_static->count;369 if ($m->count > $max[$type]) { 370 $max[$type] = $m->count; 371 371 } 372 372 } 373 373 } 374 374 375 while ($rs_static->fetch())376 { 377 $ rs_static->set('meta_id_lower',mb_strtolower($rs_static->meta_id));378 379 $count = $ rs_static->count;380 $percent = ((integer) $ rs_static->count) * 100 / $max[$rs_static->meta_type];381 382 $ rs_static->set('percent',(integer) round($percent));383 $ rs_static->set('roundpercent',round($percent/10)*10);384 } 385 386 return $ rs_static;375 foreach ($meta_static as $m) 376 { 377 $m->set('meta_id_lower',mb_strtolower($m->meta_id)); 378 379 $count = $m->count; 380 $percent = ((integer) $m->count) * 100 / $max[$m->meta_type]; 381 382 $m->set('percent',(integer) round($percent)); 383 $m->set('roundpercent',round($percent/10)*10); 384 } 385 386 return $meta_static; 387 387 } 388 388 … … 487 487 $to_update = $to_remove = array(); 488 488 489 $ rs= $this->con->select(sprintf($getReq,$this->con->escape($meta_id),489 $meta = $this->con->select(sprintf($getReq,$this->con->escape($meta_id), 490 490 $this->con->escape($type))); 491 491 492 while ($rs->fetch()) {493 $to_update[] = $ rs->post_id;492 foreach ($meta as $m) { 493 $to_update[] = $m->post_id; 494 494 } 495 495 … … 498 498 } 499 499 500 $ rs= $this->con->select(sprintf($getReq,$new_meta_id,$type));501 while ($rs->fetch()) {502 if (in_array($ rs->post_id,$to_update)) {503 $to_remove[] = $ rs->post_id;504 unset($to_update[array_search($ rs->post_id,$to_update)]);500 $meta = $this->con->select(sprintf($getReq,$new_meta_id,$type)); 501 foreach ($meta as $m) { 502 if (in_array($m->post_id,$to_update)) { 503 $to_remove[] = $m->post_id; 504 unset($to_update[array_search($m->post_id,$to_update)]); 505 505 } 506 506 } … … 558 558 } 559 559 560 $ rs = $this->con->select($strReq);561 562 if ( $rs->isEmpty()) return array();560 $posts = $this->con->select($strReq); 561 562 if (count($posts) == 0) return array(); 563 563 564 564 $ids = array(); 565 while ($rs->fetch()) {566 $ids[] = $ rs->post_id;565 foreach ($posts as $p) { 566 $ids[] = $p->post_id; 567 567 } 568 568 -
inc/core/class.dc.namespace.php
r270 r873 49 49 } 50 50 51 private function getSettings($ rs=null)51 private function getSettings($settings=null) 52 52 { 53 if ($ rs == null) {53 if ($settings == null) { 54 54 $strReq = 'SELECT blog_id, setting_id, setting_value, '. 55 55 'setting_type, setting_label, setting_ns '. … … 61 61 62 62 try { 63 $ rs = $this->con->select($strReq);63 $settings = $this->con->select($strReq); 64 64 } catch (Exception $e) { 65 65 trigger_error(__('Unable to retrieve settings:').' '.$this->con->error(), E_USER_ERROR); 66 66 } 67 67 } 68 while ($rs->fetch())69 { 70 if ($ rs->f('setting_ns') != $this->ns){68 foreach ($settings as $s) 69 { 70 if ($s->f('setting_ns') != $this->ns){ 71 71 break; 72 72 } 73 $id = trim($ rs->f('setting_id'));74 $value = $ rs->f('setting_value');75 $type = $ rs->f('setting_type');73 $id = trim($s->f('setting_id')); 74 $value = $s->f('setting_value'); 75 $type = $s->f('setting_type'); 76 76 77 77 if ($type == 'float' || $type == 'double') { … … 83 83 settype($value,$type); 84 84 85 $array = $ rs->blog_id ? 'local' : 'global';85 $array = $s->blog_id ? 'local' : 'global'; 86 86 87 87 $this->{$array.'_settings'}[$id] = array( … … 89 89 'value' => $value, 90 90 'type' => $type, 91 'label' => (string) $ rs->f('setting_label'),92 'global' => $ rs->blog_id == ''91 'label' => (string) $s->f('setting_label'), 92 'global' => $s->blog_id == '' 93 93 ); 94 94 } -
inc/core/class.dc.workspace.php
r147 r873 53 53 } 54 54 55 private function getPrefs($ rs=null)55 private function getPrefs($settings=null) 56 56 { 57 if ($ rs == null) {57 if ($settings == null) { 58 58 $strReq = 'SELECT user_id, pref_id, pref_value, '. 59 59 'pref_type, pref_label, pref_ws '. … … 65 65 66 66 try { 67 $ rs = $this->con->select($strReq);67 $settings = $this->con->select($strReq); 68 68 } catch (Exception $e) { 69 69 throw $e; 70 70 } 71 71 } 72 while ($rs->fetch())73 { 74 if ($ rs->f('pref_ws') != $this->ws){72 foreach ($settings as $s) 73 { 74 if ($s->f('pref_ws') != $this->ws){ 75 75 break; 76 76 } 77 $id = trim($ rs->f('pref_id'));78 $value = $ rs->f('pref_value');79 $type = $ rs->f('pref_type');77 $id = trim($s->f('pref_id')); 78 $value = $s->f('pref_value'); 79 $type = $s->f('pref_type'); 80 80 81 81 if ($type == 'float' || $type == 'double') { … … 87 87 settype($value,$type); 88 88 89 $array = $ rs->user_id ? 'local' : 'global';89 $array = $s->user_id ? 'local' : 'global'; 90 90 91 91 $this->{$array.'_prefs'}[$id] = array( … … 93 93 'value' => $value, 94 94 'type' => $type, 95 'label' => (string) $ rs->f('pref_label'),96 'global' => $ rs->user_id == ''95 'label' => (string) $s->f('pref_label'), 96 'global' => $s->user_id == '' 97 97 ); 98 98 } -
inc/core/class.dc.xmlrpc.php
r852 r873 242 242 $this->setUser($user,$pwd); 243 243 $this->setBlog(); 244 $ rs = $this->core->blog->getPosts(array(244 $posts = $this->core->blog->getPosts(array( 245 245 'post_id' => (integer) $post_id, 246 246 'post_type' => $post_type 247 247 )); 248 248 249 if ( $rs->isEmpty()) {249 if (count($posts) == 0) { 250 250 throw new Exception('This entry does not exist'); 251 251 } 252 252 253 return $ rs;253 return $posts; 254 254 } 255 255 … … 494 494 495 495 $res = array(); 496 while ($posts->fetch())496 foreach ($posts as $p) 497 497 { 498 498 $tres = array(); 499 499 500 500 $tres['dateCreated'] = new xmlrpcDate($posts->getTS()); 501 $tres['userid'] = $p osts->user_id;502 $tres['postid'] = $p osts->post_id;501 $tres['userid'] = $p->user_id; 502 $tres['postid'] = $p->post_id; 503 503 504 504 if ($type == 'blogger') { 505 $tres['content'] = $p osts->post_content_xhtml;505 $tres['content'] = $p->post_content_xhtml; 506 506 } 507 507 508 508 if ($type == 'mt' || $type == 'mw') { 509 $tres['title'] = $p osts->post_title;509 $tres['title'] = $p->post_title; 510 510 } 511 511 512 512 if ($type == 'mw') { 513 $tres['description'] = $p osts->post_content_xhtml;514 $tres['link'] = $tres['permaLink'] = $p osts->getURL();515 $tres['mt_excerpt'] = $p osts->post_excerpt_xhtml;513 $tres['description'] = $p->post_content_xhtml; 514 $tres['link'] = $tres['permaLink'] = $p->getURL(); 515 $tres['mt_excerpt'] = $p->post_excerpt_xhtml; 516 516 $tres['mt_text_more'] = ''; 517 517 $tres['mt_convert_breaks'] = ''; … … 714 714 715 715 $res = array(); 716 while ($posts->fetch())716 foreach ($posts as $post) 717 717 { 718 718 $tres = array( 719 "dateCreated" => new xmlrpcDate($post s->getTS()),720 "userid" => $post s->user_id,721 "page_id" => $post s->post_id,722 "page_status" => $this->translateWpStatus((integer) $post s->post_status),723 "description" => $post s->post_content_xhtml,724 "title" => $post s->post_title,725 "link" => $post s->getURL(),726 "permaLink" => $post s->getURL(),727 "excerpt" => $post s->post_excerpt_xhtml,719 "dateCreated" => new xmlrpcDate($post->getTS()), 720 "userid" => $post->user_id, 721 "page_id" => $post->post_id, 722 "page_status" => $this->translateWpStatus((integer) $post->post_status), 723 "description" => $post->post_content_xhtml, 724 "title" => $post->post_title, 725 "link" => $post->getURL(), 726 "permaLink" => $post->getURL(), 727 "excerpt" => $post->post_excerpt_xhtml, 728 728 "text_more" => '', 729 "wp_slug" => $post s->post_url,730 "wp_password" => $post s->post_password,731 "wp_author" => $post s->getAuthorCN(),729 "wp_slug" => $post->post_url, 730 "wp_password" => $post->post_password, 731 "wp_author" => $post->getAuthorCN(), 732 732 "wp_page_parent_id" => 0, 733 733 "wp_page_parent_title" => '', 734 "wp_page_order" => $post s->post_position,735 "wp_author_id" => $post s->user_id,736 "wp_author_display_name" => $post s->getAuthorCN(),737 "date_created_gmt" => new xmlrpcDate(dt::iso8601($post s->getTS(),$posts->post_tz)),734 "wp_page_order" => $post->post_position, 735 "wp_author_id" => $post->user_id, 736 "wp_author_display_name" => $post->getAuthorCN(), 737 "date_created_gmt" => new xmlrpcDate(dt::iso8601($post->getTS(),$post->post_tz)), 738 738 "custom_fields" => array(), 739 739 "wp_page_template" => 'default' … … 790 790 $this->setBlog(); 791 791 792 $ rs = $this->core->getBlogPermissions($this->core->blog->id);792 $perms = $this->core->getBlogPermissions($this->core->blog->id); 793 793 $res = array(); 794 794 795 foreach($ rs as $k => $v)795 foreach($perms as $k => $v) 796 796 { 797 797 $res[] = array( … … 817 817 $f_url = $this->core->blog->url. 818 818 $this->core->url->getURLFor('tag_feed','%s'); 819 while ($tags->fetch())819 foreach ($tags as $tag) 820 820 { 821 821 $res[] = array( 822 'tag_id' => $tag s->meta_id,823 'name' => $tag s->meta_id,824 'count' => $tag s->count,825 'slug' => $tag s->meta_id,826 'html_url' => sprintf($url,$tag s->meta_id),827 'rss_url' => sprintf($f_url,$tag s->meta_id)822 'tag_id' => $tag->meta_id, 823 'name' => $tag->meta_id, 824 'count' => $tag->count, 825 'slug' => $tag->meta_id, 826 'html_url' => sprintf($url,$tag->meta_id), 827 'rss_url' => sprintf($f_url,$tag->meta_id) 828 828 ); 829 829 }
Note: See TracChangeset
for help on using the changeset viewer.