From 3757a19ce701ac58e0b4c3569bf779a1718f6939 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Fri, 7 Feb 2014 11:27:33 +0100 Subject: [PATCH 01/34] materio_search_api updated dynamic field definition https://drupal.org/comment/8188439#comment-8188439 --- materio_search_api.module | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/materio_search_api.module b/materio_search_api.module index ad24f4ce..71f73b60 100755 --- a/materio_search_api.module +++ b/materio_search_api.module @@ -107,13 +107,18 @@ function materio_search_api_access_search(){ function materio_search_api_search_api_data_type_info() { return array( 'edge_n2_kw_text' => array( - 'name' => t('Fulltext (partial)'), + 'name' => t('Fulltext (w/ partial matching)'), 'fallback' => 'text', + 'prefix' => 'tem', + 'always multiValued' => TRUE, ), ); - return $types; } +/** +* - - - - - - - - - - - - SOLR - - - - - - - - - - - - +*/ + /** * Implements hook_search_api_solr_dynamic_field_info(). * From 6ccf2ddb917357cc9d9087591d116b50f77af158 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Wed, 19 Feb 2014 16:59:29 +0100 Subject: [PATCH 02/34] SOLR : autocompletion accent & companie tranlation accent : added a custom term propertie which duplicate the term name to index it without accent companie : replaced the custom term propertie by a node (materiau) property which retrieve the companie info frome the tode node --- materio_search_api.module | 113 +++++++++++++++++++++++++++++--------- 1 file changed, 87 insertions(+), 26 deletions(-) diff --git a/materio_search_api.module b/materio_search_api.module index 71f73b60..6908519c 100755 --- a/materio_search_api.module +++ b/materio_search_api.module @@ -99,6 +99,11 @@ function materio_search_api_access_search(){ return user_access('use materio search api for breves') || user_access('use materio search api'); } + +/** +* - - - - - - - - - - - - SOLR - - - - - - - - - - - - +*/ + /** * Implements hook_search_api_data_type_info(). * @@ -107,18 +112,20 @@ function materio_search_api_access_search(){ function materio_search_api_search_api_data_type_info() { return array( 'edge_n2_kw_text' => array( - 'name' => t('Fulltext (w/ partial matching)'), + 'name' => t('Fulltext (partial matching)'), 'fallback' => 'text', 'prefix' => 'tem', 'always multiValued' => TRUE, ), + 'edge_n2_kw_mapped_text' => array( + 'name' => t('Fulltext without accents (partial matching)'), + 'fallback' => 'text', + 'prefix' => 'temmap', + 'always multiValued' => TRUE, + ), ); } -/** -* - - - - - - - - - - - - SOLR - - - - - - - - - - - - -*/ - /** * Implements hook_search_api_solr_dynamic_field_info(). * @@ -130,20 +137,30 @@ function materio_search_api_search_api_solr_dynamic_field_info() { 'prefix' => 'tem', 'always multiValued' => TRUE, ), + 'edge_n2_kw_mapped_text' => array( + 'prefix' => 'temmap', + 'always multiValued' => TRUE, + ), ); + } /** * hook_entity_property_info_alter(). + * + * define own fields + * - main taxonomy terms, the purpose is to be able to attribute differente boost on serach api depending on term order + * - companies infos (address) : retrieve for materiau content type the companie info from the tode node + * */ function materio_search_api_entity_property_info_alter(&$info){ // dsm($info, 'hook_entity_property_info_alter | info'); // watchdog('materio solr', 'materio_search_api_entity_property_info_alter', array()); - $properties = &$info['node']['properties']; + $node_props = &$info['node']['properties']; for ($i=1; $i <= 5 ; $i++) { - $properties['materio_search_api_onthologie_term_'.$i.'_text'] = array( + $node_props['materio_search_api_onthologie_term_'.$i.'_text'] = array( 'type'=>'text', 'label'=> t('Main onthologie term '.$i. ' as text (+ synonyms)'), // 'query callback'=>'entity_metadata_table_query', @@ -151,28 +168,42 @@ function materio_search_api_entity_property_info_alter(&$info){ ); } - $properties['materio_search_api_onthologie_term_others_text'] = array( + $node_props['materio_search_api_onthologie_term_others_text'] = array( 'type'=>'list', 'label'=> t('Others onthologie terms as text (+ synonyms)'), // 'query callback'=>'entity_metadata_table_query', 'getter callback'=>'materio_search_api_get_taxonomy_terms_others_text', ); - $properties['materio_search_api_taglibres_text'] = array( + $node_props['materio_search_api_taglibres_text'] = array( 'type'=>'list', 'label'=> t('Tag libres terms as text (+ synonyms)'), // 'query callback'=>'entity_metadata_table_query', 'getter callback'=>'materio_search_api_get_taglibres_terms_text', ); - $company_term_props = &$info['taxonomy_term']['bundles']['company']['properties']; - $company_term_props['country'] = array( - 'label' => t("Country"), - 'description' => t("Company's Country get from tode node."), - 'type' => 'text', - 'getter callback' => 'company_term_property_country_get_props', + + $node_materiau_props = &$info['node']['bundles']['materiau']['properties']; + + $node_materiau_props['materio_search_api_node_propertie_companie'] = array( + 'type'=>'list', + 'label'=> t('Manufacturers and distributors companies localised (dont addresse)'), + // 'query callback'=>'entity_metadata_table_query', + 'getter callback'=>'materio_search_api_get_companies', ); + + + + $term_props = &$info['taxonomy_term']['properties']; + + $term_props['materio_search_api_term_property_dup_name'] = array( + 'label' => t("Term name field dup"), + 'description' => t("Duplicate the term name field to apply different filter in solr (remove accents for instance)"), + 'type' => 'text', + 'getter callback' => 'term_property_dup_name', + ); + } function materio_search_api_get_onthologie_term_1_text($item){ @@ -256,20 +287,35 @@ function materio_search_api_get_taxo_term_field_text($item, $field_name, $delta) return null; } +function materio_search_api_node_propertie_companie($item){ + // dsm($item, '$item'); + $lang = "fr";//$item->language; + + $languages = language_list(); + global $language; + $language = $languages[$lang]; -function company_term_property_country_get_props($term){ - // dsm($term, 'company_term_property_country_get_props : term'); - if( $node = company_get_tode_node($term) ){ - // $field_values = field_get_items('node',$node,'field_public_address'); - // dsm($field_values, 'field_values'); - - $output = rip_tags(render(field_view_field('node',$node,'field_public_address'))); - // dsm($output, 'output'); - - return $output; + $cies = array(); + $cie_fields = array("field_company_fab", "field_company_distrib"); + foreach ($cie_fields as $cie_field_name) { + $delta = 0; + while( isset($item->{$cie_field_name}['und'][$delta]) ){ + $tid = $item->{$cie_field_name}['und'][$delta]['tid']; + $cie_term = taxonomy_term_load($tid); + if($cie_node = company_get_tode_node($cie_term)){ + $cie_node->language = $lang; + $cie_view = node_view($cie_node, "full", $lang); + $cie_rendered = rip_tags(drupal_render($cie_view)); + // dsm($cie_rendered, 'cie_rendered'); + $cies[] = $cie_rendered; + } + $delta++; + } } - return null; + + return $cies; } + function company_get_tode_node($term){ if(module_exists('tode')) if( $entitys = tode_get_nids_from_term($term)) @@ -279,6 +325,7 @@ function company_get_tode_node($term){ return false; } + function rip_tags($string) { // ----- remove HTML TAGs ----- $string = preg_replace ('/<[^>]*>/', ' ', $string); @@ -303,6 +350,20 @@ function rip_tags($string) { return $string; } +function materio_search_api_term_property_dup_name($term){ + $lang = $term->language; + return $term->name_field[$lang][0]['value']; +} + + + + + +/** + * - - -- - - - - - - blocks - - - - - - - - - - - + * + */ + /** * Implements hook_block_info(). */ From 7b99c14d96b3e31281bf718f47a94c417326c8ea Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Fri, 21 Feb 2014 21:01:03 +0100 Subject: [PATCH 03/34] bug fixe --- materio_search_api.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/materio_search_api.module b/materio_search_api.module index 6908519c..9186e433 100755 --- a/materio_search_api.module +++ b/materio_search_api.module @@ -201,7 +201,7 @@ function materio_search_api_entity_property_info_alter(&$info){ 'label' => t("Term name field dup"), 'description' => t("Duplicate the term name field to apply different filter in solr (remove accents for instance)"), 'type' => 'text', - 'getter callback' => 'term_property_dup_name', + 'getter callback' => 'materio_search_api_term_property_dup_name', ); } From 094eb5069137706f822e4c7018b433c7c75ba654 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Fri, 21 Feb 2014 21:06:23 +0100 Subject: [PATCH 04/34] bug fixe --- materio_search_api.module | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/materio_search_api.module b/materio_search_api.module index 9186e433..739f4013 100755 --- a/materio_search_api.module +++ b/materio_search_api.module @@ -190,7 +190,7 @@ function materio_search_api_entity_property_info_alter(&$info){ 'type'=>'list', 'label'=> t('Manufacturers and distributors companies localised (dont addresse)'), // 'query callback'=>'entity_metadata_table_query', - 'getter callback'=>'materio_search_api_get_companies', + 'getter callback'=>'materio_search_api_get_node_propertie_companie', ); @@ -287,7 +287,7 @@ function materio_search_api_get_taxo_term_field_text($item, $field_name, $delta) return null; } -function materio_search_api_node_propertie_companie($item){ +function materio_search_api_get_node_propertie_companie($item){ // dsm($item, '$item'); $lang = "fr";//$item->language; From 100abc9a3af03544963da9483ac9f88321371962 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Fri, 28 Feb 2014 20:00:30 +0100 Subject: [PATCH 05/34] materio_search_api_ajax add optional viewmode paramater for ajax call materio_search_api_ajax_node --- materio_search_api_ajax.pages.inc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/materio_search_api_ajax.pages.inc b/materio_search_api_ajax.pages.inc index de3f0b4b..376ee648 100755 --- a/materio_search_api_ajax.pages.inc +++ b/materio_search_api_ajax.pages.inc @@ -222,11 +222,17 @@ function materio_search_api_ajax_actuality($page = 0){ function materio_search_api_ajax_node($nid){ global $user; - $viewmode = isset($user->data['materiosearchapi_viewmode']) ? $user->data['materiosearchapi_viewmode'] : variable_get('defaultviewmode', 'full'); + + $viewmode = isset($_GET['viewmode']) ? $_GET['viewmode'] : (isset($user->data['materiosearchapi_viewmode']) ? $user->data['materiosearchapi_viewmode'] : variable_get('defaultviewmode', 'full')); + + $rep = array( + "get" => $_GET, + "viewmode" => $viewmode + ); if($nodeview = node_view(node_load($nid),$viewmode)){ - $rep = array( - 'nid'=>$nid, + $rep = $rep+array( + 'nid' => $nid, 'node' => drupal_render($nodeview), ); drupal_json_output($rep); From 4d0605604f17955ac456c14a97131a3a4dd8f8d1 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Wed, 23 Apr 2014 16:49:49 +0200 Subject: [PATCH 06/34] Simplenews default body content ofr content daily materio html template through hook_form_alter --- materio_admin.module | 20 ++++ templates/simplenews_node_template.html | 143 ++++++++++++++++++++++++ 2 files changed, 163 insertions(+) create mode 100644 templates/simplenews_node_template.html diff --git a/materio_admin.module b/materio_admin.module index 8364ae3b..f88d4be7 100644 --- a/materio_admin.module +++ b/materio_admin.module @@ -36,3 +36,23 @@ function materio_admin_menu_alter(&$items){ # deactivate default home page $items['node']['access callback'] = FALSE; } + + + +/** + * Implements hook_form_alter(). + */ +function materio_admin_form_simplenews_node_form_alter(&$form, &$form_state, $form_id) { + // dsm($form_id, '$form_id'); + // dsm($form_state, '$form_state'); + // dsm($form, '$form'); + if(!$form['nid']['#value']){ + $form['body']['und'][0]['#default_value'] = materio_admin_getSimplenewsNodBodyTemplate(); + $form['body']['und'][0]['#rows'] = 50; + } + +} + +function materio_admin_getSimplenewsNodBodyTemplate(){ + return file_get_contents(drupal_get_path('module', 'materio_admin').'/templates/simplenews_node_template.html'); +} \ No newline at end of file diff --git a/templates/simplenews_node_template.html b/templates/simplenews_node_template.html new file mode 100644 index 00000000..73343527 --- /dev/null +++ b/templates/simplenews_node_template.html @@ -0,0 +1,143 @@ + + + + + + +
+ + + + + + + +
+ +
+ + + + + + + +
+ + + + + + +
+ + + + + + +
+

+ + + ZE DAILY MATERIO' + + +

+

+ + le titre en fr + +
+ Toute une série de matières recyclées sous vos pieds, car ces tapis sont tissés avec des chambres à air usagées, des papiers de bonbons minutieusement filés, de vieux journaux et magazines tressés ou d'autres matières recyclées surprenantes. Certains tapis de cette gamme peuvent même aller à l'extérieur. +

+
+   +
+

+ + + + The english title  + + + +
+ + + A wide range of beautiful carpets made out of surprising recycled materials: recycled candy wrappers, recycled tires and bike tubes, different recycled fibers and recycled newspaper! Some of them can even be used outside. + + +

