'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('alpinelinux_settings'), 'access arguments' => array('admin alpinelinux'), ); $items['wiki'] = array( 'page callback' => 'alpinelinux_wiki_redirect', 'access callback' => TRUE, 'type' => MENU_LOCAL_TASK ); $items['w'] = 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(); alpinelinux_mirrors(); } function alpinelinux_settings($form) { $form['settings'] = array( '#type' => 'fieldset', '#title' => t('Alpine Linux settings'), ); $form['settings']['alpinelinux_latest_link_x86'] = array( '#type' => 'textfield', '#title' => t('URL to latest x86 releases file'), '#description' => t('A text file which holds information about Alpine Linux latest releases'), '#default_value' => variable_get('alpinelinux_latest_link_x86', '') ); $form['settings']['alpinelinux_latest_link_x86_64'] = array( '#type' => 'textfield', '#title' => t('URL to latest x86_64 releases file'), '#description' => t('A text file which holds information about Alpine Linux latest releases'), '#default_value' => variable_get('alpinelinux_latest_link_x86_64', '') ); $form['settings']['alpinelinux_mirrors_link'] = array( '#type' => 'textfield', '#title' => t('URL to mirrors txt file'), '#description' => t('A text file which holds information about Alpine Linux mirrors'), '#default_value' => variable_get('alpinelinux_mirrors_link', '') ); return system_settings_form($form); } function alpinelinux_latest_releases() { $latest = variable_get('alpinelinux_latest_link_x86', ''); $latest = file($latest); $result = array(); if ($latest) { foreach ($latest as $key => $line) { $result[$key] = explode(" ", $line); } variable_set('alpinelinux_releases_x86', $result); } else { watchdog('alpine', 'Failed to get latest x86 alpine release information', array(), WATCHDOG_WARNING, NULL); } $latest = variable_get('alpinelinux_latest_link_x86_64', ''); $latest = file($latest); $result = array(); if ($latest) { foreach ($latest as $key => $line) { $result[$key] = explode(" ", $line); } variable_set('alpinelinux_releases_x86_64', $result); } else { watchdog('alpine', 'Failed to get latest x86_64 alpine release information', array(), WATCHDOG_WARNING, NULL); } } function alpinelinux_mirrors() { $mirrors = variable_get('alpinelinux_mirrors_link', ''); $mirrors = file($mirrors); if ($mirrors) { variable_set('alpinelinux_mirrors', $mirrors); } else { watchdog('alpine', 'Failed to get latest alpine mirror information', array(), WATCHDOG_WARNING, NULL); } } function alpinelinux_wiki_redirect() { $wiki_url = 'http://wiki.alpinelinux.org/wiki/'; if ((arg(0) == 'wiki') || (arg(0) == 'w')) { $url = (arg(1)) ? $wiki_url . arg(1) : $wiki_url; drupal_goto($url); } }