/[drupal]/contributions/modules/ui/ui.module
ViewVC logotype

Diff of /contributions/modules/ui/ui.module

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

revision 1.4, Sun Sep 2 20:54:34 2007 UTC revision 1.5, Sun Sep 2 21:04:26 2007 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: ui.module,v 1.3 2007/09/02 20:54:06 dmitrig01 Exp $  // $Id: ui.module,v 1.4 2007/09/02 20:54:34 dmitrig01 Exp $
3    
4  function ui_add_javascript($plugin) {  function ui_add_javascript($plugin) {
5    if (is_array($plugin)) {    if (is_array($plugin)) {
# Line 9  function ui_add_javascript($plugin) { Line 9  function ui_add_javascript($plugin) {
9      }      }
10    }    }
11    else {    else {
12        $ancestors = ui_get_dependencies($plugin);
13        $ancestors[] = $plugin;
14        $path = drupal_get_path('module', 'ui') .'/javascript/ui.';
15        foreach ($ancestors as $plugin) {
16          drupal_add_js($path . $plugin .'.js');
17        }
18    }    }
19  }  }
20    
21  /**  /**
22   * Check dependencies.   * Get dependencies
23     * @param plugin
24     *   The plugin, which is a string.
25   */   */
26  function ui_check_dependencies() {  function ui_get_dependencies($plugin) {
27    if(!in_array($plugin, ui_get_plugins())) {    if(!in_array($plugin, ui_get_plugins())) {
28      return false;      return false;
29    }    }
30    return _ui_check_dependencies($plugin, array());    return _ui_check_dependencies($plugin, array());
31  }  }
32    
33    /**
34     * Check dependencies for a plugin.
35     *
36     * Gets all dependencies for every plugin recursively.
37     * Adapted from a JavaScript version.
38     *
39     * @param plugin
40     *   The plugin to check dependencies for.
41     * @param ancestors
42     *   The current ancestors.  This is because the function
43     *   is recursive, so it slowly builds up the array.
44     *
45     * @return ancestors
46     *   An array of ancestors.
47     */
48  function _ui_check_dependencies($plugin, $ancestors) {  function _ui_check_dependencies($plugin, $ancestors) {
49    $plugins = ui_get_plugins();    $plugins = ui_get_plugins();
50    if (!empty($plugins[$plugin]['dependencies'])) {    if (!empty($plugins[$plugin]['dependencies'])) {
# Line 33  function _ui_check_dependencies($plugin, Line 56  function _ui_check_dependencies($plugin,
56    }    }
57    return $ancestors;    return $ancestors;
58  }  }
59    /**
60     * Get all plugins.
61     *
62     * Each plugin has an "Official name" and some
63     * dependencies.
64     *
65     * @return plugins
66     *   An array of plugins.
67     */
68  function ui_get_plugins() {  function ui_get_plugins() {
69    return array(    return array(
70      "dimensions" => array(      "dimensions" => array(
71                          "name"=>  "Dimensions",                          "name" => "Dimensions",
72                          "dependencies" => array(),                          "dependencies" => array(),
73                  ),                  ),
74                  "mouse" => array(                  "mouse" => array(
75                          "name"=>  "Mouse system",                          "name" => "Mouse system",
76                          "dependencies" => array("dimensions"),                          "dependencies" => array("dimensions"),
77                  ),                  ),
78                  "tree" => array(                  "tree" => array(
79                          "name"=>  "Tree",                          "name" => "Tree",
80                          "dependencies" => array(),                          "dependencies" => array(),
81                  ),                  ),
82                  "tabs" => array(                  "tabs" => array(
83                          "name"=>  "Tabs",                          "name" => "Tabs",
84                          "dependencies" => array(),                          "dependencies" => array(),
85                  ),                  ),
86                  "effects" => array(                  "effects" => array(
87                          "name"=>  "Effects",                          "name" => "Effects",
88                          "dependencies" => array("dimensions"),                          "dependencies" => array("dimensions"),
89                  ),                  ),
90                  "magnifier" => array(                  "magnifier" => array(
91                          "name"=>  "Magnifier",                          "name" => "Magnifier",
92                          "dependencies" => array("dimensions"),                          "dependencies" => array("dimensions"),
93                  ),                  ),
94                  "draggable" => array(                  "draggable" => array(
95                          "name"=>  "Draggables",                          "name" => "Draggables",
96                          "dependencies" => array("mouse"),                          "dependencies" => array("mouse"),
97                  ),                  ),
98                  "sortable" => array(                  "sortable" => array(
99                          "name"=>  "Sortables",                          "name" => "Sortables",
100                          "dependencies" => array("mouse"),                          "dependencies" => array("mouse"),
101                  ),                  ),
102                  "resizable" => array(                  "resizable" => array(
103                          "name"=>  "Resizables",                          "name" => "Resizables",
104                          "dependencies" => array("mouse"),                          "dependencies" => array("mouse"),
105                  ),                  ),
106                  "slider" => array(                  "slider" => array(
107                          "name"=>  "Slider",                          "name" => "Slider",
108                          "dependencies" => array("mouse"),                          "dependencies" => array("mouse"),
109                  ),                  ),
110                  "droppable" => array(                  "droppable" => array(
111                          "name"=>  "Droppables",                          "name" => "Droppables",
112                          "dependencies" => array("draggable"),                          "dependencies" => array("draggable"),
113                  ),                  ),
114                  "modal" => array(                  "modal" => array(
115                          "name"=>  "Modal dialogs",                          "name" => "Modal dialogs",
116                          "dependencies" => array("draggable", "resizable"),                          "dependencies" => array("draggable", "resizable"),
117                  ),                  ),
118          );          );

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.2