Changeset 721
- Timestamp:
- 01/22/09 17:33:09 (14 years ago)
- Location:
- plugins/multiBlogSearch
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/multiBlogSearch/_admin.php
r717 r721 23 23 '<fieldset><legend>'.__('Multi blog search').'</legend>'. 24 24 '<p><label class="classic">'. 25 form::checkbox('multiblogsearch_enabled','1',$settings->multi search_enabled).25 form::checkbox('multiblogsearch_enabled','1',$settings->multiblogsearch_enabled). 26 26 __('Enable multi blog Search').'</label></p>'. 27 27 '</fieldset>'; … … 30 30 public static function adminBeforeBlogSettingsUpdate(&$settings) 31 31 { 32 $settings->setNameSpace('multi BlogSearch');33 $settings->put('multiblogsearch_enabled',!empty($_POST['multi search_enabled']),'boolean',false);32 $settings->setNameSpace('multiblogsearch'); 33 $settings->put('multiblogsearch_enabled',!empty($_POST['multiblogsearch_enabled']),'boolean'); 34 34 $settings->setNameSpace('system'); 35 35 } -
plugins/multiBlogSearch/_define.php
r717 r721 15 15 /* Description*/ "Find all posts in all blogs", 16 16 /* Author */ "Tomtom (http://blog.zenstyle.fr)", 17 /* Version */ '0. 2',17 /* Version */ '0.3', 18 18 /* Permissions */ 'usage,contentadmin' 19 19 ); -
plugins/multiBlogSearch/_public.php
r717 r721 16 16 $core->tpl->addValue('MultiBlogSearchPaginationURL',array('multiBlogSearchTpl','paginationURL')); 17 17 $core->tpl->addValue('MultiBlogSearchBlogName',array('multiBlogSearchTpl','blogName')); 18 $core->tpl->addValue('MultiBlogSearchEntryURL',array('multiBlogSearchTpl','entryURL')); 19 $core->tpl->addValue('MultiBlogSearchCategoryURL',array('multiBlogSearchTpl','categoryURL')); 20 $core->tpl->addValue('MultiBlogSearchMetaURL',array('multiBlogSearchTpl','metaURL')); 18 21 $core->tpl->addBlock('MultiBlogSearchEntries',array('multiBlogSearchTpl','entries')); 19 22 $core->tpl->addBlock('MultiBlogSearchPagination',array('multiBlogSearchTpl','pagination')); … … 22 25 class multiBlogSearchBehaviors extends dcUrlHandlers 23 26 { 24 /** 25 * Adds multiBlogSearch templates 26 */ 27 27 28 public static function addTplPath() 28 29 { … … 32 33 } 33 34 34 /**35 * Intercepts multiBlogSearch param in URI and serves right template36 */37 35 public static function multiBlogSearch() 38 36 { … … 46 44 47 45 if ($GLOBALS['_search']) { 48 $ _multiblogsearch = new multiBlogSearch($GLOBALS['core']);49 $GLOBALS['_search_count'] = $ _multiblogsearch->getMultiBlogPosts(array('search' => $GLOBALS['_search']),true)->f(0);46 $GLOBALS['_ctx']->multiblogsearch = new multiBlogSearch($GLOBALS['core']); 47 $GLOBALS['_search_count'] = $GLOBALS['_ctx']->multiblogsearch->getPosts(array('search' => $GLOBALS['_search']),true)->f(0); 50 48 self::serveDocument('multiblogsearch.html'); 51 49 exit; … … 71 69 $f = $GLOBALS['core']->tpl->getFilters($attr); 72 70 return '<?php echo '.sprintf($f,'$_ctx->posts->blog_name').'; ?>'; 71 } 72 73 public static function entryURL($attr) 74 { 75 $f = $GLOBALS['core']->tpl->getFilters($attr); 76 return '<?php echo '.sprintf($f,'$_ctx->posts->blog_url.$core->url->getBase("post").'. 77 '"/".$_ctx->posts->post_url').'; ?>'; 78 } 79 80 public static function categoryURL($attr) 81 { 82 $f = $GLOBALS['core']->tpl->getFilters($attr); 83 return '<?php echo '.sprintf($f,'$_ctx->posts->blog_url.$core->url->getBase("category").'. 84 '"/".$_ctx->posts->cat_url').'; ?>'; 85 } 86 87 public static function metaURL($attr) 88 { 89 $f = $GLOBALS['core']->tpl->getFilters($attr); 90 return '<?php echo '.sprintf($f,'$_ctx->posts->blog_url.$core->url->getBase("tag").'. 91 '"/".rawurlencode($_ctx->meta->meta_id)').'; ?>'; 73 92 } 74 93 … … 146 165 } 147 166 148 $sortby = ' post_dt';149 $order = ' desc';167 $sortby = 'blog_name'; 168 $order = 'asc'; 150 169 if (isset($attr['sortby'])) { 151 170 switch ($attr['sortby']) { … … 173 192 $res = "<?php\n"; 174 193 $res .= $p; 175 $res .= '$_multiblogsearch = new multiBlogSearch($core);'."\n";176 194 $res .= '$_ctx->post_params = $params;'."\n"; 177 $res .= '$_ctx->posts = $_ multiblogsearch->getMultiBlogPosts($params);'."\n";178 $res .= 'unset($params); unset($_multiblogsearch);'."\n";195 $res .= '$_ctx->posts = $_ctx->multiblogsearch->getPosts($params);'."\n"; 196 $res .= 'unset($params);'."\n"; 179 197 $res .= "?>\n"; 180 198 … … 189 207 { 190 208 return 191 "<?php if ( !multiBlogSearch::firstPostOfBlog(\$_ctx->posts)) : ?>".209 "<?php if (\$_ctx->multiblogsearch->firstPostOfBlog(\$_ctx->posts)) : ?>". 192 210 $content. 193 211 "<?php endif; ?>"; … … 198 216 $p = "<?php\n"; 199 217 $p .= '$params = $_ctx->post_params;'."\n"; 200 $p .= '$_multiblogsearch = new multiBlogSearch($core);'."\n"; 201 $p .= '$_ctx->pagination = $_multiblogsearch->getMultiBlogPosts($params,true); unset($params);'."\n"; 218 $p .= '$_ctx->pagination = $_ctx->multiblogsearch->getPosts($params,true); unset($params);'."\n"; 202 219 $p .= "?>\n"; 203 220 -
plugins/multiBlogSearch/default-templates/multiblogsearch.html
r717 r721 75 75 76 76 <h2 class="post-title"><a 77 href="{{tpl: EntryURL}}">{{tpl:EntryTitle encode_html="1"}}</a></h2>77 href="{{tpl:MultiBlogSearchEntryURL}}">{{tpl:EntryTitle encode_html="1"}}</a></h2> 78 78 79 79 <p class="post-info">{{tpl:lang By}} {{tpl:EntryAuthorLink}} 80 80 {{tpl:lang on}} {{tpl:EntryDate}}, {{tpl:EntryTime}} 81 81 <tpl:EntryIf has_category="1"> 82 - <a href="{{tpl: EntryCategoryURL}}">{{tpl:EntryCategory encode_html="1"}}</a>82 - <a href="{{tpl:MultiBlogSearchCategoryURL}}">{{tpl:EntryCategory encode_html="1"}}</a> 83 83 </tpl:EntryIf> 84 84 </p> … … 86 86 <tpl:EntryMetaData> 87 87 <tpl:MetaDataHeader><ul class="post-tags"></tpl:MetaDataHeader> 88 <li><a href="{{tpl:M etaURL}}">{{tpl:MetaID}}</a></li>88 <li><a href="{{tpl:MultiBlogSearchMetaURL}}">{{tpl:MetaID}}</a></li> 89 89 <tpl:MetaDataFooter></ul></tpl:MetaDataFooter> 90 90 </tpl:EntryMetaData> … … 96 96 <tpl:EntryIf extended="1"> 97 97 <div class="post-content">{{tpl:EntryExcerpt}}</div> 98 <p class="read-it"><a href="{{tpl: EntryURL}}"98 <p class="read-it"><a href="{{tpl:MultiBlogSearchEntryURL}}" 99 99 title="{{tpl:lang Continue reading}} {{tpl:EntryTitle encode_html="1"}}">{{tpl:lang Continue 100 100 reading}}</a>...</p> … … 114 114 </tpl:EntryIf> 115 115 <tpl:EntryIf show_comments="1"> 116 <a href="{{tpl: EntryURL}}#comments" class="comment_count">{{tpl:EntryCommentCount}}</a>116 <a href="{{tpl:MultiBlogSearchEntryURL}}#comments" class="comment_count">{{tpl:EntryCommentCount}}</a> 117 117 </tpl:EntryIf> 118 118 <tpl:EntryIf show_pings="1"> 119 <a href="{{tpl: EntryURL}}#pings" class="ping_count">{{tpl:EntryPingCount}}</a></tpl:EntryIf>119 <a href="{{tpl:MultiBlogSearchEntryURL}}#pings" class="ping_count">{{tpl:EntryPingCount}}</a></tpl:EntryIf> 120 120 <tpl:EntryIf has_attachment="1"> 121 <a href="{{tpl: EntryURL}}#attachments" class="attach_count">{{tpl:EntryAttachmentCount}}</a></tpl:EntryIf>121 <a href="{{tpl:MultiBlogSearchEntryURL}}#attachments" class="attach_count">{{tpl:EntryAttachmentCount}}</a></tpl:EntryIf> 122 122 <tpl:EntryIf operator="or" show_comments="1" show_pings="1" has_attachment="1"> 123 123 </p> -
plugins/multiBlogSearch/inc/class.multi.blog.search.php
r717 r721 14 14 { 15 15 protected $core; 16 16 17 17 public function __construct(&$core) 18 18 { 19 19 $this->core =& $core; 20 20 } 21 22 public function get MultiBlogPosts($params=array(),$count_only=false)21 22 public function getPosts($params = array(),$count_only = false) 23 23 { 24 24 if ($count_only) … … 35 35 'post_content, post_content_xhtml, post_notes, '; 36 36 } 37 37 38 38 if (!empty($params['columns']) && is_array($params['columns'])) { 39 39 $content_req .= implode(', ',$params['columns']).', '; 40 40 } 41 41 42 42 $strReq = 43 43 'SELECT P.post_id, P.blog_id, P.user_id, P.cat_id, post_dt, '. … … 48 48 'U.user_name, U.user_firstname, U.user_displayname, U.user_email, '. 49 49 'U.user_url, '. 50 'C.cat_title, C.cat_url, C.cat_desc, B.blog_name '; 51 } 52 50 'C.cat_title, C.cat_url, C.cat_desc, '. 51 'B.blog_url, B.blog_name '; 52 } 53 53 54 $strReq .= 54 55 'FROM '.$this->core->prefix.'post P '. 55 56 'INNER JOIN '.$this->core->prefix.'user U ON U.user_id = P.user_id '. 56 ' LEFT OUTER JOIN '.$this->core->prefix.'category C ON P.cat_id = C.cat_id'.57 'LEFT OUTER JOIN '.$this->core->prefix.' blog B ON P.blog_id = B.blog_id ';58 57 'NATURAL JOIN '.$this->core->prefix.'blog B '. 58 'LEFT OUTER JOIN '.$this->core->prefix.'category C ON P.cat_id = C.cat_id '; 59 59 60 if (!empty($params['from'])) { 60 61 $strReq .= $params['from'].' '; 61 62 } 62 63 63 64 $strReq .= 64 "WHERE P.blog_id != '' ";65 65 "WHERE P.blog_id != '' AND B.blog_id = P.blog_id "; 66 66 67 if (!$this->core->auth->check('contentadmin',$this->core->blog->id)) { 67 68 $strReq .= 'AND ((post_status = 1 '; 68 69 69 70 if ($this->core->blog->without_password) { 70 71 $strReq .= 'AND post_password IS NULL '; 71 72 } 72 73 $strReq .= ') '; 73 74 74 75 if ($this->core->auth->userID()) { 75 76 $strReq .= "OR P.user_id = '".$this->con->escape($this->core->auth->userID())."')"; … … 78 79 } 79 80 } 80 81 81 82 # Adding parameters 82 83 if (isset($params['post_type'])) … … 92 93 $strReq .= "AND post_type = 'post' "; 93 94 } 94 95 95 96 if (!empty($params['post_id'])) { 96 97 if (is_array($params['post_id'])) { … … 101 102 $strReq .= 'AND P.post_id '.$this->core->con->in($params['post_id']); 102 103 } 103 104 104 105 if (!empty($params['post_url'])) { 105 106 $strReq .= "AND post_url = '".$this->core->con->escape($params['post_url'])."' "; 106 107 } 107 108 108 109 if (!empty($params['user_id'])) { 109 110 $strReq .= "AND U.user_id = '".$this->core->con->escape($params['user_id'])."' "; 110 111 } 111 112 112 113 if (!empty($params['cat_id'])) 113 114 { … … 130 131 $strReq .= 'AND '.$this->core->blog->getPostsCategoryFilter($params['cat_url'],'cat_url').' '; 131 132 } 132 133 133 134 /* Other filters */ 134 135 if (isset($params['post_status'])) { 135 136 $strReq .= 'AND post_status = '.(integer) $params['post_status'].' '; 136 137 } 137 138 138 139 if (isset($params['post_selected'])) { 139 140 $strReq .= 'AND post_selected = '.(integer) $params['post_selected'].' '; 140 141 } 141 142 142 143 if (!empty($params['post_year'])) { 143 144 $strReq .= 'AND '.$this->core->con->dateFormat('post_dt','%Y').' = '. 144 145 "'".sprintf('%04d',$params['post_year'])."' "; 145 146 } 146 147 147 148 if (!empty($params['post_month'])) { 148 149 $strReq .= 'AND '.$this->core->con->dateFormat('post_dt','%m').' = '. 149 150 "'".sprintf('%02d',$params['post_month'])."' "; 150 151 } 151 152 152 153 if (!empty($params['post_day'])) { 153 154 $strReq .= 'AND '.$this->core->con->dateFormat('post_dt','%d').' = '. 154 155 "'".sprintf('%02d',$params['post_day'])."' "; 155 156 } 156 157 157 158 if (!empty($params['post_lang'])) { 158 159 $strReq .= "AND P.post_lang = '".$this->core->con->escape($params['post_lang'])."' "; 159 160 } 160 161 161 162 if (!empty($params['search'])) 162 163 { 163 164 $words = text::splitWords($params['search']); 164 165 165 166 if (!empty($words)) 166 167 { … … 169 170 $this->core->callBehavior('multiBlogSearchPostsSearch',$this->core,array(&$words,&$strReq,&$params)); 170 171 } 171 172 172 173 if ($words) 173 174 { … … 179 180 } 180 181 } 181 182 182 183 if (!empty($params['sql'])) { 183 184 $strReq .= $params['sql'].' '; 184 185 } 185 186 186 187 if (!$count_only) 187 188 { … … 189 190 $strReq .= 'ORDER BY '.$this->core->con->escape($params['order']).' '; 190 191 } else { 191 $strReq .= 'ORDER BY blog_name ASC, post_dt DESC '; 192 } 193 } 194 192 $strReq .= 'ORDER BY post_dt DESC, blog_name ASC '; 193 } 194 $strReq .= ', post_dt DESC '; 195 } 196 195 197 if (!$count_only && !empty($params['limit'])) { 196 //$strReq .= $this->core->con->limit($params['limit']);197 } 198 echo $strReq;//print_r($params['limit']); 198 $strReq .= $this->core->con->limit($params['limit']); 199 } 200 199 201 $rs = $this->core->con->select($strReq); 200 202 $rs->core = $this->core; 201 203 $rs->_nb_media = array(); 202 204 $rs->extend('rsExtPost'); 203 205 204 206 # --BEHAVIOR-- multiBlogSearchGetPosts 205 207 $this->core->callBehavior('multiBlogSearchGetPosts',$rs); 206 208 207 209 return $rs; 208 210 } 209 210 public static function firstPostOfBlog(&$rs) 211 { 212 $cblog = $rs->blog_id; //var_dump($rs->post_id); 211 212 public function firstPostOfBlog(&$rs) 213 { 214 if ($rs->index() == 0) { 215 return true; 216 } 217 $cblog = $rs->blog_id; 213 218 $rs->movePrev(); 214 $nblog = $rs->blog_id; //var_dump($rs->post_id);215 $rs->moveNext(); //var_dump($rs->count()); exit; //var_dump($cblog); exit;219 $nblog = $rs->blog_id; 220 $rs->moveNext(); 216 221 return $nblog != $cblog; 217 222 } 218 223 219 224 public static function paginationURL($offset = 0) 220 225 { 221 226 global $core; 222 227 223 228 $args = $_SERVER['URL_REQUEST_PART']; 224 229
Note: See TracChangeset
for help on using the changeset viewer.