@@ -19,164 +19,164 @@ |
||
19 | 19 | */ |
20 | 20 | class SmartobjectAbout |
21 | 21 | { |
22 | - public $_lang_aboutTitle; |
|
23 | - public $_lang_author_info; |
|
24 | - public $_lang_developer_lead; |
|
25 | - public $_lang_developer_contributor; |
|
26 | - public $_lang_developer_website; |
|
27 | - public $_lang_developer_email; |
|
28 | - public $_lang_developer_credits; |
|
29 | - public $_lang_module_info; |
|
30 | - public $_lang_module_status; |
|
31 | - public $_lang_module_release_date; |
|
32 | - public $_lang_module_demo; |
|
33 | - public $_lang_module_support; |
|
34 | - public $_lang_module_bug; |
|
35 | - public $_lang_module_submit_bug; |
|
36 | - public $_lang_module_feature; |
|
37 | - public $_lang_module_submit_feature; |
|
38 | - public $_lang_module_disclaimer; |
|
39 | - public $_lang_author_word; |
|
40 | - public $_lang_version_history; |
|
41 | - public $_lang_by; |
|
42 | - public $_tpl; |
|
43 | - |
|
44 | - /** |
|
45 | - * SmartobjectAbout constructor. |
|
46 | - * @param string $aboutTitle |
|
47 | - */ |
|
48 | - public function __construct($aboutTitle = 'About') |
|
49 | - { |
|
50 | - global $xoopsModule, $xoopsConfig; |
|
51 | - |
|
52 | - $fileName = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php'; |
|
53 | - if (file_exists($fileName)) { |
|
54 | - include_once $fileName; |
|
55 | - } else { |
|
56 | - include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/modinfo.php'; |
|
57 | - } |
|
58 | - $this->_aboutTitle = $aboutTitle; |
|
59 | - |
|
60 | - $this->_lang_developer_contributor = _CO_SOBJECT_DEVELOPER_CONTRIBUTOR; |
|
61 | - $this->_lang_developer_website = _CO_SOBJECT_DEVELOPER_WEBSITE; |
|
62 | - $this->_lang_developer_email = _CO_SOBJECT_DEVELOPER_EMAIL; |
|
63 | - $this->_lang_developer_credits = _CO_SOBJECT_DEVELOPER_CREDITS; |
|
64 | - $this->_lang_module_info = _CO_SOBJECT_MODULE_INFO; |
|
65 | - $this->_lang_module_status = _CO_SOBJECT_MODULE_STATUS; |
|
66 | - $this->_lang_module_release_date = _CO_SOBJECT_MODULE_RELEASE_DATE; |
|
67 | - $this->_lang_module_demo = _CO_SOBJECT_MODULE_DEMO; |
|
68 | - $this->_lang_module_support = _CO_SOBJECT_MODULE_SUPPORT; |
|
69 | - $this->_lang_module_bug = _CO_SOBJECT_MODULE_BUG; |
|
70 | - $this->_lang_module_submit_bug = _CO_SOBJECT_MODULE_SUBMIT_BUG; |
|
71 | - $this->_lang_module_feature = _CO_SOBJECT_MODULE_FEATURE; |
|
72 | - $this->_lang_module_submit_feature = _CO_SOBJECT_MODULE_SUBMIT_FEATURE; |
|
73 | - $this->_lang_module_disclaimer = _CO_SOBJECT_MODULE_DISCLAIMER; |
|
74 | - $this->_lang_author_word = _CO_SOBJECT_AUTHOR_WORD; |
|
75 | - $this->_lang_version_history = _CO_SOBJECT_VERSION_HISTORY; |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * @param $value |
|
80 | - * @return mixed |
|
81 | - */ |
|
82 | - public function sanitize($value) |
|
83 | - { |
|
84 | - $myts = MyTextSanitizer::getInstance(); |
|
85 | - |
|
86 | - return $myts->displayTarea($value, 1); |
|
87 | - } |
|
88 | - |
|
89 | - public function render() |
|
90 | - { |
|
91 | - /** |
|
92 | - * @todo move the output to a template |
|
93 | - * @todo make the output XHTML compliant |
|
94 | - */ |
|
95 | - |
|
96 | - $myts = MyTextSanitizer::getInstance(); |
|
97 | - |
|
98 | - global $xoopsModule; |
|
99 | - |
|
100 | - smart_xoops_cp_header(); |
|
101 | - |
|
102 | - $moduleHandler = xoops_getHandler('module'); |
|
103 | - $versioninfo = $moduleHandler->get($xoopsModule->getVar('mid')); |
|
104 | - |
|
105 | - //smart_adminMenu(-1, $this->_aboutTitle . " " . $versioninfo->getInfo('name')); |
|
106 | - |
|
107 | - include_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
108 | - |
|
109 | - // --- |
|
110 | - // 2012-01-01 PHP 5.3: Assigning the return value of new by reference is now deprecated. |
|
111 | - // $this->_tpl =& new XoopsTpl(); |
|
112 | - $this->_tpl = new XoopsTpl(); |
|
113 | - // --- |
|
114 | - |
|
115 | - $this->_tpl->assign('module_url', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/'); |
|
116 | - $this->_tpl->assign('module_image', $versioninfo->getInfo('image')); |
|
117 | - $this->_tpl->assign('module_name', $versioninfo->getInfo('name')); |
|
118 | - $this->_tpl->assign('module_version', $versioninfo->getInfo('version')); |
|
119 | - $this->_tpl->assign('module_status_version', $versioninfo->getInfo('status_version')); |
|
120 | - |
|
121 | - // Left headings... |
|
122 | - if ($versioninfo->getInfo('author_realname') !== '') { |
|
123 | - $author_name = $versioninfo->getInfo('author') . ' (' . $versioninfo->getInfo('author_realname') . ')'; |
|
124 | - } else { |
|
125 | - $author_name = $versioninfo->getInfo('author'); |
|
126 | - } |
|
127 | - $this->_tpl->assign('module_author_name', $author_name); |
|
128 | - |
|
129 | - $this->_tpl->assign('module_license', $versioninfo->getInfo('license')); |
|
130 | - |
|
131 | - $this->_tpl->assign('module_credits', $versioninfo->getInfo('credits')); |
|
132 | - |
|
133 | - // Developers Information |
|
134 | - $this->_tpl->assign('module_developer_lead', $versioninfo->getInfo('developer_lead')); |
|
135 | - $this->_tpl->assign('module_developer_contributor', $versioninfo->getInfo('developer_contributor')); |
|
136 | - $this->_tpl->assign('module_developer_website_url', $versioninfo->getInfo('developer_website_url')); |
|
137 | - $this->_tpl->assign('module_developer_website_name', $versioninfo->getInfo('developer_website_name')); |
|
138 | - $this->_tpl->assign('module_developer_email', $versioninfo->getInfo('developer_email')); |
|
139 | - |
|
140 | - $people = $versioninfo->getInfo('people'); |
|
141 | - if ($people) { |
|
142 | - $this->_tpl->assign('module_people_developers', isset($people['developers']) ? array_map(array($this, 'sanitize'), $people['developers']) : false); |
|
143 | - $this->_tpl->assign('module_people_testers', isset($people['testers']) ? array_map(array($this, 'sanitize'), $people['testers']) : false); |
|
144 | - $this->_tpl->assign('module_people_translators', isset($people['translators']) ? array_map(array($this, 'sanitize'), $people['translators']) : false); |
|
145 | - $this->_tpl->assign('module_people_documenters', isset($people['documenters']) ? array_map(array($this, 'sanitize'), $people['documenters']) : false); |
|
146 | - $this->_tpl->assign('module_people_other', isset($people['other']) ? array_map(array($this, 'sanitize'), $people['other']) : false); |
|
147 | - } |
|
148 | - //$this->_tpl->assign('module_developers', $versioninfo->getInfo('developer_email')); |
|
149 | - |
|
150 | - // Module Development information |
|
151 | - $this->_tpl->assign('module_date', $versioninfo->getInfo('date')); |
|
152 | - $this->_tpl->assign('module_status', $versioninfo->getInfo('status')); |
|
153 | - $this->_tpl->assign('module_demo_site_url', $versioninfo->getInfo('demo_site_url')); |
|
154 | - $this->_tpl->assign('module_demo_site_name', $versioninfo->getInfo('demo_site_name')); |
|
155 | - $this->_tpl->assign('module_support_site_url', $versioninfo->getInfo('support_site_url')); |
|
156 | - $this->_tpl->assign('module_support_site_name', $versioninfo->getInfo('support_site_name')); |
|
157 | - $this->_tpl->assign('module_submit_bug', $versioninfo->getInfo('submit_bug')); |
|
158 | - $this->_tpl->assign('module_submit_feature', $versioninfo->getInfo('submit_feature')); |
|
159 | - |
|
160 | - // Warning |
|
161 | - $this->_tpl->assign('module_warning', $this->sanitize($versioninfo->getInfo('warning'))); |
|
162 | - |
|
163 | - // Author's note |
|
164 | - $this->_tpl->assign('module_author_word', $versioninfo->getInfo('author_word')); |
|
165 | - |
|
166 | - // For changelog thanks to 3Dev |
|
167 | - global $xoopsModule; |
|
168 | - $filename = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/changelog.txt'; |
|
169 | - if (is_file($filename)) { |
|
170 | - $filesize = filesize($filename); |
|
171 | - $handle = fopen($filename, 'r'); |
|
172 | - $this->_tpl->assign('module_version_history', $myts->displayTarea(fread($handle, $filesize), true)); |
|
173 | - fclose($handle); |
|
174 | - } |
|
175 | - |
|
176 | - $this->_tpl->display('db:smartobject_about.tpl'); |
|
177 | - |
|
178 | - smart_modFooter(); |
|
179 | - |
|
180 | - xoops_cp_footer(); |
|
181 | - } |
|
22 | + public $_lang_aboutTitle; |
|
23 | + public $_lang_author_info; |
|
24 | + public $_lang_developer_lead; |
|
25 | + public $_lang_developer_contributor; |
|
26 | + public $_lang_developer_website; |
|
27 | + public $_lang_developer_email; |
|
28 | + public $_lang_developer_credits; |
|
29 | + public $_lang_module_info; |
|
30 | + public $_lang_module_status; |
|
31 | + public $_lang_module_release_date; |
|
32 | + public $_lang_module_demo; |
|
33 | + public $_lang_module_support; |
|
34 | + public $_lang_module_bug; |
|
35 | + public $_lang_module_submit_bug; |
|
36 | + public $_lang_module_feature; |
|
37 | + public $_lang_module_submit_feature; |
|
38 | + public $_lang_module_disclaimer; |
|
39 | + public $_lang_author_word; |
|
40 | + public $_lang_version_history; |
|
41 | + public $_lang_by; |
|
42 | + public $_tpl; |
|
43 | + |
|
44 | + /** |
|
45 | + * SmartobjectAbout constructor. |
|
46 | + * @param string $aboutTitle |
|
47 | + */ |
|
48 | + public function __construct($aboutTitle = 'About') |
|
49 | + { |
|
50 | + global $xoopsModule, $xoopsConfig; |
|
51 | + |
|
52 | + $fileName = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php'; |
|
53 | + if (file_exists($fileName)) { |
|
54 | + include_once $fileName; |
|
55 | + } else { |
|
56 | + include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/modinfo.php'; |
|
57 | + } |
|
58 | + $this->_aboutTitle = $aboutTitle; |
|
59 | + |
|
60 | + $this->_lang_developer_contributor = _CO_SOBJECT_DEVELOPER_CONTRIBUTOR; |
|
61 | + $this->_lang_developer_website = _CO_SOBJECT_DEVELOPER_WEBSITE; |
|
62 | + $this->_lang_developer_email = _CO_SOBJECT_DEVELOPER_EMAIL; |
|
63 | + $this->_lang_developer_credits = _CO_SOBJECT_DEVELOPER_CREDITS; |
|
64 | + $this->_lang_module_info = _CO_SOBJECT_MODULE_INFO; |
|
65 | + $this->_lang_module_status = _CO_SOBJECT_MODULE_STATUS; |
|
66 | + $this->_lang_module_release_date = _CO_SOBJECT_MODULE_RELEASE_DATE; |
|
67 | + $this->_lang_module_demo = _CO_SOBJECT_MODULE_DEMO; |
|
68 | + $this->_lang_module_support = _CO_SOBJECT_MODULE_SUPPORT; |
|
69 | + $this->_lang_module_bug = _CO_SOBJECT_MODULE_BUG; |
|
70 | + $this->_lang_module_submit_bug = _CO_SOBJECT_MODULE_SUBMIT_BUG; |
|
71 | + $this->_lang_module_feature = _CO_SOBJECT_MODULE_FEATURE; |
|
72 | + $this->_lang_module_submit_feature = _CO_SOBJECT_MODULE_SUBMIT_FEATURE; |
|
73 | + $this->_lang_module_disclaimer = _CO_SOBJECT_MODULE_DISCLAIMER; |
|
74 | + $this->_lang_author_word = _CO_SOBJECT_AUTHOR_WORD; |
|
75 | + $this->_lang_version_history = _CO_SOBJECT_VERSION_HISTORY; |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * @param $value |
|
80 | + * @return mixed |
|
81 | + */ |
|
82 | + public function sanitize($value) |
|
83 | + { |
|
84 | + $myts = MyTextSanitizer::getInstance(); |
|
85 | + |
|
86 | + return $myts->displayTarea($value, 1); |
|
87 | + } |
|
88 | + |
|
89 | + public function render() |
|
90 | + { |
|
91 | + /** |
|
92 | + * @todo move the output to a template |
|
93 | + * @todo make the output XHTML compliant |
|
94 | + */ |
|
95 | + |
|
96 | + $myts = MyTextSanitizer::getInstance(); |
|
97 | + |
|
98 | + global $xoopsModule; |
|
99 | + |
|
100 | + smart_xoops_cp_header(); |
|
101 | + |
|
102 | + $moduleHandler = xoops_getHandler('module'); |
|
103 | + $versioninfo = $moduleHandler->get($xoopsModule->getVar('mid')); |
|
104 | + |
|
105 | + //smart_adminMenu(-1, $this->_aboutTitle . " " . $versioninfo->getInfo('name')); |
|
106 | + |
|
107 | + include_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
108 | + |
|
109 | + // --- |
|
110 | + // 2012-01-01 PHP 5.3: Assigning the return value of new by reference is now deprecated. |
|
111 | + // $this->_tpl =& new XoopsTpl(); |
|
112 | + $this->_tpl = new XoopsTpl(); |
|
113 | + // --- |
|
114 | + |
|
115 | + $this->_tpl->assign('module_url', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/'); |
|
116 | + $this->_tpl->assign('module_image', $versioninfo->getInfo('image')); |
|
117 | + $this->_tpl->assign('module_name', $versioninfo->getInfo('name')); |
|
118 | + $this->_tpl->assign('module_version', $versioninfo->getInfo('version')); |
|
119 | + $this->_tpl->assign('module_status_version', $versioninfo->getInfo('status_version')); |
|
120 | + |
|
121 | + // Left headings... |
|
122 | + if ($versioninfo->getInfo('author_realname') !== '') { |
|
123 | + $author_name = $versioninfo->getInfo('author') . ' (' . $versioninfo->getInfo('author_realname') . ')'; |
|
124 | + } else { |
|
125 | + $author_name = $versioninfo->getInfo('author'); |
|
126 | + } |
|
127 | + $this->_tpl->assign('module_author_name', $author_name); |
|
128 | + |
|
129 | + $this->_tpl->assign('module_license', $versioninfo->getInfo('license')); |
|
130 | + |
|
131 | + $this->_tpl->assign('module_credits', $versioninfo->getInfo('credits')); |
|
132 | + |
|
133 | + // Developers Information |
|
134 | + $this->_tpl->assign('module_developer_lead', $versioninfo->getInfo('developer_lead')); |
|
135 | + $this->_tpl->assign('module_developer_contributor', $versioninfo->getInfo('developer_contributor')); |
|
136 | + $this->_tpl->assign('module_developer_website_url', $versioninfo->getInfo('developer_website_url')); |
|
137 | + $this->_tpl->assign('module_developer_website_name', $versioninfo->getInfo('developer_website_name')); |
|
138 | + $this->_tpl->assign('module_developer_email', $versioninfo->getInfo('developer_email')); |
|
139 | + |
|
140 | + $people = $versioninfo->getInfo('people'); |
|
141 | + if ($people) { |
|
142 | + $this->_tpl->assign('module_people_developers', isset($people['developers']) ? array_map(array($this, 'sanitize'), $people['developers']) : false); |
|
143 | + $this->_tpl->assign('module_people_testers', isset($people['testers']) ? array_map(array($this, 'sanitize'), $people['testers']) : false); |
|
144 | + $this->_tpl->assign('module_people_translators', isset($people['translators']) ? array_map(array($this, 'sanitize'), $people['translators']) : false); |
|
145 | + $this->_tpl->assign('module_people_documenters', isset($people['documenters']) ? array_map(array($this, 'sanitize'), $people['documenters']) : false); |
|
146 | + $this->_tpl->assign('module_people_other', isset($people['other']) ? array_map(array($this, 'sanitize'), $people['other']) : false); |
|
147 | + } |
|
148 | + //$this->_tpl->assign('module_developers', $versioninfo->getInfo('developer_email')); |
|
149 | + |
|
150 | + // Module Development information |
|
151 | + $this->_tpl->assign('module_date', $versioninfo->getInfo('date')); |
|
152 | + $this->_tpl->assign('module_status', $versioninfo->getInfo('status')); |
|
153 | + $this->_tpl->assign('module_demo_site_url', $versioninfo->getInfo('demo_site_url')); |
|
154 | + $this->_tpl->assign('module_demo_site_name', $versioninfo->getInfo('demo_site_name')); |
|
155 | + $this->_tpl->assign('module_support_site_url', $versioninfo->getInfo('support_site_url')); |
|
156 | + $this->_tpl->assign('module_support_site_name', $versioninfo->getInfo('support_site_name')); |
|
157 | + $this->_tpl->assign('module_submit_bug', $versioninfo->getInfo('submit_bug')); |
|
158 | + $this->_tpl->assign('module_submit_feature', $versioninfo->getInfo('submit_feature')); |
|
159 | + |
|
160 | + // Warning |
|
161 | + $this->_tpl->assign('module_warning', $this->sanitize($versioninfo->getInfo('warning'))); |
|
162 | + |
|
163 | + // Author's note |
|
164 | + $this->_tpl->assign('module_author_word', $versioninfo->getInfo('author_word')); |
|
165 | + |
|
166 | + // For changelog thanks to 3Dev |
|
167 | + global $xoopsModule; |
|
168 | + $filename = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/changelog.txt'; |
|
169 | + if (is_file($filename)) { |
|
170 | + $filesize = filesize($filename); |
|
171 | + $handle = fopen($filename, 'r'); |
|
172 | + $this->_tpl->assign('module_version_history', $myts->displayTarea(fread($handle, $filesize), true)); |
|
173 | + fclose($handle); |
|
174 | + } |
|
175 | + |
|
176 | + $this->_tpl->display('db:smartobject_about.tpl'); |
|
177 | + |
|
178 | + smart_modFooter(); |
|
179 | + |
|
180 | + xoops_cp_footer(); |
|
181 | + } |
|
182 | 182 | } |
@@ -49,11 +49,11 @@ discard block |
||
49 | 49 | { |
50 | 50 | global $xoopsModule, $xoopsConfig; |
51 | 51 | |
52 | - $fileName = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php'; |
|
52 | + $fileName = XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/'.$xoopsConfig['language'].'/modinfo.php'; |
|
53 | 53 | if (file_exists($fileName)) { |
54 | 54 | include_once $fileName; |
55 | 55 | } else { |
56 | - include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/modinfo.php'; |
|
56 | + include_once XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/english/modinfo.php'; |
|
57 | 57 | } |
58 | 58 | $this->_aboutTitle = $aboutTitle; |
59 | 59 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | |
105 | 105 | //smart_adminMenu(-1, $this->_aboutTitle . " " . $versioninfo->getInfo('name')); |
106 | 106 | |
107 | - include_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
107 | + include_once XOOPS_ROOT_PATH.'/class/template.php'; |
|
108 | 108 | |
109 | 109 | // --- |
110 | 110 | // 2012-01-01 PHP 5.3: Assigning the return value of new by reference is now deprecated. |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $this->_tpl = new XoopsTpl(); |
113 | 113 | // --- |
114 | 114 | |
115 | - $this->_tpl->assign('module_url', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/'); |
|
115 | + $this->_tpl->assign('module_url', XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname').'/'); |
|
116 | 116 | $this->_tpl->assign('module_image', $versioninfo->getInfo('image')); |
117 | 117 | $this->_tpl->assign('module_name', $versioninfo->getInfo('name')); |
118 | 118 | $this->_tpl->assign('module_version', $versioninfo->getInfo('version')); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | |
121 | 121 | // Left headings... |
122 | 122 | if ($versioninfo->getInfo('author_realname') !== '') { |
123 | - $author_name = $versioninfo->getInfo('author') . ' (' . $versioninfo->getInfo('author_realname') . ')'; |
|
123 | + $author_name = $versioninfo->getInfo('author').' ('.$versioninfo->getInfo('author_realname').')'; |
|
124 | 124 | } else { |
125 | 125 | $author_name = $versioninfo->getInfo('author'); |
126 | 126 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | |
166 | 166 | // For changelog thanks to 3Dev |
167 | 167 | global $xoopsModule; |
168 | - $filename = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/changelog.txt'; |
|
168 | + $filename = XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/changelog.txt'; |
|
169 | 169 | if (is_file($filename)) { |
170 | 170 | $filesize = filesize($filename); |
171 | 171 | $handle = fopen($filename, 'r'); |
@@ -37,125 +37,125 @@ discard block |
||
37 | 37 | */ |
38 | 38 | class SmartobjectRating extends SmartObject |
39 | 39 | { |
40 | - public $_modulePlugin = false; |
|
41 | - |
|
42 | - /** |
|
43 | - * SmartobjectRating constructor. |
|
44 | - */ |
|
45 | - public function __construct() |
|
46 | - { |
|
47 | - $this->quickInitVar('ratingid', XOBJ_DTYPE_INT, true); |
|
48 | - $this->quickInitVar('dirname', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_RATING_DIRNAME); |
|
49 | - $this->quickInitVar('item', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_RATING_ITEM); |
|
50 | - $this->quickInitVar('itemid', XOBJ_DTYPE_INT, true, _CO_SOBJECT_RATING_ITEMID); |
|
51 | - $this->quickInitVar('uid', XOBJ_DTYPE_INT, true, _CO_SOBJECT_RATING_UID); |
|
52 | - $this->quickInitVar('date', XOBJ_DTYPE_LTIME, true, _CO_SOBJECT_RATING_DATE); |
|
53 | - $this->quickInitVar('rate', XOBJ_DTYPE_INT, true, _CO_SOBJECT_RATING_RATE); |
|
54 | - |
|
55 | - $this->initNonPersistableVar('name', XOBJ_DTYPE_TXTBOX, 'user', _CO_SOBJECT_RATING_NAME); |
|
56 | - |
|
57 | - $this->setControl('dirname', array( |
|
58 | - 'handler' => 'rating', |
|
59 | - 'method' => 'getModuleList', |
|
60 | - 'onSelect' => 'submit' |
|
61 | - )); |
|
62 | - |
|
63 | - $this->setControl('item', array( |
|
64 | - 'object' => &$this, |
|
65 | - 'method' => 'getItemList' |
|
66 | - )); |
|
67 | - |
|
68 | - $this->setControl('uid', 'user'); |
|
69 | - |
|
70 | - $this->setControl('rate', array( |
|
71 | - 'handler' => 'rating', |
|
72 | - 'method' => 'getRateList' |
|
73 | - )); |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * @param string $key |
|
78 | - * @param string $format |
|
79 | - * @return mixed |
|
80 | - */ |
|
81 | - public function getVar($key, $format = 's') |
|
82 | - { |
|
83 | - if ($format === 's' && in_array($key, array('name', 'dirname'))) { |
|
84 | - // return call_user_func(array($this, $key)); |
|
85 | - return $this->{$key}(); |
|
86 | - } |
|
87 | - |
|
88 | - return parent::getVar($key, $format); |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * @return string |
|
93 | - */ |
|
94 | - public function name() |
|
95 | - { |
|
96 | - $ret = smart_getLinkedUnameFromId($this->getVar('uid', 'e'), true, array()); |
|
97 | - |
|
98 | - return $ret; |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * @return mixed |
|
103 | - */ |
|
104 | - public function dirname() |
|
105 | - { |
|
106 | - global $smartobjectRatingHandler; |
|
107 | - $moduleArray = $smartobjectRatingHandler->getModuleList(); |
|
108 | - |
|
109 | - return $moduleArray[$this->getVar('dirname', 'n')]; |
|
110 | - } |
|
111 | - |
|
112 | - /** |
|
113 | - * @return mixed |
|
114 | - */ |
|
115 | - public function getItemList() |
|
116 | - { |
|
117 | - $plugin = $this->getModulePlugin(); |
|
118 | - |
|
119 | - return $plugin->getItemList(); |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * @return string |
|
124 | - */ |
|
125 | - public function getItemValue() |
|
126 | - { |
|
127 | - $moduleUrl = XOOPS_URL . '/modules/' . $this->getVar('dirname', 'n') . '/'; |
|
128 | - $plugin = $this->getModulePlugin(); |
|
129 | - $pluginItemInfo = $plugin->getItemInfo($this->getVar('item')); |
|
130 | - if (!$pluginItemInfo) { |
|
131 | - return ''; |
|
132 | - } |
|
133 | - $itemPath = sprintf($pluginItemInfo['url'], $this->getVar('itemid')); |
|
134 | - $ret = '<a href="' . $moduleUrl . $itemPath . '">' . $pluginItemInfo['caption'] . '</a>'; |
|
135 | - |
|
136 | - return $ret; |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * @return mixed |
|
141 | - */ |
|
142 | - public function getRateValue() |
|
143 | - { |
|
144 | - return $this->getVar('rate'); |
|
145 | - } |
|
146 | - |
|
147 | - /** |
|
148 | - * @return bool |
|
149 | - */ |
|
150 | - public function getModulePlugin() |
|
151 | - { |
|
152 | - if (!$this->_modulePlugin) { |
|
153 | - global $smartobjectRatingHandler; |
|
154 | - $this->_modulePlugin = $smartobjectRatingHandler->pluginsObject->getPlugin($this->getVar('dirname', 'n')); |
|
155 | - } |
|
156 | - |
|
157 | - return $this->_modulePlugin; |
|
158 | - } |
|
40 | + public $_modulePlugin = false; |
|
41 | + |
|
42 | + /** |
|
43 | + * SmartobjectRating constructor. |
|
44 | + */ |
|
45 | + public function __construct() |
|
46 | + { |
|
47 | + $this->quickInitVar('ratingid', XOBJ_DTYPE_INT, true); |
|
48 | + $this->quickInitVar('dirname', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_RATING_DIRNAME); |
|
49 | + $this->quickInitVar('item', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_RATING_ITEM); |
|
50 | + $this->quickInitVar('itemid', XOBJ_DTYPE_INT, true, _CO_SOBJECT_RATING_ITEMID); |
|
51 | + $this->quickInitVar('uid', XOBJ_DTYPE_INT, true, _CO_SOBJECT_RATING_UID); |
|
52 | + $this->quickInitVar('date', XOBJ_DTYPE_LTIME, true, _CO_SOBJECT_RATING_DATE); |
|
53 | + $this->quickInitVar('rate', XOBJ_DTYPE_INT, true, _CO_SOBJECT_RATING_RATE); |
|
54 | + |
|
55 | + $this->initNonPersistableVar('name', XOBJ_DTYPE_TXTBOX, 'user', _CO_SOBJECT_RATING_NAME); |
|
56 | + |
|
57 | + $this->setControl('dirname', array( |
|
58 | + 'handler' => 'rating', |
|
59 | + 'method' => 'getModuleList', |
|
60 | + 'onSelect' => 'submit' |
|
61 | + )); |
|
62 | + |
|
63 | + $this->setControl('item', array( |
|
64 | + 'object' => &$this, |
|
65 | + 'method' => 'getItemList' |
|
66 | + )); |
|
67 | + |
|
68 | + $this->setControl('uid', 'user'); |
|
69 | + |
|
70 | + $this->setControl('rate', array( |
|
71 | + 'handler' => 'rating', |
|
72 | + 'method' => 'getRateList' |
|
73 | + )); |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * @param string $key |
|
78 | + * @param string $format |
|
79 | + * @return mixed |
|
80 | + */ |
|
81 | + public function getVar($key, $format = 's') |
|
82 | + { |
|
83 | + if ($format === 's' && in_array($key, array('name', 'dirname'))) { |
|
84 | + // return call_user_func(array($this, $key)); |
|
85 | + return $this->{$key}(); |
|
86 | + } |
|
87 | + |
|
88 | + return parent::getVar($key, $format); |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * @return string |
|
93 | + */ |
|
94 | + public function name() |
|
95 | + { |
|
96 | + $ret = smart_getLinkedUnameFromId($this->getVar('uid', 'e'), true, array()); |
|
97 | + |
|
98 | + return $ret; |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * @return mixed |
|
103 | + */ |
|
104 | + public function dirname() |
|
105 | + { |
|
106 | + global $smartobjectRatingHandler; |
|
107 | + $moduleArray = $smartobjectRatingHandler->getModuleList(); |
|
108 | + |
|
109 | + return $moduleArray[$this->getVar('dirname', 'n')]; |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | + * @return mixed |
|
114 | + */ |
|
115 | + public function getItemList() |
|
116 | + { |
|
117 | + $plugin = $this->getModulePlugin(); |
|
118 | + |
|
119 | + return $plugin->getItemList(); |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * @return string |
|
124 | + */ |
|
125 | + public function getItemValue() |
|
126 | + { |
|
127 | + $moduleUrl = XOOPS_URL . '/modules/' . $this->getVar('dirname', 'n') . '/'; |
|
128 | + $plugin = $this->getModulePlugin(); |
|
129 | + $pluginItemInfo = $plugin->getItemInfo($this->getVar('item')); |
|
130 | + if (!$pluginItemInfo) { |
|
131 | + return ''; |
|
132 | + } |
|
133 | + $itemPath = sprintf($pluginItemInfo['url'], $this->getVar('itemid')); |
|
134 | + $ret = '<a href="' . $moduleUrl . $itemPath . '">' . $pluginItemInfo['caption'] . '</a>'; |
|
135 | + |
|
136 | + return $ret; |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * @return mixed |
|
141 | + */ |
|
142 | + public function getRateValue() |
|
143 | + { |
|
144 | + return $this->getVar('rate'); |
|
145 | + } |
|
146 | + |
|
147 | + /** |
|
148 | + * @return bool |
|
149 | + */ |
|
150 | + public function getModulePlugin() |
|
151 | + { |
|
152 | + if (!$this->_modulePlugin) { |
|
153 | + global $smartobjectRatingHandler; |
|
154 | + $this->_modulePlugin = $smartobjectRatingHandler->pluginsObject->getPlugin($this->getVar('dirname', 'n')); |
|
155 | + } |
|
156 | + |
|
157 | + return $this->_modulePlugin; |
|
158 | + } |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
@@ -163,93 +163,93 @@ discard block |
||
163 | 163 | */ |
164 | 164 | class SmartobjectRatingHandler extends SmartPersistableObjectHandler |
165 | 165 | { |
166 | - public $_rateOptions = array(); |
|
167 | - public $_moduleList = false; |
|
168 | - public $pluginsObject; |
|
169 | - |
|
170 | - /** |
|
171 | - * SmartobjectRatingHandler constructor. |
|
172 | - * @param XoopsDatabase $db |
|
173 | - */ |
|
174 | - public function __construct(XoopsDatabase $db) |
|
175 | - { |
|
176 | - parent::__construct($db, 'rating', 'ratingid', 'rate', '', 'smartobject'); |
|
177 | - $this->generalSQL = 'SELECT * FROM ' . $this->table . ' AS ' . $this->_itemname . ' INNER JOIN ' . $this->db->prefix('users') . ' AS user ON ' . $this->_itemname . '.uid=user.uid'; |
|
178 | - |
|
179 | - $this->_rateOptions[1] = 1; |
|
180 | - $this->_rateOptions[2] = 2; |
|
181 | - $this->_rateOptions[3] = 3; |
|
182 | - $this->_rateOptions[4] = 4; |
|
183 | - $this->_rateOptions[5] = 5; |
|
184 | - |
|
185 | - $this->pluginsObject = new SmartPluginHandler(); |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * @return bool |
|
190 | - */ |
|
191 | - public function getModuleList() |
|
192 | - { |
|
193 | - if (!$this->_moduleList) { |
|
194 | - $moduleArray = $this->pluginsObject->getPluginsArray(); |
|
195 | - $this->_moduleList[0] = _CO_SOBJECT_MAKE_SELECTION; |
|
196 | - foreach ($moduleArray as $k => $v) { |
|
197 | - $this->_moduleList[$k] = $v; |
|
198 | - } |
|
199 | - } |
|
200 | - |
|
201 | - return $this->_moduleList; |
|
202 | - } |
|
203 | - |
|
204 | - /** |
|
205 | - * @return array |
|
206 | - */ |
|
207 | - public function getRateList() |
|
208 | - { |
|
209 | - return $this->_rateOptions; |
|
210 | - } |
|
211 | - |
|
212 | - /** |
|
213 | - * @param $itemid |
|
214 | - * @param $dirname |
|
215 | - * @param $item |
|
216 | - * @return int |
|
217 | - */ |
|
218 | - public function getRatingAverageByItemId($itemid, $dirname, $item) |
|
219 | - { |
|
220 | - $sql = 'SELECT AVG(rate), COUNT(ratingid) FROM ' . $this->table . " WHERE itemid=$itemid AND dirname='$dirname' AND item='$item' GROUP BY itemid"; |
|
221 | - $result = $this->db->query($sql); |
|
222 | - if (!$result) { |
|
223 | - return 0; |
|
224 | - } |
|
225 | - list($average, $sum) = $this->db->fetchRow($result); |
|
226 | - $ret['average'] = isset($average) ? $average : 0; |
|
227 | - $ret['sum'] = isset($sum) ? $sum : 0; |
|
228 | - |
|
229 | - return $ret; |
|
230 | - } |
|
231 | - |
|
232 | - /** |
|
233 | - * @param $item |
|
234 | - * @param $itemid |
|
235 | - * @param $dirname |
|
236 | - * @param $uid |
|
237 | - * @return bool |
|
238 | - */ |
|
239 | - public function already_rated($item, $itemid, $dirname, $uid) |
|
240 | - { |
|
241 | - $criteria = new CriteriaCompo(); |
|
242 | - $criteria->add(new Criteria('item', $item)); |
|
243 | - $criteria->add(new Criteria('itemid', $itemid)); |
|
244 | - $criteria->add(new Criteria('dirname', $dirname)); |
|
245 | - $criteria->add(new Criteria('user.uid', $uid)); |
|
246 | - |
|
247 | - $ret = $this->getObjects($criteria); |
|
248 | - |
|
249 | - if (!$ret) { |
|
250 | - return false; |
|
251 | - } else { |
|
252 | - return $ret[0]; |
|
253 | - } |
|
254 | - } |
|
166 | + public $_rateOptions = array(); |
|
167 | + public $_moduleList = false; |
|
168 | + public $pluginsObject; |
|
169 | + |
|
170 | + /** |
|
171 | + * SmartobjectRatingHandler constructor. |
|
172 | + * @param XoopsDatabase $db |
|
173 | + */ |
|
174 | + public function __construct(XoopsDatabase $db) |
|
175 | + { |
|
176 | + parent::__construct($db, 'rating', 'ratingid', 'rate', '', 'smartobject'); |
|
177 | + $this->generalSQL = 'SELECT * FROM ' . $this->table . ' AS ' . $this->_itemname . ' INNER JOIN ' . $this->db->prefix('users') . ' AS user ON ' . $this->_itemname . '.uid=user.uid'; |
|
178 | + |
|
179 | + $this->_rateOptions[1] = 1; |
|
180 | + $this->_rateOptions[2] = 2; |
|
181 | + $this->_rateOptions[3] = 3; |
|
182 | + $this->_rateOptions[4] = 4; |
|
183 | + $this->_rateOptions[5] = 5; |
|
184 | + |
|
185 | + $this->pluginsObject = new SmartPluginHandler(); |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * @return bool |
|
190 | + */ |
|
191 | + public function getModuleList() |
|
192 | + { |
|
193 | + if (!$this->_moduleList) { |
|
194 | + $moduleArray = $this->pluginsObject->getPluginsArray(); |
|
195 | + $this->_moduleList[0] = _CO_SOBJECT_MAKE_SELECTION; |
|
196 | + foreach ($moduleArray as $k => $v) { |
|
197 | + $this->_moduleList[$k] = $v; |
|
198 | + } |
|
199 | + } |
|
200 | + |
|
201 | + return $this->_moduleList; |
|
202 | + } |
|
203 | + |
|
204 | + /** |
|
205 | + * @return array |
|
206 | + */ |
|
207 | + public function getRateList() |
|
208 | + { |
|
209 | + return $this->_rateOptions; |
|
210 | + } |
|
211 | + |
|
212 | + /** |
|
213 | + * @param $itemid |
|
214 | + * @param $dirname |
|
215 | + * @param $item |
|
216 | + * @return int |
|
217 | + */ |
|
218 | + public function getRatingAverageByItemId($itemid, $dirname, $item) |
|
219 | + { |
|
220 | + $sql = 'SELECT AVG(rate), COUNT(ratingid) FROM ' . $this->table . " WHERE itemid=$itemid AND dirname='$dirname' AND item='$item' GROUP BY itemid"; |
|
221 | + $result = $this->db->query($sql); |
|
222 | + if (!$result) { |
|
223 | + return 0; |
|
224 | + } |
|
225 | + list($average, $sum) = $this->db->fetchRow($result); |
|
226 | + $ret['average'] = isset($average) ? $average : 0; |
|
227 | + $ret['sum'] = isset($sum) ? $sum : 0; |
|
228 | + |
|
229 | + return $ret; |
|
230 | + } |
|
231 | + |
|
232 | + /** |
|
233 | + * @param $item |
|
234 | + * @param $itemid |
|
235 | + * @param $dirname |
|
236 | + * @param $uid |
|
237 | + * @return bool |
|
238 | + */ |
|
239 | + public function already_rated($item, $itemid, $dirname, $uid) |
|
240 | + { |
|
241 | + $criteria = new CriteriaCompo(); |
|
242 | + $criteria->add(new Criteria('item', $item)); |
|
243 | + $criteria->add(new Criteria('itemid', $itemid)); |
|
244 | + $criteria->add(new Criteria('dirname', $dirname)); |
|
245 | + $criteria->add(new Criteria('user.uid', $uid)); |
|
246 | + |
|
247 | + $ret = $this->getObjects($criteria); |
|
248 | + |
|
249 | + if (!$ret) { |
|
250 | + return false; |
|
251 | + } else { |
|
252 | + return $ret[0]; |
|
253 | + } |
|
254 | + } |
|
255 | 255 | } |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | |
30 | 30 | // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
31 | 31 | |
32 | -include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobject.php'; |
|
33 | -include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartplugins.php'; |
|
32 | +include_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartobject.php'; |
|
33 | +include_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartplugins.php'; |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Class SmartobjectRating |
@@ -124,14 +124,14 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function getItemValue() |
126 | 126 | { |
127 | - $moduleUrl = XOOPS_URL . '/modules/' . $this->getVar('dirname', 'n') . '/'; |
|
127 | + $moduleUrl = XOOPS_URL.'/modules/'.$this->getVar('dirname', 'n').'/'; |
|
128 | 128 | $plugin = $this->getModulePlugin(); |
129 | 129 | $pluginItemInfo = $plugin->getItemInfo($this->getVar('item')); |
130 | 130 | if (!$pluginItemInfo) { |
131 | 131 | return ''; |
132 | 132 | } |
133 | 133 | $itemPath = sprintf($pluginItemInfo['url'], $this->getVar('itemid')); |
134 | - $ret = '<a href="' . $moduleUrl . $itemPath . '">' . $pluginItemInfo['caption'] . '</a>'; |
|
134 | + $ret = '<a href="'.$moduleUrl.$itemPath.'">'.$pluginItemInfo['caption'].'</a>'; |
|
135 | 135 | |
136 | 136 | return $ret; |
137 | 137 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | public function __construct(XoopsDatabase $db) |
175 | 175 | { |
176 | 176 | parent::__construct($db, 'rating', 'ratingid', 'rate', '', 'smartobject'); |
177 | - $this->generalSQL = 'SELECT * FROM ' . $this->table . ' AS ' . $this->_itemname . ' INNER JOIN ' . $this->db->prefix('users') . ' AS user ON ' . $this->_itemname . '.uid=user.uid'; |
|
177 | + $this->generalSQL = 'SELECT * FROM '.$this->table.' AS '.$this->_itemname.' INNER JOIN '.$this->db->prefix('users').' AS user ON '.$this->_itemname.'.uid=user.uid'; |
|
178 | 178 | |
179 | 179 | $this->_rateOptions[1] = 1; |
180 | 180 | $this->_rateOptions[2] = 2; |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | */ |
218 | 218 | public function getRatingAverageByItemId($itemid, $dirname, $item) |
219 | 219 | { |
220 | - $sql = 'SELECT AVG(rate), COUNT(ratingid) FROM ' . $this->table . " WHERE itemid=$itemid AND dirname='$dirname' AND item='$item' GROUP BY itemid"; |
|
220 | + $sql = 'SELECT AVG(rate), COUNT(ratingid) FROM '.$this->table." WHERE itemid=$itemid AND dirname='$dirname' AND item='$item' GROUP BY itemid"; |
|
221 | 221 | $result = $this->db->query($sql); |
222 | 222 | if (!$result) { |
223 | 223 | return 0; |
@@ -8,22 +8,22 @@ discard block |
||
8 | 8 | */ |
9 | 9 | class SmartobjectUrlLink extends SmartobjectBasedUrl |
10 | 10 | { |
11 | - /** |
|
12 | - * SmartobjectUrlLink constructor. |
|
13 | - */ |
|
14 | - public function __construct() |
|
15 | - { |
|
16 | - parent::__construct(); |
|
17 | - $this->quickInitVar('urllinkid', XOBJ_DTYPE_TXTBOX, true); |
|
18 | - $this->quickInitVar('target', XOBJ_DTYPE_TXTBOX, true); |
|
11 | + /** |
|
12 | + * SmartobjectUrlLink constructor. |
|
13 | + */ |
|
14 | + public function __construct() |
|
15 | + { |
|
16 | + parent::__construct(); |
|
17 | + $this->quickInitVar('urllinkid', XOBJ_DTYPE_TXTBOX, true); |
|
18 | + $this->quickInitVar('target', XOBJ_DTYPE_TXTBOX, true); |
|
19 | 19 | |
20 | - $this->setControl('target', array( |
|
21 | - 'options' => array( |
|
22 | - '_self' => _CO_SOBJECT_URLLINK_SELF, |
|
23 | - '_blank' => _CO_SOBJECT_URLLINK_BLANK |
|
24 | - ) |
|
25 | - )); |
|
26 | - } |
|
20 | + $this->setControl('target', array( |
|
21 | + 'options' => array( |
|
22 | + '_self' => _CO_SOBJECT_URLLINK_SELF, |
|
23 | + '_blank' => _CO_SOBJECT_URLLINK_BLANK |
|
24 | + ) |
|
25 | + )); |
|
26 | + } |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -31,12 +31,12 @@ discard block |
||
31 | 31 | */ |
32 | 32 | class SmartobjectUrlLinkHandler extends SmartPersistableObjectHandler |
33 | 33 | { |
34 | - /** |
|
35 | - * SmartobjectUrlLinkHandler constructor. |
|
36 | - * @param XoopsDatabase $db |
|
37 | - */ |
|
38 | - public function __construct(XoopsDatabase $db) |
|
39 | - { |
|
40 | - parent::__construct($db, 'urllink', 'urllinkid', 'caption', 'desc', 'smartobject'); |
|
41 | - } |
|
34 | + /** |
|
35 | + * SmartobjectUrlLinkHandler constructor. |
|
36 | + * @param XoopsDatabase $db |
|
37 | + */ |
|
38 | + public function __construct(XoopsDatabase $db) |
|
39 | + { |
|
40 | + parent::__construct($db, 'urllink', 'urllinkid', 'caption', 'desc', 'smartobject'); |
|
41 | + } |
|
42 | 42 | } |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
3 | 3 | |
4 | -include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/basedurl.php'; |
|
4 | +include_once XOOPS_ROOT_PATH.'/modules/smartobject/class/basedurl.php'; |
|
5 | 5 | |
6 | 6 | /** |
7 | 7 | * Class SmartobjectUrlLink |
@@ -19,96 +19,96 @@ |
||
19 | 19 | */ |
20 | 20 | class SmartHighlighter |
21 | 21 | { |
22 | - /** |
|
23 | - * @access private |
|
24 | - */ |
|
25 | - public $preg_keywords = ''; |
|
26 | - /** |
|
27 | - * @access private |
|
28 | - */ |
|
29 | - public $keywords = ''; |
|
30 | - /** |
|
31 | - * @access private |
|
32 | - */ |
|
33 | - public $singlewords = false; |
|
34 | - /** |
|
35 | - * @access private |
|
36 | - */ |
|
37 | - public $replace_callback = null; |
|
22 | + /** |
|
23 | + * @access private |
|
24 | + */ |
|
25 | + public $preg_keywords = ''; |
|
26 | + /** |
|
27 | + * @access private |
|
28 | + */ |
|
29 | + public $keywords = ''; |
|
30 | + /** |
|
31 | + * @access private |
|
32 | + */ |
|
33 | + public $singlewords = false; |
|
34 | + /** |
|
35 | + * @access private |
|
36 | + */ |
|
37 | + public $replace_callback = null; |
|
38 | 38 | |
39 | - public $content; |
|
39 | + public $content; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Main constructor |
|
43 | - * |
|
44 | - * This is the main constructor of keyhighlighter class. <br> |
|
45 | - * It's the only public method of the class. |
|
46 | - * @param string $keywords the keywords you want to highlight |
|
47 | - * @param boolean $singlewords specify if it has to highlight also the single words. |
|
48 | - * @param callback $replace_callback a custom callback for keyword highlight. |
|
49 | - * <code> |
|
50 | - * <?php |
|
51 | - * require ('keyhighlighter.class.php'); |
|
52 | - * |
|
53 | - * function my_highlighter ($matches) { |
|
54 | - * return '<span style="font-weight: bolder; color: #FF0000;">' . $matches[0] . '</span>'; |
|
55 | - * } |
|
56 | - * |
|
57 | - * new keyhighlighter ('W3C', false, 'my_highlighter'); |
|
58 | - * readfile ('http://www.w3c.org/'); |
|
59 | - * ?> |
|
60 | - * </code> |
|
61 | - */ |
|
62 | - // public function __construct () |
|
63 | - public function __construct($keywords, $singlewords = false, $replace_callback = null) |
|
64 | - { |
|
65 | - $this->keywords = $keywords; |
|
66 | - $this->singlewords = $singlewords; |
|
67 | - $this->replace_callback = $replace_callback; |
|
68 | - } |
|
41 | + /** |
|
42 | + * Main constructor |
|
43 | + * |
|
44 | + * This is the main constructor of keyhighlighter class. <br> |
|
45 | + * It's the only public method of the class. |
|
46 | + * @param string $keywords the keywords you want to highlight |
|
47 | + * @param boolean $singlewords specify if it has to highlight also the single words. |
|
48 | + * @param callback $replace_callback a custom callback for keyword highlight. |
|
49 | + * <code> |
|
50 | + * <?php |
|
51 | + * require ('keyhighlighter.class.php'); |
|
52 | + * |
|
53 | + * function my_highlighter ($matches) { |
|
54 | + * return '<span style="font-weight: bolder; color: #FF0000;">' . $matches[0] . '</span>'; |
|
55 | + * } |
|
56 | + * |
|
57 | + * new keyhighlighter ('W3C', false, 'my_highlighter'); |
|
58 | + * readfile ('http://www.w3c.org/'); |
|
59 | + * ?> |
|
60 | + * </code> |
|
61 | + */ |
|
62 | + // public function __construct () |
|
63 | + public function __construct($keywords, $singlewords = false, $replace_callback = null) |
|
64 | + { |
|
65 | + $this->keywords = $keywords; |
|
66 | + $this->singlewords = $singlewords; |
|
67 | + $this->replace_callback = $replace_callback; |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * @access private |
|
72 | - * @param $replace_matches |
|
73 | - * @return mixed |
|
74 | - */ |
|
75 | - public function replace($replace_matches) |
|
76 | - { |
|
77 | - $patterns = array(); |
|
78 | - if ($this->singlewords) { |
|
79 | - $keywords = explode(' ', $this->preg_keywords); |
|
80 | - foreach ($keywords as $keyword) { |
|
81 | - $patterns[] = '/(?' . '>' . $keyword . '+)/si'; |
|
82 | - } |
|
83 | - } else { |
|
84 | - $patterns[] = '/(?' . '>' . $this->preg_keywords . '+)/si'; |
|
85 | - } |
|
70 | + /** |
|
71 | + * @access private |
|
72 | + * @param $replace_matches |
|
73 | + * @return mixed |
|
74 | + */ |
|
75 | + public function replace($replace_matches) |
|
76 | + { |
|
77 | + $patterns = array(); |
|
78 | + if ($this->singlewords) { |
|
79 | + $keywords = explode(' ', $this->preg_keywords); |
|
80 | + foreach ($keywords as $keyword) { |
|
81 | + $patterns[] = '/(?' . '>' . $keyword . '+)/si'; |
|
82 | + } |
|
83 | + } else { |
|
84 | + $patterns[] = '/(?' . '>' . $this->preg_keywords . '+)/si'; |
|
85 | + } |
|
86 | 86 | |
87 | - $result = $replace_matches[0]; |
|
87 | + $result = $replace_matches[0]; |
|
88 | 88 | |
89 | - foreach ($patterns as $pattern) { |
|
90 | - if (null !== $this->replace_callback) { |
|
91 | - $result = preg_replace_callback($pattern, $this->replace_callback, $result); |
|
92 | - } else { |
|
93 | - $result = preg_replace($pattern, '<span class="highlightedkey">\\0</span>', $result); |
|
94 | - } |
|
95 | - } |
|
89 | + foreach ($patterns as $pattern) { |
|
90 | + if (null !== $this->replace_callback) { |
|
91 | + $result = preg_replace_callback($pattern, $this->replace_callback, $result); |
|
92 | + } else { |
|
93 | + $result = preg_replace($pattern, '<span class="highlightedkey">\\0</span>', $result); |
|
94 | + } |
|
95 | + } |
|
96 | 96 | |
97 | - return $result; |
|
98 | - } |
|
97 | + return $result; |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * @access private |
|
102 | - * @param $buffer |
|
103 | - * @return mixed|string |
|
104 | - */ |
|
105 | - public function highlight($buffer) |
|
106 | - { |
|
107 | - $buffer = '>' . $buffer . '<'; |
|
108 | - $this->preg_keywords = preg_replace('/[^\w ]/si', '', $this->keywords); |
|
109 | - $buffer = preg_replace_callback("/(\>(((?" . ">[^><]+)|(?R))*)\<)/is", array(&$this, 'replace'), $buffer); |
|
110 | - $buffer = substr($buffer, 1, -1); |
|
100 | + /** |
|
101 | + * @access private |
|
102 | + * @param $buffer |
|
103 | + * @return mixed|string |
|
104 | + */ |
|
105 | + public function highlight($buffer) |
|
106 | + { |
|
107 | + $buffer = '>' . $buffer . '<'; |
|
108 | + $this->preg_keywords = preg_replace('/[^\w ]/si', '', $this->keywords); |
|
109 | + $buffer = preg_replace_callback("/(\>(((?" . ">[^><]+)|(?R))*)\<)/is", array(&$this, 'replace'), $buffer); |
|
110 | + $buffer = substr($buffer, 1, -1); |
|
111 | 111 | |
112 | - return $buffer; |
|
113 | - } |
|
112 | + return $buffer; |
|
113 | + } |
|
114 | 114 | } |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | if ($this->singlewords) { |
79 | 79 | $keywords = explode(' ', $this->preg_keywords); |
80 | 80 | foreach ($keywords as $keyword) { |
81 | - $patterns[] = '/(?' . '>' . $keyword . '+)/si'; |
|
81 | + $patterns[] = '/(?'.'>'.$keyword.'+)/si'; |
|
82 | 82 | } |
83 | 83 | } else { |
84 | - $patterns[] = '/(?' . '>' . $this->preg_keywords . '+)/si'; |
|
84 | + $patterns[] = '/(?'.'>'.$this->preg_keywords.'+)/si'; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | $result = $replace_matches[0]; |
@@ -104,9 +104,9 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function highlight($buffer) |
106 | 106 | { |
107 | - $buffer = '>' . $buffer . '<'; |
|
107 | + $buffer = '>'.$buffer.'<'; |
|
108 | 108 | $this->preg_keywords = preg_replace('/[^\w ]/si', '', $this->keywords); |
109 | - $buffer = preg_replace_callback("/(\>(((?" . ">[^><]+)|(?R))*)\<)/is", array(&$this, 'replace'), $buffer); |
|
109 | + $buffer = preg_replace_callback("/(\>(((?".">[^><]+)|(?R))*)\<)/is", array(&$this, 'replace'), $buffer); |
|
110 | 110 | $buffer = substr($buffer, 1, -1); |
111 | 111 | |
112 | 112 | return $buffer; |
@@ -18,123 +18,123 @@ discard block |
||
18 | 18 | */ |
19 | 19 | class SmartobjectCategory extends SmartSeoObject |
20 | 20 | { |
21 | - public $_categoryPath; |
|
22 | - |
|
23 | - /** |
|
24 | - * SmartobjectCategory constructor. |
|
25 | - */ |
|
26 | - public function __construct() |
|
27 | - { |
|
28 | - $this->initVar('categoryid', XOBJ_DTYPE_INT, '', true); |
|
29 | - $this->initVar('parentid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_CATEGORY_PARENTID, _CO_SOBJECT_CATEGORY_PARENTID_DSC); |
|
30 | - $this->initVar('name', XOBJ_DTYPE_TXTBOX, '', false, null, '', false, _CO_SOBJECT_CATEGORY_NAME, _CO_SOBJECT_CATEGORY_NAME_DSC); |
|
31 | - $this->initVar('description', XOBJ_DTYPE_TXTAREA, '', false, null, '', false, _CO_SOBJECT_CATEGORY_DESCRIPTION, _CO_SOBJECT_CATEGORY_DESCRIPTION_DSC); |
|
32 | - $this->initVar('image', XOBJ_DTYPE_TXTBOX, '', false, null, '', false, _CO_SOBJECT_CATEGORY_IMAGE, _CO_SOBJECT_CATEGORY_IMAGE_DSC); |
|
33 | - |
|
34 | - $this->initCommonVar('doxcode'); |
|
35 | - |
|
36 | - $this->setControl('image', array('name' => 'image')); |
|
37 | - $this->setControl('parentid', array('name' => 'parentcategory')); |
|
38 | - $this->setControl('description', array( |
|
39 | - 'name' => 'textarea', |
|
40 | - 'itemHandler' => false, |
|
41 | - 'method' => false, |
|
42 | - 'module' => false, |
|
43 | - 'form_editor' => 'default' |
|
44 | - )); |
|
45 | - |
|
46 | - // call parent constructor to get SEO fields initiated |
|
47 | - parent::__construct(); |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * returns a specific variable for the object in a proper format |
|
52 | - * |
|
53 | - * @access public |
|
54 | - * @param string $key key of the object's variable to be returned |
|
55 | - * @param string $format format to use for the output |
|
56 | - * @return mixed formatted value of the variable |
|
57 | - */ |
|
58 | - public function getVar($key, $format = 's') |
|
59 | - { |
|
60 | - if ($format === 's' && in_array($key, array('description', 'image'))) { |
|
61 | - // return call_user_func(array($this, $key)); |
|
62 | - return $this->{$key}(); |
|
63 | - } |
|
64 | - |
|
65 | - return parent::getVar($key, $format); |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * @return string |
|
70 | - */ |
|
71 | - public function description() |
|
72 | - { |
|
73 | - return $this->getValueFor('description', false); |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * @return bool|mixed |
|
78 | - */ |
|
79 | - public function image() |
|
80 | - { |
|
81 | - $ret = $this->getVar('image', 'e'); |
|
82 | - if ($ret == '-1') { |
|
83 | - return false; |
|
84 | - } else { |
|
85 | - return $ret; |
|
86 | - } |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * @return array |
|
91 | - */ |
|
92 | - public function toArray() |
|
93 | - { |
|
94 | - $this->setVar('doxcode', true); |
|
95 | - global $myts; |
|
96 | - $objectArray = parent::toArray(); |
|
97 | - if ($objectArray['image']) { |
|
98 | - $objectArray['image'] = $this->getImageDir() . $objectArray['image']; |
|
99 | - } |
|
100 | - |
|
101 | - return $objectArray; |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * Create the complete path of a category |
|
106 | - * |
|
107 | - * @todo this could be improved as it uses multiple queries |
|
108 | - * @param bool $withAllLink make all name clickable |
|
109 | - * @param bool $currentCategory |
|
110 | - * @return string complete path (breadcrumb) |
|
111 | - */ |
|
112 | - public function getCategoryPath($withAllLink = true, $currentCategory = false) |
|
113 | - { |
|
114 | - include_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectcontroller.php'; |
|
115 | - $controller = new SmartObjectController($this->handler); |
|
116 | - |
|
117 | - if (!$this->_categoryPath) { |
|
118 | - if ($withAllLink && !$currentCategory) { |
|
119 | - $ret = $controller->getItemLink($this); |
|
120 | - } else { |
|
121 | - $currentCategory = false; |
|
122 | - $ret = $this->getVar('name'); |
|
123 | - } |
|
124 | - $parentid = $this->getVar('parentid'); |
|
125 | - if ($parentid != 0) { |
|
126 | - $parentObj = $this->handler->get($parentid); |
|
127 | - if ($parentObj->isNew()) { |
|
128 | - exit; |
|
129 | - } |
|
130 | - $parentid = $parentObj->getVar('parentid'); |
|
131 | - $ret = $parentObj->getCategoryPath($withAllLink, $currentCategory) . ' > ' . $ret; |
|
132 | - } |
|
133 | - $this->_categoryPath = $ret; |
|
134 | - } |
|
135 | - |
|
136 | - return $this->_categoryPath; |
|
137 | - } |
|
21 | + public $_categoryPath; |
|
22 | + |
|
23 | + /** |
|
24 | + * SmartobjectCategory constructor. |
|
25 | + */ |
|
26 | + public function __construct() |
|
27 | + { |
|
28 | + $this->initVar('categoryid', XOBJ_DTYPE_INT, '', true); |
|
29 | + $this->initVar('parentid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_CATEGORY_PARENTID, _CO_SOBJECT_CATEGORY_PARENTID_DSC); |
|
30 | + $this->initVar('name', XOBJ_DTYPE_TXTBOX, '', false, null, '', false, _CO_SOBJECT_CATEGORY_NAME, _CO_SOBJECT_CATEGORY_NAME_DSC); |
|
31 | + $this->initVar('description', XOBJ_DTYPE_TXTAREA, '', false, null, '', false, _CO_SOBJECT_CATEGORY_DESCRIPTION, _CO_SOBJECT_CATEGORY_DESCRIPTION_DSC); |
|
32 | + $this->initVar('image', XOBJ_DTYPE_TXTBOX, '', false, null, '', false, _CO_SOBJECT_CATEGORY_IMAGE, _CO_SOBJECT_CATEGORY_IMAGE_DSC); |
|
33 | + |
|
34 | + $this->initCommonVar('doxcode'); |
|
35 | + |
|
36 | + $this->setControl('image', array('name' => 'image')); |
|
37 | + $this->setControl('parentid', array('name' => 'parentcategory')); |
|
38 | + $this->setControl('description', array( |
|
39 | + 'name' => 'textarea', |
|
40 | + 'itemHandler' => false, |
|
41 | + 'method' => false, |
|
42 | + 'module' => false, |
|
43 | + 'form_editor' => 'default' |
|
44 | + )); |
|
45 | + |
|
46 | + // call parent constructor to get SEO fields initiated |
|
47 | + parent::__construct(); |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * returns a specific variable for the object in a proper format |
|
52 | + * |
|
53 | + * @access public |
|
54 | + * @param string $key key of the object's variable to be returned |
|
55 | + * @param string $format format to use for the output |
|
56 | + * @return mixed formatted value of the variable |
|
57 | + */ |
|
58 | + public function getVar($key, $format = 's') |
|
59 | + { |
|
60 | + if ($format === 's' && in_array($key, array('description', 'image'))) { |
|
61 | + // return call_user_func(array($this, $key)); |
|
62 | + return $this->{$key}(); |
|
63 | + } |
|
64 | + |
|
65 | + return parent::getVar($key, $format); |
|
66 | + } |
|
67 | + |
|
68 | + /** |
|
69 | + * @return string |
|
70 | + */ |
|
71 | + public function description() |
|
72 | + { |
|
73 | + return $this->getValueFor('description', false); |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * @return bool|mixed |
|
78 | + */ |
|
79 | + public function image() |
|
80 | + { |
|
81 | + $ret = $this->getVar('image', 'e'); |
|
82 | + if ($ret == '-1') { |
|
83 | + return false; |
|
84 | + } else { |
|
85 | + return $ret; |
|
86 | + } |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * @return array |
|
91 | + */ |
|
92 | + public function toArray() |
|
93 | + { |
|
94 | + $this->setVar('doxcode', true); |
|
95 | + global $myts; |
|
96 | + $objectArray = parent::toArray(); |
|
97 | + if ($objectArray['image']) { |
|
98 | + $objectArray['image'] = $this->getImageDir() . $objectArray['image']; |
|
99 | + } |
|
100 | + |
|
101 | + return $objectArray; |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * Create the complete path of a category |
|
106 | + * |
|
107 | + * @todo this could be improved as it uses multiple queries |
|
108 | + * @param bool $withAllLink make all name clickable |
|
109 | + * @param bool $currentCategory |
|
110 | + * @return string complete path (breadcrumb) |
|
111 | + */ |
|
112 | + public function getCategoryPath($withAllLink = true, $currentCategory = false) |
|
113 | + { |
|
114 | + include_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectcontroller.php'; |
|
115 | + $controller = new SmartObjectController($this->handler); |
|
116 | + |
|
117 | + if (!$this->_categoryPath) { |
|
118 | + if ($withAllLink && !$currentCategory) { |
|
119 | + $ret = $controller->getItemLink($this); |
|
120 | + } else { |
|
121 | + $currentCategory = false; |
|
122 | + $ret = $this->getVar('name'); |
|
123 | + } |
|
124 | + $parentid = $this->getVar('parentid'); |
|
125 | + if ($parentid != 0) { |
|
126 | + $parentObj = $this->handler->get($parentid); |
|
127 | + if ($parentObj->isNew()) { |
|
128 | + exit; |
|
129 | + } |
|
130 | + $parentid = $parentObj->getVar('parentid'); |
|
131 | + $ret = $parentObj->getCategoryPath($withAllLink, $currentCategory) . ' > ' . $ret; |
|
132 | + } |
|
133 | + $this->_categoryPath = $ret; |
|
134 | + } |
|
135 | + |
|
136 | + return $this->_categoryPath; |
|
137 | + } |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -142,91 +142,91 @@ discard block |
||
142 | 142 | */ |
143 | 143 | class SmartobjectCategoryHandler extends SmartPersistableObjectHandler |
144 | 144 | { |
145 | - public $allCategoriesObj = false; |
|
146 | - public $_allCategoriesId = false; |
|
147 | - |
|
148 | - /** |
|
149 | - * SmartobjectCategoryHandler constructor. |
|
150 | - * @param XoopsDatabase $db |
|
151 | - * @param $modulename |
|
152 | - */ |
|
153 | - public function __construct(XoopsDatabase $db, $modulename) |
|
154 | - { |
|
155 | - parent::__construct($db, 'category', 'categoryid', 'name', 'description', $modulename); |
|
156 | - } |
|
157 | - |
|
158 | - /** |
|
159 | - * @param int $parentid |
|
160 | - * @param bool $perm_name |
|
161 | - * @param string $sort |
|
162 | - * @param string $order |
|
163 | - * @return array|bool |
|
164 | - */ |
|
165 | - public function getAllCategoriesArray($parentid = 0, $perm_name = false, $sort = 'parentid', $order = 'ASC') |
|
166 | - { |
|
167 | - if (!$this->allCategoriesObj) { |
|
168 | - $criteria = new CriteriaCompo(); |
|
169 | - $criteria->setSort($sort); |
|
170 | - $criteria->setOrder($order); |
|
171 | - global $xoopsUser; |
|
172 | - $userIsAdmin = is_object($xoopsUser) && $xoopsUser->isAdmin(); |
|
173 | - |
|
174 | - if ($perm_name && !$userIsAdmin) { |
|
175 | - if (!$this->setGrantedObjectsCriteria($criteria, $perm_name)) { |
|
176 | - return false; |
|
177 | - } |
|
178 | - } |
|
179 | - |
|
180 | - $this->allCategoriesObj = $this->getObjects($criteria, 'parentid'); |
|
181 | - } |
|
182 | - |
|
183 | - $ret = array(); |
|
184 | - if (isset($this->allCategoriesObj[$parentid])) { |
|
185 | - foreach ($this->allCategoriesObj[$parentid] as $categoryid => $categoryObj) { |
|
186 | - $ret[$categoryid]['self'] = $categoryObj->toArray(); |
|
187 | - if (isset($this->allCategoriesObj[$categoryid])) { |
|
188 | - $ret[$categoryid]['sub'] = $this->getAllCategoriesArray($categoryid); |
|
189 | - $ret[$categoryid]['subcatscount'] = count($ret[$categoryid]['sub']); |
|
190 | - } |
|
191 | - } |
|
192 | - } |
|
193 | - |
|
194 | - return $ret; |
|
195 | - } |
|
196 | - |
|
197 | - /** |
|
198 | - * @param $parentid |
|
199 | - * @param bool $asString |
|
200 | - * @return array|string |
|
201 | - */ |
|
202 | - public function getParentIds($parentid, $asString = true) |
|
203 | - { |
|
204 | - if (!$this->allCategoriesId) { |
|
205 | - $ret = array(); |
|
206 | - $sql = 'SELECT categoryid, parentid FROM ' . $this->table . ' AS ' . $this->_itemname . ' ORDER BY parentid'; |
|
207 | - |
|
208 | - $result = $this->db->query($sql); |
|
209 | - |
|
210 | - if (!$result) { |
|
211 | - return $ret; |
|
212 | - } |
|
213 | - |
|
214 | - while ($myrow = $this->db->fetchArray($result)) { |
|
215 | - $this->allCategoriesId[$myrow['categoryid']] = $myrow['parentid']; |
|
216 | - } |
|
217 | - } |
|
218 | - |
|
219 | - $retArray = array($parentid); |
|
220 | - while ($parentid != 0) { |
|
221 | - $parentid = $this->allCategoriesId[$parentid]; |
|
222 | - if ($parentid != 0) { |
|
223 | - $retArray[] = $parentid; |
|
224 | - } |
|
225 | - } |
|
226 | - if ($asString) { |
|
227 | - return implode(', ', $retArray); |
|
228 | - } else { |
|
229 | - return $retArray; |
|
230 | - } |
|
231 | - } |
|
145 | + public $allCategoriesObj = false; |
|
146 | + public $_allCategoriesId = false; |
|
147 | + |
|
148 | + /** |
|
149 | + * SmartobjectCategoryHandler constructor. |
|
150 | + * @param XoopsDatabase $db |
|
151 | + * @param $modulename |
|
152 | + */ |
|
153 | + public function __construct(XoopsDatabase $db, $modulename) |
|
154 | + { |
|
155 | + parent::__construct($db, 'category', 'categoryid', 'name', 'description', $modulename); |
|
156 | + } |
|
157 | + |
|
158 | + /** |
|
159 | + * @param int $parentid |
|
160 | + * @param bool $perm_name |
|
161 | + * @param string $sort |
|
162 | + * @param string $order |
|
163 | + * @return array|bool |
|
164 | + */ |
|
165 | + public function getAllCategoriesArray($parentid = 0, $perm_name = false, $sort = 'parentid', $order = 'ASC') |
|
166 | + { |
|
167 | + if (!$this->allCategoriesObj) { |
|
168 | + $criteria = new CriteriaCompo(); |
|
169 | + $criteria->setSort($sort); |
|
170 | + $criteria->setOrder($order); |
|
171 | + global $xoopsUser; |
|
172 | + $userIsAdmin = is_object($xoopsUser) && $xoopsUser->isAdmin(); |
|
173 | + |
|
174 | + if ($perm_name && !$userIsAdmin) { |
|
175 | + if (!$this->setGrantedObjectsCriteria($criteria, $perm_name)) { |
|
176 | + return false; |
|
177 | + } |
|
178 | + } |
|
179 | + |
|
180 | + $this->allCategoriesObj = $this->getObjects($criteria, 'parentid'); |
|
181 | + } |
|
182 | + |
|
183 | + $ret = array(); |
|
184 | + if (isset($this->allCategoriesObj[$parentid])) { |
|
185 | + foreach ($this->allCategoriesObj[$parentid] as $categoryid => $categoryObj) { |
|
186 | + $ret[$categoryid]['self'] = $categoryObj->toArray(); |
|
187 | + if (isset($this->allCategoriesObj[$categoryid])) { |
|
188 | + $ret[$categoryid]['sub'] = $this->getAllCategoriesArray($categoryid); |
|
189 | + $ret[$categoryid]['subcatscount'] = count($ret[$categoryid]['sub']); |
|
190 | + } |
|
191 | + } |
|
192 | + } |
|
193 | + |
|
194 | + return $ret; |
|
195 | + } |
|
196 | + |
|
197 | + /** |
|
198 | + * @param $parentid |
|
199 | + * @param bool $asString |
|
200 | + * @return array|string |
|
201 | + */ |
|
202 | + public function getParentIds($parentid, $asString = true) |
|
203 | + { |
|
204 | + if (!$this->allCategoriesId) { |
|
205 | + $ret = array(); |
|
206 | + $sql = 'SELECT categoryid, parentid FROM ' . $this->table . ' AS ' . $this->_itemname . ' ORDER BY parentid'; |
|
207 | + |
|
208 | + $result = $this->db->query($sql); |
|
209 | + |
|
210 | + if (!$result) { |
|
211 | + return $ret; |
|
212 | + } |
|
213 | + |
|
214 | + while ($myrow = $this->db->fetchArray($result)) { |
|
215 | + $this->allCategoriesId[$myrow['categoryid']] = $myrow['parentid']; |
|
216 | + } |
|
217 | + } |
|
218 | + |
|
219 | + $retArray = array($parentid); |
|
220 | + while ($parentid != 0) { |
|
221 | + $parentid = $this->allCategoriesId[$parentid]; |
|
222 | + if ($parentid != 0) { |
|
223 | + $retArray[] = $parentid; |
|
224 | + } |
|
225 | + } |
|
226 | + if ($asString) { |
|
227 | + return implode(', ', $retArray); |
|
228 | + } else { |
|
229 | + return $retArray; |
|
230 | + } |
|
231 | + } |
|
232 | 232 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
14 | -include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartseoobject.php'; |
|
14 | +include_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartseoobject.php'; |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * Class SmartobjectCategory |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | global $myts; |
96 | 96 | $objectArray = parent::toArray(); |
97 | 97 | if ($objectArray['image']) { |
98 | - $objectArray['image'] = $this->getImageDir() . $objectArray['image']; |
|
98 | + $objectArray['image'] = $this->getImageDir().$objectArray['image']; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | return $objectArray; |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function getCategoryPath($withAllLink = true, $currentCategory = false) |
113 | 113 | { |
114 | - include_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectcontroller.php'; |
|
114 | + include_once SMARTOBJECT_ROOT_PATH.'class/smartobjectcontroller.php'; |
|
115 | 115 | $controller = new SmartObjectController($this->handler); |
116 | 116 | |
117 | 117 | if (!$this->_categoryPath) { |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | exit; |
129 | 129 | } |
130 | 130 | $parentid = $parentObj->getVar('parentid'); |
131 | - $ret = $parentObj->getCategoryPath($withAllLink, $currentCategory) . ' > ' . $ret; |
|
131 | + $ret = $parentObj->getCategoryPath($withAllLink, $currentCategory).' > '.$ret; |
|
132 | 132 | } |
133 | 133 | $this->_categoryPath = $ret; |
134 | 134 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | { |
204 | 204 | if (!$this->allCategoriesId) { |
205 | 205 | $ret = array(); |
206 | - $sql = 'SELECT categoryid, parentid FROM ' . $this->table . ' AS ' . $this->_itemname . ' ORDER BY parentid'; |
|
206 | + $sql = 'SELECT categoryid, parentid FROM '.$this->table.' AS '.$this->_itemname.' ORDER BY parentid'; |
|
207 | 207 | |
208 | 208 | $result = $this->db->query($sql); |
209 | 209 |
@@ -89,51 +89,51 @@ |
||
89 | 89 | */ |
90 | 90 | class SmartUploader extends XoopsMediaUploader |
91 | 91 | { |
92 | - public $ext; |
|
93 | - public $dimension; |
|
92 | + public $ext; |
|
93 | + public $dimension; |
|
94 | 94 | |
95 | - /** |
|
96 | - * No admin check for uploads |
|
97 | - */ |
|
98 | - public $noAdminSizeCheck; |
|
95 | + /** |
|
96 | + * No admin check for uploads |
|
97 | + */ |
|
98 | + public $noAdminSizeCheck; |
|
99 | 99 | |
100 | - /** |
|
101 | - * Constructor |
|
102 | - * |
|
103 | - * @param string $uploadDir |
|
104 | - * @param array|int $allowedMimeTypes |
|
105 | - * @param int $maxFileSize |
|
106 | - * @param int $maxWidth |
|
107 | - * @param int $maxHeight |
|
108 | - * @internal param int $cmodvalue |
|
109 | - */ |
|
110 | - public function __construct($uploadDir, $allowedMimeTypes = 0, $maxFileSize, $maxWidth = 0, $maxHeight = 0) |
|
111 | - { |
|
112 | - parent::__construct($uploadDir, $allowedMimeTypes, $maxFileSize, $maxWidth, $maxHeight); |
|
113 | - } |
|
100 | + /** |
|
101 | + * Constructor |
|
102 | + * |
|
103 | + * @param string $uploadDir |
|
104 | + * @param array|int $allowedMimeTypes |
|
105 | + * @param int $maxFileSize |
|
106 | + * @param int $maxWidth |
|
107 | + * @param int $maxHeight |
|
108 | + * @internal param int $cmodvalue |
|
109 | + */ |
|
110 | + public function __construct($uploadDir, $allowedMimeTypes = 0, $maxFileSize, $maxWidth = 0, $maxHeight = 0) |
|
111 | + { |
|
112 | + parent::__construct($uploadDir, $allowedMimeTypes, $maxFileSize, $maxWidth, $maxHeight); |
|
113 | + } |
|
114 | 114 | |
115 | - /** |
|
116 | - * @param $value |
|
117 | - */ |
|
118 | - public function noAdminSizeCheck($value) |
|
119 | - { |
|
120 | - $this->noAdminSizeCheck = $value; |
|
121 | - } |
|
115 | + /** |
|
116 | + * @param $value |
|
117 | + */ |
|
118 | + public function noAdminSizeCheck($value) |
|
119 | + { |
|
120 | + $this->noAdminSizeCheck = $value; |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * Is the file the right size? |
|
125 | - * |
|
126 | - * @return bool |
|
127 | - */ |
|
128 | - public function checkMaxFileSize() |
|
129 | - { |
|
130 | - if ($this->noAdminSizeCheck) { |
|
131 | - return true; |
|
132 | - } |
|
133 | - if ($this->mediaSize > $this->maxFileSize) { |
|
134 | - return false; |
|
135 | - } |
|
123 | + /** |
|
124 | + * Is the file the right size? |
|
125 | + * |
|
126 | + * @return bool |
|
127 | + */ |
|
128 | + public function checkMaxFileSize() |
|
129 | + { |
|
130 | + if ($this->noAdminSizeCheck) { |
|
131 | + return true; |
|
132 | + } |
|
133 | + if ($this->mediaSize > $this->maxFileSize) { |
|
134 | + return false; |
|
135 | + } |
|
136 | 136 | |
137 | - return true; |
|
138 | - } |
|
137 | + return true; |
|
138 | + } |
|
139 | 139 | } |
@@ -80,9 +80,9 @@ |
||
80 | 80 | * @link http://smartfactory.ca The SmartFactory |
81 | 81 | * @package SmartObject |
82 | 82 | */ |
83 | -mt_srand((double)microtime() * 1000000); |
|
83 | +mt_srand((double) microtime() * 1000000); |
|
84 | 84 | |
85 | -include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
85 | +include_once XOOPS_ROOT_PATH.'/class/uploader.php'; |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * Class SmartUploader |
@@ -6,44 +6,44 @@ |
||
6 | 6 | */ |
7 | 7 | class SmartHookHandler |
8 | 8 | { |
9 | - /** |
|
10 | - * SmartHookHandler constructor. |
|
11 | - */ |
|
12 | - public function __construct() |
|
13 | - { |
|
14 | - } |
|
9 | + /** |
|
10 | + * SmartHookHandler constructor. |
|
11 | + */ |
|
12 | + public function __construct() |
|
13 | + { |
|
14 | + } |
|
15 | 15 | |
16 | - /** |
|
17 | - * Access the only instance of this class |
|
18 | - * |
|
19 | - * @return XoopsObject |
|
20 | - * |
|
21 | - * @static |
|
22 | - * @staticvar object |
|
23 | - */ |
|
24 | - public static function getInstance() |
|
25 | - { |
|
26 | - static $instance; |
|
27 | - if (null === $instance) { |
|
28 | - $instance = new static(); |
|
29 | - } |
|
16 | + /** |
|
17 | + * Access the only instance of this class |
|
18 | + * |
|
19 | + * @return XoopsObject |
|
20 | + * |
|
21 | + * @static |
|
22 | + * @staticvar object |
|
23 | + */ |
|
24 | + public static function getInstance() |
|
25 | + { |
|
26 | + static $instance; |
|
27 | + if (null === $instance) { |
|
28 | + $instance = new static(); |
|
29 | + } |
|
30 | 30 | |
31 | - return $instance; |
|
32 | - } |
|
31 | + return $instance; |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * @param $hook_name |
|
36 | - */ |
|
37 | - public function executeHook($hook_name) |
|
38 | - { |
|
39 | - $lower_hook_name = strtolower($hook_name); |
|
40 | - $filename = SMARTOBJECT_ROOT_PATH . 'include/custom_code/' . $lower_hook_name . '.php'; |
|
41 | - if (file_exists($filename)) { |
|
42 | - include_once($filename); |
|
43 | - $function = 'smarthook_' . $lower_hook_name; |
|
44 | - if (function_exists($function)) { |
|
45 | - $function(); |
|
46 | - } |
|
47 | - } |
|
48 | - } |
|
34 | + /** |
|
35 | + * @param $hook_name |
|
36 | + */ |
|
37 | + public function executeHook($hook_name) |
|
38 | + { |
|
39 | + $lower_hook_name = strtolower($hook_name); |
|
40 | + $filename = SMARTOBJECT_ROOT_PATH . 'include/custom_code/' . $lower_hook_name . '.php'; |
|
41 | + if (file_exists($filename)) { |
|
42 | + include_once($filename); |
|
43 | + $function = 'smarthook_' . $lower_hook_name; |
|
44 | + if (function_exists($function)) { |
|
45 | + $function(); |
|
46 | + } |
|
47 | + } |
|
48 | + } |
|
49 | 49 | } |
@@ -37,10 +37,10 @@ |
||
37 | 37 | public function executeHook($hook_name) |
38 | 38 | { |
39 | 39 | $lower_hook_name = strtolower($hook_name); |
40 | - $filename = SMARTOBJECT_ROOT_PATH . 'include/custom_code/' . $lower_hook_name . '.php'; |
|
40 | + $filename = SMARTOBJECT_ROOT_PATH.'include/custom_code/'.$lower_hook_name.'.php'; |
|
41 | 41 | if (file_exists($filename)) { |
42 | 42 | include_once($filename); |
43 | - $function = 'smarthook_' . $lower_hook_name; |
|
43 | + $function = 'smarthook_'.$lower_hook_name; |
|
44 | 44 | if (function_exists($function)) { |
45 | 45 | $function(); |
46 | 46 | } |
@@ -35,19 +35,19 @@ discard block |
||
35 | 35 | */ |
36 | 36 | class SmartobjectTag extends SmartMlObject |
37 | 37 | { |
38 | - /** |
|
39 | - * SmartobjectTag constructor. |
|
40 | - */ |
|
41 | - public function __construct() |
|
42 | - { |
|
43 | - $this->initVar('tagid', XOBJ_DTYPE_INT, '', true); |
|
44 | - $this->initVar('name', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_TAG_TAGID_CAPTION, _CO_SOBJECT_TAG_TAGID_DSC, true); |
|
45 | - $this->initVar('description', XOBJ_DTYPE_TXTAREA, '', true, null, '', false, _CO_SOBJECT_TAG_DESCRIPTION_CAPTION, _CO_SOBJECT_TAG_DESCRIPTION_DSC); |
|
46 | - $this->initVar('value', XOBJ_DTYPE_TXTAREA, '', true, null, '', true, _CO_SOBJECT_TAG_VALUE_CAPTION, _CO_SOBJECT_TAG_VALUE_DSC); |
|
38 | + /** |
|
39 | + * SmartobjectTag constructor. |
|
40 | + */ |
|
41 | + public function __construct() |
|
42 | + { |
|
43 | + $this->initVar('tagid', XOBJ_DTYPE_INT, '', true); |
|
44 | + $this->initVar('name', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_TAG_TAGID_CAPTION, _CO_SOBJECT_TAG_TAGID_DSC, true); |
|
45 | + $this->initVar('description', XOBJ_DTYPE_TXTAREA, '', true, null, '', false, _CO_SOBJECT_TAG_DESCRIPTION_CAPTION, _CO_SOBJECT_TAG_DESCRIPTION_DSC); |
|
46 | + $this->initVar('value', XOBJ_DTYPE_TXTAREA, '', true, null, '', true, _CO_SOBJECT_TAG_VALUE_CAPTION, _CO_SOBJECT_TAG_VALUE_DSC); |
|
47 | 47 | |
48 | - // call parent constructor to get Multilanguage field initiated |
|
49 | - $this->SmartMlObject(); |
|
50 | - } |
|
48 | + // call parent constructor to get Multilanguage field initiated |
|
49 | + $this->SmartMlObject(); |
|
50 | + } |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -55,27 +55,27 @@ discard block |
||
55 | 55 | */ |
56 | 56 | class SmartobjectTagHandler extends SmartPersistableMlObjectHandler |
57 | 57 | { |
58 | - /** |
|
59 | - * SmartobjectTagHandler constructor. |
|
60 | - * @param XoopsDatabase $db |
|
61 | - */ |
|
62 | - public function __construct(XoopsDatabase $db) |
|
63 | - { |
|
64 | - parent::__construct($db, 'tag', 'tagid', 'name', 'description', 'smartobject'); |
|
65 | - } |
|
58 | + /** |
|
59 | + * SmartobjectTagHandler constructor. |
|
60 | + * @param XoopsDatabase $db |
|
61 | + */ |
|
62 | + public function __construct(XoopsDatabase $db) |
|
63 | + { |
|
64 | + parent::__construct($db, 'tag', 'tagid', 'name', 'description', 'smartobject'); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * @return mixed |
|
69 | - */ |
|
70 | - public function getLanguages() |
|
71 | - { |
|
72 | - include_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
|
73 | - $aLanguages = XoopsLists::getLangList(); |
|
74 | - $ret['default'] = _CO_SOBJECT_ALL; |
|
75 | - foreach ($aLanguages as $lang) { |
|
76 | - $ret[$lang] = $lang; |
|
77 | - } |
|
67 | + /** |
|
68 | + * @return mixed |
|
69 | + */ |
|
70 | + public function getLanguages() |
|
71 | + { |
|
72 | + include_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
|
73 | + $aLanguages = XoopsLists::getLangList(); |
|
74 | + $ret['default'] = _CO_SOBJECT_ALL; |
|
75 | + foreach ($aLanguages as $lang) { |
|
76 | + $ret[$lang] = $lang; |
|
77 | + } |
|
78 | 78 | |
79 | - return $ret; |
|
80 | - } |
|
79 | + return $ret; |
|
80 | + } |
|
81 | 81 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | // -------------------------------------------------------------------------// |
29 | 29 | |
30 | 30 | // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
31 | -include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartmlobject.php'; |
|
31 | +include_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartmlobject.php'; |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Class SmartobjectTag |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function getLanguages() |
71 | 71 | { |
72 | - include_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
|
72 | + include_once XOOPS_ROOT_PATH.'/class/xoopslists.php'; |
|
73 | 73 | $aLanguages = XoopsLists::getLangList(); |
74 | 74 | $ret['default'] = _CO_SOBJECT_ALL; |
75 | 75 | foreach ($aLanguages as $lang) { |
@@ -12,23 +12,23 @@ |
||
12 | 12 | |
13 | 13 | class SmartFormUser_sigElement extends XoopsFormElementTray |
14 | 14 | { |
15 | - /** |
|
16 | - * SmartFormUser_sigElement constructor. |
|
17 | - * @param string $object |
|
18 | - * @param string $key |
|
19 | - */ |
|
20 | - public function __construct($object, $key) |
|
21 | - { |
|
22 | - $var = $object->vars[$key]; |
|
23 | - $control = $object->controls[$key]; |
|
15 | + /** |
|
16 | + * SmartFormUser_sigElement constructor. |
|
17 | + * @param string $object |
|
18 | + * @param string $key |
|
19 | + */ |
|
20 | + public function __construct($object, $key) |
|
21 | + { |
|
22 | + $var = $object->vars[$key]; |
|
23 | + $control = $object->controls[$key]; |
|
24 | 24 | |
25 | - parent::__construct($var['form_caption'], '<br><br>', $key . '_signature_tray'); |
|
25 | + parent::__construct($var['form_caption'], '<br><br>', $key . '_signature_tray'); |
|
26 | 26 | |
27 | - $signature_textarea = new XoopsFormDhtmlTextArea('', $key, $object->getVar($key, 'e')); |
|
28 | - $this->addElement($signature_textarea); |
|
27 | + $signature_textarea = new XoopsFormDhtmlTextArea('', $key, $object->getVar($key, 'e')); |
|
28 | + $this->addElement($signature_textarea); |
|
29 | 29 | |
30 | - $attach_checkbox = new XoopsFormCheckBox('', 'attachsig', $object->getVar('attachsig', 'e')); |
|
31 | - $attach_checkbox->addOption(1, _US_SHOWSIG); |
|
32 | - $this->addElement($attach_checkbox); |
|
33 | - } |
|
30 | + $attach_checkbox = new XoopsFormCheckBox('', 'attachsig', $object->getVar('attachsig', 'e')); |
|
31 | + $attach_checkbox->addOption(1, _US_SHOWSIG); |
|
32 | + $this->addElement($attach_checkbox); |
|
33 | + } |
|
34 | 34 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | $var = $object->vars[$key]; |
23 | 23 | $control = $object->controls[$key]; |
24 | 24 | |
25 | - parent::__construct($var['form_caption'], '<br><br>', $key . '_signature_tray'); |
|
25 | + parent::__construct($var['form_caption'], '<br><br>', $key.'_signature_tray'); |
|
26 | 26 | |
27 | 27 | $signature_textarea = new XoopsFormDhtmlTextArea('', $key, $object->getVar($key, 'e')); |
28 | 28 | $this->addElement($signature_textarea); |