first global commit

This commit is contained in:
2020-09-23 15:50:29 +02:00
commit 78adf3a099
6052 changed files with 1221183 additions and 0 deletions
@@ -0,0 +1,43 @@
<?php
class NodeEntityFieldQuery extends EntityFieldQuery {
// define some defaults for the class
public function __construct() {
// now we don't need to define these over and over anymore
$this
->entityCondition('entity_type', 'node')
->propertyCondition('status', 1);
}
}
class EffectuationEntityFieldQuery extends NodeEntityFieldQuery {
// define some defaults for the class
public function __construct() {
// now we don't need to define these over and over anymore
$this
->entityCondition('bundle', array('effectuation'))
->fieldCondition('field_performances', 'target_id', 'NULL', '!=')
->fieldOrderBy('field_date_de_debut', 'value', 'ASC');
}
}
// class PerformanceEntityFieldQuery extends NodeEntityFieldQuery {
// // define some defaults for the class
// public function __construct() {
// // now we don't need to define these over and over anymore
// $this
// ->entityCondition('bundle', array('performance'));
// }
// }
/*
class PerformancesEntityFieldQuery extends NodeEntityFieldQuery {
// define some defaults for the class
public function __construct() {
// now we don't need to define these over and over anymore
$this
->entityCondition('bundle', array('performance'));
}
}
*/
@@ -0,0 +1,30 @@
name = Perfart
description = "This module provide panels panes and pages for performance-art.fr using EntityFieldQuery"
; Core version (required)
core = 7.x
; Package name (see http://drupal.org/node/542202 for a list of names)
; package =
; PHP version requirement (optional)
; php = 5.2
; Loadable code files
files[] = perfart.class.inc
files[] = perfart.pages.inc
files[] = templates/node--document--cel.tpl.php
files[] = perfart.module
; Module dependencies
dependencies[] = ctools
; dependencies[] = anothermodule (>=2.4)
; dependencies[] = views (3.x)
; Configuration page
; configure = admin/config/perfart
; For further information about configuration options, see
; - http://drupal.org/node/542202
@@ -0,0 +1,212 @@
<?php
/**
* @file
* This is the file description for Perfart module.
*
* In this more verbose, multi-line description, you can specify what this
* file does exactly. Make sure to wrap your documentation in column 78 so
* that the file can be displayed nicely in default-sized consoles.
*/
define('PERFART_ELMTS_BY_PAGE', 100);
/**
* Implements hook_menu().
*/
function perfart_menu() {
$items = array();
$base = array(
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
'file' => 'perfart.pages.inc',
);
$items['perfart/ajax/dates'] = $base+array(
'title' => 'List of dates',
'page callback' => 'perfart_get_dates',
'page arguments' => array(3),
);
$items['perfart/ajax/perf'] = $base+array(
'title' => 'content of one perf',
'page callback' => 'perfart_get_perf',
'page arguments' => array(3),
);
$items['perfart/ajax/home'] = $base+array(
'title' => 'content of home page',
'page callback' => 'perfart_get_home',
'page arguments' => array(),
);
$items['perfart/performances'] = $base+array(
'title' => 'List of performances',
'page callback' => 'perfart_get_performances',
'page arguments' => array(),
);
$items['perfart/search'] = $base+array(
'title' => 'search performances',
'page callback' => 'perfart_search',
'page arguments' => array(),
);
$items['perfart/search_api'] = $base+array(
'title' => 'search performances (through search_api)',
'page callback' => 'perfart_search_api',
'page arguments' => array(),
);
// $items['perfart/ajax/filters'] = array(
// 'title' => 'List of filters blocks (taxonomy terms)',
// 'page callback' => 'perfart_get_filters',
// 'access callback' => TRUE,
// 'file' => 'perfart.pages.inc',
// 'page arguments' => array(),
// );
// $items['perfart/update_cer'] = array(
// 'title' => 'Updating Corresponding entity reference',
// 'page callback' => 'perfart_update_cer',
// 'access callback' => TRUE,
// 'file' => 'perfart.pages.inc',
// 'page arguments' => array(2),
// );
return $items;
}
/**
* Implements hook_ctools_plugin_directory -
* This lets ctools know to scan my module for a content_type plugin file
* Detailed docks in ctools/ctools.api.php
*/
function perfart_ctools_plugin_directory($owner, $plugin_type) {
// we'll be nice and limit scandir() calls
if ($owner == 'ctools' && $plugin_type == 'content_types') {
return 'plugins/content_types';
}
}
/**
* Implements hook_entity_info_alter().
*/
function perfart_entity_info_alter(&$entity_info) {
// Set the controller class for nodes to an alternate implementation of the
// DrupalEntityController interface.
// dsm($entity_info, '$entity_info');
$entity_info['node']['view modes']['short_infos'] = array(
'label' => t('Short infos'),
'custom settings' => TRUE,
);
$entity_info['node']['view modes']['views_table_cel'] = array(
'label' => t('Views table cel'),
'custom settings' => TRUE,
);
$entity_info['node']['view modes']['gridready'] = array(
'label' => t('Grid ready (timeline)'),
'custom settings' => TRUE,
);
}
/**
* Implements hook_preprocess_node().
*/
function perfart_preprocess_node(&$vars) {
// dsm($vars, '$vars node');
// if($vars['view_mode'] == 'short_infos') {
// $vars['theme_hook_suggestions'][] = 'node__short_infos';
// $vars['theme_hook_suggestions'][] = 'node__' . $vars['type'] . '__short_infos';
// }
// if($vars['view_mode'] == 'views_table_cel') {
// $vars['theme_hook_suggestions'][] = 'node__cel';
// $vars['theme_hook_suggestions'][] = 'node__' . $vars['type'] . '__cel';
// }
$vars['theme_hook_suggestions'][] = 'node__'.$vars['view_mode'];
$vars['theme_hook_suggestions'][] = 'node__' . $vars['type'] . '__' . $vars['view_mode'];
}
function perfart_preprocess_field(&$vars) {
// dsm($vars, '$vars field');
$vars['theme_hook_suggestions'][] = 'field__' . $vars['element']['#view_mode'];
$vars['theme_hook_suggestions'][] = 'field__' . $vars['element']['#field_type'] . '__' . $vars['element']['#view_mode'];
$vars['theme_hook_suggestions'][] = 'field__' . $vars['element']['#field_name'] . '__' . $vars['element']['#view_mode'];
}
/**
* Implements hook_theme().
*/
function perfart_theme($existing, $type, $theme, $path) {
$items = array();
$path = drupal_get_path('module', 'perfart') .'/templates';
$items['node__document__short_infos'] = array(
'render element' => 'form',
'path' => $path,
'template' => 'node--document--short_infos',
// 'preprocess functions' => array(
// 'rubik_preprocess_form_confirm'
// ),
);
$items['node__document__cel'] = array(
'render element' => 'form',
'path' => $path,
'template' => 'node--document--cel',
);
/*
TODO themable timeline item content
*/
// $items['timeline__item_content'] = array(
// 'render element' => 'form',
// 'path' => $path,
// 'template' => 'timeline--item-content',
// );
// $items['perfart_performances'] = array(
// 'path' => $path,
// 'template' => 'perfart-performances',
// );
return $items;
}
/**
* Implements hook_init().
*/
function perfart_init() {
$query = new EffectuationEntityFieldQuery;
$count = $query->count()->execute();
$pages = ceil($count / PERFART_ELMTS_BY_PAGE);
// drupal_set_message("pages : ".$pages);
drupal_add_js(array('perfart' => array(
'effectuations_pages' => $pages,
'strings'=>array(
'topologies'=> t('topologies'),
'places'=> t('places'),
'peoples' => t('peoples'),
),
)), 'setting');
}
/**
* Implements hook_menu_get_item_alter().
*/
// function perfart_menu_get_item_alter(&$router_item, $path, $original_map){
// dsm($router_item, 'router_item');
// dsm($path, 'path');
// dsm($original_map, 'original_map');
// }
@@ -0,0 +1,637 @@
<?php
/**
* perfart_get_dates()
*
*/
function perfart_get_dates($page = 0, $debug = false){
// dsm($page, '$page');
global $language;
// dsm($language, '$language : '.$language->language);
$query = new EffectuationEntityFieldQuery;
$query
->range(PERFART_ELMTS_BY_PAGE*$page, PERFART_ELMTS_BY_PAGE);
// ->pager(10, $page);
// ->propertyOrderBy('created', 'DESC');
$result = $query->execute();
// dsm($result, '$result');
$data = array();
foreach ($result['node'] as $eff) {
$eff = node_load($eff->nid);
//$eff = entity_load('node', array($eff->nid), NULL, FALSE);
// dsm($eff, '$eff');
# dates
if(!isset($eff->field_date_de_debut) || !isset($eff->field_performances))
continue;
$debut = $eff->field_date_de_debut['und'][0]['value'];
//1969/06/06-18:00
$pattern = '/^(\d{4})\/?(\d{2})?\/?(\d{2})?-?(\d{2})?:?+(\d{2})?$/';
preg_match($pattern, $debut, $debutMatches);
if(!isset($debutMatches[1]))
continue;
if(isset($eff->field_date_de_fin['und'])){
$fin = $eff->field_date_de_fin['und'][0]['value'];
preg_match($pattern, $fin, $finMatches);
}else{
$fin = false;
}
# lieu
$lieu_values = field_get_items('node',$eff,'field_lieu');
$lieu_values = $lieu_values ? $lieu_values : array();
// dsm($lieu_values, '$lieu_values');
$lieu = array();
foreach ($lieu_values as $value) {
$term = taxonomy_term_load($value['tid']);
if(!$term) continue;
$term = i18n_taxonomy_localize_terms($term);
// dsm($term, '$term');
$lieu[$term->tid] = array(
'tid' => $term->tid,
'name' => t($term->name),
);
}
# topologie
$topologie_values = field_get_items('node',$eff,'field_topologie');
// dsm($topologie_values, '$topologie_values');
$topologies = array();
if($topologie_values){
foreach ($topologie_values as $value) {
$term = taxonomy_term_load($value['tid']);
if(!$term) continue;
$term = i18n_taxonomy_localize_terms($term);
$topologies[$term->tid] = array(
'tid' => $term->tid,
'name' => $term->name,
);
}
}
$perfadded = array();
foreach ($eff->field_performances['und'] as $perf) {
if(in_array($perf['target_id'], $perfadded))
continue;
$perfadded[] = $perf['target_id'];
$perf = node_load($perf['target_id']);
// $perf = entity_load('node', array($perf['target_id']), NULL, FALSE);
// dsm($perf, '$perf');
$prefix = $language->language == 'fr' ? 'en/' : '';
$date = array(
"nid"=>$perf->nid,
"filters" => array(),
'ajax_link'=> 'perfart/ajax/perf/'.$perf->nid,
'node_link'=> drupal_get_path_alias('node/'.$perf->nid, $language->language),
'node_translation'=> $prefix . drupal_get_path_alias('node/'.$perf->nid, $language->language == 'fr' ? 'en' : 'fr'),
'perf_title'=>$perf->title,
'language'=>$language,
);
#images
if($images_values= field_get_items('node',$perf,'field_images')){
//dsm($images_values, '$images_values');
$image = theme('image_style', array(
'style_name'=>'timeline_thumbnail',
'path'=>$images_values[0]['uri'],
));
//$content .= $image;
// dsm($image, 'image');
$date['thumb'] = $image;
}
# timeline content + concepteurs filter
$content = '<div href="perfart/ajax/perf/'.$perf->nid.'" class="date" nid="'.$perf->nid.'" >';//thumb="'.$date['thumb'].'"
$content .= '<div class="text-content">';
$content .= '<h4>'.$perf->title.'</h4>';
#concepteur
$concepteurs_values= field_get_items('node',$perf,'field_concepteur');
$personnes = array();
if($concepteurs_values){
$concepteurs = array();
foreach ($concepteurs_values as $concepteur) {
$concepteur_term = taxonomy_term_load($concepteur['tid']);
if(!$concepteur_term) continue;
// dsm($concepteur_term);
$field_nom_values = field_get_items('taxonomy_term', $concepteur_term , 'field_nom');
$field_prenom_values = field_get_items('taxonomy_term', $concepteur_term, 'field_prenom');
$concepteurs[] = $concepteur_term->name;
$personnes[$concepteur_term->tid] = array(
"tid" => $concepteur_term->tid,
"name" => $concepteur_term->name,
"nom" => $field_nom_values[0]['value'],
"prenom" => $field_prenom_values[0]['value'],
);
}
$content .= '<h5>'.implode(', ', $concepteurs).'</h5>';
}
$content .= '</div>';
## close content link
$content .= '</div>';
# timeline array with dates
$date += array(
'content'=> $content,
'start'=>array(
'year'=>$debutMatches[1],
'month'=>isset($debutMatches[2]) ? $debutMatches[2] : null,
'day'=>isset($debutMatches[3]) ? $debutMatches[3] : null,
),
);
if($fin && false) // deactivated end date because ranges cause display probleme on the timeline
$date['end'] = array(
'year'=>isset($finMatches[1]) ? $finMatches[1] : null,
'month'=>isset($finMatches[2]) ? $finMatches[2] : null,
'day'=>isset($finMatches[3]) ? $finMatches[3] : null,
);
# filter organisateur
$organisateur_values= field_get_items('node',$perf,'field_organisateur');
// dsm($organisateur_values, 'org');
if($organisateur_values){
foreach ($organisateur_values as $personne) {
$term = taxonomy_term_load($personne['tid']);
if(!$term) continue;
// dsm($term);
$field_nom_values = field_get_items('taxonomy_term', $term , 'field_nom');
$field_prenom_values = field_get_items('taxonomy_term', $term, 'field_prenom');
$personnes[$term->tid] = array(
"tid" => $term->tid,
"name" => $term->name,
"nom" => $field_nom_values[0]['value'],
"prenom" => $field_prenom_values[0]['value'],
);
}
}
# filter participants
$participants_values= field_get_items('node',$perf,'field_participant');
// dsm(count($participants_values), 'part');
if($participants_values){
foreach ($participants_values as $personne) {
$term = taxonomy_term_load($personne['tid']);
if(!$term) continue;
// dsm($term);
$field_nom_values = field_get_items('taxonomy_term', $term , 'field_nom');
$field_prenom_values = field_get_items('taxonomy_term', $term, 'field_prenom');
$personnes[$term->tid] = array(
"tid" => $term->tid,
"name" => $term->name,
"nom" => $field_nom_values[0]['value'],
"prenom" => $field_prenom_values[0]['value'],
);
}
}
# filter topologie flag
$date["filters"]['topologies'] = $topologies;
# filter lieu flag
$date['filters']['places'] = $lieu;
# filter artistes
$date['filters']['peoples'] = $personnes;
$data[] = $date;
}
}
// if($debug){
// dsm($data, '$data');
// return t('perfart_get_dates debug mode');
// }else{
drupal_json_output($data);
// }
}
/**
* perfart_get_perf()
* home page classical (no-js)
*
*/
function perfart_get_performances(){
// dsm($page, '$page');
global $language;
// dsm($language, '$language : '.$language->language);
$limit = 100;//variable_get($viewmode.'_limite', '10');
$offset = pager_find_page() * $limit;
$query = new EffectuationEntityFieldQuery;
$query
->range($offset,$limit);
// ->pager(10, $page);
// ->propertyOrderBy('created', 'DESC');
$result = $query->execute();
// dsm($result, '$result');
$count_query = new EffectuationEntityFieldQuery;
$count = $count_query->count()->execute();
pager_default_initialize($count, $limit);
$data = array();
foreach ($result['node'] as $eff) {
$eff = node_load($eff->nid);
//$eff = entity_load('node', array($eff->nid), NULL, FALSE);
// dsm($eff, '$eff');
# dates
if(!isset($eff->field_date_de_debut) || !isset($eff->field_performances))
continue;
$debut = $eff->field_date_de_debut['und'][0]['value'];
//1969/06/06-18:00
$pattern = '/^(\d{4})\/?(\d{2})?\/?(\d{2})?-?(\d{2})?:?+(\d{2})?$/';
preg_match($pattern, $debut, $debutMatches);
if(!isset($debutMatches[1]))
continue;
if(isset($eff->field_date_de_fin['und'])){
$fin = $eff->field_date_de_fin['und'][0]['value'];
preg_match($pattern, $fin, $finMatches);
}else{
$fin = false;
}
# lieu
// $lieu_values = field_get_items('node',$eff,'field_lieu');
// $lieu_values = $lieu_values ? $lieu_values : array();
// // dsm($lieu_values, '$lieu_values');
// $lieu = array();
// foreach ($lieu_values as $value) {
// $term = taxonomy_term_load($value['tid']);
// $term = i18n_taxonomy_localize_terms($term);
// // dsm($term, '$term');
// $lieu[$term->tid] = array(
// 'tid' => $term->tid,
// 'name' => t($term->name),
// );
// }
# topologie
// $topologie_values = field_get_items('node',$eff,'field_topologie');
// // dsm($topologie_values, '$topologie_values');
// $topologies = array();
// if($topologie_values){
// foreach ($topologie_values as $value) {
// $term = taxonomy_term_load($value['tid']);
// $term = i18n_taxonomy_localize_terms($term);
// $topologies[$term->tid] = array(
// 'tid' => $term->tid,
// 'name' => $term->name,
// );
// }
// }
$perfadded = array();
foreach ($eff->field_performances['und'] as $perf) {
if(in_array($perf['target_id'], $perfadded))
continue;
$perfadded[] = $perf['target_id'];
$perf = node_load($perf['target_id']);
// $perf = entity_load('node', array($perf['target_id']), NULL, FALSE);
// dsm($perf, '$perf');
// $prefix = $language->language == 'fr' ? 'en/' : '';
// $date = array(
// "nid"=>$perf->nid,
// "filters" => array(),
// 'ajax_link'=> 'perfart/ajax/perf/'.$perf->nid,
// 'node_link'=> drupal_get_path_alias('node/'.$perf->nid, $language->language),
// 'node_translation'=> $prefix . drupal_get_path_alias('node/'.$perf->nid, $language->language == 'fr' ? 'en' : 'fr'),
// 'perf_title'=>$perf->title,
// 'language'=>$language,
// );
$node_path = drupal_get_path_alias('node/'.$perf->nid, $language->language);
$node_link = l($debutMatches[1] .' | '. $perf->title,$node_path, array('html'=>true));
# timeline content + concepteurs filter
$content = '<div class="date" nid="'.$perf->nid.'" >';
// $content .= '<div class="text-content">';
$content .= '<h4>'.$node_link.'</h4>';
#concepteur
$concepteurs_values= field_get_items('node',$perf,'field_concepteur');
$personnes = array();
if($concepteurs_values){
$concepteurs = array();
foreach ($concepteurs_values as $concepteur) {
// $concepteur_term = taxonomy_term_load($concepteur['tid']);
try {
$concepteur_term = taxonomy_term_load($concepteur['tid']);
} catch (Exception $e) {
throw new Exception( 'taxonomy_term_load didn\'t', 0, $e);
continue;
}
// dsm($concepteur_term);
$concepteurs[] = $concepteur_term->name;
// $personnes[$concepteur_term->tid] = array(
// "tid" => $concepteur_term->tid,
// "name" => $concepteur_term->name,
// );
}
$content .= '<h5>'.implode(', ', $concepteurs).'</h5>';
}
#images
if($images_values= field_get_items('node',$perf,'field_images')){
//dsm($images_values, '$images_values');
$image = theme('image_style', array(
'style_name'=>'home_no_js',
'path'=>$images_values[0]['uri'],
));
//$content .= $image;
// dsm($image, 'image');
$date['thumb'] = l($image, $node_path, array('html'=>true));
$content .= $date['thumb'];
}
// $content .= '</div>';
## close content link
$content .= '</div>';
# timeline array with dates
// $date += array(
// 'content'=> $content,
// 'start'=>array(
// 'year'=>$debutMatches[1],
// 'month'=>isset($debutMatches[2]) ? $debutMatches[2] : null,
// 'day'=>isset($debutMatches[3]) ? $debutMatches[3] : null,
// ),
// );
# filter organisateur
// $organisateur_values= field_get_items('node',$perf,'field_organisateur');
// // dsm($organisateur_values, 'org');
// if($organisateur_values){
// foreach ($organisateur_values as $personne) {
// $term = taxonomy_term_load($personne['tid']);
// // dsm($term);
// $personnes[$term->tid] = array(
// "tid" => $term->tid,
// "name" => $term->name,
// );
// }
// }
# filter participants
// $participants_values= field_get_items('node',$perf,'field_participant');
// // dsm(count($participants_values), 'part');
// if($participants_values){
// foreach ($participants_values as $personne) {
// $term = taxonomy_term_load($personne['tid']);
// // dsm($term);
// $personnes[$term->tid] = array(
// "tid" => $term->tid,
// "name" => $term->name,
// );
// }
// }
# filter topologie flag
// $date["filters"]['topologies'] = $topologies;
# filter lieu flag
// $date['filters']['places'] = $lieu;
# filter artistes
// $date['filters']['peoples'] = $personnes;
pager_default_initialize($count, $limit);
// $data[] = $date;
$list['items'][] = $content;
}
}
// dsm($data, '$data');
return theme('item_list', $list) . theme('pager');
}
/**
* perfart_search()
* ajax search
*
*/
function perfart_search(){
$keys = rawurldecode($_GET['keys']);
$return = array('keys' => $keys);
$module = 'node';
if (!empty($module)) {
$active_module_info = search_get_info();
if (isset($active_module_info[$module])) {
$info = $active_module_info[$module];
}
}
$return['info'] = $info;
// $results = search_data($keys, $info['module'], $conditions);
if($results = search_data($keys, $info['module'])){
foreach ($results['#results'] as $result) {
$return['results'][] = $result['node']->nid;
}
}
drupal_json_output($return);
}
/**
* perfart_search_api()
* ajax search_api
*
*/
function perfart_search_api(){
$typed = rawurldecode($_GET['typed']);
preg_match_all('/\s?[^\s]+\s?/', $typed, $words);
// dsm($words, "words");
foreach ($words[0] as $word) {
// dsm($word);
$word = trim($word);
// $word = str_replace($match, $replace, $word);
// dsm($word, 'word');
$keys[] = $word;
}
// dsm($keys, 'keys');
global $language;
$return = array('keys' => $keys);
$index_machine_name = $language->language == 'fr' ? 'performances_fr' : 'performance_en';
$index = search_api_index_load($index_machine_name);
if ($keys) {
$query = search_api_query($index_machine_name, array('conjunction'=>'OR', 'parse mode'=>'direct'))->keys(implode(' ', $keys));
$results = $query->execute();
$return['results'] = $index->loadItems(array_keys($results['results']));
}
drupal_json_output($return);
}
/**
* perfart_get_perf()
* get one perf through ajax
*
*/
function perfart_get_perf($nid = false){
if($nid){
global $language;
//dsm($language, 'language');
$node = node_load($nid);
// dsm($node, '$node');
$node_view = node_view($node, "gridready", $language->language);
// dsm($node_view, '$node_view');
$response = array(
"node_view"=>render($node_view),
"nid"=>$nid,
);
// dsm($response, '$response');
// return 'debug mode of perfart_get_perf()';
drupal_json_output($response);
}else{
return false;
}
}
/**
*
* perfart_get_home()
*
*/
function perfart_get_home(){
$return = array();
global $language;
$return['language'] = $language;
$front = node_view(node_load(1), 'full', $language->language);
// dsm($front, 'front');
$frontrendered = drupal_render($front);
$return['front'] = $frontrendered;
// dsm($frontrendered, '$frontrendered');
// return 'debug mode of perfart_get_home()';
drupal_json_output($return);
}
/**
* DEV
*
*/
function perfart_update_cer($page = 0){
$itemsbypage = 100;
$query = new EntityFieldQuery;
$query
->entityCondition('entity_type', 'node')
->entityCondition('bundle', array('performance'))
->fieldCondition('field_effectuations', 'target_id', 'NULL', '!=')
->range($page*$itemsbypage, $itemsbypage);
// ->propertyCondition('status', 1)
// ->pager(100, 1);
// ->propertyOrderBy('created', 'DESC');
$result = $query->execute();
//
$delta = 0;
if(count($result['node'])){
foreach ($result['node'] as $nid => $node) {
$node = node_load($nid);
// dsm($node);
// // module_invoke_all('entity_update', $node, 'node');
corresponding_entity_references_processing_entity('update', $node, 'node');
// node_save($node);
$delta++;
}
}
// dsm($delta);
return $delta." nodes where updated.";
}
function perfart_clear_effectuations_perf_ref($page = 0){
$itemsbypage = 100;
$query = new EntityFieldQuery;
$query
->entityCondition('entity_type', 'node')
->entityCondition('bundle', array('effectuation'))
->fieldCondition('field_performances', 'target_id', 'NULL', '!=')
->range($page*$itemsbypage, $itemsbypage);
// ->propertyCondition('status', 1)
// ->pager(100, 1);
// ->propertyOrderBy('created', 'DESC');
$result = $query->execute();
//
$delta = 0;
if(count($result['node'])){
foreach ($result['node'] as $nid => $node) {
$node = node_load($nid);
// dsm($node);
$node->field_performances = NULL;
// // module_invoke_all('entity_update', $node, 'node');
// corresponding_entity_references_processing_entity('update', $node, 'node');
node_save($node);
$delta++;
}
}
// dsm($delta);
return $delta." nodes where updated.";
}
@@ -0,0 +1,68 @@
<?php
/**
* This plugin array is more or less self documenting
*/
$plugin = array(
// the title in the admin
'title' => t('Perf Art test pane'),
// no one knows if "single" defaults to FALSE...
'single' => TRUE,
// oh joy, I get my own section of panel panes
'category' => array(t('Perf Art'), -9),
'edit form' => 'perfart_test_pane_content_type_edit_form',
'render callback' => 'perfart_test_pane_content_type_render'
);
/**
* Run-time rendering of the body of the block (content type)
* See ctools_plugin_examples for more advanced info
*/
function perfart_test_pane_content_type_render($subtype, $conf, $context = NULL) {
// our output is generate by js. Any markup or theme functions
// could go here.
// that private js function is so bad that fixing it will be the
// basis of the next tutorial
$block->content = t('hello');
return $block;
}
/**
* 'Edit form' callback for the content type.
*/
function perfart_test_pane_content_type_edit_form(&$form, &$form_state) {
$conf = $form_state['conf'];
$form['twitter_username'] = array(
'#type' => 'textfield',
'#title' => t('twitter username'),
'#size' => 50,
'#description' => t('A valid twitter username.'),
'#default_value' => !empty($conf['twitter_username']) ? $conf['twitter_username'] : 'nicklewisatx',
);
// no submit
return $form;
}
/**
* Submit function, note anything in the formstate[conf] automatically gets saved
*/
function perfart_test_pane_content_type_edit_form_submit(&$form, &$form_state) {
$form_state['conf']['twitter_username'] = $form_state['values']['twitter_username'];
}
/**
* This js handling kills kittens.
*/
function _gtwit_ghetto_js_that_is_bad($twitter_username) {
$output = '<script src="<a href="http://widgets.twimg.com/j/2/widget.js">http://widgets.twimg.com/j/2/widget.js</a>"></script>';
$output .= "<script>new TWTR.Widget({
version:2,type:'profile',rpp:3,interval:6000,width:'auto',height:'auto',theme:{shell:{background:'#ffffff',color:'#000000'},
tweets:{background:'#ffffff',color:'#000000',links:'#227eb3'}},
features:{scrollbar:false,loop:false,live:false,hashtags:true,timestamp:true,avatars:false,behavior:'all'}}).render().setUser('$twitter_username').start();
</script>";
return $output;
}
@@ -0,0 +1,5 @@
<a href="<?php print $node_url ?>"><?php print $title ?></a>
<?php if (!empty($content)): ?>
<?php print render($content) ?>
<?php endif; ?>