@@ -10,16 +10,16 @@ |
||
10 | 10 | |
11 | 11 | function smart_adsense_initiate_smartytags() |
12 | 12 | { |
13 | - global $xoopsTpl, $smartobjectAdsenseHandler; |
|
14 | - if (is_object($xoopsTpl)) { |
|
15 | - foreach ($smartobjectAdsenseHandler->objects as $k => $v) { |
|
16 | - $xoopsTpl->assign('adsense_' . $k, $v->render()); |
|
17 | - } |
|
18 | - } |
|
13 | + global $xoopsTpl, $smartobjectAdsenseHandler; |
|
14 | + if (is_object($xoopsTpl)) { |
|
15 | + foreach ($smartobjectAdsenseHandler->objects as $k => $v) { |
|
16 | + $xoopsTpl->assign('adsense_' . $k, $v->render()); |
|
17 | + } |
|
18 | + } |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | if (!defined('SMARTOBJECT_URL')) { |
22 | - include_once(XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php'); |
|
22 | + include_once(XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | include_once XOOPS_ROOT_PATH . '/modules/smartobject/include/functions.php'; |
@@ -26,4 +26,4 @@ |
||
26 | 26 | include_once(SMARTOBJECT_ROOT_PATH . 'class/adsense.php'); |
27 | 27 | |
28 | 28 | $smartobjectAdsenseHandler = xoops_getModuleHandler('adsense', 'smartobject'); |
29 | -$smartobjectAdsensesObj = $smartobjectAdsenseHandler->getAdsensesByTag(); |
|
29 | +$smartobjectAdsensesObj = $smartobjectAdsenseHandler->getAdsensesByTag(); |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
10 | 10 | |
11 | 11 | if (!defined('SMARTOBJECT_URL')) { |
12 | - include_once(XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php'); |
|
12 | + include_once(XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php'); |
|
13 | 13 | } |
14 | 14 | include_once(SMARTOBJECT_ROOT_PATH . 'class/rating.php'); |
15 | 15 | include_once(SMARTOBJECT_ROOT_PATH . 'include/functions.php'); |
@@ -23,53 +23,53 @@ discard block |
||
23 | 23 | $smartobjectPluginHandler = new SmartPluginHandler(); |
24 | 24 | $pluginObj = $smartobjectPluginHandler->getPlugin($module_dirname); |
25 | 25 | if ($pluginObj) { |
26 | - $rating_item = $pluginObj->getItem(); |
|
27 | - if ($rating_item) { |
|
28 | - $rating_itemid = $pluginObj->getItemIdForItem($rating_item); |
|
29 | - $stats = $smartobjectRatingHandler->getRatingAverageByItemId($rating_itemid, $module_dirname, $rating_item); |
|
30 | - $xoopsTpl->assign('smartobject_rating_stats_total', $stats['sum']); |
|
31 | - $xoopsTpl->assign('smartobject_rating_stats_average', $stats['average']); |
|
32 | - $xoopsTpl->assign('smartobject_rating_item', $rating_item); |
|
33 | - if (is_object($xoopsUser)) { |
|
34 | - $ratingObj = $smartobjectRatingHandler->already_rated($rating_item, $rating_itemid, $module_dirname, $xoopsUser->getVar('uid')); |
|
35 | - $xoopsTpl->assign('smartobject_user_can_rate', true); |
|
36 | - } |
|
37 | - if (isset($ratingObj) && is_object($ratingObj)) { |
|
38 | - $xoopsTpl->assign('smartobject_user_rate', $ratingObj->getVar('rate')); |
|
39 | - $xoopsTpl->assign('smartobject_rated', true); |
|
40 | - } else { |
|
41 | - $xoopsTpl->assign('smartobject_rating_dirname', $module_dirname); |
|
42 | - $xoopsTpl->assign('smartobject_rating_itemid', $rating_itemid); |
|
43 | - $urls = smart_getCurrentUrls(); |
|
44 | - $xoopsTpl->assign('smartobject_rating_current_page', $urls['full']); |
|
45 | - if (isset($xoTheme) && is_object($xoTheme)) { |
|
46 | - $xoTheme->addStylesheet(SMARTOBJECT_URL . 'assets/css/module.css'); |
|
47 | - } else { |
|
48 | - //probleme d'inclusion de css apres le flashplayer. Style plac� dans css du theme |
|
49 | - //$xoopsTpl->assign('smartobject_css',"<link rel='stylesheet' type='text/css' href='".XOOPS_URL."/modules/smartobject/assets/css/module.css' />"); |
|
50 | - } |
|
51 | - } |
|
52 | - } |
|
26 | + $rating_item = $pluginObj->getItem(); |
|
27 | + if ($rating_item) { |
|
28 | + $rating_itemid = $pluginObj->getItemIdForItem($rating_item); |
|
29 | + $stats = $smartobjectRatingHandler->getRatingAverageByItemId($rating_itemid, $module_dirname, $rating_item); |
|
30 | + $xoopsTpl->assign('smartobject_rating_stats_total', $stats['sum']); |
|
31 | + $xoopsTpl->assign('smartobject_rating_stats_average', $stats['average']); |
|
32 | + $xoopsTpl->assign('smartobject_rating_item', $rating_item); |
|
33 | + if (is_object($xoopsUser)) { |
|
34 | + $ratingObj = $smartobjectRatingHandler->already_rated($rating_item, $rating_itemid, $module_dirname, $xoopsUser->getVar('uid')); |
|
35 | + $xoopsTpl->assign('smartobject_user_can_rate', true); |
|
36 | + } |
|
37 | + if (isset($ratingObj) && is_object($ratingObj)) { |
|
38 | + $xoopsTpl->assign('smartobject_user_rate', $ratingObj->getVar('rate')); |
|
39 | + $xoopsTpl->assign('smartobject_rated', true); |
|
40 | + } else { |
|
41 | + $xoopsTpl->assign('smartobject_rating_dirname', $module_dirname); |
|
42 | + $xoopsTpl->assign('smartobject_rating_itemid', $rating_itemid); |
|
43 | + $urls = smart_getCurrentUrls(); |
|
44 | + $xoopsTpl->assign('smartobject_rating_current_page', $urls['full']); |
|
45 | + if (isset($xoTheme) && is_object($xoTheme)) { |
|
46 | + $xoTheme->addStylesheet(SMARTOBJECT_URL . 'assets/css/module.css'); |
|
47 | + } else { |
|
48 | + //probleme d'inclusion de css apres le flashplayer. Style plac� dans css du theme |
|
49 | + //$xoopsTpl->assign('smartobject_css',"<link rel='stylesheet' type='text/css' href='".XOOPS_URL."/modules/smartobject/assets/css/module.css' />"); |
|
50 | + } |
|
51 | + } |
|
52 | + } |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | if (isset($_POST['smartobject_rating_submit'])) { |
56 | - // The rating form has just been posted. Let's save the info |
|
57 | - $ratingObj = $smartobjectRatingHandler->create(); |
|
58 | - $ratingObj->setVar('dirname', $module_dirname); |
|
59 | - $ratingObj->setVar('item', $rating_item); |
|
60 | - $ratingObj->setVar('itemid', $rating_itemid); |
|
61 | - $ratingObj->setVar('uid', $xoopsUser->getVar('uid')); |
|
62 | - $ratingObj->setVar('date', time()); |
|
63 | - $ratingObj->setVar('rate', $_POST['smartobject_rating_value']); |
|
64 | - if (!$smartobjectRatingHandler->insert($ratingObj)) { |
|
65 | - if ($xoopsDB->errno() == 1062) { |
|
66 | - $message = _SOBJECT_RATING_DUPLICATE_ENTRY; |
|
67 | - } else { |
|
68 | - $message = _SOBJECT_RATING_ERROR; |
|
69 | - } |
|
70 | - } else { |
|
71 | - $message = _SOBJECT_RATING_SUCCESS; |
|
72 | - } |
|
73 | - redirect_header('', 3, $message); |
|
74 | - exit; |
|
56 | + // The rating form has just been posted. Let's save the info |
|
57 | + $ratingObj = $smartobjectRatingHandler->create(); |
|
58 | + $ratingObj->setVar('dirname', $module_dirname); |
|
59 | + $ratingObj->setVar('item', $rating_item); |
|
60 | + $ratingObj->setVar('itemid', $rating_itemid); |
|
61 | + $ratingObj->setVar('uid', $xoopsUser->getVar('uid')); |
|
62 | + $ratingObj->setVar('date', time()); |
|
63 | + $ratingObj->setVar('rate', $_POST['smartobject_rating_value']); |
|
64 | + if (!$smartobjectRatingHandler->insert($ratingObj)) { |
|
65 | + if ($xoopsDB->errno() == 1062) { |
|
66 | + $message = _SOBJECT_RATING_DUPLICATE_ENTRY; |
|
67 | + } else { |
|
68 | + $message = _SOBJECT_RATING_ERROR; |
|
69 | + } |
|
70 | + } else { |
|
71 | + $message = _SOBJECT_RATING_SUCCESS; |
|
72 | + } |
|
73 | + redirect_header('', 3, $message); |
|
74 | + exit; |
|
75 | 75 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | // Retreive the SmartObject Rating plugin for the current module if it exists |
22 | 22 | $smartobjectRatingHandler = xoops_getModuleHandler('rating', 'smartobject'); |
23 | 23 | $smartobjectPluginHandler = new SmartPluginHandler(); |
24 | -$pluginObj = $smartobjectPluginHandler->getPlugin($module_dirname); |
|
24 | +$pluginObj = $smartobjectPluginHandler->getPlugin($module_dirname); |
|
25 | 25 | if ($pluginObj) { |
26 | 26 | $rating_item = $pluginObj->getItem(); |
27 | 27 | if ($rating_item) { |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Contains the version information of the SmartObject Framework |
|
4 | - * |
|
5 | - * @license GNU |
|
6 | - * @author marcan <[email protected]> |
|
7 | - * @link http://smartfactory.ca The SmartFactory |
|
8 | - * @package SmartObject |
|
9 | - * @subpackage SmartObjectCore |
|
10 | - */ |
|
3 | + * Contains the version information of the SmartObject Framework |
|
4 | + * |
|
5 | + * @license GNU |
|
6 | + * @author marcan <[email protected]> |
|
7 | + * @link http://smartfactory.ca The SmartFactory |
|
8 | + * @package SmartObject |
|
9 | + * @subpackage SmartObjectCore |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | define('SMARTOBJECT_VERSION', 1.0); |
@@ -10,16 +10,16 @@ |
||
10 | 10 | |
11 | 11 | function smart_customtag_initiate() |
12 | 12 | { |
13 | - global $xoopsTpl, $smartobjectCustomtagHandler; |
|
14 | - if (is_object($xoopsTpl)) { |
|
15 | - foreach ($smartobjectCustomtagHandler->objects as $k => $v) { |
|
16 | - $xoopsTpl->assign($k, $v->render()); |
|
17 | - } |
|
18 | - } |
|
13 | + global $xoopsTpl, $smartobjectCustomtagHandler; |
|
14 | + if (is_object($xoopsTpl)) { |
|
15 | + foreach ($smartobjectCustomtagHandler->objects as $k => $v) { |
|
16 | + $xoopsTpl->assign($k, $v->render()); |
|
17 | + } |
|
18 | + } |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | if (!defined('SMARTOBJECT_URL')) { |
22 | - include_once(XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php'); |
|
22 | + include_once(XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | smart_loadLanguageFile('smartobject', 'customtag'); |
@@ -28,4 +28,4 @@ |
||
28 | 28 | include_once(SMARTOBJECT_ROOT_PATH . 'class/customtag.php'); |
29 | 29 | |
30 | 30 | $smartobjectCustomtagHandler = xoops_getModuleHandler('customtag', 'smartobject'); |
31 | -$smartobjectCustomTagsObj = $smartobjectCustomtagHandler->getCustomtagsByName(); |
|
31 | +$smartobjectCustomTagsObj = $smartobjectCustomtagHandler->getCustomtagsByName(); |
@@ -15,90 +15,90 @@ |
||
15 | 15 | */ |
16 | 16 | class JavaScript |
17 | 17 | { |
18 | - /** |
|
19 | - * @param $name |
|
20 | - * @param null $function |
|
21 | - * @return string |
|
22 | - */ |
|
23 | - public function button_to_function($name, $function = null) |
|
24 | - { |
|
25 | - return '<input type="button" value="' . $name . '" onclick="' . $function . '" />'; |
|
26 | - } |
|
18 | + /** |
|
19 | + * @param $name |
|
20 | + * @param null $function |
|
21 | + * @return string |
|
22 | + */ |
|
23 | + public function button_to_function($name, $function = null) |
|
24 | + { |
|
25 | + return '<input type="button" value="' . $name . '" onclick="' . $function . '" />'; |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * @param $javascript |
|
30 | - * @return mixed|string |
|
31 | - */ |
|
32 | - public function escape($javascript) |
|
33 | - { |
|
34 | - $javascript = addslashes($javascript); |
|
35 | - $javascript = str_replace(array("\r\n", "\n", "\r"), array("\n"), $javascript); |
|
28 | + /** |
|
29 | + * @param $javascript |
|
30 | + * @return mixed|string |
|
31 | + */ |
|
32 | + public function escape($javascript) |
|
33 | + { |
|
34 | + $javascript = addslashes($javascript); |
|
35 | + $javascript = str_replace(array("\r\n", "\n", "\r"), array("\n"), $javascript); |
|
36 | 36 | |
37 | - return $javascript; |
|
38 | - } |
|
37 | + return $javascript; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @param $content |
|
42 | - * @return string |
|
43 | - */ |
|
44 | - public function tag($content) |
|
45 | - { |
|
46 | - return '<script type="text/javascript">' . $content . '</script>'; |
|
47 | - } |
|
40 | + /** |
|
41 | + * @param $content |
|
42 | + * @return string |
|
43 | + */ |
|
44 | + public function tag($content) |
|
45 | + { |
|
46 | + return '<script type="text/javascript">' . $content . '</script>'; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @param $name |
|
51 | - * @param $function |
|
52 | - * @param null $html_options |
|
53 | - * @return string |
|
54 | - */ |
|
55 | - public function link_to_function($name, $function, $html_options = null) |
|
56 | - { |
|
57 | - return '<a href="' . (isset($html_options['href']) ? $html_options['href'] : '#') . '" onclick="' . (isset($html_options['onclick']) ? $html_options['onclick'] . ';' : '') . $function . '; return false;" />' . $name . '</a>'; |
|
58 | - } |
|
49 | + /** |
|
50 | + * @param $name |
|
51 | + * @param $function |
|
52 | + * @param null $html_options |
|
53 | + * @return string |
|
54 | + */ |
|
55 | + public function link_to_function($name, $function, $html_options = null) |
|
56 | + { |
|
57 | + return '<a href="' . (isset($html_options['href']) ? $html_options['href'] : '#') . '" onclick="' . (isset($html_options['onclick']) ? $html_options['onclick'] . ';' : '') . $function . '; return false;" />' . $name . '</a>'; |
|
58 | + } |
|
59 | 59 | |
60 | - ///////////////////////////////////////////////////////////////////////////////////// |
|
61 | - // Private functions |
|
62 | - ///////////////////////////////////////////////////////////////////////////////////// |
|
60 | + ///////////////////////////////////////////////////////////////////////////////////// |
|
61 | + // Private functions |
|
62 | + ///////////////////////////////////////////////////////////////////////////////////// |
|
63 | 63 | |
64 | - /** |
|
65 | - * @param $option |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - public function _array_or_string_for_javascript($option) |
|
69 | - { |
|
70 | - $return_val = ''; |
|
71 | - if (is_array($option)) { |
|
72 | - foreach ($option as $value) { |
|
73 | - if (!empty($return_val)) { |
|
74 | - $ret_val .= ', '; |
|
75 | - } |
|
76 | - $return_val .= $value; |
|
77 | - } |
|
64 | + /** |
|
65 | + * @param $option |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + public function _array_or_string_for_javascript($option) |
|
69 | + { |
|
70 | + $return_val = ''; |
|
71 | + if (is_array($option)) { |
|
72 | + foreach ($option as $value) { |
|
73 | + if (!empty($return_val)) { |
|
74 | + $ret_val .= ', '; |
|
75 | + } |
|
76 | + $return_val .= $value; |
|
77 | + } |
|
78 | 78 | |
79 | - return '[' . $return_val . ']'; |
|
80 | - } |
|
79 | + return '[' . $return_val . ']'; |
|
80 | + } |
|
81 | 81 | |
82 | - return "'$option'"; |
|
83 | - } |
|
82 | + return "'$option'"; |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * @param $options |
|
87 | - * @return string |
|
88 | - */ |
|
89 | - public function _options_for_javascript($options) |
|
90 | - { |
|
91 | - $return_val = ''; |
|
85 | + /** |
|
86 | + * @param $options |
|
87 | + * @return string |
|
88 | + */ |
|
89 | + public function _options_for_javascript($options) |
|
90 | + { |
|
91 | + $return_val = ''; |
|
92 | 92 | |
93 | - if (is_array($options)) { |
|
94 | - foreach ($options as $var => $val) { |
|
95 | - if (!empty($return_val)) { |
|
96 | - $return_val .= ', '; |
|
97 | - } |
|
98 | - $return_val .= "$var:$val"; |
|
99 | - } |
|
100 | - } |
|
93 | + if (is_array($options)) { |
|
94 | + foreach ($options as $var => $val) { |
|
95 | + if (!empty($return_val)) { |
|
96 | + $return_val .= ', '; |
|
97 | + } |
|
98 | + $return_val .= "$var:$val"; |
|
99 | + } |
|
100 | + } |
|
101 | 101 | |
102 | - return '{' . $return_val . '}'; |
|
103 | - } |
|
102 | + return '{' . $return_val . '}'; |
|
103 | + } |
|
104 | 104 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | /** |
29 | 29 | * @param $javascript |
30 | - * @return mixed|string |
|
30 | + * @return string |
|
31 | 31 | */ |
32 | 32 | public function escape($javascript) |
33 | 33 | { |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @param $name |
51 | - * @param $function |
|
51 | + * @param string $function |
|
52 | 52 | * @param null $html_options |
53 | 53 | * @return string |
54 | 54 | */ |
@@ -15,452 +15,452 @@ |
||
15 | 15 | */ |
16 | 16 | class Prototype extends JavaScript |
17 | 17 | { |
18 | - public $CALLBACKS = array( |
|
19 | - 'uninitialized', |
|
20 | - 'loading', |
|
21 | - 'loaded', |
|
22 | - 'interactive', |
|
23 | - 'complete', |
|
24 | - 'failure', |
|
25 | - 'success' |
|
26 | - ); |
|
27 | - |
|
28 | - public $AJAX_OPTIONS = array( |
|
29 | - 'before', |
|
30 | - 'after', |
|
31 | - 'condition', |
|
32 | - 'url', |
|
33 | - 'asynchronous', |
|
34 | - 'method', |
|
35 | - 'insertion', |
|
36 | - 'position', |
|
37 | - 'form', |
|
38 | - 'with', |
|
39 | - 'update', |
|
40 | - 'script', |
|
41 | - 'uninitialized', |
|
42 | - 'loading', |
|
43 | - 'loaded', |
|
44 | - 'interactive', |
|
45 | - 'complete', |
|
46 | - 'failure', |
|
47 | - 'success' |
|
48 | - ); |
|
49 | - |
|
50 | - /** |
|
51 | - * @return string |
|
52 | - */ |
|
53 | - public function evaluate_remote_response() |
|
54 | - { |
|
55 | - return 'eval(request.responseText)'; |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * @param $options |
|
60 | - * @return string |
|
61 | - */ |
|
62 | - public function form_remote_tag($options) |
|
63 | - { |
|
64 | - $options['form'] = true; |
|
65 | - |
|
66 | - return '<form action="' . $options['url'] . '" onsubmit="' . $this->remote_function($options) . '; return false;" method="' . (isset($options['method']) ? $options['method'] : 'post') . '" >'; |
|
67 | - } |
|
68 | - |
|
69 | - /** |
|
70 | - * @param $name |
|
71 | - * @param null $options |
|
72 | - * @param null $html_options |
|
73 | - * @return string |
|
74 | - */ |
|
75 | - public function link_to_remote($name, $options = null, $html_options = null) |
|
76 | - { |
|
77 | - return $this->link_to_function($name, $this->remote_function($options), $html_options); |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * @param $field_id |
|
82 | - * @param null $options |
|
83 | - * @return string |
|
84 | - */ |
|
85 | - public function observe_field($field_id, $options = null) |
|
86 | - { |
|
87 | - if (isset($options['frequency']) && $options['frequency'] > 0) { |
|
88 | - return $this->_build_observer('Form.Element.Observer', $field_id, $options); |
|
89 | - } else { |
|
90 | - return $this->_build_observer('Form.Element.EventObserver', $field_id, $options); |
|
91 | - } |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * @param $form_id |
|
96 | - * @param null $options |
|
97 | - * @return string |
|
98 | - */ |
|
99 | - public function observe_form($form_id, $options = null) |
|
100 | - { |
|
101 | - if (isset($options['frequency'])) { |
|
102 | - return $this->_build_observer('Form.Observer', $form_id, $options); |
|
103 | - } else { |
|
104 | - return $this->_build_observer('Form.EventObserver', $form_id, $options); |
|
105 | - } |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * @param null $options |
|
110 | - * @return string |
|
111 | - */ |
|
112 | - public function periodically_call_remote($options = null) |
|
113 | - { |
|
114 | - $frequency = isset($options['frequency']) ? $options['frequency'] : 10; |
|
115 | - $code = 'new PeriodicalExecuter(function() {' . $this->remote_function($options) . '},' . $frequency . ')'; |
|
116 | - |
|
117 | - return $code; |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * @param $options |
|
122 | - * @return string |
|
123 | - */ |
|
124 | - public function remote_function($options) |
|
125 | - { |
|
126 | - $javascript_options = $this->_options_for_ajax($options); |
|
127 | - |
|
128 | - $update = ''; |
|
129 | - |
|
130 | - if (isset($options['update']) && is_array($options['update'])) { |
|
131 | - $update = isset($options['update']['success']) ? 'success: ' . $options['update']['success'] : ''; |
|
132 | - $update .= empty($update) ? '' : ','; |
|
133 | - $update .= isset($options['update']['failure']) ? 'failure: ' . $options['update']['failure'] : ''; |
|
134 | - } else { |
|
135 | - $update .= isset($options['update']) ? $options['update'] : ''; |
|
136 | - } |
|
137 | - |
|
138 | - $ajax_function = empty($update) ? 'new Ajax.Request(' : 'new Ajax.Updater(\'' . $update . '\','; |
|
139 | - |
|
140 | - $ajax_function .= "'" . $options['url'] . "'"; |
|
141 | - $ajax_function .= ',' . $javascript_options . ')'; |
|
142 | - |
|
143 | - $ajax_function = isset($options['before']) ? $options['before'] . ';' . $ajax_function : $ajax_function; |
|
144 | - $ajax_function = isset($options['after']) ? $ajax_function . ';' . $options['after'] : $ajax_function; |
|
145 | - $ajax_function = isset($options['condition']) ? 'if (' . $options['condition'] . ') {' . $ajax_function . '}' : $ajax_function; |
|
146 | - $ajax_function = isset($options['confirm']) ? 'if ( confirm(\'' . $options['confirm'] . '\' ) ) { ' . $ajax_function . ' } ' : $ajax_function; |
|
147 | - |
|
148 | - return $ajax_function; |
|
149 | - } |
|
150 | - |
|
151 | - /** |
|
152 | - * @param $name |
|
153 | - * @param $value |
|
154 | - * @param $options |
|
155 | - * @return string |
|
156 | - */ |
|
157 | - public function submit_to_remote($name, $value, $options) |
|
158 | - { |
|
159 | - if (isset($options['with'])) { |
|
160 | - $options['with'] = 'Form.serialize(this.form)'; |
|
161 | - } |
|
162 | - |
|
163 | - return '<input type="button" onclick="' . $this->remote_function($options) . '" name="' . $name . '" value ="' . $value . '" />'; |
|
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * @param $element_id |
|
168 | - * @param null $options |
|
169 | - * @param $block |
|
170 | - */ |
|
171 | - public function update_element_function($element_id, $options = null, $block) |
|
172 | - { |
|
173 | - $content = isset($options['content']) ? $options['content'] : ''; |
|
174 | - $content = $this->escape($content); |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * @param $block |
|
179 | - */ |
|
180 | - public function update_page($block) |
|
181 | - { |
|
182 | - } |
|
183 | - |
|
184 | - /** |
|
185 | - * @param $block |
|
186 | - * @return string |
|
187 | - */ |
|
188 | - public function update_page_tag(& $block) |
|
189 | - { |
|
190 | - return $this->tag($block); |
|
191 | - } |
|
192 | - |
|
193 | - ///////////////////////////////////////////////////////////////////////////////////// |
|
194 | - // Private functions |
|
195 | - ///////////////////////////////////////////////////////////////////////////////////// |
|
196 | - |
|
197 | - /** |
|
198 | - * @param $options |
|
199 | - * @return array |
|
200 | - */ |
|
201 | - public function _build_callbacks($options) |
|
202 | - { |
|
203 | - $callbacks = array(); |
|
204 | - foreach ($options as $callback => $code) { |
|
205 | - if (in_array($callback, $this->CALLBACKS)) { |
|
206 | - $name = 'on' . ucfirst($callback); |
|
207 | - $callbacks[$name] = 'function(request){' . $code . '}'; |
|
208 | - } |
|
209 | - } |
|
210 | - |
|
211 | - return $callbacks; |
|
212 | - } |
|
213 | - |
|
214 | - /** |
|
215 | - * @param $klass |
|
216 | - * @param $name |
|
217 | - * @param null $options |
|
218 | - * @return string |
|
219 | - */ |
|
220 | - public function _build_observer($klass, $name, $options = null) |
|
221 | - { |
|
222 | - if (isset($options['with']) && false === strpos($options['with'], '=')) { |
|
223 | - $options['with'] = '\'' . $options['with'] . '=\' + value'; |
|
224 | - } elseif (isset($options['with']) && isset($options['update'])) { |
|
225 | - $options['with'] = 'value'; |
|
226 | - } |
|
227 | - |
|
228 | - $callback = $options['function'] ?: $this->remote_function($options); |
|
229 | - |
|
230 | - $javascript = "new $klass('$name', "; |
|
231 | - $javascript .= isset($options['frequency']) ? $options['frequency'] . ', ' : ''; |
|
232 | - $javascript .= 'function (element,value) { '; |
|
233 | - $javascript .= $callback; |
|
234 | - $javascript .= isset($options['on']) ? ', ' . $options['on'] : ''; |
|
235 | - $javascript .= '})'; |
|
236 | - |
|
237 | - return $javascript; |
|
238 | - } |
|
239 | - |
|
240 | - /** |
|
241 | - * @param $method |
|
242 | - * @return string |
|
243 | - */ |
|
244 | - public function _method_option_to_s($method) |
|
245 | - { |
|
246 | - return strstr($method, "'") ? $method : "'$method'"; |
|
247 | - } |
|
248 | - |
|
249 | - /** |
|
250 | - * @param $options |
|
251 | - * @return string |
|
252 | - */ |
|
253 | - public function _options_for_ajax($options) |
|
254 | - { |
|
255 | - $js_options = is_array($options) ? $this->_build_callbacks($options) : array(); |
|
256 | - |
|
257 | - if (isset($options['type']) && $option['type'] === 'synchronous') { |
|
258 | - $js_options['asynchronous'] = 'false'; |
|
259 | - } |
|
260 | - |
|
261 | - if (isset($options['method'])) { |
|
262 | - $js_options['method'] = $this->_method_option_to_s($options['method']); |
|
263 | - } |
|
264 | - |
|
265 | - if (isset($options['position'])) { |
|
266 | - $js_options['insertion'] = 'Insertion.' . ucfirst($options['position']); |
|
267 | - } |
|
268 | - |
|
269 | - $js_options['evalScripts'] = isset($options['script']) ? $options['script'] : 'true'; |
|
270 | - |
|
271 | - if (isset($options['form'])) { |
|
272 | - $js_options['parameters'] = 'Form.serialize(this)'; |
|
273 | - } elseif (isset($options['parameters'])) { |
|
274 | - $js_options['parameters'] = 'Form.serialize(\'' . $options['submit'] . '\')'; |
|
275 | - } elseif (isset($options['with'])) { |
|
276 | - $js_options['parameters'] = $options['with']; |
|
277 | - } |
|
278 | - |
|
279 | - return $this->_options_for_javascript($js_options); |
|
280 | - } |
|
281 | - |
|
282 | - ///////////////////////////////////////////////////////////////////////////////////// |
|
283 | - // Mergerd Javascript Generator helpers |
|
284 | - ///////////////////////////////////////////////////////////////////////////////////// |
|
285 | - |
|
286 | - /** |
|
287 | - * @param $javascript |
|
288 | - */ |
|
289 | - public function dump($javascript) |
|
290 | - { |
|
291 | - echo $javascript; |
|
292 | - } |
|
293 | - |
|
294 | - /** |
|
295 | - * @param $id |
|
296 | - * @param null $extend |
|
297 | - * @return string |
|
298 | - */ |
|
299 | - public function ID($id, $extend = null) |
|
300 | - { |
|
301 | - return "$('$id')" . (!empty($extend)) ? '.' . $extend . '()' : ''; |
|
302 | - } |
|
303 | - |
|
304 | - /** |
|
305 | - * @param $message |
|
306 | - * @return string |
|
307 | - */ |
|
308 | - public function alert($message) |
|
309 | - { |
|
310 | - return $this->call('alert', $message); |
|
311 | - } |
|
312 | - |
|
313 | - /** |
|
314 | - * @param $variable |
|
315 | - * @param $value |
|
316 | - * @return string |
|
317 | - */ |
|
318 | - public function assign($variable, $value) |
|
319 | - { |
|
320 | - return "$variable = $value;"; |
|
321 | - } |
|
322 | - |
|
323 | - /** |
|
324 | - * @param $function |
|
325 | - * @param null $args |
|
326 | - * @return string |
|
327 | - */ |
|
328 | - public function call($function, $args = null) |
|
329 | - { |
|
330 | - $arg_str = ''; |
|
331 | - if (is_array($args)) { |
|
332 | - foreach ($args as $arg) { |
|
333 | - if (!empty($arg_str)) { |
|
334 | - $arg_str .= ', '; |
|
335 | - } |
|
336 | - if (is_string($arg)) { |
|
337 | - $arg_str .= "'$arg'"; |
|
338 | - } else { |
|
339 | - $arg_str .= $arg; |
|
340 | - } |
|
341 | - } |
|
342 | - } else { |
|
343 | - if (is_string($args)) { |
|
344 | - $arg_str .= "'$args'"; |
|
345 | - } else { |
|
346 | - $arg_str .= $args; |
|
347 | - } |
|
348 | - } |
|
349 | - |
|
350 | - return "$function($arg_str)"; |
|
351 | - } |
|
352 | - |
|
353 | - /** |
|
354 | - * @param int $seconds |
|
355 | - * @param string $script |
|
356 | - * @return string |
|
357 | - */ |
|
358 | - public function delay($seconds = 1, $script = '') |
|
359 | - { |
|
360 | - return "setTimeout( function() { $script } , " . ($seconds * 1000) . ' )'; |
|
361 | - } |
|
362 | - |
|
363 | - /** |
|
364 | - * @param $id |
|
365 | - * @return string |
|
366 | - */ |
|
367 | - public function hide($id) |
|
368 | - { |
|
369 | - return $this->call('Element.hide', $id); |
|
370 | - } |
|
371 | - |
|
372 | - /** |
|
373 | - * @param $position |
|
374 | - * @param $id |
|
375 | - * @param null $options_for_render |
|
376 | - * @return string |
|
377 | - */ |
|
378 | - public function insert_html($position, $id, $options_for_render = null) |
|
379 | - { |
|
380 | - $args = array_merge(array($id), (is_array($options_for_render) ? $options_for_render : array($options_for_render))); |
|
381 | - |
|
382 | - return $this->call('new Insertion.' . ucfirst($position), $args); |
|
383 | - } |
|
384 | - |
|
385 | - /** |
|
386 | - * @param $location |
|
387 | - * @return string |
|
388 | - */ |
|
389 | - public function redirect_to($location) |
|
390 | - { |
|
391 | - return $this->assign('window.location.href', $location); |
|
392 | - } |
|
393 | - |
|
394 | - /** |
|
395 | - * @param $id |
|
396 | - * @return string |
|
397 | - */ |
|
398 | - public function remove($id) |
|
399 | - { |
|
400 | - if (is_array($id)) { |
|
401 | - $arr_str = ''; |
|
402 | - foreach ($id as $obj) { |
|
403 | - if (!empty($arg_str)) { |
|
404 | - $arg_str .= ', '; |
|
405 | - } |
|
406 | - $arg_str .= "'$arg'"; |
|
407 | - } |
|
408 | - |
|
409 | - return "$A[$arg_str].each(Element.remove)"; |
|
410 | - } else { |
|
411 | - return "Element.remove('$id')"; |
|
412 | - } |
|
413 | - } |
|
414 | - |
|
415 | - /** |
|
416 | - * @param $id |
|
417 | - * @param $options_for_render |
|
418 | - * @return string |
|
419 | - */ |
|
420 | - public function replace($id, $options_for_render) |
|
421 | - { |
|
422 | - $args = array_merge(array($id), (is_array($options_for_render) ? $options_for_render : array($options_for_render))); |
|
423 | - |
|
424 | - return $this->call('Element.replace', $args); |
|
425 | - } |
|
426 | - |
|
427 | - /** |
|
428 | - * @param $id |
|
429 | - * @param $options_for_render |
|
430 | - * @return string |
|
431 | - */ |
|
432 | - public function replace_html($id, $options_for_render) |
|
433 | - { |
|
434 | - $args = array_merge(array($id), (is_array($options_for_render) ? $options_for_render : array($options_for_render))); |
|
435 | - |
|
436 | - return $this->call('Element.update', $args); |
|
437 | - } |
|
438 | - |
|
439 | - /** |
|
440 | - * @param $pattern |
|
441 | - * @param null $extend |
|
442 | - * @return string |
|
443 | - */ |
|
444 | - public function select($pattern, $extend = null) |
|
445 | - { |
|
446 | - return "$$('$pattern')" . (!empty($extend)) ? '.' . $extend : ''; |
|
447 | - } |
|
448 | - |
|
449 | - /** |
|
450 | - * @param $id |
|
451 | - * @return string |
|
452 | - */ |
|
453 | - public function show($id) |
|
454 | - { |
|
455 | - return $this->call('Element.show', $id); |
|
456 | - } |
|
457 | - |
|
458 | - /** |
|
459 | - * @param $id |
|
460 | - * @return string |
|
461 | - */ |
|
462 | - public function toggle($id) |
|
463 | - { |
|
464 | - return $this->call('Element.toggle', $id); |
|
465 | - } |
|
18 | + public $CALLBACKS = array( |
|
19 | + 'uninitialized', |
|
20 | + 'loading', |
|
21 | + 'loaded', |
|
22 | + 'interactive', |
|
23 | + 'complete', |
|
24 | + 'failure', |
|
25 | + 'success' |
|
26 | + ); |
|
27 | + |
|
28 | + public $AJAX_OPTIONS = array( |
|
29 | + 'before', |
|
30 | + 'after', |
|
31 | + 'condition', |
|
32 | + 'url', |
|
33 | + 'asynchronous', |
|
34 | + 'method', |
|
35 | + 'insertion', |
|
36 | + 'position', |
|
37 | + 'form', |
|
38 | + 'with', |
|
39 | + 'update', |
|
40 | + 'script', |
|
41 | + 'uninitialized', |
|
42 | + 'loading', |
|
43 | + 'loaded', |
|
44 | + 'interactive', |
|
45 | + 'complete', |
|
46 | + 'failure', |
|
47 | + 'success' |
|
48 | + ); |
|
49 | + |
|
50 | + /** |
|
51 | + * @return string |
|
52 | + */ |
|
53 | + public function evaluate_remote_response() |
|
54 | + { |
|
55 | + return 'eval(request.responseText)'; |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * @param $options |
|
60 | + * @return string |
|
61 | + */ |
|
62 | + public function form_remote_tag($options) |
|
63 | + { |
|
64 | + $options['form'] = true; |
|
65 | + |
|
66 | + return '<form action="' . $options['url'] . '" onsubmit="' . $this->remote_function($options) . '; return false;" method="' . (isset($options['method']) ? $options['method'] : 'post') . '" >'; |
|
67 | + } |
|
68 | + |
|
69 | + /** |
|
70 | + * @param $name |
|
71 | + * @param null $options |
|
72 | + * @param null $html_options |
|
73 | + * @return string |
|
74 | + */ |
|
75 | + public function link_to_remote($name, $options = null, $html_options = null) |
|
76 | + { |
|
77 | + return $this->link_to_function($name, $this->remote_function($options), $html_options); |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * @param $field_id |
|
82 | + * @param null $options |
|
83 | + * @return string |
|
84 | + */ |
|
85 | + public function observe_field($field_id, $options = null) |
|
86 | + { |
|
87 | + if (isset($options['frequency']) && $options['frequency'] > 0) { |
|
88 | + return $this->_build_observer('Form.Element.Observer', $field_id, $options); |
|
89 | + } else { |
|
90 | + return $this->_build_observer('Form.Element.EventObserver', $field_id, $options); |
|
91 | + } |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * @param $form_id |
|
96 | + * @param null $options |
|
97 | + * @return string |
|
98 | + */ |
|
99 | + public function observe_form($form_id, $options = null) |
|
100 | + { |
|
101 | + if (isset($options['frequency'])) { |
|
102 | + return $this->_build_observer('Form.Observer', $form_id, $options); |
|
103 | + } else { |
|
104 | + return $this->_build_observer('Form.EventObserver', $form_id, $options); |
|
105 | + } |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * @param null $options |
|
110 | + * @return string |
|
111 | + */ |
|
112 | + public function periodically_call_remote($options = null) |
|
113 | + { |
|
114 | + $frequency = isset($options['frequency']) ? $options['frequency'] : 10; |
|
115 | + $code = 'new PeriodicalExecuter(function() {' . $this->remote_function($options) . '},' . $frequency . ')'; |
|
116 | + |
|
117 | + return $code; |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * @param $options |
|
122 | + * @return string |
|
123 | + */ |
|
124 | + public function remote_function($options) |
|
125 | + { |
|
126 | + $javascript_options = $this->_options_for_ajax($options); |
|
127 | + |
|
128 | + $update = ''; |
|
129 | + |
|
130 | + if (isset($options['update']) && is_array($options['update'])) { |
|
131 | + $update = isset($options['update']['success']) ? 'success: ' . $options['update']['success'] : ''; |
|
132 | + $update .= empty($update) ? '' : ','; |
|
133 | + $update .= isset($options['update']['failure']) ? 'failure: ' . $options['update']['failure'] : ''; |
|
134 | + } else { |
|
135 | + $update .= isset($options['update']) ? $options['update'] : ''; |
|
136 | + } |
|
137 | + |
|
138 | + $ajax_function = empty($update) ? 'new Ajax.Request(' : 'new Ajax.Updater(\'' . $update . '\','; |
|
139 | + |
|
140 | + $ajax_function .= "'" . $options['url'] . "'"; |
|
141 | + $ajax_function .= ',' . $javascript_options . ')'; |
|
142 | + |
|
143 | + $ajax_function = isset($options['before']) ? $options['before'] . ';' . $ajax_function : $ajax_function; |
|
144 | + $ajax_function = isset($options['after']) ? $ajax_function . ';' . $options['after'] : $ajax_function; |
|
145 | + $ajax_function = isset($options['condition']) ? 'if (' . $options['condition'] . ') {' . $ajax_function . '}' : $ajax_function; |
|
146 | + $ajax_function = isset($options['confirm']) ? 'if ( confirm(\'' . $options['confirm'] . '\' ) ) { ' . $ajax_function . ' } ' : $ajax_function; |
|
147 | + |
|
148 | + return $ajax_function; |
|
149 | + } |
|
150 | + |
|
151 | + /** |
|
152 | + * @param $name |
|
153 | + * @param $value |
|
154 | + * @param $options |
|
155 | + * @return string |
|
156 | + */ |
|
157 | + public function submit_to_remote($name, $value, $options) |
|
158 | + { |
|
159 | + if (isset($options['with'])) { |
|
160 | + $options['with'] = 'Form.serialize(this.form)'; |
|
161 | + } |
|
162 | + |
|
163 | + return '<input type="button" onclick="' . $this->remote_function($options) . '" name="' . $name . '" value ="' . $value . '" />'; |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * @param $element_id |
|
168 | + * @param null $options |
|
169 | + * @param $block |
|
170 | + */ |
|
171 | + public function update_element_function($element_id, $options = null, $block) |
|
172 | + { |
|
173 | + $content = isset($options['content']) ? $options['content'] : ''; |
|
174 | + $content = $this->escape($content); |
|
175 | + } |
|
176 | + |
|
177 | + /** |
|
178 | + * @param $block |
|
179 | + */ |
|
180 | + public function update_page($block) |
|
181 | + { |
|
182 | + } |
|
183 | + |
|
184 | + /** |
|
185 | + * @param $block |
|
186 | + * @return string |
|
187 | + */ |
|
188 | + public function update_page_tag(& $block) |
|
189 | + { |
|
190 | + return $this->tag($block); |
|
191 | + } |
|
192 | + |
|
193 | + ///////////////////////////////////////////////////////////////////////////////////// |
|
194 | + // Private functions |
|
195 | + ///////////////////////////////////////////////////////////////////////////////////// |
|
196 | + |
|
197 | + /** |
|
198 | + * @param $options |
|
199 | + * @return array |
|
200 | + */ |
|
201 | + public function _build_callbacks($options) |
|
202 | + { |
|
203 | + $callbacks = array(); |
|
204 | + foreach ($options as $callback => $code) { |
|
205 | + if (in_array($callback, $this->CALLBACKS)) { |
|
206 | + $name = 'on' . ucfirst($callback); |
|
207 | + $callbacks[$name] = 'function(request){' . $code . '}'; |
|
208 | + } |
|
209 | + } |
|
210 | + |
|
211 | + return $callbacks; |
|
212 | + } |
|
213 | + |
|
214 | + /** |
|
215 | + * @param $klass |
|
216 | + * @param $name |
|
217 | + * @param null $options |
|
218 | + * @return string |
|
219 | + */ |
|
220 | + public function _build_observer($klass, $name, $options = null) |
|
221 | + { |
|
222 | + if (isset($options['with']) && false === strpos($options['with'], '=')) { |
|
223 | + $options['with'] = '\'' . $options['with'] . '=\' + value'; |
|
224 | + } elseif (isset($options['with']) && isset($options['update'])) { |
|
225 | + $options['with'] = 'value'; |
|
226 | + } |
|
227 | + |
|
228 | + $callback = $options['function'] ?: $this->remote_function($options); |
|
229 | + |
|
230 | + $javascript = "new $klass('$name', "; |
|
231 | + $javascript .= isset($options['frequency']) ? $options['frequency'] . ', ' : ''; |
|
232 | + $javascript .= 'function (element,value) { '; |
|
233 | + $javascript .= $callback; |
|
234 | + $javascript .= isset($options['on']) ? ', ' . $options['on'] : ''; |
|
235 | + $javascript .= '})'; |
|
236 | + |
|
237 | + return $javascript; |
|
238 | + } |
|
239 | + |
|
240 | + /** |
|
241 | + * @param $method |
|
242 | + * @return string |
|
243 | + */ |
|
244 | + public function _method_option_to_s($method) |
|
245 | + { |
|
246 | + return strstr($method, "'") ? $method : "'$method'"; |
|
247 | + } |
|
248 | + |
|
249 | + /** |
|
250 | + * @param $options |
|
251 | + * @return string |
|
252 | + */ |
|
253 | + public function _options_for_ajax($options) |
|
254 | + { |
|
255 | + $js_options = is_array($options) ? $this->_build_callbacks($options) : array(); |
|
256 | + |
|
257 | + if (isset($options['type']) && $option['type'] === 'synchronous') { |
|
258 | + $js_options['asynchronous'] = 'false'; |
|
259 | + } |
|
260 | + |
|
261 | + if (isset($options['method'])) { |
|
262 | + $js_options['method'] = $this->_method_option_to_s($options['method']); |
|
263 | + } |
|
264 | + |
|
265 | + if (isset($options['position'])) { |
|
266 | + $js_options['insertion'] = 'Insertion.' . ucfirst($options['position']); |
|
267 | + } |
|
268 | + |
|
269 | + $js_options['evalScripts'] = isset($options['script']) ? $options['script'] : 'true'; |
|
270 | + |
|
271 | + if (isset($options['form'])) { |
|
272 | + $js_options['parameters'] = 'Form.serialize(this)'; |
|
273 | + } elseif (isset($options['parameters'])) { |
|
274 | + $js_options['parameters'] = 'Form.serialize(\'' . $options['submit'] . '\')'; |
|
275 | + } elseif (isset($options['with'])) { |
|
276 | + $js_options['parameters'] = $options['with']; |
|
277 | + } |
|
278 | + |
|
279 | + return $this->_options_for_javascript($js_options); |
|
280 | + } |
|
281 | + |
|
282 | + ///////////////////////////////////////////////////////////////////////////////////// |
|
283 | + // Mergerd Javascript Generator helpers |
|
284 | + ///////////////////////////////////////////////////////////////////////////////////// |
|
285 | + |
|
286 | + /** |
|
287 | + * @param $javascript |
|
288 | + */ |
|
289 | + public function dump($javascript) |
|
290 | + { |
|
291 | + echo $javascript; |
|
292 | + } |
|
293 | + |
|
294 | + /** |
|
295 | + * @param $id |
|
296 | + * @param null $extend |
|
297 | + * @return string |
|
298 | + */ |
|
299 | + public function ID($id, $extend = null) |
|
300 | + { |
|
301 | + return "$('$id')" . (!empty($extend)) ? '.' . $extend . '()' : ''; |
|
302 | + } |
|
303 | + |
|
304 | + /** |
|
305 | + * @param $message |
|
306 | + * @return string |
|
307 | + */ |
|
308 | + public function alert($message) |
|
309 | + { |
|
310 | + return $this->call('alert', $message); |
|
311 | + } |
|
312 | + |
|
313 | + /** |
|
314 | + * @param $variable |
|
315 | + * @param $value |
|
316 | + * @return string |
|
317 | + */ |
|
318 | + public function assign($variable, $value) |
|
319 | + { |
|
320 | + return "$variable = $value;"; |
|
321 | + } |
|
322 | + |
|
323 | + /** |
|
324 | + * @param $function |
|
325 | + * @param null $args |
|
326 | + * @return string |
|
327 | + */ |
|
328 | + public function call($function, $args = null) |
|
329 | + { |
|
330 | + $arg_str = ''; |
|
331 | + if (is_array($args)) { |
|
332 | + foreach ($args as $arg) { |
|
333 | + if (!empty($arg_str)) { |
|
334 | + $arg_str .= ', '; |
|
335 | + } |
|
336 | + if (is_string($arg)) { |
|
337 | + $arg_str .= "'$arg'"; |
|
338 | + } else { |
|
339 | + $arg_str .= $arg; |
|
340 | + } |
|
341 | + } |
|
342 | + } else { |
|
343 | + if (is_string($args)) { |
|
344 | + $arg_str .= "'$args'"; |
|
345 | + } else { |
|
346 | + $arg_str .= $args; |
|
347 | + } |
|
348 | + } |
|
349 | + |
|
350 | + return "$function($arg_str)"; |
|
351 | + } |
|
352 | + |
|
353 | + /** |
|
354 | + * @param int $seconds |
|
355 | + * @param string $script |
|
356 | + * @return string |
|
357 | + */ |
|
358 | + public function delay($seconds = 1, $script = '') |
|
359 | + { |
|
360 | + return "setTimeout( function() { $script } , " . ($seconds * 1000) . ' )'; |
|
361 | + } |
|
362 | + |
|
363 | + /** |
|
364 | + * @param $id |
|
365 | + * @return string |
|
366 | + */ |
|
367 | + public function hide($id) |
|
368 | + { |
|
369 | + return $this->call('Element.hide', $id); |
|
370 | + } |
|
371 | + |
|
372 | + /** |
|
373 | + * @param $position |
|
374 | + * @param $id |
|
375 | + * @param null $options_for_render |
|
376 | + * @return string |
|
377 | + */ |
|
378 | + public function insert_html($position, $id, $options_for_render = null) |
|
379 | + { |
|
380 | + $args = array_merge(array($id), (is_array($options_for_render) ? $options_for_render : array($options_for_render))); |
|
381 | + |
|
382 | + return $this->call('new Insertion.' . ucfirst($position), $args); |
|
383 | + } |
|
384 | + |
|
385 | + /** |
|
386 | + * @param $location |
|
387 | + * @return string |
|
388 | + */ |
|
389 | + public function redirect_to($location) |
|
390 | + { |
|
391 | + return $this->assign('window.location.href', $location); |
|
392 | + } |
|
393 | + |
|
394 | + /** |
|
395 | + * @param $id |
|
396 | + * @return string |
|
397 | + */ |
|
398 | + public function remove($id) |
|
399 | + { |
|
400 | + if (is_array($id)) { |
|
401 | + $arr_str = ''; |
|
402 | + foreach ($id as $obj) { |
|
403 | + if (!empty($arg_str)) { |
|
404 | + $arg_str .= ', '; |
|
405 | + } |
|
406 | + $arg_str .= "'$arg'"; |
|
407 | + } |
|
408 | + |
|
409 | + return "$A[$arg_str].each(Element.remove)"; |
|
410 | + } else { |
|
411 | + return "Element.remove('$id')"; |
|
412 | + } |
|
413 | + } |
|
414 | + |
|
415 | + /** |
|
416 | + * @param $id |
|
417 | + * @param $options_for_render |
|
418 | + * @return string |
|
419 | + */ |
|
420 | + public function replace($id, $options_for_render) |
|
421 | + { |
|
422 | + $args = array_merge(array($id), (is_array($options_for_render) ? $options_for_render : array($options_for_render))); |
|
423 | + |
|
424 | + return $this->call('Element.replace', $args); |
|
425 | + } |
|
426 | + |
|
427 | + /** |
|
428 | + * @param $id |
|
429 | + * @param $options_for_render |
|
430 | + * @return string |
|
431 | + */ |
|
432 | + public function replace_html($id, $options_for_render) |
|
433 | + { |
|
434 | + $args = array_merge(array($id), (is_array($options_for_render) ? $options_for_render : array($options_for_render))); |
|
435 | + |
|
436 | + return $this->call('Element.update', $args); |
|
437 | + } |
|
438 | + |
|
439 | + /** |
|
440 | + * @param $pattern |
|
441 | + * @param null $extend |
|
442 | + * @return string |
|
443 | + */ |
|
444 | + public function select($pattern, $extend = null) |
|
445 | + { |
|
446 | + return "$$('$pattern')" . (!empty($extend)) ? '.' . $extend : ''; |
|
447 | + } |
|
448 | + |
|
449 | + /** |
|
450 | + * @param $id |
|
451 | + * @return string |
|
452 | + */ |
|
453 | + public function show($id) |
|
454 | + { |
|
455 | + return $this->call('Element.show', $id); |
|
456 | + } |
|
457 | + |
|
458 | + /** |
|
459 | + * @param $id |
|
460 | + * @return string |
|
461 | + */ |
|
462 | + public function toggle($id) |
|
463 | + { |
|
464 | + return $this->call('Element.toggle', $id); |
|
465 | + } |
|
466 | 466 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
215 | - * @param $klass |
|
215 | + * @param string $klass |
|
216 | 216 | * @param $name |
217 | 217 | * @param null $options |
218 | 218 | * @return string |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | } |
312 | 312 | |
313 | 313 | /** |
314 | - * @param $variable |
|
314 | + * @param string $variable |
|
315 | 315 | * @param $value |
316 | 316 | * @return string |
317 | 317 | */ |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | } |
322 | 322 | |
323 | 323 | /** |
324 | - * @param $function |
|
324 | + * @param string $function |
|
325 | 325 | * @param null $args |
326 | 326 | * @return string |
327 | 327 | */ |
@@ -15,310 +15,310 @@ discard block |
||
15 | 15 | */ |
16 | 16 | class Scriptaculous extends Prototype |
17 | 17 | { |
18 | - public $TOGGLE_EFFECTS = array('toggle_appear', 'toggle_slide', 'toggle_blind'); |
|
19 | - |
|
20 | - /** |
|
21 | - * Scriptaculous constructor. |
|
22 | - */ |
|
23 | - public function __construct() |
|
24 | - { |
|
25 | - } |
|
26 | - |
|
27 | - /** |
|
28 | - * @param $element_id |
|
29 | - * @param null $options |
|
30 | - * @return string |
|
31 | - */ |
|
32 | - public function dragable_element($element_id, $options = null) |
|
33 | - { |
|
34 | - return $this->tag($this->_dragable_element_js($element_id, $options)); |
|
35 | - } |
|
36 | - |
|
37 | - /** |
|
38 | - * @param $element_id |
|
39 | - * @param null $options |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - public function drop_receiving_element($element_id, $options = null) |
|
43 | - { |
|
44 | - return $this->tag($this->_drop_receiving_element($element_id, $options)); |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * @param $name |
|
49 | - * @param bool $element_id |
|
50 | - * @param null $js_options |
|
51 | - * @return string |
|
52 | - */ |
|
53 | - public function visual_effect($name, $element_id = false, $js_options = null) |
|
54 | - { |
|
55 | - $element = $element_id ? "'$element_id'" : 'element'; |
|
56 | - |
|
57 | - $js_queue = ''; |
|
58 | - if (isset($js_options) && is_array($js_options['queue'])) { |
|
59 | - } elseif (isset($js_options)) { |
|
60 | - $js_queue = "'$js_options'"; |
|
61 | - } |
|
62 | - |
|
63 | - if (in_array($name, $this->TOGGLE_EFFECTS)) { |
|
64 | - return "Effect.toggle($element,'" . str_replace('toggle_', '', $name) . "'," . $this->_options_for_javascript($js_options) . ')'; |
|
65 | - } else { |
|
66 | - return 'new Effect.' . ucwords($name) . "($element," . $this->_options_for_javascript($js_options) . ')'; |
|
67 | - } |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * @param $element_id |
|
72 | - * @param null $options |
|
73 | - * @return string |
|
74 | - */ |
|
75 | - public function sortabe_element($element_id, $options = null) |
|
76 | - { |
|
77 | - return $this->tag($this->_sortabe_element($element_id, $options)); |
|
78 | - } |
|
79 | - |
|
80 | - ///////////////////////////////////////////////////////////////////////////////////// |
|
81 | - // Private functions |
|
82 | - ///////////////////////////////////////////////////////////////////////////////////// |
|
83 | - |
|
84 | - /** |
|
85 | - * @param $element_id |
|
86 | - * @param $options |
|
87 | - * @return string |
|
88 | - */ |
|
89 | - |
|
90 | - public function _sortabe_element($element_id, $options) |
|
91 | - { |
|
92 | - //if (isset($options['with'])) |
|
93 | - { |
|
94 | - $options['with'] = "Sortable.serialize('$element_id')"; |
|
95 | - } |
|
96 | - |
|
97 | - //if (isset($option['onUpdate'])) |
|
98 | - { |
|
99 | - $options['onUpdate'] = 'function(){' . $this->remote_function($options) . '}'; |
|
100 | - } |
|
101 | - |
|
102 | - foreach ($options as $var => $val) { |
|
103 | - if (in_array($var, $this->AJAX_OPTIONS)) { |
|
104 | - unset($options[$var]); |
|
105 | - } |
|
106 | - } |
|
107 | - |
|
108 | - $arr = array('tag', 'overlap', 'contraint', 'handle'); |
|
109 | - |
|
110 | - foreach ($arr as $var) { |
|
111 | - if (isset($options[$var])) { |
|
112 | - $options[$var] = "'" . $options[$var] . "'"; |
|
113 | - } |
|
114 | - } |
|
115 | - |
|
116 | - if (isset($options['containment'])) { |
|
117 | - $options['containment'] = $this->_array_or_string_for_javascript($options['containment']); |
|
118 | - } |
|
119 | - |
|
120 | - if (isset($options['only'])) { |
|
121 | - $options['only'] = $this->_array_or_string_for_javascript($options['only']); |
|
122 | - } |
|
123 | - |
|
124 | - return "Sortable.create('$element_id'," . $this->_options_for_javascript($options) . ')'; |
|
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * @param $element_id |
|
129 | - * @param $options |
|
130 | - * @return string |
|
131 | - */ |
|
132 | - public function _dragable_element_js($element_id, $options) |
|
133 | - { |
|
134 | - return 'new Draggable(\'' . $element_id . '\',' . $this->_options_for_javascript($options) . ')'; |
|
135 | - } |
|
136 | - |
|
137 | - /** |
|
138 | - * @param $element_id |
|
139 | - * @param $options |
|
140 | - * @return string |
|
141 | - */ |
|
142 | - public function _drop_receiving_element($element_id, $options) |
|
143 | - { |
|
144 | - |
|
145 | - //if (isset($options['with'])) |
|
146 | - { |
|
147 | - $options['with'] = '\'id=\' + encodeURIComponent(element.id)'; |
|
148 | - } |
|
149 | - |
|
150 | - //if (isset($option['onDrop'])) |
|
151 | - { |
|
152 | - $options['onDrop'] = 'function(element){' . $this->remote_function($options) . '}'; |
|
153 | - } |
|
154 | - |
|
155 | - if (is_array($options)) { |
|
156 | - foreach ($options as $var => $val) { |
|
157 | - if (in_array($var, $this->AJAX_OPTIONS)) { |
|
158 | - unset($options[$var]); |
|
159 | - } |
|
160 | - } |
|
161 | - } |
|
162 | - |
|
163 | - if (isset($options['accept'])) { |
|
164 | - $options['accept'] = $this->_array_or_string_for_javascript($options['accept']); |
|
165 | - } |
|
166 | - |
|
167 | - if (isset($options['hoverclass'])) { |
|
168 | - $options['hoverclass'] = "'" . $options['hoverclass'] . "'"; |
|
169 | - } |
|
170 | - |
|
171 | - return 'Droppables.add(\'' . $element_id . '\',' . $this->_options_for_javascript($options) . ')'; |
|
172 | - } |
|
173 | - |
|
174 | - ///////////////////////////////////////////////////////////////////////////////////// |
|
175 | - // Merged Javascript macro |
|
176 | - ///////////////////////////////////////////////////////////////////////////////////// |
|
177 | - |
|
178 | - /** |
|
179 | - * @param $field_id |
|
180 | - * @param $options |
|
181 | - * @param bool $tag |
|
182 | - * @return string |
|
183 | - */ |
|
184 | - public function in_place_editor($field_id, $options, $tag = true) |
|
185 | - { |
|
186 | - $function = 'new Ajax.InPlaceEditor('; |
|
187 | - $function .= "'$field_id', "; |
|
188 | - $function .= "'" . $options['url'] . "'"; |
|
189 | - |
|
190 | - $js_options = array(); |
|
191 | - if (isset($options['cancel_text'])) { |
|
192 | - $js_options['cancelText'] = $options['cancel_text']; |
|
193 | - } |
|
194 | - if (isset($options['save_text'])) { |
|
195 | - $js_options['okText'] = $options['save_text']; |
|
196 | - } |
|
197 | - if (isset($options['loading_text'])) { |
|
198 | - $js_options['loadingText'] = $options['loading_text']; |
|
199 | - } |
|
200 | - if (isset($options['rows'])) { |
|
201 | - $js_options['rows'] = $options['rows']; |
|
202 | - } |
|
203 | - if (isset($options['cols'])) { |
|
204 | - $js_options['cols'] = $options['cols']; |
|
205 | - } |
|
206 | - if (isset($options['size'])) { |
|
207 | - $js_options['size'] = $options['size']; |
|
208 | - } |
|
209 | - if (isset($options['external_control'])) { |
|
210 | - $js_options['externalControl'] = "'" . $options['external_control'] . "'"; |
|
211 | - } |
|
212 | - if (isset($options['load_text_url'])) { |
|
213 | - $js_options['loadTextURL'] = "'" . $options['load_text_url'] . "'"; |
|
214 | - } |
|
215 | - if (isset($options['options'])) { |
|
216 | - $js_options['ajaxOptions'] = $options['options']; |
|
217 | - } |
|
218 | - if (isset($options['script'])) { |
|
219 | - $js_options['evalScripts'] = $options['script']; |
|
220 | - } |
|
221 | - if (isset($options['with'])) { |
|
222 | - $js_options['callback'] = 'function(form) { return ' . $options['with'] . ' }'; |
|
223 | - } |
|
224 | - |
|
225 | - $function .= ', ' . $this->_options_for_javascript($js_options) . ' )'; |
|
226 | - if ($tag) { |
|
227 | - return $this->tag($function); |
|
228 | - } else { |
|
229 | - return $function; |
|
230 | - } |
|
231 | - } |
|
232 | - |
|
233 | - /** |
|
234 | - * @param $object |
|
235 | - * @param null $tag_options |
|
236 | - * @param null $in_place_editor_options |
|
237 | - * @return string |
|
238 | - */ |
|
239 | - public function in_place_editor_field($object, $tag_options = null, $in_place_editor_options = null) |
|
240 | - { |
|
241 | - $ret_val = ''; |
|
242 | - $ret_val .= '<span id="' . $object . '" class="in_place_editor_field">' . (isset($tag_options['value']) ? $tag_options['value'] : '') . '</span>'; |
|
243 | - $ret_val .= $this->in_place_editor($object, $in_place_editor_options); |
|
244 | - |
|
245 | - return $ret_val; |
|
246 | - } |
|
247 | - |
|
248 | - /** |
|
249 | - * @param $field_id |
|
250 | - * @param $options |
|
251 | - * @return mixed |
|
252 | - */ |
|
253 | - public function auto_complete_field($field_id, $options) |
|
254 | - { |
|
255 | - $function = "var $field_id" . '_auto_completer = new Ajax.Autocompleter('; |
|
256 | - $function .= "'$field_id', "; |
|
257 | - $function .= "'" . (isset($options['update']) ? $options['update'] : $field_id . '_auto_complete') . "', "; |
|
258 | - $function .= "'" . $options['url'] . "'"; |
|
259 | - |
|
260 | - $js_options = array(); |
|
261 | - if (isset($options['tokens'])) { |
|
262 | - $js_options['tokens'] = $this->javascript->_array_or_string_for_javascript($options['tokens']); |
|
263 | - } |
|
264 | - if (isset($options['with'])) { |
|
265 | - $js_options['callback'] = 'function(element, value) { return ' . $options['with'] . ' }'; |
|
266 | - } |
|
267 | - if (isset($options['indicator'])) { |
|
268 | - $js_options['indicator'] = "'" . $options['indicator'] . "'"; |
|
269 | - } |
|
270 | - if (isset($options['select'])) { |
|
271 | - $js_options['select'] = "'" . $options['select'] . "'"; |
|
272 | - } |
|
273 | - |
|
274 | - foreach (array('on_show' => 'onShow', 'on_hide' => 'onHide', 'min_chars' => 'min_chars') as $var => $val) { |
|
275 | - if (isset($options[$var])) { |
|
276 | - $js_options['$val'] = $options['var']; |
|
277 | - } |
|
278 | - } |
|
279 | - |
|
280 | - $function .= ', ' . $this->_options_for_javascript($js_options) . ' )'; |
|
281 | - |
|
282 | - return $this->tag($function); |
|
283 | - } |
|
284 | - |
|
285 | - /** |
|
286 | - * @param $entries |
|
287 | - * @param $field |
|
288 | - * @param null $phrase |
|
289 | - */ |
|
290 | - public function auto_complete_results($entries, $field, $phrase = null) |
|
291 | - { |
|
292 | - if (!is_array($entries)) { |
|
293 | - return; |
|
294 | - } |
|
295 | - $ret_val = '<ul>'; |
|
296 | - // Complete this function |
|
297 | - } |
|
298 | - |
|
299 | - /** |
|
300 | - * @param $object |
|
301 | - * @param null $tag_options |
|
302 | - * @param null $completion_options |
|
303 | - * @return string |
|
304 | - */ |
|
305 | - public function text_field_with_auto_complete($object, $tag_options = null, $completion_options = null) |
|
306 | - { |
|
307 | - $ret_val = isset($completion_options['skip_style']) ? '' : $this->_auto_complete_stylesheet(); |
|
308 | - $ret_val .= '<input autocomplete="off" id="' . $object . '" name="' . $object . '" size="' . (isset($tag_options['size']) ? $tag_options['size'] : 30) . '" type="text" value="' . (isset($tag_options['size']) ? $tag_options['value'] : '') . '" ' . (isset($tag_options['class']) ? 'class = "' . $tag_options['class'] . '" ' : '') . '/>'; |
|
309 | - |
|
310 | - $ret_val .= '<div id="' . $object . '_auto_complete" class="auto_complete"></div>'; |
|
311 | - $ret_val .= $this->auto_complete_field($object, $completion_options); |
|
312 | - |
|
313 | - return $ret_val; |
|
314 | - } |
|
315 | - |
|
316 | - /** |
|
317 | - * @return string |
|
318 | - */ |
|
319 | - public function _auto_complete_stylesheet() |
|
320 | - { |
|
321 | - return '<style> div.auto_complete { |
|
18 | + public $TOGGLE_EFFECTS = array('toggle_appear', 'toggle_slide', 'toggle_blind'); |
|
19 | + |
|
20 | + /** |
|
21 | + * Scriptaculous constructor. |
|
22 | + */ |
|
23 | + public function __construct() |
|
24 | + { |
|
25 | + } |
|
26 | + |
|
27 | + /** |
|
28 | + * @param $element_id |
|
29 | + * @param null $options |
|
30 | + * @return string |
|
31 | + */ |
|
32 | + public function dragable_element($element_id, $options = null) |
|
33 | + { |
|
34 | + return $this->tag($this->_dragable_element_js($element_id, $options)); |
|
35 | + } |
|
36 | + |
|
37 | + /** |
|
38 | + * @param $element_id |
|
39 | + * @param null $options |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + public function drop_receiving_element($element_id, $options = null) |
|
43 | + { |
|
44 | + return $this->tag($this->_drop_receiving_element($element_id, $options)); |
|
45 | + } |
|
46 | + |
|
47 | + /** |
|
48 | + * @param $name |
|
49 | + * @param bool $element_id |
|
50 | + * @param null $js_options |
|
51 | + * @return string |
|
52 | + */ |
|
53 | + public function visual_effect($name, $element_id = false, $js_options = null) |
|
54 | + { |
|
55 | + $element = $element_id ? "'$element_id'" : 'element'; |
|
56 | + |
|
57 | + $js_queue = ''; |
|
58 | + if (isset($js_options) && is_array($js_options['queue'])) { |
|
59 | + } elseif (isset($js_options)) { |
|
60 | + $js_queue = "'$js_options'"; |
|
61 | + } |
|
62 | + |
|
63 | + if (in_array($name, $this->TOGGLE_EFFECTS)) { |
|
64 | + return "Effect.toggle($element,'" . str_replace('toggle_', '', $name) . "'," . $this->_options_for_javascript($js_options) . ')'; |
|
65 | + } else { |
|
66 | + return 'new Effect.' . ucwords($name) . "($element," . $this->_options_for_javascript($js_options) . ')'; |
|
67 | + } |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * @param $element_id |
|
72 | + * @param null $options |
|
73 | + * @return string |
|
74 | + */ |
|
75 | + public function sortabe_element($element_id, $options = null) |
|
76 | + { |
|
77 | + return $this->tag($this->_sortabe_element($element_id, $options)); |
|
78 | + } |
|
79 | + |
|
80 | + ///////////////////////////////////////////////////////////////////////////////////// |
|
81 | + // Private functions |
|
82 | + ///////////////////////////////////////////////////////////////////////////////////// |
|
83 | + |
|
84 | + /** |
|
85 | + * @param $element_id |
|
86 | + * @param $options |
|
87 | + * @return string |
|
88 | + */ |
|
89 | + |
|
90 | + public function _sortabe_element($element_id, $options) |
|
91 | + { |
|
92 | + //if (isset($options['with'])) |
|
93 | + { |
|
94 | + $options['with'] = "Sortable.serialize('$element_id')"; |
|
95 | + } |
|
96 | + |
|
97 | + //if (isset($option['onUpdate'])) |
|
98 | + { |
|
99 | + $options['onUpdate'] = 'function(){' . $this->remote_function($options) . '}'; |
|
100 | + } |
|
101 | + |
|
102 | + foreach ($options as $var => $val) { |
|
103 | + if (in_array($var, $this->AJAX_OPTIONS)) { |
|
104 | + unset($options[$var]); |
|
105 | + } |
|
106 | + } |
|
107 | + |
|
108 | + $arr = array('tag', 'overlap', 'contraint', 'handle'); |
|
109 | + |
|
110 | + foreach ($arr as $var) { |
|
111 | + if (isset($options[$var])) { |
|
112 | + $options[$var] = "'" . $options[$var] . "'"; |
|
113 | + } |
|
114 | + } |
|
115 | + |
|
116 | + if (isset($options['containment'])) { |
|
117 | + $options['containment'] = $this->_array_or_string_for_javascript($options['containment']); |
|
118 | + } |
|
119 | + |
|
120 | + if (isset($options['only'])) { |
|
121 | + $options['only'] = $this->_array_or_string_for_javascript($options['only']); |
|
122 | + } |
|
123 | + |
|
124 | + return "Sortable.create('$element_id'," . $this->_options_for_javascript($options) . ')'; |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * @param $element_id |
|
129 | + * @param $options |
|
130 | + * @return string |
|
131 | + */ |
|
132 | + public function _dragable_element_js($element_id, $options) |
|
133 | + { |
|
134 | + return 'new Draggable(\'' . $element_id . '\',' . $this->_options_for_javascript($options) . ')'; |
|
135 | + } |
|
136 | + |
|
137 | + /** |
|
138 | + * @param $element_id |
|
139 | + * @param $options |
|
140 | + * @return string |
|
141 | + */ |
|
142 | + public function _drop_receiving_element($element_id, $options) |
|
143 | + { |
|
144 | + |
|
145 | + //if (isset($options['with'])) |
|
146 | + { |
|
147 | + $options['with'] = '\'id=\' + encodeURIComponent(element.id)'; |
|
148 | + } |
|
149 | + |
|
150 | + //if (isset($option['onDrop'])) |
|
151 | + { |
|
152 | + $options['onDrop'] = 'function(element){' . $this->remote_function($options) . '}'; |
|
153 | + } |
|
154 | + |
|
155 | + if (is_array($options)) { |
|
156 | + foreach ($options as $var => $val) { |
|
157 | + if (in_array($var, $this->AJAX_OPTIONS)) { |
|
158 | + unset($options[$var]); |
|
159 | + } |
|
160 | + } |
|
161 | + } |
|
162 | + |
|
163 | + if (isset($options['accept'])) { |
|
164 | + $options['accept'] = $this->_array_or_string_for_javascript($options['accept']); |
|
165 | + } |
|
166 | + |
|
167 | + if (isset($options['hoverclass'])) { |
|
168 | + $options['hoverclass'] = "'" . $options['hoverclass'] . "'"; |
|
169 | + } |
|
170 | + |
|
171 | + return 'Droppables.add(\'' . $element_id . '\',' . $this->_options_for_javascript($options) . ')'; |
|
172 | + } |
|
173 | + |
|
174 | + ///////////////////////////////////////////////////////////////////////////////////// |
|
175 | + // Merged Javascript macro |
|
176 | + ///////////////////////////////////////////////////////////////////////////////////// |
|
177 | + |
|
178 | + /** |
|
179 | + * @param $field_id |
|
180 | + * @param $options |
|
181 | + * @param bool $tag |
|
182 | + * @return string |
|
183 | + */ |
|
184 | + public function in_place_editor($field_id, $options, $tag = true) |
|
185 | + { |
|
186 | + $function = 'new Ajax.InPlaceEditor('; |
|
187 | + $function .= "'$field_id', "; |
|
188 | + $function .= "'" . $options['url'] . "'"; |
|
189 | + |
|
190 | + $js_options = array(); |
|
191 | + if (isset($options['cancel_text'])) { |
|
192 | + $js_options['cancelText'] = $options['cancel_text']; |
|
193 | + } |
|
194 | + if (isset($options['save_text'])) { |
|
195 | + $js_options['okText'] = $options['save_text']; |
|
196 | + } |
|
197 | + if (isset($options['loading_text'])) { |
|
198 | + $js_options['loadingText'] = $options['loading_text']; |
|
199 | + } |
|
200 | + if (isset($options['rows'])) { |
|
201 | + $js_options['rows'] = $options['rows']; |
|
202 | + } |
|
203 | + if (isset($options['cols'])) { |
|
204 | + $js_options['cols'] = $options['cols']; |
|
205 | + } |
|
206 | + if (isset($options['size'])) { |
|
207 | + $js_options['size'] = $options['size']; |
|
208 | + } |
|
209 | + if (isset($options['external_control'])) { |
|
210 | + $js_options['externalControl'] = "'" . $options['external_control'] . "'"; |
|
211 | + } |
|
212 | + if (isset($options['load_text_url'])) { |
|
213 | + $js_options['loadTextURL'] = "'" . $options['load_text_url'] . "'"; |
|
214 | + } |
|
215 | + if (isset($options['options'])) { |
|
216 | + $js_options['ajaxOptions'] = $options['options']; |
|
217 | + } |
|
218 | + if (isset($options['script'])) { |
|
219 | + $js_options['evalScripts'] = $options['script']; |
|
220 | + } |
|
221 | + if (isset($options['with'])) { |
|
222 | + $js_options['callback'] = 'function(form) { return ' . $options['with'] . ' }'; |
|
223 | + } |
|
224 | + |
|
225 | + $function .= ', ' . $this->_options_for_javascript($js_options) . ' )'; |
|
226 | + if ($tag) { |
|
227 | + return $this->tag($function); |
|
228 | + } else { |
|
229 | + return $function; |
|
230 | + } |
|
231 | + } |
|
232 | + |
|
233 | + /** |
|
234 | + * @param $object |
|
235 | + * @param null $tag_options |
|
236 | + * @param null $in_place_editor_options |
|
237 | + * @return string |
|
238 | + */ |
|
239 | + public function in_place_editor_field($object, $tag_options = null, $in_place_editor_options = null) |
|
240 | + { |
|
241 | + $ret_val = ''; |
|
242 | + $ret_val .= '<span id="' . $object . '" class="in_place_editor_field">' . (isset($tag_options['value']) ? $tag_options['value'] : '') . '</span>'; |
|
243 | + $ret_val .= $this->in_place_editor($object, $in_place_editor_options); |
|
244 | + |
|
245 | + return $ret_val; |
|
246 | + } |
|
247 | + |
|
248 | + /** |
|
249 | + * @param $field_id |
|
250 | + * @param $options |
|
251 | + * @return mixed |
|
252 | + */ |
|
253 | + public function auto_complete_field($field_id, $options) |
|
254 | + { |
|
255 | + $function = "var $field_id" . '_auto_completer = new Ajax.Autocompleter('; |
|
256 | + $function .= "'$field_id', "; |
|
257 | + $function .= "'" . (isset($options['update']) ? $options['update'] : $field_id . '_auto_complete') . "', "; |
|
258 | + $function .= "'" . $options['url'] . "'"; |
|
259 | + |
|
260 | + $js_options = array(); |
|
261 | + if (isset($options['tokens'])) { |
|
262 | + $js_options['tokens'] = $this->javascript->_array_or_string_for_javascript($options['tokens']); |
|
263 | + } |
|
264 | + if (isset($options['with'])) { |
|
265 | + $js_options['callback'] = 'function(element, value) { return ' . $options['with'] . ' }'; |
|
266 | + } |
|
267 | + if (isset($options['indicator'])) { |
|
268 | + $js_options['indicator'] = "'" . $options['indicator'] . "'"; |
|
269 | + } |
|
270 | + if (isset($options['select'])) { |
|
271 | + $js_options['select'] = "'" . $options['select'] . "'"; |
|
272 | + } |
|
273 | + |
|
274 | + foreach (array('on_show' => 'onShow', 'on_hide' => 'onHide', 'min_chars' => 'min_chars') as $var => $val) { |
|
275 | + if (isset($options[$var])) { |
|
276 | + $js_options['$val'] = $options['var']; |
|
277 | + } |
|
278 | + } |
|
279 | + |
|
280 | + $function .= ', ' . $this->_options_for_javascript($js_options) . ' )'; |
|
281 | + |
|
282 | + return $this->tag($function); |
|
283 | + } |
|
284 | + |
|
285 | + /** |
|
286 | + * @param $entries |
|
287 | + * @param $field |
|
288 | + * @param null $phrase |
|
289 | + */ |
|
290 | + public function auto_complete_results($entries, $field, $phrase = null) |
|
291 | + { |
|
292 | + if (!is_array($entries)) { |
|
293 | + return; |
|
294 | + } |
|
295 | + $ret_val = '<ul>'; |
|
296 | + // Complete this function |
|
297 | + } |
|
298 | + |
|
299 | + /** |
|
300 | + * @param $object |
|
301 | + * @param null $tag_options |
|
302 | + * @param null $completion_options |
|
303 | + * @return string |
|
304 | + */ |
|
305 | + public function text_field_with_auto_complete($object, $tag_options = null, $completion_options = null) |
|
306 | + { |
|
307 | + $ret_val = isset($completion_options['skip_style']) ? '' : $this->_auto_complete_stylesheet(); |
|
308 | + $ret_val .= '<input autocomplete="off" id="' . $object . '" name="' . $object . '" size="' . (isset($tag_options['size']) ? $tag_options['size'] : 30) . '" type="text" value="' . (isset($tag_options['size']) ? $tag_options['value'] : '') . '" ' . (isset($tag_options['class']) ? 'class = "' . $tag_options['class'] . '" ' : '') . '/>'; |
|
309 | + |
|
310 | + $ret_val .= '<div id="' . $object . '_auto_complete" class="auto_complete"></div>'; |
|
311 | + $ret_val .= $this->auto_complete_field($object, $completion_options); |
|
312 | + |
|
313 | + return $ret_val; |
|
314 | + } |
|
315 | + |
|
316 | + /** |
|
317 | + * @return string |
|
318 | + */ |
|
319 | + public function _auto_complete_stylesheet() |
|
320 | + { |
|
321 | + return '<style> div.auto_complete { |
|
322 | 322 | width: 350px; |
323 | 323 | background: #fff; |
324 | 324 | } |
@@ -342,5 +342,5 @@ discard block |
||
342 | 342 | padding:0; |
343 | 343 | } |
344 | 344 | </style>'; |
345 | - } |
|
345 | + } |
|
346 | 346 | } |
@@ -245,7 +245,7 @@ |
||
245 | 245 | /** |
246 | 246 | * @param $field_id |
247 | 247 | * @param $options |
248 | - * @return mixed |
|
248 | + * @return string |
|
249 | 249 | */ |
250 | 250 | public function auto_complete_field($field_id, $options) |
251 | 251 | { |
@@ -17,13 +17,13 @@ |
||
17 | 17 | $smartobjectCurrencyHandler = xoops_getModuleHandler('currency', 'smartobject'); |
18 | 18 | |
19 | 19 | if (!$smartobjectCurrenciesObj) { |
20 | - $smartobjectCurrenciesObj = $smartobjectCurrencyHandler->getCurrencies(); |
|
20 | + $smartobjectCurrenciesObj = $smartobjectCurrencyHandler->getCurrencies(); |
|
21 | 21 | } |
22 | 22 | if (!$smartobjectCurrenciesArray) { |
23 | - foreach ($smartobjectCurrenciesObj as $currencyid => $currencyObj) { |
|
24 | - if ($currencyObj->getVar('default_currency', 'e')) { |
|
25 | - $smartobjectDefaultCurrency = $currencyObj; |
|
26 | - } |
|
27 | - $smartobjectCurrenciesArray[$currencyid] = $currencyObj->getCode(); |
|
28 | - } |
|
23 | + foreach ($smartobjectCurrenciesObj as $currencyid => $currencyObj) { |
|
24 | + if ($currencyObj->getVar('default_currency', 'e')) { |
|
25 | + $smartobjectDefaultCurrency = $currencyObj; |
|
26 | + } |
|
27 | + $smartobjectCurrenciesArray[$currencyid] = $currencyObj->getCode(); |
|
28 | + } |
|
29 | 29 | } |
@@ -35,26 +35,26 @@ discard block |
||
35 | 35 | */ |
36 | 36 | function xoops_module_update_smartobject($module) |
37 | 37 | { |
38 | - ob_start(); |
|
38 | + ob_start(); |
|
39 | 39 | |
40 | - $dbVersion = smart_GetMeta('version', 'smartobject'); |
|
41 | - if (!$dbVersion) { |
|
42 | - $dbVersion = 0; |
|
43 | - } |
|
40 | + $dbVersion = smart_GetMeta('version', 'smartobject'); |
|
41 | + if (!$dbVersion) { |
|
42 | + $dbVersion = 0; |
|
43 | + } |
|
44 | 44 | |
45 | - $dbupdater = new SmartobjectDbupdater(); |
|
45 | + $dbupdater = new SmartobjectDbupdater(); |
|
46 | 46 | |
47 | - echo '<code>' . _SDU_UPDATE_UPDATING_DATABASE . '<br />'; |
|
47 | + echo '<code>' . _SDU_UPDATE_UPDATING_DATABASE . '<br />'; |
|
48 | 48 | |
49 | - // db migrate version = 1 |
|
50 | - $newDbVersion = 1; |
|
51 | - if ($dbVersion < $newDbVersion) { |
|
52 | - echo 'Database migrate to version ' . $newDbVersion . '<br />'; |
|
49 | + // db migrate version = 1 |
|
50 | + $newDbVersion = 1; |
|
51 | + if ($dbVersion < $newDbVersion) { |
|
52 | + echo 'Database migrate to version ' . $newDbVersion . '<br />'; |
|
53 | 53 | |
54 | - // Create table smartobject_link |
|
55 | - $table = new SmartDbTable('smartobject_link'); |
|
56 | - if (!$table->exists()) { |
|
57 | - $table->setStructure("CREATE TABLE %s ( |
|
54 | + // Create table smartobject_link |
|
55 | + $table = new SmartDbTable('smartobject_link'); |
|
56 | + if (!$table->exists()) { |
|
57 | + $table->setStructure("CREATE TABLE %s ( |
|
58 | 58 | `linkid` int(11) NOT NULL auto_increment, |
59 | 59 | `from_uid` int(11) NOT NULL default '0', |
60 | 60 | `from_email` varchar(255) NOT NULL default '', |
@@ -71,63 +71,63 @@ discard block |
||
71 | 71 | PRIMARY KEY (`linkid`) |
72 | 72 | ) ENGINE=MyISAM COMMENT='SmartObject by The SmartFactory <www.smartfactory.ca>' AUTO_INCREMENT=1 ;"); |
73 | 73 | |
74 | - if (!$dbupdater->updateTable($table)) { |
|
75 | - /** |
|
76 | - * @todo trap the errors |
|
77 | - */ |
|
78 | - } |
|
79 | - } |
|
80 | - unset($table); |
|
81 | - // Create table smartobject_link |
|
82 | - $table = new SmartDbTable('smartobject_link'); |
|
83 | - if (!$table->fieldExists('date')) { |
|
84 | - $table->addNewField('date', "int(11) NOT NULL default '0'"); |
|
85 | - if (!$dbupdater->updateTable($table)) { |
|
86 | - /** |
|
87 | - * @todo trap the errors |
|
88 | - */ |
|
89 | - } |
|
90 | - } |
|
91 | - unset($table); |
|
92 | - |
|
93 | - // Create table smartobject_tag |
|
94 | - $table = new SmartDbTable('smartobject_tag'); |
|
95 | - if (!$table->exists()) { |
|
96 | - $table->setStructure("CREATE TABLE %s ( |
|
74 | + if (!$dbupdater->updateTable($table)) { |
|
75 | + /** |
|
76 | + * @todo trap the errors |
|
77 | + */ |
|
78 | + } |
|
79 | + } |
|
80 | + unset($table); |
|
81 | + // Create table smartobject_link |
|
82 | + $table = new SmartDbTable('smartobject_link'); |
|
83 | + if (!$table->fieldExists('date')) { |
|
84 | + $table->addNewField('date', "int(11) NOT NULL default '0'"); |
|
85 | + if (!$dbupdater->updateTable($table)) { |
|
86 | + /** |
|
87 | + * @todo trap the errors |
|
88 | + */ |
|
89 | + } |
|
90 | + } |
|
91 | + unset($table); |
|
92 | + |
|
93 | + // Create table smartobject_tag |
|
94 | + $table = new SmartDbTable('smartobject_tag'); |
|
95 | + if (!$table->exists()) { |
|
96 | + $table->setStructure("CREATE TABLE %s ( |
|
97 | 97 | `tagid` int(11) NOT NULL auto_increment, |
98 | 98 | `name` varchar(255) NOT NULL default '', |
99 | 99 | `description` TEXT NOT NULL, |
100 | 100 | PRIMARY KEY (`id`) |
101 | 101 | ) ENGINE=MyISAM COMMENT='SmartObject by The SmartFactory <www.smartfactory.ca>' AUTO_INCREMENT=1 ;"); |
102 | 102 | |
103 | - if (!$dbupdater->updateTable($table)) { |
|
104 | - /** |
|
105 | - * @todo trap the errors |
|
106 | - */ |
|
107 | - } |
|
108 | - } |
|
109 | - |
|
110 | - // Create table smartobject_tag_text |
|
111 | - $table = new SmartDbTable('smartobject_tag_text'); |
|
112 | - if (!$table->exists()) { |
|
113 | - $table->setStructure("CREATE TABLE %s ( |
|
103 | + if (!$dbupdater->updateTable($table)) { |
|
104 | + /** |
|
105 | + * @todo trap the errors |
|
106 | + */ |
|
107 | + } |
|
108 | + } |
|
109 | + |
|
110 | + // Create table smartobject_tag_text |
|
111 | + $table = new SmartDbTable('smartobject_tag_text'); |
|
112 | + if (!$table->exists()) { |
|
113 | + $table->setStructure("CREATE TABLE %s ( |
|
114 | 114 | `tagid` int(11) NOT NULL default 0, |
115 | 115 | `language` varchar(255) NOT NULL default '', |
116 | 116 | `value` TEXT NOT NULL, |
117 | 117 | PRIMARY KEY (`id`, `language`) |
118 | 118 | ) ENGINE=MyISAM COMMENT='SmartObject by The SmartFactory <www.smartfactory.ca>' AUTO_INCREMENT=1 ;"); |
119 | 119 | |
120 | - if (!$dbupdater->updateTable($table)) { |
|
121 | - /** |
|
122 | - * @todo trap the errors |
|
123 | - */ |
|
124 | - } |
|
125 | - } |
|
126 | - |
|
127 | - // Create table smartobject_adsense |
|
128 | - $table = new SmartDbTable('smartobject_adsense'); |
|
129 | - if (!$table->exists()) { |
|
130 | - $table->setStructure(" |
|
120 | + if (!$dbupdater->updateTable($table)) { |
|
121 | + /** |
|
122 | + * @todo trap the errors |
|
123 | + */ |
|
124 | + } |
|
125 | + } |
|
126 | + |
|
127 | + // Create table smartobject_adsense |
|
128 | + $table = new SmartDbTable('smartobject_adsense'); |
|
129 | + if (!$table->exists()) { |
|
130 | + $table->setStructure(" |
|
131 | 131 | `adsenseid` int(11) NOT NULL auto_increment, |
132 | 132 | `format` VARCHAR(100) NOT NULL, |
133 | 133 | `description` TEXT NOT NULL, |
@@ -141,23 +141,23 @@ discard block |
||
141 | 141 | `tag` varchar(50) NOT NULL default '', |
142 | 142 | PRIMARY KEY (`adsenseid`) |
143 | 143 | "); |
144 | - } |
|
145 | - |
|
146 | - if (!$dbupdater->updateTable($table)) { |
|
147 | - /** |
|
148 | - * @todo trap the errors |
|
149 | - */ |
|
150 | - } |
|
151 | - } |
|
152 | - // db migrate version = 2 |
|
153 | - $newDbVersion = 2; |
|
154 | - if ($dbVersion < $newDbVersion) { |
|
155 | - echo 'Database migrate to version ' . $newDbVersion . '<br />'; |
|
156 | - |
|
157 | - // Create table smartobject_rating |
|
158 | - $table = new SmartDbTable('smartobject_rating'); |
|
159 | - if (!$table->exists()) { |
|
160 | - $table->setStructure(' |
|
144 | + } |
|
145 | + |
|
146 | + if (!$dbupdater->updateTable($table)) { |
|
147 | + /** |
|
148 | + * @todo trap the errors |
|
149 | + */ |
|
150 | + } |
|
151 | + } |
|
152 | + // db migrate version = 2 |
|
153 | + $newDbVersion = 2; |
|
154 | + if ($dbVersion < $newDbVersion) { |
|
155 | + echo 'Database migrate to version ' . $newDbVersion . '<br />'; |
|
156 | + |
|
157 | + // Create table smartobject_rating |
|
158 | + $table = new SmartDbTable('smartobject_rating'); |
|
159 | + if (!$table->exists()) { |
|
160 | + $table->setStructure(' |
|
161 | 161 | `ratingid` int(11) NOT NULL auto_increment, |
162 | 162 | `dirname` VARCHAR(255) NOT NULL, |
163 | 163 | `item` VARCHAR(255) NOT NULL, |
@@ -168,36 +168,36 @@ discard block |
||
168 | 168 | PRIMARY KEY (`ratingid`), |
169 | 169 | UNIQUE (`dirname`, `item`, `itemid`, `uid`) |
170 | 170 | '); |
171 | - } |
|
172 | - |
|
173 | - if (!$dbupdater->updateTable($table)) { |
|
174 | - /** |
|
175 | - * @todo trap the errors |
|
176 | - */ |
|
177 | - } |
|
178 | - |
|
179 | - // Create table smartobject_currency |
|
180 | - $table = new SmartDbTable('smartobject_currency'); |
|
181 | - $table->setData("2, 'EUR', 'Euro', '�', 0.65, 0"); |
|
182 | - $table->setData("3, 'USD', 'American dollar', '$', 0.9, 0"); |
|
183 | - $table->setData("1, 'CAD', 'Canadian dollar', '$', 1, 1"); |
|
184 | - |
|
185 | - if (!$dbupdater->updateTable($table)) { |
|
186 | - /** |
|
187 | - * @todo trap the errors |
|
188 | - */ |
|
189 | - } |
|
190 | - } |
|
191 | - |
|
192 | - // db migrate version = 3 |
|
193 | - $newDbVersion = 3; |
|
194 | - if ($dbVersion < $newDbVersion) { |
|
195 | - echo 'Database migrate to version ' . $newDbVersion . '<br />'; |
|
196 | - |
|
197 | - // Create table smartobject_customtag |
|
198 | - $table = new SmartDbTable('smartobject_customtag'); |
|
199 | - if (!$table->exists()) { |
|
200 | - $table->setStructure(' |
|
171 | + } |
|
172 | + |
|
173 | + if (!$dbupdater->updateTable($table)) { |
|
174 | + /** |
|
175 | + * @todo trap the errors |
|
176 | + */ |
|
177 | + } |
|
178 | + |
|
179 | + // Create table smartobject_currency |
|
180 | + $table = new SmartDbTable('smartobject_currency'); |
|
181 | + $table->setData("2, 'EUR', 'Euro', '�', 0.65, 0"); |
|
182 | + $table->setData("3, 'USD', 'American dollar', '$', 0.9, 0"); |
|
183 | + $table->setData("1, 'CAD', 'Canadian dollar', '$', 1, 1"); |
|
184 | + |
|
185 | + if (!$dbupdater->updateTable($table)) { |
|
186 | + /** |
|
187 | + * @todo trap the errors |
|
188 | + */ |
|
189 | + } |
|
190 | + } |
|
191 | + |
|
192 | + // db migrate version = 3 |
|
193 | + $newDbVersion = 3; |
|
194 | + if ($dbVersion < $newDbVersion) { |
|
195 | + echo 'Database migrate to version ' . $newDbVersion . '<br />'; |
|
196 | + |
|
197 | + // Create table smartobject_customtag |
|
198 | + $table = new SmartDbTable('smartobject_customtag'); |
|
199 | + if (!$table->exists()) { |
|
200 | + $table->setStructure(' |
|
201 | 201 | `customtagid` int(11) NOT NULL auto_increment, |
202 | 202 | `name` VARCHAR(255) NOT NULL, |
203 | 203 | `description` TEXT NOT NULL, |
@@ -205,24 +205,24 @@ discard block |
||
205 | 205 | `language` TEXT NOT NULL, |
206 | 206 | PRIMARY KEY (`customtagid`) |
207 | 207 | '); |
208 | - } |
|
209 | - |
|
210 | - if (!$dbupdater->updateTable($table)) { |
|
211 | - /** |
|
212 | - * @todo trap the errors |
|
213 | - */ |
|
214 | - } |
|
215 | - } |
|
216 | - |
|
217 | - // db migrate version = 4 |
|
218 | - $newDbVersion = 4; |
|
219 | - if ($dbVersion < $newDbVersion) { |
|
220 | - echo 'Database migrate to version ' . $newDbVersion . '<br />'; |
|
221 | - |
|
222 | - // Create table smartobject_currency |
|
223 | - $table = new SmartDbTable('smartobject_currency'); |
|
224 | - if (!$table->exists()) { |
|
225 | - $table->setStructure(' |
|
208 | + } |
|
209 | + |
|
210 | + if (!$dbupdater->updateTable($table)) { |
|
211 | + /** |
|
212 | + * @todo trap the errors |
|
213 | + */ |
|
214 | + } |
|
215 | + } |
|
216 | + |
|
217 | + // db migrate version = 4 |
|
218 | + $newDbVersion = 4; |
|
219 | + if ($dbVersion < $newDbVersion) { |
|
220 | + echo 'Database migrate to version ' . $newDbVersion . '<br />'; |
|
221 | + |
|
222 | + // Create table smartobject_currency |
|
223 | + $table = new SmartDbTable('smartobject_currency'); |
|
224 | + if (!$table->exists()) { |
|
225 | + $table->setStructure(' |
|
226 | 226 | `currencyid` int(11) NOT NULL auto_increment, |
227 | 227 | `iso4217` VARCHAR(5) NOT NULL, |
228 | 228 | `name` VARCHAR(255) NOT NULL, |
@@ -231,46 +231,46 @@ discard block |
||
231 | 231 | `default_currency` int(1) NOT NULL, |
232 | 232 | PRIMARY KEY (`currencyid`) |
233 | 233 | '); |
234 | - } |
|
235 | - |
|
236 | - if (!$dbupdater->updateTable($table)) { |
|
237 | - /** |
|
238 | - * @todo trap the errors |
|
239 | - */ |
|
240 | - } |
|
241 | - } |
|
242 | - |
|
243 | - // db migrate version = 6 |
|
244 | - $newDbVersion = 6; |
|
245 | - if ($dbVersion < $newDbVersion) { |
|
246 | - echo 'Database migrate to version ' . $newDbVersion . '<br />'; |
|
247 | - } |
|
248 | - |
|
249 | - $newDbVersion = 7; |
|
250 | - if ($dbVersion < $newDbVersion) { |
|
251 | - echo 'Database migrate to version ' . $newDbVersion . '<br />'; |
|
252 | - |
|
253 | - // Create table smartobject_file |
|
254 | - $table = new SmartDbTable('smartobject_file'); |
|
255 | - if (!$table->exists()) { |
|
256 | - $table->setStructure(' |
|
234 | + } |
|
235 | + |
|
236 | + if (!$dbupdater->updateTable($table)) { |
|
237 | + /** |
|
238 | + * @todo trap the errors |
|
239 | + */ |
|
240 | + } |
|
241 | + } |
|
242 | + |
|
243 | + // db migrate version = 6 |
|
244 | + $newDbVersion = 6; |
|
245 | + if ($dbVersion < $newDbVersion) { |
|
246 | + echo 'Database migrate to version ' . $newDbVersion . '<br />'; |
|
247 | + } |
|
248 | + |
|
249 | + $newDbVersion = 7; |
|
250 | + if ($dbVersion < $newDbVersion) { |
|
251 | + echo 'Database migrate to version ' . $newDbVersion . '<br />'; |
|
252 | + |
|
253 | + // Create table smartobject_file |
|
254 | + $table = new SmartDbTable('smartobject_file'); |
|
255 | + if (!$table->exists()) { |
|
256 | + $table->setStructure(' |
|
257 | 257 | `fileid` int(11) NOT NULL auto_increment, |
258 | 258 | `caption` varchar(255) collate latin1_general_ci NOT NULL, |
259 | 259 | `url` varchar(255) collate latin1_general_ci NOT NULL, |
260 | 260 | `description` text collate latin1_general_ci NOT NULL, |
261 | 261 | PRIMARY KEY (`fileid`) |
262 | 262 | '); |
263 | - if (!$dbupdater->updateTable($table)) { |
|
264 | - /** |
|
265 | - * @todo trap the errors |
|
266 | - */ |
|
267 | - } |
|
268 | - } |
|
269 | - unset($table); |
|
270 | - // Create table smartobject_urllink |
|
271 | - $table = new SmartDbTable('smartobject_urllink'); |
|
272 | - if (!$table->exists()) { |
|
273 | - $table->setStructure(' |
|
263 | + if (!$dbupdater->updateTable($table)) { |
|
264 | + /** |
|
265 | + * @todo trap the errors |
|
266 | + */ |
|
267 | + } |
|
268 | + } |
|
269 | + unset($table); |
|
270 | + // Create table smartobject_urllink |
|
271 | + $table = new SmartDbTable('smartobject_urllink'); |
|
272 | + if (!$table->exists()) { |
|
273 | + $table->setStructure(' |
|
274 | 274 | `urllinkid` int(11) NOT NULL auto_increment, |
275 | 275 | `caption` varchar(255) collate latin1_general_ci NOT NULL, |
276 | 276 | `url` varchar(255) collate latin1_general_ci NOT NULL, |
@@ -278,25 +278,25 @@ discard block |
||
278 | 278 | `target` varchar(10) collate latin1_general_ci NOT NULL, |
279 | 279 | PRIMARY KEY (`urllinkid`) |
280 | 280 | '); |
281 | - if (!$dbupdater->updateTable($table)) { |
|
282 | - /** |
|
283 | - * @todo trap the errors |
|
284 | - */ |
|
285 | - } |
|
286 | - } |
|
287 | - unset($table); |
|
288 | - } |
|
289 | - echo '</code>'; |
|
290 | - |
|
291 | - $feedback = ob_get_clean(); |
|
292 | - if (method_exists($module, 'setMessage')) { |
|
293 | - $module->setMessage($feedback); |
|
294 | - } else { |
|
295 | - echo $feedback; |
|
296 | - } |
|
297 | - smart_SetMeta('version', $newDbVersion, 'smartobject'); //Set meta version to current |
|
298 | - |
|
299 | - return true; |
|
281 | + if (!$dbupdater->updateTable($table)) { |
|
282 | + /** |
|
283 | + * @todo trap the errors |
|
284 | + */ |
|
285 | + } |
|
286 | + } |
|
287 | + unset($table); |
|
288 | + } |
|
289 | + echo '</code>'; |
|
290 | + |
|
291 | + $feedback = ob_get_clean(); |
|
292 | + if (method_exists($module, 'setMessage')) { |
|
293 | + $module->setMessage($feedback); |
|
294 | + } else { |
|
295 | + echo $feedback; |
|
296 | + } |
|
297 | + smart_SetMeta('version', $newDbVersion, 'smartobject'); //Set meta version to current |
|
298 | + |
|
299 | + return true; |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
@@ -305,10 +305,10 @@ discard block |
||
305 | 305 | */ |
306 | 306 | function xoops_module_install_smartobject($module) |
307 | 307 | { |
308 | - ob_start(); |
|
308 | + ob_start(); |
|
309 | 309 | |
310 | - echo 'Using the ImpressCMS onInstall event'; |
|
311 | - $feedback = ob_get_clean(); |
|
310 | + echo 'Using the ImpressCMS onInstall event'; |
|
311 | + $feedback = ob_get_clean(); |
|
312 | 312 | |
313 | - return $feedback; |
|
313 | + return $feedback; |
|
314 | 314 | } |