-
-
Save ss81/ddba0aa6f580f162602d to your computer and use it in GitHub Desktop.
Check what nodequeues are used in views
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Check what nodequeues are used in views | |
* | |
* Usage: | |
* drush ev "luxian_nodequeue_stats();" | |
*/ | |
function luxian_nodequeue_stats() { | |
if (!drupal_is_cli()) { | |
return; | |
} | |
$nodequeues = db_select('nodequeue_queue', 'nq') | |
->fields('nq', array('name', 'title')) | |
->execute() | |
->fetchAllAssoc('name'); | |
$q = db_select('views_view', 'vv'); | |
$q->fields('vv', array('vid', 'name', 'human_name')); | |
$q->leftJoin('views_display', 'vd', 'vd.vid = vv.vid'); | |
$q->fields('vd', array('id', 'display_title', 'display_options')); | |
$q->addExpression("CONCAT(vv.name, ':', vd.id)", 'display_full_id'); | |
$results = $q->execute()->fetchAllAssoc('display_full_id'); | |
foreach($results as $key => $result) { | |
$result->display_options = unserialize($result->display_options); | |
if (isset($result->display_options['relationships']['nodequeue_rel'])) { | |
$relationship = $result->display_options['relationships']['nodequeue_rel']; | |
foreach($relationship['names'] as $key => $value) { | |
if (!empty($value) && $key == $value && isset($nodequeues[$key])) { | |
$nodequeues[$key]->views[$result->name]['human_name'] = $result->human_name; | |
$nodequeues[$key]->views[$result->name]['displays'][$result->id] = $result->display_title; | |
} | |
} | |
} | |
} | |
$indentation = "\t"; | |
foreach($nodequeues as $nq) { | |
echo "{$nq->title} ({$nq->name})\n"; | |
if (empty($nq->views)) { | |
echo $indentation . "Not used in any view\n"; | |
} | |
else { | |
foreach($nq->views as $view_id => $view) { | |
echo $indentation . "{$view['human_name']} ($view_id):\n"; | |
foreach($view['displays'] as $display_id => $human_name) { | |
echo $indentation . $indentation . "$human_name ($display_id)\n"; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment