/[drupal]/contributions/modules/imagepath/imagepath.inc
ViewVC logotype

Contents of /contributions/modules/imagepath/imagepath.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Thu Mar 13 21:30:07 2008 UTC (20 months, 2 weeks ago) by noelbush
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--1
File MIME type: text/x-php
corrected bug at http://drupal.org/node/233854, and change from hook_init to hook_menu to play more nicely with others
1 <?php
2
3 /**
4 * Scan currently defined node types, and their
5 * fields, and update the regexes that will
6 * match requests for image fields. These regexes,
7 * plus the list of imagefields available for each
8 * type, are returned in a structured array that defines
9 * the "domain" over which imagepath will operate. The
10 * domain is also stored in a variable for caching.
11 */
12 function _imagepath_update_domain() {
13 $domain = array();
14 foreach (content_types() as $type) {
15 $type_added = FALSE;
16 $imagefield_count = 0;
17 foreach ($type['fields'] as $field) {
18 if ($field['type'] == 'image') {
19 $imagefield_count++;
20 if (!$type_added) {
21 $type = $type['type'];
22 }
23 $field_name = substr($field['field_name'], 6);
24 $domain[$type]['fields'][] = $field_name;
25 $type_added = TRUE;
26 }
27 }
28 if ($type_added) {
29 $regex .= '))';
30 // Allow field name to be omitted if type has only one imagefield.
31 if ($imagefield_count == 1) {
32 $regex .= '?';
33 $domain[$type]['default_field'] = $field_name;
34 }
35 }
36 }
37 variable_set('imagepath_domain', $domain);
38 return $domain;
39 }

  ViewVC Help
Powered by ViewVC 1.1.2