From a60d068bcc351c8bc2e0a71f6e05dd79173be73f Mon Sep 17 00:00:00 2001 From: Kink03 Date: Thu, 20 Jun 2013 11:18:56 +0200 Subject: [PATCH 1/3] Update README.md Ready for v1.02 * url page call instead of module url * filtering displayed item --- README.md | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 82962bb..96b0aaf 100755 --- a/README.md +++ b/README.md @@ -1,17 +1,17 @@ Ionize Search module ======================= -Version : 1.0 +Version : 1.1 -Ionize version : 0.9.9 +Ionize version : 1.0.2 -Released on january 2013 +Released on june 2013 ### About -Search gives search capabilities to Ionize. +Search gives multilang search capabilities to Ionize. -This version of Search works only with Ionize from version 0.9.9 +This version of Search works only with Ionize from version 1.0.2 ### Authors @@ -24,6 +24,14 @@ This version of Search works only with Ionize from version 0.9.9 * Copy the folder "Search" into the "/modules" folder of your Ionize installation. * In the ionize backend, go to : Modules > Administration * Click on "install" +* Create a view containing the tag `` +* Create a page called 'search', it's mandatory +* Translate title and url of this page to any language +* Add previous view to this page. + +That's all. + +To display a search form in other views, simply use the tag `` From 689d7feab8c40a3f81c9cf4dbc365b40b7d03421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Brugi=C3=A8re?= Date: Thu, 20 Jun 2013 13:35:55 +0200 Subject: [PATCH 2/3] Updated for Ionize 1.02 --- Search/config.xml | 7 --- Search/config/config.php | 18 +++++++ Search/config/index.html | 10 ++++ Search/controllers/search.php | 4 +- Search/index.html | 10 ++++ Search/language/en/index.html | 10 ++++ Search/language/en/search_lang.php | 5 +- Search/language/fr/index.html | 10 ++++ Search/language/fr/search_lang.php | 4 +- Search/language/ja/index.html | 2 +- Search/language/ja/search_lang.php | 15 ++++-- Search/language/tr/index.html | 10 ++++ Search/language/tr/search_lang.php | 7 +++ Search/libraries/tags.php | 43 +++++++++++++--- Search/models/search_model.php | 3 +- Search/views/search_form.php | 8 +-- Search/views/search_result.php | 79 ++++++++---------------------- 17 files changed, 153 insertions(+), 92 deletions(-) delete mode 100644 Search/config.xml create mode 100644 Search/config/index.html create mode 100644 Search/index.html create mode 100644 Search/language/en/index.html create mode 100644 Search/language/fr/index.html create mode 100644 Search/language/tr/index.html diff --git a/Search/config.xml b/Search/config.xml deleted file mode 100644 index a334dcb..0000000 --- a/Search/config.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - Search Module - Search the content of the site - search - false - \ No newline at end of file diff --git a/Search/config/config.php b/Search/config/config.php index e69de29..c3ba0a8 100644 --- a/Search/config/config.php +++ b/Search/config/config.php @@ -0,0 +1,18 @@ + "Search", + 'name' => "Search Module", + 'description' => "Search the content of the site", + 'author' => "Partikule", + 'version' => "1.1", + + // to activate multilang searching, module don't use its url, so, anything is good except 'search'. + // Instead, module use a call to a page with id 'search' which can be translated to any language. It's mandatory ! + 'uri' => 'searching', + 'has_admin'=> FALSE, + 'has_frontend'=> FALSE, +); + +return $config['module']['search']; \ No newline at end of file diff --git a/Search/config/index.html b/Search/config/index.html new file mode 100644 index 0000000..c942a79 --- /dev/null +++ b/Search/config/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + \ No newline at end of file diff --git a/Search/controllers/search.php b/Search/controllers/search.php index 7cd9e6b..cca56e9 100644 --- a/Search/controllers/search.php +++ b/Search/controllers/search.php @@ -6,7 +6,7 @@ * @author Ionize Dev Team * @license http://ionizecms.com/doc-license * @link http://ionizecms.com - * @since Version 0.94 + * @since Version 1.02 */ // ------------------------------------------------------------------------ @@ -22,7 +22,7 @@ */ -class Search extends Base_Controller +class Search extends My_Module { // ------------------------------------------------------------------------ diff --git a/Search/index.html b/Search/index.html new file mode 100644 index 0000000..c942a79 --- /dev/null +++ b/Search/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + \ No newline at end of file diff --git a/Search/language/en/index.html b/Search/language/en/index.html new file mode 100644 index 0000000..c942a79 --- /dev/null +++ b/Search/language/en/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + \ No newline at end of file diff --git a/Search/language/en/search_lang.php b/Search/language/en/search_lang.php index a487f48..ad74632 100644 --- a/Search/language/en/search_lang.php +++ b/Search/language/en/search_lang.php @@ -15,11 +15,10 @@ $lang['module_search_input_label'] = 'Search'; $lang['module_search_button_start'] = 'Start searching'; -$lang['module_search_message_no_results'] = 'No result found'; +$lang['module_search_message_no_results'] = 'No result found with term '; $lang['module_search_fill_the_field'] = 'Your searched term :'; $lang['module_search_results_title'] = 'Results for'; $lang['module_search_form'] = 'Search for...'; $lang['module_search_result_in'] = 'Result in: '; -$lang['module_search_read_complete_article'] = 'Read the article...'; - +$lang['module_search_read_complete_article'] = 'Read the article...'; \ No newline at end of file diff --git a/Search/language/fr/index.html b/Search/language/fr/index.html new file mode 100644 index 0000000..c942a79 --- /dev/null +++ b/Search/language/fr/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + \ No newline at end of file diff --git a/Search/language/fr/search_lang.php b/Search/language/fr/search_lang.php index 01775ea..4521073 100644 --- a/Search/language/fr/search_lang.php +++ b/Search/language/fr/search_lang.php @@ -15,10 +15,10 @@ $lang['module_search_input_label'] = 'Chercher'; $lang['module_search_button_start'] = 'Lancer la recherche'; -$lang['module_search_message_no_results'] = 'Aucun résultat trouvé'; +$lang['module_search_message_no_results'] = 'Aucun résultat trouvé avec le terme '; $lang['module_search_fill_the_field'] = 'Saisissez le terme recherché'; $lang['module_search_results_title'] = 'Résultats pour : '; $lang['module_search_form'] = 'Rechercher...'; $lang['module_search_result_in'] = 'Résultat dans : '; -$lang['module_search_read_complete_article'] = "Lire l'article..."; +$lang['module_search_read_complete_article'] = "Lire l'article..."; \ No newline at end of file diff --git a/Search/language/ja/index.html b/Search/language/ja/index.html index 4762c04..c942a79 100644 --- a/Search/language/ja/index.html +++ b/Search/language/ja/index.html @@ -4,7 +4,7 @@ -

