Dotclear

Changeset 1522


Ignore:
Timestamp:
09/28/09 10:28:29 (14 years ago)
Author:
Tomtom33
Message:

dcOpenSearch 1.0.3 :

  • fixes bug with media search
  • adds IHM for page search engine
Location:
plugins/dcOpenSearch
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • plugins/dcOpenSearch/_define.php

    r1493 r1522  
    1717          /* Description*/         "Add an advanced search on your blog (posts, pages, comments, medias and other)", 
    1818          /* Author */             "Tomtom (http://blog.zenstyle.fr/)", 
    19           /* Version */            '1.0.2-r1479', 
     19          /* Version */            '1.0.3', 
    2020          /* Permissions */        'usage,contentadmin', 
    2121          /* Priority */           20 
  • plugins/dcOpenSearch/engines/class.dc.engine.medias.php

    r1516 r1522  
    4545          'U.user_name, U.user_firstname, U.user_displayname, U.user_url '. 
    4646          'FROM '.$this->core->prefix.'media M '. 
    47           'INNER JOIN '.$this->core->prefix.'user U ON (M.user_id = U.user_id) '. 
    48           "WHERE (media_title LIKE '%".$q."%' OR ". 
    49           "media_file LIKE '%".$q."%') AND ". 
    50           "media_path = '".$this->core->blog->settings->public_path."'"; 
     47          'INNER JOIN '.$this->core->prefix.'user U ON (M.user_id = U.user_id) WHERE'; 
     48           
     49          $words = text::splitWords($q); 
     50                
     51          if (!empty($words)) { 
     52               if ($words) { 
     53                    foreach ($words as $i => $w) { 
     54                         $words[$i] = "(media_title LIKE '%".$this->core->con->escape($w)."%' OR media_file LIKE '%".$this->core->con->escape($w)."%')"; 
     55                    } 
     56                    $strReq .= ' '.implode(' AND ',$words).' '; 
     57               } 
     58          } 
     59           
     60          $strReq .= " AND media_path = '".$this->core->blog->settings->public_path."'"; 
    5161           
    5262          if (!$this->core->auth->check('media_admin',$this->core->blog->id)) 
     
    5565                
    5666               if ($this->core->auth->userID()) { 
    57                     $strReq .= "OR user_id = '".$this->con->escape($this->core->auth->userID())."'"; 
     67                    $strReq .= "OR user_id = '".$this->core->con->escape($this->core->auth->userID())."'"; 
    5868               } 
    5969               $strReq .= ') '; 
  • plugins/dcOpenSearch/engines/class.dc.engine.pages.php

    r1477 r1522  
    2020      
    2121     protected $core; 
    22      protected $has_gui = false; 
     22     protected $has_gui = true; 
    2323     protected $gui_url = null; 
    2424      
     
    4242           
    4343          while ($rs->fetch()) { 
     44               if ($rs->post_excerpt_xhtml === '') { 
     45                    $content = $rs->post_content_xhtml; 
     46               } 
     47               elseif ($this->getEngineConfig('display') === 'both') { 
     48                    $content = $rs->post_excerpt_xhtml.$rs->post_content_xhtml; 
     49               } 
     50               elseif ($this->getEngineConfig('display') === 'excerpt') { 
     51                    $content = $rs->post_excerpt_xhtml; 
     52               } 
     53               else { 
     54                    $content = $rs->post_content_xhtml; 
     55               } 
    4456               $res[] = array( 
    4557                    'search_id' => $rs->post_id, 
     
    5466                    'search_dt' => $rs->post_creadt, 
    5567                    'search_tz' => $rs->post_tz, 
    56                     'search_content' => (empty($rs->post_excerpt_xhtml) ? $rs->post_content_xhtml : $rs->post_excerpt_xhtml), 
     68                    'search_content' => $content, 
    5769                    'search_comment_nb' => $rs->nb_trackback, 
    5870                    'search_trackback_nb' => $rs->nb_comment, 
     
    6476           
    6577          return $res;    
     78     } 
     79      
     80     public function gui($url) 
     81     { 
     82          $res = ''; 
     83           
     84          $value = array( 
     85               __('Content only') => 'content', 
     86               __('Excerpt when it exists') => 'excerpt', 
     87               __('Both') => 'both' 
     88          ); 
     89           
     90          if (isset($_POST['save'])) 
     91          { 
     92               try { 
     93                    $this->addEngineConfig('display',$_POST['display']); 
     94                    $this->saveEngineConfig(); 
     95                    http::redirect($url.'&config=1'); 
     96               } catch (Exception $e) { 
     97                    $core->error->add($e->getMessage()); 
     98               } 
     99          } 
     100           
     101          if (!empty($_GET['config'])) { 
     102               $res .= '<p class="message">'.__('Configuration have been successfully saved.').'</p>'; 
     103          } 
     104           
     105          $res .= 
     106          '<form action="'.html::escapeURL($url).'" method="post">'. 
     107          '<fieldset><legend>'.__('General').'</legend>'. 
     108          '<p class="field"><label class="classic">'.form::combo('display',$value,$this->getEngineConfig('display')).' '. 
     109          __('Content type:').'</label></p>'. 
     110          '</fieldset>'. 
     111          $this->core->formNonce(). 
     112          '<p><input type="submit" name="save" value="'.__('Save').'"/></p>'. 
     113          '</form>'; 
     114           
     115          return $res; 
    66116     } 
    67117      
Note: See TracChangeset for help on using the changeset viewer.

Sites map