+
+
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + + + + +
+ + Facebook + + + + Twitter + + + + Linkedin + + + + Pinterest + +
+
+
+
+
+
+
+ + + + + + +
+   +
+
\ No newline at end of file From d7dddd57646ec2897e70846a25d145db41afe372 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Wed, 23 Apr 2014 18:40:19 +0200 Subject: [PATCH 07/34] added template selection regarding simplenews categorie (trough url query) --- materio_admin.module | 29 ++++++++++++++++--- ...ml => simplenews_daily_node_template.html} | 0 templates/simplenews_news_node_template.html | 1 + 3 files changed, 26 insertions(+), 4 deletions(-) rename templates/{simplenews_node_template.html => simplenews_daily_node_template.html} (100%) create mode 100644 templates/simplenews_news_node_template.html diff --git a/materio_admin.module b/materio_admin.module index f88d4be7..db506aaa 100644 --- a/materio_admin.module +++ b/materio_admin.module @@ -46,13 +46,34 @@ function materio_admin_form_simplenews_node_form_alter(&$form, &$form_state, $fo // dsm($form_id, '$form_id'); // dsm($form_state, '$form_state'); // dsm($form, '$form'); + // dsm($_GET, 'GET'); + if(!$form['nid']['#value']){ - $form['body']['und'][0]['#default_value'] = materio_admin_getSimplenewsNodBodyTemplate(); - $form['body']['und'][0]['#rows'] = 50; + if(isset($_GET['cat'])){ + $cat = $_GET['cat']; + switch($cat){ + case 6374: + $template = 'daily'; + break; + case 6274: + $template = 'news'; + break; + } + + // prepopulate type of news + $form['field_simplenews_term']['und']['#default_value'] = $cat; + $form['field_simplenews_term']['und']['#disabled'] = true; + + // change default template regarding type of news + $form['body']['und'][0]['#default_value'] = materio_admin_getSimplenewsNodeBodyTemplate($template); + $form['body']['und'][0]['#rows'] = 50; + } + }else{ + $form['field_simplenews_term']['und']['#disabled'] = true; } } -function materio_admin_getSimplenewsNodBodyTemplate(){ - return file_get_contents(drupal_get_path('module', 'materio_admin').'/templates/simplenews_node_template.html'); +function materio_admin_getSimplenewsNodeBodyTemplate($template){ + return file_get_contents(drupal_get_path('module', 'materio_admin').'/templates/simplenews_'.$template.'_node_template.html'); } \ No newline at end of file diff --git a/templates/simplenews_node_template.html b/templates/simplenews_daily_node_template.html similarity index 100% rename from templates/simplenews_node_template.html rename to templates/simplenews_daily_node_template.html diff --git a/templates/simplenews_news_node_template.html b/templates/simplenews_news_node_template.html new file mode 100644 index 00000000..b731baec --- /dev/null +++ b/templates/simplenews_news_node_template.html @@ -0,0 +1 @@ +

TODO

\ No newline at end of file From 9d2fee4dddb69d1db8f47f5133a99f948facd398 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Fri, 25 Apr 2014 15:11:39 +0200 Subject: [PATCH 08/34] simplenews prepopulation improvement --- materio_admin.module | 72 ++++++--- ...emplate.html => simplenews_6274_node.html} | 0 ...emplate.html => simplenews_6374_node.html} | 0 templates/simplenews_6585_node.html | 143 ++++++++++++++++++ 4 files changed, 197 insertions(+), 18 deletions(-) rename templates/{simplenews_news_node_template.html => simplenews_6274_node.html} (100%) rename templates/{simplenews_daily_node_template.html => simplenews_6374_node.html} (100%) create mode 100644 templates/simplenews_6585_node.html diff --git a/materio_admin.module b/materio_admin.module index db506aaa..c0eabbee 100644 --- a/materio_admin.module +++ b/materio_admin.module @@ -1,4 +1,4 @@ - $name) { + // $items['node/%node/simplenews'] = array( + // 'title' => 'Newsletter', + // 'type' => MENU_LOCAL_TASK, + // 'access callback' => 'simplenews_node_tab_access', + // 'access arguments' => array(1), + // 'page callback' => 'simplenews_node_tab_page', + // 'page arguments' => array(1), + // 'context' => MENU_LOCAL_TASK, + // 'file' => 'includes/simplenews.admin.inc', + // 'weight' => 2, + // ); + $items['node/add/simplenews/'.$tid] = array( + 'title' => $name, + 'title callback' => 'check_plain', + 'page callback' => 'node_add', + 'page arguments' => array('simplenews'), + 'access callback' => 'node_access', + 'access arguments' => array('create', 'simplenews'), + // 'description' => $type->description, + 'file path' => drupal_get_path('module', 'node'), + 'file' => 'node.pages.inc', + 'options' => array('query'=>array('cat'=>$tid)) + ); + } + } + return $items; +} + /** * Implements hook_menu_alter(). */ @@ -27,18 +64,26 @@ function materio_admin_menu_alter(&$items){ $items['admin/people']['access arguments'] = array('access default users list'); // dsm($items['admin/people']); } - + if(isset($items['admin/people/expiration'])){ $items['admin/people/expiration']['access arguments'] = array('access default UC roles expiration list'); // dsm($items['admin/people/expiration']); } - + # deactivate default home page $items['node']['access callback'] = FALSE; + + // if(isset($items['admin/content/add/simplenews'])){ + // delete($items['admin/content/add/simplenews']); + // $cats = simplenews_category_list(); + // dsm($cats, 'cats'); + // foreach ($cats as $tid => $name) { + // $items['admin/content/add/simplenews/'.$tid] + // } + // } + } - - /** * Implements hook_form_alter(). */ @@ -51,29 +96,20 @@ function materio_admin_form_simplenews_node_form_alter(&$form, &$form_state, $fo if(!$form['nid']['#value']){ if(isset($_GET['cat'])){ $cat = $_GET['cat']; - switch($cat){ - case 6374: - $template = 'daily'; - break; - case 6274: - $template = 'news'; - break; - } // prepopulate type of news $form['field_simplenews_term']['und']['#default_value'] = $cat; $form['field_simplenews_term']['und']['#disabled'] = true; // change default template regarding type of news - $form['body']['und'][0]['#default_value'] = materio_admin_getSimplenewsNodeBodyTemplate($template); - $form['body']['und'][0]['#rows'] = 50; + $form['body']['und'][0]['#default_value'] = materio_admin_getSimplenewsNodeBodyTemplate($cat); + $form['body']['und'][0]['#rows'] = 50; } }else{ $form['field_simplenews_term']['und']['#disabled'] = true; } - } -function materio_admin_getSimplenewsNodeBodyTemplate($template){ - return file_get_contents(drupal_get_path('module', 'materio_admin').'/templates/simplenews_'.$template.'_node_template.html'); +function materio_admin_getSimplenewsNodeBodyTemplate($cat){ + return file_get_contents(drupal_get_path('module', 'materio_admin').'/templates/simplenews_'.$cat.'_node.html'); } \ No newline at end of file diff --git a/templates/simplenews_news_node_template.html b/templates/simplenews_6274_node.html similarity index 100% rename from templates/simplenews_news_node_template.html rename to templates/simplenews_6274_node.html diff --git a/templates/simplenews_daily_node_template.html b/templates/simplenews_6374_node.html similarity index 100% rename from templates/simplenews_daily_node_template.html rename to templates/simplenews_6374_node.html diff --git a/templates/simplenews_6585_node.html b/templates/simplenews_6585_node.html new file mode 100644 index 00000000..73343527 --- /dev/null +++ b/templates/simplenews_6585_node.html @@ -0,0 +1,143 @@ + + + + + + +
+ + + + + + + +
+ +
+ + + + + + + +
+ + + + + + +
+ + + + + + +
+

+ + + ZE DAILY MATERIO' + + +

+

+ + le titre en fr + +
+ Toute une série de matières recyclées sous vos pieds, car ces tapis sont tissés avec des chambres à air usagées, des papiers de bonbons minutieusement filés, de vieux journaux et magazines tressés ou d'autres matières recyclées surprenantes. Certains tapis de cette gamme peuvent même aller à l'extérieur. +

+
+   +
+

+ + + + The english title  + + + +
+ + + A wide range of beautiful carpets made out of surprising recycled materials: recycled candy wrappers, recycled tires and bike tubes, different recycled fibers and recycled newspaper! Some of them can even be used outside. + + +

+
+
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + + + + +
+ + Facebook + + + + Twitter + + + + Linkedin + + + + Pinterest + +
+
+
+
+
+
+
+ + + + + + +
+   +
+
\ No newline at end of file From f6d5c40ae2f91cffd7a0b8ca53196bbfa038107f Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Fri, 25 Apr 2014 15:15:52 +0200 Subject: [PATCH 09/34] removed dsm() --- materio_admin.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/materio_admin.module b/materio_admin.module index c0eabbee..86e28112 100644 --- a/materio_admin.module +++ b/materio_admin.module @@ -24,7 +24,7 @@ function materio_admin_menu() { if(module_exists('simplenews')){ $cats = simplenews_category_list(); - dsm($cats, 'cats'); + // dsm($cats, 'cats'); foreach ($cats as $tid => $name) { // $items['node/%node/simplenews'] = array( // 'title' => 'Newsletter', From 76efcb077820eb1e9dbf3e1be8c921e00a0f1291 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Fri, 25 Apr 2014 16:13:11 +0200 Subject: [PATCH 10/34] added simplenews local actions + change template selection from query to path --- materio_admin.module | 51 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/materio_admin.module b/materio_admin.module index 86e28112..d34b7888 100644 --- a/materio_admin.module +++ b/materio_admin.module @@ -44,10 +44,8 @@ function materio_admin_menu() { 'page arguments' => array('simplenews'), 'access callback' => 'node_access', 'access arguments' => array('create', 'simplenews'), - // 'description' => $type->description, 'file path' => drupal_get_path('module', 'node'), 'file' => 'node.pages.inc', - 'options' => array('query'=>array('cat'=>$tid)) ); } } @@ -81,7 +79,47 @@ function materio_admin_menu_alter(&$items){ // $items['admin/content/add/simplenews/'.$tid] // } // } +} +/** + * Implements hook_menu_local_tasks_alter(). + */ +function materio_admin_menu_local_tasks_alter(&$data, $router_item, $root_path) { + + if ($root_path == 'admin/people/simplenews') { + $item = menu_get_item('admin/content/simplenews'); + if ($item['access']) { + $item['title'] = 'Go to '.$item['title']; + $data['actions']['output'][] = array( + '#theme' => 'menu_local_task', + '#link' => $item, + ); + } + } + + if ($root_path == 'admin/content/simplenews') { + + $cats = simplenews_category_list(); + foreach ($cats as $tid => $name) { + $item = menu_get_item('node/add/simplenews/'.$tid); + $item['title'] = 'Create new '.$name; + if ($item['access']) { + $data['actions']['output'][] = array( + '#theme' => 'menu_local_task', + '#link' => $item, + ); + } + } + + $item = menu_get_item('admin/people/simplenews'); + if ($item['access']) { + $item['title'] = 'Go to '.$item['title']; + $data['actions']['output'][] = array( + '#theme' => 'menu_local_task', + '#link' => $item, + ); + } + } } /** @@ -94,9 +132,12 @@ function materio_admin_form_simplenews_node_form_alter(&$form, &$form_state, $fo // dsm($_GET, 'GET'); if(!$form['nid']['#value']){ - if(isset($_GET['cat'])){ - $cat = $_GET['cat']; - + $cats = simplenews_category_list(); + $cats_tids = array_keys($cats); + $q = parse_url($_GET['q']); + $cat = array_pop(explode('/', $q['path'])); + // dsm($cat, 'cat'); + if(in_array($cat, $cats_tids)){ // prepopulate type of news $form['field_simplenews_term']['und']['#default_value'] = $cat; $form['field_simplenews_term']['und']['#disabled'] = true; From 639433022628e525fcadf84744652436dc179247 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Fri, 25 Apr 2014 16:57:33 +0200 Subject: [PATCH 11/34] removed icons from body template added to footer template on materiobasetheme theme --- templates/simplenews_6374_node.html | 58 ----------------------------- 1 file changed, 58 deletions(-) diff --git a/templates/simplenews_6374_node.html b/templates/simplenews_6374_node.html index 73343527..e118e7c2 100644 --- a/templates/simplenews_6374_node.html +++ b/templates/simplenews_6374_node.html @@ -62,64 +62,6 @@ - - - - - - -
- - - - - - -
- - - - - - -
- - - - - - -
- - - - - - - - - -
- - Facebook - - - - Twitter - - - - Linkedin - - - - Pinterest - -
-
-
-
-
From a64d6e34d834ffb62d0dd0ddf20c25f507ed8e90 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Fri, 25 Apr 2014 17:12:19 +0200 Subject: [PATCH 12/34] upadted also test template --- templates/simplenews_6585_node.html | 58 ----------------------------- 1 file changed, 58 deletions(-) diff --git a/templates/simplenews_6585_node.html b/templates/simplenews_6585_node.html index 73343527..e118e7c2 100644 --- a/templates/simplenews_6585_node.html +++ b/templates/simplenews_6585_node.html @@ -62,64 +62,6 @@ - - - - - - -
- - - - - - -
- - - - - - -
- - - - - - -
- - - - - - - - - -
- - Facebook - - - - Twitter - - - - Linkedin - - - - Pinterest - -
-
-
-
-
From 332c17c25ce1e331d1156eadaad4875dc4556d5d Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Fri, 25 Apr 2014 17:25:48 +0200 Subject: [PATCH 13/34] change body field height systematicaly --- materio_admin.module | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/materio_admin.module b/materio_admin.module index d34b7888..8c0a1f56 100644 --- a/materio_admin.module +++ b/materio_admin.module @@ -144,11 +144,13 @@ function materio_admin_form_simplenews_node_form_alter(&$form, &$form_state, $fo // change default template regarding type of news $form['body']['und'][0]['#default_value'] = materio_admin_getSimplenewsNodeBodyTemplate($cat); - $form['body']['und'][0]['#rows'] = 50; } }else{ $form['field_simplenews_term']['und']['#disabled'] = true; } + + $form['body']['und'][0]['#rows'] = 50; + } function materio_admin_getSimplenewsNodeBodyTemplate($cat){ From 148e2db56e1d68a7ece84f996d82a3f66552d888 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Fri, 25 Apr 2014 18:42:37 +0200 Subject: [PATCH 14/34] updated templates --- templates/simplenews_6374_node.html | 108 +++++++++++----------------- templates/simplenews_6585_node.html | 28 -------- 2 files changed, 40 insertions(+), 96 deletions(-) diff --git a/templates/simplenews_6374_node.html b/templates/simplenews_6374_node.html index e118e7c2..0e662957 100644 --- a/templates/simplenews_6374_node.html +++ b/templates/simplenews_6374_node.html @@ -1,67 +1,48 @@ - + +
-
- - +
+ -
- -
- - + -
+ - @@ -70,16 +51,7 @@
- - - - - - -
- - - - - - -
-

- - - ZE DAILY MATERIO' - - -

-

- - le titre en fr - -
- Toute une série de matières recyclées sous vos pieds, car ces tapis sont tissés avec des chambres à air usagées, des papiers de bonbons minutieusement filés, de vieux journaux et magazines tressés ou d'autres matières recyclées surprenantes. Certains tapis de cette gamme peuvent même aller à l'extérieur. -

-
-   -
-

- - - - The english title  - - - -
- - - A wide range of beautiful carpets made out of surprising recycled materials: recycled candy wrappers, recycled tires and bike tubes, different recycled fibers and recycled newspaper! Some of them can even be used outside. - - -

-
-
+
+

+ + + ZE DAILY MATERIO' + + +

+

+ + le titre en fr + +
+ Toute une série de matières recyclées sous vos pieds, car ces tapis sont tissés avec des chambres à air usagées, des papiers de bonbons minutieusement filés, de vieux journaux et magazines tressés ou d'autres matières recyclées surprenantes. Certains tapis de cette gamme peuvent même aller à l'extérieur. +

+
+   +
+

+ + + + The english title  + + + +
+ + + A wide range of beautiful carpets made out of surprising recycled materials: recycled candy wrappers, recycled tires and bike tubes, different recycled fibers and recycled newspaper! Some of them can even be used outside. + + +

- - - - - - -
-   -
\ No newline at end of file +
diff --git a/templates/simplenews_6585_node.html b/templates/simplenews_6585_node.html index e118e7c2..d8c9dcaa 100644 --- a/templates/simplenews_6585_node.html +++ b/templates/simplenews_6585_node.html @@ -1,14 +1,3 @@ - - - - - - -
- - - - - - - -
- -
@@ -66,20 +55,3 @@
-
- - - - - - -
-   -
-
\ No newline at end of file From e371e746ff83d41272ab0604f0ee7aa3a402b54c Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Fri, 25 Apr 2014 18:46:28 +0200 Subject: [PATCH 15/34] updated simplenews templates --- templates/simplenews_6374_node.html | 1 - templates/simplenews_6585_node.html | 101 ++++++++++++++-------------- 2 files changed, 50 insertions(+), 52 deletions(-) diff --git a/templates/simplenews_6374_node.html b/templates/simplenews_6374_node.html index 0e662957..d002094e 100644 --- a/templates/simplenews_6374_node.html +++ b/templates/simplenews_6374_node.html @@ -1,4 +1,3 @@ - diff --git a/templates/simplenews_6585_node.html b/templates/simplenews_6585_node.html index d8c9dcaa..d002094e 100644 --- a/templates/simplenews_6585_node.html +++ b/templates/simplenews_6585_node.html @@ -1,57 +1,56 @@ - -
+
+ + + + + +
+ + + + + + +
+ -
- - - - - - -
- - - - - - -
-

- - - ZE DAILY MATERIO' - - -

-

- - le titre en fr - -
- Toute une série de matières recyclées sous vos pieds, car ces tapis sont tissés avec des chambres à air usagées, des papiers de bonbons minutieusement filés, de vieux journaux et magazines tressés ou d'autres matières recyclées surprenantes. Certains tapis de cette gamme peuvent même aller à l'extérieur. -

-
-   -
-

- - - - The english title  - - - -
- - - A wide range of beautiful carpets made out of surprising recycled materials: recycled candy wrappers, recycled tires and bike tubes, different recycled fibers and recycled newspaper! Some of them can even be used outside. - - -

-
-
+
+

+ + + ZE DAILY MATERIO' + + +

+

+ + le titre en fr + +
+ Toute une série de matières recyclées sous vos pieds, car ces tapis sont tissés avec des chambres à air usagées, des papiers de bonbons minutieusement filés, de vieux journaux et magazines tressés ou d'autres matières recyclées surprenantes. Certains tapis de cette gamme peuvent même aller à l'extérieur. +

+
+   +
+

+ + + + The english title  + + + +
+ + + A wide range of beautiful carpets made out of surprising recycled materials: recycled candy wrappers, recycled tires and bike tubes, different recycled fibers and recycled newspaper! Some of them can even be used outside. + + +

+
+
From a613426482e1c5281183a03ce1063642ddc1d228 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Fri, 25 Apr 2014 18:48:28 +0200 Subject: [PATCH 16/34] updated simplenews templates --- templates/simplenews_6374_node.html | 2 ++ templates/simplenews_6585_node.html | 2 ++ 2 files changed, 4 insertions(+) diff --git a/templates/simplenews_6374_node.html b/templates/simplenews_6374_node.html index d002094e..25c398ea 100644 --- a/templates/simplenews_6374_node.html +++ b/templates/simplenews_6374_node.html @@ -1,3 +1,5 @@ + +
diff --git a/templates/simplenews_6585_node.html b/templates/simplenews_6585_node.html index d002094e..25c398ea 100644 --- a/templates/simplenews_6585_node.html +++ b/templates/simplenews_6585_node.html @@ -1,3 +1,5 @@ + +
From 5b7b67573f5ac4a886736fabf3b50d6ca2ed1bc3 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Fri, 25 Apr 2014 18:54:36 +0200 Subject: [PATCH 17/34] updated simplenews templates --- templates/simplenews_6374_node.html | 11 +++++++++-- templates/simplenews_6585_node.html | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/templates/simplenews_6374_node.html b/templates/simplenews_6374_node.html index 25c398ea..5f4f31a3 100644 --- a/templates/simplenews_6374_node.html +++ b/templates/simplenews_6374_node.html @@ -1,5 +1,12 @@ - -
+
+ + + + + +
+ +
diff --git a/templates/simplenews_6585_node.html b/templates/simplenews_6585_node.html index 25c398ea..5f4f31a3 100644 --- a/templates/simplenews_6585_node.html +++ b/templates/simplenews_6585_node.html @@ -1,5 +1,12 @@ - -
+
+ + + + + +
+ +
From 40fe76b2cfff143cc316ca1791779ae634a3bfee Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Mon, 28 Apr 2014 11:19:49 +0200 Subject: [PATCH 18/34] improved mail templates (wysiwyg filter) --- materio_admin.module | 2 +- templates/simplenews_6374_node.html | 26 +++++++++++++------------- templates/simplenews_6585_node.html | 26 +++++++++++++------------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/materio_admin.module b/materio_admin.module index 8c0a1f56..1035855c 100644 --- a/materio_admin.module +++ b/materio_admin.module @@ -102,7 +102,7 @@ function materio_admin_menu_local_tasks_alter(&$data, $router_item, $root_path) $cats = simplenews_category_list(); foreach ($cats as $tid => $name) { $item = menu_get_item('node/add/simplenews/'.$tid); - $item['title'] = 'Create new '.$name; + $item['title'] = 'Add new '.$name; if ($item['access']) { $data['actions']['output'][] = array( '#theme' => 'menu_local_task', diff --git a/templates/simplenews_6374_node.html b/templates/simplenews_6374_node.html index 5f4f31a3..8be1cd1d 100644 --- a/templates/simplenews_6374_node.html +++ b/templates/simplenews_6374_node.html @@ -1,24 +1,24 @@
- - - -
- -
- - - -
- +
+ + + + + + +
+ +
+
- +
-
+

diff --git a/templates/simplenews_6585_node.html b/templates/simplenews_6585_node.html index 5f4f31a3..8be1cd1d 100644 --- a/templates/simplenews_6585_node.html +++ b/templates/simplenews_6585_node.html @@ -1,24 +1,24 @@ - - - -
- -
- - - -
- +
+ + + + + + +
+ +
+
- +
-
+

From df548917f6b91ce8e4f45c896902aded57f57579 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Mon, 28 Apr 2014 11:42:36 +0200 Subject: [PATCH 19/34] improved mail templates --- templates/simplenews_6374_node.html | 2 +- templates/simplenews_6585_node.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/simplenews_6374_node.html b/templates/simplenews_6374_node.html index 8be1cd1d..b66feb88 100644 --- a/templates/simplenews_6374_node.html +++ b/templates/simplenews_6374_node.html @@ -1,7 +1,7 @@ -
+ diff --git a/templates/simplenews_6585_node.html b/templates/simplenews_6585_node.html index 8be1cd1d..b66feb88 100644 --- a/templates/simplenews_6585_node.html +++ b/templates/simplenews_6585_node.html @@ -1,7 +1,7 @@
-
+ From c8a37f425577e67708d5e84e133aceccacd1d50f Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Mon, 28 Apr 2014 16:29:17 +0200 Subject: [PATCH 20/34] Trailing slash + bug fixe http://studio.g-u-i.net/fr/materio/node/1368 --- js/materio_flag.js | 85 ++++---- js/materio_flag.min.js | 455 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 454 insertions(+), 86 deletions(-) diff --git a/js/materio_flag.js b/js/materio_flag.js index 5782179e..896d2f3e 100755 --- a/js/materio_flag.js +++ b/js/materio_flag.js @@ -17,7 +17,7 @@ MaterioFlag = function(){ $(document) .bind('flagGlobalAfterLinkUpdate', onFlaging) - .bind('resultscompleted resultschanged', onResultsUpdated) + .bind('resultscompleted resultschanged previewloaded', onResultsUpdated) .bind('init-scroller-pager', onInitScrollerPager) .bind('load-scroller-pager', onLoadScrollerPager) .bind('view-mode-changed', onViewModeChanged) @@ -87,14 +87,14 @@ MaterioFlag = function(){ .bind('click', onClickCreatLink) .addClass('ajax-processed'); - + // preview block $('section.flag-list:not(.ajax-processed)', '#block-materio-flag-materio-flag-mylists').each(function(index){ var name = $(this).attr('class').match(/flag_lists_[^_]+_[0-9]+/); $('').appendTo($('h2.listname', this)).attr('name', name).bind('click', onClickClosePreview); $('a.open-list', this).bind('click', onClickOpenLink); - + }).addClass('ajax-processed'); break; } @@ -106,7 +106,7 @@ MaterioFlag = function(){ type : 'my'+type+'-block-builded', block : block, name : name - }); + }); },10); // trace('MaterioFlag :: activename', activename); @@ -115,7 +115,7 @@ MaterioFlag = function(){ // trace('MaterioFlag :: activename', activename); if(activename) - showPreview(activename, block); + showPreview(activename, block); }; function refreshBlocks(name){ @@ -125,17 +125,17 @@ MaterioFlag = function(){ }else if($('#block-materio-flag-materio-flag-mylists').length){ var type = 'lists'; } - + if(type != undefined){ var id = '#block-materio-flag-materio-flag-my'+type; var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/refresh/block/'+type; $.getJSON(url, function(json){ //trace('MaterioFlag :: block refreshed '+type, json); - + $(id).replaceWith(json.block); $('#block-materio-flag-materio-flag-mylists-nav').replaceWith(json.block_nav); - - buildBlocks(name); + + buildBlocks(name); $.event.trigger({ type : 'my'+type+'-block-updated', @@ -150,7 +150,7 @@ MaterioFlag = function(){ //trace('MaterioFlag :: ajaxifyLinks', container); container = ((container != null) ? container : 'body'); - + // trace('MaterioFlag :: typeof Drupal.flagLink', typeof Drupal.flagLink); if (typeof Drupal.flagLink != 'undefined') Drupal.flagLink(container); @@ -161,12 +161,11 @@ MaterioFlag = function(){ .bind('click', onUnflagList) .addClass('ajax-processed'); } - + $('a.flag-lists-create:not(.ajax-processed)', container) .bind('click', onClickCreatLink) .addClass('ajax-processed'); - }; /** @@ -191,9 +190,9 @@ MaterioFlag = function(){ //trace('MaterioFlag :: onClickClosePreview', event); eraseCookie('materiomyflaglistsopened'); if($(this).attr('name') == 'bookmarks'){ - $(this).parents('.block').find('section.bookmarks').removeClass('active'); + $(this).parents('.block').find('section.bookmarks').removeClass('active'); }else{ - $(this).parents('section.flag-list').removeClass('active'); + $(this).parents('section.flag-list').removeClass('active'); } $.event.trigger('init-layout'); @@ -214,7 +213,7 @@ MaterioFlag = function(){ function loadList(fid){ //trace('MaterioFlag :: loadList | fid', fid); var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/ajax/list/'+fid; - + $.event.trigger('loading-content'); $.getJSON(url, {'current_path':document.location.href},function(json){ @@ -231,14 +230,14 @@ MaterioFlag = function(){ if(json.rendered){ $('.inner-content','#content').html(json.rendered); - + $.event.trigger('loaded-content'); - + // no need of ajaxifylinks because it's triggered with resultschanged // ajaxifyLinks('#content'); var path = Drupal.settings.basePath + Drupal.settings.pathPrefix + json.path; - + $.event.trigger({ type : 'new-history-page', path : path, @@ -246,10 +245,10 @@ MaterioFlag = function(){ content : json.rendered }); - // TODO: change language links for folders + // TODO: change language links for folders // for (language in Drupal.settings.materio_search_api_ajax.languages) { // var l = Drupal.settings.materio_search_api_ajax.languages[language]; - // $('#block-locale-language li.'+language+' a').attr('href', Drupal.settings.basePath + l.prefix+'/' + json.search_path + '/' + json.keys) + // $('#block-locale-language li.'+language+' a').attr('href', Drupal.settings.basePath + l.prefix+'/' + json.search_path + '/' + json.keys) // }; triggerContentChanged(); @@ -308,7 +307,7 @@ MaterioFlag = function(){ case 'cancel': //trace('MaterioFlag :: cancel',event); $(this).parents('#modal').remove(); - + // google analytics $.event.trigger({ type:"record-stat", @@ -333,11 +332,11 @@ MaterioFlag = function(){ createList($modal, type, title, $link); break; } - + return false; }) .parents('form').find('input[type="text"]').focus(); - // TODO: esc keypressed close the form + // TODO: esc keypressed close the form }; function createList($modal, type, title, $link){ @@ -365,7 +364,7 @@ MaterioFlag = function(){ } }); }; - + function flagEntityWithList(name, nid, token){ //trace('MaterioFlag :: flagEntityWithList | name', name); // var ret; @@ -378,7 +377,7 @@ MaterioFlag = function(){ success: function (data2) { //trace('MaterioFlag :: node taged with newly created list : data2', data2) if (data2.status) { - + // google analytics $.event.trigger({ type : "record-stat", @@ -410,7 +409,7 @@ MaterioFlag = function(){ nids.push($(this).attr('class').match(/node-([0-9]+)/)[1]); }); // trace('MaterioFlag :: nids', nids); - + var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/nodelinks'; $.getJSON(url, {nids:nids.join(";")}, function(data) { // trace('MaterioFlag :: data', data); @@ -421,14 +420,14 @@ MaterioFlag = function(){ // trace('MaterioFlag :: typeof Drupal.flagLink', typeof Drupal.flagLink); // if (typeof Drupal.flagLink != 'undefined') - // Drupal.flagLink($('.node-'+nid+' .flag-lists-entity-links')); - + // Drupal.flagLink($('.node-'+nid+' .flag-lists-entity-links')); + // TODO: sortir ajaxifyLinks de la boucle, je pense que ça prend trop de ressources ajaxifyLinks('.node-'+nid+' .flag-lists-entity-links'); } }); - + $.event.trigger({ type : 'materioflag-nodelinks-updated', nids : nids @@ -440,12 +439,12 @@ MaterioFlag = function(){ */ function onCLickEditList(event){ //trace('MaterioFlag :: onCLickEditList | event', event); - // TODO: empécher le double formulaire + // TODO: empécher le double formulaire event.preventDefault(); var $link = $(event.currentTarget); var lid = $link.attr('href').match(/[^\/]*$/); var type = 'materiau'; // this is cheap - + var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/editlistform/'+type+'/'+lid[0]; $.getJSON(url, function(json){ @@ -485,14 +484,14 @@ MaterioFlag = function(){ case 'cancel': //trace('MaterioFlag :: cancel',event); $(this).parents('#modal').remove(); - + // google analytics - var action = 'cancel edit form'; + var action = 'cancel edit form'; break; case 'save': //trace('MaterioFlag :: create',event); - + // google analytics var action = "submit edit form"; @@ -503,14 +502,14 @@ MaterioFlag = function(){ if(confirm('Do you realy want to delete your '+title+' folder ?')){ var action = "submit delete form"; - deleteList($modal, fid); + deleteList($modal, fid); }else{ var action = "cancel delete form"; } - + break; } - + // google analytics $.event.trigger({ type:"record-stat", @@ -521,7 +520,7 @@ MaterioFlag = function(){ return false; }) .parents('form').find('input[type="text"]').focus(); - // TODO: esc keypressed close the form + // TODO: esc keypressed close the form }; function saveList($modal, fid, name, title){ @@ -538,7 +537,7 @@ MaterioFlag = function(){ } else { //trace('MaterioFlag :: saved list : data', data); - + $.event.trigger({ type : 'list-edited', name : data.listname, @@ -627,7 +626,7 @@ MaterioFlag = function(){ var $newcontent = $(json.rendered), $newitems = $(container_class, $newcontent).children('article').addClass('just-added'), $newpager = $('ul.pager', $newcontent); - + $(container_class, '#content').append($newitems); $('ul.pager', '#content').replaceWith($newpager.hide()); @@ -672,8 +671,8 @@ MaterioFlag = function(){ }; - /** - * cookies + /** + * cookies */ function createCookie(name,value,days) { if (days) { @@ -709,5 +708,5 @@ MaterioFlag = function(){ $(document).ready(function() { var materioflag = new MaterioFlag(); }); - + })(jQuery); \ No newline at end of file diff --git a/js/materio_flag.min.js b/js/materio_flag.min.js index 5782179e..8f7efde4 100644 --- a/js/materio_flag.min.js +++ b/js/materio_flag.min.js @@ -1,3 +1,373 @@ +// * date 2011/10/19 * + +/** +* misc +*/ + +// ------ TRACE ------ + +function trace(s,o){ + if(window.console && window.console.debug){ + arguments.length === 2 ? window.console.debug(s,o) : window.console.debug(s); + }else if(console && console.log){ + arguments.length === 2 ? console.log(s,o) : console.log(s); + } +}; + +// ------ LOADJSCSSFILE ------ + +function loadjscssfile(filename, filetype){ + if (filetype=="js"){ //if filename is a external JavaScript file + var fileref=document.createElement('script') + fileref.setAttribute("type","text/javascript") + fileref.setAttribute("src", filename) + } + else if (filetype=="css"){ //if filename is an external CSS file + var fileref=document.createElement("link") + fileref.setAttribute("rel", "stylesheet") + fileref.setAttribute("type", "text/css") + fileref.setAttribute("href", filename) + } + if (typeof fileref!="undefined") + document.getElementsByTagName("head")[0].appendChild(fileref) +}; + +// ------ TIMEOUT + +function Timeout(fn, interval) { + var id = setTimeout(fn, interval); + this.cleared = false; + this.clear = function () { + this.cleared = true; + clearTimeout(id); + }; +} + +// ------ HEXTORGB convert hex to rgb color ------ + +function HexToRGB(h){ + if(h.charAt(0)=="#"){ + var coul = h.substring(1,7); + var r = parseInt(coul.substring(0,2),16); + var g = parseInt(coul.substring(2,4),16); + var b = parseInt(coul.substring(4,6),16); + return 'rgb('+r+', '+g+', '+b+')'; + }else{ + return null; + } +} + +// ------ PAIR check if number is pair of impair ------ + +function pair(n){return typeof n=='number'?(n%2==0?true:false):null;} + +// ------ RANDOM ------ + +function random(n1,n2){ + return arguments.length === 1 && typeof n1 === 'number'? Math.random()*n1 : ( arguments.length === 2 && typeof n1 === typeof n2 && typeof n1 === 'number' ? n1 + Math.random()*(n2-n1) : NaN ); +} +function randomInt(n1,n2){ + var rand = arguments.length === 1 && typeof n1 === 'number'? Math.random()*n1 : ( arguments.length === 2 && typeof n1 === typeof n2 && typeof n1 === 'number' ? n1 + Math.random()*(n2-n1) : NaN ); + return parseInt(rand); +} + +// ------ ROUNDED ------ + +function round(n,granularity){ + if(arguments.length == 1){ + n = Math.round(n); + }else{ + granularity = granularity.toString(); + granularity = granularity.replace(/./gi, 0); + granularity = granularity.replace(/^./gi, 1); + granularity = parseInt(granularity); + n = Math.round(n*granularity)/granularity; + } + return n; +} + +// ------ FLOOR ------ + +function floor(n,granularity){ + if(arguments.length == 1){ + n = Math.floor(n); + }else{ + granularity = granularity.toString(); + granularity = granularity.replace(/./gi, 0); + granularity = granularity.replace(/^./gi, 1); + granularity = parseInt(granularity); + n = Math.floor(n*granularity)/granularity; + } + return n; +} + +// ------ CEIL ------ + +function ceil(n,granularity){ + if(arguments.length == 1){ + n = Math.ceil(n); + }else{ + granularity = granularity.toString(); + granularity = granularity.replace(/./gi, 0); + granularity = granularity.replace(/^./gi, 1); + granularity = parseInt(granularity); + n = Math.ceil(n*granularity)/granularity; + } + return n; +} + +/** +* String +*/ + +// ------ TRIM remove multiple, leading or trailing spaces ------ + +String.prototype.trim = function() { + return this.replace(/(^\s*)|(\s*$)/gi,"").replace(/[ ]{2,}/gi," ").replace(/\n /,"\n"); +} + +// ------ remove all accents, for sort() by example ------ + +var Latinise={};Latinise.latin_map={"Á":"A","Ă":"A","Ắ":"A","Ặ":"A","Ằ":"A","Ẳ":"A","Ẵ":"A","Ǎ":"A","Â":"A","Ấ":"A","Ậ":"A","Ầ":"A","Ẩ":"A","Ẫ":"A","Ä":"A","Ǟ":"A","Ȧ":"A","Ǡ":"A","Ạ":"A","Ȁ":"A","À":"A","Ả":"A","Ȃ":"A","Ā":"A","Ą":"A","Å":"A","Ǻ":"A","Ḁ":"A","Ⱥ":"A","Ã":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ǣ":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ḃ":"B","Ḅ":"B","Ɓ":"B","Ḇ":"B","Ƀ":"B","Ƃ":"B","Ć":"C","Č":"C","Ç":"C","Ḉ":"C","Ĉ":"C","Ċ":"C","Ƈ":"C","Ȼ":"C","Ď":"D","Ḑ":"D","Ḓ":"D","Ḋ":"D","Ḍ":"D","Ɗ":"D","Ḏ":"D","Dz":"D","Dž":"D","Đ":"D","Ƌ":"D","DZ":"DZ","DŽ":"DZ","É":"E","Ĕ":"E","Ě":"E","Ȩ":"E","Ḝ":"E","Ê":"E","Ế":"E","Ệ":"E","Ề":"E","Ể":"E","Ễ":"E","Ḙ":"E","Ë":"E","Ė":"E","Ẹ":"E","Ȅ":"E","È":"E","Ẻ":"E","Ȇ":"E","Ē":"E","Ḗ":"E","Ḕ":"E","Ę":"E","Ɇ":"E","Ẽ":"E","Ḛ":"E","Ꝫ":"ET","Ḟ":"F","Ƒ":"F","Ǵ":"G","Ğ":"G","Ǧ":"G","Ģ":"G","Ĝ":"G","Ġ":"G","Ɠ":"G","Ḡ":"G","Ǥ":"G","Ḫ":"H","Ȟ":"H","Ḩ":"H","Ĥ":"H","Ⱨ":"H","Ḧ":"H","Ḣ":"H","Ḥ":"H","Ħ":"H","Í":"I","Ĭ":"I","Ǐ":"I","Î":"I","Ï":"I","Ḯ":"I","İ":"I","Ị":"I","Ȉ":"I","Ì":"I","Ỉ":"I","Ȋ":"I","Ī":"I","Į":"I","Ɨ":"I","Ĩ":"I","Ḭ":"I","Ꝺ":"D","Ꝼ":"F","Ᵹ":"G","Ꞃ":"R","Ꞅ":"S","Ꞇ":"T","Ꝭ":"IS","Ĵ":"J","Ɉ":"J","Ḱ":"K","Ǩ":"K","Ķ":"K","Ⱪ":"K","Ꝃ":"K","Ḳ":"K","Ƙ":"K","Ḵ":"K","Ꝁ":"K","Ꝅ":"K","Ĺ":"L","Ƚ":"L","Ľ":"L","Ļ":"L","Ḽ":"L","Ḷ":"L","Ḹ":"L","Ⱡ":"L","Ꝉ":"L","Ḻ":"L","Ŀ":"L","Ɫ":"L","Lj":"L","Ł":"L","LJ":"LJ","Ḿ":"M","Ṁ":"M","Ṃ":"M","Ɱ":"M","Ń":"N","Ň":"N","Ņ":"N","Ṋ":"N","Ṅ":"N","Ṇ":"N","Ǹ":"N","Ɲ":"N","Ṉ":"N","Ƞ":"N","Nj":"N","Ñ":"N","NJ":"NJ","Ó":"O","Ŏ":"O","Ǒ":"O","Ô":"O","Ố":"O","Ộ":"O","Ồ":"O","Ổ":"O","Ỗ":"O","Ö":"O","Ȫ":"O","Ȯ":"O","Ȱ":"O","Ọ":"O","Ő":"O","Ȍ":"O","Ò":"O","Ỏ":"O","Ơ":"O","Ớ":"O","Ợ":"O","Ờ":"O","Ở":"O","Ỡ":"O","Ȏ":"O","Ꝋ":"O","Ꝍ":"O","Ō":"O","Ṓ":"O","Ṑ":"O","Ɵ":"O","Ǫ":"O","Ǭ":"O","Ø":"O","Ǿ":"O","Õ":"O","Ṍ":"O","Ṏ":"O","Ȭ":"O","Ƣ":"OI","Ꝏ":"OO","Ɛ":"E","Ɔ":"O","Ȣ":"OU","Ṕ":"P","Ṗ":"P","Ꝓ":"P","Ƥ":"P","Ꝕ":"P","Ᵽ":"P","Ꝑ":"P","Ꝙ":"Q","Ꝗ":"Q","Ŕ":"R","Ř":"R","Ŗ":"R","Ṙ":"R","Ṛ":"R","Ṝ":"R","Ȑ":"R","Ȓ":"R","Ṟ":"R","Ɍ":"R","Ɽ":"R","Ꜿ":"C","Ǝ":"E","Ś":"S","Ṥ":"S","Š":"S","Ṧ":"S","Ş":"S","Ŝ":"S","Ș":"S","Ṡ":"S","Ṣ":"S","Ṩ":"S","Ť":"T","Ţ":"T","Ṱ":"T","Ț":"T","Ⱦ":"T","Ṫ":"T","Ṭ":"T","Ƭ":"T","Ṯ":"T","Ʈ":"T","Ŧ":"T","Ɐ":"A","Ꞁ":"L","Ɯ":"M","Ʌ":"V","Ꜩ":"TZ","Ú":"U","Ŭ":"U","Ǔ":"U","Û":"U","Ṷ":"U","Ü":"U","Ǘ":"U","Ǚ":"U","Ǜ":"U","Ǖ":"U","Ṳ":"U","Ụ":"U","Ű":"U","Ȕ":"U","Ù":"U","Ủ":"U","Ư":"U","Ứ":"U","Ự":"U","Ừ":"U","Ử":"U","Ữ":"U","Ȗ":"U","Ū":"U","Ṻ":"U","Ų":"U","Ů":"U","Ũ":"U","Ṹ":"U","Ṵ":"U","Ꝟ":"V","Ṿ":"V","Ʋ":"V","Ṽ":"V","Ꝡ":"VY","Ẃ":"W","Ŵ":"W","Ẅ":"W","Ẇ":"W","Ẉ":"W","Ẁ":"W","Ⱳ":"W","Ẍ":"X","Ẋ":"X","Ý":"Y","Ŷ":"Y","Ÿ":"Y","Ẏ":"Y","Ỵ":"Y","Ỳ":"Y","Ƴ":"Y","Ỷ":"Y","Ỿ":"Y","Ȳ":"Y","Ɏ":"Y","Ỹ":"Y","Ź":"Z","Ž":"Z","Ẑ":"Z","Ⱬ":"Z","Ż":"Z","Ẓ":"Z","Ȥ":"Z","Ẕ":"Z","Ƶ":"Z","IJ":"IJ","Œ":"OE","ᴀ":"A","ᴁ":"AE","ʙ":"B","ᴃ":"B","ᴄ":"C","ᴅ":"D","ᴇ":"E","ꜰ":"F","ɢ":"G","ʛ":"G","ʜ":"H","ɪ":"I","ʁ":"R","ᴊ":"J","ᴋ":"K","ʟ":"L","ᴌ":"L","ᴍ":"M","ɴ":"N","ᴏ":"O","ɶ":"OE","ᴐ":"O","ᴕ":"OU","ᴘ":"P","ʀ":"R","ᴎ":"N","ᴙ":"R","ꜱ":"S","ᴛ":"T","ⱻ":"E","ᴚ":"R","ᴜ":"U","ᴠ":"V","ᴡ":"W","ʏ":"Y","ᴢ":"Z","á":"a","ă":"a","ắ":"a","ặ":"a","ằ":"a","ẳ":"a","ẵ":"a","ǎ":"a","â":"a","ấ":"a","ậ":"a","ầ":"a","ẩ":"a","ẫ":"a","ä":"a","ǟ":"a","ȧ":"a","ǡ":"a","ạ":"a","ȁ":"a","à":"a","ả":"a","ȃ":"a","ā":"a","ą":"a","ᶏ":"a","ẚ":"a","å":"a","ǻ":"a","ḁ":"a","ⱥ":"a","ã":"a","ꜳ":"aa","æ":"ae","ǽ":"ae","ǣ":"ae","ꜵ":"ao","ꜷ":"au","ꜹ":"av","ꜻ":"av","ꜽ":"ay","ḃ":"b","ḅ":"b","ɓ":"b","ḇ":"b","ᵬ":"b","ᶀ":"b","ƀ":"b","ƃ":"b","ɵ":"o","ć":"c","č":"c","ç":"c","ḉ":"c","ĉ":"c","ɕ":"c","ċ":"c","ƈ":"c","ȼ":"c","ď":"d","ḑ":"d","ḓ":"d","ȡ":"d","ḋ":"d","ḍ":"d","ɗ":"d","ᶑ":"d","ḏ":"d","ᵭ":"d","ᶁ":"d","đ":"d","ɖ":"d","ƌ":"d","ı":"i","ȷ":"j","ɟ":"j","ʄ":"j","dz":"dz","dž":"dz","é":"e","ĕ":"e","ě":"e","ȩ":"e","ḝ":"e","ê":"e","ế":"e","ệ":"e","ề":"e","ể":"e","ễ":"e","ḙ":"e","ë":"e","ė":"e","ẹ":"e","ȅ":"e","è":"e","ẻ":"e","ȇ":"e","ē":"e","ḗ":"e","ḕ":"e","ⱸ":"e","ę":"e","ᶒ":"e","ɇ":"e","ẽ":"e","ḛ":"e","ꝫ":"et","ḟ":"f","ƒ":"f","ᵮ":"f","ᶂ":"f","ǵ":"g","ğ":"g","ǧ":"g","ģ":"g","ĝ":"g","ġ":"g","ɠ":"g","ḡ":"g","ᶃ":"g","ǥ":"g","ḫ":"h","ȟ":"h","ḩ":"h","ĥ":"h","ⱨ":"h","ḧ":"h","ḣ":"h","ḥ":"h","ɦ":"h","ẖ":"h","ħ":"h","ƕ":"hv","í":"i","ĭ":"i","ǐ":"i","î":"i","ï":"i","ḯ":"i","ị":"i","ȉ":"i","ì":"i","ỉ":"i","ȋ":"i","ī":"i","į":"i","ᶖ":"i","ɨ":"i","ĩ":"i","ḭ":"i","ꝺ":"d","ꝼ":"f","ᵹ":"g","ꞃ":"r","ꞅ":"s","ꞇ":"t","ꝭ":"is","ǰ":"j","ĵ":"j","ʝ":"j","ɉ":"j","ḱ":"k","ǩ":"k","ķ":"k","ⱪ":"k","ꝃ":"k","ḳ":"k","ƙ":"k","ḵ":"k","ᶄ":"k","ꝁ":"k","ꝅ":"k","ĺ":"l","ƚ":"l","ɬ":"l","ľ":"l","ļ":"l","ḽ":"l","ȴ":"l","ḷ":"l","ḹ":"l","ⱡ":"l","ꝉ":"l","ḻ":"l","ŀ":"l","ɫ":"l","ᶅ":"l","ɭ":"l","ł":"l","lj":"lj","ſ":"s","ẜ":"s","ẛ":"s","ẝ":"s","ḿ":"m","ṁ":"m","ṃ":"m","ɱ":"m","ᵯ":"m","ᶆ":"m","ń":"n","ň":"n","ņ":"n","ṋ":"n","ȵ":"n","ṅ":"n","ṇ":"n","ǹ":"n","ɲ":"n","ṉ":"n","ƞ":"n","ᵰ":"n","ᶇ":"n","ɳ":"n","ñ":"n","nj":"nj","ó":"o","ŏ":"o","ǒ":"o","ô":"o","ố":"o","ộ":"o","ồ":"o","ổ":"o","ỗ":"o","ö":"o","ȫ":"o","ȯ":"o","ȱ":"o","ọ":"o","ő":"o","ȍ":"o","ò":"o","ỏ":"o","ơ":"o","ớ":"o","ợ":"o","ờ":"o","ở":"o","ỡ":"o","ȏ":"o","ꝋ":"o","ꝍ":"o","ⱺ":"o","ō":"o","ṓ":"o","ṑ":"o","ǫ":"o","ǭ":"o","ø":"o","ǿ":"o","õ":"o","ṍ":"o","ṏ":"o","ȭ":"o","ƣ":"oi","ꝏ":"oo","ɛ":"e","ᶓ":"e","ɔ":"o","ᶗ":"o","ȣ":"ou","ṕ":"p","ṗ":"p","ꝓ":"p","ƥ":"p","ᵱ":"p","ᶈ":"p","ꝕ":"p","ᵽ":"p","ꝑ":"p","ꝙ":"q","ʠ":"q","ɋ":"q","ꝗ":"q","ŕ":"r","ř":"r","ŗ":"r","ṙ":"r","ṛ":"r","ṝ":"r","ȑ":"r","ɾ":"r","ᵳ":"r","ȓ":"r","ṟ":"r","ɼ":"r","ᵲ":"r","ᶉ":"r","ɍ":"r","ɽ":"r","ↄ":"c","ꜿ":"c","ɘ":"e","ɿ":"r","ś":"s","ṥ":"s","š":"s","ṧ":"s","ş":"s","ŝ":"s","ș":"s","ṡ":"s","ṣ":"s","ṩ":"s","ʂ":"s","ᵴ":"s","ᶊ":"s","ȿ":"s","ɡ":"g","ᴑ":"o","ᴓ":"o","ᴝ":"u","ť":"t","ţ":"t","ṱ":"t","ț":"t","ȶ":"t","ẗ":"t","ⱦ":"t","ṫ":"t","ṭ":"t","ƭ":"t","ṯ":"t","ᵵ":"t","ƫ":"t","ʈ":"t","ŧ":"t","ᵺ":"th","ɐ":"a","ᴂ":"ae","ǝ":"e","ᵷ":"g","ɥ":"h","ʮ":"h","ʯ":"h","ᴉ":"i","ʞ":"k","ꞁ":"l","ɯ":"m","ɰ":"m","ᴔ":"oe","ɹ":"r","ɻ":"r","ɺ":"r","ⱹ":"r","ʇ":"t","ʌ":"v","ʍ":"w","ʎ":"y","ꜩ":"tz","ú":"u","ŭ":"u","ǔ":"u","û":"u","ṷ":"u","ü":"u","ǘ":"u","ǚ":"u","ǜ":"u","ǖ":"u","ṳ":"u","ụ":"u","ű":"u","ȕ":"u","ù":"u","ủ":"u","ư":"u","ứ":"u","ự":"u","ừ":"u","ử":"u","ữ":"u","ȗ":"u","ū":"u","ṻ":"u","ų":"u","ᶙ":"u","ů":"u","ũ":"u","ṹ":"u","ṵ":"u","ᵫ":"ue","ꝸ":"um","ⱴ":"v","ꝟ":"v","ṿ":"v","ʋ":"v","ᶌ":"v","ⱱ":"v","ṽ":"v","ꝡ":"vy","ẃ":"w","ŵ":"w","ẅ":"w","ẇ":"w","ẉ":"w","ẁ":"w","ⱳ":"w","ẘ":"w","ẍ":"x","ẋ":"x","ᶍ":"x","ý":"y","ŷ":"y","ÿ":"y","ẏ":"y","ỵ":"y","ỳ":"y","ƴ":"y","ỷ":"y","ỿ":"y","ȳ":"y","ẙ":"y","ɏ":"y","ỹ":"y","ź":"z","ž":"z","ẑ":"z","ʑ":"z","ⱬ":"z","ż":"z","ẓ":"z","ȥ":"z","ẕ":"z","ᵶ":"z","ᶎ":"z","ʐ":"z","ƶ":"z","ɀ":"z","ff":"ff","ffi":"ffi","ffl":"ffl","fi":"fi","fl":"fl","ij":"ij","œ":"oe","st":"st","ₐ":"a","ₑ":"e","ᵢ":"i","ⱼ":"j","ₒ":"o","ᵣ":"r","ᵤ":"u","ᵥ":"v","ₓ":"x"}; +String.prototype.latinise=function(){return this.replace(/[^A-Za-z0-9\[\] ]/g,function(a){return Latinise.latin_map[a]||a})}; +String.prototype.latinize=String.prototype.latinise; +String.prototype.isLatin=function(){return this==this.latinise()} + +/** +* Array +*/ + +// ------ UNIQUE reduces duplicates ------ + +array_unique = function(ar){ + var r = new Array(); + o:for(var i = 0, n = ar.length; i < n; i++) + { + for(var x = 0, y = r.length; x < y; x++) + { + if(r[x]==ar[i]) + { + continue o; + } + } + r[r.length] = ar[i]; + } + return r; +}; + +// ------ SUBSTRACT substract two array ------ + +array_subtract = function(ara1,ara2) { + var aRes = new Array() ; + for (var i = ara1.length-1; i >= 0; i--) + if(array_contains(ara2,ara1[i])) + aRes.push(ara1[i]); + return aRes ; +} + +/* + SHUFFLE Add a shuffle function to Array object prototype + author: Stephane Roucheray + src: http://sroucheray.org/blog/2009/11/array-sort-should-not-be-used-to-shuffle-an-array/ + found 2011/09/08. +*/ +array_shuffle = function(ar){ + var i = ar.length, j, temp; + if ( i == 0 ) return; + while ( --i ) { + j = Math.floor( Math.random() * ( i + 1 ) ); + temp = ar[i]; + ar[i] = ar[j]; + ar[j] = temp; + } + return ar; +}; + +// ------ CONTAINS ------ + +array_contains = function(ar, obj) { + var i = ar.length; + while (i--) + if (ar[i] === obj) + return true; + return false; +}; + +// ------ REMOVE ------ + +// /!\ Found on the Internet, not sure of efficiency. +// Array.prototype.remove = function(v) { +// var x, _i, _len, _results; +// _results = []; +// for (_i = 0, _len = this.length; _i < _len; _i++) { +// x = this[_i]; +// if (x !== v) { +// _results.push(x); +// } +// } +// return _results; +// }; + +array_remove = function(ar){ + var what, a= arguments, L= a.length, ax; + while(L && ar.length){ + what= a[--L]; + while((ax= ar.indexOf(what))!= -1){ + ar.splice(ax, 1); + } + } + return ar; +}; + +// for IE +// if(!Array.prototype.indexOf){ +// Array.prototype.indexOf= function(what, i){ +// i= i || 0; +// var L= this.length; +// while(i< L){ +// if(this[i]=== what) return i; +// ++i; +// } +// return -1; +// }; +// } + +array_indexOf = function(ar, what, i){ + i= i || 0; + var L= ar.length; + while(i< L){ + if(ar[i]=== what) return i; + ++i; + } + return -1; +}; + +// ------ SUBSTRACT substract two array ------ + +function array_subtract(ara1,ara2) { + var aRes = new Array() ; + for (var i = ara1.length-1; i >= 0; i--) + if( !array_contains(ara1[i],ara2) ) + aRes.push(ara1[i]); + return aRes ; +}; + +/** +* Objects +* +*/ + +// ------ OBJECTSIZE get the length of objects ------ + +function objectSize(o) { + var len = o.length ? --o.length : 0; + for (var k in o) + len++; + return len; +} +// Object.prototype.size = function () { +// // var len = this.length ? --this.length : -1; // POURQUOI NE FONCTIONNE PAS? +// var len = this.length ? --this.length : -2; +// for (var k in this) +// len++; +// return len; +// } + +function objectIsEmpty(obj){ + for (var prop in obj) { + if (obj.hasOwnProperty(prop)) + return false; + } + return true; +}; + +// ------ OBJECTGETKEY get key of index ------ + +function objectGetKey(o,index){ + var i = 0; + for (var k in o){ + if (k === 'length' || !o.hasOwnProperty(k)) + continue; + if(i == index) + return k; + i ++; + } +} +// Object.prototype.getKey = function(index){ +// var i = 0; +// for (var key in this){ +// if (key === 'length' || !this.hasOwnProperty(key)) +// continue; +// if(i == index) +// return key; +// i ++; +// } +// } + +// ------ OBJECTSORT sort object ------ + +function objectSort(o,value) { + var connection = new Array(); + for (var i = objectSize(o) - 1; i >= 0; i--){ + var k = objectGetKey(o,i); + for (var j = objectSize(o[k].wit) - 1; j >= 0; j--){ + var k2 = objectGetKey(o[k].wit,j); + if (k2==value) { + var the_wit = parseFloat(o[k].wit[k2]); + connection.push( {wit:the_wit,nid:k} ); + }; + }; + }; + + connection.sort(function(a,b){ + // return (a.wit - b.wit);//ascending + return (b.wit - a.wit);//descending + }); + + var o_sort = {}; + for (var i = connection.length - 1; i >= 0; i--){ + // o_sort[connection[i].wit+'-'+connection[i].nid] = o[connection[i].nid]; + o_sort[connection[i].nid] = o[connection[i].nid]; + }; + + return o_sort; +} + +/** +* trigo +*/ + +// -------- getElementAngle ---------- +// L'angle 0 correspond au nord (vers le haut) +// Exemple : getElementAngle(posElementX, posElementY, posSourisX, posSourisY) +// Ceci retournera l'angle de l'élément par rapport à la position de la souris + +function getElementAngle(x1, y1, x2, y2) { + var adj = x2 - x1; + var opp = y2 - y1; + + var angle = Math.abs(Math.atan(opp/adj) * 180/Math.PI); + + if (adj > 0 && opp < 0 ) { + angle = 90 - angle; + } + else if (adj >= 0 && opp >= 0) { + angle += 90; + } + else if (adj < 0 && opp >= 0) { + angle = 180 + (90 - angle); + } + else { + angle += 270; + } + + return angle; +} + + + + + // @codekit-prepend "gui.js" // @koala-prepend "gui.js" @@ -17,7 +387,7 @@ MaterioFlag = function(){ $(document) .bind('flagGlobalAfterLinkUpdate', onFlaging) - .bind('resultscompleted resultschanged', onResultsUpdated) + .bind('resultscompleted resultschanged previewloaded', onResultsUpdated) .bind('init-scroller-pager', onInitScrollerPager) .bind('load-scroller-pager', onLoadScrollerPager) .bind('view-mode-changed', onViewModeChanged) @@ -87,14 +457,14 @@ MaterioFlag = function(){ .bind('click', onClickCreatLink) .addClass('ajax-processed'); - + // preview block $('section.flag-list:not(.ajax-processed)', '#block-materio-flag-materio-flag-mylists').each(function(index){ var name = $(this).attr('class').match(/flag_lists_[^_]+_[0-9]+/); $('').appendTo($('h2.listname', this)).attr('name', name).bind('click', onClickClosePreview); $('a.open-list', this).bind('click', onClickOpenLink); - + }).addClass('ajax-processed'); break; } @@ -106,7 +476,7 @@ MaterioFlag = function(){ type : 'my'+type+'-block-builded', block : block, name : name - }); + }); },10); // trace('MaterioFlag :: activename', activename); @@ -115,7 +485,7 @@ MaterioFlag = function(){ // trace('MaterioFlag :: activename', activename); if(activename) - showPreview(activename, block); + showPreview(activename, block); }; function refreshBlocks(name){ @@ -125,17 +495,17 @@ MaterioFlag = function(){ }else if($('#block-materio-flag-materio-flag-mylists').length){ var type = 'lists'; } - + if(type != undefined){ var id = '#block-materio-flag-materio-flag-my'+type; var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/refresh/block/'+type; $.getJSON(url, function(json){ //trace('MaterioFlag :: block refreshed '+type, json); - + $(id).replaceWith(json.block); $('#block-materio-flag-materio-flag-mylists-nav').replaceWith(json.block_nav); - - buildBlocks(name); + + buildBlocks(name); $.event.trigger({ type : 'my'+type+'-block-updated', @@ -150,7 +520,7 @@ MaterioFlag = function(){ //trace('MaterioFlag :: ajaxifyLinks', container); container = ((container != null) ? container : 'body'); - + // trace('MaterioFlag :: typeof Drupal.flagLink', typeof Drupal.flagLink); if (typeof Drupal.flagLink != 'undefined') Drupal.flagLink(container); @@ -161,12 +531,11 @@ MaterioFlag = function(){ .bind('click', onUnflagList) .addClass('ajax-processed'); } - + $('a.flag-lists-create:not(.ajax-processed)', container) .bind('click', onClickCreatLink) .addClass('ajax-processed'); - }; /** @@ -191,9 +560,9 @@ MaterioFlag = function(){ //trace('MaterioFlag :: onClickClosePreview', event); eraseCookie('materiomyflaglistsopened'); if($(this).attr('name') == 'bookmarks'){ - $(this).parents('.block').find('section.bookmarks').removeClass('active'); + $(this).parents('.block').find('section.bookmarks').removeClass('active'); }else{ - $(this).parents('section.flag-list').removeClass('active'); + $(this).parents('section.flag-list').removeClass('active'); } $.event.trigger('init-layout'); @@ -214,7 +583,7 @@ MaterioFlag = function(){ function loadList(fid){ //trace('MaterioFlag :: loadList | fid', fid); var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/ajax/list/'+fid; - + $.event.trigger('loading-content'); $.getJSON(url, {'current_path':document.location.href},function(json){ @@ -231,14 +600,14 @@ MaterioFlag = function(){ if(json.rendered){ $('.inner-content','#content').html(json.rendered); - + $.event.trigger('loaded-content'); - + // no need of ajaxifylinks because it's triggered with resultschanged // ajaxifyLinks('#content'); var path = Drupal.settings.basePath + Drupal.settings.pathPrefix + json.path; - + $.event.trigger({ type : 'new-history-page', path : path, @@ -246,10 +615,10 @@ MaterioFlag = function(){ content : json.rendered }); - // TODO: change language links for folders + // TODO: change language links for folders // for (language in Drupal.settings.materio_search_api_ajax.languages) { // var l = Drupal.settings.materio_search_api_ajax.languages[language]; - // $('#block-locale-language li.'+language+' a').attr('href', Drupal.settings.basePath + l.prefix+'/' + json.search_path + '/' + json.keys) + // $('#block-locale-language li.'+language+' a').attr('href', Drupal.settings.basePath + l.prefix+'/' + json.search_path + '/' + json.keys) // }; triggerContentChanged(); @@ -308,7 +677,7 @@ MaterioFlag = function(){ case 'cancel': //trace('MaterioFlag :: cancel',event); $(this).parents('#modal').remove(); - + // google analytics $.event.trigger({ type:"record-stat", @@ -333,11 +702,11 @@ MaterioFlag = function(){ createList($modal, type, title, $link); break; } - + return false; }) .parents('form').find('input[type="text"]').focus(); - // TODO: esc keypressed close the form + // TODO: esc keypressed close the form }; function createList($modal, type, title, $link){ @@ -365,7 +734,7 @@ MaterioFlag = function(){ } }); }; - + function flagEntityWithList(name, nid, token){ //trace('MaterioFlag :: flagEntityWithList | name', name); // var ret; @@ -378,7 +747,7 @@ MaterioFlag = function(){ success: function (data2) { //trace('MaterioFlag :: node taged with newly created list : data2', data2) if (data2.status) { - + // google analytics $.event.trigger({ type : "record-stat", @@ -410,7 +779,7 @@ MaterioFlag = function(){ nids.push($(this).attr('class').match(/node-([0-9]+)/)[1]); }); // trace('MaterioFlag :: nids', nids); - + var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/nodelinks'; $.getJSON(url, {nids:nids.join(";")}, function(data) { // trace('MaterioFlag :: data', data); @@ -421,14 +790,14 @@ MaterioFlag = function(){ // trace('MaterioFlag :: typeof Drupal.flagLink', typeof Drupal.flagLink); // if (typeof Drupal.flagLink != 'undefined') - // Drupal.flagLink($('.node-'+nid+' .flag-lists-entity-links')); - + // Drupal.flagLink($('.node-'+nid+' .flag-lists-entity-links')); + // TODO: sortir ajaxifyLinks de la boucle, je pense que ça prend trop de ressources ajaxifyLinks('.node-'+nid+' .flag-lists-entity-links'); } }); - + $.event.trigger({ type : 'materioflag-nodelinks-updated', nids : nids @@ -440,12 +809,12 @@ MaterioFlag = function(){ */ function onCLickEditList(event){ //trace('MaterioFlag :: onCLickEditList | event', event); - // TODO: empécher le double formulaire + // TODO: empécher le double formulaire event.preventDefault(); var $link = $(event.currentTarget); var lid = $link.attr('href').match(/[^\/]*$/); var type = 'materiau'; // this is cheap - + var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/editlistform/'+type+'/'+lid[0]; $.getJSON(url, function(json){ @@ -485,14 +854,14 @@ MaterioFlag = function(){ case 'cancel': //trace('MaterioFlag :: cancel',event); $(this).parents('#modal').remove(); - + // google analytics - var action = 'cancel edit form'; + var action = 'cancel edit form'; break; case 'save': //trace('MaterioFlag :: create',event); - + // google analytics var action = "submit edit form"; @@ -503,14 +872,14 @@ MaterioFlag = function(){ if(confirm('Do you realy want to delete your '+title+' folder ?')){ var action = "submit delete form"; - deleteList($modal, fid); + deleteList($modal, fid); }else{ var action = "cancel delete form"; } - + break; } - + // google analytics $.event.trigger({ type:"record-stat", @@ -521,7 +890,7 @@ MaterioFlag = function(){ return false; }) .parents('form').find('input[type="text"]').focus(); - // TODO: esc keypressed close the form + // TODO: esc keypressed close the form }; function saveList($modal, fid, name, title){ @@ -538,7 +907,7 @@ MaterioFlag = function(){ } else { //trace('MaterioFlag :: saved list : data', data); - + $.event.trigger({ type : 'list-edited', name : data.listname, @@ -627,7 +996,7 @@ MaterioFlag = function(){ var $newcontent = $(json.rendered), $newitems = $(container_class, $newcontent).children('article').addClass('just-added'), $newpager = $('ul.pager', $newcontent); - + $(container_class, '#content').append($newitems); $('ul.pager', '#content').replaceWith($newpager.hide()); @@ -672,8 +1041,8 @@ MaterioFlag = function(){ }; - /** - * cookies + /** + * cookies */ function createCookie(name,value,days) { if (days) { @@ -709,5 +1078,5 @@ MaterioFlag = function(){ $(document).ready(function() { var materioflag = new MaterioFlag(); }); - + })(jQuery); \ No newline at end of file From ae72f70488fcaa860e61b7f88f2e221134167a8e Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Mon, 28 Apr 2014 16:53:58 +0200 Subject: [PATCH 21/34] bug fixe ? --- js/materio_flag.js | 4 - js/materio_flag.min.js | 374 ----------------------------------------- 2 files changed, 378 deletions(-) diff --git a/js/materio_flag.js b/js/materio_flag.js index 896d2f3e..afb45d6c 100755 --- a/js/materio_flag.js +++ b/js/materio_flag.js @@ -1,7 +1,3 @@ -// @codekit-prepend "gui.js" -// @koala-prepend "gui.js" - - (function($) { MaterioFlag = function(){ diff --git a/js/materio_flag.min.js b/js/materio_flag.min.js index 8f7efde4..afb45d6c 100644 --- a/js/materio_flag.min.js +++ b/js/materio_flag.min.js @@ -1,377 +1,3 @@ -// * date 2011/10/19 * - -/** -* misc -*/ - -// ------ TRACE ------ - -function trace(s,o){ - if(window.console && window.console.debug){ - arguments.length === 2 ? window.console.debug(s,o) : window.console.debug(s); - }else if(console && console.log){ - arguments.length === 2 ? console.log(s,o) : console.log(s); - } -}; - -// ------ LOADJSCSSFILE ------ - -function loadjscssfile(filename, filetype){ - if (filetype=="js"){ //if filename is a external JavaScript file - var fileref=document.createElement('script') - fileref.setAttribute("type","text/javascript") - fileref.setAttribute("src", filename) - } - else if (filetype=="css"){ //if filename is an external CSS file - var fileref=document.createElement("link") - fileref.setAttribute("rel", "stylesheet") - fileref.setAttribute("type", "text/css") - fileref.setAttribute("href", filename) - } - if (typeof fileref!="undefined") - document.getElementsByTagName("head")[0].appendChild(fileref) -}; - -// ------ TIMEOUT - -function Timeout(fn, interval) { - var id = setTimeout(fn, interval); - this.cleared = false; - this.clear = function () { - this.cleared = true; - clearTimeout(id); - }; -} - -// ------ HEXTORGB convert hex to rgb color ------ - -function HexToRGB(h){ - if(h.charAt(0)=="#"){ - var coul = h.substring(1,7); - var r = parseInt(coul.substring(0,2),16); - var g = parseInt(coul.substring(2,4),16); - var b = parseInt(coul.substring(4,6),16); - return 'rgb('+r+', '+g+', '+b+')'; - }else{ - return null; - } -} - -// ------ PAIR check if number is pair of impair ------ - -function pair(n){return typeof n=='number'?(n%2==0?true:false):null;} - -// ------ RANDOM ------ - -function random(n1,n2){ - return arguments.length === 1 && typeof n1 === 'number'? Math.random()*n1 : ( arguments.length === 2 && typeof n1 === typeof n2 && typeof n1 === 'number' ? n1 + Math.random()*(n2-n1) : NaN ); -} -function randomInt(n1,n2){ - var rand = arguments.length === 1 && typeof n1 === 'number'? Math.random()*n1 : ( arguments.length === 2 && typeof n1 === typeof n2 && typeof n1 === 'number' ? n1 + Math.random()*(n2-n1) : NaN ); - return parseInt(rand); -} - -// ------ ROUNDED ------ - -function round(n,granularity){ - if(arguments.length == 1){ - n = Math.round(n); - }else{ - granularity = granularity.toString(); - granularity = granularity.replace(/./gi, 0); - granularity = granularity.replace(/^./gi, 1); - granularity = parseInt(granularity); - n = Math.round(n*granularity)/granularity; - } - return n; -} - -// ------ FLOOR ------ - -function floor(n,granularity){ - if(arguments.length == 1){ - n = Math.floor(n); - }else{ - granularity = granularity.toString(); - granularity = granularity.replace(/./gi, 0); - granularity = granularity.replace(/^./gi, 1); - granularity = parseInt(granularity); - n = Math.floor(n*granularity)/granularity; - } - return n; -} - -// ------ CEIL ------ - -function ceil(n,granularity){ - if(arguments.length == 1){ - n = Math.ceil(n); - }else{ - granularity = granularity.toString(); - granularity = granularity.replace(/./gi, 0); - granularity = granularity.replace(/^./gi, 1); - granularity = parseInt(granularity); - n = Math.ceil(n*granularity)/granularity; - } - return n; -} - -/** -* String -*/ - -// ------ TRIM remove multiple, leading or trailing spaces ------ - -String.prototype.trim = function() { - return this.replace(/(^\s*)|(\s*$)/gi,"").replace(/[ ]{2,}/gi," ").replace(/\n /,"\n"); -} - -// ------ remove all accents, for sort() by example ------ - -var Latinise={};Latinise.latin_map={"Á":"A","Ă":"A","Ắ":"A","Ặ":"A","Ằ":"A","Ẳ":"A","Ẵ":"A","Ǎ":"A","Â":"A","Ấ":"A","Ậ":"A","Ầ":"A","Ẩ":"A","Ẫ":"A","Ä":"A","Ǟ":"A","Ȧ":"A","Ǡ":"A","Ạ":"A","Ȁ":"A","À":"A","Ả":"A","Ȃ":"A","Ā":"A","Ą":"A","Å":"A","Ǻ":"A","Ḁ":"A","Ⱥ":"A","Ã":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ǣ":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ḃ":"B","Ḅ":"B","Ɓ":"B","Ḇ":"B","Ƀ":"B","Ƃ":"B","Ć":"C","Č":"C","Ç":"C","Ḉ":"C","Ĉ":"C","Ċ":"C","Ƈ":"C","Ȼ":"C","Ď":"D","Ḑ":"D","Ḓ":"D","Ḋ":"D","Ḍ":"D","Ɗ":"D","Ḏ":"D","Dz":"D","Dž":"D","Đ":"D","Ƌ":"D","DZ":"DZ","DŽ":"DZ","É":"E","Ĕ":"E","Ě":"E","Ȩ":"E","Ḝ":"E","Ê":"E","Ế":"E","Ệ":"E","Ề":"E","Ể":"E","Ễ":"E","Ḙ":"E","Ë":"E","Ė":"E","Ẹ":"E","Ȅ":"E","È":"E","Ẻ":"E","Ȇ":"E","Ē":"E","Ḗ":"E","Ḕ":"E","Ę":"E","Ɇ":"E","Ẽ":"E","Ḛ":"E","Ꝫ":"ET","Ḟ":"F","Ƒ":"F","Ǵ":"G","Ğ":"G","Ǧ":"G","Ģ":"G","Ĝ":"G","Ġ":"G","Ɠ":"G","Ḡ":"G","Ǥ":"G","Ḫ":"H","Ȟ":"H","Ḩ":"H","Ĥ":"H","Ⱨ":"H","Ḧ":"H","Ḣ":"H","Ḥ":"H","Ħ":"H","Í":"I","Ĭ":"I","Ǐ":"I","Î":"I","Ï":"I","Ḯ":"I","İ":"I","Ị":"I","Ȉ":"I","Ì":"I","Ỉ":"I","Ȋ":"I","Ī":"I","Į":"I","Ɨ":"I","Ĩ":"I","Ḭ":"I","Ꝺ":"D","Ꝼ":"F","Ᵹ":"G","Ꞃ":"R","Ꞅ":"S","Ꞇ":"T","Ꝭ":"IS","Ĵ":"J","Ɉ":"J","Ḱ":"K","Ǩ":"K","Ķ":"K","Ⱪ":"K","Ꝃ":"K","Ḳ":"K","Ƙ":"K","Ḵ":"K","Ꝁ":"K","Ꝅ":"K","Ĺ":"L","Ƚ":"L","Ľ":"L","Ļ":"L","Ḽ":"L","Ḷ":"L","Ḹ":"L","Ⱡ":"L","Ꝉ":"L","Ḻ":"L","Ŀ":"L","Ɫ":"L","Lj":"L","Ł":"L","LJ":"LJ","Ḿ":"M","Ṁ":"M","Ṃ":"M","Ɱ":"M","Ń":"N","Ň":"N","Ņ":"N","Ṋ":"N","Ṅ":"N","Ṇ":"N","Ǹ":"N","Ɲ":"N","Ṉ":"N","Ƞ":"N","Nj":"N","Ñ":"N","NJ":"NJ","Ó":"O","Ŏ":"O","Ǒ":"O","Ô":"O","Ố":"O","Ộ":"O","Ồ":"O","Ổ":"O","Ỗ":"O","Ö":"O","Ȫ":"O","Ȯ":"O","Ȱ":"O","Ọ":"O","Ő":"O","Ȍ":"O","Ò":"O","Ỏ":"O","Ơ":"O","Ớ":"O","Ợ":"O","Ờ":"O","Ở":"O","Ỡ":"O","Ȏ":"O","Ꝋ":"O","Ꝍ":"O","Ō":"O","Ṓ":"O","Ṑ":"O","Ɵ":"O","Ǫ":"O","Ǭ":"O","Ø":"O","Ǿ":"O","Õ":"O","Ṍ":"O","Ṏ":"O","Ȭ":"O","Ƣ":"OI","Ꝏ":"OO","Ɛ":"E","Ɔ":"O","Ȣ":"OU","Ṕ":"P","Ṗ":"P","Ꝓ":"P","Ƥ":"P","Ꝕ":"P","Ᵽ":"P","Ꝑ":"P","Ꝙ":"Q","Ꝗ":"Q","Ŕ":"R","Ř":"R","Ŗ":"R","Ṙ":"R","Ṛ":"R","Ṝ":"R","Ȑ":"R","Ȓ":"R","Ṟ":"R","Ɍ":"R","Ɽ":"R","Ꜿ":"C","Ǝ":"E","Ś":"S","Ṥ":"S","Š":"S","Ṧ":"S","Ş":"S","Ŝ":"S","Ș":"S","Ṡ":"S","Ṣ":"S","Ṩ":"S","Ť":"T","Ţ":"T","Ṱ":"T","Ț":"T","Ⱦ":"T","Ṫ":"T","Ṭ":"T","Ƭ":"T","Ṯ":"T","Ʈ":"T","Ŧ":"T","Ɐ":"A","Ꞁ":"L","Ɯ":"M","Ʌ":"V","Ꜩ":"TZ","Ú":"U","Ŭ":"U","Ǔ":"U","Û":"U","Ṷ":"U","Ü":"U","Ǘ":"U","Ǚ":"U","Ǜ":"U","Ǖ":"U","Ṳ":"U","Ụ":"U","Ű":"U","Ȕ":"U","Ù":"U","Ủ":"U","Ư":"U","Ứ":"U","Ự":"U","Ừ":"U","Ử":"U","Ữ":"U","Ȗ":"U","Ū":"U","Ṻ":"U","Ų":"U","Ů":"U","Ũ":"U","Ṹ":"U","Ṵ":"U","Ꝟ":"V","Ṿ":"V","Ʋ":"V","Ṽ":"V","Ꝡ":"VY","Ẃ":"W","Ŵ":"W","Ẅ":"W","Ẇ":"W","Ẉ":"W","Ẁ":"W","Ⱳ":"W","Ẍ":"X","Ẋ":"X","Ý":"Y","Ŷ":"Y","Ÿ":"Y","Ẏ":"Y","Ỵ":"Y","Ỳ":"Y","Ƴ":"Y","Ỷ":"Y","Ỿ":"Y","Ȳ":"Y","Ɏ":"Y","Ỹ":"Y","Ź":"Z","Ž":"Z","Ẑ":"Z","Ⱬ":"Z","Ż":"Z","Ẓ":"Z","Ȥ":"Z","Ẕ":"Z","Ƶ":"Z","IJ":"IJ","Œ":"OE","ᴀ":"A","ᴁ":"AE","ʙ":"B","ᴃ":"B","ᴄ":"C","ᴅ":"D","ᴇ":"E","ꜰ":"F","ɢ":"G","ʛ":"G","ʜ":"H","ɪ":"I","ʁ":"R","ᴊ":"J","ᴋ":"K","ʟ":"L","ᴌ":"L","ᴍ":"M","ɴ":"N","ᴏ":"O","ɶ":"OE","ᴐ":"O","ᴕ":"OU","ᴘ":"P","ʀ":"R","ᴎ":"N","ᴙ":"R","ꜱ":"S","ᴛ":"T","ⱻ":"E","ᴚ":"R","ᴜ":"U","ᴠ":"V","ᴡ":"W","ʏ":"Y","ᴢ":"Z","á":"a","ă":"a","ắ":"a","ặ":"a","ằ":"a","ẳ":"a","ẵ":"a","ǎ":"a","â":"a","ấ":"a","ậ":"a","ầ":"a","ẩ":"a","ẫ":"a","ä":"a","ǟ":"a","ȧ":"a","ǡ":"a","ạ":"a","ȁ":"a","à":"a","ả":"a","ȃ":"a","ā":"a","ą":"a","ᶏ":"a","ẚ":"a","å":"a","ǻ":"a","ḁ":"a","ⱥ":"a","ã":"a","ꜳ":"aa","æ":"ae","ǽ":"ae","ǣ":"ae","ꜵ":"ao","ꜷ":"au","ꜹ":"av","ꜻ":"av","ꜽ":"ay","ḃ":"b","ḅ":"b","ɓ":"b","ḇ":"b","ᵬ":"b","ᶀ":"b","ƀ":"b","ƃ":"b","ɵ":"o","ć":"c","č":"c","ç":"c","ḉ":"c","ĉ":"c","ɕ":"c","ċ":"c","ƈ":"c","ȼ":"c","ď":"d","ḑ":"d","ḓ":"d","ȡ":"d","ḋ":"d","ḍ":"d","ɗ":"d","ᶑ":"d","ḏ":"d","ᵭ":"d","ᶁ":"d","đ":"d","ɖ":"d","ƌ":"d","ı":"i","ȷ":"j","ɟ":"j","ʄ":"j","dz":"dz","dž":"dz","é":"e","ĕ":"e","ě":"e","ȩ":"e","ḝ":"e","ê":"e","ế":"e","ệ":"e","ề":"e","ể":"e","ễ":"e","ḙ":"e","ë":"e","ė":"e","ẹ":"e","ȅ":"e","è":"e","ẻ":"e","ȇ":"e","ē":"e","ḗ":"e","ḕ":"e","ⱸ":"e","ę":"e","ᶒ":"e","ɇ":"e","ẽ":"e","ḛ":"e","ꝫ":"et","ḟ":"f","ƒ":"f","ᵮ":"f","ᶂ":"f","ǵ":"g","ğ":"g","ǧ":"g","ģ":"g","ĝ":"g","ġ":"g","ɠ":"g","ḡ":"g","ᶃ":"g","ǥ":"g","ḫ":"h","ȟ":"h","ḩ":"h","ĥ":"h","ⱨ":"h","ḧ":"h","ḣ":"h","ḥ":"h","ɦ":"h","ẖ":"h","ħ":"h","ƕ":"hv","í":"i","ĭ":"i","ǐ":"i","î":"i","ï":"i","ḯ":"i","ị":"i","ȉ":"i","ì":"i","ỉ":"i","ȋ":"i","ī":"i","į":"i","ᶖ":"i","ɨ":"i","ĩ":"i","ḭ":"i","ꝺ":"d","ꝼ":"f","ᵹ":"g","ꞃ":"r","ꞅ":"s","ꞇ":"t","ꝭ":"is","ǰ":"j","ĵ":"j","ʝ":"j","ɉ":"j","ḱ":"k","ǩ":"k","ķ":"k","ⱪ":"k","ꝃ":"k","ḳ":"k","ƙ":"k","ḵ":"k","ᶄ":"k","ꝁ":"k","ꝅ":"k","ĺ":"l","ƚ":"l","ɬ":"l","ľ":"l","ļ":"l","ḽ":"l","ȴ":"l","ḷ":"l","ḹ":"l","ⱡ":"l","ꝉ":"l","ḻ":"l","ŀ":"l","ɫ":"l","ᶅ":"l","ɭ":"l","ł":"l","lj":"lj","ſ":"s","ẜ":"s","ẛ":"s","ẝ":"s","ḿ":"m","ṁ":"m","ṃ":"m","ɱ":"m","ᵯ":"m","ᶆ":"m","ń":"n","ň":"n","ņ":"n","ṋ":"n","ȵ":"n","ṅ":"n","ṇ":"n","ǹ":"n","ɲ":"n","ṉ":"n","ƞ":"n","ᵰ":"n","ᶇ":"n","ɳ":"n","ñ":"n","nj":"nj","ó":"o","ŏ":"o","ǒ":"o","ô":"o","ố":"o","ộ":"o","ồ":"o","ổ":"o","ỗ":"o","ö":"o","ȫ":"o","ȯ":"o","ȱ":"o","ọ":"o","ő":"o","ȍ":"o","ò":"o","ỏ":"o","ơ":"o","ớ":"o","ợ":"o","ờ":"o","ở":"o","ỡ":"o","ȏ":"o","ꝋ":"o","ꝍ":"o","ⱺ":"o","ō":"o","ṓ":"o","ṑ":"o","ǫ":"o","ǭ":"o","ø":"o","ǿ":"o","õ":"o","ṍ":"o","ṏ":"o","ȭ":"o","ƣ":"oi","ꝏ":"oo","ɛ":"e","ᶓ":"e","ɔ":"o","ᶗ":"o","ȣ":"ou","ṕ":"p","ṗ":"p","ꝓ":"p","ƥ":"p","ᵱ":"p","ᶈ":"p","ꝕ":"p","ᵽ":"p","ꝑ":"p","ꝙ":"q","ʠ":"q","ɋ":"q","ꝗ":"q","ŕ":"r","ř":"r","ŗ":"r","ṙ":"r","ṛ":"r","ṝ":"r","ȑ":"r","ɾ":"r","ᵳ":"r","ȓ":"r","ṟ":"r","ɼ":"r","ᵲ":"r","ᶉ":"r","ɍ":"r","ɽ":"r","ↄ":"c","ꜿ":"c","ɘ":"e","ɿ":"r","ś":"s","ṥ":"s","š":"s","ṧ":"s","ş":"s","ŝ":"s","ș":"s","ṡ":"s","ṣ":"s","ṩ":"s","ʂ":"s","ᵴ":"s","ᶊ":"s","ȿ":"s","ɡ":"g","ᴑ":"o","ᴓ":"o","ᴝ":"u","ť":"t","ţ":"t","ṱ":"t","ț":"t","ȶ":"t","ẗ":"t","ⱦ":"t","ṫ":"t","ṭ":"t","ƭ":"t","ṯ":"t","ᵵ":"t","ƫ":"t","ʈ":"t","ŧ":"t","ᵺ":"th","ɐ":"a","ᴂ":"ae","ǝ":"e","ᵷ":"g","ɥ":"h","ʮ":"h","ʯ":"h","ᴉ":"i","ʞ":"k","ꞁ":"l","ɯ":"m","ɰ":"m","ᴔ":"oe","ɹ":"r","ɻ":"r","ɺ":"r","ⱹ":"r","ʇ":"t","ʌ":"v","ʍ":"w","ʎ":"y","ꜩ":"tz","ú":"u","ŭ":"u","ǔ":"u","û":"u","ṷ":"u","ü":"u","ǘ":"u","ǚ":"u","ǜ":"u","ǖ":"u","ṳ":"u","ụ":"u","ű":"u","ȕ":"u","ù":"u","ủ":"u","ư":"u","ứ":"u","ự":"u","ừ":"u","ử":"u","ữ":"u","ȗ":"u","ū":"u","ṻ":"u","ų":"u","ᶙ":"u","ů":"u","ũ":"u","ṹ":"u","ṵ":"u","ᵫ":"ue","ꝸ":"um","ⱴ":"v","ꝟ":"v","ṿ":"v","ʋ":"v","ᶌ":"v","ⱱ":"v","ṽ":"v","ꝡ":"vy","ẃ":"w","ŵ":"w","ẅ":"w","ẇ":"w","ẉ":"w","ẁ":"w","ⱳ":"w","ẘ":"w","ẍ":"x","ẋ":"x","ᶍ":"x","ý":"y","ŷ":"y","ÿ":"y","ẏ":"y","ỵ":"y","ỳ":"y","ƴ":"y","ỷ":"y","ỿ":"y","ȳ":"y","ẙ":"y","ɏ":"y","ỹ":"y","ź":"z","ž":"z","ẑ":"z","ʑ":"z","ⱬ":"z","ż":"z","ẓ":"z","ȥ":"z","ẕ":"z","ᵶ":"z","ᶎ":"z","ʐ":"z","ƶ":"z","ɀ":"z","ff":"ff","ffi":"ffi","ffl":"ffl","fi":"fi","fl":"fl","ij":"ij","œ":"oe","st":"st","ₐ":"a","ₑ":"e","ᵢ":"i","ⱼ":"j","ₒ":"o","ᵣ":"r","ᵤ":"u","ᵥ":"v","ₓ":"x"}; -String.prototype.latinise=function(){return this.replace(/[^A-Za-z0-9\[\] ]/g,function(a){return Latinise.latin_map[a]||a})}; -String.prototype.latinize=String.prototype.latinise; -String.prototype.isLatin=function(){return this==this.latinise()} - -/** -* Array -*/ - -// ------ UNIQUE reduces duplicates ------ - -array_unique = function(ar){ - var r = new Array(); - o:for(var i = 0, n = ar.length; i < n; i++) - { - for(var x = 0, y = r.length; x < y; x++) - { - if(r[x]==ar[i]) - { - continue o; - } - } - r[r.length] = ar[i]; - } - return r; -}; - -// ------ SUBSTRACT substract two array ------ - -array_subtract = function(ara1,ara2) { - var aRes = new Array() ; - for (var i = ara1.length-1; i >= 0; i--) - if(array_contains(ara2,ara1[i])) - aRes.push(ara1[i]); - return aRes ; -} - -/* - SHUFFLE Add a shuffle function to Array object prototype - author: Stephane Roucheray - src: http://sroucheray.org/blog/2009/11/array-sort-should-not-be-used-to-shuffle-an-array/ - found 2011/09/08. -*/ -array_shuffle = function(ar){ - var i = ar.length, j, temp; - if ( i == 0 ) return; - while ( --i ) { - j = Math.floor( Math.random() * ( i + 1 ) ); - temp = ar[i]; - ar[i] = ar[j]; - ar[j] = temp; - } - return ar; -}; - -// ------ CONTAINS ------ - -array_contains = function(ar, obj) { - var i = ar.length; - while (i--) - if (ar[i] === obj) - return true; - return false; -}; - -// ------ REMOVE ------ - -// /!\ Found on the Internet, not sure of efficiency. -// Array.prototype.remove = function(v) { -// var x, _i, _len, _results; -// _results = []; -// for (_i = 0, _len = this.length; _i < _len; _i++) { -// x = this[_i]; -// if (x !== v) { -// _results.push(x); -// } -// } -// return _results; -// }; - -array_remove = function(ar){ - var what, a= arguments, L= a.length, ax; - while(L && ar.length){ - what= a[--L]; - while((ax= ar.indexOf(what))!= -1){ - ar.splice(ax, 1); - } - } - return ar; -}; - -// for IE -// if(!Array.prototype.indexOf){ -// Array.prototype.indexOf= function(what, i){ -// i= i || 0; -// var L= this.length; -// while(i< L){ -// if(this[i]=== what) return i; -// ++i; -// } -// return -1; -// }; -// } - -array_indexOf = function(ar, what, i){ - i= i || 0; - var L= ar.length; - while(i< L){ - if(ar[i]=== what) return i; - ++i; - } - return -1; -}; - -// ------ SUBSTRACT substract two array ------ - -function array_subtract(ara1,ara2) { - var aRes = new Array() ; - for (var i = ara1.length-1; i >= 0; i--) - if( !array_contains(ara1[i],ara2) ) - aRes.push(ara1[i]); - return aRes ; -}; - -/** -* Objects -* -*/ - -// ------ OBJECTSIZE get the length of objects ------ - -function objectSize(o) { - var len = o.length ? --o.length : 0; - for (var k in o) - len++; - return len; -} -// Object.prototype.size = function () { -// // var len = this.length ? --this.length : -1; // POURQUOI NE FONCTIONNE PAS? -// var len = this.length ? --this.length : -2; -// for (var k in this) -// len++; -// return len; -// } - -function objectIsEmpty(obj){ - for (var prop in obj) { - if (obj.hasOwnProperty(prop)) - return false; - } - return true; -}; - -// ------ OBJECTGETKEY get key of index ------ - -function objectGetKey(o,index){ - var i = 0; - for (var k in o){ - if (k === 'length' || !o.hasOwnProperty(k)) - continue; - if(i == index) - return k; - i ++; - } -} -// Object.prototype.getKey = function(index){ -// var i = 0; -// for (var key in this){ -// if (key === 'length' || !this.hasOwnProperty(key)) -// continue; -// if(i == index) -// return key; -// i ++; -// } -// } - -// ------ OBJECTSORT sort object ------ - -function objectSort(o,value) { - var connection = new Array(); - for (var i = objectSize(o) - 1; i >= 0; i--){ - var k = objectGetKey(o,i); - for (var j = objectSize(o[k].wit) - 1; j >= 0; j--){ - var k2 = objectGetKey(o[k].wit,j); - if (k2==value) { - var the_wit = parseFloat(o[k].wit[k2]); - connection.push( {wit:the_wit,nid:k} ); - }; - }; - }; - - connection.sort(function(a,b){ - // return (a.wit - b.wit);//ascending - return (b.wit - a.wit);//descending - }); - - var o_sort = {}; - for (var i = connection.length - 1; i >= 0; i--){ - // o_sort[connection[i].wit+'-'+connection[i].nid] = o[connection[i].nid]; - o_sort[connection[i].nid] = o[connection[i].nid]; - }; - - return o_sort; -} - -/** -* trigo -*/ - -// -------- getElementAngle ---------- -// L'angle 0 correspond au nord (vers le haut) -// Exemple : getElementAngle(posElementX, posElementY, posSourisX, posSourisY) -// Ceci retournera l'angle de l'élément par rapport à la position de la souris - -function getElementAngle(x1, y1, x2, y2) { - var adj = x2 - x1; - var opp = y2 - y1; - - var angle = Math.abs(Math.atan(opp/adj) * 180/Math.PI); - - if (adj > 0 && opp < 0 ) { - angle = 90 - angle; - } - else if (adj >= 0 && opp >= 0) { - angle += 90; - } - else if (adj < 0 && opp >= 0) { - angle = 180 + (90 - angle); - } - else { - angle += 270; - } - - return angle; -} - - - - - -// @codekit-prepend "gui.js" -// @koala-prepend "gui.js" - - (function($) { MaterioFlag = function(){ From a08a5287fc654f7cf4fc8b83bb9ad27325fd8038 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Mon, 28 Apr 2014 17:05:27 +0200 Subject: [PATCH 22/34] bug fixe ? --- js/materio_flag.js | 2 +- js/materio_flag.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/materio_flag.js b/js/materio_flag.js index afb45d6c..0a46a595 100755 --- a/js/materio_flag.js +++ b/js/materio_flag.js @@ -126,7 +126,7 @@ MaterioFlag = function(){ var id = '#block-materio-flag-materio-flag-my'+type; var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/refresh/block/'+type; $.getJSON(url, function(json){ - //trace('MaterioFlag :: block refreshed '+type, json); + trace('MaterioFlag :: block refreshed '+type, json); $(id).replaceWith(json.block); $('#block-materio-flag-materio-flag-mylists-nav').replaceWith(json.block_nav); diff --git a/js/materio_flag.min.js b/js/materio_flag.min.js index afb45d6c..0a46a595 100644 --- a/js/materio_flag.min.js +++ b/js/materio_flag.min.js @@ -126,7 +126,7 @@ MaterioFlag = function(){ var id = '#block-materio-flag-materio-flag-my'+type; var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/refresh/block/'+type; $.getJSON(url, function(json){ - //trace('MaterioFlag :: block refreshed '+type, json); + trace('MaterioFlag :: block refreshed '+type, json); $(id).replaceWith(json.block); $('#block-materio-flag-materio-flag-mylists-nav').replaceWith(json.block_nav); From 05a41ebf3ae37c58fadac13af9228580eb48a4d5 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Mon, 28 Apr 2014 17:09:33 +0200 Subject: [PATCH 23/34] bug fixe ? --- materio_flag.pages.inc | 86 +++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/materio_flag.pages.inc b/materio_flag.pages.inc index 65112aab..58e8544e 100755 --- a/materio_flag.pages.inc +++ b/materio_flag.pages.inc @@ -2,10 +2,10 @@ /** * materio_flag_refresh_blocks($flag) - * + * */ function materio_flag_refresh_block($flag){ - + switch ($flag) { case 'bookmarks': $block_name = 'materio_flag_mybookmarks'; @@ -18,7 +18,7 @@ function materio_flag_refresh_block($flag){ if(!isset($block_name)) return; - + $rep = array(); $block = block_load('materio_flag', $block_name); @@ -27,20 +27,20 @@ function materio_flag_refresh_block($flag){ $block_rendered = drupal_render($build); $rep['block'] = $block_rendered; - if(isset($block_nav_name)) + if(isset($block_nav_name)){ $block = block_load('materio_flag', $block_nav_name); $block_content = _block_render_blocks(array($block)); $build = _block_get_renderable_array($block_content); $block_rendered = drupal_render($build); $rep['block_nav'] = $block_rendered; - + } drupal_json_output($rep); } /** * materio_flag_createlist($type) - * + * */ function materio_flag_createlist_form($type){ $debug = false; @@ -55,7 +55,7 @@ function materio_flag_createlist_form($type){ // menu_set_active_item($path); // $return = menu_execute_active_handler($path, FALSE); - + // if (is_int($return)) { // switch ($return) { // case MENU_NOT_FOUND : @@ -69,7 +69,7 @@ function materio_flag_createlist_form($type){ // break; // } // } elseif (isset($return)) { - + // $form_state['build_info']['args'] = array(NULL, 'breve'); // $f = drupal_get_form('flag_lists_form', $form_state); // dsm($f); @@ -86,11 +86,11 @@ function materio_flag_createlist_form($type){ ); $form['listname'] = array( - '#type' => 'textfield', + '#type' => 'textfield', '#title' => t('Create new @name', array('@name'=>variable_get('flag_lists_name', 'list'))), - '#default_value' => '', - // '#size' => 100, - '#maxlength' => 255, + '#default_value' => '', + // '#size' => 100, + '#maxlength' => 255, '#name' => 'flag-lists-name', '#description' => t('A short, descriptive title for this Folder list. Limit to 255 characters.'), ); @@ -111,21 +111,21 @@ function materio_flag_createlist_form($type){ '#value' => t('cancel'), '#name' => 'cancel', ); - + // dsm($form, 'form'); - $return = drupal_render($form); + $return = drupal_render($form); $rep = array( 'rendered_form'=>$return, ); - + if ($debug) { dsm($rep, 'rep'); return "debug display"; }else{ - drupal_json_output($rep); + drupal_json_output($rep); } } @@ -172,7 +172,7 @@ function materio_flag_editlist_form($type, $fid){ '#value' => $fid, '#name' => 'fid', ); - + $form['name'] = array( '#type' => 'hidden', '#value' => $name, @@ -180,11 +180,11 @@ function materio_flag_editlist_form($type, $fid){ ); $form['listtitle'] = array( - '#type' => 'textfield', + '#type' => 'textfield', '#title' => t('Edit this '.variable_get('flag_lists_name', 'list')), - '#value' => $flag->title, - // '#size' => 100, - '#maxlength' => 255, + '#value' => $flag->title, + // '#size' => 100, + '#maxlength' => 255, '#name' => 'flag-lists-title', '#description' => t('A short, descriptive title for this Folder list. Limit to 255 characters.'), ); @@ -211,10 +211,10 @@ function materio_flag_editlist_form($type, $fid){ '#value' => t('cancel'), '#name' => 'cancel', ); - + // dsm($form, 'form'); - $return = drupal_render($form); + $return = drupal_render($form); $rep = array( 'rendered_form'=>$return, @@ -225,12 +225,12 @@ function materio_flag_editlist_form($type, $fid){ 'message' => t('you do not have rights to edit this '.variable_get('flag_lists_name', 'list')), ); } - + if ($debug) { dsm($rep, 'rep'); return "debug display"; }else{ - drupal_json_output($rep); + drupal_json_output($rep); } } @@ -270,7 +270,7 @@ function materio_flag_edit_list($fid, $name, $title){ } - drupal_json_output($rep); + drupal_json_output($rep); } function materio_flag_delete_list($fid){ @@ -299,15 +299,15 @@ function materio_flag_delete_list($fid){ } $flag = flag_lists_get_flag($name); - - flag_lists_fl_delete($flag); + + flag_lists_fl_delete($flag); $rep = array( 'status' => 'saved', ); } - drupal_json_output($rep); + drupal_json_output($rep); } function materio_flag_nodelinks(){ @@ -324,19 +324,19 @@ function materio_flag_nodelinks(){ "status" => 1, "nids" => $nids, 'links' => $links, - ); + ); }else{ $rep['status'] = 0; } - drupal_json_output($rep); + drupal_json_output($rep); } function materio_flag_user_bookmarks(){ global $user; - + drupal_set_title(t('My bookmarks'), PASS_THROUGH); - + $flaged = flag_get_user_flags('node'); // dsm($flaged, 'flaged'); @@ -363,7 +363,7 @@ function materio_flag_user_bookmarks(){ } } } - + $ret['#items'] = $items; $ret['#theme'] = 'materio_flag_mylists_list'; $ret['#view_mode'] = $viewmode; @@ -397,12 +397,12 @@ function materio_flag_user_lists($fid){ $count = count($flaged_content); $max = $offset+$limit > $count ? $count : $offset+$limit; - for ($i=$offset; $i < $max; $i++) { + for ($i=$offset; $i < $max; $i++) { if($flaged_content[$i]->entity_type == 'node'){ $items[] = node_load($flaged_content[$i]->entity_id); } - } - + } + $ret['#items'] = $items; $ret['#theme'] = 'materio_flag_mylists_list'; $ret['#view_mode'] = $viewmode; @@ -425,9 +425,9 @@ function materio_flag_ajax_list($fid, $page = 0){ $list_path = $path = 'bookmarks'; }else{ $list_path = 'lists'; - $path = $list_path.'/'.$fid; + $path = $list_path.'/'.$fid; } - + // check if request is ajax, if not rediret to search_api_page page with right keys if (!$debug && (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest')) { @@ -462,7 +462,7 @@ function materio_flag_ajax_list($fid, $page = 0){ $return = menu_execute_active_handler($path, FALSE); dsm($return, '$return'); - + if (is_int($return)) { switch ($return) { case MENU_NOT_FOUND : @@ -480,18 +480,18 @@ function materio_flag_ajax_list($fid, $page = 0){ if (is_array($return)) { $rendered = drupal_render($return); } - + $rep = array( 'rendered' => $rendered, 'path' => $path, 'title' => drupal_get_title(), ); - + if ($debug) { dsm($rep, 'rep'); return "debug display"; }else{ - drupal_json_output($rep); + drupal_json_output($rep); } } } \ No newline at end of file From 5d0c233fec5cc492639c94ad0ba08e5ef4022078 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Mon, 28 Apr 2014 17:20:50 +0200 Subject: [PATCH 24/34] bug fixed --- js/materio_flag.js | 9 +++--- js/materio_flag.min.js | 9 +++--- materio_flag.module | 64 +++++++++++++++++++++--------------------- materio_flag.pages.inc | 2 +- 4 files changed, 43 insertions(+), 41 deletions(-) diff --git a/js/materio_flag.js b/js/materio_flag.js index 0a46a595..950183bf 100755 --- a/js/materio_flag.js +++ b/js/materio_flag.js @@ -116,17 +116,18 @@ MaterioFlag = function(){ function refreshBlocks(name){ //trace('MaterioFlag :: refreshBlocks | name', name); - if($('#block-materio-flag-materio-flag-mybookmarks').length){ - var type = 'bookmarks'; - }else if($('#block-materio-flag-materio-flag-mylists').length){ + if($('#block-materio-flag-materio-flag-mylists').length){ var type = 'lists'; + }else if($('#block-materio-flag-materio-flag-mybookmarks').length){ + var type = 'bookmarks'; } + if(type != undefined){ var id = '#block-materio-flag-materio-flag-my'+type; var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/refresh/block/'+type; $.getJSON(url, function(json){ - trace('MaterioFlag :: block refreshed '+type, json); + // trace('MaterioFlag :: block refreshed '+type, json); $(id).replaceWith(json.block); $('#block-materio-flag-materio-flag-mylists-nav').replaceWith(json.block_nav); diff --git a/js/materio_flag.min.js b/js/materio_flag.min.js index 0a46a595..950183bf 100644 --- a/js/materio_flag.min.js +++ b/js/materio_flag.min.js @@ -116,17 +116,18 @@ MaterioFlag = function(){ function refreshBlocks(name){ //trace('MaterioFlag :: refreshBlocks | name', name); - if($('#block-materio-flag-materio-flag-mybookmarks').length){ - var type = 'bookmarks'; - }else if($('#block-materio-flag-materio-flag-mylists').length){ + if($('#block-materio-flag-materio-flag-mylists').length){ var type = 'lists'; + }else if($('#block-materio-flag-materio-flag-mybookmarks').length){ + var type = 'bookmarks'; } + if(type != undefined){ var id = '#block-materio-flag-materio-flag-my'+type; var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/refresh/block/'+type; $.getJSON(url, function(json){ - trace('MaterioFlag :: block refreshed '+type, json); + // trace('MaterioFlag :: block refreshed '+type, json); $(id).replaceWith(json.block); $('#block-materio-flag-materio-flag-mylists-nav').replaceWith(json.block_nav); diff --git a/materio_flag.module b/materio_flag.module index c0db18d4..3da5f9fe 100755 --- a/materio_flag.module +++ b/materio_flag.module @@ -5,7 +5,7 @@ * The Flag bookmark module. * * This module creates a default Flag when enabled. - * + * */ /** @@ -55,14 +55,14 @@ function materio_flag_menu() { 'page callback' => 'materio_flag_createlist_form', 'page arguments' => array(3), ); - + $items['materioflag/editlistform/%/%'] = $base+array( 'access arguments' => array('create flag lists'), 'access callback' => 'user_access', 'page callback' => 'materio_flag_editlist_form', 'page arguments' => array(2,3), ); - + $items['materioflag/editlist/%/%'] = $base+array( 'access arguments' => array('create flag lists'), 'access callback' => 'user_access', @@ -83,7 +83,7 @@ function materio_flag_menu() { 'page callback' => 'materio_flag_nodelinks', // 'page arguments' => array(3), ); - + $items['lists/%'] = $base+array( 'access arguments' => array('view flag lists'), 'access callback' => 'user_access', @@ -121,7 +121,7 @@ function materio_flag_menu_alter(&$items) { * Implements hook_block_info(). */ function materio_flag_block_info() { - + $blocks['materio_flag_mybookmarks'] = array( 'info' => t('My bookmarks'), 'cache' => DRUPAL_NO_CACHE @@ -160,7 +160,7 @@ function materio_flag_block_view($delta = '') { } // TODO: put this title generation on a theme function $subject = ''.t('My bookmarks (@len) ', array("@len"=>count($userbookmarks))).''; - $block['subject'] = $subject . l('', 'bookmarks', array('html'=>true, 'attributes' => array('class' => array('open-list')),)); // + $block['subject'] = $subject . l('', 'bookmarks', array('html'=>true, 'attributes' => array('class' => array('open-list')),)); // $block['content'] = theme('materio_flag_mybookmarks_block', array("bookmarks"=>$userbookmarks, "viewmode"=>"bookmark")); }else{ $block['subject'] = t('My bookmarks'); @@ -175,7 +175,7 @@ function materio_flag_block_view($delta = '') { // $userflags = flag_get_user_flags('node'); // dsm($userflags, 'userflags'); // dsm($flags, 'flags'); - + foreach ($flags as $name => $flag) { $flag->path = url('lists/'.$flag->fid); $flaged_content = flag_lists_get_flagged_content($flag->fid, $user->uid); @@ -222,7 +222,7 @@ function materio_flag_block_view($delta = '') { // if($flags){ // $block['subject'] = t('My !listname'.'s', array('!listname'=>variable_get('flag_lists_name', 'list'))); $block['subject'] = t('My '.variable_get('flag_lists_name', 'list').'s'); - + $block['content'] = theme('materio_flag_mylists_nav_block', array("flags"=>$flags)); // $block['content'] = theme('flag_lists_user_page', array('uid' => $user->uid)); // } @@ -255,7 +255,7 @@ function materio_flag_entity_info_alter(&$entity_info) { function materio_flag_entity_view($entity, $type, $view_mode, $langcode) { if($type == 'node'){ if(user_access('create flag lists') && $view_mode != 'print'){ - + $entity->content['flaglistslinks'] = materio_flag_get_entity_links($entity, $type, $view_mode); drupal_add_css(drupal_get_path('module', 'flag') . '/theme/flag.css'); @@ -268,12 +268,12 @@ function materio_flag_entity_view($entity, $type, $view_mode, $langcode) { foreach ($flags as $flag) { // dsm($flag, 'flag'); if ( ($flag->module == 'flag_lists' && _flag_lists_is_flagged($flag, $entity->nid, $user->uid, 0)) || $flag->is_flagged($entity->nid) ) { - $entity->flags[] = $flag; + $entity->flags[] = $flag; } } } } - + } } } @@ -290,10 +290,10 @@ function materio_flag_get_entity_links($entity, $type, $view_mode = null){ $links = array(); # if flag name is provided we are on flaglists content list (block mylists) if($view_mode == 'bookmark'){ - // TODO: define view mode in settings + // TODO: define view mode in settings // if (isset($entity->flag_names) && $flags = flag_lists_get_user_flags($entity->type, $user)) { // // dsm($flags, 'flags'); - // // TODO: limit flag link by current flag list + // // TODO: limit flag link by current flag list // foreach ($flags as $flag) { // //dsm($flag->name, 'flag'); // if(in_array($flag->name, $entity->flag_names)){ @@ -301,7 +301,7 @@ function materio_flag_get_entity_links($entity, $type, $view_mode = null){ // $action = _flag_lists_is_flagged($flag, $entity->nid, $user->uid, 0) ? 'unflag' : 'flag'; // } else { // $action = $flag->is_flagged($entity->nid) ? 'unflag' : 'flag'; - // } + // } // $flag->module = 'materio_flag'; // $link = $flag->theme($action, $entity->nid); @@ -349,12 +349,12 @@ function materio_flag_get_entity_links($entity, $type, $view_mode = null){ } } - + // dsm($items, 'items '.$entity->title); #create new list $link = l( - ' ' . t('New @name', array('@name' => t(variable_get('flag_lists_name', 'list')))) . '', + ' ' . t('New @name', array('@name' => t(variable_get('flag_lists_name', 'list')))) . '', 'flag-lists/add/' . $entity->type, array( 'attributes' => array( @@ -366,7 +366,7 @@ function materio_flag_get_entity_links($entity, $type, $view_mode = null){ 'html' => TRUE, ) ); - + $create = array( 'data' => $link, 'class' => array('flag-lists-create'), @@ -375,15 +375,15 @@ function materio_flag_get_entity_links($entity, $type, $view_mode = null){ if(isset($items)){ $ops = array( - '#node' => $entity, + '#node' => $entity, '#items' => $items, ); } - - if(isset($create)){ + + if(isset($create)){ $ops['#create'] = $create; } - + if(isset($ops)){ // dsm($ops, 'ops'); drupal_add_js(drupal_get_path('module', 'materio_flag').'/js/materio_flag.min.js'); @@ -397,19 +397,19 @@ function materio_flag_get_entity_links($entity, $type, $view_mode = null){ function _materio_flag_get_listpagetitle($flag){ $cont = ''; $cont .= ''.check_plain($flag->title).''; - + if(flag_lists_is_owner('edit', $flag->fid)){ - - $cont .= l('', - 'flags/lists/edit/'.$flag->fid, + + $cont .= l('', + 'flags/lists/edit/'.$flag->fid, array( 'html'=>true, 'attributes'=>array('class'=>array('edit-list', $flag->name)), ) - ); + ); } - - + + return $cont; } @@ -468,11 +468,11 @@ function template_preprocess_materio_flag_mylists_nav_block(&$vars){ /** * theme_materio_flag_mylists_entity_links() - * + * * see theme_flag_lists_list() */ function theme_materio_flag_mylists_entity_links($vars){ - + // $node = $vars['node']; $items = $vars['items']; @@ -480,13 +480,13 @@ function theme_materio_flag_mylists_entity_links($vars){ if(isset($vars['create'])) $items[] = $vars['create']; - + return theme('item_list', array('items' => $items, 'type' => 'ul', 'attributes' => array('class' => 'flag-lists-entity-links'))); } function template_preprocess_materio_flag_mylists_list(&$vars) { - + $vars['list_count'] = format_plural( $vars['count'], '@name @title contains 1 item.', // in @sec seconds diff --git a/materio_flag.pages.inc b/materio_flag.pages.inc index 58e8544e..1546c401 100755 --- a/materio_flag.pages.inc +++ b/materio_flag.pages.inc @@ -19,7 +19,7 @@ function materio_flag_refresh_block($flag){ if(!isset($block_name)) return; - $rep = array(); + $rep = array("flag"=>$flag); $block = block_load('materio_flag', $block_name); $block_content = _block_render_blocks(array($block)); From 748548f8f4acf5c31e61dd468271e152f0021b30 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Wed, 30 Apr 2014 10:41:24 +0200 Subject: [PATCH 25/34] cleaned file --- materio_search_api.module | 80 +++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/materio_search_api.module b/materio_search_api.module index 739f4013..e58075c3 100755 --- a/materio_search_api.module +++ b/materio_search_api.module @@ -101,7 +101,7 @@ function materio_search_api_access_search(){ /** -* - - - - - - - - - - - - SOLR - - - - - - - - - - - - +* - - - - - - - - - - - - SOLR - - - - - - - - - - - - */ /** @@ -148,18 +148,18 @@ function materio_search_api_search_api_solr_dynamic_field_info() { /** * hook_entity_property_info_alter(). - * + * * define own fields * - main taxonomy terms, the purpose is to be able to attribute differente boost on serach api depending on term order * - companies infos (address) : retrieve for materiau content type the companie info from the tode node - * + * */ function materio_search_api_entity_property_info_alter(&$info){ // dsm($info, 'hook_entity_property_info_alter | info'); // watchdog('materio solr', 'materio_search_api_entity_property_info_alter', array()); $node_props = &$info['node']['properties']; - - for ($i=1; $i <= 5 ; $i++) { + + for ($i=1; $i <= 5 ; $i++) { $node_props['materio_search_api_onthologie_term_'.$i.'_text'] = array( 'type'=>'text', 'label'=> t('Main onthologie term '.$i. ' as text (+ synonyms)'), @@ -198,9 +198,9 @@ function materio_search_api_entity_property_info_alter(&$info){ $term_props = &$info['taxonomy_term']['properties']; $term_props['materio_search_api_term_property_dup_name'] = array( - 'label' => t("Term name field dup"), - 'description' => t("Duplicate the term name field to apply different filter in solr (remove accents for instance)"), - 'type' => 'text', + 'label' => t("Term name field dup"), + 'description' => t("Duplicate the term name field to apply different filter in solr (remove accents for instance)"), + 'type' => 'text', 'getter callback' => 'materio_search_api_term_property_dup_name', ); @@ -252,7 +252,7 @@ function materio_search_api_get_taglibres_terms_text($item){ function materio_search_api_get_taxo_term_field_text($item, $field_name, $delta){ // dsm($item, 'item'); // dsm($delta, 'delta'); - + if(isset($item->{$field_name}['und'][$delta])){ // print '** item **'."\n"; // print_r($item); @@ -282,7 +282,7 @@ function materio_search_api_get_taxo_term_field_text($item, $field_name, $delta) return implode(" ", $keywords); } - + return null; } @@ -290,7 +290,7 @@ function materio_search_api_get_taxo_term_field_text($item, $field_name, $delta) function materio_search_api_get_node_propertie_companie($item){ // dsm($item, '$item'); $lang = "fr";//$item->language; - + $languages = language_list(); global $language; $language = $languages[$lang]; @@ -312,7 +312,7 @@ function materio_search_api_get_node_propertie_companie($item){ $delta++; } } - + return $cies; } @@ -326,19 +326,19 @@ function company_get_tode_node($term){ return false; } -function rip_tags($string) { - // ----- remove HTML TAGs ----- - $string = preg_replace ('/<[^>]*>/', ' ', $string); - - // ----- remove control characters ----- +function rip_tags($string) { + // ----- remove HTML TAGs ----- + $string = preg_replace ('/<[^>]*>/', ' ', $string); + + // ----- remove control characters ----- $string = str_replace("\r", '', $string); // --- replace with empty space $string = str_replace("\n", ' ', $string); // --- replace with space $string = str_replace("\t", ' ', $string); // --- replace with space - + // $string = str_replace(" ", ' ', $string); // --- replace with space // $string = str_replace("'", '\'', $string); // --- replace with space - // ----- remove multiple spaces ----- + // ----- remove multiple spaces ----- $string = trim(preg_replace('/ {2,}/', ' ', $string)); // ----- remove html entities @@ -346,7 +346,7 @@ function rip_tags($string) { foreach ($entities[0] as $entity) { $string = str_replace($entity, mb_convert_encoding($entity, 'UTF-8', 'HTML-ENTITIES'), $string); } - + return $string; } @@ -360,8 +360,8 @@ function materio_search_api_term_property_dup_name($term){ /** - * - - -- - - - - - - blocks - - - - - - - - - - - - * + * - - -- - - - - - - blocks - - - - - - - - - - - + * */ /** @@ -378,7 +378,7 @@ function materio_search_api_block_info() { 'info' => t('Materio search api view mode selection'), 'cache' => DRUPAL_NO_CACHE ); - + // $blocks['materio_search_api_filters'] = array( // 'info' => t('Materio search api filters'), // 'cache' => DRUPAL_NO_CACHE @@ -426,12 +426,12 @@ function materio_search_api_entity_info_alter(&$entity_info) { 'label' => t('Small cards'), 'custom settings' => TRUE, ); - + $entity_info['node']['view modes']['cardmedium'] = array( 'label' => t('Medium cards'), 'custom settings' => TRUE, ); - + $entity_info['node']['view modes']['cardbig'] = array( 'label' => t('Big cards'), 'custom settings' => TRUE, @@ -455,7 +455,7 @@ function materio_search_api_node_view_alter(&$build) { // dsm($viewmode, 'viewmode'); $node = $build['#node']; if($build['#view_mode'] != $viewmode && $build['#view_mode'] != "bookmark" & in_array($node->type, array('breve', 'materiau'))){ - $build = node_view($node, $viewmode); + $build = node_view($node, $viewmode); } } } @@ -502,7 +502,7 @@ function materio_search_api_search_form($form, &$form_state){ $form['searchfield'] = array( '#type' => 'textfield', - '#default_value' => $path == 'explore' ? $keys : $default_value, // TODO: set the search page path global or a variable in settings + '#default_value' => $path == 'explore' ? $keys : $default_value, // TODO: set the search page path global or a variable in settings // '#value' => $keys, '#autocomplete_path' => 'materiosearchapi/autocomplete/searchapi', //'#autocomplete_path' => 'materiosearchapi/autocomplete/dbselect', @@ -512,15 +512,15 @@ function materio_search_api_search_form($form, &$form_state){ ); if(user_access('use materio search api filters')){ - + $index = search_api_index_load(variable_get('mainsearchindex', -1)); $indexed_bundles = $index->options['data_alter_callbacks']['search_api_alter_bundle_filter']['settings']['bundles']; - + foreach ($indexed_bundles as $bundle) { $bundles_options[$bundle] = $bundle; $default_bundles[] = $bundle; } - + $user_bundles_filter = isset($user->data['materiosearchapi_bundlesfilter']) ? $user->data['materiosearchapi_bundlesfilter'] : $default_bundles; $form['bundles_filter'] = array( @@ -530,7 +530,7 @@ function materio_search_api_search_form($form, &$form_state){ // '#attributes' => array('class'=>array('btn-group')), ); } - + $form['create'] = array( '#type' => 'image_button', '#src' => drupal_get_path('module', 'materio_search_api') . '/images/search.png', @@ -564,7 +564,7 @@ function materio_search_api_search_form_submit($form, &$form_state){ # if user have no access to filters $index = search_api_index_load(variable_get('mainsearchindex', -1)); $indexed_bundles = $index->options['data_alter_callbacks']['search_api_alter_bundle_filter']['settings']['bundles']; - + foreach ($indexed_bundles as $bundle) { $bundles[] = $bundle; } @@ -600,7 +600,7 @@ function _materio_search_api_change_viewmode($vm){ } /** -* - - - - - - - - - - - - THEME - - - - - - - - - - - - +* - - - - - - - - - - - - THEME - - - - - - - - - - - - */ /** @@ -624,7 +624,7 @@ function materio_search_api_theme($existing, $type, $theme, $path) { // 'path' => drupal_get_path('module', 'materio_search_api').'/templates', // ), 'materio_search_api_results' => array( - 'arguments' => array(), + 'arguments' => array(), 'template' => 'materio-search-api-results', 'path' => drupal_get_path('module', 'materio_search_api').'/templates', 'variables' => array( @@ -683,7 +683,7 @@ function template_preprocess_materio_search_api_select_viewmode_block(&$vars){ $entity_infos = entity_get_info(); // dsm($entity_infos, 'entity_infos'); - + $content = '
'; foreach ($entity_infos['node']['view modes'] as $viewmode => $value) { if(in_array($viewmode, $availableviewmodes)){ @@ -720,9 +720,9 @@ function template_preprocess_materio_search_api_select_viewmode_block(&$vars){ // // $entity_infos = entity_get_info($index->item_type); // // dsm($entity_infos, 'entity_infos'); // $indexed_bundles = $index->options['data_alter_callbacks']['search_api_alter_bundle_filter']['settings']['bundles']; - + // dsm($indexed_bundles, 'indexed_bundles'); - + // $vars['content'] = drupal_get_form('materio_search_api_filters_form', $indexed_bundles); // } @@ -762,7 +762,7 @@ function template_preprocess_materio_search_api_results(array &$variables) { // $variables['items'] = $variables['index']->loadItems(array_keys($variables['results']['results'])); $variables['result_count'] = $results['result count']; $variables['sec'] = round($results['performance']['complete'], 3); - + if(isset($results['breves count'])){ $variables['search_performance'] = format_plural( $results['breves count'], @@ -802,7 +802,7 @@ function template_preprocess_materio_search_api_actuality(&$vars){ } /** -* - - - - - - - - - - - - SEARCH API PAGE - - - - - - - - - - - - +* - - - - - - - - - - - - SEARCH API PAGE - - - - - - - - - - - - */ /** @@ -813,7 +813,7 @@ function materio_search_api_block_view_alter(&$data, $block) { if ($block->module == 'search_api_page') { $page = search_api_page_load($block->delta); $item = menu_get_item(); - + if (isset($page->path) && $page->path == $item['path']) { $keys = arg(count(arg(NULL, $page->path))); if ($keys) { From c4d8c34e1a8657b09775938424ccbd32dd2a2e15 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Wed, 30 Apr 2014 10:41:52 +0200 Subject: [PATCH 26/34] Viewmode block restrict display on node page for materiau and breve --- materio_search_api.module | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/materio_search_api.module b/materio_search_api.module index e58075c3..aad042d1 100755 --- a/materio_search_api.module +++ b/materio_search_api.module @@ -403,7 +403,16 @@ function materio_search_api_block_view($delta = '') { } break; case 'materio_search_api_viewmode': - if (user_access('use materio search api viewmode selection')) { + // restrict display on node page for materiau and breve + $block_is_visible = true; + $q = parse_url($_GET['q']); + $parts = explode('/', $q['path']); + if($parts[0] == "node"){ + $node = node_load($parts[1]); + $block_is_visible = in_array($node->type, array('materiau','breve')) ? true : false; + } + + if (user_access('use materio search api viewmode selection') && $block_is_visible) { $block['subject'] = t('View mode'); $block['content'] = theme('materio_search_api_select_viewmode_block', array()); } From e2183f0a0dd73692431833081a41a48be7220bd7 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Tue, 1 Jul 2014 18:15:47 +0200 Subject: [PATCH 27/34] fixed viewmode block visibility depending on permission as before but also on node type visible only with materiaux and breves --- materio_search_api_ajax.module | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/materio_search_api_ajax.module b/materio_search_api_ajax.module index 5e8c1b97..68ded5fe 100755 --- a/materio_search_api_ajax.module +++ b/materio_search_api_ajax.module @@ -15,7 +15,7 @@ function materio_search_api_ajax_init() { if (module_exists('locale')) { $languages = language_list('enabled'); } - + drupal_add_js(array('materio_search_api_ajax' => array( 'module_path' => drupal_get_path('module', 'materio_search_api_ajax'), // 'strings'=>array( @@ -51,7 +51,7 @@ function materio_search_api_ajax_menu() { 'page argument' => array(3), 'access arguments' => array('use materio search api viewmode selection'), ); - + $items['materio_search_api_ajax/actuality'] = $base+array( 'page callback' => 'materio_search_api_ajax_actuality', 'access callback' => TRUE, From 9df43555ac7e35dae6c95cf2c35cbff19abb1508 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Wed, 2 Jul 2014 16:24:54 +0200 Subject: [PATCH 28/34] restrict access to materials descriptions for free users --- materio_display.info | 23 +++++++++++++++++ materio_display.module | 58 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 materio_display.info create mode 100644 materio_display.module diff --git a/materio_display.info b/materio_display.info new file mode 100644 index 00000000..7fb5b0d1 --- /dev/null +++ b/materio_display.info @@ -0,0 +1,23 @@ +name = Materio Display +description = "Materio display module (permissions, ...)" + +; Core version (required) +core = 7.x + +; Package name (see http://drupal.org/node/542202 for a list of names) +package = Materio + +; PHP version requirement (optional) +; php = 5.2 + +; Loadable code files +; files[] = materio_ctools_automodal.module + +; Module dependencies +; dependencies[] = user + +; Configuration page +; configure = admin/config/materiobasemod + +; For further information about configuration options, see +; - http://drupal.org/node/542202 diff --git a/materio_display.module b/materio_display.module new file mode 100644 index 00000000..34526572 --- /dev/null +++ b/materio_display.module @@ -0,0 +1,58 @@ + array( + 'title' => t('view full materiau description'), + 'description' => t('view full materiau description'), + ), + ); +} + +/** + * Implements hook_preprocess(). + */ +function materio_display_preprocess_field(&$vars, $hook) { + // dsm($vars); + $element = $vars['element']; + + if($element['#field_name'] == 'field_description'){ + dsm($vars); + if(!user_access('view full materiau description')){ + $value = $element['#items'][0]['value']; + + switch ($element['#view_mode']) { + case 'cardbig': + case 'cardfull': + $limit = 210; + break; + default: + $limit = 130; + break; + } + $summary = truncate_utf8($value, $limit, TRUE, TRUE); + + $summary .= '

' + . t("In order to access full description, information about manufacturers and more, you need to upgrade your account.") + . l(t("Pricing"), 'node/11187') + . '

'; + + // dsm($summary); + $vars['items'][0]['#markup'] = $summary; + + } + } + +} \ No newline at end of file From 5b26e363553592ddb547abae53155fec1a53b17b Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Wed, 2 Jul 2014 18:21:39 +0200 Subject: [PATCH 29/34] highlighted the FOUND X RESULTS sentence --- materio_search_api.module | 51 +++++++++++++------- materio_search_api.pages.inc | 44 ++++++++--------- templates/materio-search-api-results.tpl.php | 14 +++++- 3 files changed, 67 insertions(+), 42 deletions(-) diff --git a/materio_search_api.module b/materio_search_api.module index aad042d1..81b17889 100755 --- a/materio_search_api.module +++ b/materio_search_api.module @@ -763,43 +763,58 @@ function template_preprocess_materio_search_api_select_viewmode_block(&$vars){ * * @see materio-search-api-results.tpl.php */ -function template_preprocess_materio_search_api_results(array &$variables) { - // dsm($variables, '$variables'); - $results = $variables['results']; - $keys = $variables['keys']; +function template_preprocess_materio_search_api_results(array &$vars) { + // dsm($vars, '$vars'); + $results = $vars['results']; + $keys = $vars['keys']; - // $variables['items'] = $variables['index']->loadItems(array_keys($variables['results']['results'])); - $variables['result_count'] = $results['result count']; - $variables['sec'] = round($results['performance']['complete'], 3); + // $vars['items'] = $vars['index']->loadItems(array_keys($vars['results']['results'])); + $vars['result_count'] = $results['result count']; + $vars['sec'] = round($results['performance']['complete'], 3); + + $vars['keywords'] = implode(', ', $vars['keys']); if(isset($results['breves count'])){ - $variables['search_performance'] = format_plural( + $vars['perfascard'] = true; + $vars['search_performance'] = format_plural( $results['breves count'], 'The search found 1 news ', 'The search found @count news ' ); - $variables['search_performance'] .= format_plural( - $variables['result_count'] - $results['breves count'], + $vars['search_performance'] .= format_plural( + $vars['result_count'] - $results['breves count'], 'with 1 associated matter.', 'with @count associated matters.' ); - $variables['search_performance'] .= format_plural( + $vars['search_performance'] .= format_plural( $results['could results']['result count'], ' You could find 1 result with a ', ' You could find @count results with a ' ); - $variables['search_performance'] .= l(t('full access to materiO\'.'), 'node/11187'); + $vars['search_performance'] .= l(t('full access to materiO\'.'), 'node/11187'); + + $vars['search_performance'] .= l(t('pricing'), 'node/11187', array("attributes"=>array("class"=>array('button')))); }else{ - $variables['search_performance'] = format_plural( - // $results['result count'], - $variables['result_count'], - 'The search found 1 result.', - 'The search found @count results.' + $vars['perfascard'] = false; + + // $vars['search_performance'] = format_plural( + // // $results['result count'], + // $vars['result_count'], + // 'The search found 1 result ', + // 'The search found @count results ' + // ) + + $vars['search_performance'] = t('The search found @count result(s) with keywords @keys. @mat materials and @new news.', array( + "@count"=>$vars['result_count'], + "@keys"=>$vars['keywords'], + "@mat"=>4, + "@new"=>7) ); + } - //dsm($variables, 'variables'); + //dsm($vars, '$vars'); } diff --git a/materio_search_api.pages.inc b/materio_search_api.pages.inc index 791ae860..0bf83273 100755 --- a/materio_search_api.pages.inc +++ b/materio_search_api.pages.inc @@ -2,22 +2,22 @@ /** * materiobase_search_autocomplete_dbselect() - * + * * inspired by taxonomy_autocomplete() - * + * * OBSOLETE : this fonction use a direct dbselect request to provide results forautocomplete - * + * */ function materio_search_api_autocomplete_dbselect($typed = ''){ // If the request has a '/' in the search text, then the menu system will have // split it into multiple arguments, recover the intended $tags_typed. $args = func_get_args(); $typed = implode('/', $args); - + /* TODO riche serach engine + \\ etc gmail like */ - + if ($typed != '') { // Part of the criteria for the query come from the field's own settings. @@ -56,7 +56,7 @@ function materio_search_api_autocomplete_dbselect($typed = ''){ /** * materio_search_api_autocomplete_searchapi($typed = '') -* +* * GOOD one using searchapi (SOLR) */ function materio_search_api_autocomplete_searchapi($typed = ''){ @@ -64,7 +64,7 @@ function materio_search_api_autocomplete_searchapi($typed = ''){ // split it into multiple arguments, recover the intended $tags_typed. $args = func_get_args(); $typed = implode('/', $args); - + // dsm($typed, 'typed'); if ($typed != '') { @@ -78,7 +78,7 @@ function materio_search_api_autocomplete_searchapi($typed = ''){ global $language; $index_machine_name = variable_get('autocompletesearchindex_'.$language->language, -1); $query = search_api_query($index_machine_name); - + // $query_filter = $query->createFilter(); // $query_filter->condition('name', $tosearch); // $query_filter->condition('type', 'article'); @@ -96,14 +96,14 @@ function materio_search_api_autocomplete_searchapi($typed = ''){ //dsm($item, '$item'); //$term_matches[$item->tid] = check_plain($item->name); // $term_matches[check_plain($item->name)] = check_plain($item->name); - // TODO: leave tags with nodes + // TODO: leave tags with nodes $term_matches[ trim(implode(' ', $adv_search_q[0]).' '.$last[1].$item->name)] = check_plain($item->name); $delta++; if($delta > 15) break; - } - drupal_json_output($term_matches); + } + drupal_json_output($term_matches); }else{ drupal_json_output(array()); } @@ -111,15 +111,15 @@ function materio_search_api_autocomplete_searchapi($typed = ''){ return; } - + // dsm($term_matches, 'term_matches'); // return 'debug mode of materio_search_api_autocomplete_searchapi'; } /** * materio_search_api_results_search() -* -* +* +* */ function materio_search_api_results_search(){ global $user; @@ -138,11 +138,11 @@ function materio_search_api_results_search(){ // else{ // $page = 0; // } - + preg_match_all('/\s?[^\s]+\s?/', $typed, $words); // dsm($words, "words"); - + // $match = array('\\', '+', '-', '&', '|', '!', '(', ')', '{', '}', '[', ']', '^', '~', '*', '?', ':', '"', ';', ' '); // $replace = array('\\\\', '\\+', '\\-', '\\&', '\\|', '\\!', '\\(', '\\)', '\\{', '\\}', '\\[', '\\]', '\\^', '\\~', '\\*', '\\?', '\\:', '\\"', '\\;', '\\ '); foreach ($words[0] as $word) { @@ -197,7 +197,7 @@ function materio_search_api_results_search(){ // dsm($viewmode, 'viewmode'); if ($keys) { - // TODO: cache the results with cache graceful : http://drupal.org/project/cache_graceful + // TODO: cache the results with cache graceful : http://drupal.org/project/cache_graceful try { $limit = variable_get($viewmode.'_limite', '10'); $offset = pager_find_page() * $limit; //$page*$limit;// @@ -244,7 +244,7 @@ function materio_search_api_results_search(){ // $results['results'] = $accessible_results; // $results['result count'] = count($accessible_results); - + if(user_access('use materio search api')){ $items = $index->loadItems(array_keys($results['results'])); @@ -296,7 +296,7 @@ function materio_search_api_results_search(){ if (!empty($results['ignored'])) { drupal_set_message( - t('The following search keys are too short or too common and were therefore ignored: "@list".', + t('The following search keys are too short or too common and were therefore ignored: "@list".', array( '@list' => implode(t('", "'), $results['ignored']) ) ), 'warning' ); @@ -320,7 +320,7 @@ function materio_search_api_actuality(){ global $user; if(isset($user->roles[1])){ - $date_limit = strtotime('-6 month'); + $date_limit = strtotime('-6 month'); // dsm(date('d m y', $date_limit)); } @@ -361,7 +361,7 @@ function materio_search_api_actuality(){ if(isset($result['node'])){ foreach ($result['node'] as $nid => $n) { $breve = node_load($nid); - + if(!node_access('view', $breve)) continue; @@ -377,7 +377,7 @@ function materio_search_api_actuality(){ } } } - + // drupal_set_title(t('Actualities')); drupal_set_title(t('')); diff --git a/templates/materio-search-api-results.tpl.php b/templates/materio-search-api-results.tpl.php index 0dd3f011..aef05f00 100755 --- a/templates/materio-search-api-results.tpl.php +++ b/templates/materio-search-api-results.tpl.php @@ -38,11 +38,21 @@
-

+ +

+
+ +
+
+ +

+
+
+ - item_type, $items, $variables['view_mode'])); ?> From 1eb8bb9de827837ae7bd5321c5c4e032004c4587 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Wed, 2 Jul 2014 18:24:34 +0200 Subject: [PATCH 30/34] change pricing to Pricing --- materio_search_api.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/materio_search_api.module b/materio_search_api.module index 81b17889..78029017 100755 --- a/materio_search_api.module +++ b/materio_search_api.module @@ -793,7 +793,7 @@ function template_preprocess_materio_search_api_results(array &$vars) { ); $vars['search_performance'] .= l(t('full access to materiO\'.'), 'node/11187'); - $vars['search_performance'] .= l(t('pricing'), 'node/11187', array("attributes"=>array("class"=>array('button')))); + $vars['search_performance'] .= l(t('Pricing'), 'node/11187', array("attributes"=>array("class"=>array('button')))); }else{ $vars['perfascard'] = false; From f881f8b6386479e2665393481ab0f736e790d3b4 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Thu, 3 Jul 2014 16:13:44 +0200 Subject: [PATCH 31/34] fixed mispelling --- materio_search_api.module | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/materio_search_api.module b/materio_search_api.module index 78029017..1132d256 100755 --- a/materio_search_api.module +++ b/materio_search_api.module @@ -788,8 +788,8 @@ function template_preprocess_materio_search_api_results(array &$vars) { ); $vars['search_performance'] .= format_plural( $results['could results']['result count'], - ' You could find 1 result with a ', - ' You could find @count results with a ' + ' You could have found 1 result with a ', + ' You could have found @count results with a ' ); $vars['search_performance'] .= l(t('full access to materiO\'.'), 'node/11187'); From 0c711448333575dbdff797a2ef8339cc07f500b9 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Thu, 3 Jul 2014 17:27:36 +0200 Subject: [PATCH 32/34] disabled submit on registration to avoid duplicate account creation --- js/materio_user.js | 30 ++++++++++++++++++++++-------- js/materio_user.min.js | 30 ++++++++++++++++++++++-------- materio_user.module | 40 ++++++++++++++++++++-------------------- materio_user.pages.inc | 8 ++++---- 4 files changed, 68 insertions(+), 40 deletions(-) diff --git a/js/materio_user.js b/js/materio_user.js index f7f92c40..c83806b1 100755 --- a/js/materio_user.js +++ b/js/materio_user.js @@ -4,7 +4,7 @@ (function($) { MaterioUser = function(){ - + var _isAdhesion = $('body').is('.page-node-11187') || $('body').is('.page-node-11186'); function init() { @@ -17,7 +17,7 @@ MaterioUser = function(){ // trace('initAdhesion'); $('.get-link a').bind('click', function(event) { // trace('get-link click'); - + // do not show the registration form if already logged-in if($('body').is('.logged-in')) return true; @@ -29,7 +29,7 @@ MaterioUser = function(){ href = $this.attr("href"), destination = href.match('/\?destination=([^,]+)'); - destination = "/" + destination[1].replace('%23', '#'); + destination = "/" + destination[1].replace('%23', '#'); destination = destination.replace('//', '/'); // trace('destination', destination); @@ -55,7 +55,7 @@ MaterioUser = function(){ function formLoaded(json, destination){ //trace('formLoaded | json', json); var $modal = $('
').addClass('modal-content').append(json.block); - + var id,label, description; $('input.form-text', $modal).each(function(i) { id = $(this).attr('id'); @@ -83,11 +83,16 @@ MaterioUser = function(){ $("#user-register-form #edit-submit, #user-register-form #edit-submit--2", $modal).click(function(event){ event.preventDefault(); + + // disable submit button to avoid duplicate user creation + // console.log('click', this); + $(this).attr('disabled', 'true'); + $.ajax({ type: 'POST', dataType:'json', url: Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/register/submit", - data: $('#user-register-form', $modal).serialize(), + data: $('#user-register-form', $modal).serialize(), success: function(data) { onUserLoginRegisterSubmit($('#user-register-form'), data, destination);}, error: function() {trace('error');} }); @@ -100,14 +105,14 @@ MaterioUser = function(){ type: 'POST', dataType:'json', url: Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/login/submit", - data: $('#user-login', $modal).serialize(), + data: $('#user-login', $modal).serialize(), success: function(data){ onUserLoginRegisterSubmit($('#user-login'), data, destination); }, error: function() { trace('error'); } }); return false; }); - // google analytics + // google analytics // $.event.trigger({ // type : "record-stat", // categorie : 'Search', @@ -120,12 +125,21 @@ MaterioUser = function(){ }; function onUserLoginRegisterSubmit($form, data, destination){ + // console.log('data', data); cleanModalErrors(); if(data.errors != null){ for(field in data.errors){ $('input[name='+field+']', $form).addClass('error'); $form.prepend($('
').addClass('message-error').html(data.errors[field])); } + + (function($form){ + setTimeout(function(){ + console.log('enabled'); + $('input[type=submit]', $form).removeAttr('disabled'); + }, 0.5*1000); + })($form); + }else{ // trace('destination = '+destination); window.location.pathname = destination; @@ -143,5 +157,5 @@ MaterioUser = function(){ $(document).ready(function() { var materiouser = new MaterioUser(); }); - + })(jQuery); \ No newline at end of file diff --git a/js/materio_user.min.js b/js/materio_user.min.js index 400f414a..fa4344c0 100755 --- a/js/materio_user.min.js +++ b/js/materio_user.min.js @@ -374,7 +374,7 @@ function getElementAngle(x1, y1, x2, y2) { (function($) { MaterioUser = function(){ - + var _isAdhesion = $('body').is('.page-node-11187') || $('body').is('.page-node-11186'); function init() { @@ -387,7 +387,7 @@ MaterioUser = function(){ // trace('initAdhesion'); $('.get-link a').bind('click', function(event) { // trace('get-link click'); - + // do not show the registration form if already logged-in if($('body').is('.logged-in')) return true; @@ -399,7 +399,7 @@ MaterioUser = function(){ href = $this.attr("href"), destination = href.match('/\?destination=([^,]+)'); - destination = "/" + destination[1].replace('%23', '#'); + destination = "/" + destination[1].replace('%23', '#'); destination = destination.replace('//', '/'); // trace('destination', destination); @@ -425,7 +425,7 @@ MaterioUser = function(){ function formLoaded(json, destination){ //trace('formLoaded | json', json); var $modal = $('
').addClass('modal-content').append(json.block); - + var id,label, description; $('input.form-text', $modal).each(function(i) { id = $(this).attr('id'); @@ -453,11 +453,16 @@ MaterioUser = function(){ $("#user-register-form #edit-submit, #user-register-form #edit-submit--2", $modal).click(function(event){ event.preventDefault(); + + // disable submit button to avoid duplicate user creation + // console.log('click', this); + $(this).attr('disabled', 'true'); + $.ajax({ type: 'POST', dataType:'json', url: Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/register/submit", - data: $('#user-register-form', $modal).serialize(), + data: $('#user-register-form', $modal).serialize(), success: function(data) { onUserLoginRegisterSubmit($('#user-register-form'), data, destination);}, error: function() {trace('error');} }); @@ -470,14 +475,14 @@ MaterioUser = function(){ type: 'POST', dataType:'json', url: Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/login/submit", - data: $('#user-login', $modal).serialize(), + data: $('#user-login', $modal).serialize(), success: function(data){ onUserLoginRegisterSubmit($('#user-login'), data, destination); }, error: function() { trace('error'); } }); return false; }); - // google analytics + // google analytics // $.event.trigger({ // type : "record-stat", // categorie : 'Search', @@ -490,12 +495,21 @@ MaterioUser = function(){ }; function onUserLoginRegisterSubmit($form, data, destination){ + // console.log('data', data); cleanModalErrors(); if(data.errors != null){ for(field in data.errors){ $('input[name='+field+']', $form).addClass('error'); $form.prepend($('
').addClass('message-error').html(data.errors[field])); } + + (function($form){ + setTimeout(function(){ + console.log('enabled'); + $('input[type=submit]', $form).removeAttr('disabled'); + }, 0.5*1000); + })($form); + }else{ // trace('destination = '+destination); window.location.pathname = destination; @@ -513,5 +527,5 @@ MaterioUser = function(){ $(document).ready(function() { var materiouser = new MaterioUser(); }); - + })(jQuery); \ No newline at end of file diff --git a/materio_user.module b/materio_user.module index 499fcd7a..0a2f5ece 100755 --- a/materio_user.module +++ b/materio_user.module @@ -1,4 +1,4 @@ -roles[6]) || isset($user->roles[8])) && $user->created < strtotime('01-12-2012') ){ // dsm($user, 'user'); $block['subject'] = ''; - + $path = 'http://base.materio.com'; - + if($language->language == 'fr') $path .= '/index_fr.html'; @@ -157,7 +157,7 @@ function materio_user_form_alter(&$form, &$form_state, $form_id) { // dsm($form); $form['account']['pass']['#type'] = 'password'; $form['account']['pass']['#title'] = t('Password'); - + $form['actions']['#type'] = "container"; $form['actions']['submit']['#value'] = t('Join'); @@ -172,12 +172,12 @@ function materio_user_form_alter(&$form, &$form_state, $form_id) { } if($form_id == "user_login" ){ // dsm($form); - + $form['actions']['#type'] = "container"; // $form['actions']['submit']['#value'] = t('Join'); // if( $_GET['q'] == 'node/11187' ){ - // $form['#submit'][] = "materio_user_user_login_form_submit"; + // $form['#submit'][] = "materio_user_user_login_form_submit"; // } } @@ -209,7 +209,7 @@ function materio_user_form_alter(&$form, &$form_state, $form_id) { // 'fragment' => $_GET['q'] == 'node/11187' ? 'content-bottom' : '', // if we register from the membership page, then go directly to the form // ) // ); - + // $frontlink = l('continue with basic', ''); // // drupal_get_messages('status'); // drupal_set_message(t('Welcome, you just join materiO\'! now you can choose the membership that\'s right for you, or !link', array('!link'=>$frontlink))); @@ -241,13 +241,13 @@ function materio_user_webform_client_111186_validate($form, &$form_state){ // TODO : tester si les email ne sont pas deja inscrit sur le site - form_set_error($field_name, t('You must provide a value for the !name field.', array('!name'=>$human_field_name))); + form_set_error($field_name, t('You must provide a value for the !name field.', array('!name'=>$human_field_name))); } } } - - } + + } } // function materio_user_webform_client_111186_submit($form, &$form_state){ @@ -263,7 +263,7 @@ function materio_user_webform_client_111186_validate($form, &$form_state){ // // $field_name = 'submitted][collaborators]['.$coll_key.']['.$field_key; // // // dsm($field_name, 'field_name'); -// // form_set_error($field_name, t('You must provide a value for the !name field.', array('!name'=>$human_field_name))); +// // form_set_error($field_name, t('You must provide a value for the !name field.', array('!name'=>$human_field_name))); // // } // // } // $userinfo = array( @@ -281,9 +281,9 @@ function materio_user_webform_client_111186_validate($form, &$form_state){ // // module_invoke_all('user_insert', $edit, $account); // $i++; // } - -// } + +// } // enregistrer le type d'adonnement chez les user @@ -299,7 +299,7 @@ function materio_user_help($path, $arg) { if($arg[1] == 11187 ){ global $user; // dsm($user, 'user'); - + if(isset($user->roles[1])){ // anonyme $message = t('Please create first a free account and join materio or log in with your existing account,
then we\'ll provide you our membership form.', array()); $content = '

' . $message . '

'; @@ -340,16 +340,16 @@ function _materio_user_user_update(&$edit, $account, $category){ // dsm($edit, 'edit'); // dsm($account, 'account'); // dsm($category, 'category'); - + // This is only fired when a user confirms their email address, logintoboggan style - if (isset($account->logintoboggan_email_validated) && $account->logintoboggan_email_validated == TRUE) { - $confirmed_rid = materio_user_get_role_by_name(MATERIO_USER_CONFIRMED_USER_ROLE); + if (isset($account->logintoboggan_email_validated) && $account->logintoboggan_email_validated == TRUE) { + $confirmed_rid = materio_user_get_role_by_name(MATERIO_USER_CONFIRMED_USER_ROLE); $roles = $account->roles + array($confirmed_rid => MATERIO_USER_CONFIRMED_USER_ROLE); - + // we have to do this to stop an infinite loop, and also to allow lower weighted modules to possibly do something here $user = $account; unset($user->logintoboggan_email_validated); - + user_save($user, array('roles' => $roles)); drupal_go_to('user/'.$user->uid.'/edit'); @@ -367,5 +367,5 @@ function _materio_user_user_update(&$edit, $account, $category){ */ function materio_user_get_role_by_name($name) { return array_search($name, user_roles()); -} +} diff --git a/materio_user.pages.inc b/materio_user.pages.inc index 5ca522a5..9cc11058 100644 --- a/materio_user.pages.inc +++ b/materio_user.pages.inc @@ -1,4 +1,4 @@ -$_POST); drupal_form_submit($_POST['form_id'], $form_state); - + $return['errors'] = form_get_errors(); if($return['errors']) unset ($_SESSION['messages']['error']); From 28deeac474eec7fdde946a3087f7d9a982aaff93 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Thu, 3 Jul 2014 18:52:20 +0200 Subject: [PATCH 33/34] materio admin : created duplicate mails page admin --- materio_admin.module | 54 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/materio_admin.module b/materio_admin.module index 1035855c..d9e7f436 100644 --- a/materio_admin.module +++ b/materio_admin.module @@ -14,6 +14,10 @@ function materio_admin_permission() { 'title' => t('access default UC roles expiration list'), 'description' => t('access default UC roles expiration list.'), ), + 'access duplicate mails list' => array( + 'title' => t('access duplicate mails list'), + 'description' => t('access duplicate mails list.'), + ), ); } @@ -22,6 +26,16 @@ function materio_admin_permission() { */ function materio_admin_menu() { + $items['admin/users/duplicatemails'] = array( + 'title' => "Duplicate mails", + 'page callback' => 'materio_duplicatemails', + 'access callback' => 'user_access', + 'access arguments' => array('access duplicate mails list'), + 'type' => MENU_LOCAL_TASK + ); + + + if(module_exists('simplenews')){ $cats = simplenews_category_list(); // dsm($cats, 'cats'); @@ -52,6 +66,46 @@ function materio_admin_menu() { return $items; } +function materio_duplicatemails(){ + $mails = db_query('SELECT mail FROM {users} GROUP BY mail HAVING count(mail) > 1')->fetchCol(); + + // Bail out early if there are no duplicates. + if (!$mails) { + return t('All accounts have unique email addresses.'); + } + + // Grab all the user data for accounts with addresses identified as + // duplicates. This is a little convoluted, but it lets us grab all the user + // data in one shot. + $uids = db_select('users', 'u') + ->fields('u', array('uid')) + ->condition('mail', $mails, 'IN') + ->orderBy('access', 'DESC') + ->execute() + ->fetchCol(); + $duplicate_users = user_load_multiple($uids); + $duplicate_mails = array(); + foreach ($duplicate_users as $duplicate_user) { + $duplicate_mails[$duplicate_user->mail][] = $duplicate_user; + } + + // Turn the data we've got into markup. + $output = t('Accounts with duplicate email address:') . '
'; + $output = "
    "; + foreach ($duplicate_mails as $mail => $users) { + $output .= "
  • $mail :
    "; + $accounts = array(); + foreach ($users as $duplicate_user) { + $accounts[] = l($duplicate_user->name, "user/{$duplicate_user->uid}") . ' ('. date('Y-m-d', $duplicate_user->access) .')'; + } + $output .= implode(', ', $accounts); + + $output .= '
  • '; + } + $output .= "
"; + return $output; +} + /** * Implements hook_menu_alter(). */ From f4ae3c9055407b5d7853100afa91c194bef97cc3 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Mon, 7 Jul 2014 12:49:40 +0200 Subject: [PATCH 34/34] fixed results summary --- materio_search_api.module | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/materio_search_api.module b/materio_search_api.module index 1132d256..967e04a3 100755 --- a/materio_search_api.module +++ b/materio_search_api.module @@ -805,13 +805,19 @@ function template_preprocess_materio_search_api_results(array &$vars) { // 'The search found @count results ' // ) - $vars['search_performance'] = t('The search found @count result(s) with keywords @keys. @mat materials and @new news.', array( + $vars['search_performance'] = t('The search found @count result(s) with keywords @keys.', array( "@count"=>$vars['result_count'], - "@keys"=>$vars['keywords'], - "@mat"=>4, - "@new"=>7) + "@keys"=>$vars['keywords']) ); + // TODO indicate how many materials and how many news + // $vars['search_performance'] = t('The search found @count result(s) with keywords @keys. @mat materials and @new news.', array( + // "@count"=>$vars['result_count'], + // "@keys"=>$vars['keywords'], + // "@mat"=>4, + // "@new"=>7) + // ); + } //dsm($vars, '$vars');