@@ -19,27 +19,27 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class SmartFormImageUploadElement extends Smartobject\Form\Elements\SmartFormUploadElement |
| 21 | 21 | { |
| 22 | - /** |
|
| 23 | - * SmartFormImageUploadElement constructor. |
|
| 24 | - * @param string $object |
|
| 25 | - * @param string $key |
|
| 26 | - */ |
|
| 27 | - public function __construct($object, $key) |
|
| 28 | - { |
|
| 29 | - $this->SmartFormFileElement($object, $key); |
|
| 30 | - // Override name for upload purposes |
|
| 31 | - $this->setName('upload_' . $key); |
|
| 32 | - } |
|
| 22 | + /** |
|
| 23 | + * SmartFormImageUploadElement constructor. |
|
| 24 | + * @param string $object |
|
| 25 | + * @param string $key |
|
| 26 | + */ |
|
| 27 | + public function __construct($object, $key) |
|
| 28 | + { |
|
| 29 | + $this->SmartFormFileElement($object, $key); |
|
| 30 | + // Override name for upload purposes |
|
| 31 | + $this->setName('upload_' . $key); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * prepare HTML for output |
|
| 36 | - * |
|
| 37 | - * @return string HTML |
|
| 38 | - */ |
|
| 39 | - public function render() |
|
| 40 | - { |
|
| 41 | - return "<input type='hidden' name='MAX_FILE_SIZE' value='" . $this->getMaxFileSize() . "'> |
|
| 34 | + /** |
|
| 35 | + * prepare HTML for output |
|
| 36 | + * |
|
| 37 | + * @return string HTML |
|
| 38 | + */ |
|
| 39 | + public function render() |
|
| 40 | + { |
|
| 41 | + return "<input type='hidden' name='MAX_FILE_SIZE' value='" . $this->getMaxFileSize() . "'> |
|
| 42 | 42 | <input type='file' name='" . $this->getName() . "' id='" . $this->getName() . "'" . $this->getExtra() . "> |
| 43 | 43 | <input type='hidden' name='smart_upload_image[]' id='smart_upload_image[]' value='" . $this->getName() . "'>"; |
| 44 | - } |
|
| 44 | + } |
|
| 45 | 45 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | { |
| 29 | 29 | $this->SmartFormFileElement($object, $key); |
| 30 | 30 | // Override name for upload purposes |
| 31 | - $this->setName('upload_' . $key); |
|
| 31 | + $this->setName('upload_'.$key); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function render() |
| 40 | 40 | { |
| 41 | - return "<input type='hidden' name='MAX_FILE_SIZE' value='" . $this->getMaxFileSize() . "'> |
|
| 42 | - <input type='file' name='" . $this->getName() . "' id='" . $this->getName() . "'" . $this->getExtra() . "> |
|
| 43 | - <input type='hidden' name='smart_upload_image[]' id='smart_upload_image[]' value='" . $this->getName() . "'>"; |
|
| 41 | + return "<input type='hidden' name='MAX_FILE_SIZE' value='".$this->getMaxFileSize()."'> |
|
| 42 | + <input type='file' name='" . $this->getName()."' id='".$this->getName()."'".$this->getExtra()."> |
|
| 43 | + <input type='hidden' name='smart_upload_image[]' id='smart_upload_image[]' value='" . $this->getName()."'>"; |
|
| 44 | 44 | } |
| 45 | 45 | } |
@@ -18,36 +18,36 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class SmartFormUserElement extends \XoopsFormSelect |
| 20 | 20 | { |
| 21 | - public $multiple = false; |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * SmartFormUserElement constructor. |
|
| 25 | - * @param string $object |
|
| 26 | - * @param string $key |
|
| 27 | - */ |
|
| 28 | - public function __construct($object, $key) |
|
| 29 | - { |
|
| 30 | - $var = $object->vars[$key]; |
|
| 31 | - $size = isset($var['size']) ? $var['size'] : ($this->multiple ? 5 : 1); |
|
| 32 | - |
|
| 33 | - parent::__construct($var['form_caption'], $key, $object->getVar($key, 'e'), $size, $this->multiple); |
|
| 34 | - |
|
| 35 | - // Adding the options inside this SelectBox |
|
| 36 | - // If the custom method is not from a module, than it's from the core |
|
| 37 | - $control = $object->getControl($key); |
|
| 38 | - |
|
| 39 | - global $xoopsDB; |
|
| 40 | - $ret = []; |
|
| 41 | - $limit = $start = 0; |
|
| 42 | - $sql = 'SELECT uid, uname FROM ' . $xoopsDB->prefix('users'); |
|
| 43 | - $sql .= ' ORDER BY uname ASC'; |
|
| 44 | - |
|
| 45 | - $result = $xoopsDB->query($sql); |
|
| 46 | - if ($result) { |
|
| 47 | - while (false !== ($myrow = $xoopsDB->fetchArray($result))) { |
|
| 48 | - $uArray[$myrow['uid']] = $myrow['uname']; |
|
| 49 | - } |
|
| 50 | - } |
|
| 51 | - $this->addOptionArray($uArray); |
|
| 52 | - } |
|
| 21 | + public $multiple = false; |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * SmartFormUserElement constructor. |
|
| 25 | + * @param string $object |
|
| 26 | + * @param string $key |
|
| 27 | + */ |
|
| 28 | + public function __construct($object, $key) |
|
| 29 | + { |
|
| 30 | + $var = $object->vars[$key]; |
|
| 31 | + $size = isset($var['size']) ? $var['size'] : ($this->multiple ? 5 : 1); |
|
| 32 | + |
|
| 33 | + parent::__construct($var['form_caption'], $key, $object->getVar($key, 'e'), $size, $this->multiple); |
|
| 34 | + |
|
| 35 | + // Adding the options inside this SelectBox |
|
| 36 | + // If the custom method is not from a module, than it's from the core |
|
| 37 | + $control = $object->getControl($key); |
|
| 38 | + |
|
| 39 | + global $xoopsDB; |
|
| 40 | + $ret = []; |
|
| 41 | + $limit = $start = 0; |
|
| 42 | + $sql = 'SELECT uid, uname FROM ' . $xoopsDB->prefix('users'); |
|
| 43 | + $sql .= ' ORDER BY uname ASC'; |
|
| 44 | + |
|
| 45 | + $result = $xoopsDB->query($sql); |
|
| 46 | + if ($result) { |
|
| 47 | + while (false !== ($myrow = $xoopsDB->fetchArray($result))) { |
|
| 48 | + $uArray[$myrow['uid']] = $myrow['uname']; |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | + $this->addOptionArray($uArray); |
|
| 52 | + } |
|
| 53 | 53 | } |
@@ -18,59 +18,59 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class SmartFormSelectElement extends \XoopsFormSelect |
| 20 | 20 | { |
| 21 | - public $multiple = false; |
|
| 21 | + public $multiple = false; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * SmartFormSelectElement constructor. |
|
| 25 | - * @param string $object |
|
| 26 | - * @param string $key |
|
| 27 | - */ |
|
| 28 | - public function __construct($object, $key) |
|
| 29 | - { |
|
| 30 | - $var = $object->vars[$key]; |
|
| 31 | - $size = isset($var['size']) ? $var['size'] : ($this->multiple ? 5 : 1); |
|
| 23 | + /** |
|
| 24 | + * SmartFormSelectElement constructor. |
|
| 25 | + * @param string $object |
|
| 26 | + * @param string $key |
|
| 27 | + */ |
|
| 28 | + public function __construct($object, $key) |
|
| 29 | + { |
|
| 30 | + $var = $object->vars[$key]; |
|
| 31 | + $size = isset($var['size']) ? $var['size'] : ($this->multiple ? 5 : 1); |
|
| 32 | 32 | |
| 33 | - // Adding the options inside this SelectBox |
|
| 34 | - // If the custom method is not from a module, than it's from the core |
|
| 35 | - $control = $object->getControl($key); |
|
| 33 | + // Adding the options inside this SelectBox |
|
| 34 | + // If the custom method is not from a module, than it's from the core |
|
| 35 | + $control = $object->getControl($key); |
|
| 36 | 36 | |
| 37 | - $value = isset($control['value']) ? $control['value'] : $object->getVar($key, 'e'); |
|
| 37 | + $value = isset($control['value']) ? $control['value'] : $object->getVar($key, 'e'); |
|
| 38 | 38 | |
| 39 | - parent::__construct($var['form_caption'], $key, $value, $size, $this->multiple); |
|
| 39 | + parent::__construct($var['form_caption'], $key, $value, $size, $this->multiple); |
|
| 40 | 40 | |
| 41 | - if (isset($control['options'])) { |
|
| 42 | - $this->addOptionArray($control['options']); |
|
| 43 | - } else { |
|
| 44 | - // let's find if the method we need to call comes from an already defined object |
|
| 45 | - if (isset($control['object'])) { |
|
| 46 | - if (method_exists($control['object'], $control['method'])) { |
|
| 47 | - if ($option_array = $control['object']->{$control['method']}()) { |
|
| 48 | - // Adding the options array to the XoopsFormSelect |
|
| 49 | - $this->addOptionArray($option_array); |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - } else { |
|
| 53 | - // finding the itemHandler; if none, let's take the itemHandler of the $object |
|
| 54 | - if (isset($control['itemHandler'])) { |
|
| 55 | - if (!$control['module']) { |
|
| 56 | - // Creating the specified core object handler |
|
| 57 | - $controlHandler = xoops_getHandler($control['itemHandler']); |
|
| 58 | - } else { |
|
| 59 | - $controlHandler = xoops_getModuleHandler($control['itemHandler'], $control['module']); |
|
| 60 | - } |
|
| 61 | - } else { |
|
| 62 | - $controlHandler = $object->handler; |
|
| 63 | - } |
|
| 41 | + if (isset($control['options'])) { |
|
| 42 | + $this->addOptionArray($control['options']); |
|
| 43 | + } else { |
|
| 44 | + // let's find if the method we need to call comes from an already defined object |
|
| 45 | + if (isset($control['object'])) { |
|
| 46 | + if (method_exists($control['object'], $control['method'])) { |
|
| 47 | + if ($option_array = $control['object']->{$control['method']}()) { |
|
| 48 | + // Adding the options array to the XoopsFormSelect |
|
| 49 | + $this->addOptionArray($option_array); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + } else { |
|
| 53 | + // finding the itemHandler; if none, let's take the itemHandler of the $object |
|
| 54 | + if (isset($control['itemHandler'])) { |
|
| 55 | + if (!$control['module']) { |
|
| 56 | + // Creating the specified core object handler |
|
| 57 | + $controlHandler = xoops_getHandler($control['itemHandler']); |
|
| 58 | + } else { |
|
| 59 | + $controlHandler = xoops_getModuleHandler($control['itemHandler'], $control['module']); |
|
| 60 | + } |
|
| 61 | + } else { |
|
| 62 | + $controlHandler = $object->handler; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - // Checking if the specified method exists |
|
| 66 | - if (method_exists($controlHandler, $control['method'])) { |
|
| 67 | - // TODO: How could I pass the parameters in the following call ... |
|
| 68 | - if ($option_array = $controlHandler->{$control['method']}()) { |
|
| 69 | - // Adding the options array to the XoopsFormSelect |
|
| 70 | - $this->addOptionArray($option_array); |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - } |
|
| 65 | + // Checking if the specified method exists |
|
| 66 | + if (method_exists($controlHandler, $control['method'])) { |
|
| 67 | + // TODO: How could I pass the parameters in the following call ... |
|
| 68 | + if ($option_array = $controlHandler->{$control['method']}()) { |
|
| 69 | + // Adding the options array to the XoopsFormSelect |
|
| 70 | + $this->addOptionArray($option_array); |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | 76 | } |
@@ -18,31 +18,31 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class SmartFormUrlLinkElement extends \XoopsFormElementTray |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * SmartFormUrlLinkElement constructor. |
|
| 23 | - * @param string $form_caption |
|
| 24 | - * @param string $key |
|
| 25 | - * @param string $object |
|
| 26 | - */ |
|
| 27 | - public function __construct($form_caption, $key, $object) |
|
| 28 | - { |
|
| 29 | - parent::__construct($form_caption, ' '); |
|
| 30 | - |
|
| 31 | - $this->addElement(new \XoopsFormLabel('', '<br>' . _CO_SOBJECT_URLLINK_URL)); |
|
| 32 | - $this->addElement(new SmartFormTextElement($object, 'url_' . $key)); |
|
| 33 | - |
|
| 34 | - $this->addElement(new \XoopsFormLabel('', '<br>' . _CO_SOBJECT_CAPTION)); |
|
| 35 | - $this->addElement(new SmartFormTextElement($object, 'caption_' . $key)); |
|
| 36 | - |
|
| 37 | - $this->addElement(new \XoopsFormLabel('', '<br>' . _CO_SOBJECT_DESC . '<br>')); |
|
| 38 | - $this->addElement(new \XoopsFormTextArea('', 'desc_' . $key, $object->getVar('description'))); |
|
| 39 | - |
|
| 40 | - $this->addElement(new \XoopsFormLabel('', '<br>' . _CO_SOBJECT_URLLINK_TARGET)); |
|
| 41 | - $targ_val = $object->getVar('target'); |
|
| 42 | - $targetRadio = new \XoopsFormRadio('', 'target_' . $key, '' !== $targ_val ? $targ_val : '_blank'); |
|
| 43 | - $control = $object->getControl('target'); |
|
| 44 | - $targetRadio->addOptionArray($control['options']); |
|
| 45 | - |
|
| 46 | - $this->addElement($targetRadio); |
|
| 47 | - } |
|
| 21 | + /** |
|
| 22 | + * SmartFormUrlLinkElement constructor. |
|
| 23 | + * @param string $form_caption |
|
| 24 | + * @param string $key |
|
| 25 | + * @param string $object |
|
| 26 | + */ |
|
| 27 | + public function __construct($form_caption, $key, $object) |
|
| 28 | + { |
|
| 29 | + parent::__construct($form_caption, ' '); |
|
| 30 | + |
|
| 31 | + $this->addElement(new \XoopsFormLabel('', '<br>' . _CO_SOBJECT_URLLINK_URL)); |
|
| 32 | + $this->addElement(new SmartFormTextElement($object, 'url_' . $key)); |
|
| 33 | + |
|
| 34 | + $this->addElement(new \XoopsFormLabel('', '<br>' . _CO_SOBJECT_CAPTION)); |
|
| 35 | + $this->addElement(new SmartFormTextElement($object, 'caption_' . $key)); |
|
| 36 | + |
|
| 37 | + $this->addElement(new \XoopsFormLabel('', '<br>' . _CO_SOBJECT_DESC . '<br>')); |
|
| 38 | + $this->addElement(new \XoopsFormTextArea('', 'desc_' . $key, $object->getVar('description'))); |
|
| 39 | + |
|
| 40 | + $this->addElement(new \XoopsFormLabel('', '<br>' . _CO_SOBJECT_URLLINK_TARGET)); |
|
| 41 | + $targ_val = $object->getVar('target'); |
|
| 42 | + $targetRadio = new \XoopsFormRadio('', 'target_' . $key, '' !== $targ_val ? $targ_val : '_blank'); |
|
| 43 | + $control = $object->getControl('target'); |
|
| 44 | + $targetRadio->addOptionArray($control['options']); |
|
| 45 | + |
|
| 46 | + $this->addElement($targetRadio); |
|
| 47 | + } |
|
| 48 | 48 | } |
@@ -28,18 +28,18 @@ |
||
| 28 | 28 | { |
| 29 | 29 | parent::__construct($form_caption, ' '); |
| 30 | 30 | |
| 31 | - $this->addElement(new \XoopsFormLabel('', '<br>' . _CO_SOBJECT_URLLINK_URL)); |
|
| 32 | - $this->addElement(new SmartFormTextElement($object, 'url_' . $key)); |
|
| 31 | + $this->addElement(new \XoopsFormLabel('', '<br>'._CO_SOBJECT_URLLINK_URL)); |
|
| 32 | + $this->addElement(new SmartFormTextElement($object, 'url_'.$key)); |
|
| 33 | 33 | |
| 34 | - $this->addElement(new \XoopsFormLabel('', '<br>' . _CO_SOBJECT_CAPTION)); |
|
| 35 | - $this->addElement(new SmartFormTextElement($object, 'caption_' . $key)); |
|
| 34 | + $this->addElement(new \XoopsFormLabel('', '<br>'._CO_SOBJECT_CAPTION)); |
|
| 35 | + $this->addElement(new SmartFormTextElement($object, 'caption_'.$key)); |
|
| 36 | 36 | |
| 37 | - $this->addElement(new \XoopsFormLabel('', '<br>' . _CO_SOBJECT_DESC . '<br>')); |
|
| 38 | - $this->addElement(new \XoopsFormTextArea('', 'desc_' . $key, $object->getVar('description'))); |
|
| 37 | + $this->addElement(new \XoopsFormLabel('', '<br>'._CO_SOBJECT_DESC.'<br>')); |
|
| 38 | + $this->addElement(new \XoopsFormTextArea('', 'desc_'.$key, $object->getVar('description'))); |
|
| 39 | 39 | |
| 40 | - $this->addElement(new \XoopsFormLabel('', '<br>' . _CO_SOBJECT_URLLINK_TARGET)); |
|
| 40 | + $this->addElement(new \XoopsFormLabel('', '<br>'._CO_SOBJECT_URLLINK_TARGET)); |
|
| 41 | 41 | $targ_val = $object->getVar('target'); |
| 42 | - $targetRadio = new \XoopsFormRadio('', 'target_' . $key, '' !== $targ_val ? $targ_val : '_blank'); |
|
| 42 | + $targetRadio = new \XoopsFormRadio('', 'target_'.$key, '' !== $targ_val ? $targ_val : '_blank'); |
|
| 43 | 43 | $control = $object->getControl('target'); |
| 44 | 44 | $targetRadio->addOptionArray($control['options']); |
| 45 | 45 | |
@@ -26,20 +26,20 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | class SmartFormHidden extends \XoopsFormHidden |
| 28 | 28 | { |
| 29 | - /** |
|
| 30 | - * @return string |
|
| 31 | - */ |
|
| 32 | - public function render() |
|
| 33 | - { |
|
| 34 | - if (is_array($this->getValue())) { |
|
| 35 | - $ret = ''; |
|
| 36 | - foreach ($this->getValue() as $value) { |
|
| 37 | - $ret .= "<input type='hidden' name='" . $this->getName() . "[]' id='" . $this->getName() . "' value='" . $value . "'>\n"; |
|
| 38 | - } |
|
| 39 | - } else { |
|
| 40 | - $ret = "<input type='hidden' name='" . $this->getName() . "' id='" . $this->getName() . "' value='" . $this->getValue() . "'>"; |
|
| 41 | - } |
|
| 29 | + /** |
|
| 30 | + * @return string |
|
| 31 | + */ |
|
| 32 | + public function render() |
|
| 33 | + { |
|
| 34 | + if (is_array($this->getValue())) { |
|
| 35 | + $ret = ''; |
|
| 36 | + foreach ($this->getValue() as $value) { |
|
| 37 | + $ret .= "<input type='hidden' name='" . $this->getName() . "[]' id='" . $this->getName() . "' value='" . $value . "'>\n"; |
|
| 38 | + } |
|
| 39 | + } else { |
|
| 40 | + $ret = "<input type='hidden' name='" . $this->getName() . "' id='" . $this->getName() . "' value='" . $this->getValue() . "'>"; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - return $ret; |
|
| 44 | - } |
|
| 43 | + return $ret; |
|
| 44 | + } |
|
| 45 | 45 | } |
@@ -18,39 +18,39 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class SmartFormImageElement extends \XoopsFormElementTray |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * SmartFormImageElement constructor. |
|
| 23 | - * @param string $object |
|
| 24 | - * @param string $key |
|
| 25 | - */ |
|
| 26 | - public function __construct($object, $key) |
|
| 27 | - { |
|
| 28 | - $var = $object->vars[$key]; |
|
| 29 | - $object_imageurl = $object->getImageDir(); |
|
| 30 | - parent::__construct($var['form_caption'], ' '); |
|
| 31 | - |
|
| 32 | - $objectArray['image'] = str_replace('{XOOPS_URL}', XOOPS_URL, $objectArray['image']); |
|
| 33 | - |
|
| 34 | - if ('' !== $object->getVar($key) |
|
| 35 | - && (0 === strpos($object->getVar($key), 'http') |
|
| 36 | - || 0 === strpos($object->getVar($key), '{XOOPS_URL}'))) { |
|
| 37 | - $this->addElement(new \XoopsFormLabel('', "<img src='" . str_replace('{XOOPS_URL}', XOOPS_URL, $object->getVar($key)) . "' alt=''><br><br>")); |
|
| 38 | - } elseif ('' !== $object->getVar($key)) { |
|
| 39 | - $this->addElement(new \XoopsFormLabel('', "<img src='" . $object_imageurl . $object->getVar($key) . "' alt=''><br><br>")); |
|
| 40 | - } |
|
| 21 | + /** |
|
| 22 | + * SmartFormImageElement constructor. |
|
| 23 | + * @param string $object |
|
| 24 | + * @param string $key |
|
| 25 | + */ |
|
| 26 | + public function __construct($object, $key) |
|
| 27 | + { |
|
| 28 | + $var = $object->vars[$key]; |
|
| 29 | + $object_imageurl = $object->getImageDir(); |
|
| 30 | + parent::__construct($var['form_caption'], ' '); |
|
| 31 | + |
|
| 32 | + $objectArray['image'] = str_replace('{XOOPS_URL}', XOOPS_URL, $objectArray['image']); |
|
| 33 | + |
|
| 34 | + if ('' !== $object->getVar($key) |
|
| 35 | + && (0 === strpos($object->getVar($key), 'http') |
|
| 36 | + || 0 === strpos($object->getVar($key), '{XOOPS_URL}'))) { |
|
| 37 | + $this->addElement(new \XoopsFormLabel('', "<img src='" . str_replace('{XOOPS_URL}', XOOPS_URL, $object->getVar($key)) . "' alt=''><br><br>")); |
|
| 38 | + } elseif ('' !== $object->getVar($key)) { |
|
| 39 | + $this->addElement(new \XoopsFormLabel('', "<img src='" . $object_imageurl . $object->getVar($key) . "' alt=''><br><br>")); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | 42 | // require_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformfileuploadelement.php'; |
| 43 | - $this->addElement(new SmartFormFileUploadElement($object, $key)); |
|
| 43 | + $this->addElement(new SmartFormFileUploadElement($object, $key)); |
|
| 44 | 44 | |
| 45 | - $this->addElement(new \XoopsFormLabel('<div style="height: 10px; padding-top: 8px; font-size: 80%;">' . _CO_SOBJECT_URL_FILE_DSC . '</div>', '')); |
|
| 45 | + $this->addElement(new \XoopsFormLabel('<div style="height: 10px; padding-top: 8px; font-size: 80%;">' . _CO_SOBJECT_URL_FILE_DSC . '</div>', '')); |
|
| 46 | 46 | // require_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformtextelement.php'; |
| 47 | 47 | // require_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformcheckelement.php'; |
| 48 | 48 | |
| 49 | - $this->addElement(new \XoopsFormLabel('', '<br>' . _CO_SOBJECT_URL_FILE)); |
|
| 50 | - $this->addElement(new SmartFormTextElement($object, 'url_' . $key)); |
|
| 51 | - $this->addElement(new \XoopsFormLabel('', '<br><br>')); |
|
| 52 | - $delete_check = new SmartFormCheckElement('', 'delete_' . $key); |
|
| 53 | - $delete_check->addOption(1, '<span style="color:red;">' . _CO_SOBJECT_DELETE . '</span>'); |
|
| 54 | - $this->addElement($delete_check); |
|
| 55 | - } |
|
| 49 | + $this->addElement(new \XoopsFormLabel('', '<br>' . _CO_SOBJECT_URL_FILE)); |
|
| 50 | + $this->addElement(new SmartFormTextElement($object, 'url_' . $key)); |
|
| 51 | + $this->addElement(new \XoopsFormLabel('', '<br><br>')); |
|
| 52 | + $delete_check = new SmartFormCheckElement('', 'delete_' . $key); |
|
| 53 | + $delete_check->addOption(1, '<span style="color:red;">' . _CO_SOBJECT_DELETE . '</span>'); |
|
| 54 | + $this->addElement($delete_check); |
|
| 55 | + } |
|
| 56 | 56 | } |
@@ -34,23 +34,23 @@ |
||
| 34 | 34 | if ('' !== $object->getVar($key) |
| 35 | 35 | && (0 === strpos($object->getVar($key), 'http') |
| 36 | 36 | || 0 === strpos($object->getVar($key), '{XOOPS_URL}'))) { |
| 37 | - $this->addElement(new \XoopsFormLabel('', "<img src='" . str_replace('{XOOPS_URL}', XOOPS_URL, $object->getVar($key)) . "' alt=''><br><br>")); |
|
| 37 | + $this->addElement(new \XoopsFormLabel('', "<img src='".str_replace('{XOOPS_URL}', XOOPS_URL, $object->getVar($key))."' alt=''><br><br>")); |
|
| 38 | 38 | } elseif ('' !== $object->getVar($key)) { |
| 39 | - $this->addElement(new \XoopsFormLabel('', "<img src='" . $object_imageurl . $object->getVar($key) . "' alt=''><br><br>")); |
|
| 39 | + $this->addElement(new \XoopsFormLabel('', "<img src='".$object_imageurl.$object->getVar($key)."' alt=''><br><br>")); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | // require_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformfileuploadelement.php'; |
| 43 | 43 | $this->addElement(new SmartFormFileUploadElement($object, $key)); |
| 44 | 44 | |
| 45 | - $this->addElement(new \XoopsFormLabel('<div style="height: 10px; padding-top: 8px; font-size: 80%;">' . _CO_SOBJECT_URL_FILE_DSC . '</div>', '')); |
|
| 45 | + $this->addElement(new \XoopsFormLabel('<div style="height: 10px; padding-top: 8px; font-size: 80%;">'._CO_SOBJECT_URL_FILE_DSC.'</div>', '')); |
|
| 46 | 46 | // require_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformtextelement.php'; |
| 47 | 47 | // require_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformcheckelement.php'; |
| 48 | 48 | |
| 49 | - $this->addElement(new \XoopsFormLabel('', '<br>' . _CO_SOBJECT_URL_FILE)); |
|
| 50 | - $this->addElement(new SmartFormTextElement($object, 'url_' . $key)); |
|
| 49 | + $this->addElement(new \XoopsFormLabel('', '<br>'._CO_SOBJECT_URL_FILE)); |
|
| 50 | + $this->addElement(new SmartFormTextElement($object, 'url_'.$key)); |
|
| 51 | 51 | $this->addElement(new \XoopsFormLabel('', '<br><br>')); |
| 52 | - $delete_check = new SmartFormCheckElement('', 'delete_' . $key); |
|
| 53 | - $delete_check->addOption(1, '<span style="color:red;">' . _CO_SOBJECT_DELETE . '</span>'); |
|
| 52 | + $delete_check = new SmartFormCheckElement('', 'delete_'.$key); |
|
| 53 | + $delete_check->addOption(1, '<span style="color:red;">'._CO_SOBJECT_DELETE.'</span>'); |
|
| 54 | 54 | $this->addElement($delete_check); |
| 55 | 55 | } |
| 56 | 56 | } |
@@ -18,24 +18,24 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class SmartFormTextElement extends \XoopsFormText |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * SmartFormTextElement constructor. |
|
| 23 | - * @param string $object |
|
| 24 | - * @param string $key |
|
| 25 | - */ |
|
| 26 | - public function __construct($object, $key) |
|
| 27 | - { |
|
| 28 | - $var = $object->vars[$key]; |
|
| 21 | + /** |
|
| 22 | + * SmartFormTextElement constructor. |
|
| 23 | + * @param string $object |
|
| 24 | + * @param string $key |
|
| 25 | + */ |
|
| 26 | + public function __construct($object, $key) |
|
| 27 | + { |
|
| 28 | + $var = $object->vars[$key]; |
|
| 29 | 29 | |
| 30 | - if (isset($object->controls[$key])) { |
|
| 31 | - $control = $object->controls[$key]; |
|
| 32 | - $form_maxlength = isset($control['maxlength']) ? $control['maxlength'] : (isset($var['maxlength']) ? $var['maxlength'] : 255); |
|
| 33 | - $form_size = isset($control['size']) ? $control['size'] : 50; |
|
| 34 | - } else { |
|
| 35 | - $form_maxlength = 255; |
|
| 36 | - $form_size = 50; |
|
| 37 | - } |
|
| 30 | + if (isset($object->controls[$key])) { |
|
| 31 | + $control = $object->controls[$key]; |
|
| 32 | + $form_maxlength = isset($control['maxlength']) ? $control['maxlength'] : (isset($var['maxlength']) ? $var['maxlength'] : 255); |
|
| 33 | + $form_size = isset($control['size']) ? $control['size'] : 50; |
|
| 34 | + } else { |
|
| 35 | + $form_maxlength = 255; |
|
| 36 | + $form_size = 50; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - parent::__construct($var['form_caption'], $key, $form_size, $form_maxlength, $object->getVar($key, 'e')); |
|
| 40 | - } |
|
| 39 | + parent::__construct($var['form_caption'], $key, $form_size, $form_maxlength, $object->getVar($key, 'e')); |
|
| 40 | + } |
|
| 41 | 41 | } |
@@ -31,93 +31,93 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | class SmartobjectRatingHandler extends Smartobject\SmartPersistableObjectHandler |
| 33 | 33 | { |
| 34 | - public $_rateOptions = []; |
|
| 35 | - public $_moduleList = false; |
|
| 36 | - public $pluginsObject; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * SmartobjectRatingHandler constructor. |
|
| 40 | - * @param \XoopsDatabase $db |
|
| 41 | - */ |
|
| 42 | - public function __construct(\XoopsDatabase $db) |
|
| 43 | - { |
|
| 44 | - parent::__construct($db, 'rating', 'ratingid', 'rate', '', 'smartobject'); |
|
| 45 | - $this->generalSQL = 'SELECT * FROM ' . $this->table . ' AS ' . $this->_itemname . ' INNER JOIN ' . $this->db->prefix('users') . ' AS user ON ' . $this->_itemname . '.uid=user.uid'; |
|
| 46 | - |
|
| 47 | - $this->_rateOptions[1] = 1; |
|
| 48 | - $this->_rateOptions[2] = 2; |
|
| 49 | - $this->_rateOptions[3] = 3; |
|
| 50 | - $this->_rateOptions[4] = 4; |
|
| 51 | - $this->_rateOptions[5] = 5; |
|
| 52 | - |
|
| 53 | - $this->pluginsObject = new SmartPluginHandler(); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * @return bool |
|
| 58 | - */ |
|
| 59 | - public function getModuleList() |
|
| 60 | - { |
|
| 61 | - if (!$this->_moduleList) { |
|
| 62 | - $moduleArray = $this->pluginsObject->getPluginsArray(); |
|
| 63 | - $this->_moduleList[0] = _CO_SOBJECT_MAKE_SELECTION; |
|
| 64 | - foreach ($moduleArray as $k => $v) { |
|
| 65 | - $this->_moduleList[$k] = $v; |
|
| 66 | - } |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - return $this->_moduleList; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * @return array |
|
| 74 | - */ |
|
| 75 | - public function getRateList() |
|
| 76 | - { |
|
| 77 | - return $this->_rateOptions; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * @param $itemid |
|
| 82 | - * @param $dirname |
|
| 83 | - * @param $item |
|
| 84 | - * @return int |
|
| 85 | - */ |
|
| 86 | - public function getRatingAverageByItemId($itemid, $dirname, $item) |
|
| 87 | - { |
|
| 88 | - $sql = 'SELECT AVG(rate), COUNT(ratingid) FROM ' . $this->table . " WHERE itemid=$itemid AND dirname='$dirname' AND item='$item' GROUP BY itemid"; |
|
| 89 | - $result = $this->db->query($sql); |
|
| 90 | - if (!$result) { |
|
| 91 | - return 0; |
|
| 92 | - } |
|
| 93 | - list($average, $sum) = $this->db->fetchRow($result); |
|
| 94 | - $ret['average'] = isset($average) ? $average : 0; |
|
| 95 | - $ret['sum'] = isset($sum) ? $sum : 0; |
|
| 96 | - |
|
| 97 | - return $ret; |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * @param $item |
|
| 102 | - * @param $itemid |
|
| 103 | - * @param $dirname |
|
| 104 | - * @param $uid |
|
| 105 | - * @return bool |
|
| 106 | - */ |
|
| 107 | - public function already_rated($item, $itemid, $dirname, $uid) |
|
| 108 | - { |
|
| 109 | - $criteria = new \CriteriaCompo(); |
|
| 110 | - $criteria->add(new \Criteria('item', $item)); |
|
| 111 | - $criteria->add(new \Criteria('itemid', $itemid)); |
|
| 112 | - $criteria->add(new \Criteria('dirname', $dirname)); |
|
| 113 | - $criteria->add(new \Criteria('user.uid', $uid)); |
|
| 114 | - |
|
| 115 | - $ret =& $this->getObjects($criteria); |
|
| 116 | - |
|
| 117 | - if (!$ret) { |
|
| 118 | - return false; |
|
| 119 | - } else { |
|
| 120 | - return $ret[0]; |
|
| 121 | - } |
|
| 122 | - } |
|
| 34 | + public $_rateOptions = []; |
|
| 35 | + public $_moduleList = false; |
|
| 36 | + public $pluginsObject; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * SmartobjectRatingHandler constructor. |
|
| 40 | + * @param \XoopsDatabase $db |
|
| 41 | + */ |
|
| 42 | + public function __construct(\XoopsDatabase $db) |
|
| 43 | + { |
|
| 44 | + parent::__construct($db, 'rating', 'ratingid', 'rate', '', 'smartobject'); |
|
| 45 | + $this->generalSQL = 'SELECT * FROM ' . $this->table . ' AS ' . $this->_itemname . ' INNER JOIN ' . $this->db->prefix('users') . ' AS user ON ' . $this->_itemname . '.uid=user.uid'; |
|
| 46 | + |
|
| 47 | + $this->_rateOptions[1] = 1; |
|
| 48 | + $this->_rateOptions[2] = 2; |
|
| 49 | + $this->_rateOptions[3] = 3; |
|
| 50 | + $this->_rateOptions[4] = 4; |
|
| 51 | + $this->_rateOptions[5] = 5; |
|
| 52 | + |
|
| 53 | + $this->pluginsObject = new SmartPluginHandler(); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * @return bool |
|
| 58 | + */ |
|
| 59 | + public function getModuleList() |
|
| 60 | + { |
|
| 61 | + if (!$this->_moduleList) { |
|
| 62 | + $moduleArray = $this->pluginsObject->getPluginsArray(); |
|
| 63 | + $this->_moduleList[0] = _CO_SOBJECT_MAKE_SELECTION; |
|
| 64 | + foreach ($moduleArray as $k => $v) { |
|
| 65 | + $this->_moduleList[$k] = $v; |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + return $this->_moduleList; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * @return array |
|
| 74 | + */ |
|
| 75 | + public function getRateList() |
|
| 76 | + { |
|
| 77 | + return $this->_rateOptions; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * @param $itemid |
|
| 82 | + * @param $dirname |
|
| 83 | + * @param $item |
|
| 84 | + * @return int |
|
| 85 | + */ |
|
| 86 | + public function getRatingAverageByItemId($itemid, $dirname, $item) |
|
| 87 | + { |
|
| 88 | + $sql = 'SELECT AVG(rate), COUNT(ratingid) FROM ' . $this->table . " WHERE itemid=$itemid AND dirname='$dirname' AND item='$item' GROUP BY itemid"; |
|
| 89 | + $result = $this->db->query($sql); |
|
| 90 | + if (!$result) { |
|
| 91 | + return 0; |
|
| 92 | + } |
|
| 93 | + list($average, $sum) = $this->db->fetchRow($result); |
|
| 94 | + $ret['average'] = isset($average) ? $average : 0; |
|
| 95 | + $ret['sum'] = isset($sum) ? $sum : 0; |
|
| 96 | + |
|
| 97 | + return $ret; |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * @param $item |
|
| 102 | + * @param $itemid |
|
| 103 | + * @param $dirname |
|
| 104 | + * @param $uid |
|
| 105 | + * @return bool |
|
| 106 | + */ |
|
| 107 | + public function already_rated($item, $itemid, $dirname, $uid) |
|
| 108 | + { |
|
| 109 | + $criteria = new \CriteriaCompo(); |
|
| 110 | + $criteria->add(new \Criteria('item', $item)); |
|
| 111 | + $criteria->add(new \Criteria('itemid', $itemid)); |
|
| 112 | + $criteria->add(new \Criteria('dirname', $dirname)); |
|
| 113 | + $criteria->add(new \Criteria('user.uid', $uid)); |
|
| 114 | + |
|
| 115 | + $ret =& $this->getObjects($criteria); |
|
| 116 | + |
|
| 117 | + if (!$ret) { |
|
| 118 | + return false; |
|
| 119 | + } else { |
|
| 120 | + return $ret[0]; |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | 123 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | public function __construct(\XoopsDatabase $db) |
| 43 | 43 | { |
| 44 | 44 | parent::__construct($db, 'rating', 'ratingid', 'rate', '', 'smartobject'); |
| 45 | - $this->generalSQL = 'SELECT * FROM ' . $this->table . ' AS ' . $this->_itemname . ' INNER JOIN ' . $this->db->prefix('users') . ' AS user ON ' . $this->_itemname . '.uid=user.uid'; |
|
| 45 | + $this->generalSQL = 'SELECT * FROM '.$this->table.' AS '.$this->_itemname.' INNER JOIN '.$this->db->prefix('users').' AS user ON '.$this->_itemname.'.uid=user.uid'; |
|
| 46 | 46 | |
| 47 | 47 | $this->_rateOptions[1] = 1; |
| 48 | 48 | $this->_rateOptions[2] = 2; |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public function getRatingAverageByItemId($itemid, $dirname, $item) |
| 87 | 87 | { |
| 88 | - $sql = 'SELECT AVG(rate), COUNT(ratingid) FROM ' . $this->table . " WHERE itemid=$itemid AND dirname='$dirname' AND item='$item' GROUP BY itemid"; |
|
| 88 | + $sql = 'SELECT AVG(rate), COUNT(ratingid) FROM '.$this->table." WHERE itemid=$itemid AND dirname='$dirname' AND item='$item' GROUP BY itemid"; |
|
| 89 | 89 | $result = $this->db->query($sql); |
| 90 | 90 | if (!$result) { |
| 91 | 91 | return 0; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | $criteria->add(new \Criteria('dirname', $dirname)); |
| 113 | 113 | $criteria->add(new \Criteria('user.uid', $uid)); |
| 114 | 114 | |
| 115 | - $ret =& $this->getObjects($criteria); |
|
| 115 | + $ret = & $this->getObjects($criteria); |
|
| 116 | 116 | |
| 117 | 117 | if (!$ret) { |
| 118 | 118 | return false; |
@@ -27,44 +27,44 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class SmartHookHandler |
| 29 | 29 | { |
| 30 | - /** |
|
| 31 | - * SmartHookHandler constructor. |
|
| 32 | - */ |
|
| 33 | - public function __construct() |
|
| 34 | - { |
|
| 35 | - } |
|
| 30 | + /** |
|
| 31 | + * SmartHookHandler constructor. |
|
| 32 | + */ |
|
| 33 | + public function __construct() |
|
| 34 | + { |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Access the only instance of this class |
|
| 39 | - * |
|
| 40 | - * @return \XoopsModules\Smartobject\SmartHookHandler |
|
| 41 | - * |
|
| 42 | - * @static |
|
| 43 | - * @staticvar object |
|
| 44 | - */ |
|
| 45 | - public static function getInstance() |
|
| 46 | - { |
|
| 47 | - static $instance; |
|
| 48 | - if (null === $instance) { |
|
| 49 | - $instance = new static(); |
|
| 50 | - } |
|
| 37 | + /** |
|
| 38 | + * Access the only instance of this class |
|
| 39 | + * |
|
| 40 | + * @return \XoopsModules\Smartobject\SmartHookHandler |
|
| 41 | + * |
|
| 42 | + * @static |
|
| 43 | + * @staticvar object |
|
| 44 | + */ |
|
| 45 | + public static function getInstance() |
|
| 46 | + { |
|
| 47 | + static $instance; |
|
| 48 | + if (null === $instance) { |
|
| 49 | + $instance = new static(); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - return $instance; |
|
| 53 | - } |
|
| 52 | + return $instance; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * @param $hook_name |
|
| 57 | - */ |
|
| 58 | - public function executeHook($hook_name) |
|
| 59 | - { |
|
| 60 | - $lower_hook_name = strtolower($hook_name); |
|
| 61 | - $filename = SMARTOBJECT_ROOT_PATH . 'include/custom_code/' . $lower_hook_name . '.php'; |
|
| 62 | - if (file_exists($filename)) { |
|
| 63 | - require_once $filename; |
|
| 64 | - $function = 'smarthook_' . $lower_hook_name; |
|
| 65 | - if (function_exists($function)) { |
|
| 66 | - $function(); |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - } |
|
| 55 | + /** |
|
| 56 | + * @param $hook_name |
|
| 57 | + */ |
|
| 58 | + public function executeHook($hook_name) |
|
| 59 | + { |
|
| 60 | + $lower_hook_name = strtolower($hook_name); |
|
| 61 | + $filename = SMARTOBJECT_ROOT_PATH . 'include/custom_code/' . $lower_hook_name . '.php'; |
|
| 62 | + if (file_exists($filename)) { |
|
| 63 | + require_once $filename; |
|
| 64 | + $function = 'smarthook_' . $lower_hook_name; |
|
| 65 | + if (function_exists($function)) { |
|
| 66 | + $function(); |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | 70 | } |