| 1 |
<?php
|
| 2 |
|
| 3 |
// $Id: colophon.module,v 1.2 2008/08/18 14:53:25 maxheadroom Exp $
|
| 4 |
|
| 5 |
/**
|
| 6 |
* @file
|
| 7 |
* List all enabled modules and themes in a 'colophon' or 'about' page
|
| 8 |
*
|
| 9 |
* Based on code provided by somebody at: http://drupal.org/node/199755
|
| 10 |
* Development sponsored by www.webnthings.co.za.
|
| 11 |
* This module is for Drupal 5.x
|
| 12 |
*/
|
| 13 |
|
| 14 |
/*******************************************************************************
|
| 15 |
* Hook Functions (Drupal)
|
| 16 |
******************************************************************************/
|
| 17 |
|
| 18 |
/**
|
| 19 |
* Implementation of hook_help().
|
| 20 |
*/
|
| 21 |
function colophon_help($section) {
|
| 22 |
switch ($section) {
|
| 23 |
case 'admin/settings/colophon':
|
| 24 |
return '<a href="http://en.wikipedia.org/wiki/Colophon_%28publishing%29">WIKI</a><br /><p>'. t(' The colophon module will show you a list of all the enabled modules as well as themes in this installation. <br> You can add your own intro message and also notes for the modules and themes section each. <br> You are able to select if you you want to view themes or modules only. <br /> When you\'ve enabled the module, the colophon can be directly linked as "mysite.com/colophon". <br> You can put a link anywhere on your page by using the colophon block. A selection of Drupal icons and banners are available which you can use as a link inside the block. You can also use your own text instead. <br> The text or icons can be positioned inside the block left, right or center.');
|
| 25 |
}
|
| 26 |
}
|
| 27 |
|
| 28 |
/**
|
| 29 |
* Implementation of hook_menu().
|
| 30 |
*/
|
| 31 |
function colophon_menu($may_cache) {
|
| 32 |
drupal_add_css(drupal_get_path('module', 'colophon') . '/colophon.css');
|
| 33 |
if ($may_cache) {
|
| 34 |
$items[] = array(
|
| 35 |
'path' => 'admin/settings/colophon',
|
| 36 |
'title' => t('Colophon settings'),
|
| 37 |
'description' => t('Settings for the colophon or about page that shows enabled modules and themes'),
|
| 38 |
'callback' => 'drupal_get_form',
|
| 39 |
'callback arguments' => array('colophon_admin_settings'),
|
| 40 |
'access' => user_access('administer site configuration'),
|
| 41 |
);
|
| 42 |
|
| 43 |
$items[] = array(
|
| 44 |
'path' => 'colophon',
|
| 45 |
'title' => t('Colophon'),
|
| 46 |
'callback' => 'colophon_display',
|
| 47 |
'type' => MENU_CALLBACK,
|
| 48 |
'access' => TRUE,
|
| 49 |
);
|
| 50 |
}
|
| 51 |
|
| 52 |
return $items;
|
| 53 |
}
|
| 54 |
|
| 55 |
/**
|
| 56 |
* Implementation of hook_block().
|
| 57 |
*/
|
| 58 |
function colophon_block($op='list', $delta=0) {
|
| 59 |
if ($op == "list") {
|
| 60 |
$block[0]["info"] = t('Colophon');
|
| 61 |
return $block;
|
| 62 |
}
|
| 63 |
elseif ($op == "view") {
|
| 64 |
if (variable_get('colophon_link', 0) == 0) {
|
| 65 |
$modpath = base_path() . drupal_get_path('module', 'colophon');
|
| 66 |
$colophon_icons = array(
|
| 67 |
$modpath.'/images/druplicon_small.jpg',
|
| 68 |
$modpath.'/images/druplicon_eyes_small.jpg',
|
| 69 |
$modpath.'/images/powered-blue-80x15.png',
|
| 70 |
$modpath.'/images/powered-gray-80x15.png',
|
| 71 |
$modpath.'/images/powered-black-80x15.png',
|
| 72 |
$modpath.'/images/powered-blue-88x31.png',
|
| 73 |
$modpath.'/images/powered-gray-88x31.png',
|
| 74 |
$modpath.'/images/powered-black-88x31.png',
|
| 75 |
$modpath.'/images/powered-blue-135x42.png',
|
| 76 |
$modpath.'/images/powered-gray-135x42.png',
|
| 77 |
$modpath.'/images/powered-black-135x42.png',
|
| 78 |
$modpath.'/images/drupal.powered.stealthese.1.png',
|
| 79 |
$modpath.'/images/drupal.powered.stealthese.2.png',
|
| 80 |
$modpath.'/images/drupal.powered.3d.png',
|
| 81 |
'Text only',
|
| 82 |
);
|
| 83 |
|
| 84 |
|
| 85 |
switch (variable_get('colophon_position', 1)) {
|
| 86 |
case 0:
|
| 87 |
if ($colophon_icons[variable_get('colophon_icon', 0)] == 'Text only') {
|
| 88 |
$block_content .= '<div class="left_image"><a href="' . $base_url . '/colophon" title="Colophon">'. variable_get('colophon_text', 'Powered by Drupal') . '</div></a>';
|
| 89 |
}
|
| 90 |
else{
|
| 91 |
$block_content .= '<a href="' . $base_url . '/colophon" title="Colophon"><img src="'. $colophon_icons[variable_get('colophon_icon', 0)] . '" class="left_image" alt="Powered by Drupal"></a>';
|
| 92 |
}
|
| 93 |
break;
|
| 94 |
|
| 95 |
case 1:
|
| 96 |
if ($colophon_icons[variable_get('colophon_icon', 0)] == 'Text only') {
|
| 97 |
$block_content .= '<div class="center_image"><a href="' . $base_url . '/colophon" title="Colophon">'. variable_get('colophon_text', 'Powered by Drupal') . '</div></a>';
|
| 98 |
}
|
| 99 |
else{
|
| 100 |
$block_content .= '<a href="' . $base_url . '/colophon" title="Colophon"><img src="'. $colophon_icons[variable_get('colophon_icon', 0)] . '" class="center_image" alt="Powered by Drupal"></a>';
|
| 101 |
}
|
| 102 |
break;
|
| 103 |
|
| 104 |
case 2:
|
| 105 |
if ($colophon_icons == 'Text only') {
|
| 106 |
$block_content .= '<div class="right_image"><a href="' . $base_url . '/colophon" title="Colophon">'. variable_get('colophon_text', 'Powered by Drupal') . '</div></a>';
|
| 107 |
}
|
| 108 |
else{
|
| 109 |
$block_content .= '<a href="' . $base_url . '/colophon" title="Colophon"><img src="'. $colophon_icons[variable_get('colophon_icon', 0)] . '" class="right_image" alt="Powered by Drupal"></a>';
|
| 110 |
}
|
| 111 |
}
|
| 112 |
}
|
| 113 |
$block['subject'] = '';
|
| 114 |
$block['content'] = $block_content;
|
| 115 |
return $block;
|
| 116 |
}
|
| 117 |
}
|
| 118 |
|
| 119 |
|
| 120 |
/*******************************************************************************
|
| 121 |
* Callback Functions, Forms, and Tables
|
| 122 |
******************************************************************************/
|
| 123 |
function colophon_admin_settings() {
|
| 124 |
$pathmod = base_path() . drupal_get_path('module', 'colophon');
|
| 125 |
$form['content'] = array(
|
| 126 |
'#type' => 'fieldset',
|
| 127 |
'#title' => t('Content.'),
|
| 128 |
);
|
| 129 |
|
| 130 |
$form['content']['colophon_option'] = array(
|
| 131 |
'#type' => 'checkboxes',
|
| 132 |
'#title' => t('View modules and themes'),
|
| 133 |
'#description' => t('Select whether to show modules or themes or both.'),
|
| 134 |
'#default_value' => variable_get('colophon_option', array('modules', 'themes')),
|
| 135 |
'#options' => array(
|
| 136 |
'modules' => t('modules'),
|
| 137 |
'themes' => t('themes'),
|
| 138 |
),
|
| 139 |
);
|
| 140 |
|
| 141 |
$form['content']['colophon_intro'] = array(
|
| 142 |
'#type' => 'textarea',
|
| 143 |
'#title' => t('Comment'),
|
| 144 |
'#description' => t('General comments or notes regarding this Drupal installation.'),
|
| 145 |
'#default_value' => variable_get('colophon_intro', ''),
|
| 146 |
'#rows' => 3,
|
| 147 |
);
|
| 148 |
|
| 149 |
$form['content']['colophon_module_intro'] = array(
|
| 150 |
'#type' => 'textarea',
|
| 151 |
'#title' => t('Comment for modules'),
|
| 152 |
'#description' => t('Comments or notes regarding the modules in this Drupal installation.'),
|
| 153 |
'#default_value' => variable_get('colophon_module_intro', ''),
|
| 154 |
'#rows' => 3,
|
| 155 |
);
|
| 156 |
|
| 157 |
$form['content']['colophon_theme_intro'] = array(
|
| 158 |
'#type' => 'textarea',
|
| 159 |
'#title' => t('Comment for themes'),
|
| 160 |
'#description' => t('Comments or notes regarding the themes in this Drupal installation.'),
|
| 161 |
'#default_value' => variable_get('colophon_theme_intro', ''),
|
| 162 |
'#rows' => 3,
|
| 163 |
);
|
| 164 |
|
| 165 |
$form['display'] = array(
|
| 166 |
'#type' => 'fieldset',
|
| 167 |
'#title' => t('Icons and position.'),
|
| 168 |
);
|
| 169 |
$form['display']['colophon_icon'] = array(
|
| 170 |
'#type' => 'radios',
|
| 171 |
'#title' => t('Select icon'),
|
| 172 |
'#description' => t('Select icon or text to be displayed in footer'),
|
| 173 |
'#default_value' => variable_get('colophon_icon', 0),
|
| 174 |
'#options' => array(
|
| 175 |
'<img src="'. $pathmod .'/images/druplicon_small.jpg" style="position: relative; left: 2.5em;">',
|
| 176 |
'<img src="'. $pathmod .'/images/druplicon_eyes_small.jpg" style="position: relative; left: 2.5em;">',
|
| 177 |
'<img src="'. $pathmod .'/images/powered-blue-80x15.png" style="position: relative; left: 2.5em;">',
|
| 178 |
'<img src="'. $pathmod .'/images/powered-gray-80x15.png" style="position: relative; left: 2.5em;">',
|
| 179 |
'<img src="'. $pathmod .'/images/powered-black-80x15.png" style="position: relative; left: 2.5em;">',
|
| 180 |
'<img src="'. $pathmod .'/images/powered-blue-88x31.png" style="position: relative; left: 2.5em;">',
|
| 181 |
'<img src="'. $pathmod .'/images/powered-gray-88x31.png" style="position: relative; left: 2.5em;">',
|
| 182 |
'<img src="'. $pathmod .'/images/powered-black-88x31.png" style="position: relative; left: 2.5em;">',
|
| 183 |
'<img src="'. $pathmod .'/images/powered-blue-135x42.png" style="position: relative; left: 2.5em;">',
|
| 184 |
'<img src="'. $pathmod .'/images/powered-gray-135x42.png" style="position: relative; left: 2.5em;">',
|
| 185 |
'<img src="'. $pathmod .'/images/powered-black-135x42.png" style="position: relative; left: 2.5em;">',
|
| 186 |
'<img src="'. $pathmod .'/images/drupal.powered.stealthese.1.png" style="position: relative; left: 2.5em;">',
|
| 187 |
'<img src="'. $pathmod .'/images/drupal.powered.stealthese.2.png" style="position: relative; left: 2.5em;">',
|
| 188 |
'<img src="'. $pathmod .'/images/drupal.powered.3d.png" style="position: relative; left: 2.5em;">',
|
| 189 |
t('Text only') ,
|
| 190 |
)
|
| 191 |
);
|
| 192 |
|
| 193 |
$form['display']['colophon_text'] = array(
|
| 194 |
'#type' => 'textarea',
|
| 195 |
'#title' => t('Text in footer'),
|
| 196 |
'#description' => t('If you selected Text only to be displayed in footer, enter it here.'),
|
| 197 |
'#default_value' => variable_get('colophon_text', 'Powered by Drupal'),
|
| 198 |
);
|
| 199 |
|
| 200 |
$form['display']['colophon_position'] = array(
|
| 201 |
'#type' => 'radios',
|
| 202 |
'#title' => t('Alignment'),
|
| 203 |
'#description' => t('Position where icon or text to be displayed in footer'),
|
| 204 |
'#default_value' => variable_get('colophon_position', 1),
|
| 205 |
'#options' => array(
|
| 206 |
t('Left'),
|
| 207 |
t('Center'),
|
| 208 |
t('Right'),
|
| 209 |
)
|
| 210 |
);
|
| 211 |
|
| 212 |
return system_settings_form($form);
|
| 213 |
}
|
| 214 |
|
| 215 |
function colophon_display() {
|
| 216 |
$options = variable_get('colophon_option', array('modules', 'themes'));
|
| 217 |
$content = '<div id="colophon">';
|
| 218 |
$content .= '<h2 class="title">Drupal modules and themes used in ' . variable_get('site_name', '') . '</h2><br>';
|
| 219 |
$content .='<table><tr><td><a href="http://www.drupal.org" title="Drupal Home"><img src="'. $base_url . '/misc/druplicon.png" class="left_image" alt="Drupal home"><a></td><td>';
|
| 220 |
$content .= '<a href="http://www.drupal.org" title="Drupal Home"><h3 class ="version">Drupal version: '. VERSION . '</h3><a><br></td></tr</table>';
|
| 221 |
$content .= '<div class="intro">' . variable_get('colophon_intro', '') . '</div><br>';
|
| 222 |
// Modules
|
| 223 |
if ($options['modules']) {
|
| 224 |
$modules = module_list(FALSE, FALSE, TRUE);
|
| 225 |
$content .= '<h4>Modules:</h4><br />';
|
| 226 |
$content .= '<div class="module_intro">' . variable_get('colophon_module_intro', '') . '</div>';
|
| 227 |
$content .= '<table><thead><th>Name</th><th>Version</th><th>Description</th><th>URL</th></thead><tbody>';
|
| 228 |
$row = 0;
|
| 229 |
foreach ($modules as $item) {
|
| 230 |
if (module_exists($item)) { // Only list the module if it's enabled
|
| 231 |
$module_loc = drupal_get_filename('module', $item); // The location of the Module
|
| 232 |
$info = parse_ini_file(dirname($module_loc) . '/' . $item . '.info'); // Location of the info file
|
| 233 |
$name = $info['name'];
|
| 234 |
$description = $info['description'];
|
| 235 |
$version = $info['version'];
|
| 236 |
$project = $info['project'];
|
| 237 |
$package = $info['package'];
|
| 238 |
$togs =($row % 2 == 0 ? 'odd' : 'even');
|
| 239 |
$content .= '<tr class = ' . $togs . '><td>' . $name;
|
| 240 |
if ($package) {
|
| 241 |
$content .= '<br /><small>(Part of ' . $package . ')';
|
| 242 |
}
|
| 243 |
$content .= '</td><td>' . $version . '</td><td>' . $description . '</td><td><a href="http://drupal.org/project/' . $project . '">http://drupal.org/project/' . $project . '</a></td></tr>';
|
| 244 |
$row++;
|
| 245 |
}
|
| 246 |
}
|
| 247 |
$content .= '</table>';
|
| 248 |
}
|
| 249 |
|
| 250 |
// Themes
|
| 251 |
if ($options['themes']) {
|
| 252 |
$themes = list_themes();
|
| 253 |
$content .= '<h4>Themes:</h4><br />';
|
| 254 |
$content .= '<div class="theme_intro">' . variable_get('colophon_theme_intro', '') . '</div>';
|
| 255 |
$content .= '<table ><thead><th style: width="60%">Screenshot</th><th style: width="40%">Name</th></thead>';
|
| 256 |
$row = 0;
|
| 257 |
foreach ($themes as $item) {
|
| 258 |
// Only lists the theme if the theme is enabled
|
| 259 |
$list = get_object_vars($item); // Drupal's list_themes() function returns an array of objects, so we extract an array from each of the objects
|
| 260 |
if ($list['status']) { // Only list the theme if it is enabled
|
| 261 |
$name = $list['name'];
|
| 262 |
if (file_exists(dirname($list['filename']) . '/screenshot-drupal.org.png')) { // List the screenshot intended for drupal.or, if available
|
| 263 |
$screenshot = dirname($list['filename']) . '/screenshot-drupal.org.png';
|
| 264 |
}
|
| 265 |
else {
|
| 266 |
$screenshot = dirname($list['filename']) . '/screenshot.png';
|
| 267 |
}
|
| 268 |
$togs =($row % 2 == 0 ? 'odd' : 'even');
|
| 269 |
$content .= '<tr class = ' . $togs . '><td><img src="' . $screenshot . '" alt="' . $name . ' screenshot" /></td><td> ' . $name . '</td></tr>';
|
| 270 |
$row++;
|
| 271 |
}
|
| 272 |
}
|
| 273 |
$content .= '</table>';
|
| 274 |
$content .= '</div>';
|
| 275 |
}
|
| 276 |
return $content;
|
| 277 |
}
|
| 278 |
|
| 279 |
function theme_colphon_footer($message) {
|
| 280 |
return '<div id="footer">'. $message .'</div>';
|
| 281 |
}
|
| 282 |
|
| 283 |
/*******************************************************************************
|
| 284 |
* Module and Helper Functions
|
| 285 |
******************************************************************************/
|
| 286 |
|