| 1 |
<?php |
<?php |
|
// $Id$ |
|
| 2 |
|
// $Id: ui.module,v 1.2 2007/09/02 20:34:28 dmitrig01 Exp $ |
| 3 |
|
|
| 4 |
|
function ui_add_javascript($plugin) { |
| 5 |
|
if (is_array($plugin)) { |
| 6 |
|
$result = array(); |
| 7 |
|
foreach ($plugin as $p) { |
| 8 |
|
$result[$p] = ui_add_javascript($p); |
| 9 |
|
} |
| 10 |
|
} |
| 11 |
|
else { |
| 12 |
|
|
| 13 |
|
} |
| 14 |
|
} |
| 15 |
|
|
| 16 |
|
/** |
| 17 |
|
* Check dependencies. |
| 18 |
|
*/ |
| 19 |
|
function ui_check_dependencies() { |
| 20 |
|
if(!in_array($plugin, ui_get_plugins())) { |
| 21 |
|
return false; |
| 22 |
|
} |
| 23 |
|
$ancestors = array(); |
| 24 |
|
_ui_check_dependencies($plugin, $ancestors); |
| 25 |
|
} |
| 26 |
|
function _ui_check_dependencies($plugin, $ancestors) { |
| 27 |
|
$plugins = ui_get_plugins(); |
| 28 |
|
if (!empty($plugins[$plugin]['dependencies'])) { |
| 29 |
|
foreach ($plugins[$plugin]['dependencies'] as $dependant) { |
| 30 |
|
$ancestors[] = $dependant; |
| 31 |
|
// We might as well have a performance gain by not passing by reference |
| 32 |
|
$ancestors = _ui_check_dependencies($dependant, $plugins, $ancestors); |
| 33 |
|
} |
| 34 |
|
} |
| 35 |
|
return $ancestors; |
| 36 |
|
} |
| 37 |
|
|
| 38 |
|
function ui_get_plugins() { |
| 39 |
|
return array( |
| 40 |
|
"dimensions" => array( |
| 41 |
|
"name"=> "Dimensions", |
| 42 |
|
"dependencies" => array(), |
| 43 |
|
), |
| 44 |
|
"mouse" => array( |
| 45 |
|
"name"=> "Mouse system", |
| 46 |
|
"dependencies" => array("dimensions"), |
| 47 |
|
), |
| 48 |
|
"tree" => array( |
| 49 |
|
"name"=> "Tree", |
| 50 |
|
"dependencies" => array(), |
| 51 |
|
), |
| 52 |
|
"tabs" => array( |
| 53 |
|
"name"=> "Tabs", |
| 54 |
|
"dependencies" => array(), |
| 55 |
|
), |
| 56 |
|
"effects" => array( |
| 57 |
|
"name"=> "Effects", |
| 58 |
|
"dependencies" => array("dimensions"), |
| 59 |
|
), |
| 60 |
|
"magnifier" => array( |
| 61 |
|
"name"=> "Magnifier", |
| 62 |
|
"dependencies" => array("dimensions"), |
| 63 |
|
), |
| 64 |
|
"draggable" => array( |
| 65 |
|
"name"=> "Draggables", |
| 66 |
|
"dependencies" => array("mouse"), |
| 67 |
|
), |
| 68 |
|
"sortable" => array( |
| 69 |
|
"name"=> "Sortables", |
| 70 |
|
"dependencies" => array("mouse"), |
| 71 |
|
), |
| 72 |
|
"resizable" => array( |
| 73 |
|
"name"=> "Resizables", |
| 74 |
|
"dependencies" => array("mouse"), |
| 75 |
|
), |
| 76 |
|
"slider" => array( |
| 77 |
|
"name"=> "Slider", |
| 78 |
|
"dependencies" => array("mouse"), |
| 79 |
|
), |
| 80 |
|
"droppable" => array( |
| 81 |
|
"name"=> "Droppables", |
| 82 |
|
"dependencies" => array("draggable"), |
| 83 |
|
), |
| 84 |
|
"modal" => array( |
| 85 |
|
"name"=> "Modal dialogs", |
| 86 |
|
"dependencies" => array("draggable", "resizable"), |
| 87 |
|
), |
| 88 |
|
); |
| 89 |
|
} |