/[drupal]/contributions/modules/refcolab/modules/collections/refcolab_collections.module
ViewVC logotype

Diff of /contributions/modules/refcolab/modules/collections/refcolab_collections.module

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

revision 1.1, Fri Jun 13 02:36:19 2008 UTC revision 1.2, Tue Jun 17 03:56:56 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id$  // $Id: refcolab_collections.module,v 1.1 2008/06/13 02:36:19 herc Exp $
3    
4  /**  /**
5   * Implementation of hook_theme().   * Implementation of hook_theme().
# Line 9  function refcolab_collections_theme() { Line 9  function refcolab_collections_theme() {
9      'refcolab_collections_overview_form' => array(      'refcolab_collections_overview_form' => array(
10        'arguments' => array('form' => array()),        'arguments' => array('form' => array()),
11        'file' => 'refcolab_collections.pages.inc',        'file' => 'refcolab_collections.pages.inc',
12      ),      ),
13        'refcolab_collections_form' => array(
14          'arguments' => array('form' => array()),
15          'file' => 'refcolab_collections.pages.inc',
16        ),
17    );    );
18  }  }
19    
# Line 148  function refcolab_collections_get_tree($ Line 152  function refcolab_collections_get_tree($
152    }    }
153    
154    return $tree;    return $tree;
155    }
156    
157    /**
158     * Return a form select element with the collection tree as the options.
159     *
160     * @param $tree
161     *   The collections tree, as returned by refcolab_collections_get_tree().
162     * @param $title
163     *   The title of the form element.
164     * @param $value
165     *   The value.
166     * @param array $exclude
167     *   An array of colelctions IDs to be excluded from the options.
168     * @param $add_root
169     *   Whether to include a root parent.
170     * @return
171     *   The select form element.
172     */
173    function refcolab_collection_select($tree, $title, $value, $exclude, $add_root = TRUE) {
174      if ($add_root) {
175        $options = array(0 => '<'.t('root').'>');
176      }
177      else {
178        $options = array();
179      }
180      foreach ($tree as $item) {
181        if (!in_array($item->cid, $exclude)) {
182          $options[$item->cid] =  str_repeat('-', $item->depth) . $item->name;
183        }
184      }
185      $form = array(
186        '#type' => 'select',
187        '#title' => $title,
188        '#options' => $options,
189        '#default_value' => $value,
190      );
191    
192      return $form;
193  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.2