From 9bc94530822d43f6367671f1e883d74015488ee3 Mon Sep 17 00:00:00 2001 From: Carlo Landmeter Date: Fri, 8 Apr 2011 21:10:11 +0000 Subject: added new apk fields and generate path based on terms --- apk_browser.info | 5 +++-- apk_browser.install | 25 +++++++++++++++---------- apk_browser.module | 33 +++++++++++++++++++++++++-------- 3 files changed, 43 insertions(+), 20 deletions(-) diff --git a/apk_browser.info b/apk_browser.info index 1429aaf..9ee70c3 100644 --- a/apk_browser.info +++ b/apk_browser.info @@ -1,9 +1,10 @@ name = "APK browser" description = "Package browser for Alpine Linux" -version = "7.x-1.x-dev" +version = "7.x-1.0" core = "7.x" dependencies[] = taxonomy dependencies[] = field_ui dependencies[] = user_reference +dependencies[] = path files[] = apk_browser.views_default.inc -configure = "admin/config/apk_browser/settings" \ No newline at end of file +configure = "admin/config/apk_browser/settings" diff --git a/apk_browser.install b/apk_browser.install index a5cd42e..ab74d38 100644 --- a/apk_browser.install +++ b/apk_browser.install @@ -170,20 +170,25 @@ function _apk_browser_field_vars() { 'apk_license' => array( 'label' => $t('License') ), - 'apk_depends' => array( - 'label' => $t('Dependencies'), - 'cdl' => '-1' + 'apk_origin' => array( + 'label' => $t('Origin') + ), + 'builddate' => array( + 'label' => $t('Build date') + ), + 'commit' => array( + 'label' => $t('Commit') ), 'apk_maintainer' => array( 'label' => $t('Maintainer'), - 'type' => 'user_reference', - 'widget' => 'options_select' ), - 'apk_contributor' => array( - 'label' => $t('Contributor'), - 'type' => 'user_reference', - 'widget' => 'user_reference_autocomplete', + 'apk_depends' => array( + 'label' => $t('Dependencies'), + 'cdl' => '-1' + ), + 'install_if' => array( + 'label' => $t('Install if'), 'cdl' => '-1' - ) + ) ); } diff --git a/apk_browser.module b/apk_browser.module index 0ff9b74..31c9f90 100644 --- a/apk_browser.module +++ b/apk_browser.module @@ -79,7 +79,7 @@ function apk_browser_settings($form) { } function apk_browser_cron() { - apk_browser_import_apk(); + //apk_browser_import_apk(); } function apk_browser_repository_delete_form($form, &$form_state, $rid) { @@ -269,12 +269,14 @@ function apk_browser_import_apk() { } } -function apk_browser_add_apk($package, $arch, $repo) { +function apk_browser_add_apk($package, $arch_tid, $repo_tid) { /* * 1st array key is language, currently set to und * second key is for multi value fields like depend * php timeout set to 10min for initial repo import */ + $repo = taxonomy_term_load($repo_tid); + $arch = taxonomy_term_load($arch_tid); ini_set('max_execution_time', 600); $node = (isset($package['update'])) ? node_load($package['update']) : new stdClass(); $node->type = 'apk'; @@ -318,10 +320,16 @@ function apk_browser_add_apk($package, $arch, $repo) { break; } } - $node->taxonomy_apk_repo['und'][0]['tid'] = $repo; - $node->taxonomy_apk_arch['und'][0]['tid'] = $arch; + $node->taxonomy_apk_repo['und'][0]['tid'] = $repo->tid; + $node->taxonomy_apk_arch['und'][0]['tid'] = $arch->tid; $node = node_submit($node); node_save($node); + //create a human path based on repo and arch + $alias = array( + 'source' => 'node'.$node->nid, + 'alias' => 'apk/'.$repo->name.'/'.$arch->name.'/'.$node->title + ); + path_save($alias); return $node->nid; } @@ -341,9 +349,16 @@ function apk_browser_apkindex_reader($apk_string) { //convert packages lines into array $apackage = preg_split("`\n`", $package); foreach ($apackage as $apk_line) { - //create apk variables and arrayify if its depend line - $value = substr($apk_line, 2); - $apackages[$key][$apk_line[0]] = ($apk_line[0] == 'D') ? explode(" ", $value) : $value; + switch ($apk_line[0]) { + //depend and install_if lines + case "D": + case "i": + $apackages[$key][$apk_line[0]] = explode(" ", substr($apk_line, 2)); + break; + //other apk variables + default: + $apackages[$key][$apk_line[0]] = substr($apk_line, 2); + } } } unlink($temp); @@ -356,7 +371,7 @@ function apk_browser_apk_check($title, $arch, $repo) { * to check if its updated */ return db_query(" - SELECT node.nid, + SELECT node.nid, csum.apk_checksum_value as csum FROM {node}, {field_data_taxonomy_apk_arch} AS arch, @@ -375,6 +390,8 @@ function apk_browser_apk_check($title, $arch, $repo) { )->fetchAssoc(); } + +//this is needed for auto views integration function apk_browser_views_api() { return array('api' => 3.0); } -- cgit v1.2.3