- added materio_user.module (add permission to view the profile page)
- materio_serach_api.pages : limit actu items for anonymous
- materio_search_api_ajax.pages & materio_flag.pages : redirect to real page if current page not corresponding on ajax request (solve the view mode block visibility on user edit profile page)
- materio_flag : added edit lists functionalities ++ get_list_page_title func

Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
bachy 2012-11-21 10:06:34 +01:00
parent 61c83b5a75
commit 2601c718c2
15 changed files with 628 additions and 76 deletions

File diff suppressed because one or more lines are too long

View File

@ -51,7 +51,7 @@ MaterioFlag = function(){
var name = $this.attr('class').match(/flag_lists_[^_]+_[0-9]+/);
// trace('MaterioFlag :: name', name);
$('<span class="preview">open preview</span>').attr('name', name).insertAfter($this).bind('click', onClickShowPreview);
$('<span class="preview"><i class="icon-eye-open"></i></span>').attr('name', name).insertAfter($this).bind('click', onClickShowPreview);
});
// preview block
@ -113,6 +113,10 @@ MaterioFlag = function(){
$('a.flag-lists-create:not(.ajax-processed)', container)
.bind('click', onClickCreatLink)
.addClass('ajax-processed');
$('a.edit-list:not(.ajax-processed)', container)
.bind('click', onCLickEditList)
.addClass('ajax-processed');
};
/**
@ -158,9 +162,13 @@ MaterioFlag = function(){
$.event.trigger('loading-content');
$.getJSON(url, function(json){
$.getJSON(url, {'current_path':document.location.href},function(json){
trace('MaterioFlag :: json', json);
changeContent(json);
if(json.redirect){
window.location = json.redirect;
}else{
changeContent(json);
}
});
};
@ -214,7 +222,7 @@ MaterioFlag = function(){
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/createlist/form/'+type[0];
$.getJSON(url, function(json){
trace('MaterioFlag :: json', json);
trace('MaterioFlag :: creat list : json', json);
showCreateListForm(json, $link);
});
return false;
@ -358,6 +366,142 @@ MaterioFlag = function(){
});
};
/**
* onCLickEditList(event)
*/
function onCLickEditList(event){
// 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){
trace('MaterioFlag :: editlist : json', json);
showEditListForm(json, $link);
});
return false;
};
function showEditListForm(json, $link){
// google analytics
$.event.trigger({
type:"record-stat",
categorie:"flagLists",
action: 'show edit form'
});
var $modal = $('<div id="modal" class="modal"/>').appendTo('body');
$modal
.css({
position:'absolute',
top:'40%', left:'50%',
marginLeft:'-150px', width:'300px',
zIndex:"99999"
})
.append(json.return)
.find('input[type="submit"]', '#materio-flag-edit-list-form').bind('click', function(event) {
event.preventDefault();
var $form = $(this).parents('form');
var title = $form.find('input[name*="flag-lists-title"]').val();
var fid = $form.find('input[name*="fid"]').val();
var name = $form.find('input[name*="name"]').val();
switch($(this).attr('name')){
case 'cancel':
trace('MaterioFlag :: cancel',event);
$(this).parents('#modal').remove();
// google analytics
var action = 'cancel edit form';
break;
case 'save':
trace('MaterioFlag :: create',event);
// google analytics
var action = "submit edit form";
editList($modal, fid, name, title);
break;
case 'delete':
trace('MaterioFlag :: delete',event);
if(confirm('Do you realy want to delete the folder '+title+'?')){
var action = "submit delete form";
deleteList($modal, fid);
}else{
var action = "cancel delete form";
}
break;
}
// google analytics
$.event.trigger({
type:"record-stat",
categorie:"flagLists",
action: action
});
return false;
})
.parents('form').find('input[type="text"]').focus();
// TODO: esc keypressed close the form
};
function editList($modal, fid, name, title){
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/editlist/'+fid+'/'+name+'/'+title;
$.getJSON(url, function(data) {
if (data.error) {
// trace(data.error);
if(data.message)
alert(data.message);
}
else {
trace('MaterioFlag :: saved list : data', data);
$.event.trigger({
type : 'list-edited',
name : data.listname,
title : data.title,
});
refreshBlocks();
refreshNodeLinks();
$modal.remove();
}
});
};
function deleteList($modal, fid){
// prompt('are you sure ?');
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/deletelist/'+fid;
$.getJSON(url, function(data) {
if (data.error) {
// trace(data.error);
if(data.message)
alert(data.message);
}
else {
trace('MaterioFlag :: deleted list : data', data);
refreshBlocks();
refreshNodeLinks();
// TODO: if the deleted list was the current displayed list ??
$modal.remove();
}
});
}
/**
*
*/
function onInitScrollerPager(event){
// trace('MaterioFlag :: MaterioFlag :: onInitScrollerPager');
if (isList()){

File diff suppressed because one or more lines are too long

View File

@ -5,7 +5,10 @@
MaterioPageTitle = function(){
function init(){
$(document).bind('materio-page-title-refresh-block', onRefreshBlock);
$(document)
.bind('materio-page-title-refresh-block', onRefreshBlock)
.bind('list-edited', onListEdited);
};
function onRefreshBlock(event){
@ -19,6 +22,16 @@ MaterioPageTitle = function(){
$('#block-materio-page-title-materio-page-title h1').html(event.title);
};
function onListEdited(event){
trace('MaterioPageTitle :: onListEdited', event);
// this is for refreshing page title when list title was just edited AND this list is the cirreunt list
if($("#materio-page-title ."+event.name).length)
$('a.open-list.'+event.name).eq(0).trigger('click');
};
init();
};

File diff suppressed because one or more lines are too long

View File

@ -81,10 +81,10 @@ MaterioSearchApiAjax = function(){
$.event.trigger('loading-content');
_isloadingresults = true;
$('#materio-search-api-search-form').addClass('loading');
// trace('window.location.href',window.location.href);
// TODO: record ajax path in a variable from materio_search_api_ajax_init
$.getJSON(Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_search_api_ajax/search/'+keys,
{'types':types},
{'types':types,'current_path':document.location.href},
function(json){
trace('json', json);
$.event.trigger('loaded-content');
@ -99,8 +99,12 @@ MaterioSearchApiAjax = function(){
label : 'filters : '+ stringTypes.join(' ,'),
value : json.count
});
changeContent(json);
if(json.redirect){
window.location = json.redirect;
}else{
changeContent(json);
}
});
}
}
@ -129,7 +133,7 @@ MaterioSearchApiAjax = function(){
if(json.return){
$.event.trigger('loaded-content');
$('.inner-content',_$content).html(json.return);
$('.inner-content',_$content).html(json.return).find('ul.pager').hide();
triggerContentChanged();
}else{
trace('no results');
@ -162,57 +166,54 @@ MaterioSearchApiAjax = function(){
};
function onLoadScrollerPager(event){
if (isExplore())
loadNextResultsPage(event.href);
if(!_isloadingresults){
if (isExplore())
loadNextResultsPage(event.href);
if(isActuality())
loadNextActualityPage(event.href);
if(isActuality())
loadNextActualityPage(event.href);
}
};
function loadNextResultsPage(href){
// trace('loadNextResultsPage');
if(!_isloadingresults){
var keys = href.match(/explore\/([^\/|\?]+)/);
var page = href.match(/\?page=([0-9]+)/);
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_search_api_ajax/search/'+keys[1]+'/'+page[1];
loadNextPage(url, $('.materiobase-results', _$content), '.search-results');
}
var keys = href.match(/explore\/([^\/|\?]+)/);
var page = href.match(/\?page=([0-9]+)/);
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_search_api_ajax/search/'+keys[1]+'/'+page[1];
loadNextPage(url, $('.materiobase-results', _$content), '.search-results');
};
function loadNextActualityPage(href){
// trace('loadNextActualityPage');
if(!_isloadingresults){
var page = href.match(/\?page=([0-9]+)/);
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_search_api_ajax/actuality/'+page[1];
var page = href.match(/\?page=([0-9]+)/);
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_search_api_ajax/actuality/'+page[1];
loadNextPage(url, $('.materiobase-actuality', _$content), '.actuality-items');
}
loadNextPage(url, $('.materiobase-actuality', _$content), '.actuality-items');
};
function loadNextPage(url, $container, target){
trace('loadNextPage');
trace('MaterioSearchApiAjax :: loadNextPage()');
_isloadingresults = true;
$container.addClass('loading');
$.getJSON(url, function(json){
trace('json', json);
_isloadingresults = false;
$container.removeClass('loading');
addNextpage(json, target);
// addNextpageItemByItem($(json.return), target);
});
};
function addNextpage(json, container_class){
var $newcontent = $(json.return),
$newitems = $(container_class, $newcontent).children('article').addClass('just-added'),
$newitems = $(container_class, $newcontent).children('article'), //.addClass('just-added'),
$newpager = $('ul.pager', $newcontent);
$(container_class, _$content).append($newitems);
$('ul.pager', _$content).replaceWith($newpager.hide());
// TODO: animation, this should be on theme side
$(container_class, _$content).children('.just-added').each(function(i){
// $(this).delay(5000*i).removeClass('just-added');
var $this = $(this);
setTimeout(function(){
$this.removeClass('just-added');
@ -223,38 +224,66 @@ MaterioSearchApiAjax = function(){
type : 'resultscompleted',
container : $(container_class, _$content)
});
_isloadingresults = false;
};
// TEST not used
function addNextpageItemByItem($newcontent, container_class){
trace('MaterioSearchApiAjax :: addNextpageItemByItem()');
$('ul.pager', _$content).remove();
$(container_class, _$content).append($(container_class, $newcontent).children('article').eq(0));
if($(container_class, $newcontent).children('article').length){
setTimeout(function(){
addNextpageItemByItem($newcontent, container_class);
}, 200);
}else{
_isloadingresults = false;
$('ul.pager', _$content).replaceWith($('ul.pager', $newcontent).hide());
$.event.trigger({
type : 'resultscompleted',
container : $(container_class, _$content)
});
}
};
/**
* viewmode
*/
function initViewMode(){
$('.viewmode-link').click(function(event){
event.preventDefault();
changeViewMode($(this).attr('rel'), $(this));
if(!$(this).is('.active'))
changeViewMode($(this).attr('rel'), $(this));
return false;
});
};
function changeViewMode(vm, $btn){
$.getJSON(Drupal.settings.basePath+'materio_search_api_ajax/viewmode/change/'+vm, function(json){
trace('viewmode json', json);
if (json.statut == "saved"){
// google analytics
$.event.trigger({
type : "record-stat",
categorie : 'Viewmode',
action : vm,
label : isActuality() ? 'Actualities' : 'Search results'
});
if(!_isloadingresults){
_isloadingresults = true;
$.getJSON(Drupal.settings.basePath+'materio_search_api_ajax/viewmode/change/'+vm, function(json){
trace('viewmode json', json);
_isloadingresults = false;
if (json.statut == "saved"){
// google analytics
$.event.trigger({
type : "record-stat",
categorie : 'Viewmode',
action : vm,
label : isActuality() ? 'Actualities' : 'Search results'
});
$.event.trigger('view-mode-changed');
$('.viewmode-link, .viewmode-link i').removeClass('active');
$btn.addClass('active').find('i').addClass('active');
}
});
$.event.trigger('view-mode-changed');
$('.viewmode-link, .viewmode-link i').removeClass('active');
$btn.addClass('active').find('i').addClass('active');
}
});
}
};
function onViewModeChanged(event){

View File

@ -57,7 +57,27 @@ function materio_flag_menu() {
'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',
'page callback' => 'materio_flag_edit_list',
'page arguments' => array(2,3),
);
$items['materioflag/deletelist/%'] = $base+array(
'access arguments' => array('create flag lists'),
'access callback' => 'user_access',
'page callback' => 'materio_flag_delete_list',
'page arguments' => array(2,3),
);
$items['materioflag/nodelinks'] = $base+array(
'access arguments' => array('create flag lists'),
'access callback' => 'user_access',
@ -66,7 +86,7 @@ function materio_flag_menu() {
);
$items['lists/%'] = $base+array(
'access arguments' => array('create flag lists'),
'access arguments' => array('view flag lists'),
'access callback' => 'user_access',
'page callback' => 'materio_flag_user_lists',
'page arguments' => array(1),
@ -82,6 +102,18 @@ function materio_flag_menu() {
return $items;
}
/**
* Implements hook_menu_alter().
*/
function materio_flag_menu_alter(&$items) {
// Example - disable the page at node/add
/*
*$items['node/add']['access callback'] = FALSE;
*/
// disable tabs on user page
$items['user/%user/flags/lists']['access callback'] = false;
$items['user/%user/flags/lists/%']['access callback'] = false;
}
/**
* Implements hook_block_info().
@ -162,12 +194,13 @@ function materio_flag_block_view($delta = '') {
}
if(isset($lists)){
$block['subject'] = t('My !listname'.'s', array('!listname'=>t(variable_get('flag_lists_name', 'list'))));
// $block['subject'] = t('My !listname'.'s', array('!listname'=>t(variable_get('flag_lists_name', 'list'))));
$block['subject'] = t('My '.variable_get('flag_lists_name', 'list').'s');
$block['content'] = theme('materio_flag_mylists_block', array("lists"=>$lists, "viewmode"=>"bookmark"));
// $block['content'] = theme('flag_lists_user_page', array('uid' => $user->uid));
}else{
$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'] = t('No !listname yet. Add !listname on clicking on results star', array('!listname'=>variable_get('flag_lists_name', 'list')));
}
drupal_add_js(drupal_get_path('module', 'materio_flag').'/js/materio_flag-ck.js');
@ -183,7 +216,8 @@ function materio_flag_block_view($delta = '') {
$flags[$name] = $flag;
}
$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['content'] = theme('materio_flag_mylists_nav_block', array("flags"=>$flags));
// $block['content'] = theme('flag_lists_user_page', array('uid' => $user->uid));
}
@ -349,6 +383,25 @@ function materio_flag_get_entity_links($entity, $type, $view_mode = null){
return;
}
function _materio_flag_get_listpagetitle($flag){
$cont = '<i class="icon-materio-folder"></i>';
$cont .= '<span class="'.$flag->name.'">'.check_plain($flag->title).'</span>';
if(flag_lists_is_owner('edit', $flag->fid)){
$cont .= l('<i class="icon-wrench"></i>',
'flags/lists/edit/'.$flag->fid,
array(
'html'=>true,
'attributes'=>array('class'=>array('edit-list', $flag->name)),
)
);
}
return $cont;
}
/**
* Implements hook_theme().

View File

@ -70,7 +70,7 @@ function materio_flag_createlist_form($type){
// }
// } 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);
// dsm($f);
@ -130,6 +130,187 @@ function materio_flag_createlist_form($type){
}
/**
* materio_flag_editlist_form()
*/
function materio_flag_editlist_form($type, $fid){
$debug = false;
$path = 'flags/lists/edit/' . $fid;
// check if request is ajax, if not rediret
if (!$debug && (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest')) {
drupal_goto($path);
exit ;
}
// If name is numeric, then we have the fid, so get the name.
if (is_numeric($fid)) {
$name = db_select('flag_lists_flags', 'f')
->fields('f', array('name'))
->condition('fid', $fid)
->execute()
->fetchField();
}
if(flag_lists_is_owner('edit', $fid)){
$flag = flag_lists_get_flag($name);
$form = array(
'#type' => 'form',
'#id' => 'materio-flag-edit-list-form',
);
$form['type'] = array(
'#type' => 'hidden',
'#value' => $type,
'#name' => 'type',
);
$form['fid'] = array(
'#type' => 'hidden',
'#value' => $fid,
'#name' => 'fid',
);
$form['name'] = array(
'#type' => 'hidden',
'#value' => $name,
'#name' => 'name',
);
$form['listtitle'] = array(
'#type' => 'textfield',
'#title' => t('Edit this '.variable_get('flag_lists_name', 'list')),
'#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.'),
);
$form['actions'] = array(
'#prefix' => '<div class="actions">',
'#suffix' => '</div>',
);
$form['actions']['save'] = array(
'#type' => 'submit',
'#value' => t('save'),
'#name' => 'save',
);
$form['actions']['delete'] = array(
'#type' => 'submit',
'#value' => t('delete'),
'#name' => 'delete',
);
$form['actions']['cancel'] = array(
'#type' => 'button',
'#value' => t('cancel'),
'#name' => 'cancel',
);
// dsm($form, 'form');
$return = drupal_render($form);
$rep = array(
'return'=>$return,
);
}else{
$rep = array(
'status' => 'error',
'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);
}
}
function materio_flag_edit_list($fid, $name, $title){
$path = 'flags/lists/edit/' . $fid;
// check if request is ajax, if not rediret
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
drupal_goto($path);
exit ;
}
if(!flag_lists_is_owner('edit', $fid)){
$rep = array(
'error' => true,
'message' => t('You have not enough rights to edit this @name.', array('@name' => variable_get('flag_lists_name', t('list'))))
);
}else if (flag_lists_title_exists($title, 'materiau') || flag_lists_title_exists($title, 'breve')){
$rep = array(
'error' => true,
'message' => t('You already have a @name with this name.', array('@name' => variable_get('flag_lists_name', t('list'))))
);
}else{
$flag = flag_lists_get_flag($name);
$flag->title = $title;
flag_lists_set_messages($flag);
flag_lists_save($flag);
_flag_lists_clear_cache();
$rep = array(
'status' => 'saved',
'listname' => $name,
'listtitle' => $title,
);
}
drupal_json_output($rep);
}
function materio_flag_delete_list($fid){
$path = 'flags/lists/delete/' . $fid;
// check if request is ajax, if not rediret
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
drupal_goto($path);
exit ;
}
if(!flag_lists_is_owner('delete', $fid)){
$rep = array(
'error' => true,
'message' => t('You have not enough rights to delete this @name.', array('@name' => variable_get('flag_lists_name', t('list'))))
);
}else{
// If name is numeric, then we have the fid, so get the name.
if (is_numeric($fid)) {
$name = db_select('flag_lists_flags', 'f')
->fields('f', array('name'))
->condition('fid', $fid)
->execute()
->fetchField();
}
$flag = flag_lists_get_flag($name);
flag_lists_fl_delete($flag);
$rep = array(
'status' => 'saved',
);
}
drupal_json_output($rep);
}
function materio_flag_nodelinks(){
$nids = explode(';', $_REQUEST['nids']);
@ -157,7 +338,7 @@ function materio_flag_user_lists($fid){
$flag = flag_lists_get_flag($fid);
// dsm($flag, 'flag');
drupal_set_title('<i class="icon-materio-folder"></i>'.check_plain($flag->title), PASS_THROUGH);
drupal_set_title(_materio_flag_get_listpagetitle($flag), PASS_THROUGH);
$flaged_content = flag_lists_get_flagged_content($fid, $user->uid);
// dsm($flaged_content, 'flaged_content');
@ -195,7 +376,9 @@ function materio_flag_ajax_list($fid, $page = 0){
$_GET['page'] = $page;
$path = 'lists/'.$fid;
$list_path = 'lists';
$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')) {
@ -203,6 +386,28 @@ function materio_flag_ajax_list($fid, $page = 0){
exit;
}
if(isset($_GET['current_path'])){
// dsm($_GET['current_path'], '$_GET[current_path]');
// url() generates the prefix using hook_url_outbound_alter(). Instead of
// running the hook_url_outbound_alter() again here, extract the prefix
// from url().
url('', array('prefix' => &$prefix));
$cur_path = str_replace($base_url.base_path().$prefix, '', $_GET['current_path']);
// dsm($cur_path, 'cur_path');
$cur_is_list_path = strpos($cur_path, $list_path);
// dsm($matches, '$matches');
if($cur_is_list_path === false){
$rep = array(
"redirect" => $base_url.base_path().$prefix.$path,
);
drupal_json_output($rep);
exit;
}
}
// get results
menu_set_active_item($path);
$return = menu_execute_active_handler($path, FALSE);

View File

@ -257,7 +257,10 @@ function materio_search_api_results_search(){
function materio_search_api_actuality(){
global $user;
$date = strtotime('-6 month');
if(!user_access('use materio search api')){
$date = strtotime('-6 month');
// dsm($date);
}
$viewmode = isset($user->data['materiosearchapi_viewmode']) ? $user->data['materiosearchapi_viewmode'] : variable_get('defaultviewmode', 'full');
$limit = 10;//variable_get($viewmode.'_limite', '10');
@ -269,21 +272,26 @@ function materio_search_api_actuality(){
->entityCondition('entity_type', 'node')
->propertyCondition('status', 1)
->entityCondition('bundle', array('breve'))
->propertyCondition('created', $date, '>')
->propertyOrderBy('created', 'DESC')
->range($offset,$limit);
if(!user_access('use materio search api')){
$query->propertyCondition('created', $date, '>');
}
$result = $query->execute();
// dsm($result, '$result');
$count_query = new EntityFieldQuery;
$count = $count_query
$count_query
->entityCondition('entity_type', 'node')
->propertyCondition('status', 1)
->entityCondition('bundle', array('breve'))
->propertyCondition('created', $date, '>')
->count()->execute();
->entityCondition('bundle', array('breve'));
// dsm($count, 'count');
if(!user_access('use materio search api')){
$count_query->propertyCondition('created', $date, '>');
}
$count = $count_query->count()->execute();
pager_default_initialize($count, $limit);

View File

@ -25,7 +25,6 @@ function materio_search_api_ajax_init() {
'languages' => isset($languages) ? $languages[1] : array(),
)), 'setting');
drupal_add_js(drupal_get_path('module', 'materio_search_api_ajax').'/js/libraries/jquery.history.js');
drupal_add_js(drupal_get_path('module', 'materio_search_api_ajax').'/js/materio_search_api_ajax-ck.js');
}

View File

@ -3,10 +3,22 @@
function materio_search_api_ajax_search($keys, $page = 0){
$debug = false;
global $user;
global $user, $base_url;
// TODO: set research path configurable
$search_path = "explore";
# execute search
$_GET['page'] = $page;
$path = $search_path . '/' . $keys ;//. ($page ? '?page='.$page : '');
// dsm($menuhandler, 'menuhandler');
// 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')) {
drupal_goto($path, array(), 301);
exit ;
}
# content type filter s
// $types = $_GET['types'];
if(isset($_GET['types'])){
@ -31,16 +43,25 @@ function materio_search_api_ajax_search($keys, $page = 0){
user_save($user, array("data"=>array('materiosearchapi_bundlesfilter' => $active_types)));
# execute search
$_GET['page'] = $page;
if(isset($_GET['current_path'])){
// dsm($_GET['current_path'], '$_GET[current_path]');
// url() generates the prefix using hook_url_outbound_alter(). Instead of
// running the hook_url_outbound_alter() again here, extract the prefix
// from url().
url('', array('prefix' => &$prefix));
$path = $search_path . '/' . $keys ;//. ($page ? '?page='.$page : '');
// dsm($menuhandler, 'menuhandler');
$cur_path = str_replace($base_url.base_path().$prefix, '', $_GET['current_path']);
// dsm($cur_path, 'cur_path');
// 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')) {
drupal_goto($path, array(), 301);
exit ;
$cur_is_search_path = strpos($cur_path, $search_path);
// dsm($matches, '$matches');
if($cur_is_search_path === false){
$rep = array(
"redirect" => $base_url.base_path().$prefix.$path,
);
drupal_json_output($rep);
exit;
}
}
// get results
@ -116,6 +137,8 @@ function materio_search_api_ajax_viewmode_change($vm){
function materio_search_api_ajax_actuality($page = 0){
$debug = false;
$_GET['page'] = $page;
$path = 'actuality';
@ -126,6 +149,28 @@ function materio_search_api_ajax_actuality($page = 0){
exit ;
}
// if(isset($_GET['current_path'])){
// // dsm($_GET['current_path'], '$_GET[current_path]');
// // url() generates the prefix using hook_url_outbound_alter(). Instead of
// // running the hook_url_outbound_alter() again here, extract the prefix
// // from url().
// url('', array('prefix' => &$prefix));
// $cur_path = str_replace($base_url.base_path().$prefix, '', $_GET['current_path']);
// // dsm($cur_path, 'cur_path');
// $cur_is_search_path = strpos($cur_path, $search_path);
// // dsm($matches, '$matches');
// if($cur_is_search_path === false){
// $rep = array(
// "redirect" => $base_url.base_path().$prefix.$path,
// );
// drupal_json_output($rep);
// exit;
// }
// }
// get results
menu_set_active_item($path);
$return = menu_execute_active_handler($path, FALSE);

23
materio_user.info Normal file
View File

@ -0,0 +1,23 @@
name = Materio User
description = "Materio user generalist module"
; 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

22
materio_user.module Normal file
View File

@ -0,0 +1,22 @@
<?php
/**
* Implements hook_permission().
*/
function materio_user_permission() {
return array(
'view own user profile' => array(
'title' => t('view own user profile'),
'description' => t('view own user profile'),
),
);
}
/**
* Implements hook_menu_alter().
*/
function materio_user_menu_alter(&$items) {
$items['user/%user']['access callback'] = 'user_access';
$items['user/%user']['access arguments'] = array('view own user profile');
}

View File

@ -8,7 +8,7 @@
</span>
<a class="open-list" href="<?php print $list['list']->path; ?>">
<?php //print t('open this @name', array('@name'=>variable_get('flag_lists_name', 'list'))) ;?>
<?php print t('open'); ?>
<i class="icon-resize-full"></i>
</a>
</h2>
<div class="flaged <?php print $list['list']->name; ?>"> <?php print render(entity_view('node', $list['content'], $viewmode)); ?> </div>

View File

@ -4,6 +4,17 @@
<?php //dsm($flag, 'flag') ;?>
<li class="flaglist <?php print $flag->name; ?>">
<?php print l($flag->title . '<span class="count">('.count($flag->flaged_content).')</span>', 'lists/'.$flag->fid, array('html'=>true,'attributes'=>array('class'=>array('open-list', $flag->name)))); ?>
<?php if(flag_lists_is_owner('edit', $flag->fid)): ?>
<?php
print l('<i class="icon-wrench"></i>',
'flags/lists/edit/'.$flag->fid,
array(
'html'=>true,
'attributes'=>array('class'=>array('edit-list', $flag->name)),
)
);
?>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>