bug fixed

This commit is contained in:
Bachir Soussi Chiadmi 2014-04-28 17:20:50 +02:00
parent 05a41ebf3a
commit 5d0c233fec
4 changed files with 43 additions and 41 deletions

View File

@ -116,17 +116,18 @@ MaterioFlag = function(){
function refreshBlocks(name){ function refreshBlocks(name){
//trace('MaterioFlag :: refreshBlocks | name', name); //trace('MaterioFlag :: refreshBlocks | name', name);
if($('#block-materio-flag-materio-flag-mybookmarks').length){ if($('#block-materio-flag-materio-flag-mylists').length){
var type = 'bookmarks';
}else if($('#block-materio-flag-materio-flag-mylists').length){
var type = 'lists'; var type = 'lists';
}else if($('#block-materio-flag-materio-flag-mybookmarks').length){
var type = 'bookmarks';
} }
if(type != undefined){ if(type != undefined){
var id = '#block-materio-flag-materio-flag-my'+type; var id = '#block-materio-flag-materio-flag-my'+type;
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/refresh/block/'+type; var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/refresh/block/'+type;
$.getJSON(url, function(json){ $.getJSON(url, function(json){
trace('MaterioFlag :: block refreshed '+type, json); // trace('MaterioFlag :: block refreshed '+type, json);
$(id).replaceWith(json.block); $(id).replaceWith(json.block);
$('#block-materio-flag-materio-flag-mylists-nav').replaceWith(json.block_nav); $('#block-materio-flag-materio-flag-mylists-nav').replaceWith(json.block_nav);

View File

@ -116,17 +116,18 @@ MaterioFlag = function(){
function refreshBlocks(name){ function refreshBlocks(name){
//trace('MaterioFlag :: refreshBlocks | name', name); //trace('MaterioFlag :: refreshBlocks | name', name);
if($('#block-materio-flag-materio-flag-mybookmarks').length){ if($('#block-materio-flag-materio-flag-mylists').length){
var type = 'bookmarks';
}else if($('#block-materio-flag-materio-flag-mylists').length){
var type = 'lists'; var type = 'lists';
}else if($('#block-materio-flag-materio-flag-mybookmarks').length){
var type = 'bookmarks';
} }
if(type != undefined){ if(type != undefined){
var id = '#block-materio-flag-materio-flag-my'+type; var id = '#block-materio-flag-materio-flag-my'+type;
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/refresh/block/'+type; var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/refresh/block/'+type;
$.getJSON(url, function(json){ $.getJSON(url, function(json){
trace('MaterioFlag :: block refreshed '+type, json); // trace('MaterioFlag :: block refreshed '+type, json);
$(id).replaceWith(json.block); $(id).replaceWith(json.block);
$('#block-materio-flag-materio-flag-mylists-nav').replaceWith(json.block_nav); $('#block-materio-flag-materio-flag-mylists-nav').replaceWith(json.block_nav);

View File

@ -5,7 +5,7 @@
* The Flag bookmark module. * The Flag bookmark module.
* *
* This module creates a default Flag when enabled. * This module creates a default Flag when enabled.
* *
*/ */
/** /**
@ -55,14 +55,14 @@ function materio_flag_menu() {
'page callback' => 'materio_flag_createlist_form', 'page callback' => 'materio_flag_createlist_form',
'page arguments' => array(3), 'page arguments' => array(3),
); );
$items['materioflag/editlistform/%/%'] = $base+array( $items['materioflag/editlistform/%/%'] = $base+array(
'access arguments' => array('create flag lists'), 'access arguments' => array('create flag lists'),
'access callback' => 'user_access', 'access callback' => 'user_access',
'page callback' => 'materio_flag_editlist_form', 'page callback' => 'materio_flag_editlist_form',
'page arguments' => array(2,3), 'page arguments' => array(2,3),
); );
$items['materioflag/editlist/%/%'] = $base+array( $items['materioflag/editlist/%/%'] = $base+array(
'access arguments' => array('create flag lists'), 'access arguments' => array('create flag lists'),
'access callback' => 'user_access', 'access callback' => 'user_access',
@ -83,7 +83,7 @@ function materio_flag_menu() {
'page callback' => 'materio_flag_nodelinks', 'page callback' => 'materio_flag_nodelinks',
// 'page arguments' => array(3), // 'page arguments' => array(3),
); );
$items['lists/%'] = $base+array( $items['lists/%'] = $base+array(
'access arguments' => array('view flag lists'), 'access arguments' => array('view flag lists'),
'access callback' => 'user_access', 'access callback' => 'user_access',
@ -121,7 +121,7 @@ function materio_flag_menu_alter(&$items) {
* Implements hook_block_info(). * Implements hook_block_info().
*/ */
function materio_flag_block_info() { function materio_flag_block_info() {
$blocks['materio_flag_mybookmarks'] = array( $blocks['materio_flag_mybookmarks'] = array(
'info' => t('My bookmarks'), 'info' => t('My bookmarks'),
'cache' => DRUPAL_NO_CACHE 'cache' => DRUPAL_NO_CACHE
@ -160,7 +160,7 @@ function materio_flag_block_view($delta = '') {
} }
// TODO: put this title generation on a theme function // TODO: put this title generation on a theme function
$subject = '<span class="listname">'.t('My bookmarks (@len) ', array("@len"=>count($userbookmarks))).'</span>'; $subject = '<span class="listname">'.t('My bookmarks (@len) ', array("@len"=>count($userbookmarks))).'</span>';
$block['subject'] = $subject . l('<i class="icon-resize-full"></i>', 'bookmarks', array('html'=>true, 'attributes' => array('class' => array('open-list')),)); // $block['subject'] = $subject . l('<i class="icon-resize-full"></i>', 'bookmarks', array('html'=>true, 'attributes' => array('class' => array('open-list')),)); //
$block['content'] = theme('materio_flag_mybookmarks_block', array("bookmarks"=>$userbookmarks, "viewmode"=>"bookmark")); $block['content'] = theme('materio_flag_mybookmarks_block', array("bookmarks"=>$userbookmarks, "viewmode"=>"bookmark"));
}else{ }else{
$block['subject'] = t('My bookmarks'); $block['subject'] = t('My bookmarks');
@ -175,7 +175,7 @@ function materio_flag_block_view($delta = '') {
// $userflags = flag_get_user_flags('node'); // $userflags = flag_get_user_flags('node');
// dsm($userflags, 'userflags'); // dsm($userflags, 'userflags');
// dsm($flags, 'flags'); // dsm($flags, 'flags');
foreach ($flags as $name => $flag) { foreach ($flags as $name => $flag) {
$flag->path = url('lists/'.$flag->fid); $flag->path = url('lists/'.$flag->fid);
$flaged_content = flag_lists_get_flagged_content($flag->fid, $user->uid); $flaged_content = flag_lists_get_flagged_content($flag->fid, $user->uid);
@ -222,7 +222,7 @@ function materio_flag_block_view($delta = '') {
// if($flags){ // if($flags){
// $block['subject'] = t('My !listname'.'s', array('!listname'=>variable_get('flag_lists_name', 'list'))); // $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['subject'] = t('My '.variable_get('flag_lists_name', 'list').'s');
$block['content'] = theme('materio_flag_mylists_nav_block', array("flags"=>$flags)); $block['content'] = theme('materio_flag_mylists_nav_block', array("flags"=>$flags));
// $block['content'] = theme('flag_lists_user_page', array('uid' => $user->uid)); // $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) { function materio_flag_entity_view($entity, $type, $view_mode, $langcode) {
if($type == 'node'){ if($type == 'node'){
if(user_access('create flag lists') && $view_mode != 'print'){ if(user_access('create flag lists') && $view_mode != 'print'){
$entity->content['flaglistslinks'] = materio_flag_get_entity_links($entity, $type, $view_mode); $entity->content['flaglistslinks'] = materio_flag_get_entity_links($entity, $type, $view_mode);
drupal_add_css(drupal_get_path('module', 'flag') . '/theme/flag.css'); 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) { foreach ($flags as $flag) {
// dsm($flag, 'flag'); // dsm($flag, 'flag');
if ( ($flag->module == 'flag_lists' && _flag_lists_is_flagged($flag, $entity->nid, $user->uid, 0)) || $flag->is_flagged($entity->nid) ) { 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(); $links = array();
# if flag name is provided we are on flaglists content list (block mylists) # if flag name is provided we are on flaglists content list (block mylists)
if($view_mode == 'bookmark'){ 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)) { // if (isset($entity->flag_names) && $flags = flag_lists_get_user_flags($entity->type, $user)) {
// // dsm($flags, 'flags'); // // dsm($flags, 'flags');
// // TODO: limit flag link by current flag list // // TODO: limit flag link by current flag list
// foreach ($flags as $flag) { // foreach ($flags as $flag) {
// //dsm($flag->name, 'flag'); // //dsm($flag->name, 'flag');
// if(in_array($flag->name, $entity->flag_names)){ // 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'; // $action = _flag_lists_is_flagged($flag, $entity->nid, $user->uid, 0) ? 'unflag' : 'flag';
// } else { // } else {
// $action = $flag->is_flagged($entity->nid) ? 'unflag' : 'flag'; // $action = $flag->is_flagged($entity->nid) ? 'unflag' : 'flag';
// } // }
// $flag->module = 'materio_flag'; // $flag->module = 'materio_flag';
// $link = $flag->theme($action, $entity->nid); // $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); // dsm($items, 'items '.$entity->title);
#create new list #create new list
$link = l( $link = l(
'<i class="icon-plus"></i>&nbsp;<span>' . t('New @name', array('@name' => t(variable_get('flag_lists_name', 'list')))) . '</span>', '<i class="icon-plus"></i>&nbsp;<span>' . t('New @name', array('@name' => t(variable_get('flag_lists_name', 'list')))) . '</span>',
'flag-lists/add/' . $entity->type, 'flag-lists/add/' . $entity->type,
array( array(
'attributes' => array( 'attributes' => array(
@ -366,7 +366,7 @@ function materio_flag_get_entity_links($entity, $type, $view_mode = null){
'html' => TRUE, 'html' => TRUE,
) )
); );
$create = array( $create = array(
'data' => $link, 'data' => $link,
'class' => array('flag-lists-create'), 'class' => array('flag-lists-create'),
@ -375,15 +375,15 @@ function materio_flag_get_entity_links($entity, $type, $view_mode = null){
if(isset($items)){ if(isset($items)){
$ops = array( $ops = array(
'#node' => $entity, '#node' => $entity,
'#items' => $items, '#items' => $items,
); );
} }
if(isset($create)){ if(isset($create)){
$ops['#create'] = $create; $ops['#create'] = $create;
} }
if(isset($ops)){ if(isset($ops)){
// dsm($ops, 'ops'); // dsm($ops, 'ops');
drupal_add_js(drupal_get_path('module', 'materio_flag').'/js/materio_flag.min.js'); 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){ function _materio_flag_get_listpagetitle($flag){
$cont = '<i class="icon-materio-folder"></i>'; $cont = '<i class="icon-materio-folder"></i>';
$cont .= '<span class="'.$flag->name.'">'.check_plain($flag->title).'</span>'; $cont .= '<span class="'.$flag->name.'">'.check_plain($flag->title).'</span>';
if(flag_lists_is_owner('edit', $flag->fid)){ if(flag_lists_is_owner('edit', $flag->fid)){
$cont .= l('<i class="icon-wrench"></i>', $cont .= l('<i class="icon-wrench"></i>',
'flags/lists/edit/'.$flag->fid, 'flags/lists/edit/'.$flag->fid,
array( array(
'html'=>true, 'html'=>true,
'attributes'=>array('class'=>array('edit-list', $flag->name)), 'attributes'=>array('class'=>array('edit-list', $flag->name)),
) )
); );
} }
return $cont; return $cont;
} }
@ -468,11 +468,11 @@ function template_preprocess_materio_flag_mylists_nav_block(&$vars){
/** /**
* theme_materio_flag_mylists_entity_links() * theme_materio_flag_mylists_entity_links()
* *
* see theme_flag_lists_list() * see theme_flag_lists_list()
*/ */
function theme_materio_flag_mylists_entity_links($vars){ function theme_materio_flag_mylists_entity_links($vars){
// $node = $vars['node']; // $node = $vars['node'];
$items = $vars['items']; $items = $vars['items'];
@ -480,13 +480,13 @@ function theme_materio_flag_mylists_entity_links($vars){
if(isset($vars['create'])) if(isset($vars['create']))
$items[] = $vars['create']; $items[] = $vars['create'];
return theme('item_list', array('items' => $items, 'type' => 'ul', 'attributes' => array('class' => 'flag-lists-entity-links'))); return theme('item_list', array('items' => $items, 'type' => 'ul', 'attributes' => array('class' => 'flag-lists-entity-links')));
} }
function template_preprocess_materio_flag_mylists_list(&$vars) { function template_preprocess_materio_flag_mylists_list(&$vars) {
$vars['list_count'] = format_plural( $vars['list_count'] = format_plural(
$vars['count'], $vars['count'],
'@name @title contains 1 item.', // in @sec seconds '@name @title contains 1 item.', // in @sec seconds

View File

@ -19,7 +19,7 @@ function materio_flag_refresh_block($flag){
if(!isset($block_name)) if(!isset($block_name))
return; return;
$rep = array(); $rep = array("flag"=>$flag);
$block = block_load('materio_flag', $block_name); $block = block_load('materio_flag', $block_name);
$block_content = _block_render_blocks(array($block)); $block_content = _block_render_blocks(array($block));