直接アクセス禁止

+

Directory access is forbidden.

\ No newline at end of file diff --git a/Search/language/ja/search_lang.php b/Search/language/ja/search_lang.php index 61e0172..17b6994 100644 --- a/Search/language/ja/search_lang.php +++ b/Search/language/ja/search_lang.php @@ -13,7 +13,14 @@ |-------------------------------------------------------------------------- */ -$lang['module_search_button_start'] = '検索実行'; -$lang['module_search_message_no_results'] = '一件も見つかりませんでした'; -$lang['module_search_fill_the_field'] = '検索文字列 :'; -$lang['module_search_results_title'] = '検索結果'; +$lang['module_search_input_label'] = '検索'; +$lang['module_search_button_start'] = '検索実行'; +$lang['module_search_message_no_results'] = '一件も見つかりませんでした'; +$lang['module_search_fill_the_field'] = '検索文字列 :'; +$lang['module_search_results_title'] = '検索結果'; + + +$lang['module_search_form'] = '検索...'; + +$lang['module_search_result_in'] = '結果: '; +$lang['module_search_read_complete_article'] = "記事を読む..."; \ No newline at end of file diff --git a/Search/language/tr/index.html b/Search/language/tr/index.html new file mode 100644 index 0000000..c942a79 --- /dev/null +++ b/Search/language/tr/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + \ No newline at end of file diff --git a/Search/language/tr/search_lang.php b/Search/language/tr/search_lang.php index 5d44d45..c7187d9 100644 --- a/Search/language/tr/search_lang.php +++ b/Search/language/tr/search_lang.php @@ -13,8 +13,15 @@ |-------------------------------------------------------------------------- */ + +$lang['module_search_input_label'] = 'Arama'; $lang['module_search_button_start'] = 'Aramayı başlat'; $lang['module_search_message_no_results'] = 'Sonuç bulunamadı'; $lang['module_search_fill_the_field'] = 'Arama Terimleriniz :'; $lang['module_search_results_title'] = 'Sonuçlar'; + +$lang['module_search_form'] = 'Arama...'; + +$lang['module_search_result_in'] = 'Sonuçları: '; +$lang['module_search_read_complete_article'] = "Makaleyi okuyun ..."; \ No newline at end of file diff --git a/Search/libraries/tags.php b/Search/libraries/tags.php index 261cb52..b2925ed 100755 --- a/Search/libraries/tags.php +++ b/Search/libraries/tags.php @@ -8,7 +8,7 @@ * @author Ionize Dev Team * @license http://ionizecms.com/doc-license * @link http://ionizecms.com - * @since Version 0.9.5 + * @since Version 1.02 * * */ @@ -31,6 +31,7 @@ class Search_Tags extends TagManager public static $tag_definitions = array ( 'search:form' => 'tag_search_form', + 'search:display' => 'tag_search_display', 'search:results' => 'tag_search_results', 'search:realm' => 'tag_simple_value', 'search:results:result' => 'tag_expand', @@ -91,6 +92,24 @@ public static function tag_search_form(FTL_Binding $tag) } + // ------------------------------------------------------------------------ + + + /** + * Display the results view + * + * @usage + * + */ + public static function tag_search_display(FTL_Binding $tag) + { + $tag->expand(); + + // the tag returns the content of this view : + return $tag->parse_as_nested(file_get_contents(MODPATH.'Search/views/search_result'.EXT)); + } + + // ------------------------------------------------------------------------ @@ -126,15 +145,25 @@ public static function tag_search_results(FTL_Binding $tag) { // arrays of keys, for multisorting $knum = $kdate = array(); + $unique = array(); foreach($articles as $key => &$article) { - // set number of found words - preg_match_all('#'.$realm.'#i', $article['title'].' '.$article['content'], $match); - $num = count($match[0]); - - $article['nb_words'] = $knum[$key] = $num; - $kdate[$key] = strtotime($article['date']); + // remove duplicates + if(!in_array($article['id_article'], $unique)) { + $unique[] = $article['id_article']; + + // set number of found words + preg_match_all('#'.$realm.'#i', $article['title'].' '.$article['content'], $match); + $num = count($match[0]); + + $article['nb_words'] = $knum[$key] = $num; + $kdate[$key] = strtotime($article['date']); + + } else { + unset($articles[$key]); + } + } // Sort the results by realm occurences DESC first, by date DESC second. diff --git a/Search/models/search_model.php b/Search/models/search_model.php index b687870..f392349 100644 --- a/Search/models/search_model.php +++ b/Search/models/search_model.php @@ -6,7 +6,7 @@ * @author Ionize Dev Team * @license http://ionizecms.com/doc-license * @link http://ionizecms.com - * @since Version 0.9.5 + * @since Version 1.02 */ // ------------------------------------------------------------------------ @@ -47,6 +47,7 @@ function get_articles($realm) $lang = Settings::get_lang(); + // Page_Article table $this->{$this->db_group}->select($this->parent_table.'.*', FALSE); $this->{$this->db_group}->join( diff --git a/Search/views/search_form.php b/Search/views/search_form.php index 26d8b9b..7f327d8 100644 --- a/Search/views/search_form.php +++ b/Search/views/search_form.php @@ -1,9 +1,5 @@ -
- - - - " /> - + + " />
\ No newline at end of file diff --git a/Search/views/search_result.php b/Search/views/search_result.php index a268525..abeb7cd 100755 --- a/Search/views/search_result.php +++ b/Search/views/search_result.php @@ -1,62 +1,23 @@ - + - - - - -

""

- - - - + +

""

- - - - - - -
- - - - - -

- - - - - - - -
- - - - - - -
- -
+ + + "" + + + + + + +
+
+ +
+
+
+
+ \ No newline at end of file From 34a78266cb1392698aced65eb1e52ff86bb4d972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Brugi=C3=A8re?= Date: Thu, 8 Aug 2013 10:28:56 +0200 Subject: [PATCH 3/3] [bug_correction] search scope Because of the new definition of library, i changed the name of the file --- Search/libraries/{tags.php => search_tags.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Search/libraries/{tags.php => search_tags.php} (100%) mode change 100755 => 100644 diff --git a/Search/libraries/tags.php b/Search/libraries/search_tags.php old mode 100755 new mode 100644 similarity index 100% rename from Search/libraries/tags.php rename to Search/libraries/search_tags.php