| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: image_gallery.module,v 1.46.2.1 2010/08/03 17:43:00 sun Exp $ 3 4 define('IMAGE_GALLERY_SORT_CREATE_DESC', 0); 5 define('IMAGE_GALLERY_SORT_CREATE_ASC', 1); 6 define('IMAGE_GALLERY_SORT_FILENAME', 2); 7 define('IMAGE_GALLERY_SORT_TITLE', 3); 8 9 /** 10 * Implementation of hook_help(). 11 */ 12 function image_gallery_help($path, $arg) { 13 switch ($path) { 14 case 'admin/help#image_gallery': 15 $output = '<p>' . t('The Image gallery module allows you to organize your image nodes into galleries. Images are placed into galleries in the same way as nodes are given taxonomy terms.') . '</p>'; 16 $output .= '<p>' . t('You can:') . '</p>'; 17 $output .= '<ul>'; 18 $output .= '<li>' . t('View your <a href="@image-gallery-url">galleries</a>.', array('@image-gallery-url' => url('image'))) . '</li>'; 19 $output .= '<li>' . t('Add or change galleries at <a href="@image-gallery-admin-url">Administer » Content » Image galleries</a>.', array('@image-gallery-admin-url' => url('admin/content/image'))) . '</li>'; 20 $output .= '<li>' . t('Configure gallery settings at <a href="@image-gallery-settings-url">Administer » Site configuration » Image » Image gallery</a>.', array('@image-gallery-settings-url' => url('admin/settings/image/image_gallery'))) . '</li>'; 21 $output .= '</ul>'; 22 $output .= '<p>' . t('For more information, see the online handbook entry for <a href="@image-url">Image module</a> and its related submodules.', array('@image-url' => 'http://drupal.org/handbook/modules/image')) . '</p>'; 23 return $output; 24 25 case 'admin/content/image': 26 $output = '<p>' . t('<a href="@image-gallery-url">Image galleries</a> can be used to organize and present groups of images. Galleries may be nested. To add a new gallery click the "add gallery" tab.', array('@image-gallery-url' => url('image'))) . '</p>'; 27 return $output; 28 } 29 } 30 31 /** 32 * Implementation of hook_perm(). 33 */ 34 function image_gallery_perm() { 35 return array('administer image galleries'); 36 } 37 38 /** 39 * Implementation of hook_menu(). 40 */ 41 function image_gallery_menu() { 42 $items = array(); 43 44 $items['image'] = array( 45 'title' => 'Image galleries', 46 'access arguments' => array('access content'), 47 'type' => MENU_SUGGESTED_ITEM, 48 'page callback' => 'image_gallery_page', 49 'file' => 'image_gallery.pages.inc', 50 ); 51 $items['admin/content/image'] = array( 52 'title' => 'Image galleries', 53 'access arguments' => array('administer image galleries'), 54 'page callback' => 'image_gallery_admin', 55 'file' => 'image_gallery.admin.inc', 56 'description' => 'Create and manage image galleries.', 57 ); 58 $items['admin/content/image/list'] = array( 59 'title' => 'List', 60 'access arguments' => array('administer image galleries'), 61 'type' => MENU_DEFAULT_LOCAL_TASK, 62 'weight' => -10, 63 ); 64 $items['admin/content/image/add'] = array( 65 'title' => 'Add gallery', 66 'access arguments' => array('administer image galleries'), 67 'page callback' => 'image_gallery_admin_edit', 68 'file' => 'image_gallery.admin.inc', 69 'type' => MENU_LOCAL_TASK, 70 ); 71 $items['admin/content/image/edit/%'] = array( 72 'title' => 'Edit image gallery', 73 'page callback' => 'image_gallery_admin_edit', 74 'page arguments' => array(4), 75 'file' => 'image_gallery.admin.inc', 76 'access arguments' => array('administer image galleries'), 77 'type' => MENU_CALLBACK, 78 ); 79 80 $items['admin/settings/image/image_gallery'] = array( 81 'title' => 'Image gallery', 82 'access arguments' => array('administer site configuration'), 83 'page callback' => 'drupal_get_form', 84 'page arguments' => array('image_gallery_admin_settings'), 85 'file' => 'image_gallery.admin.inc', 86 'description' => 'Configure appearance of image galleries.', 87 'type' => MENU_LOCAL_TASK, 88 ); 89 90 return $items; 91 } 92 93 /** 94 * Implementation of hook_taxonomy. If our vocabulary gets deleted, delete our 95 * variable pointing to it. 96 */ 97 function image_gallery_taxonomy($op, $type, $array) { 98 if ($op == 'delete' && $type == 'vocabulary') { 99 $vid = variable_get('image_gallery_nav_vocabulary', ''); 100 if ($vid == $array['vid']) { 101 variable_set('image_gallery_nav_vocabulary', ''); 102 } 103 } 104 } 105 106 /** 107 * Implementation of hook_term_path(). 108 */ 109 function image_gallery_term_path($term) { 110 return 'image/tid/' . $term->tid; 111 } 112 113 /** 114 * Implementation of hook_nodeapi(). 115 */ 116 function image_gallery_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { 117 switch ($op) { 118 case 'view': 119 if ($page && !$teaser && $node->type == 'image') { 120 $vid = _image_gallery_get_vid(); 121 $terms = taxonomy_node_get_terms_by_vocabulary($node, $vid); 122 $term = array_pop($terms); 123 if ($term) { 124 $vocabulary = taxonomy_vocabulary_load($vid); 125 // Breadcrumb navigation 126 $breadcrumb = array(); 127 $breadcrumb[] = l(t('Home'), NULL); 128 $breadcrumb[] = l($vocabulary->name, 'image'); 129 if ($parents = taxonomy_get_parents_all($term->tid)) { 130 $parents = array_reverse($parents); 131 foreach ($parents as $parent) { 132 $breadcrumb[] = l($parent->name, 'image/tid/' . $parent->tid); 133 } 134 } 135 drupal_set_breadcrumb($breadcrumb); 136 } 137 } 138 break; 139 } 140 } 141 142 /** 143 * Implementation of hook_theme() registry. 144 **/ 145 function image_gallery_theme() { 146 return array( 147 'image_gallery' => array( 148 'arguments' => array('galleries' => NULL, 'images' => NULL), 149 ), 150 'image_gallery_count' => array( 151 'arguments' => array('count' => 0), 152 ), 153 'image_gallery_updated' => array( 154 'arguments' => array('timestamp' => 0), 155 ), 156 'image_gallery_img' => array( 157 'arguments' => array('image' => NULL, 'size' => NULL), 158 ), 159 ); 160 } 161 162 /** 163 * Theme the count of gallery items on a gallery list. 164 */ 165 function theme_image_gallery_count($count) { 166 return format_plural( 167 $count, 168 'There is 1 image in this gallery', 169 'There are @count images in this gallery' 170 ); 171 } 172 173 /** 174 * Theme the gallery last updated time on a gallery list. 175 */ 176 function theme_image_gallery_updated($timestamp) { 177 return t('%date', array('%date' => format_date($timestamp))) . "\n"; 178 } 179 180 /** 181 * Returns (and possibly creates) a new vocabulary for Image galleries. 182 */ 183 function _image_gallery_get_vid() { 184 $vid = variable_get('image_gallery_nav_vocabulary', NULL); 185 // This is invoked from many locations and only D7 ensures that required 186 // modules are installed/enabled first. 187 // @todo Perhaps also disable image_gallery module and report an error? 188 if (!module_exists('taxonomy')) { 189 return $vid; 190 } 191 if (empty($vid) || !($vocabulary = taxonomy_vocabulary_load($vid))) { 192 // Check to see if an image gallery vocabulary exists. 193 $vid = db_result(db_query("SELECT vid FROM {vocabulary} WHERE module = 'image_gallery'")); 194 if (!$vid && !$vocabulary) { 195 $vocabulary = array( 196 'name' => t('Image Galleries'), 197 'multiple' => 0, 198 'required' => 0, 199 'hierarchy' => 1, 200 'relations' => 0, 201 'module' => 'image_gallery', 202 'nodes' => array('image' => 1), 203 ); 204 taxonomy_save_vocabulary($vocabulary); 205 $vid = $vocabulary['vid']; 206 } 207 elseif ($vocabulary) { 208 // Existing install; ensure that image node type is still assigned. 209 // Keep all other node types intact there. 210 $vocabulary = (array) $vocabulary; 211 $vocabulary['nodes']['image'] = 1; 212 taxonomy_save_vocabulary($vocabulary); 213 $vid = $vocabulary['vid']; 214 } 215 variable_set('image_gallery_nav_vocabulary', $vid); 216 } 217 218 return $vid; 219 } 220 221 /** 222 * Implementation of hook_views_api(). 223 */ 224 function image_gallery_views_api() { 225 return array( 226 'api' => 2, 227 'path' => drupal_get_path('module', 'image_gallery') . '/views', 228 ); 229 } 230
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |