Completed
Push — master ( b3fce7...c570af )
by Michael
02:32
created
include/captcha/text.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
     public function setCode()
44 44
     {
45
-        $_SESSION['XoopsCaptcha_sessioncode'] = (string)$this->code;
45
+        $_SESSION['XoopsCaptcha_sessioncode'] = (string) $this->code;
46 46
     }
47 47
 
48 48
     /**
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
      */
51 51
     public function render()
52 52
     {
53
-        $form = $this->loadText() . "&nbsp;&nbsp; <input type='text' name='" . $this->config['name'] . "' id='" . $this->config['name'] . "' size='" . $this->config['num_chars'] . "' maxlength='" . $this->config['num_chars'] . "' value=''>";
53
+        $form = $this->loadText()."&nbsp;&nbsp; <input type='text' name='".$this->config['name']."' id='".$this->config['name']."' size='".$this->config['num_chars']."' maxlength='".$this->config['num_chars']."' value=''>";
54 54
         $rule = constant('XOOPS_CAPTCHA_RULE_TEXT');
55 55
         if (!empty($rule)) {
56 56
             $form .= "&nbsp;&nbsp;<small>{$rule}</small>";
Please login to merge, or discard this patch.
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -7,75 +7,75 @@
 block discarded – undo
7 7
  */
8 8
 class XoopsCaptchaText
9 9
 {
10
-    public $config = [];
11
-    public $code;
10
+	public $config = [];
11
+	public $code;
12 12
 
13
-    /**
14
-     * XoopsCaptchaText constructor.
15
-     */
16
-    public function __construct()
17
-    {
18
-    }
13
+	/**
14
+	 * XoopsCaptchaText constructor.
15
+	 */
16
+	public function __construct()
17
+	{
18
+	}
19 19
 
20
-    /**
21
-     * @return XoopsCaptchaText
22
-     */
23
-    public static function getInstance()
24
-    {
25
-        static $instance;
26
-        if (null === $instance) {
27
-            $instance = new static();
28
-        }
20
+	/**
21
+	 * @return XoopsCaptchaText
22
+	 */
23
+	public static function getInstance()
24
+	{
25
+		static $instance;
26
+		if (null === $instance) {
27
+			$instance = new static();
28
+		}
29 29
 
30
-        return $instance;
31
-    }
30
+		return $instance;
31
+	}
32 32
 
33
-    /**
34
-     * Loading configs from CAPTCHA class
35
-     * @param array $config
36
-     */
37
-    public function loadConfig($config = [])
38
-    {
39
-        // Loading default preferences
40
-        $this->config = $config;
41
-    }
33
+	/**
34
+	 * Loading configs from CAPTCHA class
35
+	 * @param array $config
36
+	 */
37
+	public function loadConfig($config = [])
38
+	{
39
+		// Loading default preferences
40
+		$this->config = $config;
41
+	}
42 42
 
43
-    public function setCode()
44
-    {
45
-        $_SESSION['XoopsCaptcha_sessioncode'] = (string)$this->code;
46
-    }
43
+	public function setCode()
44
+	{
45
+		$_SESSION['XoopsCaptcha_sessioncode'] = (string)$this->code;
46
+	}
47 47
 
48
-    /**
49
-     * @return string
50
-     */
51
-    public function render()
52
-    {
53
-        $form = $this->loadText() . "&nbsp;&nbsp; <input type='text' name='" . $this->config['name'] . "' id='" . $this->config['name'] . "' size='" . $this->config['num_chars'] . "' maxlength='" . $this->config['num_chars'] . "' value=''>";
54
-        $rule = constant('XOOPS_CAPTCHA_RULE_TEXT');
55
-        if (!empty($rule)) {
56
-            $form .= "&nbsp;&nbsp;<small>{$rule}</small>";
57
-        }
48
+	/**
49
+	 * @return string
50
+	 */
51
+	public function render()
52
+	{
53
+		$form = $this->loadText() . "&nbsp;&nbsp; <input type='text' name='" . $this->config['name'] . "' id='" . $this->config['name'] . "' size='" . $this->config['num_chars'] . "' maxlength='" . $this->config['num_chars'] . "' value=''>";
54
+		$rule = constant('XOOPS_CAPTCHA_RULE_TEXT');
55
+		if (!empty($rule)) {
56
+			$form .= "&nbsp;&nbsp;<small>{$rule}</small>";
57
+		}
58 58
 
59
-        $this->setCode();
59
+		$this->setCode();
60 60
 
61
-        return $form;
62
-    }
61
+		return $form;
62
+	}
63 63
 
64
-    /**
65
-     * @return string
66
-     */
67
-    public function loadText()
68
-    {
69
-        $val_a = mt_rand(0, 9);
70
-        $val_b = mt_rand(0, 9);
71
-        if ($val_a > $val_b) {
72
-            $expression = "{$val_a} - {$val_b} = ?";
73
-            $this->code = $val_a - $val_b;
74
-        } else {
75
-            $expression = "{$val_a} + {$val_b} = ?";
76
-            $this->code = $val_a + $val_b;
77
-        }
64
+	/**
65
+	 * @return string
66
+	 */
67
+	public function loadText()
68
+	{
69
+		$val_a = mt_rand(0, 9);
70
+		$val_b = mt_rand(0, 9);
71
+		if ($val_a > $val_b) {
72
+			$expression = "{$val_a} - {$val_b} = ?";
73
+			$this->code = $val_a - $val_b;
74
+		} else {
75
+			$expression = "{$val_a} + {$val_b} = ?";
76
+			$this->code = $val_a + $val_b;
77
+		}
78 78
 
79
-        return "<span style='font-style: normal; font-weight: bold; font-size: 100%; font-color: #333; border: 1px solid #333; padding: 1px 5px;'>{$expression}</span>";
80
-    }
79
+		return "<span style='font-style: normal; font-weight: bold; font-size: 100%; font-color: #333; border: 1px solid #333; padding: 1px 5px;'>{$expression}</span>";
80
+	}
81 81
 }
Please login to merge, or discard this patch.
include/captcha/image.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -45,10 +45,10 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function render()
47 47
     {
48
-        $form = "<input type='text' name='" . $this->config['name'] . "' id='" . $this->config['name'] . "' size='" . $this->config['num_chars'] . "' maxlength='" . $this->config['num_chars'] . "' value=''> &nbsp; " . $this->loadImage();
48
+        $form = "<input type='text' name='".$this->config['name']."' id='".$this->config['name']."' size='".$this->config['num_chars']."' maxlength='".$this->config['num_chars']."' value=''> &nbsp; ".$this->loadImage();
49 49
         $rule = htmlspecialchars(XOOPS_CAPTCHA_REFRESH, ENT_QUOTES);
50 50
         if ($this->config['maxattempt']) {
51
-            $rule .= ' | ' . sprintf(constant('XOOPS_CAPTCHA_MAXATTEMPTS'), $this->config['maxattempt']);
51
+            $rule .= ' | '.sprintf(constant('XOOPS_CAPTCHA_MAXATTEMPTS'), $this->config['maxattempt']);
52 52
         }
53 53
         $form .= "&nbsp;&nbsp;<small>{$rule}</small>";
54 54
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     public function loadImage()
62 62
     {
63 63
         $rule = $this->config['casesensitive'] ? constant('XOOPS_CAPTCHA_RULE_CASESENSITIVE') : constant('XOOPS_CAPTCHA_RULE_CASEINSENSITIVE');
64
-        $ret  = "<img id='captcha' src='" . XOOPS_URL . '/' . $this->config['imageurl'] . "' onclick=\"this.src='" . XOOPS_URL . '/' . $this->config['imageurl'] . "?refresh='+Math.random()" . "\" align='absmiddle'  style='cursor: pointer;' alt='" . htmlspecialchars($rule, ENT_QUOTES) . "'>";
64
+        $ret  = "<img id='captcha' src='".XOOPS_URL.'/'.$this->config['imageurl']."' onclick=\"this.src='".XOOPS_URL.'/'.$this->config['imageurl']."?refresh='+Math.random()"."\" align='absmiddle'  style='cursor: pointer;' alt='".htmlspecialchars($rule, ENT_QUOTES)."'>";
65 65
 
66 66
         return $ret;
67 67
     }
Please login to merge, or discard this patch.
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -7,62 +7,62 @@
 block discarded – undo
7 7
  */
8 8
 class XoopsCaptchaImage
9 9
 {
10
-    public $config = [];
10
+	public $config = [];
11 11
 
12
-    /**
13
-     * XoopsCaptchaImage constructor.
14
-     */
15
-    public function __construct()
16
-    {
17
-        //$this->name = md5( session_id() );
18
-    }
12
+	/**
13
+	 * XoopsCaptchaImage constructor.
14
+	 */
15
+	public function __construct()
16
+	{
17
+		//$this->name = md5( session_id() );
18
+	}
19 19
 
20
-    /**
21
-     * @return XoopsCaptchaImage
22
-     */
23
-    public static function getInstance()
24
-    {
25
-        static $instance;
26
-        if (null === $instance) {
27
-            $instance = new static();
28
-        }
20
+	/**
21
+	 * @return XoopsCaptchaImage
22
+	 */
23
+	public static function getInstance()
24
+	{
25
+		static $instance;
26
+		if (null === $instance) {
27
+			$instance = new static();
28
+		}
29 29
 
30
-        return $instance;
31
-    }
30
+		return $instance;
31
+	}
32 32
 
33
-    /**
34
-     * Loading configs from CAPTCHA class
35
-     * @param array $config
36
-     */
37
-    public function loadConfig($config = [])
38
-    {
39
-        // Loading default preferences
40
-        $this->config = $config;
41
-    }
33
+	/**
34
+	 * Loading configs from CAPTCHA class
35
+	 * @param array $config
36
+	 */
37
+	public function loadConfig($config = [])
38
+	{
39
+		// Loading default preferences
40
+		$this->config = $config;
41
+	}
42 42
 
43
-    /**
44
-     * @return string
45
-     */
46
-    public function render()
47
-    {
48
-        $form = "<input type='text' name='" . $this->config['name'] . "' id='" . $this->config['name'] . "' size='" . $this->config['num_chars'] . "' maxlength='" . $this->config['num_chars'] . "' value=''> &nbsp; " . $this->loadImage();
49
-        $rule = htmlspecialchars(XOOPS_CAPTCHA_REFRESH, ENT_QUOTES);
50
-        if ($this->config['maxattempt']) {
51
-            $rule .= ' | ' . sprintf(constant('XOOPS_CAPTCHA_MAXATTEMPTS'), $this->config['maxattempt']);
52
-        }
53
-        $form .= "&nbsp;&nbsp;<small>{$rule}</small>";
43
+	/**
44
+	 * @return string
45
+	 */
46
+	public function render()
47
+	{
48
+		$form = "<input type='text' name='" . $this->config['name'] . "' id='" . $this->config['name'] . "' size='" . $this->config['num_chars'] . "' maxlength='" . $this->config['num_chars'] . "' value=''> &nbsp; " . $this->loadImage();
49
+		$rule = htmlspecialchars(XOOPS_CAPTCHA_REFRESH, ENT_QUOTES);
50
+		if ($this->config['maxattempt']) {
51
+			$rule .= ' | ' . sprintf(constant('XOOPS_CAPTCHA_MAXATTEMPTS'), $this->config['maxattempt']);
52
+		}
53
+		$form .= "&nbsp;&nbsp;<small>{$rule}</small>";
54 54
 
55
-        return $form;
56
-    }
55
+		return $form;
56
+	}
57 57
 
58
-    /**
59
-     * @return string
60
-     */
61
-    public function loadImage()
62
-    {
63
-        $rule = $this->config['casesensitive'] ? constant('XOOPS_CAPTCHA_RULE_CASESENSITIVE') : constant('XOOPS_CAPTCHA_RULE_CASEINSENSITIVE');
64
-        $ret  = "<img id='captcha' src='" . XOOPS_URL . '/' . $this->config['imageurl'] . "' onclick=\"this.src='" . XOOPS_URL . '/' . $this->config['imageurl'] . "?refresh='+Math.random()" . "\" align='absmiddle'  style='cursor: pointer;' alt='" . htmlspecialchars($rule, ENT_QUOTES) . "'>";
58
+	/**
59
+	 * @return string
60
+	 */
61
+	public function loadImage()
62
+	{
63
+		$rule = $this->config['casesensitive'] ? constant('XOOPS_CAPTCHA_RULE_CASESENSITIVE') : constant('XOOPS_CAPTCHA_RULE_CASEINSENSITIVE');
64
+		$ret  = "<img id='captcha' src='" . XOOPS_URL . '/' . $this->config['imageurl'] . "' onclick=\"this.src='" . XOOPS_URL . '/' . $this->config['imageurl'] . "?refresh='+Math.random()" . "\" align='absmiddle'  style='cursor: pointer;' alt='" . htmlspecialchars($rule, ENT_QUOTES) . "'>";
65 65
 
66
-        return $ret;
67
-    }
66
+		return $ret;
67
+	}
68 68
 }
Please login to merge, or discard this patch.
include/captcha/config.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,8 +44,8 @@
 block discarded – undo
44 44
 
45 45
 $language = preg_replace("/[^a-z0-9_\-]/i", '', $GLOBALS['xoopsConfig']['language']);
46 46
 
47
-if (!@require_once __DIR__ . "/language/{$language}.php") {
48
-    require_once __DIR__ . '/language/english.php';
47
+if (!@require_once __DIR__."/language/{$language}.php") {
48
+    require_once __DIR__.'/language/english.php';
49 49
 }
50 50
 
51 51
 return $config;
Please login to merge, or discard this patch.
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -12,40 +12,40 @@
 block discarded – undo
12 12
  */
13 13
 
14 14
 $config = [
15
-    'mode'       => 'image',
16
-    'name'       => 'xoopscaptcha',
17
-    'skipmember' => true,
18
-    // Skip CAPTCHA check for members
19
-    'maxattempt' => 100,
20
-    // Maximum attempts for each session
15
+	'mode'       => 'image',
16
+	'name'       => 'xoopscaptcha',
17
+	'skipmember' => true,
18
+	// Skip CAPTCHA check for members
19
+	'maxattempt' => 100,
20
+	// Maximum attempts for each session
21 21
 
22
-    'num_chars'       => 4,
23
-    // Maximum characters
22
+	'num_chars'       => 4,
23
+	// Maximum characters
24 24
 
25
-    // For image mode, based on DuGris' SecurityImage
26
-    'rootpath'        => __DIR__,
27
-    // __Absolute__ Path to the root of fonts and backgrounds
28
-    'imagepath'       => 'uploads/captcha',
29
-    // Path to temporary image files, __relative__ to XOOPS_ROOT_PATH
30
-    'imageurl'        => 'modules/smartobject/include/captcha/scripts/img.php',
31
-    // Path to the script for creating image, __relative__ to XOOPS_ROOT_PATH
32
-    'casesensitive'   => false,
33
-    // Characters in image mode is case-sensitive
34
-    'fontsize_min'    => 12,
35
-    // Minimum font-size
36
-    'fontsize_max'    => 12,
37
-    // Maximum font-size
38
-    'background_type' => 0,
39
-    // Background type in image mode: 0 - bar; 1 - circle; 2 - line; 3 - rectangle; 4 - ellipse; 5 - polygon; 100 - generated from files
40
-    'background_num'  => 50,
41
-    // Number of background images to generate
42
-    'polygon_point'   => 3
25
+	// For image mode, based on DuGris' SecurityImage
26
+	'rootpath'        => __DIR__,
27
+	// __Absolute__ Path to the root of fonts and backgrounds
28
+	'imagepath'       => 'uploads/captcha',
29
+	// Path to temporary image files, __relative__ to XOOPS_ROOT_PATH
30
+	'imageurl'        => 'modules/smartobject/include/captcha/scripts/img.php',
31
+	// Path to the script for creating image, __relative__ to XOOPS_ROOT_PATH
32
+	'casesensitive'   => false,
33
+	// Characters in image mode is case-sensitive
34
+	'fontsize_min'    => 12,
35
+	// Minimum font-size
36
+	'fontsize_max'    => 12,
37
+	// Maximum font-size
38
+	'background_type' => 0,
39
+	// Background type in image mode: 0 - bar; 1 - circle; 2 - line; 3 - rectangle; 4 - ellipse; 5 - polygon; 100 - generated from files
40
+	'background_num'  => 50,
41
+	// Number of background images to generate
42
+	'polygon_point'   => 3
43 43
 ];
44 44
 
45 45
 $language = preg_replace("/[^a-z0-9_\-]/i", '', $GLOBALS['xoopsConfig']['language']);
46 46
 
47 47
 if (!@require_once __DIR__ . "/language/{$language}.php") {
48
-    require_once __DIR__ . '/language/english.php';
48
+	require_once __DIR__ . '/language/english.php';
49 49
 }
50 50
 
51 51
 return $config;
Please login to merge, or discard this patch.
include/projax_/projax.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@
 block discarded – undo
13 13
  * @filesource
14 14
  */
15 15
 
16
-include __DIR__ . '/classes/JavaScript.php';
17
-__DIR__ . '/classes/Prototype.php';
18
-__DIR__ . '/classes/Scriptaculous.php';
16
+include __DIR__.'/classes/JavaScript.php';
17
+__DIR__.'/classes/Prototype.php';
18
+__DIR__.'/classes/Scriptaculous.php';
19 19
 
20 20
 // For $projax = new Projax();
21 21
 
Please login to merge, or discard this patch.
include/projax_/classes/JavaScript.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 
28 28
     /**
29 29
      * @param $javascript
30
-     * @return mixed|string
30
+     * @return string
31 31
      */
32 32
     public function escape($javascript)
33 33
     {
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
     /**
50 50
      * @param         $name
51
-     * @param         $function
51
+     * @param         string $function
52 52
      * @param  null   $html_options
53 53
      * @return string
54 54
      */
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
      */
23 23
     public function button_to_function($name, $function = null)
24 24
     {
25
-        return '<input type="button" value="' . $name . '" onclick="' . $function . '">';
25
+        return '<input type="button" value="'.$name.'" onclick="'.$function.'">';
26 26
     }
27 27
 
28 28
     /**
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function tag($content)
45 45
     {
46
-        return '<script type="text/javascript">' . $content . '</script>';
46
+        return '<script type="text/javascript">'.$content.'</script>';
47 47
     }
48 48
 
49 49
     /**
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      */
55 55
     public function link_to_function($name, $function, $html_options = null)
56 56
     {
57
-        return '<a href="' . (isset($html_options['href']) ? $html_options['href'] : '#') . '" onclick="' . (isset($html_options['onclick']) ? $html_options['onclick'] . ';' : '') . $function . '; return false;">' . $name . '</a>';
57
+        return '<a href="'.(isset($html_options['href']) ? $html_options['href'] : '#').'" onclick="'.(isset($html_options['onclick']) ? $html_options['onclick'].';' : '').$function.'; return false;">'.$name.'</a>';
58 58
     }
59 59
 
60 60
     /////////////////////////////////////////////////////////////////////////////////////
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
                 $return_val .= $value;
77 77
             }
78 78
 
79
-            return '[' . $return_val . ']';
79
+            return '['.$return_val.']';
80 80
         }
81 81
 
82 82
         return "'$option'";
@@ -99,6 +99,6 @@  discard block
 block discarded – undo
99 99
             }
100 100
         }
101 101
 
102
-        return '{' . $return_val . '}';
102
+        return '{'.$return_val.'}';
103 103
     }
