FINAL suepr merge step : added all modules to this super repos
This commit is contained in:
25
sites/all/modules/contrib/dev/queue_ui/lib/QueueUI.php
Normal file
25
sites/all/modules/contrib/dev/queue_ui/lib/QueueUI.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
|
||||
class QueueUI {
|
||||
|
||||
/**
|
||||
* Return the QueueUI class object for working with.
|
||||
*
|
||||
* @param $class
|
||||
* The queue class name to work with.
|
||||
*
|
||||
* @return mixte
|
||||
* The queue object for a given name, or FALSE if the QueueUI class does not exist for
|
||||
* the specified queue class.
|
||||
*/
|
||||
public static function get($class) {
|
||||
if (class_exists($class)) {
|
||||
$object = new $class();
|
||||
return $object;
|
||||
}
|
||||
|
||||
// If class does not exist then QueueUI has not been implemented for this class.
|
||||
return FALSE;
|
||||
}
|
||||
}
|
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Declares the Queue UI interface for inspecting queue data.
|
||||
*/
|
||||
|
||||
interface QueueUIInterface {
|
||||
|
||||
/**
|
||||
* Starting working with a Queue class.
|
||||
*/
|
||||
public function __construct();
|
||||
|
||||
/**
|
||||
* Inspect the queue items in a specified queue.
|
||||
*
|
||||
* @param string $queue_name
|
||||
* The name of the queue being inspected.
|
||||
*
|
||||
* @return
|
||||
* FALSE if inspection is not implemented for this queue class. Otherwise returns the
|
||||
* content to be rendered on the Queue inspection screen.
|
||||
*/
|
||||
public function inspect($queue_name);
|
||||
|
||||
/**
|
||||
* View item data for a specified queue item.
|
||||
*
|
||||
* @param integer $item_id
|
||||
* The item id to be viewed.
|
||||
*
|
||||
* @return
|
||||
* FALSE if viewing queue items is not implemented for this queue class. Otherwise returns
|
||||
* the content to be renders on the Queue item details screen.
|
||||
*/
|
||||
public function view($item_id);
|
||||
|
||||
/**
|
||||
* Force the deletion of a specified queue item.
|
||||
*
|
||||
* @param integer $item_id
|
||||
* The item id to be deleted.
|
||||
*
|
||||
* @return
|
||||
* TRUE if deletion succeeds, FALSE if deletion fails.
|
||||
*/
|
||||
public function delete($item_id);
|
||||
|
||||
/**
|
||||
* Force the releasing of a specified queue item.
|
||||
*
|
||||
* @param integer $item_id
|
||||
* The item id to be released.
|
||||
*
|
||||
* @return
|
||||
* TRUE if releasing succeeds, FALSE if releasing fails.
|
||||
*/
|
||||
public function release($item_id);
|
||||
|
||||
/**
|
||||
* Retrieve the available operations for the implementing queue class.
|
||||
*
|
||||
* @return
|
||||
* An array of the available operations for the implementing queue class.
|
||||
*/
|
||||
public function getOperations();
|
||||
}
|
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
class QueueUISystemQueue implements QueueUIInterface {
|
||||
|
||||
public $inspect;
|
||||
|
||||
public function __construct() {
|
||||
$this->inspect = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* SystemQueue implements all default QueueUI methods.
|
||||
*
|
||||
* @return array
|
||||
* An array of available QueueUI methods. Array key is system name of the
|
||||
* operation, array key value is the display name.
|
||||
*/
|
||||
public function getOperations() {
|
||||
return array(
|
||||
'view' => t('View'),
|
||||
'release' => t('Release'),
|
||||
'delete' => t('Delete'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* View the queue items in a queue and expose additional methods for inspection.
|
||||
*
|
||||
* @param string $queue_name
|
||||
* @return string
|
||||
*/
|
||||
public function inspect($queue_name) {
|
||||
$query = db_select('queue', 'q')
|
||||
->fields('q', array('item_id', 'expire', 'created'))
|
||||
->condition('q.name', $queue_name)
|
||||
->extend('PagerDefault')
|
||||
->limit(25)
|
||||
->execute();
|
||||
|
||||
foreach ($query as $record) {
|
||||
$result[] = $record;
|
||||
}
|
||||
|
||||
$header = array(
|
||||
t('Item ID'),
|
||||
t('Expires'),
|
||||
t('Created'),
|
||||
array('data' => t('Operations'), 'colspan' => '3'),
|
||||
);
|
||||
|
||||
$rows = array();
|
||||
foreach ($result as $item) {
|
||||
$row = array();
|
||||
$row[] = $item->item_id;
|
||||
$row[] = ($item->expire ? date(DATE_RSS, $item->expire) : $item->expire);
|
||||
$row[] = date(DATE_RSS, $item->created);
|
||||
|
||||
foreach ($this->getOperations() as $op => $title) {
|
||||
$row[] = l($title, QUEUE_UI_BASE . "/$queue_name/$op/$item->item_id");
|
||||
}
|
||||
|
||||
$rows[] = array('data' => $row);
|
||||
}
|
||||
|
||||
$content = theme('table', array('header' => $header, 'rows' => $rows));
|
||||
$content .= theme('pager');
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* View the item data for a specified queue item.
|
||||
*
|
||||
* @param int $item_id
|
||||
* @return string
|
||||
*/
|
||||
public function view($item_id) {
|
||||
$queue_item = $this->loadItem($item_id);
|
||||
|
||||
$rows[] = array(
|
||||
'data' => array(
|
||||
'header' => t('Item ID'),
|
||||
'data' => $queue_item->item_id,
|
||||
),
|
||||
);
|
||||
$rows[] = array(
|
||||
'data' => array(
|
||||
'header' => t('Queue name'),
|
||||
'data' => $queue_item->name,
|
||||
),
|
||||
);
|
||||
$rows[] = array(
|
||||
'data' => array(
|
||||
'header' => t('Expire'),
|
||||
'data' => ($queue_item->expire ? date(DATE_RSS, $queue_item->expire) : $queue_item->expire),
|
||||
),
|
||||
);
|
||||
$rows[] = array(
|
||||
'data' => array(
|
||||
'header' => t('Created'),
|
||||
'data' => date(DATE_RSS, $queue_item->created),
|
||||
),
|
||||
);
|
||||
$rows[] = array(
|
||||
'data' => array(
|
||||
'header' => array('data' => t('Data'), 'style' => 'vertical-align:top'),
|
||||
'data' => '<pre>' . print_r(unserialize($queue_item->data), TRUE) . '</pre>',
|
||||
// @TODO - should probably do something nicer than print_r here...
|
||||
),
|
||||
);
|
||||
|
||||
return theme('table', array('rows' => $rows));
|
||||
}
|
||||
|
||||
public function delete($item_id) {
|
||||
// @TODO - try... catch...
|
||||
drupal_set_message("Deleted queue item " . $item_id);
|
||||
|
||||
db_delete('queue')
|
||||
->condition('item_id', $item_id)
|
||||
->execute();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public function release($item_id) {
|
||||
// @TODO - try... catch...
|
||||
drupal_set_message("Released queue item " . $item_id);
|
||||
|
||||
db_update('queue')
|
||||
->condition('item_id', $item_id)
|
||||
->fields(array('expire' => 0))
|
||||
->execute();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a specified SystemQueue queue item from the database.
|
||||
*
|
||||
* @param $item_id
|
||||
* The item id to load
|
||||
* @return
|
||||
* Result of the database query loading the queue item.
|
||||
*/
|
||||
private function loadItem($item_id) {
|
||||
// Load the specified queue item from the queue table.
|
||||
$query = db_select('queue', 'q')
|
||||
->fields('q', array('item_id', 'name', 'data', 'expire', 'created'))
|
||||
->condition('q.item_id', $item_id)
|
||||
->range(0, 1) // item id should be unique
|
||||
->execute();
|
||||
|
||||
foreach ($query as $record) {
|
||||
$result[] = $record;
|
||||
}
|
||||
|
||||
return $result[0];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user