summaryrefslogtreecommitdiffstats
path: root/alpinelinux.module
diff options
context:
space:
mode:
Diffstat (limited to 'alpinelinux.module')
-rw-r--r--alpinelinux.module77
1 files changed, 77 insertions, 0 deletions
diff --git a/alpinelinux.module b/alpinelinux.module
new file mode 100644
index 0000000..1c12e24
--- /dev/null
+++ b/alpinelinux.module
@@ -0,0 +1,77 @@
+<?php
+
+function alpinelinux_menu() {
+ $items['admin/config/alpinelinux'] = array(
+ 'title' => 'Alpine Linux settings',
+ 'description' => 'Configure Alpine Linux settings',
+ 'page callback' => 'system_admin_menu_block_page',
+ 'access arguments' => array('admin alpinelinux'),
+ //system_admin_menu_block_page needs admin inc
+ 'file' => 'system.admin.inc',
+ 'file path' => drupal_get_path('module', 'system'),
+ );
+
+ $items['admin/config/alpinelinux/settings'] = array(
+ 'title' => 'Settings',
+ 'description' => 'Configure Alpine Linux settings',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('apk_browser_settings'),
+ 'access arguments' => array('admin alpinelinux'),
+ );
+ $items['wiki'] = array(
+ 'page callback' => 'alpinelinux_wiki_redirect',
+ 'access callback' => TRUE,
+ 'type' => MENU_LOCAL_TASK
+ );
+ return $items;
+}
+
+function alpinelinux_permission() {
+ return array(
+ 'admin alpinelinux' => array(
+ 'title' => t('Administer Alpine Linux settings'),
+ 'description' => t('Access permissions for Alpine Linux settings'),
+ ),
+ );
+}
+
+function alpinelinux_cron() {
+ alpinelinux_latest_releases();
+}
+
+function apk_browser_settings($form) {
+ $form['settings'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Alpine Linux settings'),
+ );
+ $form['settings']['alpinelinux_latest_link'] = array(
+ '#type' => 'textfield',
+ '#title' => t('URL to latest releases file'),
+ '#description' => t('A test file which holds information about Alpine Linux latests ISO\'s'),
+ '#default_value' => variable_get('alpinelinux_latest_link', '')
+ );
+ return system_settings_form($form);
+}
+
+function alpinelinux_latest_releases() {
+ $latest = variable_get('alpinelinux_latest_link', '');
+ $latest = file($latest);
+ if ($latest) {
+ foreach ($latest as $key => $line) {
+ $result[$key] = explode(" ", $line);
+ }
+ variable_set('alpinelinux_releases', $result);
+ $releases = variable_get('alpinelinux_releases', array());
+ print_r($releases);
+ } else {
+ watchdog('alpine', 'Failed to get latest alpine release information', array(), WATCHDOG_WARNING, NULL);
+ }
+}
+
+function alpinelinux_wiki_redirect() {
+ $wiki_url = 'http://wiki.alpinelinux.org/wiki/';
+ if (arg(0) == 'wiki') {
+ $url = (arg(1)) ? $wiki_url . arg(1) : $wiki_url;
+ drupal_goto($url);
+ }
+}