104 104
 }
Please login to merge, or discard this patch.
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -15,90 +15,90 @@
 block discarded – undo
15 15
  */
16 16
 class JavaScript
17 17
 {
18
-    /**
19
-     * @param         $name
20
-     * @param  null   $function
21
-     * @return string
22
-     */
23
-    public function button_to_function($name, $function = null)
24
-    {
25
-        return '<input type="button" value="' . $name . '" onclick="' . $function . '">';
26
-    }
18
+	/**
19
+	 * @param         $name
20
+	 * @param  null   $function
21
+	 * @return string
22
+	 */
23
+	public function button_to_function($name, $function = null)
24
+	{
25
+		return '<input type="button" value="' . $name . '" onclick="' . $function . '">';
26
+	}
27 27
 
28
-    /**
29
-     * @param $javascript
30
-     * @return mixed|string
31
-     */
32
-    public function escape($javascript)
33
-    {
34
-        $javascript = addslashes($javascript);
35
-        $javascript = str_replace(["\r\n", "\n", "\r"], ["\n"], $javascript);
28
+	/**
29
+	 * @param $javascript
30
+	 * @return mixed|string
31
+	 */
32
+	public function escape($javascript)
33
+	{
34
+		$javascript = addslashes($javascript);
35
+		$javascript = str_replace(["\r\n", "\n", "\r"], ["\n"], $javascript);
36 36
 
37
-        return $javascript;
38
-    }
37
+		return $javascript;
38
+	}
39 39
 
40
-    /**
41
-     * @param $content
42
-     * @return string
43
-     */
44
-    public function tag($content)
45
-    {
46
-        return '<script type="text/javascript">' . $content . '</script>';
47
-    }
40
+	/**
41
+	 * @param $content
42
+	 * @return string
43
+	 */
44
+	public function tag($content)
45
+	{
46
+		return '<script type="text/javascript">' . $content . '</script>';
47
+	}
48 48
 
49
-    /**
50
-     * @param         $name
51
-     * @param         $function
52
-     * @param  null   $html_options
53
-     * @return string
54
-     */
55
-    public function link_to_function($name, $function, $html_options = null)
56
-    {
57
-        return '<a href="' . (isset($html_options['href']) ? $html_options['href'] : '#') . '" onclick="' . (isset($html_options['onclick']) ? $html_options['onclick'] . ';' : '') . $function . '; return false;">' . $name . '</a>';
58
-    }
49
+	/**
50
+	 * @param         $name
51
+	 * @param         $function
52
+	 * @param  null   $html_options
53
+	 * @return string
54
+	 */
55
+	public function link_to_function($name, $function, $html_options = null)
56
+	{
57
+		return '<a href="' . (isset($html_options['href']) ? $html_options['href'] : '#') . '" onclick="' . (isset($html_options['onclick']) ? $html_options['onclick'] . ';' : '') . $function . '; return false;">' . $name . '</a>';
58
+	}
59 59
 
60
-    /////////////////////////////////////////////////////////////////////////////////////
61
-    //                             Private functions
62
-    /////////////////////////////////////////////////////////////////////////////////////
60
+	/////////////////////////////////////////////////////////////////////////////////////
61
+	//                             Private functions
62
+	/////////////////////////////////////////////////////////////////////////////////////
63 63
 
64
-    /**
65
-     * @param $option
66
-     * @return string
67
-     */
68
-    public function _array_or_string_for_javascript($option)
69
-    {
70
-        $return_val = '';
71
-        if (is_array($option)) {
72
-            foreach ($option as $value) {
73
-                if (!empty($return_val)) {
74
-                    $ret_val .= ', ';
75
-                }
76
-                $return_val .= $value;
77
-            }
64
+	/**
65
+	 * @param $option
66
+	 * @return string
67
+	 */
68
+	public function _array_or_string_for_javascript($option)
69
+	{
70
+		$return_val = '';
71
+		if (is_array($option)) {
72
+			foreach ($option as $value) {
73
+				if (!empty($return_val)) {
74
+					$ret_val .= ', ';
75
+				}
76
+				$return_val .= $value;
77
+			}
78 78
 
79
-            return '[' . $return_val . ']';
80
-        }
79
+			return '[' . $return_val . ']';
80
+		}
81 81
 
82
-        return "'$option'";
83
-    }
82
+		return "'$option'";
83
+	}
84 84
 
85
-    /**
86
-     * @param $options
87
-     * @return string
88
-     */
89
-    public function _options_for_javascript($options)
90
-    {
91
-        $return_val = '';
85
+	/**
86
+	 * @param $options
87
+	 * @return string
88
+	 */
89
+	public function _options_for_javascript($options)
90
+	{
91
+		$return_val = '';
92 92
 
93
-        if (is_array($options)) {
94
-            foreach ($options as $var => $val) {
95
-                if (!empty($return_val)) {
96
-                    $return_val .= ', ';
97
-                }
98
-                $return_val .= "$var:$val";
99
-            }
100
-        }
93
+		if (is_array($options)) {
94
+			foreach ($options as $var => $val) {
95
+				if (!empty($return_val)) {
96
+					$return_val .= ', ';
97
+				}
98
+				$return_val .= "$var:$val";
99
+			}
100
+		}
101 101
 
102
-        return '{' . $return_val . '}';
103
-    }
102
+		return '{' . $return_val . '}';
103
+	}
104 104
 }
Please login to merge, or discard this patch.
include/projax_/classes/Prototype.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
     }
213 213
 
214 214
     /**
215
-     * @param         $klass
215
+     * @param         string $klass
216 216
      * @param         $name
217 217
      * @param  null   $options
218 218
      * @return string
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
     }
312 312
 
313 313
     /**
314
-     * @param $variable
314
+     * @param string $variable
315 315
      * @param $value
316 316
      * @return string
317 317
      */
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
     }
322 322
 
323 323
     /**
324
-     * @param         $function
324
+     * @param         string $function
325 325
      * @param  null   $args
326 326
      * @return string
327 327
      */
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     {
64 64
         $options['form'] = true;
65 65
 
66
-        return '<form action="' . $options['url'] . '" onsubmit="' . $this->remote_function($options) . '; return false;" method="' . (isset($options['method']) ? $options['method'] : 'post') . '"  >';
66
+        return '<form action="'.$options['url'].'" onsubmit="'.$this->remote_function($options).'; return false;" method="'.(isset($options['method']) ? $options['method'] : 'post').'"  >';
67 67
     }
68 68
 
69 69
     /**
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
     public function periodically_call_remote($options = null)
113 113
     {
114 114
         $frequency = isset($options['frequency']) ? $options['frequency'] : 10;
115
-        $code      = 'new PeriodicalExecuter(function() {' . $this->remote_function($options) . '},' . $frequency . ')';
115
+        $code      = 'new PeriodicalExecuter(function() {'.$this->remote_function($options).'},'.$frequency.')';
116 116
 
117 117
         return $code;
118 118
     }
@@ -128,22 +128,22 @@  discard block
 block discarded – undo
128 128
         $update = '';
129 129
 
130 130
         if (isset($options['update']) && is_array($options['update'])) {
131
-            $update = isset($options['update']['success']) ? 'success: ' . $options['update']['success'] : '';
131
+            $update = isset($options['update']['success']) ? 'success: '.$options['update']['success'] : '';
132 132
             $update .= empty($update) ? '' : ',';
133
-            $update .= isset($options['update']['failure']) ? 'failure: ' . $options['update']['failure'] : '';
133
+            $update .= isset($options['update']['failure']) ? 'failure: '.$options['update']['failure'] : '';
134 134
         } else {
135 135
             $update .= isset($options['update']) ? $options['update'] : '';
136 136
         }
137 137
 
138
-        $ajax_function = empty($update) ? 'new Ajax.Request(' : 'new Ajax.Updater(\'' . $update . '\',';
138
+        $ajax_function = empty($update) ? 'new Ajax.Request(' : 'new Ajax.Updater(\''.$update.'\',';
139 139
 
140
-        $ajax_function .= "'" . $options['url'] . "'";
141
-        $ajax_function .= ',' . $javascript_options . ')';
140
+        $ajax_function .= "'".$options['url']."'";
141
+        $ajax_function .= ','.$javascript_options.')';
142 142
 
143
-        $ajax_function = isset($options['before']) ? $options['before'] . ';' . $ajax_function : $ajax_function;
144
-        $ajax_function = isset($options['after']) ? $ajax_function . ';' . $options['after'] : $ajax_function;
145
-        $ajax_function = isset($options['condition']) ? 'if (' . $options['condition'] . ') {' . $ajax_function . '}' : $ajax_function;
146
-        $ajax_function = isset($options['confirm']) ? 'if ( confirm(\'' . $options['confirm'] . '\' ) ) { ' . $ajax_function . ' } ' : $ajax_function;
143
+        $ajax_function = isset($options['before']) ? $options['before'].';'.$ajax_function : $ajax_function;
144
+        $ajax_function = isset($options['after']) ? $ajax_function.';'.$options['after'] : $ajax_function;
145
+        $ajax_function = isset($options['condition']) ? 'if ('.$options['condition'].') {'.$ajax_function.'}' : $ajax_function;
146
+        $ajax_function = isset($options['confirm']) ? 'if ( confirm(\''.$options['confirm'].'\' ) ) { '.$ajax_function.' } ' : $ajax_function;
147 147
 
148 148
         return $ajax_function;
149 149
     }
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
             $options['with'] = 'Form.serialize(this.form)';
161 161
         }
162 162
 
163
-        return '<input type="button" onclick="' . $this->remote_function($options) . '" name="' . $name . '" value ="' . $value . '">';
163
+        return '<input type="button" onclick="'.$this->remote_function($options).'" name="'.$name.'" value ="'.$value.'">';
164 164
     }
165 165
 
166 166
     /**
@@ -203,8 +203,8 @@  discard block
 block discarded – undo
203 203
         $callbacks = [];
204 204
         foreach ($options as $callback => $code) {
205 205
             if (in_array($callback, $this->CALLBACKS)) {
206
-                $name             = 'on' . ucfirst($callback);
207
-                $callbacks[$name] = 'function(request){' . $code . '}';
206
+                $name             = 'on'.ucfirst($callback);
207
+                $callbacks[$name] = 'function(request){'.$code.'}';
208 208
             }
209 209
         }
210 210
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
     public function _build_observer($klass, $name, $options = null)
221 221
     {
222 222
         if (isset($options['with']) && false === strpos($options['with'], '=')) {
223
-            $options['with'] = '\'' . $options['with'] . '=\' + value';
223
+            $options['with'] = '\''.$options['with'].'=\' + value';
224 224
         } elseif (isset($options['with']) && isset($options['update'])) {
225 225
             $options['with'] = 'value';
226 226
         }
@@ -228,10 +228,10 @@  discard block
 block discarded – undo
228 228
         $callback = $options['function'] ?: $this->remote_function($options);
229 229
 
230 230
         $javascript = "new $klass('$name', ";
231
-        $javascript .= isset($options['frequency']) ? $options['frequency'] . ', ' : '';
231
+        $javascript .= isset($options['frequency']) ? $options['frequency'].', ' : '';
232 232
         $javascript .= 'function (element,value) { ';
233 233
         $javascript .= $callback;
234
-        $javascript .= isset($options['on']) ? ', ' . $options['on'] : '';
234
+        $javascript .= isset($options['on']) ? ', '.$options['on'] : '';
235 235
         $javascript .= '})';
236 236
 
237 237
         return $javascript;
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
         }
264 264
 
265 265
         if (isset($options['position'])) {
266
-            $js_options['insertion'] = 'Insertion.' . ucfirst($options['position']);
266
+            $js_options['insertion'] = 'Insertion.'.ucfirst($options['position']);
267 267
         }
268 268
 
269 269
         $js_options['evalScripts'] = isset($options['script']) ? $options['script'] : 'true';
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
         if (isset($options['form'])) {
272 272
             $js_options['parameters'] = 'Form.serialize(this)';
273 273
         } elseif (isset($options['parameters'])) {
274
-            $js_options['parameters'] = 'Form.serialize(\'' . $options['submit'] . '\')';
274
+            $js_options['parameters'] = 'Form.serialize(\''.$options['submit'].'\')';
275 275
         } elseif (isset($options['with'])) {
276 276
             $js_options['parameters'] = $options['with'];
277 277
         }
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
      */
299 299
     public function ID($id, $extend = null)
300 300
     {
301
-        return "$('$id')" . (!empty($extend)) ? '.' . $extend . '()' : '';
301
+        return "$('$id')".(!empty($extend)) ? '.'.$extend.'()' : '';
302 302
     }
303 303
 
304 304
     /**
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
      */
358 358
     public function delay($seconds = 1, $script = '')
359 359
     {
360
-        return "setTimeout( function() { $script } , " . ($seconds * 1000) . ' )';
360
+        return "setTimeout( function() { $script } , ".($seconds * 1000).' )';
361 361
     }
362 362
 
363 363
     /**
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
     {
380 380
         $args = array_merge([$id], (is_array($options_for_render) ? $options_for_render : [$options_for_render]));
381 381
 
382
-        return $this->call('new Insertion.' . ucfirst($position), $args);
382
+        return $this->call('new Insertion.'.ucfirst($position), $args);
383 383
     }
384 384
 
385 385
     /**
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
      */
444 444
     public function select($pattern, $extend = null)
445 445
     {
446
-        return "$$('$pattern')" . (!empty($extend)) ? '.' . $extend : '';
446
+        return "$$('$pattern')".(!empty($extend)) ? '.'.$extend : '';
447 447
     }
448 448
 
449 449
     /**
Please login to merge, or discard this patch.
Indentation   +448 added lines, -448 removed lines patch added patch discarded remove patch
@@ -15,452 +15,452 @@
 block discarded – undo
15 15
  */
16 16
 class Prototype extends JavaScript
17 17
 {
18
-    public $CALLBACKS = [
19
-        'uninitialized',
20
-        'loading',
21
-        'loaded',
22
-        'interactive',
23
-        'complete',
24
-        'failure',
25
-        'success'
26
-    ];
27
-
28
-    public $AJAX_OPTIONS = [
29
-        'before',
30
-        'after',
31
-        'condition',
32
-        'url',
33
-        'asynchronous',
34
-        'method',
35
-        'insertion',
36
-        'position',
37
-        'form',
38
-        'with',
39
-        'update',
40
-        'script',
41
-        'uninitialized',
42
-        'loading',
43
-        'loaded',
44
-        'interactive',
45
-        'complete',
46
-        'failure',
47
-        'success'
48
-    ];
49
-
50
-    /**
51
-     * @return string
52
-     */
53
-    public function evaluate_remote_response()
54
-    {
55
-        return 'eval(request.responseText)';
56
-    }
57
-
58
-    /**
59
-     * @param $options
60
-     * @return string
61
-     */
62
-    public function form_remote_tag($options)
63
-    {
64
-        $options['form'] = true;
65
-
66
-        return '<form action="' . $options['url'] . '" onsubmit="' . $this->remote_function($options) . '; return false;" method="' . (isset($options['method']) ? $options['method'] : 'post') . '"  >';
67
-    }
68
-
69
-    /**
70
-     * @param         $name
71
-     * @param  null   $options
72
-     * @param  null   $html_options
73
-     * @return string
74
-     */
75
-    public function link_to_remote($name, $options = null, $html_options = null)
76
-    {
77
-        return $this->link_to_function($name, $this->remote_function($options), $html_options);
78
-    }
79
-
80
-    /**
81
-     * @param         $field_id
82
-     * @param  null   $options
83
-     * @return string
84
-     */
85
-    public function observe_field($field_id, $options = null)
86
-    {
87
-        if (isset($options['frequency']) && $options['frequency'] > 0) {
88
-            return $this->_build_observer('Form.Element.Observer', $field_id, $options);
89
-        } else {
90
-            return $this->_build_observer('Form.Element.EventObserver', $field_id, $options);
91
-        }
92
-    }
93
-
94
-    /**
95
-     * @param         $form_id
96
-     * @param  null   $options
97
-     * @return string
98
-     */
99
-    public function observe_form($form_id, $options = null)
100
-    {
101
-        if (isset($options['frequency'])) {
102
-            return $this->_build_observer('Form.Observer', $form_id, $options);
103
-        } else {
104
-            return $this->_build_observer('Form.EventObserver', $form_id, $options);
105
-        }
106
-    }
107
-
108
-    /**
109
-     * @param  null $options
110
-     * @return string
111
-     */
112
-    public function periodically_call_remote($options = null)
113
-    {
114
-        $frequency = isset($options['frequency']) ? $options['frequency'] : 10;
115
-        $code      = 'new PeriodicalExecuter(function() {' . $this->remote_function($options) . '},' . $frequency . ')';
116
-
117
-        return $code;
118
-    }
119
-
120
-    /**
121
-     * @param $options
122
-     * @return string
123
-     */
124
-    public function remote_function($options)
125
-    {
126
-        $javascript_options = $this->_options_for_ajax($options);
127
-
128
-        $update = '';
129
-
130
-        if (isset($options['update']) && is_array($options['update'])) {
131
-            $update = isset($options['update']['success']) ? 'success: ' . $options['update']['success'] : '';
132
-            $update .= empty($update) ? '' : ',';
133
-            $update .= isset($options['update']['failure']) ? 'failure: ' . $options['update']['failure'] : '';
134
-        } else {
135
-            $update .= isset($options['update']) ? $options['update'] : '';
136
-        }
137
-
138
-        $ajax_function = empty($update) ? 'new Ajax.Request(' : 'new Ajax.Updater(\'' . $update . '\',';
139
-
140
-        $ajax_function .= "'" . $options['url'] . "'";
141
-        $ajax_function .= ',' . $javascript_options . ')';
142
-
143
-        $ajax_function = isset($options['before']) ? $options['before'] . ';' . $ajax_function : $ajax_function;
144
-        $ajax_function = isset($options['after']) ? $ajax_function . ';' . $options['after'] : $ajax_function;
145
-        $ajax_function = isset($options['condition']) ? 'if (' . $options['condition'] . ') {' . $ajax_function . '}' : $ajax_function;
146
-        $ajax_function = isset($options['confirm']) ? 'if ( confirm(\'' . $options['confirm'] . '\' ) ) { ' . $ajax_function . ' } ' : $ajax_function;
147
-
148
-        return $ajax_function;
149
-    }
150
-
151
-    /**
152
-     * @param $name
153
-     * @param $value
154
-     * @param $options
155
-     * @return string
156
-     */
157
-    public function submit_to_remote($name, $value, $options)
158
-    {
159
-        if (isset($options['with'])) {
160
-            $options['with'] = 'Form.serialize(this.form)';
161
-        }
162
-
163
-        return '<input type="button" onclick="' . $this->remote_function($options) . '" name="' . $name . '" value ="' . $value . '">';
164
-    }
165
-
166
-    /**
167
-     * @param      $element_id
168
-     * @param null $options
169
-     * @param      $block
170
-     */
171
-    public function update_element_function($element_id, $options = null, $block)
172
-    {
173
-        $content = isset($options['content']) ? $options['content'] : '';
174
-        $content = $this->escape($content);
175
-    }
176
-
177
-    /**
178
-     * @param $block
179
-     */
180
-    public function update_page($block)
181
-    {
182
-    }
183
-
184
-    /**
185
-     * @param $block
186
-     * @return string
187
-     */
188
-    public function update_page_tag(& $block)
189
-    {
190
-        return $this->tag($block);
191
-    }
192
-
193
-    /////////////////////////////////////////////////////////////////////////////////////
194
-    //                             Private functions
195
-    /////////////////////////////////////////////////////////////////////////////////////
196
-
197
-    /**
198
-     * @param $options
199
-     * @return array
200
-     */
201
-    public function _build_callbacks($options)
202
-    {
203
-        $callbacks = [];
204
-        foreach ($options as $callback => $code) {
205
-            if (in_array($callback, $this->CALLBACKS)) {
206
-                $name             = 'on' . ucfirst($callback);
207
-                $callbacks[$name] = 'function(request){' . $code . '}';
208
-            }
209
-        }
210
-
211
-        return $callbacks;
212
-    }
213
-
214
-    /**
215
-     * @param         $klass
216
-     * @param         $name
217
-     * @param  null   $options
218
-     * @return string
219
-     */
220
-    public function _build_observer($klass, $name, $options = null)
221
-    {
222
-        if (isset($options['with']) && false === strpos($options['with'], '=')) {
223
-            $options['with'] = '\'' . $options['with'] . '=\' + value';
224
-        } elseif (isset($options['with']) && isset($options['update'])) {
225
-            $options['with'] = 'value';
226
-        }
227
-
228
-        $callback = $options['function'] ?: $this->remote_function($options);
229
-
230
-        $javascript = "new $klass('$name', ";
231
-        $javascript .= isset($options['frequency']) ? $options['frequency'] . ', ' : '';
232
-        $javascript .= 'function (element,value) { ';
233
-        $javascript .= $callback;
234
-        $javascript .= isset($options['on']) ? ', ' . $options['on'] : '';
235
-        $javascript .= '})';
236
-
237
-        return $javascript;
238
-    }
239
-
240
-    /**
241
-     * @param $method
242
-     * @return string
243
-     */
244
-    public function _method_option_to_s($method)
245
-    {
246
-        return false !== strpos($method, "'") ? $method : "'$method'";
247
-    }
248
-
249
-    /**
250
-     * @param $options
251
-     * @return string
252
-     */
253
-    public function _options_for_ajax($options)
254
-    {
255
-        $js_options = is_array($options) ? $this->_build_callbacks($options) : [];
256
-
257
-        if (isset($options['type']) && 'synchronous' === $option['type']) {
258
-            $js_options['asynchronous'] = 'false';
259
-        }
260
-
261
-        if (isset($options['method'])) {
262
-            $js_options['method'] = $this->_method_option_to_s($options['method']);
263
-        }
264
-
265
-        if (isset($options['position'])) {
266
-            $js_options['insertion'] = 'Insertion.' . ucfirst($options['position']);
267
-        }
268
-
269
-        $js_options['evalScripts'] = isset($options['script']) ? $options['script'] : 'true';
270
-
271
-        if (isset($options['form'])) {
272
-            $js_options['parameters'] = 'Form.serialize(this)';
273
-        } elseif (isset($options['parameters'])) {
274
-            $js_options['parameters'] = 'Form.serialize(\'' . $options['submit'] . '\')';
275
-        } elseif (isset($options['with'])) {
276
-            $js_options['parameters'] = $options['with'];
277
-        }
278
-
279
-        return $this->_options_for_javascript($js_options);
280
-    }
281
-
282
-    /////////////////////////////////////////////////////////////////////////////////////
283
-    //                            Mergerd Javascript Generator helpers
284
-    /////////////////////////////////////////////////////////////////////////////////////
285
-
286
-    /**
287
-     * @param $javascript
288
-     */
289
-    public function dump($javascript)
290
-    {
291
-        echo $javascript;
292
-    }
293
-
294
-    /**
295
-     * @param         $id
296
-     * @param  null   $extend
297
-     * @return string
298
-     */
299
-    public function ID($id, $extend = null)
300
-    {
301
-        return "$('$id')" . (!empty($extend)) ? '.' . $extend . '()' : '';
302
-    }
303
-
304
-    /**
305
-     * @param $message
306
-     * @return string
307
-     */
308
-    public function alert($message)
309
-    {
310
-        return $this->call('alert', $message);
311
-    }
312
-
313
-    /**
314
-     * @param $variable
315
-     * @param $value
316
-     * @return string
317
-     */
318
-    public function assign($variable, $value)
319
-    {
320
-        return "$variable = $value;";
321
-    }
322
-
323
-    /**
324
-     * @param         $function
325
-     * @param  null   $args
326
-     * @return string
327
-     */
328
-    public function call($function, $args = null)
329
-    {
330
-        $arg_str = '';
331
-        if (is_array($args)) {
332
-            foreach ($args as $arg) {
333
-                if (!empty($arg_str)) {
334
-                    $arg_str .= ', ';
335
-                }
336
-                if (is_string($arg)) {
337
-                    $arg_str .= "'$arg'";
338
-                } else {
339
-                    $arg_str .= $arg;
340
-                }
341
-            }
342
-        } else {
343
-            if (is_string($args)) {
344
-                $arg_str .= "'$args'";
345
-            } else {
346
-                $arg_str .= $args;
347
-            }
348
-        }
349
-
350
-        return "$function($arg_str)";
351
-    }
352
-
353
-    /**
354
-     * @param  int    $seconds
355
-     * @param  string $script
356
-     * @return string
357
-     */
358
-    public function delay($seconds = 1, $script = '')
359
-    {
360
-        return "setTimeout( function() { $script } , " . ($seconds * 1000) . ' )';
361
-    }
362
-
363
-    /**
364
-     * @param $id
365
-     * @return string
366
-     */
367
-    public function hide($id)
368
-    {
369
-        return $this->call('Element.hide', $id);
370
-    }
371
-
372
-    /**
373
-     * @param         $position
374
-     * @param         $id
375
-     * @param  null   $options_for_render
376
-     * @return string
377
-     */
378
-    public function insert_html($position, $id, $options_for_render = null)
379
-    {
380
-        $args = array_merge([$id], (is_array($options_for_render) ? $options_for_render : [$options_for_render]));
381
-
382
-        return $this->call('new Insertion.' . ucfirst($position), $args);
383
-    }
384
-
385
-    /**
386
-     * @param $location
387
-     * @return string
388
-     */
389
-    public function redirect_to($location)
390
-    {
391
-        return $this->assign('window.location.href', $location);
392
-    }
393
-
394
-    /**
395
-     * @param $id
396
-     * @return string
397
-     */
398
-    public function remove($id)
399
-    {
400
-        if (is_array($id)) {
401
-            $arr_str = '';
402
-            foreach ($id as $obj) {
403
-                if (!empty($arg_str)) {
404
-                    $arg_str .= ', ';
405
-                }
406
-                $arg_str .= "'$arg'";
407
-            }
408
-
409
-            return "$A[$arg_str].each(Element.remove)";
410
-        } else {
411
-            return "Element.remove('$id')";
412
-        }
413
-    }
414
-
415
-    /**
416
-     * @param $id
417
-     * @param $options_for_render
418
-     * @return string
419
-     */
420
-    public function replace($id, $options_for_render)
421
-    {
422
-        $args = array_merge([$id], (is_array($options_for_render) ? $options_for_render : [$options_for_render]));
423
-
424
-        return $this->call('Element.replace', $args);
425
-    }
426
-
427
-    /**
428
-     * @param $id
429
-     * @param $options_for_render
430
-     * @return string
431
-     */
432
-    public function replace_html($id, $options_for_render)
433
-    {
434
-        $args = array_merge([$id], (is_array($options_for_render) ? $options_for_render : [$options_for_render]));
435
-
436
-        return $this->call('Element.update', $args);
437
-    }
438
-
439
-    /**
440
-     * @param         $pattern
441
-     * @param  null   $extend
442
-     * @return string
443
-     */
444
-    public function select($pattern, $extend = null)
445
-    {
446
-        return "$$('$pattern')" . (!empty($extend)) ? '.' . $extend : '';
447
-    }
448
-
449
-    /**
450
-     * @param $id
451
-     * @return string
452
-     */
453
-    public function show($id)
454
-    {
455
-        return $this->call('Element.show', $id);
456
-    }
457
-
458
-    /**
459
-     * @param $id
460
-     * @return string
461
-     */
462
-    public function toggle($id)
463
-    {
464
-        return $this->call('Element.toggle', $id);
465
-    }
18
+	public $CALLBACKS = [
19
+		'uninitialized',
20
+		'loading',
21
+		'loaded',
22
+		'interactive',
23
+		'complete',
24
+		'failure',
25
+		'success'
26
+	];
27
+
28
+	public $AJAX_OPTIONS = [
29
+		'before',
30
+		'after',
31
+		'condition',
32
+		'url',
33
+		'asynchronous',
34
+		'method',
35
+		'insertion',
36
+		'position',
37
+		'form',
38
+		'with',
39
+		'update',
40
+		'script',
41
+		'uninitialized',
42
+		'loading',
43
+		'loaded',
44
+		'interactive',
45
+		'complete',
46
+		'failure',
47
+		'success'
48
+	];
49
+
50
+	/**
51
+	 * @return string
52
+	 */
53
+	public function evaluate_remote_response()
54
+	{
55
+		return 'eval(request.responseText)';
56
+	}
57
+
58
+	/**
59
+	 * @param $options
60
+	 * @return string
61
+	 */
62
+	public function form_remote_tag($options)
63
+	{
64
+		$options['form'] = true;
65
+
66
+		return '<form action="' . $options['url'] . '" onsubmit="' . $this->remote_function($options) . '; return false;" method="' . (isset($options['method']) ? $options['method'] : 'post') . '"  >';
67
+	}
68
+
69
+	/**
70
+	 * @param         $name
71
+	 * @param  null   $options
72
+	 * @param  null   $html_options
73
+	 * @return string
74
+	 */
75
+	public function link_to_remote($name, $options = null, $html_options = null)
76
+	{
77
+		return $this->link_to_function($name, $this->remote_function($options), $html_options);
78
+	}
79
+
80
+	/**
81
+	 * @param         $field_id
82
+	 * @param  null   $options
83
+	 * @return string
84
+	 */
85
+	public function observe_field($field_id, $options = null)
86
+	{
87
+		if (isset($options['frequency']) && $options['frequency'] > 0) {
88
+			return $this->_build_observer('Form.Element.Observer', $field_id, $options);
89
+		} else {
90
+			return $this->_build_observer('Form.Element.EventObserver', $field_id, $options);
91
+		}
92
+	}
93
+
94
+	/**
95
+	 * @param         $form_id
96
+	 * @param  null   $options
97
+	 * @return string
98
+	 */
99
+	public function observe_form($form_id, $options = null)
100
+	{
101
+		if (isset($options['frequency'])) {
102
+			return $this->_build_observer('Form.Observer', $form_id, $options);
103
+		} else {
104
+			return $this->_build_observer('Form.EventObserver', $form_id, $options);
105
+		}
106
+	}
107
+
108
+	/**
109
+	 * @param  null $options
110
+	 * @return string
111
+	 */
112
+	public function periodically_call_remote($options = null)
113
+	{
114
+		$frequency = isset($options['frequency']) ? $options['frequency'] : 10;
115
+		$code      = 'new PeriodicalExecuter(function() {' . $this->remote_function($options) . '},' . $frequency . ')';
116
+
117
+		return $code;
118
+	}
119
+
120
+	/**
121
+	 * @param $options
122
+	 * @return string
123
+	 */
124
+	public function remote_function($options)
125
+	{
126
+		$javascript_options = $this->_options_for_ajax($options);
127
+
128
+		$update = '';
129
+
130
+		if (isset($options['update']) && is_array($options['update'])) {
131
+			$update = isset($options['update']['success']) ? 'success: ' . $options['update']['success'] : '';
132
+			$update .= empty($update) ? '' : ',';
133
+			$update .= isset($options['update']['failure']) ? 'failure: ' . $options['update']['failure'] : '';
134
+		} else {
135
+			$update .= isset($options['update']) ? $options['update'] : '';
136
+		}
137
+
138
+		$ajax_function = empty($update) ? 'new Ajax.Request(' : 'new Ajax.Updater(\'' . $update . '\',';
139
+
140
+		$ajax_function .= "'" . $options['url'] . "'";
141
+		$ajax_function .= ',' . $javascript_options . ')';
142
+
143
+		$ajax_function = isset($options['before']) ? $options['before'] . ';' . $ajax_function : $ajax_function;
144
+		$ajax_function = isset($options['after']) ? $ajax_function . ';' . $options['after'] : $ajax_function;
145
+		$ajax_function = isset($options['condition']) ? 'if (' . $options['condition'] . ') {' . $ajax_function . '}' : $ajax_function;
146
+		$ajax_function = isset($options['confirm']) ? 'if ( confirm(\'' . $options['confirm'] . '\' ) ) { ' . $ajax_function . ' } ' : $ajax_function;
147
+
148
+		return $ajax_function;
149
+	}
150
+
151
+	/**
152
+	 * @param $name
153
+	 * @param $value
154
+	 * @param $options
155
+	 * @return string
156
+	 */
157
+	public function submit_to_remote($name, $value, $options)
158
+	{
159
+		if (isset($options['with'])) {
160
+			$options['with'] = 'Form.serialize(this.form)';
161
+		}
162
+
163
+		return '<input type="button" onclick="' . $this->remote_function($options) . '" name="' . $name . '" value ="' . $value . '">';
164
+	}
165
+
166
+	/**
167
+	 * @param      $element_id
168
+	 * @param null $options
169
+	 * @param      $block
170
+	 */
171
+	public function update_element_function($element_id, $options = null, $block)
172
+	{
173
+		$content = isset($options['content']) ? $options['content'] : '';
174
+		$content = $this->escape($content);
175
+	}
176
+
177
+	/**
178
+	 * @param $block
179
+	 */
180
+	public function update_page($block)
181
+	{
182
+	}
183
+
184
+	/**
185
+	 * @param $block
186
+	 * @return string
187
+	 */
188
+	public function update_page_tag(& $block)
189
+	{
190
+		return $this->tag($block);
191
+	}
192
+
193
+	/////////////////////////////////////////////////////////////////////////////////////
194
+	//                             Private functions
195
+	/////////////////////////////////////////////////////////////////////////////////////
196
+
197
+	/**
198
+	 * @param $options
199
+	 * @return array
200
+	 */
201
+	public function _build_callbacks($options)
202
+	{
203
+		$callbacks = [];
204
+		foreach ($options as $callback => $code) {
205
+			if (in_array($callback, $this->CALLBACKS)) {
206
+				$name             = 'on' . ucfirst($callback);
207
+				$callbacks[$name] = 'function(request){' . $code . '}';
208
+			}
209
+		}
210
+
211
+		return $callbacks;
212
+	}
213
+
214
+	/**
215
+	 * @param         $klass
216
+	 * @param         $name
217
+	 * @param  null   $options
218
+	 * @return string
219
+	 */
220
+	public function _build_observer($klass, $name, $options = null)
221
+	{
222
+		if (isset($options['with']) && false === strpos($options['with'], '=')) {
223
+			$options['with'] = '\'' . $options['with'] . '=\' + value';
224
+		} elseif (isset($options['with']) && isset($options['update'])) {
225
+			$options['with'] = 'value';
226
+		}
227
+
228
+		$callback = $options['function'] ?: $this->remote_function($options);
229
+
230
+		$javascript = "new $klass('$name', ";
231
+		$javascript .= isset($options['frequency']) ? $options['frequency'] . ', ' : '';
232
+		$javascript .= 'function (element,value) { ';
233
+		$javascript .= $callback;
234
+		$javascript .= isset($options['on']) ? ', ' . $options['on'] : '';
235
+		$javascript .= '})';
236
+
237
+		return $javascript;
238
+	}
239
+
240
+	/**
241
+	 * @param $method
242
+	 * @return string
243
+	 */
244
+	public function _method_option_to_s($method)
245
+	{
246
+		return false !== strpos($method, "'") ? $method : "'$method'";
247
+	}
248
+
249
+	/**
250
+	 * @param $options
251
+	 * @return string
252
+	 */
253
+	public function _options_for_ajax($options)
254
+	{
255
+		$js_options = is_array($options) ? $this->_build_callbacks($options) : [];
256
+
257
+		if (isset($options['type']) && 'synchronous' === $option['type']) {
258
+			$js_options['asynchronous'] = 'false';
259
+		}
260
+
261
+		if (isset($options['method'])) {
262
+			$js_options['method'] = $this->_method_option_to_s($options['method']);
263
+		}
264
+
265
+		if (isset($options['position'])) {
266
+			$js_options['insertion'] = 'Insertion.' . ucfirst($options['position']);
267
+		}
268
+
269
+		$js_options['evalScripts'] = isset($options['script']) ? $options['script'] : 'true';
270
+
271
+		if (isset($options['form'])) {
272
+			$js_options['parameters'] = 'Form.serialize(this)';
273
+		} elseif (isset($options['parameters'])) {
274
+			$js_options['parameters'] = 'Form.serialize(\'' . $options['submit'] . '\')';
275
+		} elseif (isset($options['with'])) {
276
+			$js_options['parameters'] = $options['with'];
277
+		}
278
+
279
+		return $this->_options_for_javascript($js_options);
280
+	}
281
+
282
+	/////////////////////////////////////////////////////////////////////////////////////
283
+	//                            Mergerd Javascript Generator helpers
284
+	/////////////////////////////////////////////////////////////////////////////////////
285
+
286
+	/**
287
+	 * @param $javascript
288
+	 */
289
+	public function dump($javascript)
290
+	{
291
+		echo $javascript;
292
+	}
293
+
294
+	/**
295
+	 * @param         $id
296
+	 * @param  null   $extend
297
+	 * @return string
298
+	 */
299
+	public function ID($id, $extend = null)
300
+	{
301
+		return "$('$id')" . (!empty($extend)) ? '.' . $extend . '()' : '';
302
+	}
303
+
304
+	/**
305
+	 * @param $message
306
+	 * @return string
307
+	 */
308
+	public function alert($message)
309
+	{
310
+		return $this->call('alert', $message);
311
+	}
312
+
313
+	/**
314
+	 * @param $variable
315
+	 * @param $value
316
+	 * @return string
317
+	 */
318
+	public function assign($variable, $value)
319
+	{
320
+		return "$variable = $value;";
321
+	}
322
+
323
+	/**
324
+	 * @param         $function
325
+	 * @param  null   $args
326
+	 * @return string
327
+	 */
328
+	public function call($function, $args = null)
329
+	{
330
+		$arg_str = '';
331
+		if (is_array($args)) {
332
+			foreach ($args as $arg) {
333
+				if (!empty($arg_str)) {
334
+					$arg_str .= ', ';
335
+				}
336
+				if (is_string($arg)) {
337
+					$arg_str .= "'$arg'";
338
+				} else {
339
+					$arg_str .= $arg;
340
+				}
341
+			}
342
+		} else {
343
+			if (is_string($args)) {
344
+				$arg_str .= "'$args'";
345
+			} else {
346
+				$arg_str .= $args;
347
+			}
348
+		}
349
+
350
+		return "$function($arg_str)";
351
+	}
352
+
353
+	/**
354
+	 * @param  int    $seconds
355
+	 * @param  string $script
356
+	 * @return string
357
+	 */
358
+	public function delay($seconds = 1, $script = '')
359
+	{
360
+		return "setTimeout( function() { $script } , " . ($seconds * 1000) . ' )';
361
+	}
362
+
363
+	/**
364
+	 * @param $id
365
+	 * @return string
366
+	 */
367
+	public function hide($id)
368
+	{
369
+		return $this->call('Element.hide', $id);
370
+	}
371
+
372
+	/**
373
+	 * @param         $position
374
+	 * @param         $id
375
+	 * @param  null   $options_for_render
376
+	 * @return string
377
+	 */
378
+	public function insert_html($position, $id, $options_for_render = null)
379
+	{
380
+		$args = array_merge([$id], (is_array($options_for_render) ? $options_for_render : [$options_for_render]));
381
+
382
+		return $this->call('new Insertion.' . ucfirst($position), $args);
383
+	}
384
+
385
+	/**
386
+	 * @param $location
387
+	 * @return string
388
+	 */
389
+	public function redirect_to($location)
390
+	{
391
+		return $this->assign('window.location.href', $location);
392
+	}
393
+
394
+	/**
395
+	 * @param $id
396
+	 * @return string
397
+	 */
398
+	public function remove($id)
399
+	{
400
+		if (is_array($id)) {
401
+			$arr_str = '';
402
+			foreach ($id as $obj) {
403
+				if (!empty($arg_str)) {
404
+					$arg_str .= ', ';
405
+				}
406
+				$arg_str .= "'$arg'";
407
+			}
408
+
409
+			return "$A[$arg_str].each(Element.remove)";
410
+		} else {
411
+			return "Element.remove('$id')";
412
+		}
413
+	}
414
+
415
+	/**
416
+	 * @param $id
417
+	 * @param $options_for_render
418
+	 * @return string
419
+	 */
420
+	public function replace($id, $options_for_render)
421
+	{
422
+		$args = array_merge([$id], (is_array($options_for_render) ? $options_for_render : [$options_for_render]));
423
+
424
+		return $this->call('Element.replace', $args);
425
+	}
426
+
427
+	/**
428
+	 * @param $id
429
+	 * @param $options_for_render
430
+	 * @return string
431
+	 */
432
+	public function replace_html($id, $options_for_render)
433
+	{
434
+		$args = array_merge([$id], (is_array($options_for_render) ? $options_for_render : [$options_for_render]));
435
+
436
+		return $this->call('Element.update', $args);
437
+	}
438
+
439
+	/**
440
+	 * @param         $pattern
441
+	 * @param  null   $extend
442
+	 * @return string
443
+	 */
444
+	public function select($pattern, $extend = null)
445
+	{
446
+		return "$$('$pattern')" . (!empty($extend)) ? '.' . $extend : '';
447
+	}
448
+
449
+	/**
450
+	 * @param $id
451
+	 * @return string
452
+	 */
453
+	public function show($id)
454
+	{
455
+		return $this->call('Element.show', $id);
456
+	}
457
+
458
+	/**
459
+	 * @param $id
460
+	 * @return string
461
+	 */
462
+	public function toggle($id)
463
+	{
464
+		return $this->call('Element.toggle', $id);
465
+	}
466 466
 }
