<?php
function update_test_system_theme_info() {
$themes['update_test_basetheme'] = drupal_get_path('module', 'update_test') . '/themes/update_test_basetheme/update_test_basetheme.info';
$themes['update_test_subtheme'] = drupal_get_path('module', 'update_test') . '/themes/update_test_subtheme/update_test_subtheme.info';
$themes['update_test_admintheme'] = drupal_get_path('module', 'update_test') . '/themes/update_test_admintheme/update_test_admintheme.info';
return $themes;
}
function update_test_menu() {
$items = array();
$items['update-test'] = array(
'title' => t('Update test'),
'page callback' => 'update_test_mock_page',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
$items['503-error'] = array(
'title' => t('503 Service unavailable'),
'page callback' => 'update_callback_service_unavailable',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
return $items;
}
function update_test_system_info_alter(&$info, $file) {
$setting = variable_get('update_test_system_info', array());
foreach (array(
'#all',
$file->name,
) as $id) {
if (!empty($setting[$id])) {
foreach ($setting[$id] as $key => $value) {
$info[$key] = $value;
}
}
}
}
function update_test_update_status_alter(&$projects) {
$setting = variable_get('update_test_update_status', array());
if (!empty($setting)) {
foreach ($projects as $project_name => &$project) {
foreach (array(
'#all',
$project_name,
) as $id) {
if (!empty($setting[$id])) {
foreach ($setting[$id] as $key => $value) {
$project[$key] = $value;
}
}
}
}
}
}
function update_test_mock_page($project_name) {
$xml_map = variable_get('update_test_xml_map', FALSE);
if (isset($xml_map[$project_name])) {
$availability_scenario = $xml_map[$project_name];
}
elseif (isset($xml_map['#all'])) {
$availability_scenario = $xml_map['#all'];
}
else {
$availability_scenario = '#broken#';
}
$path = drupal_get_path('module', 'update_test');
readfile("{$path}/{$project_name}.{$availability_scenario}.xml");
}
function update_test_archiver_info() {
return array(
'update_test_archiver' => array(
'class' => 'ArchiverUpdateTest',
'extensions' => array(
'update-test-extension',
),
),
);
}
function update_test_filetransfer_info() {
return array(
'system_test' => array(
'title' => t('Update Test FileTransfer'),
'file' => 'update_test.module',
'class' => 'UpdateTestFileTransfer',
'weight' => -20,
),
);
}
class UpdateTestFileTransfer {
public static function factory() {
return new UpdateTestFileTransfer();
}
public function getSettingsForm() {
$form = array();
$form['udpate_test_username'] = array(
'#type' => 'textfield',
'#title' => t('Update Test Username'),
);
return $form;
}
}
function update_callback_service_unavailable() {
drupal_add_http_header('Status', '503 Service unavailable');
print "503 Service Temporarily Unavailable";
}