@@ -25,66 +25,66 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | class Plugin |
| 27 | 27 | { |
| 28 | - public $_infoArray; |
|
| 28 | + public $_infoArray; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * SmartPlugin constructor. |
|
| 32 | - * @param $array |
|
| 33 | - */ |
|
| 34 | - public function __construct($array) |
|
| 35 | - { |
|
| 36 | - $this->_infoArray = $array; |
|
| 37 | - } |
|
| 30 | + /** |
|
| 31 | + * SmartPlugin constructor. |
|
| 32 | + * @param $array |
|
| 33 | + */ |
|
| 34 | + public function __construct($array) |
|
| 35 | + { |
|
| 36 | + $this->_infoArray = $array; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @param $item |
|
| 41 | - * @return bool |
|
| 42 | - */ |
|
| 43 | - public function getItemInfo($item) |
|
| 44 | - { |
|
| 45 | - if (isset($this->_infoArray['items'][$item])) { |
|
| 46 | - return $this->_infoArray['items'][$item]; |
|
| 47 | - } else { |
|
| 48 | - return false; |
|
| 49 | - } |
|
| 50 | - } |
|
| 39 | + /** |
|
| 40 | + * @param $item |
|
| 41 | + * @return bool |
|
| 42 | + */ |
|
| 43 | + public function getItemInfo($item) |
|
| 44 | + { |
|
| 45 | + if (isset($this->_infoArray['items'][$item])) { |
|
| 46 | + return $this->_infoArray['items'][$item]; |
|
| 47 | + } else { |
|
| 48 | + return false; |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * @return mixed |
|
| 54 | - */ |
|
| 55 | - public function getItemList() |
|
| 56 | - { |
|
| 57 | - $itemsArray = $this->_infoArray['items']; |
|
| 58 | - foreach ($itemsArray as $k => $v) { |
|
| 59 | - $ret[$k] = $v['caption']; |
|
| 60 | - } |
|
| 52 | + /** |
|
| 53 | + * @return mixed |
|
| 54 | + */ |
|
| 55 | + public function getItemList() |
|
| 56 | + { |
|
| 57 | + $itemsArray = $this->_infoArray['items']; |
|
| 58 | + foreach ($itemsArray as $k => $v) { |
|
| 59 | + $ret[$k] = $v['caption']; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - return $ret; |
|
| 63 | - } |
|
| 62 | + return $ret; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * @return bool|int|string |
|
| 67 | - */ |
|
| 68 | - public function getItem() |
|
| 69 | - { |
|
| 70 | - $ret = false; |
|
| 71 | - foreach ($this->_infoArray['items'] as $k => $v) { |
|
| 72 | - $search_str = str_replace('%u', '', $v['url']); |
|
| 73 | - if (strpos($_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'], $search_str) > 0) { |
|
| 74 | - $ret = $k; |
|
| 75 | - break; |
|
| 76 | - } |
|
| 77 | - } |
|
| 65 | + /** |
|
| 66 | + * @return bool|int|string |
|
| 67 | + */ |
|
| 68 | + public function getItem() |
|
| 69 | + { |
|
| 70 | + $ret = false; |
|
| 71 | + foreach ($this->_infoArray['items'] as $k => $v) { |
|
| 72 | + $search_str = str_replace('%u', '', $v['url']); |
|
| 73 | + if (strpos($_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'], $search_str) > 0) { |
|
| 74 | + $ret = $k; |
|
| 75 | + break; |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - return $ret; |
|
| 80 | - } |
|
| 79 | + return $ret; |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * @param $item |
|
| 84 | - * @return mixed |
|
| 85 | - */ |
|
| 86 | - public function getItemIdForItem($item) |
|
| 87 | - { |
|
| 88 | - return $_REQUEST[$this->_infoArray['items'][$item]['request']]; |
|
| 89 | - } |
|
| 82 | + /** |
|
| 83 | + * @param $item |
|
| 84 | + * @return mixed |
|
| 85 | + */ |
|
| 86 | + public function getItemIdForItem($item) |
|
| 87 | + { |
|
| 88 | + return $_REQUEST[$this->_infoArray['items'][$item]['request']]; |
|
| 89 | + } |
|
| 90 | 90 | } |
@@ -26,80 +26,80 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | class MlObject extends Smartobject\BaseSmartObject |
| 28 | 28 | { |
| 29 | - /** |
|
| 30 | - * SmartMlObject constructor. |
|
| 31 | - */ |
|
| 32 | - public function __construct() |
|
| 33 | - { |
|
| 34 | - $this->initVar('language', XOBJ_DTYPE_TXTBOX, 'english', false, null, '', true, _CO_SOBJECT_LANGUAGE_CAPTION, _CO_SOBJECT_LANGUAGE_DSC, true, true); |
|
| 35 | - $this->setControl('language', 'language'); |
|
| 36 | - } |
|
| 29 | + /** |
|
| 30 | + * SmartMlObject constructor. |
|
| 31 | + */ |
|
| 32 | + public function __construct() |
|
| 33 | + { |
|
| 34 | + $this->initVar('language', XOBJ_DTYPE_TXTBOX, 'english', false, null, '', true, _CO_SOBJECT_LANGUAGE_CAPTION, _CO_SOBJECT_LANGUAGE_DSC, true, true); |
|
| 35 | + $this->setControl('language', 'language'); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * If object is not new, change the control of the not-multilanguage fields |
|
| 40 | - * |
|
| 41 | - * We need to intercept this function from SmartObject because if the object is not new... |
|
| 42 | - */ |
|
| 43 | - // function getForm() { |
|
| 38 | + /** |
|
| 39 | + * If object is not new, change the control of the not-multilanguage fields |
|
| 40 | + * |
|
| 41 | + * We need to intercept this function from SmartObject because if the object is not new... |
|
| 42 | + */ |
|
| 43 | + // function getForm() { |
|
| 44 | 44 | |
| 45 | - //} |
|
| 45 | + //} |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Strip Multilanguage Fields |
|
| 49 | - * |
|
| 50 | - * Get rid of all the multilanguage fields to have an object with only global fields. |
|
| 51 | - * This will be usefull when creating the ML object for the first time. Then we will be able |
|
| 52 | - * to create translations. |
|
| 53 | - */ |
|
| 54 | - public function stripMultilanguageFields() |
|
| 55 | - { |
|
| 56 | - $objectVars =& $this->getVars(); |
|
| 57 | - $newObjectVars = []; |
|
| 58 | - foreach ($objectVars as $key => $var) { |
|
| 59 | - if (!$var['multilingual']) { |
|
| 60 | - $newObjectVars[$key] = $var; |
|
| 61 | - } |
|
| 62 | - } |
|
| 63 | - $this->vars = $newObjectVars; |
|
| 64 | - } |
|
| 47 | + /** |
|
| 48 | + * Strip Multilanguage Fields |
|
| 49 | + * |
|
| 50 | + * Get rid of all the multilanguage fields to have an object with only global fields. |
|
| 51 | + * This will be usefull when creating the ML object for the first time. Then we will be able |
|
| 52 | + * to create translations. |
|
| 53 | + */ |
|
| 54 | + public function stripMultilanguageFields() |
|
| 55 | + { |
|
| 56 | + $objectVars =& $this->getVars(); |
|
| 57 | + $newObjectVars = []; |
|
| 58 | + foreach ($objectVars as $key => $var) { |
|
| 59 | + if (!$var['multilingual']) { |
|
| 60 | + $newObjectVars[$key] = $var; |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + $this->vars = $newObjectVars; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - public function stripNonMultilanguageFields() |
|
| 67 | - { |
|
| 68 | - $objectVars =& $this->getVars(); |
|
| 69 | - $newObjectVars = []; |
|
| 70 | - foreach ($objectVars as $key => $var) { |
|
| 71 | - if ($var['multilingual'] || $key == $this->handler->keyName) { |
|
| 72 | - $newObjectVars[$key] = $var; |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - $this->vars = $newObjectVars; |
|
| 76 | - } |
|
| 66 | + public function stripNonMultilanguageFields() |
|
| 67 | + { |
|
| 68 | + $objectVars =& $this->getVars(); |
|
| 69 | + $newObjectVars = []; |
|
| 70 | + foreach ($objectVars as $key => $var) { |
|
| 71 | + if ($var['multilingual'] || $key == $this->handler->keyName) { |
|
| 72 | + $newObjectVars[$key] = $var; |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + $this->vars = $newObjectVars; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Make non multilanguage fields read only |
|
| 80 | - * |
|
| 81 | - * This is used when we are creating/editing a translation. |
|
| 82 | - * We only want to edit the multilanguag fields, not the global one. |
|
| 83 | - */ |
|
| 84 | - public function makeNonMLFieldReadOnly() |
|
| 85 | - { |
|
| 86 | - foreach ($this->getVars() as $key => $var) { |
|
| 87 | - //if (($key == 'language') || (!$var['multilingual'] && $key <> $this->handler->keyName)) { |
|
| 88 | - if (!$var['multilingual'] && $key != $this->handler->keyName) { |
|
| 89 | - $this->setControl($key, 'label'); |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - } |
|
| 78 | + /** |
|
| 79 | + * Make non multilanguage fields read only |
|
| 80 | + * |
|
| 81 | + * This is used when we are creating/editing a translation. |
|
| 82 | + * We only want to edit the multilanguag fields, not the global one. |
|
| 83 | + */ |
|
| 84 | + public function makeNonMLFieldReadOnly() |
|
| 85 | + { |
|
| 86 | + foreach ($this->getVars() as $key => $var) { |
|
| 87 | + //if (($key == 'language') || (!$var['multilingual'] && $key <> $this->handler->keyName)) { |
|
| 88 | + if (!$var['multilingual'] && $key != $this->handler->keyName) { |
|
| 89 | + $this->setControl($key, 'label'); |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * @param bool $onlyUrl |
|
| 96 | - * @param bool $withimage |
|
| 97 | - * @return string |
|
| 98 | - */ |
|
| 99 | - public function getEditLanguageLink($onlyUrl = false, $withimage = true) |
|
| 100 | - { |
|
| 101 | - $controller = new ObjectController($this->handler); |
|
| 94 | + /** |
|
| 95 | + * @param bool $onlyUrl |
|
| 96 | + * @param bool $withimage |
|
| 97 | + * @return string |
|
| 98 | + */ |
|
| 99 | + public function getEditLanguageLink($onlyUrl = false, $withimage = true) |
|
| 100 | + { |
|
| 101 | + $controller = new ObjectController($this->handler); |
|
| 102 | 102 | |
| 103 | - return $controller->getEditLanguageLink($this, $onlyUrl, $withimage); |
|
| 104 | - } |
|
| 103 | + return $controller->getEditLanguageLink($this, $onlyUrl, $withimage); |
|
| 104 | + } |
|
| 105 | 105 | } |
@@ -81,51 +81,51 @@ |
||
| 81 | 81 | */ |
| 82 | 82 | class Uploader extends \XoopsMediaUploader |
| 83 | 83 | { |
| 84 | - public $ext; |
|
| 85 | - public $dimension; |
|
| 84 | + public $ext; |
|
| 85 | + public $dimension; |
|
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * No admin check for uploads |
|
| 89 | - */ |
|
| 90 | - public $noAdminSizeCheck; |
|
| 87 | + /** |
|
| 88 | + * No admin check for uploads |
|
| 89 | + */ |
|
| 90 | + public $noAdminSizeCheck; |
|
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * Constructor |
|
| 94 | - * |
|
| 95 | - * @param string $uploadDir |
|
| 96 | - * @param array|int $allowedMimeTypes |
|
| 97 | - * @param int $maxFileSize |
|
| 98 | - * @param int $maxWidth |
|
| 99 | - * @param int $maxHeight |
|
| 100 | - * @internal param int $cmodvalue |
|
| 101 | - */ |
|
| 102 | - public function __construct($uploadDir, $allowedMimeTypes = 0, $maxFileSize, $maxWidth = 0, $maxHeight = 0) |
|
| 103 | - { |
|
| 104 | - parent::__construct($uploadDir, $allowedMimeTypes, $maxFileSize, $maxWidth, $maxHeight); |
|
| 105 | - } |
|
| 92 | + /** |
|
| 93 | + * Constructor |
|
| 94 | + * |
|
| 95 | + * @param string $uploadDir |
|
| 96 | + * @param array|int $allowedMimeTypes |
|
| 97 | + * @param int $maxFileSize |
|
| 98 | + * @param int $maxWidth |
|
| 99 | + * @param int $maxHeight |
|
| 100 | + * @internal param int $cmodvalue |
|
| 101 | + */ |
|
| 102 | + public function __construct($uploadDir, $allowedMimeTypes = 0, $maxFileSize, $maxWidth = 0, $maxHeight = 0) |
|
| 103 | + { |
|
| 104 | + parent::__construct($uploadDir, $allowedMimeTypes, $maxFileSize, $maxWidth, $maxHeight); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - /** |
|
| 108 | - * @param $value |
|
| 109 | - */ |
|
| 110 | - public function noAdminSizeCheck($value) |
|
| 111 | - { |
|
| 112 | - $this->noAdminSizeCheck = $value; |
|
| 113 | - } |
|
| 107 | + /** |
|
| 108 | + * @param $value |
|
| 109 | + */ |
|
| 110 | + public function noAdminSizeCheck($value) |
|
| 111 | + { |
|
| 112 | + $this->noAdminSizeCheck = $value; |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - /** |
|
| 116 | - * Is the file the right size? |
|
| 117 | - * |
|
| 118 | - * @return bool |
|
| 119 | - */ |
|
| 120 | - public function checkMaxFileSize() |
|
| 121 | - { |
|
| 122 | - if ($this->noAdminSizeCheck) { |
|
| 123 | - return true; |
|
| 124 | - } |
|
| 125 | - if ($this->mediaSize > $this->maxFileSize) { |
|
| 126 | - return false; |
|
| 127 | - } |
|
| 115 | + /** |
|
| 116 | + * Is the file the right size? |
|
| 117 | + * |
|
| 118 | + * @return bool |
|
| 119 | + */ |
|
| 120 | + public function checkMaxFileSize() |
|
| 121 | + { |
|
| 122 | + if ($this->noAdminSizeCheck) { |
|
| 123 | + return true; |
|
| 124 | + } |
|
| 125 | + if ($this->mediaSize > $this->maxFileSize) { |
|
| 126 | + return false; |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - return true; |
|
| 130 | - } |
|
| 129 | + return true; |
|
| 130 | + } |
|
| 131 | 131 | } |
@@ -27,44 +27,44 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class HookHandler |
| 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\HookHandler |
|
| 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\HookHandler |
|
| 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 | } |
@@ -17,45 +17,45 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class Tip |
| 19 | 19 | { |
| 20 | - public $id; |
|
| 21 | - public $caption; |
|
| 22 | - public $message; |
|
| 23 | - public $visible; |
|
| 24 | - public $_tpl; |
|
| 20 | + public $id; |
|
| 21 | + public $caption; |
|
| 22 | + public $message; |
|
| 23 | + public $visible; |
|
| 24 | + public $_tpl; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * SmartTip constructor. |
|
| 28 | - * @param $id |
|
| 29 | - * @param $caption |
|
| 30 | - * @param $message |
|
| 31 | - * @param bool $visible |
|
| 32 | - */ |
|
| 33 | - public function __construct($id, $caption, $message, $visible = false) |
|
| 34 | - { |
|
| 35 | - $this->id = $id; |
|
| 36 | - $this->caption = $caption; |
|
| 37 | - $this->message = $message; |
|
| 38 | - $this->visible = $visible; |
|
| 39 | - $this->_tpl = new \XoopsTpl(); |
|
| 40 | - } |
|
| 26 | + /** |
|
| 27 | + * SmartTip constructor. |
|
| 28 | + * @param $id |
|
| 29 | + * @param $caption |
|
| 30 | + * @param $message |
|
| 31 | + * @param bool $visible |
|
| 32 | + */ |
|
| 33 | + public function __construct($id, $caption, $message, $visible = false) |
|
| 34 | + { |
|
| 35 | + $this->id = $id; |
|
| 36 | + $this->caption = $caption; |
|
| 37 | + $this->message = $message; |
|
| 38 | + $this->visible = $visible; |
|
| 39 | + $this->_tpl = new \XoopsTpl(); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @param bool $outputNow |
|
| 44 | - * @return mixed|string|void |
|
| 45 | - */ |
|
| 46 | - public function render($outputNow = true) |
|
| 47 | - { |
|
| 48 | - $aTip = [ |
|
| 49 | - 'id' => $this->id, |
|
| 50 | - 'caption' => $this->caption, |
|
| 51 | - 'message' => $this->message, |
|
| 52 | - 'visible' => $this->visible ? 'block' : 'none' |
|
| 53 | - ]; |
|
| 54 | - $this->_tpl->assign('tip', $aTip); |
|
| 55 | - if ($outputNow) { |
|
| 56 | - $this->_tpl->display('db:smartobject_tip.tpl'); |
|
| 57 | - } else { |
|
| 58 | - return $this->_tpl->fetch('db:smartobject_tip.tpl'); |
|
| 59 | - } |
|
| 60 | - } |
|
| 42 | + /** |
|
| 43 | + * @param bool $outputNow |
|
| 44 | + * @return mixed|string|void |
|
| 45 | + */ |
|
| 46 | + public function render($outputNow = true) |
|
| 47 | + { |
|
| 48 | + $aTip = [ |
|
| 49 | + 'id' => $this->id, |
|
| 50 | + 'caption' => $this->caption, |
|
| 51 | + 'message' => $this->message, |
|
| 52 | + 'visible' => $this->visible ? 'block' : 'none' |
|
| 53 | + ]; |
|
| 54 | + $this->_tpl->assign('tip', $aTip); |
|
| 55 | + if ($outputNow) { |
|
| 56 | + $this->_tpl->display('db:smartobject_tip.tpl'); |
|
| 57 | + } else { |
|
| 58 | + return $this->_tpl->fetch('db:smartobject_tip.tpl'); |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | 61 | } |
@@ -27,57 +27,57 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class PluginHandler |
| 29 | 29 | { |
| 30 | - public $pluginPatterns = false; |
|
| 30 | + public $pluginPatterns = false; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @param $dirname |
|
| 34 | - * @return bool|Plugin |
|
| 35 | - */ |
|
| 36 | - public function getPlugin($dirname) |
|
| 37 | - { |
|
| 38 | - $pluginName = SMARTOBJECT_ROOT_PATH . 'plugins/' . $dirname . '.php'; |
|
| 39 | - if (file_exists($pluginName)) { |
|
| 40 | - require_once $pluginName; |
|
| 41 | - $function = 'smartobject_plugin_' . $dirname; |
|
| 42 | - if (function_exists($function)) { |
|
| 43 | - $array = $function(); |
|
| 44 | - $ret = new Plugin($array); |
|
| 32 | + /** |
|
| 33 | + * @param $dirname |
|
| 34 | + * @return bool|Plugin |
|
| 35 | + */ |
|
| 36 | + public function getPlugin($dirname) |
|
| 37 | + { |
|
| 38 | + $pluginName = SMARTOBJECT_ROOT_PATH . 'plugins/' . $dirname . '.php'; |
|
| 39 | + if (file_exists($pluginName)) { |
|
| 40 | + require_once $pluginName; |
|
| 41 | + $function = 'smartobject_plugin_' . $dirname; |
|
| 42 | + if (function_exists($function)) { |
|
| 43 | + $array = $function(); |
|
| 44 | + $ret = new Plugin($array); |
|
| 45 | 45 | |
| 46 | - return $ret; |
|
| 47 | - } |
|
| 48 | - } |
|
| 46 | + return $ret; |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - return false; |
|
| 51 | - } |
|
| 50 | + return false; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * @return array |
|
| 55 | - */ |
|
| 56 | - public function getPluginsArray() |
|
| 57 | - { |
|
| 58 | - require_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
|
| 53 | + /** |
|
| 54 | + * @return array |
|
| 55 | + */ |
|
| 56 | + public function getPluginsArray() |
|
| 57 | + { |
|
| 58 | + require_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
|
| 59 | 59 | |
| 60 | - $moduleHandler = xoops_getHandler('module'); |
|
| 61 | - $criteria = new \CriteriaCompo(); |
|
| 62 | - $criteria->add(new \Criteria('isactive', 1)); |
|
| 63 | - $tempModulesObj = $moduleHandler->getObjects($criteria); |
|
| 64 | - $modulesObj = []; |
|
| 65 | - foreach ($tempModulesObj as $moduleObj) { |
|
| 66 | - $modulesObj[$moduleObj->getVar('dirname')] = $moduleObj; |
|
| 67 | - } |
|
| 60 | + $moduleHandler = xoops_getHandler('module'); |
|
| 61 | + $criteria = new \CriteriaCompo(); |
|
| 62 | + $criteria->add(new \Criteria('isactive', 1)); |
|
| 63 | + $tempModulesObj = $moduleHandler->getObjects($criteria); |
|
| 64 | + $modulesObj = []; |
|
| 65 | + foreach ($tempModulesObj as $moduleObj) { |
|
| 66 | + $modulesObj[$moduleObj->getVar('dirname')] = $moduleObj; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - $aFiles = XoopsLists::getFileListAsArray(SMARTOBJECT_ROOT_PATH . 'plugins/'); |
|
| 70 | - $ret = []; |
|
| 71 | - foreach ($aFiles as $file) { |
|
| 72 | - if ('.php' === substr($file, strlen($file) - 4, 4)) { |
|
| 73 | - $pluginName = str_replace('.php', '', $file); |
|
| 74 | - $module_xoops_version_file = XOOPS_ROOT_PATH . "/modules/$pluginName/xoops_version.php"; |
|
| 75 | - if (file_exists($module_xoops_version_file) && isset($modulesObj[$pluginName])) { |
|
| 76 | - $ret[$pluginName] = $modulesObj[$pluginName]->getVar('name'); |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - } |
|
| 69 | + $aFiles = XoopsLists::getFileListAsArray(SMARTOBJECT_ROOT_PATH . 'plugins/'); |
|
| 70 | + $ret = []; |
|
| 71 | + foreach ($aFiles as $file) { |
|
| 72 | + if ('.php' === substr($file, strlen($file) - 4, 4)) { |
|
| 73 | + $pluginName = str_replace('.php', '', $file); |
|
| 74 | + $module_xoops_version_file = XOOPS_ROOT_PATH . "/modules/$pluginName/xoops_version.php"; |
|
| 75 | + if (file_exists($module_xoops_version_file) && isset($modulesObj[$pluginName])) { |
|
| 76 | + $ret[$pluginName] = $modulesObj[$pluginName]->getVar('name'); |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - return $ret; |
|
| 82 | - } |
|
| 81 | + return $ret; |
|
| 82 | + } |
|
| 83 | 83 | } |
@@ -41,116 +41,116 @@ |
||
| 41 | 41 | */ |
| 42 | 42 | class Export |
| 43 | 43 | { |
| 44 | - public $handler; |
|
| 45 | - public $criteria; |
|
| 46 | - public $fields; |
|
| 47 | - public $format; |
|
| 48 | - public $filename; |
|
| 49 | - public $filepath; |
|
| 50 | - public $options; |
|
| 51 | - public $outputMethods = false; |
|
| 52 | - public $notDisplayFields; |
|
| 44 | + public $handler; |
|
| 45 | + public $criteria; |
|
| 46 | + public $fields; |
|
| 47 | + public $format; |
|
| 48 | + public $filename; |
|
| 49 | + public $filepath; |
|
| 50 | + public $options; |
|
| 51 | + public $outputMethods = false; |
|
| 52 | + public $notDisplayFields; |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Constructor |
|
| 56 | - * |
|
| 57 | - * @param PersistableObjectHandler $objectHandler SmartObjectHandler handling the data we want to export |
|
| 58 | - * @param \CriteriaElement $criteria containing the criteria of the query fetching the objects to be exported |
|
| 59 | - * @param array|bool $fields fields to be exported. If FALSE then all fields will be exported |
|
| 60 | - * @param bool|string $filename name of the file to be created |
|
| 61 | - * @param bool|string $filepath path where the file will be saved |
|
| 62 | - * @param string $format format of the ouputed export. Currently only supports CSV |
|
| 63 | - * @param array|bool $options options of the format to be exported in |
|
| 64 | - */ |
|
| 65 | - public function __construct( |
|
| 66 | - PersistableObjectHandler $objectHandler, |
|
| 67 | - \CriteriaElement $criteria = null, |
|
| 68 | - $fields = false, |
|
| 69 | - $filename = false, |
|
| 70 | - $filepath = false, |
|
| 71 | - $format = 'csv', |
|
| 72 | - $options = false |
|
| 73 | - ) { |
|
| 74 | - $this->handler = $objectHandler; |
|
| 75 | - $this->criteria = $criteria; |
|
| 76 | - $this->fields = $fields; |
|
| 77 | - $this->filename = $filename; |
|
| 78 | - $this->format = $format; |
|
| 79 | - $this->options = $options; |
|
| 80 | - $this->notDisplayFields = false; |
|
| 81 | - } |
|
| 54 | + /** |
|
| 55 | + * Constructor |
|
| 56 | + * |
|
| 57 | + * @param PersistableObjectHandler $objectHandler SmartObjectHandler handling the data we want to export |
|
| 58 | + * @param \CriteriaElement $criteria containing the criteria of the query fetching the objects to be exported |
|
| 59 | + * @param array|bool $fields fields to be exported. If FALSE then all fields will be exported |
|
| 60 | + * @param bool|string $filename name of the file to be created |
|
| 61 | + * @param bool|string $filepath path where the file will be saved |
|
| 62 | + * @param string $format format of the ouputed export. Currently only supports CSV |
|
| 63 | + * @param array|bool $options options of the format to be exported in |
|
| 64 | + */ |
|
| 65 | + public function __construct( |
|
| 66 | + PersistableObjectHandler $objectHandler, |
|
| 67 | + \CriteriaElement $criteria = null, |
|
| 68 | + $fields = false, |
|
| 69 | + $filename = false, |
|
| 70 | + $filepath = false, |
|
| 71 | + $format = 'csv', |
|
| 72 | + $options = false |
|
| 73 | + ) { |
|
| 74 | + $this->handler = $objectHandler; |
|
| 75 | + $this->criteria = $criteria; |
|
| 76 | + $this->fields = $fields; |
|
| 77 | + $this->filename = $filename; |
|
| 78 | + $this->format = $format; |
|
| 79 | + $this->options = $options; |
|
| 80 | + $this->notDisplayFields = false; |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * Renders the export |
|
| 85 | - * @param $filename |
|
| 86 | - */ |
|
| 87 | - public function render($filename) |
|
| 88 | - { |
|
| 89 | - $this->filename = $filename; |
|
| 83 | + /** |
|
| 84 | + * Renders the export |
|
| 85 | + * @param $filename |
|
| 86 | + */ |
|
| 87 | + public function render($filename) |
|
| 88 | + { |
|
| 89 | + $this->filename = $filename; |
|
| 90 | 90 | |
| 91 | - $objects = $this->handler->getObjects($this->criteria); |
|
| 92 | - $rows = []; |
|
| 93 | - $columnsHeaders = []; |
|
| 94 | - $firstObject = true; |
|
| 95 | - foreach ($objects as $object) { |
|
| 96 | - $row = []; |
|
| 97 | - foreach ($object->vars as $key => $var) { |
|
| 98 | - if ((!$this->fields || in_array($key, $this->fields)) && !in_array($key, $this->notDisplayFields)) { |
|
| 99 | - if ($this->outputMethods && isset($this->outputMethods[$key]) |
|
| 100 | - && method_exists($object, $this->outputMethods[$key])) { |
|
| 101 | - $method = $this->outputMethods[$key]; |
|
| 102 | - $row[$key] = $object->$method(); |
|
| 103 | - } else { |
|
| 104 | - $row[$key] = $object->getVar($key); |
|
| 105 | - } |
|
| 106 | - if ($firstObject) { |
|
| 107 | - // then set the columnsHeaders array as well |
|
| 108 | - $columnsHeaders[$key] = $var['form_caption']; |
|
| 109 | - } |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - $firstObject = false; |
|
| 113 | - $rows[] = $row; |
|
| 114 | - unset($row); |
|
| 115 | - } |
|
| 116 | - $data = []; |
|
| 117 | - $data['rows'] = $rows; |
|
| 118 | - $data['columnsHeaders'] = $columnsHeaders; |
|
| 119 | - $smartExportRenderer = new ExportRenderer($data, $this->filename, $this->filepath, $this->format, $this->options); |
|
| 120 | - $smartExportRenderer->execute(); |
|
| 121 | - } |
|
| 91 | + $objects = $this->handler->getObjects($this->criteria); |
|
| 92 | + $rows = []; |
|
| 93 | + $columnsHeaders = []; |
|
| 94 | + $firstObject = true; |
|
| 95 | + foreach ($objects as $object) { |
|
| 96 | + $row = []; |
|
| 97 | + foreach ($object->vars as $key => $var) { |
|
| 98 | + if ((!$this->fields || in_array($key, $this->fields)) && !in_array($key, $this->notDisplayFields)) { |
|
| 99 | + if ($this->outputMethods && isset($this->outputMethods[$key]) |
|
| 100 | + && method_exists($object, $this->outputMethods[$key])) { |
|
| 101 | + $method = $this->outputMethods[$key]; |
|
| 102 | + $row[$key] = $object->$method(); |
|
| 103 | + } else { |
|
| 104 | + $row[$key] = $object->getVar($key); |
|
| 105 | + } |
|
| 106 | + if ($firstObject) { |
|
| 107 | + // then set the columnsHeaders array as well |
|
| 108 | + $columnsHeaders[$key] = $var['form_caption']; |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + $firstObject = false; |
|
| 113 | + $rows[] = $row; |
|
| 114 | + unset($row); |
|
| 115 | + } |
|
| 116 | + $data = []; |
|
| 117 | + $data['rows'] = $rows; |
|
| 118 | + $data['columnsHeaders'] = $columnsHeaders; |
|
| 119 | + $smartExportRenderer = new ExportRenderer($data, $this->filename, $this->filepath, $this->format, $this->options); |
|
| 120 | + $smartExportRenderer->execute(); |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * Set an array contaning the alternate methods to use instead of the default getVar() |
|
| 125 | - * |
|
| 126 | - * $outputMethods array example: 'uid' => 'getUserName'... |
|
| 127 | - * @param $outputMethods |
|
| 128 | - */ |
|
| 129 | - public function setOuptutMethods($outputMethods) |
|
| 130 | - { |
|
| 131 | - $this->outputMethods = $outputMethods; |
|
| 132 | - } |
|
| 123 | + /** |
|
| 124 | + * Set an array contaning the alternate methods to use instead of the default getVar() |
|
| 125 | + * |
|
| 126 | + * $outputMethods array example: 'uid' => 'getUserName'... |
|
| 127 | + * @param $outputMethods |
|
| 128 | + */ |
|
| 129 | + public function setOuptutMethods($outputMethods) |
|
| 130 | + { |
|
| 131 | + $this->outputMethods = $outputMethods; |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - /* |
|
| 134 | + /* |
|
| 135 | 135 | * Set an array of fields that we don't want in export |
| 136 | 136 | */ |
| 137 | - /** |
|
| 138 | - * @param $fields |
|
| 139 | - */ |
|
| 140 | - public function setNotDisplayFields($fields) |
|
| 141 | - { |
|
| 142 | - if (!$this->notDisplayFields) { |
|
| 143 | - if (is_array($fields)) { |
|
| 144 | - $this->notDisplayFields = $fields; |
|
| 145 | - } else { |
|
| 146 | - $this->notDisplayFields = [$fields]; |
|
| 147 | - } |
|
| 148 | - } else { |
|
| 149 | - if (is_array($fields)) { |
|
| 150 | - $this->notDisplayFields = array_merge($this->notDisplayFields, $fields); |
|
| 151 | - } else { |
|
| 152 | - $this->notDisplayFields[] = $fields; |
|
| 153 | - } |
|
| 154 | - } |
|
| 155 | - } |
|
| 137 | + /** |
|
| 138 | + * @param $fields |
|
| 139 | + */ |
|
| 140 | + public function setNotDisplayFields($fields) |
|
| 141 | + { |
|
| 142 | + if (!$this->notDisplayFields) { |
|
| 143 | + if (is_array($fields)) { |
|
| 144 | + $this->notDisplayFields = $fields; |
|
| 145 | + } else { |
|
| 146 | + $this->notDisplayFields = [$fields]; |
|
| 147 | + } |
|
| 148 | + } else { |
|
| 149 | + if (is_array($fields)) { |
|
| 150 | + $this->notDisplayFields = array_merge($this->notDisplayFields, $fields); |
|
| 151 | + } else { |
|
| 152 | + $this->notDisplayFields[] = $fields; |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | + } |
|
| 156 | 156 | } |
@@ -28,17 +28,17 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | class Tag extends MlObject |
| 30 | 30 | { |
| 31 | - /** |
|
| 32 | - * SmartobjectTag constructor. |
|
| 33 | - */ |
|
| 34 | - public function __construct() |
|
| 35 | - { |
|
| 36 | - $this->initVar('tagid', XOBJ_DTYPE_INT, '', true); |
|
| 37 | - $this->initVar('name', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_TAG_TAGID_CAPTION, _CO_SOBJECT_TAG_TAGID_DSC, true); |
|
| 38 | - $this->initVar('description', XOBJ_DTYPE_TXTAREA, '', true, null, '', false, _CO_SOBJECT_TAG_DESCRIPTION_CAPTION, _CO_SOBJECT_TAG_DESCRIPTION_DSC); |
|
| 39 | - $this->initVar('value', XOBJ_DTYPE_TXTAREA, '', true, null, '', true, _CO_SOBJECT_TAG_VALUE_CAPTION, _CO_SOBJECT_TAG_VALUE_DSC); |
|
| 31 | + /** |
|
| 32 | + * SmartobjectTag constructor. |
|
| 33 | + */ |
|
| 34 | + public function __construct() |
|
| 35 | + { |
|
| 36 | + $this->initVar('tagid', XOBJ_DTYPE_INT, '', true); |
|
| 37 | + $this->initVar('name', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_TAG_TAGID_CAPTION, _CO_SOBJECT_TAG_TAGID_DSC, true); |
|
| 38 | + $this->initVar('description', XOBJ_DTYPE_TXTAREA, '', true, null, '', false, _CO_SOBJECT_TAG_DESCRIPTION_CAPTION, _CO_SOBJECT_TAG_DESCRIPTION_DSC); |
|
| 39 | + $this->initVar('value', XOBJ_DTYPE_TXTAREA, '', true, null, '', true, _CO_SOBJECT_TAG_VALUE_CAPTION, _CO_SOBJECT_TAG_VALUE_DSC); |
|
| 40 | 40 | |
| 41 | - // call parent constructor to get Multilanguage field initiated |
|
| 42 | - $this->SmartMlObject(); |
|
| 43 | - } |
|
| 41 | + // call parent constructor to get Multilanguage field initiated |
|
| 42 | + $this->SmartMlObject(); |
|
| 43 | + } |
|
| 44 | 44 | } |
@@ -30,17 +30,17 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | class Tree extends \XoopsObjectTree |
| 32 | 32 | { |
| 33 | - public function _initialize() |
|
| 34 | - { |
|
| 35 | - foreach (array_keys($this->_objects) as $i) { |
|
| 36 | - $key1 = $this->_objects[$i]->getVar($this->_myId); |
|
| 37 | - $this->tree[$key1]['obj'] = $this->_objects[$i]; |
|
| 38 | - $key2 = $this->_objects[$i]->getVar($this->_parentId, 'e'); |
|
| 39 | - $this->tree[$key1]['parent'] = $key2; |
|
| 40 | - $this->tree[$key2]['child'][] = $key1; |
|
| 41 | - if (isset($this->_rootId)) { |
|
| 42 | - $this->tree[$key1]['root'] = $this->_objects[$i]->getVar($this->_rootId); |
|
| 43 | - } |
|
| 44 | - } |
|
| 45 | - } |
|
| 33 | + public function _initialize() |
|
| 34 | + { |
|
| 35 | + foreach (array_keys($this->_objects) as $i) { |
|
| 36 | + $key1 = $this->_objects[$i]->getVar($this->_myId); |
|
| 37 | + $this->tree[$key1]['obj'] = $this->_objects[$i]; |
|
| 38 | + $key2 = $this->_objects[$i]->getVar($this->_parentId, 'e'); |
|
| 39 | + $this->tree[$key1]['parent'] = $key2; |
|
| 40 | + $this->tree[$key2]['child'][] = $key1; |
|
| 41 | + if (isset($this->_rootId)) { |
|
| 42 | + $this->tree[$key1]['root'] = $this->_objects[$i]->getVar($this->_rootId); |
|
| 43 | + } |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | 46 | } |