Please login to merge, or discard this patch.
xoops_version.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
 global $xoopsConfig;
67 67
 $common_file = XOOPS_ROOT_PATH . '/modules/smartobject/language/' . $xoopsConfig['language'] . '/common.php';
68 68
 if (file_exists($common_file)) {
69
-    $flag_common = true;
70
-    require_once $common_file;
69
+	$flag_common = true;
70
+	require_once $common_file;
71 71
 } else {
72
-    require_once XOOPS_ROOT_PATH . '/modules/smartobject/language/english/common.php';
72
+	require_once XOOPS_ROOT_PATH . '/modules/smartobject/language/english/common.php';
73 73
 }
74 74
 // -----
75 75
 
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
 
106 106
 // ------------------- Help files ------------------- //
107 107
 $modversion['helpsection'] = [
108
-    ['name' => _MI_SOBJECT_OVERVIEW, 'link' => 'page=help'],
109
-    ['name' => _MI_SOBJECT_DISCLAIMER, 'link' => 'page=disclaimer'],
110
-    ['name' => _MI_SOBJECT_LICENSE, 'link' => 'page=license'],
111
-    ['name' => _MI_SOBJECT_SUPPORT, 'link' => 'page=support'],
108
+	['name' => _MI_SOBJECT_OVERVIEW, 'link' => 'page=help'],
109
+	['name' => _MI_SOBJECT_DISCLAIMER, 'link' => 'page=disclaimer'],
110
+	['name' => _MI_SOBJECT_LICENSE, 'link' => 'page=license'],
111
+	['name' => _MI_SOBJECT_SUPPORT, 'link' => 'page=support'],
112 112
 ];
113 113
 
114 114
 
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
 // defined('XOOPS_ROOT_PATH') || die('Restricted access');
12 12
 
13
-require_once __DIR__ . '/preloads/autoloader.php';
13
+require_once __DIR__.'/preloads/autoloader.php';
14 14
 
15 15
 $modversion['version']       = '1.12';
16 16
 $modversion['module_status'] = 'RC 2';
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 //$modversion['status'] = "Final";
34 34
 $modversion['modicons16']          = 'assets/images/icons/16';
35 35
 $modversion['modicons32']          = 'assets/images/icons/32';
36
-$modversion['release_file']        = XOOPS_URL . '/modules/' . $modversion['dirname'] . '/docs/changelog.txt';
36
+$modversion['release_file']        = XOOPS_URL.'/modules/'.$modversion['dirname'].'/docs/changelog.txt';
37 37
 $modversion['module_website_url']  = 'www.xoops.org';
38 38
 $modversion['module_website_name'] = 'XOOPS';
39 39
 $modversion['min_php']             = '5.5';
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
 // ----- BUG: not read other language file -----
67 67
 //include_once(XOOPS_ROOT_PATH.'/modules/smartobject/language/english/common.php');
68 68
 global $xoopsConfig;
69
-$common_file = XOOPS_ROOT_PATH . '/modules/smartobject/language/' . $xoopsConfig['language'] . '/common.php';
69
+$common_file = XOOPS_ROOT_PATH.'/modules/smartobject/language/'.$xoopsConfig['language'].'/common.php';
70 70
 if (file_exists($common_file)) {
71 71
     $flag_common = true;
72 72
     require_once $common_file;
73 73
 } else {
74
-    require_once XOOPS_ROOT_PATH . '/modules/smartobject/language/english/common.php';
74
+    require_once XOOPS_ROOT_PATH.'/modules/smartobject/language/english/common.php';
75 75
 }
