Completed
Push — master ( bf34f3...88111b )
by Michael
03:08
created
class/SmartPlugin.php 2 patches
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -25,66 +25,66 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@
 block discarded – undo
70 70
         $ret = false;
71 71
         foreach ($this->_infoArray['items'] as $k => $v) {
72 72
             $search_str = str_replace('%u', '', $v['url']);
73
-            if (strpos($_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'], $search_str) > 0) {
73
+            if (strpos($_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'], $search_str) > 0) {
74 74
                 $ret = $k;
75 75
                 break;
76 76
             }
Please login to merge, or discard this patch.
class/SmartobjectCategory.php 2 patches
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -20,121 +20,121 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
         global $myts;
98 98
         $objectArray = parent::toArray();
99 99
         if ($objectArray['image']) {
100
-            $objectArray['image'] = $this->getImageDir() . $objectArray['image'];
100
+            $objectArray['image'] = $this->getImageDir().$objectArray['image'];
101 101
         }
102 102
 
103 103
         return $objectArray;
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public function getCategoryPath($withAllLink = true, $currentCategory = false)
115 115
     {
116
-        require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectcontroller.php';
116
+        require_once SMARTOBJECT_ROOT_PATH.'class/smartobjectcontroller.php';
117 117
         $controller = new SmartObjectController($this->handler);
118 118
 
119 119
         if (!$this->_categoryPath) {
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
                     exit;
131 131
                 }
132 132
                 $parentid = $parentObj->getVar('parentid');
133
-                $ret      = $parentObj->getCategoryPath($withAllLink, $currentCategory) . ' > ' . $ret;
133
+                $ret      = $parentObj->getCategoryPath($withAllLink, $currentCategory).' > '.$ret;
134 134
             }
135 135
             $this->_categoryPath = $ret;
136 136
         }
Please login to merge, or discard this patch.
class/SmartobjectAdsenseHandler.php 2 patches
Indentation   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -30,116 +30,116 @@
 block discarded – undo
30 30
  */
31 31
 class SmartobjectAdsenseHandler extends Smartobject\SmartPersistableObjectHandler
32 32
 {
33
-    public $adFormats;
34
-    public $adFormatsList;
35
-    public $objects = false;
36
-
37
-    /**
38
-     * SmartobjectAdsenseHandler constructor.
39
-     * @param \XoopsDatabase $db
40
-     */
41
-    public function __construct(\XoopsDatabase $db)
42
-    {
43
-        parent::__construct($db, 'adsense', 'adsenseid', 'description', '', 'smartobject');
44
-        $this->adFormats     = [];
45
-        $this->adFormatsList = [];
46
-
47
-        $this->adFormats['728x90_as']['caption'] = '728 X 90 Leaderboard';
48
-        $this->adFormats['728x90_as']['width']   = 728;
49
-        $this->adFormats['728x90_as']['height']  = 90;
50
-        $this->adFormatsList['728x90_as']        = $this->adFormats['728x90_as']['caption'];
51
-
52
-        $this->adFormats['468x60_as']['caption'] = '468 X 60 Banner';
53
-        $this->adFormats['468x60_as']['width']   = 468;
54
-        $this->adFormats['468x60_as']['height']  = 60;
55
-        $this->adFormatsList['468x60_as']        = $this->adFormats['468x60_as']['caption'];
56
-
57
-        $this->adFormats['234x60_as']['caption'] = '234 X 60 Half Banner';
58
-        $this->adFormats['234x60_as']['width']   = 234;
59
-        $this->adFormats['234x60_as']['height']  = 60;
60
-        $this->adFormatsList['234x60_as']        = $this->adFormats['234x60_as']['caption'];
61
-
62
-        $this->adFormats['120x600_as']['caption'] = '120 X 600 Skyscraper';
63
-        $this->adFormats['120x600_as']['width']   = 120;
64
-        $this->adFormats['120x600_as']['height']  = 600;
65
-        $this->adFormatsList['120x600_as']        = $this->adFormats['120x600_as']['caption'];
66
-
67
-        $this->adFormats['160x600_as']['caption'] = '160 X 600 Wide Skyscraper';
68
-        $this->adFormats['160x600_as']['width']   = 160;
69
-        $this->adFormats['160x600_as']['height']  = 600;
70
-        $this->adFormatsList['160x600_as']        = $this->adFormats['160x600_as']['caption'];
71
-
72
-        $this->adFormats['120x240_as']['caption'] = '120 X 240 Vertical Banner';
73
-        $this->adFormats['120x240_as']['width']   = 120;
74
-        $this->adFormats['120x240_as']['height']  = 240;
75
-        $this->adFormatsList['120x240_as']        = $this->adFormats['120x240_as']['caption'];
76
-
77
-        $this->adFormats['336x280_as']['caption'] = '336 X 280 Large Rectangle';
78
-        $this->adFormats['336x280_as']['width']   = 136;
79
-        $this->adFormats['336x280_as']['height']  = 280;
80
-        $this->adFormatsList['336x280_as']        = $this->adFormats['336x280_as']['caption'];
81
-
82
-        $this->adFormats['300x250_as']['caption'] = '300 X 250 Medium Rectangle';
83
-        $this->adFormats['300x250_as']['width']   = 300;
84
-        $this->adFormats['300x250_as']['height']  = 250;
85
-        $this->adFormatsList['300x250_as']        = $this->adFormats['300x250_as']['caption'];
86
-
87
-        $this->adFormats['250x250_as']['caption'] = '250 X 250 Square';
88
-        $this->adFormats['250x250_as']['width']   = 250;
89
-        $this->adFormats['250x250_as']['height']  = 250;
90
-        $this->adFormatsList['250x250_as']        = $this->adFormats['250x250_as']['caption'];
91
-
92
-        $this->adFormats['200x200_as']['caption'] = '200 X 200 Small Square';
93
-        $this->adFormats['200x200_as']['width']   = 200;
94
-        $this->adFormats['200x200_as']['height']  = 200;
95
-        $this->adFormatsList['200x200_as']        = $this->adFormats['200x200_as']['caption'];
96
-
97
-        $this->adFormats['180x150_as']['caption'] = '180 X 150 Small Rectangle';
98
-        $this->adFormats['180x150_as']['width']   = 180;
99
-        $this->adFormats['180x150_as']['height']  = 150;
100
-        $this->adFormatsList['180x150_as']        = $this->adFormats['180x150_as']['caption'];
101
-
102
-        $this->adFormats['125x125_as']['caption'] = '125 X 125 Button';
103
-        $this->adFormats['125x125_as']['width']   = 125;
104
-        $this->adFormats['125x125_as']['height']  = 125;
105
-        $this->adFormatsList['125x125_as']        = $this->adFormats['125x125_as']['caption'];
106
-    }
107
-
108
-    /**
109
-     * @return array
110
-     */
111
-    public function getFormats()
112
-    {
113
-        return $this->adFormatsList;
114
-    }
115
-
116
-    /**
117
-     * @param $obj
118
-     * @return bool
119
-     */
120
-    public function beforeSave($obj)
121
-    {
122
-        if ('' === $obj->getVar('tag')) {
123
-            $obj->setVar('tag', $title = $obj->generateTag());
124
-        }
125
-
126
-        return true;
127
-    }
128
-
129
-    /**
130
-     * @return array|bool
131
-     */
132
-    public function getAdsensesByTag()
133
-    {
134
-        if (!$this->objects) {
135
-            $adsensesObj =& $this->getObjects(null, true);
136
-            $ret         = [];
137
-            foreach ($adsensesObj as $adsenseObj) {
138
-                $ret[$adsenseObj->getVar('tag')] = $adsenseObj;
139
-            }
140
-            $this->objects = $ret;
141
-        }
142
-
143
-        return $this->objects;
144
-    }
33
+	public $adFormats;
34
+	public $adFormatsList;
35
+	public $objects = false;
36
+
37
+	/**
38
+	 * SmartobjectAdsenseHandler constructor.
39
+	 * @param \XoopsDatabase $db
40
+	 */
41
+	public function __construct(\XoopsDatabase $db)
42
+	{
43
+		parent::__construct($db, 'adsense', 'adsenseid', 'description', '', 'smartobject');
44
+		$this->adFormats     = [];
45
+		$this->adFormatsList = [];
46
+
47
+		$this->adFormats['728x90_as']['caption'] = '728 X 90 Leaderboard';
48
+		$this->adFormats['728x90_as']['width']   = 728;
49
+		$this->adFormats['728x90_as']['height']  = 90;
50
+		$this->adFormatsList['728x90_as']        = $this->adFormats['728x90_as']['caption'];
51
+
52
+		$this->adFormats['468x60_as']['caption'] = '468 X 60 Banner';
53
+		$this->adFormats['468x60_as']['width']   = 468;
54
+		$this->adFormats['468x60_as']['height']  = 60;
55
+		$this->adFormatsList['468x60_as']        = $this->adFormats['468x60_as']['caption'];
56
+
57
+		$this->adFormats['234x60_as']['caption'] = '234 X 60 Half Banner';
58
+		$this->adFormats['234x60_as']['width']   = 234;
59
+		$this->adFormats['234x60_as']['height']  = 60;
60
+		$this->adFormatsList['234x60_as']        = $this->adFormats['234x60_as']['caption'];
61
+
62
+		$this->adFormats['120x600_as']['caption'] = '120 X 600 Skyscraper';
63
+		$this->adFormats['120x600_as']['width']   = 120;
64
+		$this->adFormats['120x600_as']['height']  = 600;
65
+		$this->adFormatsList['120x600_as']        = $this->adFormats['120x600_as']['caption'];
66
+
67
+		$this->adFormats['160x600_as']['caption'] = '160 X 600 Wide Skyscraper';
68
+		$this->adFormats['160x600_as']['width']   = 160;
69
+		$this->adFormats['160x600_as']['height']  = 600;
70
+		$this->adFormatsList['160x600_as']        = $this->adFormats['160x600_as']['caption'];
71
+
72
+		$this->adFormats['120x240_as']['caption'] = '120 X 240 Vertical Banner';
73
+		$this->adFormats['120x240_as']['width']   = 120;
74
+		$this->adFormats['120x240_as']['height']  = 240;
75
+		$this->adFormatsList['120x240_as']        = $this->adFormats['120x240_as']['caption'];
76
+
77
+		$this->adFormats['336x280_as']['caption'] = '336 X 280 Large Rectangle';
78
+		$this->adFormats['336x280_as']['width']   = 136;
79
+		$this->adFormats['336x280_as']['height']  = 280;
80
+		$this->adFormatsList['336x280_as']        = $this->adFormats['336x280_as']['caption'];
81
+
82
+		$this->adFormats['300x250_as']['caption'] = '300 X 250 Medium Rectangle';
83
+		$this->adFormats['300x250_as']['width']   = 300;
84
+		$this->adFormats['300x250_as']['height']  = 250;
85
+		$this->adFormatsList['300x250_as']        = $this->adFormats['300x250_as']['caption'];
86
+
87
+		$this->adFormats['250x250_as']['caption'] = '250 X 250 Square';
88
+		$this->adFormats['250x250_as']['width']   = 250;
89
+		$this->adFormats['250x250_as']['height']  = 250;
90
+		$this->adFormatsList['250x250_as']        = $this->adFormats['250x250_as']['caption'];
91
+
92
+		$this->adFormats['200x200_as']['caption'] = '200 X 200 Small Square';
93
+		$this->adFormats['200x200_as']['width']   = 200;
94
+		$this->adFormats['200x200_as']['height']  = 200;
95
+		$this->adFormatsList['200x200_as']        = $this->adFormats['200x200_as']['caption'];
96
+
97
+		$this->adFormats['180x150_as']['caption'] = '180 X 150 Small Rectangle';
98
+		$this->adFormats['180x150_as']['width']   = 180;
99
+		$this->adFormats['180x150_as']['height']  = 150;
100
+		$this->adFormatsList['180x150_as']        = $this->adFormats['180x150_as']['caption'];
101
+
102
+		$this->adFormats['125x125_as']['caption'] = '125 X 125 Button';
103
+		$this->adFormats['125x125_as']['width']   = 125;
104
+		$this->adFormats['125x125_as']['height']  = 125;
105
+		$this->adFormatsList['125x125_as']        = $this->adFormats['125x125_as']['caption'];
106
+	}
107
+
108
+	/**
109
+	 * @return array
110
+	 */
111
+	public function getFormats()
112
+	{
113
+		return $this->adFormatsList;
114
+	}
115
+
116
+	/**
117
+	 * @param $obj
118
+	 * @return bool
119
+	 */
120
+	public function beforeSave($obj)
121
+	{
122
+		if ('' === $obj->getVar('tag')) {
123
+			$obj->setVar('tag', $title = $obj->generateTag());
124
+		}
125
+
126
+		return true;
127
+	}
128
+
129
+	/**
130
+	 * @return array|bool
131
+	 */
132
+	public function getAdsensesByTag()
133
+	{
134
+		if (!$this->objects) {
135
+			$adsensesObj =& $this->getObjects(null, true);
136
+			$ret         = [];
137
+			foreach ($adsensesObj as $adsenseObj) {
138
+				$ret[$adsenseObj->getVar('tag')] = $adsenseObj;
139
+			}
140
+			$this->objects = $ret;
141
+		}
142
+
143
+		return $this->objects;
144
+	}
145 145
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -132,7 +132,7 @@
 block discarded – undo
132 132
     public function getAdsensesByTag()
133 133
     {
134 134
         if (!$this->objects) {
135
-            $adsensesObj =& $this->getObjects(null, true);
135
+            $adsensesObj = & $this->getObjects(null, true);
136 136
             $ret         = [];
137 137
             foreach ($adsensesObj as $adsenseObj) {
138 138
                 $ret[$adsenseObj->getVar('tag')] = $adsenseObj;
Please login to merge, or discard this patch.
class/SmartobjectBasedUrl.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -29,29 +29,29 @@
 block discarded – undo
29 29
  */
30 30
 class SmartobjectBasedUrl extends Smartobject\BaseSmartObject
31 31
 {
32
-    /**
33
-     * SmartobjectBasedUrl constructor.
34
-     */
35
-    public function __construct()
36
-    {
37
-        $this->quickInitVar('caption', XOBJ_DTYPE_TXTBOX, false);
38
-        $this->quickInitVar('description', XOBJ_DTYPE_TXTBOX, false);
39
-        $this->quickInitVar('url', XOBJ_DTYPE_TXTBOX, false);
40
-    }
32
+	/**
33
+	 * SmartobjectBasedUrl constructor.
34
+	 */
35
+	public function __construct()
36
+	{
37
+		$this->quickInitVar('caption', XOBJ_DTYPE_TXTBOX, false);
38
+		$this->quickInitVar('description', XOBJ_DTYPE_TXTBOX, false);
39
+		$this->quickInitVar('url', XOBJ_DTYPE_TXTBOX, false);
40
+	}
41 41
 
42
-    /**
43
-     * @param  string $key
44
-     * @param  string $format
45
-     * @return mixed
46
-     */
47
-    public function getVar($key, $format = 'e')
48
-    {
49
-        if (0 === strpos($key, 'url_')) {
50
-            return parent::getVar('url', $format);
51
-        } elseif (0 === strpos($key, 'caption_')) {
52
-            return parent::getVar('caption', $format);
53
-        } else {
54
-            return parent::getVar($key, $format);
55
-        }
56
-    }
42
+	/**
43
+	 * @param  string $key
44
+	 * @param  string $format
45
+	 * @return mixed
46
+	 */
47
+	public function getVar($key, $format = 'e')
48
+	{
49
+		if (0 === strpos($key, 'url_')) {
50
+			return parent::getVar('url', $format);
51
+		} elseif (0 === strpos($key, 'caption_')) {
52
+			return parent::getVar('caption', $format);
53
+		} else {
54
+			return parent::getVar($key, $format);
55
+		}
56
+	}
57 57
 }
Please login to merge, or discard this patch.
class/SmartObjectExport.php 1 patch
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -41,116 +41,116 @@
 block discarded – undo
41 41
  */
42 42
 class SmartObjectExport
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 SmartPersistableObjectHandler $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
-        SmartPersistableObjectHandler $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 SmartPersistableObjectHandler $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
+		SmartPersistableObjectHandler $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 SmartExportRenderer($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 SmartExportRenderer($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
 }
Please login to merge, or discard this patch.
class/smartloader.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 
16 16
 // defined('XOOPS_ROOT_PATH') || die('Restricted access');
17 17
 
18
-require_once XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php';
18
+require_once XOOPS_ROOT_PATH.'/modules/smartobject/include/common.php';
19 19
 
20 20
 /**
21 21
  * Include other classes used by the SmartObject
Please login to merge, or discard this patch.
class/SmartobjectLink.php 2 patches
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -29,152 +29,152 @@
 block discarded – undo
29 29
  */
30 30
 class SmartobjectLink extends Smartobject\BaseSmartObject
31 31
 {
32
-    /**
33
-     * SmartobjectLink constructor.
34
-     */
35
-    public function __construct()
36
-    {
37
-        $this->initVar('linkid', XOBJ_DTYPE_INT, '', true);
38
-        $this->initVar('date', XOBJ_DTYPE_INT, 0, false, null, '', false, _CO_SOBJECT_LINK_DATE, '', true, true, false);
39
-        $this->initVar('from_uid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_LINK_FROM_UID, _CO_SOBJECT_LINK_FROM_UID_DSC);
40
-        $this->initVar('from_email', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_FROM_EMAIL, _CO_SOBJECT_LINK_FROM_EMAIL_DSC, true);
41
-        $this->initVar('from_name', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_FROM_NAME, _CO_SOBJECT_LINK_FROM_NAME_DSC, true);
42
-        $this->initVar('to_uid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_LINK_TO_UID, _CO_SOBJECT_LINK_TO_UID_DSC);
43
-        $this->initVar('to_email', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_TO_EMAIL, _CO_SOBJECT_LINK_TO_EMAIL_DSC, true);
44
-        $this->initVar('to_name', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_TO_NAME, _CO_SOBJECT_LINK_TO_NAME_DSC, true);
45
-        $this->initVar('link', XOBJ_DTYPE_TXTBOX, '', false, 255, '', false, _CO_SOBJECT_LINK_LINK, _CO_SOBJECT_LINK_LINK_DSC, true);
46
-        $this->initVar('subject', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_SUBJECT, _CO_SOBJECT_LINK_SUBJECT_DSC, true);
47
-        $this->initVar('body', XOBJ_DTYPE_TXTAREA, '', true, null, '', false, _CO_SOBJECT_LINK_BODY, _CO_SOBJECT_LINK_BODY_DSC);
48
-        $this->initVar('mid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_LINK_MID, _CO_SOBJECT_LINK_MID_DSC);
49
-        $this->initVar('mid_name', XOBJ_DTYPE_TXTBOX, '', false, 255, '', false, _CO_SOBJECT_LINK_MID_NAME, _CO_SOBJECT_LINK_MID_NAME_DSC, true);
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, ['from_uid', 'to_uid', 'date', 'link'])) {
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 from_uid()
74
-    {
75
-        $ret = smart_getLinkedUnameFromId($this->getVar('from_uid', 'e'), 1, null, true);
76
-
77
-        return $ret;
78
-    }
79
-
80
-    /**
81
-     * @param  bool $withContact
82
-     * @return string
83
-     */
84
-    public function to_uid($withContact = false)
85
-    {
86
-        $ret = smart_getLinkedUnameFromId($this->getVar('to_uid', 'e'), 1, null, true);
87
-
88
-        return $ret;
89
-    }
90
-
91
-    /**
92
-     * @return string
93
-     */
94
-    public function date()
95
-    {
96
-        $ret = formatTimestamp($this->getVar('date', 'e'));
97
-
98
-        return $ret;
99
-    }
100
-
101
-    /**
102
-     * @param  bool $full
103
-     * @return mixed|string
104
-     */
105
-    public function link($full = false)
106
-    {
107
-        $ret = $this->getVar('link', 'e');
108
-        if ($full) {
109
-            $myts = \MyTextSanitizer::getInstance();
110
-            $ret  = $myts->displayTarea($ret);
111
-
112
-            return $ret;
113
-        } else {
114
-            $ret = '<a href="' . $ret . '" alt="' . $this->getVar('link', 'e') . '" title="' . $this->getVar('link', 'e') . '">' . _AM_SOBJECT_SENT_LINKS_GOTO . '</a>';
115
-
116
-            return $ret;
117
-        }
118
-    }
119
-
120
-    /**
121
-     * @return string
122
-     */
123
-    public function getViewItemLink()
124
-    {
125
-        $ret = '<a href="' . SMARTOBJECT_URL . 'admin/link.php?op=view&linkid=' . $this->getVar('linkid') . '"><img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'mail_find.png" alt="' . _AM_SOBJECT_SENT_LINK_VIEW . '" title="' . _AM_SOBJECT_SENT_LINK_VIEW . '"></a>';
126
-
127
-        return $ret;
128
-    }
129
-
130
-    /**
131
-     * @return string
132
-     */
133
-    public function getFromInfo()
134
-    {
135
-        // check if from_uid represent a user
136
-
137
-        if ($this->getVar('from_uid')) {
138
-            $user = smart_getLinkedUnameFromId($this->getVar('from_uid'));
139
-            if ($user == $GLOBALS['xoopsConfig']['anonymous']) {
140
-                $user = '<a href="mailto:' . $this->getVar('from_email') . '">' . $this->getVar('from_email') . '</a>';
141
-            }
142
-        } else {
143
-            $user = '<a href="mailto:' . $this->getVar('from_email') . '">' . $this->getVar('from_email') . '</a>';
144
-        }
145
-
146
-        return $user;
147
-    }
148
-
149
-    /**
150
-     * @return array
151
-     */
152
-    public function toArray()
153
-    {
154
-        $ret             = parent::toArray();
155
-        $ret['fromInfo'] = $this->getFromInfo();
156
-        $ret['toInfo']   = $this->getToInfo();
157
-        $ret['fullLink'] = $this->link(true);
158
-
159
-        return $ret;
160
-    }
161
-
162
-    /**
163
-     * @return string
164
-     */
165
-    public function getToInfo()
166
-    {
167
-        // check if from_uid represent a user
168
-
169
-        if ($this->getVar('to_uid')) {
170
-            $user = smart_getLinkedUnameFromId($this->getVar('to_uid'));
171
-            if ($user == $GLOBALS['xoopsConfig']['anonymous']) {
172
-                $user = '<a href="mailto:' . $this->getVar('to_email') . '">' . $this->getVar('to_email') . '</a>';
173
-            }
174
-        } else {
175
-            $user = '<a href="mailto:' . $this->getVar('to_email') . '">' . $this->getVar('to_email') . '</a>';
176
-        }
177
-
178
-        return $user;
179
-    }
32
+	/**
33
+	 * SmartobjectLink constructor.
34
+	 */
35
+	public function __construct()
36
+	{
37
+		$this->initVar('linkid', XOBJ_DTYPE_INT, '', true);
38
+		$this->initVar('date', XOBJ_DTYPE_INT, 0, false, null, '', false, _CO_SOBJECT_LINK_DATE, '', true, true, false);
39
+		$this->initVar('from_uid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_LINK_FROM_UID, _CO_SOBJECT_LINK_FROM_UID_DSC);
40
+		$this->initVar('from_email', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_FROM_EMAIL, _CO_SOBJECT_LINK_FROM_EMAIL_DSC, true);
41
+		$this->initVar('from_name', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_FROM_NAME, _CO_SOBJECT_LINK_FROM_NAME_DSC, true);
42
+		$this->initVar('to_uid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_LINK_TO_UID, _CO_SOBJECT_LINK_TO_UID_DSC);
43
+		$this->initVar('to_email', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_TO_EMAIL, _CO_SOBJECT_LINK_TO_EMAIL_DSC, true);
44
+		$this->initVar('to_name', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_TO_NAME, _CO_SOBJECT_LINK_TO_NAME_DSC, true);
45
+		$this->initVar('link', XOBJ_DTYPE_TXTBOX, '', false, 255, '', false, _CO_SOBJECT_LINK_LINK, _CO_SOBJECT_LINK_LINK_DSC, true);
46
+		$this->initVar('subject', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_SUBJECT, _CO_SOBJECT_LINK_SUBJECT_DSC, true);
47
+		$this->initVar('body', XOBJ_DTYPE_TXTAREA, '', true, null, '', false, _CO_SOBJECT_LINK_BODY, _CO_SOBJECT_LINK_BODY_DSC);
48
+		$this->initVar('mid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_LINK_MID, _CO_SOBJECT_LINK_MID_DSC);
49
+		$this->initVar('mid_name', XOBJ_DTYPE_TXTBOX, '', false, 255, '', false, _CO_SOBJECT_LINK_MID_NAME, _CO_SOBJECT_LINK_MID_NAME_DSC, true);
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, ['from_uid', 'to_uid', 'date', 'link'])) {
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 from_uid()
74
+	{
75
+		$ret = smart_getLinkedUnameFromId($this->getVar('from_uid', 'e'), 1, null, true);
76
+
77
+		return $ret;
78
+	}
79
+
80
+	/**
81
+	 * @param  bool $withContact
82
+	 * @return string
83
+	 */
84
+	public function to_uid($withContact = false)
85
+	{
86
+		$ret = smart_getLinkedUnameFromId($this->getVar('to_uid', 'e'), 1, null, true);
87
+
88
+		return $ret;
89
+	}
90
+
91
+	/**
92
+	 * @return string
93
+	 */
94
+	public function date()
95
+	{
96
+		$ret = formatTimestamp($this->getVar('date', 'e'));
97
+
98
+		return $ret;
99
+	}
100
+
101
+	/**
102
+	 * @param  bool $full
103
+	 * @return mixed|string
104
+	 */
105
+	public function link($full = false)
106
+	{
107
+		$ret = $this->getVar('link', 'e');
108
+		if ($full) {
109
+			$myts = \MyTextSanitizer::getInstance();
110
+			$ret  = $myts->displayTarea($ret);
111
+
112
+			return $ret;
113
+		} else {
114
+			$ret = '<a href="' . $ret . '" alt="' . $this->getVar('link', 'e') . '" title="' . $this->getVar('link', 'e') . '">' . _AM_SOBJECT_SENT_LINKS_GOTO . '</a>';
115
+
116
+			return $ret;
117
+		}
118
+	}
119
+
120
+	/**
121
+	 * @return string
122
+	 */
123
+	public function getViewItemLink()
124
+	{
125
+		$ret = '<a href="' . SMARTOBJECT_URL . 'admin/link.php?op=view&linkid=' . $this->getVar('linkid') . '"><img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'mail_find.png" alt="' . _AM_SOBJECT_SENT_LINK_VIEW . '" title="' . _AM_SOBJECT_SENT_LINK_VIEW . '"></a>';
126
+
127
+		return $ret;
128
+	}
129
+
130
+	/**
131
+	 * @return string
132
+	 */
133
+	public function getFromInfo()
134
+	{
135
+		// check if from_uid represent a user
136
+
137
+		if ($this->getVar('from_uid')) {
138
+			$user = smart_getLinkedUnameFromId($this->getVar('from_uid'));
139
+			if ($user == $GLOBALS['xoopsConfig']['anonymous']) {
140
+				$user = '<a href="mailto:' . $this->getVar('from_email') . '">' . $this->getVar('from_email') . '</a>';
141
+			}
142
+		} else {
143
+			$user = '<a href="mailto:' . $this->getVar('from_email') . '">' . $this->getVar('from_email') . '</a>';
144
+		}
145
+
146
+		return $user;
147
+	}
148
+
149
+	/**
150
+	 * @return array
151
+	 */
152
+	public function toArray()
153
+	{
154
+		$ret             = parent::toArray();
155
+		$ret['fromInfo'] = $this->getFromInfo();
156
+		$ret['toInfo']   = $this->getToInfo();
157
+		$ret['fullLink'] = $this->link(true);
158
+
159
+		return $ret;
160
+	}
161
+
162
+	/**
163
+	 * @return string
164
+	 */
165
+	public function getToInfo()
166
+	{
167
+		// check if from_uid represent a user
168
+
169
+		if ($this->getVar('to_uid')) {
170
+			$user = smart_getLinkedUnameFromId($this->getVar('to_uid'));
171
+			if ($user == $GLOBALS['xoopsConfig']['anonymous']) {
172
+				$user = '<a href="mailto:' . $this->getVar('to_email') . '">' . $this->getVar('to_email') . '</a>';
173
+			}
174
+		} else {
175
+			$user = '<a href="mailto:' . $this->getVar('to_email') . '">' . $this->getVar('to_email') . '</a>';
176
+		}
177
+
178
+		return $user;
179
+	}
180 180
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 
112 112
             return $ret;
113 113
         } else {
114
-            $ret = '<a href="' . $ret . '" alt="' . $this->getVar('link', 'e') . '" title="' . $this->getVar('link', 'e') . '">' . _AM_SOBJECT_SENT_LINKS_GOTO . '</a>';
114
+            $ret = '<a href="'.$ret.'" alt="'.$this->getVar('link', 'e').'" title="'.$this->getVar('link', 'e').'">'._AM_SOBJECT_SENT_LINKS_GOTO.'</a>';
115 115
 
116 116
             return $ret;
117 117
         }
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
      */
123 123
     public function getViewItemLink()
124 124
     {
125
-        $ret = '<a href="' . SMARTOBJECT_URL . 'admin/link.php?op=view&linkid=' . $this->getVar('linkid') . '"><img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'mail_find.png" alt="' . _AM_SOBJECT_SENT_LINK_VIEW . '" title="' . _AM_SOBJECT_SENT_LINK_VIEW . '"></a>';
125
+        $ret = '<a href="'.SMARTOBJECT_URL.'admin/link.php?op=view&linkid='.$this->getVar('linkid').'"><img src="'.SMARTOBJECT_IMAGES_ACTIONS_URL.'mail_find.png" alt="'._AM_SOBJECT_SENT_LINK_VIEW.'" title="'._AM_SOBJECT_SENT_LINK_VIEW.'"></a>';
126 126
 
127 127
         return $ret;
128 128
     }
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
         if ($this->getVar('from_uid')) {
138 138
             $user = smart_getLinkedUnameFromId($this->getVar('from_uid'));
139 139
             if ($user == $GLOBALS['xoopsConfig']['anonymous']) {
140
-                $user = '<a href="mailto:' . $this->getVar('from_email') . '">' . $this->getVar('from_email') . '</a>';
140
+                $user = '<a href="mailto:'.$this->getVar('from_email').'">'.$this->getVar('from_email').'</a>';
141 141
             }
142 142
         } else {
143
-            $user = '<a href="mailto:' . $this->getVar('from_email') . '">' . $this->getVar('from_email') . '</a>';
143
+            $user = '<a href="mailto:'.$this->getVar('from_email').'">'.$this->getVar('from_email').'</a>';
144 144
         }
145 145
 
146 146
         return $user;
@@ -169,10 +169,10 @@  discard block
 block discarded – undo
169 169
         if ($this->getVar('to_uid')) {
170 170
             $user = smart_getLinkedUnameFromId($this->getVar('to_uid'));
171 171
             if ($user == $GLOBALS['xoopsConfig']['anonymous']) {
172
-                $user = '<a href="mailto:' . $this->getVar('to_email') . '">' . $this->getVar('to_email') . '</a>';
172
+                $user = '<a href="mailto:'.$this->getVar('to_email').'">'.$this->getVar('to_email').'</a>';
173 173
             }
174 174
         } else {
175
-            $user = '<a href="mailto:' . $this->getVar('to_email') . '">' . $this->getVar('to_email') . '</a>';
175
+            $user = '<a href="mailto:'.$this->getVar('to_email').'">'.$this->getVar('to_email').'</a>';
176 176
         }
177 177
 
178 178
         return $user;
Please login to merge, or discard this patch.
class/SmartobjectPermissionHandler.php 1 patch
Indentation   +199 added lines, -199 removed lines patch added patch discarded remove patch
@@ -19,18 +19,18 @@  discard block
 block discarded – undo
19 19
  */
20 20
 class SmartobjectPermissionHandler extends \XoopsObjectHandler
21 21
 {
22
-    public $handler;
23
-
24
-    /**
25
-     * SmartobjectPermissionHandler constructor.
26
-     * @param \XoopsDatabase $handler
27
-     */
28
-    public function __construct($handler)
29
-    {
30
-        $this->handler = $handler;
31
-    }
32
-
33
-    /*
22
+	public $handler;
23
+
24
+	/**
25
+	 * SmartobjectPermissionHandler constructor.
26
+	 * @param \XoopsDatabase $handler
27
+	 */
28
+	public function __construct($handler)
29
+	{
30
+		$this->handler = $handler;
31
+	}
32
+
33
+	/*
34 34
      * Returns permissions for a certain type
35 35
      *
36 36
      * @param string $type "global", "forum" or "topic" (should perhaps have "post" as well - but I don't know)
@@ -38,74 +38,74 @@  discard block
 block discarded – undo
38 38
      *
39 39
      * @return array
40 40
      */
41
-    /**
42
-     * @param        $gperm_name
43
-     * @param  null  $id
44
-     * @return array
45
-     */
46
-    public function getGrantedGroups($gperm_name, $id = null)
47
-    {
48
-        static $groups;
49
-
50
-        if (!isset($groups[$gperm_name]) || (null !== $id && !isset($groups[$gperm_name][$id]))) {
51
-            $smartModule = $this->handler->getModuleInfo();
52
-            //Get group permissions handler
53
-            $gpermHandler = xoops_getHandler('groupperm');
54
-
55
-            //Get groups allowed for an item id
56
-            $allowedgroups            = $gpermHandler->getGroupIds($gperm_name, $id, $smartModule->getVar('mid'));
57
-            $groups[$gperm_name][$id] = $allowedgroups;
58
-        }
59
-
60
-        //Return the permission array
61
-        return isset($groups[$gperm_name][$id]) ? $groups[$gperm_name][$id] : [];
62
-    }
63
-
64
-    /**
65
-     * @param        $item_ids_array
66
-     * @param  bool  $gperm_name
67
-     * @return array
68
-     */
69
-    public function getGrantedGroupsForIds($item_ids_array, $gperm_name = false)
70
-    {
71
-        static $groups;
72
-
73
-        if ($gperm_name) {
74
-            if (isset($groups[$gperm_name])) {
75
-                return $groups[$gperm_name];
76
-            }
77
-        } else {
78
-            // if !$gperm_name then we will fetch all permissions in the module so we don't need them again
79
-            return $groups;
80
-        }
81
-
82
-        $smartModule = $this->handler->getModuleInfo();
83
-
84
-        $criteria = new \CriteriaCompo();
85
-        $criteria->add(new \Criteria('gperm_modid', $smartModule->getVar('mid')));
86
-
87
-        if ($gperm_name) {
88
-            $criteria->add(new \Criteria('gperm_name', $gperm_name));
89
-        }
90
-
91
-        //Get group permissions handler
92
-        $gpermHandler = xoops_getHandler('groupperm');
93
-
94
-        $permissionsObj = $gpermHandler->getObjects($criteria);
95
-
96
-        foreach ($permissionsObj as $permissionObj) {
97
-            $groups[$permissionObj->getVar('gperm_name')][$permissionObj->getVar('gperm_itemid')][] = $permissionObj->getVar('gperm_groupid');
98
-        }
99
-
100
-        //Return the permission array
101
-        if ($gperm_name) {
102
-            return isset($groups[$gperm_name]) ? $groups[$gperm_name] : [];
103
-        } else {
104
-            return isset($groups) ? $groups : [];
105
-        }
106
-    }
107
-
108
-    /*
41
+	/**
42
+	 * @param        $gperm_name
43
+	 * @param  null  $id
44
+	 * @return array
45
+	 */
46
+	public function getGrantedGroups($gperm_name, $id = null)
47
+	{
48
+		static $groups;
49
+
50
+		if (!isset($groups[$gperm_name]) || (null !== $id && !isset($groups[$gperm_name][$id]))) {
51
+			$smartModule = $this->handler->getModuleInfo();
52
+			//Get group permissions handler
53
+			$gpermHandler = xoops_getHandler('groupperm');
54
+
55
+			//Get groups allowed for an item id
56
+			$allowedgroups            = $gpermHandler->getGroupIds($gperm_name, $id, $smartModule->getVar('mid'));
57
+			$groups[$gperm_name][$id] = $allowedgroups;
58
+		}
59
+
60
+		//Return the permission array
61
+		return isset($groups[$gperm_name][$id]) ? $groups[$gperm_name][$id] : [];
62
+	}
63
+
64
+	/**
65
+	 * @param        $item_ids_array
66
+	 * @param  bool  $gperm_name
67
+	 * @return array
68
+	 */
69
+	public function getGrantedGroupsForIds($item_ids_array, $gperm_name = false)
70
+	{
71
+		static $groups;
72
+
73
+		if ($gperm_name) {
74
+			if (isset($groups[$gperm_name])) {
75
+				return $groups[$gperm_name];
76
+			}
77
+		} else {
78
+			// if !$gperm_name then we will fetch all permissions in the module so we don't need them again
79
+			return $groups;
80
+		}
81
+
82
+		$smartModule = $this->handler->getModuleInfo();
83
+
84
+		$criteria = new \CriteriaCompo();
85
+		$criteria->add(new \Criteria('gperm_modid', $smartModule->getVar('mid')));
86
+
87
+		if ($gperm_name) {
88
+			$criteria->add(new \Criteria('gperm_name', $gperm_name));
89
+		}
90
+
91
+		//Get group permissions handler
92
+		$gpermHandler = xoops_getHandler('groupperm');
93
+
94
+		$permissionsObj = $gpermHandler->getObjects($criteria);
95
+
96
+		foreach ($permissionsObj as $permissionObj) {
97
+			$groups[$permissionObj->getVar('gperm_name')][$permissionObj->getVar('gperm_itemid')][] = $permissionObj->getVar('gperm_groupid');
98
+		}
99
+
100
+		//Return the permission array
101
+		if ($gperm_name) {
102
+			return isset($groups[$gperm_name]) ? $groups[$gperm_name] : [];
103
+		} else {
104
+			return isset($groups) ? $groups : [];
105
+		}
106
+	}
107
+
108
+	/*
109 109
      * Returns permissions for a certain type
110 110
      *
111 111
      * @param string $type "global", "forum" or "topic" (should perhaps have "post" as well - but I don't know)
@@ -113,123 +113,123 @@  discard block
 block discarded – undo
113 113
      *
114 114
      * @return array
115 115
      */
116
-    /**
117
-     * @param        $gperm_name
118
-     * @param  null  $id
119
-     * @return array
120
-     */
121
-    public function getGrantedItems($gperm_name, $id = null)
122
-    {
123
-        global $xoopsUser;
124
-        static $permissions;
125
-
126
-        if (!isset($permissions[$gperm_name]) || (null !== $id && !isset($permissions[$gperm_name][$id]))) {
127
-            $smartModule = $this->handler->getModuleInfo();
128
-
129
-            if (is_object($smartModule)) {
130
-
131
-                //Get group permissions handler
132
-                $gpermHandler = xoops_getHandler('groupperm');
133
-
134
-                //Get user's groups
135
-                $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : [XOOPS_GROUP_ANONYMOUS];
136
-
137
-                //Get all allowed item ids in this module and for this user's groups
138
-                $userpermissions          = $gpermHandler->getItemIds($gperm_name, $groups, $smartModule->getVar('mid'));
139
-                $permissions[$gperm_name] = $userpermissions;
140
-            }
141
-        }
142
-
143
-        //Return the permission array
144
-        return isset($permissions[$gperm_name]) ? $permissions[$gperm_name] : [];
145
-    }
146
-
147
-    /**
148
-     * @param $id
149
-     */
150
-    public function storeAllPermissionsForId($id)
151
-    {
152
-        foreach ($this->handler->getPermissions() as $permission) {
153
-            $this->saveItem_Permissions($_POST[$permission['perm_name']], $id, $permission['perm_name']);
154
-        }
155
-    }
156
-
157
-    /**
158
-     * Saves permissions for the selected item
159
-     *
160
-     *  saveItem_Permissions()
161
-     *
162
-     * @param  array  $groups    : group with granted permission
163
-     * @param  int    $itemid    categoryID on which we are setting permissions for Categories and Forums
164
-     * @param  string $perm_name : name of the permission
165
-     * @return bool   : TRUE if the no errors occured
166
-     */
167
-
168
-    public function saveItem_Permissions($groups, $itemid, $perm_name)
169
-    {
170
-        $smartModule = $this->handler->getModuleInfo();
171
-
172
-        $result       = true;
173
-        $module_id    = $smartModule->getVar('mid');
174
-        $gpermHandler = xoops_getHandler('groupperm');
175
-
176
-        // First, if the permissions are already there, delete them
177
-        $gpermHandler->deleteByModule($module_id, $perm_name, $itemid);
178
-        //echo "itemid: $itemid - perm: $perm_name - modid: $module_id";
179
-        //exit;
180
-        // Save the new permissions
181
-
182
-        if (count($groups) > 0) {
183
-            foreach ($groups as $group_id) {
184
-                $gpermHandler->addRight($perm_name, $itemid, $group_id, $module_id);
185
-            }
186
-        }
187
-
188
-        return $result;
189
-    }
190
-
191
-    /**
192
-     * Delete all permission for a specific item
193
-     *
194
-     *  deletePermissions()
195
-     *
196
-     * @param  integer $itemid : id of the item for which to delete the permissions
197
-     * @param          $gperm_name
198
-     * @return bool:   TRUE if the no errors occured
199
-     */
200
-    public function deletePermissions($itemid, $gperm_name)
201
-    {
202
-        global $xoopsModule;
203
-
204
-        $smartModule = smartsection_getModuleInfo();
205
-
206
-        $result       = true;
207
-        $module_id    = $smartModule->getVar('mid');
208
-        $gpermHandler = xoops_getHandler('groupperm');
209
-
210
-        $gpermHandler->deleteByModule($module_id, $gperm_name, $itemid);
211
-
212
-        return $result;
213
-    }
214
-
215
-    /**
216
-     * Checks if the user has access to a specific permission on a given object
217
-     *
218
-     * @param  string $gperm_name   name of the permission to test
219
-     * @param  int    $gperm_itemid id of the object to check
220
-     * @return boolean: TRUE if user has access, FALSE if not
221
-     **/
222
-    public function accessGranted($gperm_name, $gperm_itemid)
223
-    {
224
-        global $xoopsUser;
225
-
226
-        $gperm_groupid = is_object($xoopsUser) ? $xoopsUser->getGroups() : [XOOPS_GROUP_ANONYMOUS];
227
-        $smartModule   = $this->handler->getModuleInfo();
228
-        $gperm_modid   = $smartModule->getVar('mid');
229
-
230
-        //Get group permissions handler
231
-        $gpermHandler = xoops_getHandler('groupperm');
232
-
233
-        return $gpermHandler->checkRight($gperm_name, $gperm_itemid, $gperm_groupid, $gperm_modid);
234
-    }
116
+	/**
117
+	 * @param        $gperm_name
118
+	 * @param  null  $id
119
+	 * @return array
120
+	 */
121
+	public function getGrantedItems($gperm_name, $id = null)
122
+	{
123
+		global $xoopsUser;
124
+		static $permissions;
125
+
126
+		if (!isset($permissions[$gperm_name]) || (null !== $id && !isset($permissions[$gperm_name][$id]))) {
127
+			$smartModule = $this->handler->getModuleInfo();
128
+
129
+			if (is_object($smartModule)) {
130
+
131
+				//Get group permissions handler
132
+				$gpermHandler = xoops_getHandler('groupperm');
133
+
134
+				//Get user's groups
135
+				$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : [XOOPS_GROUP_ANONYMOUS];
136
+
137
+				//Get all allowed item ids in this module and for this user's groups
138
+				$userpermissions          = $gpermHandler->getItemIds($gperm_name, $groups, $smartModule->getVar('mid'));
139
+				$permissions[$gperm_name] = $userpermissions;
140
+			}
141
+		}
142
+
143
+		//Return the permission array
144
+		return isset($permissions[$gperm_name]) ? $permissions[$gperm_name] : [];
145
+	}
146
+
147
+	/**
148
+	 * @param $id
149
+	 */
150
+	public function storeAllPermissionsForId($id)
151
+	{
152
+		foreach ($this->handler->getPermissions() as $permission) {
153
+			$this->saveItem_Permissions($_POST[$permission['perm_name']], $id, $permission['perm_name']);
154
+		}
155
+	}
156
+
157
+	/**
158
+	 * Saves permissions for the selected item
159
+	 *
160
+	 *  saveItem_Permissions()
161
+	 *
162
+	 * @param  array  $groups    : group with granted permission
163
+	 * @param  int    $itemid    categoryID on which we are setting permissions for Categories and Forums
164
+	 * @param  string $perm_name : name of the permission
165
+	 * @return bool   : TRUE if the no errors occured
166
+	 */
167
+
168
+	public function saveItem_Permissions($groups, $itemid, $perm_name)
169
+	{
170
+		$smartModule = $this->handler->getModuleInfo();
171
+
172
+		$result       = true;
173
+		$module_id    = $smartModule->getVar('mid');
174
+		$gpermHandler = xoops_getHandler('groupperm');
175
+
176
+		// First, if the permissions are already there, delete them
177
+		$gpermHandler->deleteByModule($module_id, $perm_name, $itemid);
178
+		//echo "itemid: $itemid - perm: $perm_name - modid: $module_id";
179
+		//exit;
180
+		// Save the new permissions
181
+
182
+		if (count($groups) > 0) {
183
+			foreach ($groups as $group_id) {
184
+				$gpermHandler->addRight($perm_name, $itemid, $group_id, $module_id);
185
+			}
186
+		}
187
+
188
+		return $result;
189
+	}
190
+
191
+	/**
192
+	 * Delete all permission for a specific item
193
+	 *
194
+	 *  deletePermissions()
195
+	 *
196
+	 * @param  integer $itemid : id of the item for which to delete the permissions
197
+	 * @param          $gperm_name
198
+	 * @return bool:   TRUE if the no errors occured
199
+	 */
200
+	public function deletePermissions($itemid, $gperm_name)
201
+	{
202
+		global $xoopsModule;
203
+
204
+		$smartModule = smartsection_getModuleInfo();
205
+
206
+		$result       = true;
207
+		$module_id    = $smartModule->getVar('mid');
208
+		$gpermHandler = xoops_getHandler('groupperm');
209
+
210
+		$gpermHandler->deleteByModule($module_id, $gperm_name, $itemid);
211
+
212
+		return $result;
213
+	}
214
+
215
+	/**
216
+	 * Checks if the user has access to a specific permission on a given object
217
+	 *
218
+	 * @param  string $gperm_name   name of the permission to test
219
+	 * @param  int    $gperm_itemid id of the object to check
220
+	 * @return boolean: TRUE if user has access, FALSE if not
221
+	 **/
222
+	public function accessGranted($gperm_name, $gperm_itemid)
223
+	{
224
+		global $xoopsUser;
225
+
226
+		$gperm_groupid = is_object($xoopsUser) ? $xoopsUser->getGroups() : [XOOPS_GROUP_ANONYMOUS];
227
+		$smartModule   = $this->handler->getModuleInfo();
228
+		$gperm_modid   = $smartModule->getVar('mid');
229
+
230
+		//Get group permissions handler
231
+		$gpermHandler = xoops_getHandler('groupperm');
232
+
233
+		return $gpermHandler->checkRight($gperm_name, $gperm_itemid, $gperm_groupid, $gperm_modid);
234
+	}
235 235
 }
Please login to merge, or discard this patch.
class/SmartobjectFile.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,12 +29,12 @@
 block discarded – undo
29 29
  */
30 30
 class SmartobjectFile extends Smartobject\BaseSmartObjectBasedUrl
31 31
 {
32
-    /**
33
-     * SmartobjectFile constructor.
34
-     */
35
-    public function __construct()
36
-    {
37
-        parent::__construct();
38
-        $this->quickInitVar('fileid', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_RATING_DIRNAME);
39
-    }
32
+	/**
33
+	 * SmartobjectFile constructor.
34
+	 */
35
+	public function __construct()
36
+	{
37
+		parent::__construct();
38
+		$this->quickInitVar('fileid', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_RATING_DIRNAME);
39
+	}
40 40
 }
Please login to merge, or discard this patch.