summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlo Landmeter <clandmeter@gmail.com>2011-05-06 21:11:03 +0200
committerCarlo Landmeter <clandmeter@gmail.com>2011-05-06 21:11:03 +0200
commitccbcffa58133dec1fbab4388be8a561f3f9ecf1a (patch)
tree7c64aaa62f185ecc444f779d418dcb9a4fa286b3
parentac5b5954e722a011ee21e1e068fbd229c81e5c8e (diff)
downloadapk_browser-ccbcffa58133dec1fbab4388be8a561f3f9ecf1a.tar.bz2
apk_browser-ccbcffa58133dec1fbab4388be8a561f3f9ecf1a.tar.xz
add origin table to apk template
-rw-r--r--apk_browser.module57
1 files changed, 48 insertions, 9 deletions
diff --git a/apk_browser.module b/apk_browser.module
index a28320e..f30e451 100644
--- a/apk_browser.module
+++ b/apk_browser.module
@@ -99,7 +99,7 @@ function apk_browser_settings($form) {
if (module_exists('aggregator')) {
$feeds += db_query("SELECT fid,title FROM {aggregator_feed}")->fetchAllKeyed();
$disabled = FALSE;
- $description = t('When enabled, commit title will be searched in this aggregator feed.');
+ $description = t('When enabled, commit title will be searched in this aggregator feed.');
} else {
$disabled = TRUE;
$description = t('You need to have aggregator enabled and configured to enable this.');
@@ -108,7 +108,7 @@ function apk_browser_settings($form) {
'#type' => 'select',
'#title' => t('RSS commit lookup'),
'#description' => $description,
- '#default_value' => variable_get('apk_import_aggregator','0'),
+ '#default_value' => variable_get('apk_import_aggregator', '0'),
'#options' => $feeds,
'#disabled' => $disabled,
);
@@ -493,19 +493,19 @@ function apk_browser_cleanup() {
//create an url from the commit, and if we find it in aggregator we add a title
function apk_browser_commit_url($commit) {
- $fid = variable_get('apk_import_aggregator','0');
+ $fid = variable_get('apk_import_aggregator', '0');
$attributes = array();
$href = str_replace('%commit%', $commit, variable_get('apk_import_commit_url', ''));
if (module_exists('aggregator') && $fid) {
- if (!empty($commit)) {
+ if (!empty($commit)) {
$search = '%' . $commit . '%';
}
$title = db_query("SELECT title FROM {aggregator_item} WHERE link LIKE :commit AND fid = :fid", array(':commit' => $search, ':fid' => $fid))->fetchField();
- if ($title) {
- $attributes = array('title' => check_plain($title), 'class' => 'with-tooltip');
- $path = drupal_get_path('module', 'apk_browser');
- drupal_add_js($path . '/tooltip/tooltip.js');
- drupal_add_js('jQuery().ready(function(){jQuery(".with-tooltip").simpletooltip();});', 'inline');
+ if ($title) {
+ $attributes = array('title' => check_plain($title), 'class' => 'with-tooltip');
+ $path = drupal_get_path('module', 'apk_browser');
+ drupal_add_js($path . '/tooltip/tooltip.js');
+ drupal_add_js('jQuery().ready(function(){jQuery(".with-tooltip").simpletooltip();});', 'inline');
}
}
return l($commit, $href, array('attributes' => $attributes));
@@ -584,6 +584,7 @@ function apk_browser_package_table($vars) {
function apk_browser_preprocess_node(&$vars) {
if ($vars['node']->type == 'apk') {
$vars['apk_table'] = apk_browser_package_table($vars);
+ $vars['origin_table'] = apk_browser_origin_table($vars);
}
}
@@ -653,3 +654,41 @@ function apk_browser_batch_delete_all_apk_finished($success, $results, $operatio
}
drupal_set_message($message);
}
+
+function apk_browser_origin_table($vars) {
+ $rows = db_query("
+ SELECT node.title
+ FROM {node}
+ LEFT JOIN {field_data_apk_origin} as origin ON (node.nid = origin.entity_id)
+ LEFT JOIN {field_data_taxonomy_apk_arch} as arch ON (node.nid = arch.entity_id)
+ LEFT JOIN {field_data_taxonomy_apk_repo} as repo ON (node.nid = repo.entity_id)
+ WHERE origin.apk_origin_value = :origin
+ AND arch.taxonomy_apk_arch_tid = :arch
+ AND repo.taxonomy_apk_repo_tid = :repo
+ AND node.status = '1'
+ LIMIT 10", array(
+ ':origin' => $vars['apk_origin']['0']['value'],
+ ':arch' => $vars['taxonomy_apk_arch']['0']['tid'],
+ ':repo' => $vars['taxonomy_apk_repo']['0']['tid']
+ )
+ )->fetchCol();
+ if ($rows) {
+ $table['header'] = array(t('Same origin'));
+ foreach ($rows as $key => $row) {
+ $value = trim($row, '!');
+ $value = preg_split("/[<>=]/", $value);
+ $link = l($row, 'apk/' .
+ $vars['taxonomy_apk_repo']['0']['taxonomy_term']->name . '/' .
+ $vars['taxonomy_apk_arch']['0']['taxonomy_term']->name . '/' .
+ $value[0]
+ );
+ $table['rows'][$key]['data'] = array($link);
+ }
+ $table['attributes']['id'] = 'origin-table';
+ return theme('table', $table);
+ } else {
+ return FALSE;
+ }
+}
+
+?>