76 76
 // -----
77 77
 
Please login to merge, or discard this patch.
plugins/smartpartner.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -9,15 +9,15 @@
 block discarded – undo
9 9
 
10 10
 function smartobject_plugin_smartpartner()
11 11
 {
12
-    $pluginInfo = [];
12
+	$pluginInfo = [];
13 13
 
14
-    $pluginInfo['items']['partner']['caption'] = 'Partner';
15
-    $pluginInfo['items']['partner']['url']     = 'partner.php?partnerid=%u';
16
-    $pluginInfo['items']['partner']['request'] = 'partnerid';
14
+	$pluginInfo['items']['partner']['caption'] = 'Partner';
15
+	$pluginInfo['items']['partner']['url']     = 'partner.php?partnerid=%u';
16
+	$pluginInfo['items']['partner']['request'] = 'partnerid';
17 17
 
18
-    $pluginInfo['items']['category']['caption'] = 'Category';
19
-    $pluginInfo['items']['category']['url']     = 'index.php?view_category_id=%u';
20
-    $pluginInfo['items']['category']['request'] = 'view_category_id';
18
+	$pluginInfo['items']['category']['caption'] = 'Category';
19
+	$pluginInfo['items']['category']['url']     = 'index.php?view_category_id=%u';
20
+	$pluginInfo['items']['category']['request'] = 'view_category_id';
21 21
 
22
-    return $pluginInfo;
22
+	return $pluginInfo;
23 23
 }
Please login to merge, or discard this patch.
plugins/smartshop.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -9,15 +9,15 @@
 block discarded – undo
9 9
 
10 10
 function smartobject_plugin_smartshop()
11 11
 {
12
-    $pluginInfo = [];
12
+	$pluginInfo = [];
13 13
 
14
-    $pluginInfo['items']['item']['caption'] = 'Item';
15
-    $pluginInfo['items']['item']['url']     = 'item.php?itemid=%u';
16
-    $pluginInfo['items']['item']['request'] = 'itemid';
14
+	$pluginInfo['items']['item']['caption'] = 'Item';
15
+	$pluginInfo['items']['item']['url']     = 'item.php?itemid=%u';
16
+	$pluginInfo['items']['item']['request'] = 'itemid';
17 17
 
18
-    $pluginInfo['items']['category']['caption'] = 'Category';
19
-    $pluginInfo['items']['category']['url']     = 'category.php?categoryid=%u';
20
-    $pluginInfo['items']['category']['request'] = 'categoryid';
18
+	$pluginInfo['items']['category']['caption'] = 'Category';
19
+	$pluginInfo['items']['category']['url']     = 'category.php?categoryid=%u';
20
+	$pluginInfo['items']['category']['request'] = 'categoryid';
21 21
 
22
-    return $pluginInfo;
22
+	return $pluginInfo;
23 23
 }
Please login to merge, or discard this patch.