Changeset 2222:30fe556de226
- Timestamp:
- 10/03/13 00:57:41 (11 years ago)
- Branch:
- dcRepo
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/blog_theme.php
r2220 r2222 137 137 ->newList('theme-update') 138 138 ->setModules($modules) 139 ->setPageTab(' update')139 ->setPageTab('themes') 140 140 ->displayModulesList( 141 141 /*cols */ array('sshot', 'name', 'desc', 'author', 'version', 'current_version', 'parent'), 142 /* actions */ array('update' )142 /* actions */ array('update', 'delete') 143 143 ); 144 144 … … 207 207 ->displayNavMenu() 208 208 ->displayModulesList( 209 /* cols */ array('expander', 'sshot', 'name', ' config', 'desc', 'author', 'version', 'parent', 'details', 'support'),209 /* cols */ array('expander', 'sshot', 'name', 'score', 'config', 'desc', 'author', 'version', 'parent', 'details', 'support'), 210 210 /* actions */ array('install'), 211 211 /* nav limit */ true -
admin/js/_plugins.js
r2171 r2222 78 78 var support = $(rsp).find('support').text(); 79 79 var box = document.createElement('div'); 80 var dl= document.createElement('ul');81 dl.className = "mod-more";80 var bloc = document.createElement('ul'); 81 bloc.className = "mod-more"; 82 82 83 83 if (author) { 84 $( dl).append($('<li class="module-author">'+dotclear.msg.module_author+' '+author+'</li>'));84 $(bloc).append($('<li class="module-author">'+dotclear.msg.module_author+' '+author+'</li>')); 85 85 } 86 86 if (details) { … … 91 91 dd += '<a class="module-support" href="'+support+'">'+dotclear.msg.module_support+'</a>'; 92 92 } 93 $( dl).append($('<li>'+dotclear.msg.module_help+' '+dd+'</li>'));93 $(bloc).append($('<li>'+dotclear.msg.module_help+' '+dd+'</li>')); 94 94 } 95 95 96 $(td).append($(box).addClass('two-boxes').append( dl));96 $(td).append($(box).addClass('two-boxes').append(bloc)); 97 97 98 98 var section = $(rsp).find('section').text(); … … 100 100 101 101 var boxb = document.createElement('div'); 102 var dlb = document.createElement('ul');103 dlb.className = "mod-more";102 var blocb = document.createElement('ul'); 103 blocb.className = "mod-more"; 104 104 105 105 if (section) { 106 $( dlb).append($('<li class="module-section">'+dotclear.msg.module_section+' '+section+'</li>'));106 $(blocb).append($('<li class="module-section">'+dotclear.msg.module_section+' '+section+'</li>')); 107 107 } 108 108 if (tags) { 109 $( dlb).append($('<li class="module-tags">'+dotclear.msg.module_tags+' '+tags+'</li>'));109 $(blocb).append($('<li class="module-tags">'+dotclear.msg.module_tags+' '+tags+'</li>')); 110 110 } 111 $(td).append($(boxb).addClass('two-boxes').append( dlb));111 $(td).append($(boxb).addClass('two-boxes').append(blocb)); 112 112 } else { 113 113 alert($(rsp).find('message').text()); … … 151 151 $(function() { 152 152 $('table.modules.expandable tr:not(.line)').each(function() { 153 dotclear.modulesExpander(this,$('table.modules tr.line'));153 dotclear.modulesExpander(this,$('table.modules.expandable tr.line')); 154 154 }); 155 155 $('table.modules.expandable tr.line').each(function() { -
admin/plugins.php
r2219 r2222 229 229 ->displayNavMenu() 230 230 ->displayModulesList( 231 /* cols */ array('expander', 'name', ' version', 'desc'),231 /* cols */ array('expander', 'name', 'score', 'version', 'desc'), 232 232 /* actions */ array('install'), 233 233 /* nav limit */ true -
inc/admin/lib.moduleslist.php
r2221 r2222 269 269 'tags' => '', 270 270 'details' => '', 271 'sshot' => '' 271 'sshot' => '', 272 'score' => 0 272 273 ), 273 274 # Module's values … … 314 315 } 315 316 317 if (in_array('score', $cols) && $this->getSearchQuery() !== null && defined('DC_DEBUG') && DC_DEBUG) { 318 echo 319 '<th class="nowrap">'.__('Score').'</th>'; 320 } 321 316 322 if (in_array('version', $cols)) { 317 323 echo … … 381 387 html::escapeHTML($module['name']) 382 388 ).'</td>'; 389 390 # Display score only for debug purpose 391 if (in_array('score', $cols) && $this->getSearchQuery() !== null && defined('DC_DEBUG') && DC_DEBUG) { 392 echo 393 '<td class="module-version nowrap count"><span class="debug">'.$module['score'].'</span></td>'; 394 } 383 395 384 396 if (in_array('version', $cols)) { … … 863 875 } 864 876 877 # Display score only for debug purpose 878 if (in_array('score', $cols) && $this->getSearchQuery() !== null && defined('DC_DEBUG') && DC_DEBUG) { 879 $line .= 880 '<p class="module-score debug">'.sprintf(__('Score: %s'), $module['score']).'</p>'; 881 } 882 865 883 if (in_array('sshot', $cols)) { 866 884 # Screenshot from url … … 901 919 } 902 920 921 if (in_array('current_version', $cols)) { 922 $line .= 923 '<span class="module-current-version">'.sprintf(__('(current version %s)'),html::escapeHTML($module['current_version'])).'</span> '; 924 } 925 903 926 if (in_array('parent', $cols) && $has_parent) { 904 927 if ($is_parent_present) { … … 910 933 '<span class="module-parent-missing">'.sprintf(__('(requires "%s")'),html::escapeHTML($parent)).'</span> '; 911 934 } 912 }913 914 if (in_array('version', $cols)) {915 $line .=916 '<span class="module-version">'.sprintf(__('version %s'),html::escapeHTML($module['version'])).'</span> ';917 935 } 918 936 -
inc/core/class.dc.store.parser.php
r2216 r2222 15 15 @ingroup DC_CORE 16 16 @brief Repository modules XML feed parser 17 @since 2.6 17 18 18 19 Provides an object to parse XML feed of modules from a repository. -
inc/core/class.dc.store.php
r2216 r2222 15 15 @ingroup DC_CORE 16 16 @brief Repository modules XML feed reader 17 @since 2.6 17 18 18 19 Provides an object to parse XML feed of modules from repository. … … 24 25 /** @var object dcModules instance */ 25 26 public $modules; 27 28 /** @var array Modules fields to search on and their weighting */ 29 public static $weighting = array('id' => 10, 'name' => 8, 'author' => 6, 'tags' => 4, 'desc' => 2); 26 30 27 31 /** @var string User agent used to query repository */ … … 126 130 127 131 # Split query into small clean words 128 $patterns = explode(' ', $pattern); 129 array_walk($patterns, array('dcStore','sanitize')); 132 if (!($patterns = self::patternize($pattern))) { 133 return $result; 134 } 130 135 131 136 # For each modules 132 137 foreach ($this->data['new'] as $id => $module) { 133 134 # Split modules infos into small clean word 135 $subjects = explode(' ', $id.' '.$module['name'].' '.$module['desc']); 136 array_walk($subjects, array('dcStore','sanitize')); 137 138 # Check contents 139 if (!($nb = preg_match_all('/('.implode('|', $patterns).')/', implode(' ', $subjects), $_))) { 140 continue; 141 } 142 143 # Add module to result 144 if (!isset($sorter[$id])) { 145 $sorter[$id] = 0; 146 $result[$id] = $module; 147 } 148 149 # Increment matches count 150 $sorter[$id] += $nb; 151 $result[$id]['accuracy'] = $sorter[$id]; 138 $module['id'] = $id; 139 140 # Loop through required module fields 141 foreach(self::$weighting as $field => $weight) { 142 143 # Skip fields which not exsist on module 144 if (empty($module[$field])) { 145 continue; 146 } 147 148 # Split field value into small clean word 149 if (!($subjects = self::patternize($module[$field]))) { 150 continue; 151 } 152 153 # Check contents 154 if (!($nb = preg_match_all('/('.implode('|', $patterns).')/', implode(' ', $subjects), $_))) { 155 continue; 156 } 157 158 # Add module to result 159 if (!isset($sorter[$id])) { 160 $sorter[$id] = 0; 161 $result[$id] = $module; 162 } 163 164 # Increment score by matches count * field weight 165 $sorter[$id] += $nb * $weight; 166 $result[$id]['score'] = $sorter[$id]; 167 } 152 168 } 153 169 # Sort response by matches count … … 217 233 218 234 /** 219 * S anitize string.235 * Split and clean pattern. 220 236 * 221 237 * @param string $str String to sanitize 222 * @param null $_ Unused param 223 */ 224 public static function sanitize(&$str, $_) 225 { 226 $str = strtolower(preg_replace('/[^A-Za-z0-9]/', '', $str)); 238 * @return array Array of cleaned pieces of string or false if none 239 */ 240 public static function patternize($str) 241 { 242 $arr = array(); 243 244 foreach(explode(' ', $str) as $_) { 245 $_ = strtolower(preg_replace('/[^A-Za-z0-9]/', '', $_)); 246 if (strlen($_) > 2) { 247 $arr[] = $_; 248 } 249 } 250 251 return empty($arr) ? false : $arr; 227 252 } 228 253 -
inc/core/class.dc.store.reader.php
r2216 r2222 15 15 @ingroup DC_CORE 16 16 @brief Repository modules XML feed reader 17 @since 2.6 17 18 18 19 Provides an object to parse XML feed of modules from repository.
Note: See TracChangeset
for help on using the changeset viewer.