@@ -28,82 +28,82 @@ |
||
| 28 | 28 | $op = isset($_POST['op']) ? $_POST['op'] : ''; |
| 29 | 29 | |
| 30 | 30 | switch ($op) { |
| 31 | - case 'sendlink': |
|
| 32 | - |
|
| 33 | - require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php'; |
|
| 34 | - $controller = new XoopsModules\Smartobject\SmartObjectController($smartobjectLinkHandler); |
|
| 35 | - |
|
| 36 | - $linkObj = $controller->storeSmartObject(); |
|
| 37 | - if ($linkObj->hasError()) { |
|
| 38 | - /** |
|
| 39 | - * @todo inform user and propose to close the window if a problem occured when saving the link |
|
| 40 | - */ |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - $xoopsMailer = xoops_getMailer(); |
|
| 44 | - $xoopsMailer->useMail(); |
|
| 45 | - $xoopsMailer->setTemplateDir('language/' . $xoopsConfig['language'] . '/mail_template'); |
|
| 46 | - |
|
| 47 | - $xoopsMailer->setTemplate('sendlink.tpl'); |
|
| 48 | - $xoopsMailer->assign('X_SITENAME', $xoopsConfig['sitename']); |
|
| 49 | - $xoopsMailer->assign('TO_NAME', $linkObj->getVar('to_name')); |
|
| 50 | - $xoopsMailer->assign('FROM_NAME', $linkObj->getVar('from_name')); |
|
| 51 | - $xoopsMailer->assign('SITEURL', XOOPS_URL . '/'); |
|
| 52 | - $xoopsMailer->assign('ADMINMAIL', $xoopsConfig['adminmail']); |
|
| 53 | - $xoopsMailer->assign('MESSAGE', $_POST['body']); |
|
| 54 | - $xoopsMailer->setToEmails($linkObj->getVar('to_email')); |
|
| 55 | - $xoopsMailer->setFromEmail($linkObj->getVar('from_email')); |
|
| 56 | - $xoopsMailer->setFromName($xoopsConfig['sitename']); |
|
| 57 | - $xoopsMailer->setSubject(sprintf(_CO_SOBJECT_SUBJECT_DEFAULT, $myts->oopsStripSlashesGPC($xoopsConfig['sitename']))); |
|
| 58 | - |
|
| 59 | - if (!$xoopsMailer->send(true)) { |
|
| 60 | - $xoopsTpl->assign('send_error', sprintf(_CO_SOBJECT_SEND_ERROR, $xoopsConfig['adminmail']) . '<br>' . $xoopsMailer->getErrors(true)); |
|
| 61 | - } else { |
|
| 62 | - $xoopsTpl->assign('send_success', _CO_SOBJECT_SEND_SUCCESS); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - break; |
|
| 66 | - |
|
| 67 | - default: |
|
| 68 | - if (isset($_GET['mid'])) { |
|
| 69 | - $mid = $_GET['mid']; |
|
| 70 | - } else { |
|
| 71 | - /** |
|
| 72 | - * @todo close the window if no mid is passed as GET |
|
| 73 | - */ |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - $hModule = xoops_getHandler('module'); |
|
| 77 | - $module = $hModule->get($mid); |
|
| 78 | - $linkObj->setVar('mid', $module->getVar('mid')); |
|
| 79 | - $linkObj->setVar('mid_name', $module->getVar('name')); |
|
| 80 | - |
|
| 81 | - if (isset($_GET['link'])) { |
|
| 82 | - $link = $_GET['link']; |
|
| 83 | - } else { |
|
| 84 | - /** |
|
| 85 | - * @todo close the window if no link is passed as GET |
|
| 86 | - */ |
|
| 87 | - } |
|
| 88 | - $linkObj->setVar('link', $link); |
|
| 89 | - |
|
| 90 | - if (is_object($xoopsUser)) { |
|
| 91 | - $linkObj->setVar('from_uid', $xoopsUser->getVar('uid')); |
|
| 92 | - $linkObj->setVar('from_name', '' !== $xoopsUser->getVar('name') ? $xoopsUser->getVar('name') : $xoopsUser->getVar('uname')); |
|
| 93 | - $linkObj->setVar('from_email', $xoopsUser->getVar('email')); |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - $linkObj->setVar('subject', sprintf(_CO_SOBJECT_SUBJECT_DEFAULT, $xoopsConfig['sitename'])); |
|
| 97 | - $linkObj->setVar('body', sprintf(_CO_SOBJECT_BODY_DEFAULT, $xoopsConfig['sitename'], $link)); |
|
| 98 | - $linkObj->setVar('date', time()); |
|
| 99 | - $linkObj->hideFieldFromForm(['from_uid', 'to_uid', 'link', 'mid', 'mid_name']); |
|
| 100 | - |
|
| 101 | - $form = $linkObj->getForm(_CO_SOBJECT_SEND_LINK_FORM, 'sendlink', false, _SEND, 'javascript:window.close();'); |
|
| 102 | - |
|
| 103 | - $form->assign($xoopsTpl); |
|
| 104 | - |
|
| 105 | - $xoopsTpl->assign('showform', true); |
|
| 106 | - break; |
|
| 31 | + case 'sendlink': |
|
| 32 | + |
|
| 33 | + require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php'; |
|
| 34 | + $controller = new XoopsModules\Smartobject\SmartObjectController($smartobjectLinkHandler); |
|
| 35 | + |
|
| 36 | + $linkObj = $controller->storeSmartObject(); |
|
| 37 | + if ($linkObj->hasError()) { |
|
| 38 | + /** |
|
| 39 | + * @todo inform user and propose to close the window if a problem occured when saving the link |
|
| 40 | + */ |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + $xoopsMailer = xoops_getMailer(); |
|
| 44 | + $xoopsMailer->useMail(); |
|
| 45 | + $xoopsMailer->setTemplateDir('language/' . $xoopsConfig['language'] . '/mail_template'); |
|
| 46 | + |
|
| 47 | + $xoopsMailer->setTemplate('sendlink.tpl'); |
|
| 48 | + $xoopsMailer->assign('X_SITENAME', $xoopsConfig['sitename']); |
|
| 49 | + $xoopsMailer->assign('TO_NAME', $linkObj->getVar('to_name')); |
|
| 50 | + $xoopsMailer->assign('FROM_NAME', $linkObj->getVar('from_name')); |
|
| 51 | + $xoopsMailer->assign('SITEURL', XOOPS_URL . '/'); |
|
| 52 | + $xoopsMailer->assign('ADMINMAIL', $xoopsConfig['adminmail']); |
|
| 53 | + $xoopsMailer->assign('MESSAGE', $_POST['body']); |
|
| 54 | + $xoopsMailer->setToEmails($linkObj->getVar('to_email')); |
|
| 55 | + $xoopsMailer->setFromEmail($linkObj->getVar('from_email')); |
|
| 56 | + $xoopsMailer->setFromName($xoopsConfig['sitename']); |
|
| 57 | + $xoopsMailer->setSubject(sprintf(_CO_SOBJECT_SUBJECT_DEFAULT, $myts->oopsStripSlashesGPC($xoopsConfig['sitename']))); |
|
| 58 | + |
|
| 59 | + if (!$xoopsMailer->send(true)) { |
|
| 60 | + $xoopsTpl->assign('send_error', sprintf(_CO_SOBJECT_SEND_ERROR, $xoopsConfig['adminmail']) . '<br>' . $xoopsMailer->getErrors(true)); |
|
| 61 | + } else { |
|
| 62 | + $xoopsTpl->assign('send_success', _CO_SOBJECT_SEND_SUCCESS); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + break; |
|
| 66 | + |
|
| 67 | + default: |
|
| 68 | + if (isset($_GET['mid'])) { |
|
| 69 | + $mid = $_GET['mid']; |
|
| 70 | + } else { |
|
| 71 | + /** |
|
| 72 | + * @todo close the window if no mid is passed as GET |
|
| 73 | + */ |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + $hModule = xoops_getHandler('module'); |
|
| 77 | + $module = $hModule->get($mid); |
|
| 78 | + $linkObj->setVar('mid', $module->getVar('mid')); |
|
| 79 | + $linkObj->setVar('mid_name', $module->getVar('name')); |
|
| 80 | + |
|
| 81 | + if (isset($_GET['link'])) { |
|
| 82 | + $link = $_GET['link']; |
|
| 83 | + } else { |
|
| 84 | + /** |
|
| 85 | + * @todo close the window if no link is passed as GET |
|
| 86 | + */ |
|
| 87 | + } |
|
| 88 | + $linkObj->setVar('link', $link); |
|
| 89 | + |
|
| 90 | + if (is_object($xoopsUser)) { |
|
| 91 | + $linkObj->setVar('from_uid', $xoopsUser->getVar('uid')); |
|
| 92 | + $linkObj->setVar('from_name', '' !== $xoopsUser->getVar('name') ? $xoopsUser->getVar('name') : $xoopsUser->getVar('uname')); |
|
| 93 | + $linkObj->setVar('from_email', $xoopsUser->getVar('email')); |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + $linkObj->setVar('subject', sprintf(_CO_SOBJECT_SUBJECT_DEFAULT, $xoopsConfig['sitename'])); |
|
| 97 | + $linkObj->setVar('body', sprintf(_CO_SOBJECT_BODY_DEFAULT, $xoopsConfig['sitename'], $link)); |
|
| 98 | + $linkObj->setVar('date', time()); |
|
| 99 | + $linkObj->hideFieldFromForm(['from_uid', 'to_uid', 'link', 'mid', 'mid_name']); |
|
| 100 | + |
|
| 101 | + $form = $linkObj->getForm(_CO_SOBJECT_SEND_LINK_FORM, 'sendlink', false, _SEND, 'javascript:window.close();'); |
|
| 102 | + |
|
| 103 | + $form->assign($xoopsTpl); |
|
| 104 | + |
|
| 105 | + $xoopsTpl->assign('showform', true); |
|
| 106 | + break; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | $xoopsTpl->display('db:smartobject_sendlink.tpl'); |
@@ -4,29 +4,29 @@ |
||
| 4 | 4 | * @see http://www.php-fig.org/psr/psr-4/examples/ |
| 5 | 5 | */ |
| 6 | 6 | spl_autoload_register(function ($class) { |
| 7 | - // project-specific namespace prefix |
|
| 8 | - $prefix = 'XoopsModules\\' . ucfirst(basename(dirname(__DIR__))); |
|
| 7 | + // project-specific namespace prefix |
|
| 8 | + $prefix = 'XoopsModules\\' . ucfirst(basename(dirname(__DIR__))); |
|
| 9 | 9 | |
| 10 | - // base directory for the namespace prefix |
|
| 11 | - $base_dir = __DIR__ . '/../class/'; |
|
| 10 | + // base directory for the namespace prefix |
|
| 11 | + $base_dir = __DIR__ . '/../class/'; |
|
| 12 | 12 | |
| 13 | - // does the class use the namespace prefix? |
|
| 14 | - $len = strlen($prefix); |
|
| 13 | + // does the class use the namespace prefix? |
|
| 14 | + $len = strlen($prefix); |
|
| 15 | 15 | |
| 16 | - if (0 !== strncmp($prefix, $class, $len)) { |
|
| 17 | - return; |
|
| 18 | - } |
|
| 16 | + if (0 !== strncmp($prefix, $class, $len)) { |
|
| 17 | + return; |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - // get the relative class name |
|
| 21 | - $relative_class = substr($class, $len); |
|
| 20 | + // get the relative class name |
|
| 21 | + $relative_class = substr($class, $len); |
|
| 22 | 22 | |
| 23 | - // replace the namespace prefix with the base directory, replace namespace |
|
| 24 | - // separators with directory separators in the relative class name, append |
|
| 25 | - // with .php |
|
| 26 | - $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php'; |
|
| 23 | + // replace the namespace prefix with the base directory, replace namespace |
|
| 24 | + // separators with directory separators in the relative class name, append |
|
| 25 | + // with .php |
|
| 26 | + $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php'; |
|
| 27 | 27 | |
| 28 | - // if the file exists, require it |
|
| 29 | - if (file_exists($file)) { |
|
| 30 | - require $file; |
|
| 31 | - } |
|
| 28 | + // if the file exists, require it |
|
| 29 | + if (file_exists($file)) { |
|
| 30 | + require $file; |
|
| 31 | + } |
|
| 32 | 32 | }); |
@@ -22,12 +22,12 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class SmartobjectCorePreload extends \XoopsPreloadItem |
| 24 | 24 | { |
| 25 | - // to add PSR-4 autoloader |
|
| 26 | - /** |
|
| 27 | - * @param $args |
|
| 28 | - */ |
|
| 29 | - public static function eventCoreIncludeCommonEnd($args) |
|
| 30 | - { |
|
| 31 | - include __DIR__ . '/autoloader.php'; |
|
| 32 | - } |
|
| 25 | + // to add PSR-4 autoloader |
|
| 26 | + /** |
|
| 27 | + * @param $args |
|
| 28 | + */ |
|
| 29 | + public static function eventCoreIncludeCommonEnd($args) |
|
| 30 | + { |
|
| 31 | + include __DIR__ . '/autoloader.php'; |
|
| 32 | + } |
|
| 33 | 33 | } |
@@ -30,123 +30,123 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | class SmartobjectRating extends Smartobject\BaseSmartObject |
| 32 | 32 | { |
| 33 | - public $_modulePlugin = false; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * SmartobjectRating constructor. |
|
| 37 | - */ |
|
| 38 | - public function __construct() |
|
| 39 | - { |
|
| 40 | - $this->quickInitVar('ratingid', XOBJ_DTYPE_INT, true); |
|
| 41 | - $this->quickInitVar('dirname', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_RATING_DIRNAME); |
|
| 42 | - $this->quickInitVar('item', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_RATING_ITEM); |
|
| 43 | - $this->quickInitVar('itemid', XOBJ_DTYPE_INT, true, _CO_SOBJECT_RATING_ITEMID); |
|
| 44 | - $this->quickInitVar('uid', XOBJ_DTYPE_INT, true, _CO_SOBJECT_RATING_UID); |
|
| 45 | - $this->quickInitVar('date', XOBJ_DTYPE_LTIME, true, _CO_SOBJECT_RATING_DATE); |
|
| 46 | - $this->quickInitVar('rate', XOBJ_DTYPE_INT, true, _CO_SOBJECT_RATING_RATE); |
|
| 47 | - |
|
| 48 | - $this->initNonPersistableVar('name', XOBJ_DTYPE_TXTBOX, 'user', _CO_SOBJECT_RATING_NAME); |
|
| 49 | - |
|
| 50 | - $this->setControl('dirname', [ |
|
| 51 | - 'handler' => 'rating', |
|
| 52 | - 'method' => 'getModuleList', |
|
| 53 | - 'onSelect' => 'submit' |
|
| 54 | - ]); |
|
| 55 | - |
|
| 56 | - $this->setControl('item', [ |
|
| 57 | - 'object' => &$this, |
|
| 58 | - 'method' => 'getItemList' |
|
| 59 | - ]); |
|
| 60 | - |
|
| 61 | - $this->setControl('uid', 'user'); |
|
| 62 | - |
|
| 63 | - $this->setControl('rate', [ |
|
| 64 | - 'handler' => 'rating', |
|
| 65 | - 'method' => 'getRateList' |
|
| 66 | - ]); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * @param string $key |
|
| 71 | - * @param string $format |
|
| 72 | - * @return mixed |
|
| 73 | - */ |
|
| 74 | - public function getVar($key, $format = 's') |
|
| 75 | - { |
|
| 76 | - if ('s' === $format && in_array($key, ['name', 'dirname'])) { |
|
| 77 | - // return call_user_func(array($this, $key)); |
|
| 78 | - return $this->{$key}(); |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - return parent::getVar($key, $format); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * @return string |
|
| 86 | - */ |
|
| 87 | - public function name() |
|
| 88 | - { |
|
| 89 | - $ret = smart_getLinkedUnameFromId($this->getVar('uid', 'e'), true, []); |
|
| 90 | - |
|
| 91 | - return $ret; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * @return mixed |
|
| 96 | - */ |
|
| 97 | - public function dirname() |
|
| 98 | - { |
|
| 99 | - global $smartobjectRatingHandler; |
|
| 100 | - $moduleArray = $smartobjectRatingHandler->getModuleList(); |
|
| 101 | - |
|
| 102 | - return $moduleArray[$this->getVar('dirname', 'n')]; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * @return mixed |
|
| 107 | - */ |
|
| 108 | - public function getItemList() |
|
| 109 | - { |
|
| 110 | - $plugin = $this->getModulePlugin(); |
|
| 111 | - |
|
| 112 | - return $plugin->getItemList(); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * @return string |
|
| 117 | - */ |
|
| 118 | - public function getItemValue() |
|
| 119 | - { |
|
| 120 | - $moduleUrl = XOOPS_URL . '/modules/' . $this->getVar('dirname', 'n') . '/'; |
|
| 121 | - $plugin = $this->getModulePlugin(); |
|
| 122 | - $pluginItemInfo = $plugin->getItemInfo($this->getVar('item')); |
|
| 123 | - if (!$pluginItemInfo) { |
|
| 124 | - return ''; |
|
| 125 | - } |
|
| 126 | - $itemPath = sprintf($pluginItemInfo['url'], $this->getVar('itemid')); |
|
| 127 | - $ret = '<a href="' . $moduleUrl . $itemPath . '">' . $pluginItemInfo['caption'] . '</a>'; |
|
| 128 | - |
|
| 129 | - return $ret; |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * @return mixed |
|
| 134 | - */ |
|
| 135 | - public function getRateValue() |
|
| 136 | - { |
|
| 137 | - return $this->getVar('rate'); |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * @return bool |
|
| 142 | - */ |
|
| 143 | - public function getModulePlugin() |
|
| 144 | - { |
|
| 145 | - if (!$this->_modulePlugin) { |
|
| 146 | - global $smartobjectRatingHandler; |
|
| 147 | - $this->_modulePlugin = $smartobjectRatingHandler->pluginsObject->getPlugin($this->getVar('dirname', 'n')); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - return $this->_modulePlugin; |
|
| 151 | - } |
|
| 33 | + public $_modulePlugin = false; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * SmartobjectRating constructor. |
|
| 37 | + */ |
|
| 38 | + public function __construct() |
|
| 39 | + { |
|
| 40 | + $this->quickInitVar('ratingid', XOBJ_DTYPE_INT, true); |
|
| 41 | + $this->quickInitVar('dirname', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_RATING_DIRNAME); |
|
| 42 | + $this->quickInitVar('item', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_RATING_ITEM); |
|
| 43 | + $this->quickInitVar('itemid', XOBJ_DTYPE_INT, true, _CO_SOBJECT_RATING_ITEMID); |
|
| 44 | + $this->quickInitVar('uid', XOBJ_DTYPE_INT, true, _CO_SOBJECT_RATING_UID); |
|
| 45 | + $this->quickInitVar('date', XOBJ_DTYPE_LTIME, true, _CO_SOBJECT_RATING_DATE); |
|
| 46 | + $this->quickInitVar('rate', XOBJ_DTYPE_INT, true, _CO_SOBJECT_RATING_RATE); |
|
| 47 | + |
|
| 48 | + $this->initNonPersistableVar('name', XOBJ_DTYPE_TXTBOX, 'user', _CO_SOBJECT_RATING_NAME); |
|
| 49 | + |
|
| 50 | + $this->setControl('dirname', [ |
|
| 51 | + 'handler' => 'rating', |
|
| 52 | + 'method' => 'getModuleList', |
|
| 53 | + 'onSelect' => 'submit' |
|
| 54 | + ]); |
|
| 55 | + |
|
| 56 | + $this->setControl('item', [ |
|
| 57 | + 'object' => &$this, |
|
| 58 | + 'method' => 'getItemList' |
|
| 59 | + ]); |
|
| 60 | + |
|
| 61 | + $this->setControl('uid', 'user'); |
|
| 62 | + |
|
| 63 | + $this->setControl('rate', [ |
|
| 64 | + 'handler' => 'rating', |
|
| 65 | + 'method' => 'getRateList' |
|
| 66 | + ]); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * @param string $key |
|
| 71 | + * @param string $format |
|
| 72 | + * @return mixed |
|
| 73 | + */ |
|
| 74 | + public function getVar($key, $format = 's') |
|
| 75 | + { |
|
| 76 | + if ('s' === $format && in_array($key, ['name', 'dirname'])) { |
|
| 77 | + // return call_user_func(array($this, $key)); |
|
| 78 | + return $this->{$key}(); |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + return parent::getVar($key, $format); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * @return string |
|
| 86 | + */ |
|
| 87 | + public function name() |
|
| 88 | + { |
|
| 89 | + $ret = smart_getLinkedUnameFromId($this->getVar('uid', 'e'), true, []); |
|
| 90 | + |
|
| 91 | + return $ret; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * @return mixed |
|
| 96 | + */ |
|
| 97 | + public function dirname() |
|
| 98 | + { |
|
| 99 | + global $smartobjectRatingHandler; |
|
| 100 | + $moduleArray = $smartobjectRatingHandler->getModuleList(); |
|
| 101 | + |
|
| 102 | + return $moduleArray[$this->getVar('dirname', 'n')]; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * @return mixed |
|
| 107 | + */ |
|
| 108 | + public function getItemList() |
|
| 109 | + { |
|
| 110 | + $plugin = $this->getModulePlugin(); |
|
| 111 | + |
|
| 112 | + return $plugin->getItemList(); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * @return string |
|
| 117 | + */ |
|
| 118 | + public function getItemValue() |
|
| 119 | + { |
|
| 120 | + $moduleUrl = XOOPS_URL . '/modules/' . $this->getVar('dirname', 'n') . '/'; |
|
| 121 | + $plugin = $this->getModulePlugin(); |
|
| 122 | + $pluginItemInfo = $plugin->getItemInfo($this->getVar('item')); |
|
| 123 | + if (!$pluginItemInfo) { |
|
| 124 | + return ''; |
|
| 125 | + } |
|
| 126 | + $itemPath = sprintf($pluginItemInfo['url'], $this->getVar('itemid')); |
|
| 127 | + $ret = '<a href="' . $moduleUrl . $itemPath . '">' . $pluginItemInfo['caption'] . '</a>'; |
|
| 128 | + |
|
| 129 | + return $ret; |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * @return mixed |
|
| 134 | + */ |
|
| 135 | + public function getRateValue() |
|
| 136 | + { |
|
| 137 | + return $this->getVar('rate'); |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * @return bool |
|
| 142 | + */ |
|
| 143 | + public function getModulePlugin() |
|
| 144 | + { |
|
| 145 | + if (!$this->_modulePlugin) { |
|
| 146 | + global $smartobjectRatingHandler; |
|
| 147 | + $this->_modulePlugin = $smartobjectRatingHandler->pluginsObject->getPlugin($this->getVar('dirname', 'n')); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + return $this->_modulePlugin; |
|
| 151 | + } |
|
| 152 | 152 | } |
@@ -30,17 +30,17 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | class SmartObjectTree 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 | } |
@@ -21,60 +21,60 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class SmartPersistableMlObjectHandler extends Smartobject\SmartPersistableObjectHandler |
| 23 | 23 | { |
| 24 | - /** |
|
| 25 | - * @param null|\CriteriaElement $criteria |
|
| 26 | - * @param bool $id_as_key |
|
| 27 | - * @param bool $as_object |
|
| 28 | - * @param bool $debug |
|
| 29 | - * @param bool $language |
|
| 30 | - * @return array |
|
| 31 | - */ |
|
| 32 | - public function getObjects( |
|
| 33 | - \CriteriaElement $criteria = null, |
|
| 34 | - $id_as_key = false, |
|
| 35 | - $as_object = true, |
|
| 36 | - $debug = false, |
|
| 37 | - $language = false |
|
| 38 | - ) { |
|
| 39 | - // Create the first part of the SQL query to join the "_text" table |
|
| 40 | - $sql = 'SELECT * FROM ' . $this->table . ' AS ' . $this->_itemname . ' INNER JOIN ' . $this->table . '_text AS ' . $this->_itemname . '_text ON ' . $this->_itemname . '.' . $this->keyName . '=' . $this->_itemname . '_text.' . $this->keyName; |
|
| 24 | + /** |
|
| 25 | + * @param null|\CriteriaElement $criteria |
|
| 26 | + * @param bool $id_as_key |
|
| 27 | + * @param bool $as_object |
|
| 28 | + * @param bool $debug |
|
| 29 | + * @param bool $language |
|
| 30 | + * @return array |
|
| 31 | + */ |
|
| 32 | + public function getObjects( |
|
| 33 | + \CriteriaElement $criteria = null, |
|
| 34 | + $id_as_key = false, |
|
| 35 | + $as_object = true, |
|
| 36 | + $debug = false, |
|
| 37 | + $language = false |
|
| 38 | + ) { |
|
| 39 | + // Create the first part of the SQL query to join the "_text" table |
|
| 40 | + $sql = 'SELECT * FROM ' . $this->table . ' AS ' . $this->_itemname . ' INNER JOIN ' . $this->table . '_text AS ' . $this->_itemname . '_text ON ' . $this->_itemname . '.' . $this->keyName . '=' . $this->_itemname . '_text.' . $this->keyName; |
|
| 41 | 41 | |
| 42 | - if ($language) { |
|
| 43 | - // If a language was specified, then let's create a WHERE clause to only return the objects associated with this language |
|
| 42 | + if ($language) { |
|
| 43 | + // If a language was specified, then let's create a WHERE clause to only return the objects associated with this language |
|
| 44 | 44 | |
| 45 | - // if no criteria was previously created, let's create it |
|
| 46 | - if (!$criteria) { |
|
| 47 | - $criteria = new \CriteriaCompo(); |
|
| 48 | - } |
|
| 49 | - $criteria->add(new \Criteria('language', $language)); |
|
| 45 | + // if no criteria was previously created, let's create it |
|
| 46 | + if (!$criteria) { |
|
| 47 | + $criteria = new \CriteriaCompo(); |
|
| 48 | + } |
|
| 49 | + $criteria->add(new \Criteria('language', $language)); |
|
| 50 | 50 | |
| 51 | - return parent::getObjects($criteria, $id_as_key, $as_object, $debug, $sql); |
|
| 52 | - } |
|
| 51 | + return parent::getObjects($criteria, $id_as_key, $as_object, $debug, $sql); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - return parent::getObjects($criteria, $id_as_key, $as_object, $debug, $sql); |
|
| 55 | - } |
|
| 54 | + return parent::getObjects($criteria, $id_as_key, $as_object, $debug, $sql); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * @param mixed $id |
|
| 59 | - * @param bool $language |
|
| 60 | - * @param bool $as_object |
|
| 61 | - * @param bool $debug |
|
| 62 | - * @return mixed |
|
| 63 | - */ |
|
| 64 | - public function &get($id, $language = false, $as_object = true, $debug = false) |
|
| 65 | - { |
|
| 66 | - if (!$language) { |
|
| 67 | - return parent::get($id, $as_object, $debug); |
|
| 68 | - } else { |
|
| 69 | - $criteria = new \CriteriaCompo(); |
|
| 70 | - $criteria->add(new \Criteria('language', $language)); |
|
| 57 | + /** |
|
| 58 | + * @param mixed $id |
|
| 59 | + * @param bool $language |
|
| 60 | + * @param bool $as_object |
|
| 61 | + * @param bool $debug |
|
| 62 | + * @return mixed |
|
| 63 | + */ |
|
| 64 | + public function &get($id, $language = false, $as_object = true, $debug = false) |
|
| 65 | + { |
|
| 66 | + if (!$language) { |
|
| 67 | + return parent::get($id, $as_object, $debug); |
|
| 68 | + } else { |
|
| 69 | + $criteria = new \CriteriaCompo(); |
|
| 70 | + $criteria->add(new \Criteria('language', $language)); |
|
| 71 | 71 | |
| 72 | - return parent::get($id, $as_object, $debug, $criteria); |
|
| 73 | - } |
|
| 74 | - } |
|
| 72 | + return parent::get($id, $as_object, $debug, $criteria); |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - public function changeTableNameForML() |
|
| 77 | - { |
|
| 78 | - $this->table = $this->db->prefix($this->_moduleName . '_' . $this->_itemname . '_text'); |
|
| 79 | - } |
|
| 76 | + public function changeTableNameForML() |
|
| 77 | + { |
|
| 78 | + $this->table = $this->db->prefix($this->_moduleName . '_' . $this->_itemname . '_text'); |
|
| 79 | + } |
|
| 80 | 80 | } |
@@ -25,157 +25,157 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | class SmartObjectTreeTable extends Smartobject\BaseSmartObjectTable |
| 27 | 27 | { |
| 28 | - /** |
|
| 29 | - * SmartObjectTreeTable constructor. |
|
| 30 | - * @param SmartPersistableObjectHandler $objectHandler |
|
| 31 | - * @param bool $criteria |
|
| 32 | - * @param array $actions |
|
| 33 | - * @param bool $userSide |
|
| 34 | - */ |
|
| 35 | - public function __construct( |
|
| 36 | - SmartPersistableObjectHandler $objectHandler, |
|
| 37 | - $criteria = false, |
|
| 38 | - $actions = ['edit', 'delete'], |
|
| 39 | - $userSide = false |
|
| 40 | - ) { |
|
| 41 | - $this->SmartObjectTable($objectHandler, $criteria, $actions, $userSide); |
|
| 42 | - $this->_isTree = true; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * Get children objects given a specific parentid |
|
| 47 | - * |
|
| 48 | - * @var int $parentid id of the parent which children we want to retreive |
|
| 49 | - * @return array of SmartObject |
|
| 50 | - */ |
|
| 51 | - public function getChildrenOf($parentid = 0) |
|
| 52 | - { |
|
| 53 | - return isset($this->_objects[$parentid]) ? $this->_objects[$parentid] : false; |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * @param $object |
|
| 58 | - * @param int $level |
|
| 59 | - */ |
|
| 60 | - public function createTableRow($object, $level = 0) |
|
| 61 | - { |
|
| 62 | - $aObject = []; |
|
| 63 | - |
|
| 64 | - $i = 0; |
|
| 65 | - |
|
| 66 | - $aColumns = []; |
|
| 67 | - $doWeHaveActions = false; |
|
| 68 | - |
|
| 69 | - foreach ($this->_columns as $column) { |
|
| 70 | - $aColumn = []; |
|
| 71 | - |
|
| 72 | - if (0 == $i) { |
|
| 73 | - $class = 'head'; |
|
| 74 | - } elseif (0 == $i % 2) { |
|
| 75 | - $class = 'even'; |
|
| 76 | - } else { |
|
| 77 | - $class = 'odd'; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - if ($column->_customMethodForValue && method_exists($object, $column->_customMethodForValue)) { |
|
| 81 | - $method = $column->_customMethodForValue; |
|
| 82 | - $value = $object->$method(); |
|
| 83 | - } else { |
|
| 84 | - /** |
|
| 85 | - * If the column is the identifier, then put a link on it |
|
| 86 | - */ |
|
| 87 | - if ($column->getKeyName() == $this->_objectHandler->identifierName) { |
|
| 88 | - $value = $object->getItemLink(); |
|
| 89 | - } else { |
|
| 90 | - $value = $object->getVar($column->getKeyName()); |
|
| 91 | - } |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - $space = ''; |
|
| 95 | - if ($column->getKeyName() == $this->_objectHandler->identifierName) { |
|
| 96 | - for ($i = 0; $i < $level; ++$i) { |
|
| 97 | - $space .= '--'; |
|
| 98 | - } |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - if ('' !== $space) { |
|
| 102 | - $space .= ' '; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - $aColumn['value'] = $space . $value; |
|
| 106 | - $aColumn['class'] = $class; |
|
| 107 | - $aColumn['width'] = $column->getWidth(); |
|
| 108 | - $aColumn['align'] = $column->getAlign(); |
|
| 109 | - $aColumn['key'] = $column->getKeyName(); |
|
| 110 | - |
|
| 111 | - $aColumns[] = $aColumn; |
|
| 112 | - ++$i; |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - $aObject['columns'] = $aColumns; |
|
| 116 | - |
|
| 117 | - $class = 'even' === $class ? 'odd' : 'even'; |
|
| 118 | - $aObject['class'] = $class; |
|
| 119 | - |
|
| 120 | - $actions = []; |
|
| 121 | - |
|
| 122 | - // Adding the custom actions if any |
|
| 123 | - foreach ($this->_custom_actions as $action) { |
|
| 124 | - if (method_exists($object, $action)) { |
|
| 125 | - $actions[] = $object->$action(); |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectcontroller.php'; |
|
| 130 | - $controller = new SmartObjectController($this->_objectHandler); |
|
| 131 | - |
|
| 132 | - if (in_array('edit', $this->_actions)) { |
|
| 133 | - $actions[] = $controller->getEditItemLink($object, false, true); |
|
| 134 | - } |
|
| 135 | - if (in_array('delete', $this->_actions)) { |
|
| 136 | - $actions[] = $controller->getDeleteItemLink($object, false, true); |
|
| 137 | - } |
|
| 138 | - $aObject['actions'] = $actions; |
|
| 139 | - |
|
| 140 | - $this->_tpl->assign('smartobject_actions_column_width', count($actions) * 30); |
|
| 141 | - $aObject['id'] = $object->id(); |
|
| 142 | - $this->_aObjects[] = $aObject; |
|
| 143 | - |
|
| 144 | - $childrenObjects = $this->getChildrenOf($object->id()); |
|
| 145 | - |
|
| 146 | - $this->_hasActions = $this->_hasActions ? true : count($actions) > 0; |
|
| 147 | - |
|
| 148 | - if ($childrenObjects) { |
|
| 149 | - ++$level; |
|
| 150 | - foreach ($childrenObjects as $subObject) { |
|
| 151 | - $this->createTableRow($subObject, $level); |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - public function createTableRows() |
|
| 157 | - { |
|
| 158 | - $this->_aObjects = []; |
|
| 159 | - |
|
| 160 | - if (count($this->_objects) > 0) { |
|
| 161 | - foreach ($this->getChildrenOf() as $object) { |
|
| 162 | - $this->createTableRow($object); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - $this->_tpl->assign('smartobject_objects', $this->_aObjects); |
|
| 166 | - } else { |
|
| 167 | - $colspan = count($this->_columns) + 1; |
|
| 168 | - $this->_tpl->assign('smartobject_colspan', $colspan); |
|
| 169 | - } |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - /** |
|
| 173 | - * @return mixed |
|
| 174 | - */ |
|
| 175 | - public function fetchObjects() |
|
| 176 | - { |
|
| 177 | - $ret = $this->_objectHandler->getObjects($this->_criteria, 'parentid'); |
|
| 178 | - |
|
| 179 | - return $ret; |
|
| 180 | - } |
|
| 28 | + /** |
|
| 29 | + * SmartObjectTreeTable constructor. |
|
| 30 | + * @param SmartPersistableObjectHandler $objectHandler |
|
| 31 | + * @param bool $criteria |
|
| 32 | + * @param array $actions |
|
| 33 | + * @param bool $userSide |
|
| 34 | + */ |
|
| 35 | + public function __construct( |
|
| 36 | + SmartPersistableObjectHandler $objectHandler, |
|
| 37 | + $criteria = false, |
|
| 38 | + $actions = ['edit', 'delete'], |
|
| 39 | + $userSide = false |
|
| 40 | + ) { |
|
| 41 | + $this->SmartObjectTable($objectHandler, $criteria, $actions, $userSide); |
|
| 42 | + $this->_isTree = true; |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * Get children objects given a specific parentid |
|
| 47 | + * |
|
| 48 | + * @var int $parentid id of the parent which children we want to retreive |
|
| 49 | + * @return array of SmartObject |
|
| 50 | + */ |
|
| 51 | + public function getChildrenOf($parentid = 0) |
|
| 52 | + { |
|
| 53 | + return isset($this->_objects[$parentid]) ? $this->_objects[$parentid] : false; |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * @param $object |
|
| 58 | + * @param int $level |
|
| 59 | + */ |
|
| 60 | + public function createTableRow($object, $level = 0) |
|
| 61 | + { |
|
| 62 | + $aObject = []; |
|
| 63 | + |
|
| 64 | + $i = 0; |
|
| 65 | + |
|
| 66 | + $aColumns = []; |
|
| 67 | + $doWeHaveActions = false; |
|
| 68 | + |
|
| 69 | + foreach ($this->_columns as $column) { |
|
| 70 | + $aColumn = []; |
|
| 71 | + |
|
| 72 | + if (0 == $i) { |
|
| 73 | + $class = 'head'; |
|
| 74 | + } elseif (0 == $i % 2) { |
|
| 75 | + $class = 'even'; |
|
| 76 | + } else { |
|
| 77 | + $class = 'odd'; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + if ($column->_customMethodForValue && method_exists($object, $column->_customMethodForValue)) { |
|
| 81 | + $method = $column->_customMethodForValue; |
|
| 82 | + $value = $object->$method(); |
|
| 83 | + } else { |
|
| 84 | + /** |
|
| 85 | + * If the column is the identifier, then put a link on it |
|
| 86 | + */ |
|
| 87 | + if ($column->getKeyName() == $this->_objectHandler->identifierName) { |
|
| 88 | + $value = $object->getItemLink(); |
|
| 89 | + } else { |
|
| 90 | + $value = $object->getVar($column->getKeyName()); |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + $space = ''; |
|
| 95 | + if ($column->getKeyName() == $this->_objectHandler->identifierName) { |
|
| 96 | + for ($i = 0; $i < $level; ++$i) { |
|
| 97 | + $space .= '--'; |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + if ('' !== $space) { |
|
| 102 | + $space .= ' '; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + $aColumn['value'] = $space . $value; |
|
| 106 | + $aColumn['class'] = $class; |
|
| 107 | + $aColumn['width'] = $column->getWidth(); |
|
| 108 | + $aColumn['align'] = $column->getAlign(); |
|
| 109 | + $aColumn['key'] = $column->getKeyName(); |
|
| 110 | + |
|
| 111 | + $aColumns[] = $aColumn; |
|
| 112 | + ++$i; |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + $aObject['columns'] = $aColumns; |
|
| 116 | + |
|
| 117 | + $class = 'even' === $class ? 'odd' : 'even'; |
|
| 118 | + $aObject['class'] = $class; |
|
| 119 | + |
|
| 120 | + $actions = []; |
|
| 121 | + |
|
| 122 | + // Adding the custom actions if any |
|
| 123 | + foreach ($this->_custom_actions as $action) { |
|
| 124 | + if (method_exists($object, $action)) { |
|
| 125 | + $actions[] = $object->$action(); |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectcontroller.php'; |
|
| 130 | + $controller = new SmartObjectController($this->_objectHandler); |
|
| 131 | + |
|
| 132 | + if (in_array('edit', $this->_actions)) { |
|
| 133 | + $actions[] = $controller->getEditItemLink($object, false, true); |
|
| 134 | + } |
|
| 135 | + if (in_array('delete', $this->_actions)) { |
|
| 136 | + $actions[] = $controller->getDeleteItemLink($object, false, true); |
|
| 137 | + } |
|
| 138 | + $aObject['actions'] = $actions; |
|
| 139 | + |
|
| 140 | + $this->_tpl->assign('smartobject_actions_column_width', count($actions) * 30); |
|
| 141 | + $aObject['id'] = $object->id(); |
|
| 142 | + $this->_aObjects[] = $aObject; |
|
| 143 | + |
|
| 144 | + $childrenObjects = $this->getChildrenOf($object->id()); |
|
| 145 | + |
|
| 146 | + $this->_hasActions = $this->_hasActions ? true : count($actions) > 0; |
|
| 147 | + |
|
| 148 | + if ($childrenObjects) { |
|
| 149 | + ++$level; |
|
| 150 | + foreach ($childrenObjects as $subObject) { |
|
| 151 | + $this->createTableRow($subObject, $level); |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + public function createTableRows() |
|
| 157 | + { |
|
| 158 | + $this->_aObjects = []; |
|
| 159 | + |
|
| 160 | + if (count($this->_objects) > 0) { |
|
| 161 | + foreach ($this->getChildrenOf() as $object) { |
|
| 162 | + $this->createTableRow($object); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + $this->_tpl->assign('smartobject_objects', $this->_aObjects); |
|
| 166 | + } else { |
|
| 167 | + $colspan = count($this->_columns) + 1; |
|
| 168 | + $this->_tpl->assign('smartobject_colspan', $colspan); |
|
| 169 | + } |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + /** |
|
| 173 | + * @return mixed |
|
| 174 | + */ |
|
| 175 | + public function fetchObjects() |
|
| 176 | + { |
|
| 177 | + $ret = $this->_objectHandler->getObjects($this->_criteria, 'parentid'); |
|
| 178 | + |
|
| 179 | + return $ret; |
|
| 180 | + } |
|
| 181 | 181 | } |
@@ -25,66 +25,66 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | class SmartPlugin |
| 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 | } |
@@ -20,121 +20,121 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class SmartobjectCategory extends Smartobject\SmartSeoObject |
| 22 | 22 | { |
| 23 | - public $_categoryPath; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * SmartobjectCategory constructor. |
|
| 27 | - */ |
|
| 28 | - public function __construct() |
|
| 29 | - { |
|
| 30 | - $this->initVar('categoryid', XOBJ_DTYPE_INT, '', true); |
|
| 31 | - $this->initVar('parentid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_CATEGORY_PARENTID, _CO_SOBJECT_CATEGORY_PARENTID_DSC); |
|
| 32 | - $this->initVar('name', XOBJ_DTYPE_TXTBOX, '', false, null, '', false, _CO_SOBJECT_CATEGORY_NAME, _CO_SOBJECT_CATEGORY_NAME_DSC); |
|
| 33 | - $this->initVar('description', XOBJ_DTYPE_TXTAREA, '', false, null, '', false, _CO_SOBJECT_CATEGORY_DESCRIPTION, _CO_SOBJECT_CATEGORY_DESCRIPTION_DSC); |
|
| 34 | - $this->initVar('image', XOBJ_DTYPE_TXTBOX, '', false, null, '', false, _CO_SOBJECT_CATEGORY_IMAGE, _CO_SOBJECT_CATEGORY_IMAGE_DSC); |
|
| 35 | - |
|
| 36 | - $this->initCommonVar('doxcode'); |
|
| 37 | - |
|
| 38 | - $this->setControl('image', ['name' => 'image']); |
|
| 39 | - $this->setControl('parentid', ['name' => 'parentcategory']); |
|
| 40 | - $this->setControl('description', [ |
|
| 41 | - 'name' => 'textarea', |
|
| 42 | - 'itemHandler' => false, |
|
| 43 | - 'method' => false, |
|
| 44 | - 'module' => false, |
|
| 45 | - 'form_editor' => 'default' |
|
| 46 | - ]); |
|
| 47 | - |
|
| 48 | - // call parent constructor to get SEO fields initiated |
|
| 49 | - parent::__construct(); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * returns a specific variable for the object in a proper format |
|
| 54 | - * |
|
| 55 | - * @access public |
|
| 56 | - * @param string $key key of the object's variable to be returned |
|
| 57 | - * @param string $format format to use for the output |
|
| 58 | - * @return mixed formatted value of the variable |
|
| 59 | - */ |
|
| 60 | - public function getVar($key, $format = 's') |
|
| 61 | - { |
|
| 62 | - if ('s' === $format && in_array($key, ['description', 'image'])) { |
|
| 63 | - // return call_user_func(array($this, $key)); |
|
| 64 | - return $this->{$key}(); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - return parent::getVar($key, $format); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * @return string |
|
| 72 | - */ |
|
| 73 | - public function description() |
|
| 74 | - { |
|
| 75 | - return $this->getValueFor('description', false); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * @return bool|mixed |
|
| 80 | - */ |
|
| 81 | - public function image() |
|
| 82 | - { |
|
| 83 | - $ret = $this->getVar('image', 'e'); |
|
| 84 | - if ('-1' == $ret) { |
|
| 85 | - return false; |
|
| 86 | - } else { |
|
| 87 | - return $ret; |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * @return array |
|
| 93 | - */ |
|
| 94 | - public function toArray() |
|
| 95 | - { |
|
| 96 | - $this->setVar('doxcode', true); |
|
| 97 | - global $myts; |
|
| 98 | - $objectArray = parent::toArray(); |
|
| 99 | - if ($objectArray['image']) { |
|
| 100 | - $objectArray['image'] = $this->getImageDir() . $objectArray['image']; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - return $objectArray; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * Create the complete path of a category |
|
| 108 | - * |
|
| 109 | - * @todo this could be improved as it uses multiple queries |
|
| 110 | - * @param bool $withAllLink make all name clickable |
|
| 111 | - * @param bool $currentCategory |
|
| 112 | - * @return string complete path (breadcrumb) |
|
| 113 | - */ |
|
| 114 | - public function getCategoryPath($withAllLink = true, $currentCategory = false) |
|
| 115 | - { |
|
| 116 | - require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectcontroller.php'; |
|
| 117 | - $controller = new SmartObjectController($this->handler); |
|
| 118 | - |
|
| 119 | - if (!$this->_categoryPath) { |
|
| 120 | - if ($withAllLink && !$currentCategory) { |
|
| 121 | - $ret = $controller->getItemLink($this); |
|
| 122 | - } else { |
|
| 123 | - $currentCategory = false; |
|
| 124 | - $ret = $this->getVar('name'); |
|
| 125 | - } |
|
| 126 | - $parentid = $this->getVar('parentid'); |
|
| 127 | - if (0 != $parentid) { |
|
| 128 | - $parentObj = $this->handler->get($parentid); |
|
| 129 | - if ($parentObj->isNew()) { |
|
| 130 | - exit; |
|
| 131 | - } |
|
| 132 | - $parentid = $parentObj->getVar('parentid'); |
|
| 133 | - $ret = $parentObj->getCategoryPath($withAllLink, $currentCategory) . ' > ' . $ret; |
|
| 134 | - } |
|
| 135 | - $this->_categoryPath = $ret; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - return $this->_categoryPath; |
|
| 139 | - } |
|
| 23 | + public $_categoryPath; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * SmartobjectCategory constructor. |
|
| 27 | + */ |
|
| 28 | + public function __construct() |
|
| 29 | + { |
|
| 30 | + $this->initVar('categoryid', XOBJ_DTYPE_INT, '', true); |
|
| 31 | + $this->initVar('parentid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_CATEGORY_PARENTID, _CO_SOBJECT_CATEGORY_PARENTID_DSC); |
|
| 32 | + $this->initVar('name', XOBJ_DTYPE_TXTBOX, '', false, null, '', false, _CO_SOBJECT_CATEGORY_NAME, _CO_SOBJECT_CATEGORY_NAME_DSC); |
|
| 33 | + $this->initVar('description', XOBJ_DTYPE_TXTAREA, '', false, null, '', false, _CO_SOBJECT_CATEGORY_DESCRIPTION, _CO_SOBJECT_CATEGORY_DESCRIPTION_DSC); |
|
| 34 | + $this->initVar('image', XOBJ_DTYPE_TXTBOX, '', false, null, '', false, _CO_SOBJECT_CATEGORY_IMAGE, _CO_SOBJECT_CATEGORY_IMAGE_DSC); |
|
| 35 | + |
|
| 36 | + $this->initCommonVar('doxcode'); |
|
| 37 | + |
|
| 38 | + $this->setControl('image', ['name' => 'image']); |
|
| 39 | + $this->setControl('parentid', ['name' => 'parentcategory']); |
|
| 40 | + $this->setControl('description', [ |
|
| 41 | + 'name' => 'textarea', |
|
| 42 | + 'itemHandler' => false, |
|
| 43 | + 'method' => false, |
|
| 44 | + 'module' => false, |
|
| 45 | + 'form_editor' => 'default' |
|
| 46 | + ]); |
|
| 47 | + |
|
| 48 | + // call parent constructor to get SEO fields initiated |
|
| 49 | + parent::__construct(); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * returns a specific variable for the object in a proper format |
|
| 54 | + * |
|
| 55 | + * @access public |
|
| 56 | + * @param string $key key of the object's variable to be returned |
|
| 57 | + * @param string $format format to use for the output |
|
| 58 | + * @return mixed formatted value of the variable |
|
| 59 | + */ |
|
| 60 | + public function getVar($key, $format = 's') |
|
| 61 | + { |
|
| 62 | + if ('s' === $format && in_array($key, ['description', 'image'])) { |
|
| 63 | + // return call_user_func(array($this, $key)); |
|
| 64 | + return $this->{$key}(); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + return parent::getVar($key, $format); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * @return string |
|
| 72 | + */ |
|
| 73 | + public function description() |
|
| 74 | + { |
|
| 75 | + return $this->getValueFor('description', false); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * @return bool|mixed |
|
| 80 | + */ |
|
| 81 | + public function image() |
|
| 82 | + { |
|
| 83 | + $ret = $this->getVar('image', 'e'); |
|
| 84 | + if ('-1' == $ret) { |
|
| 85 | + return false; |
|
| 86 | + } else { |
|
| 87 | + return $ret; |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * @return array |
|
| 93 | + */ |
|
| 94 | + public function toArray() |
|
| 95 | + { |
|
| 96 | + $this->setVar('doxcode', true); |
|
| 97 | + global $myts; |
|
| 98 | + $objectArray = parent::toArray(); |
|
| 99 | + if ($objectArray['image']) { |
|
| 100 | + $objectArray['image'] = $this->getImageDir() . $objectArray['image']; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + return $objectArray; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * Create the complete path of a category |
|
| 108 | + * |
|
| 109 | + * @todo this could be improved as it uses multiple queries |
|
| 110 | + * @param bool $withAllLink make all name clickable |
|
| 111 | + * @param bool $currentCategory |
|
| 112 | + * @return string complete path (breadcrumb) |
|
| 113 | + */ |
|
| 114 | + public function getCategoryPath($withAllLink = true, $currentCategory = false) |
|
| 115 | + { |
|
| 116 | + require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectcontroller.php'; |
|
| 117 | + $controller = new SmartObjectController($this->handler); |
|
| 118 | + |
|
| 119 | + if (!$this->_categoryPath) { |
|
| 120 | + if ($withAllLink && !$currentCategory) { |
|
| 121 | + $ret = $controller->getItemLink($this); |
|
| 122 | + } else { |
|
| 123 | + $currentCategory = false; |
|
| 124 | + $ret = $this->getVar('name'); |
|
| 125 | + } |
|
| 126 | + $parentid = $this->getVar('parentid'); |
|
| 127 | + if (0 != $parentid) { |
|
| 128 | + $parentObj = $this->handler->get($parentid); |
|
| 129 | + if ($parentObj->isNew()) { |
|
| 130 | + exit; |
|
| 131 | + } |
|
| 132 | + $parentid = $parentObj->getVar('parentid'); |
|
| 133 | + $ret = $parentObj->getCategoryPath($withAllLink, $currentCategory) . ' > ' . $ret; |
|
| 134 | + } |
|
| 135 | + $this->_categoryPath = $ret; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + return $this->_categoryPath; |
|
| 139 | + } |
|
| 140 | 140 | } |