bug fixe ?

This commit is contained in:
Bachir Soussi Chiadmi 2014-04-28 17:09:33 +02:00
parent a08a5287fc
commit 05a41ebf3a

View File

@ -2,10 +2,10 @@
/** /**
* materio_flag_refresh_blocks($flag) * materio_flag_refresh_blocks($flag)
* *
*/ */
function materio_flag_refresh_block($flag){ function materio_flag_refresh_block($flag){
switch ($flag) { switch ($flag) {
case 'bookmarks': case 'bookmarks':
$block_name = 'materio_flag_mybookmarks'; $block_name = 'materio_flag_mybookmarks';
@ -18,7 +18,7 @@ function materio_flag_refresh_block($flag){
if(!isset($block_name)) if(!isset($block_name))
return; return;
$rep = array(); $rep = array();
$block = block_load('materio_flag', $block_name); $block = block_load('materio_flag', $block_name);
@ -27,20 +27,20 @@ function materio_flag_refresh_block($flag){
$block_rendered = drupal_render($build); $block_rendered = drupal_render($build);
$rep['block'] = $block_rendered; $rep['block'] = $block_rendered;
if(isset($block_nav_name)) if(isset($block_nav_name)){
$block = block_load('materio_flag', $block_nav_name); $block = block_load('materio_flag', $block_nav_name);
$block_content = _block_render_blocks(array($block)); $block_content = _block_render_blocks(array($block));
$build = _block_get_renderable_array($block_content); $build = _block_get_renderable_array($block_content);
$block_rendered = drupal_render($build); $block_rendered = drupal_render($build);
$rep['block_nav'] = $block_rendered; $rep['block_nav'] = $block_rendered;
}
drupal_json_output($rep); drupal_json_output($rep);
} }
/** /**
* materio_flag_createlist($type) * materio_flag_createlist($type)
* *
*/ */
function materio_flag_createlist_form($type){ function materio_flag_createlist_form($type){
$debug = false; $debug = false;
@ -55,7 +55,7 @@ function materio_flag_createlist_form($type){
// menu_set_active_item($path); // menu_set_active_item($path);
// $return = menu_execute_active_handler($path, FALSE); // $return = menu_execute_active_handler($path, FALSE);
// if (is_int($return)) { // if (is_int($return)) {
// switch ($return) { // switch ($return) {
// case MENU_NOT_FOUND : // case MENU_NOT_FOUND :
@ -69,7 +69,7 @@ function materio_flag_createlist_form($type){
// break; // break;
// } // }
// } elseif (isset($return)) { // } elseif (isset($return)) {
// $form_state['build_info']['args'] = array(NULL, 'breve'); // $form_state['build_info']['args'] = array(NULL, 'breve');
// $f = drupal_get_form('flag_lists_form', $form_state); // $f = drupal_get_form('flag_lists_form', $form_state);
// dsm($f); // dsm($f);
@ -86,11 +86,11 @@ function materio_flag_createlist_form($type){
); );
$form['listname'] = array( $form['listname'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Create new @name', array('@name'=>variable_get('flag_lists_name', 'list'))), '#title' => t('Create new @name', array('@name'=>variable_get('flag_lists_name', 'list'))),
'#default_value' => '', '#default_value' => '',
// '#size' => 100, // '#size' => 100,
'#maxlength' => 255, '#maxlength' => 255,
'#name' => 'flag-lists-name', '#name' => 'flag-lists-name',
'#description' => t('A short, descriptive title for this Folder list. Limit to 255 characters.'), '#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'), '#value' => t('cancel'),
'#name' => 'cancel', '#name' => 'cancel',
); );
// dsm($form, 'form'); // dsm($form, 'form');
$return = drupal_render($form); $return = drupal_render($form);
$rep = array( $rep = array(
'rendered_form'=>$return, 'rendered_form'=>$return,
); );
if ($debug) { if ($debug) {
dsm($rep, 'rep'); dsm($rep, 'rep');
return "debug display"; return "debug display";
}else{ }else{
drupal_json_output($rep); drupal_json_output($rep);
} }
} }
@ -172,7 +172,7 @@ function materio_flag_editlist_form($type, $fid){
'#value' => $fid, '#value' => $fid,
'#name' => 'fid', '#name' => 'fid',
); );
$form['name'] = array( $form['name'] = array(
'#type' => 'hidden', '#type' => 'hidden',
'#value' => $name, '#value' => $name,
@ -180,11 +180,11 @@ function materio_flag_editlist_form($type, $fid){
); );
$form['listtitle'] = array( $form['listtitle'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Edit this '.variable_get('flag_lists_name', 'list')), '#title' => t('Edit this '.variable_get('flag_lists_name', 'list')),
'#value' => $flag->title, '#value' => $flag->title,
// '#size' => 100, // '#size' => 100,
'#maxlength' => 255, '#maxlength' => 255,
'#name' => 'flag-lists-title', '#name' => 'flag-lists-title',
'#description' => t('A short, descriptive title for this Folder list. Limit to 255 characters.'), '#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'), '#value' => t('cancel'),
'#name' => 'cancel', '#name' => 'cancel',
); );
// dsm($form, 'form'); // dsm($form, 'form');
$return = drupal_render($form); $return = drupal_render($form);
$rep = array( $rep = array(
'rendered_form'=>$return, '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')), 'message' => t('you do not have rights to edit this '.variable_get('flag_lists_name', 'list')),
); );
} }
if ($debug) { if ($debug) {
dsm($rep, 'rep'); dsm($rep, 'rep');
return "debug display"; return "debug display";
}else{ }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){ function materio_flag_delete_list($fid){
@ -299,15 +299,15 @@ function materio_flag_delete_list($fid){
} }
$flag = flag_lists_get_flag($name); $flag = flag_lists_get_flag($name);
flag_lists_fl_delete($flag); flag_lists_fl_delete($flag);
$rep = array( $rep = array(
'status' => 'saved', 'status' => 'saved',
); );
} }
drupal_json_output($rep); drupal_json_output($rep);
} }
function materio_flag_nodelinks(){ function materio_flag_nodelinks(){
@ -324,19 +324,19 @@ function materio_flag_nodelinks(){
"status" => 1, "status" => 1,
"nids" => $nids, "nids" => $nids,
'links' => $links, 'links' => $links,
); );
}else{ }else{
$rep['status'] = 0; $rep['status'] = 0;
} }
drupal_json_output($rep); drupal_json_output($rep);
} }
function materio_flag_user_bookmarks(){ function materio_flag_user_bookmarks(){
global $user; global $user;
drupal_set_title(t('My bookmarks'), PASS_THROUGH); drupal_set_title(t('My bookmarks'), PASS_THROUGH);
$flaged = flag_get_user_flags('node'); $flaged = flag_get_user_flags('node');
// dsm($flaged, 'flaged'); // dsm($flaged, 'flaged');
@ -363,7 +363,7 @@ function materio_flag_user_bookmarks(){
} }
} }
} }
$ret['#items'] = $items; $ret['#items'] = $items;
$ret['#theme'] = 'materio_flag_mylists_list'; $ret['#theme'] = 'materio_flag_mylists_list';
$ret['#view_mode'] = $viewmode; $ret['#view_mode'] = $viewmode;
@ -397,12 +397,12 @@ function materio_flag_user_lists($fid){
$count = count($flaged_content); $count = count($flaged_content);
$max = $offset+$limit > $count ? $count : $offset+$limit; $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'){ if($flaged_content[$i]->entity_type == 'node'){
$items[] = node_load($flaged_content[$i]->entity_id); $items[] = node_load($flaged_content[$i]->entity_id);
} }
} }
$ret['#items'] = $items; $ret['#items'] = $items;
$ret['#theme'] = 'materio_flag_mylists_list'; $ret['#theme'] = 'materio_flag_mylists_list';
$ret['#view_mode'] = $viewmode; $ret['#view_mode'] = $viewmode;
@ -425,9 +425,9 @@ function materio_flag_ajax_list($fid, $page = 0){
$list_path = $path = 'bookmarks'; $list_path = $path = 'bookmarks';
}else{ }else{
$list_path = 'lists'; $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 // 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')) { 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); $return = menu_execute_active_handler($path, FALSE);
dsm($return, '$return'); dsm($return, '$return');
if (is_int($return)) { if (is_int($return)) {
switch ($return) { switch ($return) {
case MENU_NOT_FOUND : case MENU_NOT_FOUND :
@ -480,18 +480,18 @@ function materio_flag_ajax_list($fid, $page = 0){
if (is_array($return)) { if (is_array($return)) {
$rendered = drupal_render($return); $rendered = drupal_render($return);
} }
$rep = array( $rep = array(
'rendered' => $rendered, 'rendered' => $rendered,
'path' => $path, 'path' => $path,
'title' => drupal_get_title(), 'title' => drupal_get_title(),
); );
if ($debug) { if ($debug) {
dsm($rep, 'rep'); dsm($rep, 'rep');
return "debug display"; return "debug display";
}else{ }else{
drupal_json_output($rep); drupal_json_output($rep);
} }
} }
} }