Completed
Branch develop (80d269)
by
unknown
22:48
created
htdocs/includes/restler/framework/Luracast/Restler/iCache.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -13,51 +13,51 @@
 block discarded – undo
13 13
  */
14 14
 interface iCache
15 15
 {
16
-    /**
17
-     * store data in the cache
18
-     *
19
-     * @abstract
20
-     *
21
-     * @param string $name
22
-     * @param mixed  $data
23
-     *
24
-     * @return boolean true if successful
25
-     */
26
-    public function set($name, $data);
16
+	/**
17
+	 * store data in the cache
18
+	 *
19
+	 * @abstract
20
+	 *
21
+	 * @param string $name
22
+	 * @param mixed  $data
23
+	 *
24
+	 * @return boolean true if successful
25
+	 */
26
+	public function set($name, $data);
27 27
 
28
-    /**
29
-     * retrieve data from the cache
30
-     *
31
-     * @abstract
32
-     *
33
-     * @param string     $name
34
-     * @param bool       $ignoreErrors
35
-     *
36
-     * @return mixed
37
-     */
38
-    public function get($name, $ignoreErrors = false);
28
+	/**
29
+	 * retrieve data from the cache
30
+	 *
31
+	 * @abstract
32
+	 *
33
+	 * @param string     $name
34
+	 * @param bool       $ignoreErrors
35
+	 *
36
+	 * @return mixed
37
+	 */
38
+	public function get($name, $ignoreErrors = false);
39 39
 
40
-    /**
41
-     * delete data from the cache
42
-     *
43
-     * @abstract
44
-     *
45
-     * @param string     $name
46
-     * @param bool       $ignoreErrors
47
-     *
48
-     * @return boolean true if successful
49
-     */
50
-    public function clear($name, $ignoreErrors = false);
40
+	/**
41
+	 * delete data from the cache
42
+	 *
43
+	 * @abstract
44
+	 *
45
+	 * @param string     $name
46
+	 * @param bool       $ignoreErrors
47
+	 *
48
+	 * @return boolean true if successful
49
+	 */
50
+	public function clear($name, $ignoreErrors = false);
51 51
 
52
-    /**
53
-     * check if the given name is cached
54
-     *
55
-     * @abstract
56
-     *
57
-     * @param string $name
58
-     *
59
-     * @return boolean true if cached
60
-     */
61
-    public function isCached($name);
52
+	/**
53
+	 * check if the given name is cached
54
+	 *
55
+	 * @abstract
56
+	 *
57
+	 * @param string $name
58
+	 *
59
+	 * @return boolean true if cached
60
+	 */
61
+	public function isCached($name);
62 62
 }
63 63
 
Please login to merge, or discard this patch.
htdocs/includes/restler/framework/Luracast/Restler/views/debug.php 1 patch
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -15,41 +15,41 @@  discard block
 block discarded – undo
15 15
 
16 16
 function exceptions()
17 17
 {
18
-    global $call_trace;
19
-    $r = Util::$restler;
20
-    $source = $r->_exceptions;
21
-    if (count($source)) {
22
-        $source = end($source);
23
-        $traces = array();
24
-        do {
25
-            $traces += $source->getTrace();
26
-        } while ($source = $source->getPrevious());
27
-        $traces += debug_backtrace();
28
-        $call_trace
29
-            = parse_backtrace($traces, 0);
30
-    } else {
31
-        $call_trace
32
-            = parse_backtrace(debug_backtrace());
33
-    }
18
+	global $call_trace;
19
+	$r = Util::$restler;
20
+	$source = $r->_exceptions;
21
+	if (count($source)) {
22
+		$source = end($source);
23
+		$traces = array();
24
+		do {
25
+			$traces += $source->getTrace();
26
+		} while ($source = $source->getPrevious());
27
+		$traces += debug_backtrace();
28
+		$call_trace
29
+			= parse_backtrace($traces, 0);
30
+	} else {
31
+		$call_trace
32
+			= parse_backtrace(debug_backtrace());
33
+	}
34 34
 
35 35
 }
36 36
 exceptions();
37 37
 
38 38
 function parse_backtrace($raw, $skip = 1)
39 39
 {
40
-    $output = "";
41
-    foreach ($raw as $entry) {
42
-        if ($skip-- > 0) {
43
-            continue;
44
-        }
45
-        //$output .= print_r($entry, true) . "\n";
46
-        $output .= "\nFile: " . $entry['file'] . " (Line: " . $entry['line'] . ")\n";
47
-        if (isset($entry['class']))
48
-            $output .= $entry['class'] . "::";
49
-        $output .= $entry['function']
50
-            . "( " . json_encode($entry['args']) . " )\n";
51
-    }
52
-    return $output;
40
+	$output = "";
41
+	foreach ($raw as $entry) {
42
+		if ($skip-- > 0) {
43
+			continue;
44
+		}
45
+		//$output .= print_r($entry, true) . "\n";
46
+		$output .= "\nFile: " . $entry['file'] . " (Line: " . $entry['line'] . ")\n";
47
+		if (isset($entry['class']))
48
+			$output .= $entry['class'] . "::";
49
+		$output .= $entry['function']
50
+			. "( " . json_encode($entry['args']) . " )\n";
51
+	}
52
+	return $output;
53 53
 }
54 54
 
55 55
 
@@ -57,64 +57,64 @@  discard block
 block discarded – undo
57 57
 //print_r($response);
58 58
 $icon;
59 59
 if ($success && isset($api)) {
60
-    $arguments = implode(', ', $api->parameters);
61
-    $icon = "<icon class=\"success\"></icon>";
62
-    $title = "{$api->className}::"
63
-        . "{$api->methodName}({$arguments})";
60
+	$arguments = implode(', ', $api->parameters);
61
+	$icon = "<icon class=\"success\"></icon>";
62
+	$title = "{$api->className}::"
63
+		. "{$api->methodName}({$arguments})";
64 64
 } else {
65
-    if (isset($response['error']['message'])) {
66
-        $icon = '<icon class="denied"></icon>';
67
-        $title = end(explode(':',$response['error']['message'],2));
68
-    } else {
69
-        $icon = '<icon class="warning"></icon>';
70
-        $title = 'No Matching Resource';
71
-    }
65
+	if (isset($response['error']['message'])) {
66
+		$icon = '<icon class="denied"></icon>';
67
+		$title = end(explode(':',$response['error']['message'],2));
68
+	} else {
69
+		$icon = '<icon class="warning"></icon>';
70
+		$title = 'No Matching Resource';
71
+	}
72 72
 }
73 73
 function render($data, $shadow=true)
74 74
 {
75
-    $r = '';
76
-    if (empty($data))
77
-        return $r;
78
-    $r .= $shadow ? "<ul class=\"shadow\">\n": "<ul>\n";
79
-    if (is_array($data)) {
80
-        // field name
81
-        foreach ($data as $key => $value) {
82
-            $r .= '<li>';
83
-            $r .= is_numeric($key)
84
-                ? "<strong>[$key]</strong> "
85
-                : "<strong>$key: </strong>";
86
-            $r .= '<span>';
87
-            if (is_array($value)) {
88
-                // recursive
89
-                $r .= render($value,false);
90
-            } else {
91
-                // value, with hyperlinked hyperlinks
92
-                if (is_bool($value)) {
93
-                    $value = $value ? 'true' : 'false';
94
-                }
95
-                $value = htmlentities($value, ENT_COMPAT, 'UTF-8');
96
-                if (strpos($value, 'http://') === 0) {
97
-                    $r .= '<a href="' . $value . '">' . $value . '</a>';
98
-                } else {
99
-                    $r .= $value;
100
-                }
101
-            }
102
-            $r .= "</span></li>\n";
103
-        }
104
-    } elseif (is_bool($data)) {
105
-        $r .= '<li>' . ($data ? 'true' : 'false') . '</li>';
106
-    } else {
107
-        $r .= "<li><strong>$data</strong></li>";
108
-    }
109
-    $r .= "</ul>\n";
110
-    return $r;
75
+	$r = '';
76
+	if (empty($data))
77
+		return $r;
78
+	$r .= $shadow ? "<ul class=\"shadow\">\n": "<ul>\n";
79
+	if (is_array($data)) {
80
+		// field name
81
+		foreach ($data as $key => $value) {
82
+			$r .= '<li>';
83
+			$r .= is_numeric($key)
84
+				? "<strong>[$key]</strong> "
85
+				: "<strong>$key: </strong>";
86
+			$r .= '<span>';
87
+			if (is_array($value)) {
88
+				// recursive
89
+				$r .= render($value,false);
90
+			} else {
91
+				// value, with hyperlinked hyperlinks
92
+				if (is_bool($value)) {
93
+					$value = $value ? 'true' : 'false';
94
+				}
95
+				$value = htmlentities($value, ENT_COMPAT, 'UTF-8');
96
+				if (strpos($value, 'http://') === 0) {
97
+					$r .= '<a href="' . $value . '">' . $value . '</a>';
98
+				} else {
99
+					$r .= $value;
100
+				}
101
+			}
102
+			$r .= "</span></li>\n";
103
+		}
104
+	} elseif (is_bool($data)) {
105
+		$r .= '<li>' . ($data ? 'true' : 'false') . '</li>';
106
+	} else {
107
+		$r .= "<li><strong>$data</strong></li>";
108
+	}
109
+	$r .= "</ul>\n";
110
+	return $r;
111 111
 }
112 112
 $reqHeadersArr = array();
113 113
 $requestHeaders = $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . ' ' . $_SERVER['SERVER_PROTOCOL'] . PHP_EOL;
114 114
 foreach ($reqHeadersArr as $key => $value) {
115
-    if ($key == 'Host')
116
-        continue;
117
-    $requestHeaders .= "$key: $value" . PHP_EOL;
115
+	if ($key == 'Host')
116
+		continue;
117
+	$requestHeaders .= "$key: $value" . PHP_EOL;
118 118
 }
119 119
 // $requestHeaders = $this->encode(apache_request_headers(), FALSE,
120 120
 // FALSE);
@@ -134,24 +134,24 @@  discard block
 block discarded – undo
134 134
 <body>
135 135
 <div id="breadcrumbs-one">
136 136
     <?php
137
-    if(Util::$restler->exception){
138
-        $stages =  Util::$restler->exception->getStages();
139
-        $curStage = Util::$restler->exception->getStage();
140
-        foreach($stages['success'] as $stage){
141
-            echo "<a href=\"#\">$stage</a>";
142
-        }
143
-        foreach($stages['failure'] as $stage){
144
-            echo '<a href="#" class="failure">'
145
-                . $stage
146
-                . ($stage==$curStage ? ' <span class="state"/> ' : '')
147
-                . '</a>';
148
-        }
149
-    } else {
150
-        foreach(Util::$restler->_events as $stage){
151
-            echo "<a href=\"#\">$stage</a>";
152
-        }
153
-    }
154
-    ?>
137
+	if(Util::$restler->exception){
138
+		$stages =  Util::$restler->exception->getStages();
139
+		$curStage = Util::$restler->exception->getStage();
140
+		foreach($stages['success'] as $stage){
141
+			echo "<a href=\"#\">$stage</a>";
142
+		}
143
+		foreach($stages['failure'] as $stage){
144
+			echo '<a href="#" class="failure">'
145
+				. $stage
146
+				. ($stage==$curStage ? ' <span class="state"/> ' : '')
147
+				. '</a>';
148
+		}
149
+	} else {
150
+		foreach(Util::$restler->_events as $stage){
151
+			echo "<a href=\"#\">$stage</a>";
152
+		}
153
+	}
154
+	?>
155 155
 </div>
156 156
 <header>
157 157
     <h1><?php echo $title ?></h1>
Please login to merge, or discard this patch.
htdocs/includes/restler/framework/Luracast/Restler/Defaults.php 1 patch
Indentation   +340 added lines, -340 removed lines patch added patch discarded remove patch
@@ -19,348 +19,348 @@
 block discarded – undo
19 19
  */
20 20
 class Defaults
21 21
 {
22
-    // ==================================================================
23
-    //
24
-    // Class Mappings
25
-    //
26
-    // ------------------------------------------------------------------
27
-
28
-    /**
29
-     * @var string of name of the class that implements
30
-     * \Luracast\Restler\iCache the cache class to be used
31
-     */
32
-    public static $cacheClass = 'Luracast\\Restler\\HumanReadableCache';
33
-
34
-    /**
35
-     * @var string full path of the directory where all the generated files will
36
-     * be kept. When set to null (default) it will use the cache folder that is
37
-     * in the same folder as index.php (gateway)
38
-     */
39
-    public static $cacheDirectory;
40
-
41
-    /**
42
-     * @var string of name of the class that implements
43
-     * \Luracast\Restler\Data\iValidate the validator class to be used
44
-     */
45
-    public static $validatorClass = 'Luracast\\Restler\\Data\\Validator';
46
-
47
-    /**
48
-     * @var string name of the class that implements \Luracast\Restler\iCompose
49
-     * the class to be used to compose the response
50
-     */
51
-    public static $composeClass = 'Luracast\\Restler\\Compose';
52
-
53
-    // ==================================================================
54
-    //
55
-    // Routing
56
-    //
57
-    // ------------------------------------------------------------------
58
-
59
-    /**
60
-     * @var bool should auto routing for public and protected api methods
61
-     * should be enabled by default or not. Set this to false to get
62
-     * Restler 1.0 style behavior
63
-     */
64
-    public static $autoRoutingEnabled = true;
65
-
66
-    /**
67
-     * @var boolean avoids creating multiple routes that can increase the
68
-     * ambiguity when set to true. when a method parameter is optional it is
69
-     * not mapped to the url and should only be used in request body or as
70
-     * query string `/resource?id=value`. When a parameter is required and is
71
-     * scalar, it will be mapped as part of the url `/resource/{id}`
72
-     */
73
-    public static $smartAutoRouting = true;
74
-
75
-    /**
76
-     * @var boolean enables more ways of finding the parameter data in the request.
77
-     * If you need backward compatibility with Restler 2 or below turn this off
78
-     */
79
-    public static $smartParameterParsing = true;
80
-
81
-    // ==================================================================
82
-    //
83
-    // API Version Management
84
-    //
85
-    // ------------------------------------------------------------------
86
-
87
-    /**
88
-     * @var null|string name that is used for vendor specific media type and
89
-     * api version using the Accept Header for example
90
-     * application/vnd.{vendor}-v1+json
91
-     *
92
-     * Keep this null if you do not want to use vendor MIME for specifying api version
93
-     */
94
-    public static $apiVendor = null;
95
-
96
-    /**
97
-     * @var bool set it to true to force vendor specific MIME for versioning.
98
-     * It will be automatically set to true when Defaults::$vendor is not
99
-     * null and client is requesting for the custom MIME type
100
-     */
101
-    public static $useVendorMIMEVersioning = false;
102
-
103
-    /**
104
-     * @var bool set it to true to use enableUrl based versioning
105
-     */
106
-    public static $useUrlBasedVersioning = false;
107
-
108
-
109
-    // ==================================================================
110
-    //
111
-    // Request
112
-    //
113
-    // ------------------------------------------------------------------
114
-
115
-    /**
116
-     * @var string name to be used for the method parameter to capture the
117
-     *             entire request data
118
-     */
119
-    public static $fullRequestDataName = 'request_data';
120
-
121
-    /**
122
-     * @var string name of the property that can sent through $_GET or $_POST to
123
-     *             override the http method of the request. Set it to null or
124
-     *             blank string to disable http method override through request
125
-     *             parameters.
126
-     */
127
-    public static $httpMethodOverrideProperty = 'http_method';
128
-
129
-    /**
130
-     * @var bool should auto validating api parameters should be enabled by
131
-     *           default or not. Set this to false to avoid validation.
132
-     */
133
-    public static $autoValidationEnabled = true;
134
-
135
-    /**
136
-     * @var string name of the class that implements iUser interface to identify
137
-     *             the user for caching purposes
138
-     */
139
-    public static $userIdentifierClass = 'Luracast\\Restler\\User';
140
-
141
-    // ==================================================================
142
-    //
143
-    // Response
144
-    //
145
-    // ------------------------------------------------------------------
146
-
147
-    /**
148
-     * @var bool HTTP status codes are set on all responses by default.
149
-     * Some clients (like flash, mobile) have trouble dealing with non-200
150
-     * status codes on error responses.
151
-     *
152
-     * You can set it to true to force a HTTP 200 status code on all responses,
153
-     * even when errors occur. If you suppress status codes, look for an error
154
-     * response to determine if an error occurred.
155
-     */
156
-    public static $suppressResponseCode = false;
157
-
158
-    public static $supportedCharsets = array('utf-8', 'iso-8859-1');
159
-    public static $supportedLanguages = array('en', 'en-US');
160
-
161
-    public static $charset = 'utf-8';
162
-    public static $language = 'en';
163
-
164
-    /**
165
-     * @var bool when set to true, it will exclude the response body
166
-     */
167
-    public static $emptyBodyForNullResponse = true;
168
-
169
-    /**
170
-     * @var bool when set to true, the response will not be outputted directly into the buffer.
171
-     * If set, Restler::handle() will return the response as a string.
172
-     */
173
-    public static $returnResponse = false;
174
-
175
-    /**
176
-     * @var bool enables CORS support
177
-     */
178
-    public static $crossOriginResourceSharing = false;
179
-    public static $accessControlAllowOrigin = '*';
180
-    public static $accessControlAllowMethods =
181
-        'GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD';
182
-
183
-    // ==================================================================
184
-    //
185
-    // Header
186
-    //
187
-    // ------------------------------------------------------------------
188
-
189
-    /**
190
-     * @var array default Cache-Control template that used to set the
191
-     * Cache-Control header and has two values, first one is used when
192
-     * Defaults::$headerExpires is 0 and second one when it has some time
193
-     * value specified. When only one value is specified it will be used for
194
-     * both cases
195
-     */
196
-    public static $headerCacheControl = array(
197
-        'no-cache, must-revalidate',
198
-
199
-        /* "public, " or "private, " will be prepended based on api method
22
+	// ==================================================================
23
+	//
24
+	// Class Mappings
25
+	//
26
+	// ------------------------------------------------------------------
27
+
28
+	/**
29
+	 * @var string of name of the class that implements
30
+	 * \Luracast\Restler\iCache the cache class to be used
31
+	 */
32
+	public static $cacheClass = 'Luracast\\Restler\\HumanReadableCache';
33
+
34
+	/**
35
+	 * @var string full path of the directory where all the generated files will
36
+	 * be kept. When set to null (default) it will use the cache folder that is
37
+	 * in the same folder as index.php (gateway)
38
+	 */
39
+	public static $cacheDirectory;
40
+
41
+	/**
42
+	 * @var string of name of the class that implements
43
+	 * \Luracast\Restler\Data\iValidate the validator class to be used
44
+	 */
45
+	public static $validatorClass = 'Luracast\\Restler\\Data\\Validator';
46
+
47
+	/**
48
+	 * @var string name of the class that implements \Luracast\Restler\iCompose
49
+	 * the class to be used to compose the response
50
+	 */
51
+	public static $composeClass = 'Luracast\\Restler\\Compose';
52
+
53
+	// ==================================================================
54
+	//
55
+	// Routing
56
+	//
57
+	// ------------------------------------------------------------------
58
+
59
+	/**
60
+	 * @var bool should auto routing for public and protected api methods
61
+	 * should be enabled by default or not. Set this to false to get
62
+	 * Restler 1.0 style behavior
63
+	 */
64
+	public static $autoRoutingEnabled = true;
65
+
66
+	/**
67
+	 * @var boolean avoids creating multiple routes that can increase the
68
+	 * ambiguity when set to true. when a method parameter is optional it is
69
+	 * not mapped to the url and should only be used in request body or as
70
+	 * query string `/resource?id=value`. When a parameter is required and is
71
+	 * scalar, it will be mapped as part of the url `/resource/{id}`
72
+	 */
73
+	public static $smartAutoRouting = true;
74
+
75
+	/**
76
+	 * @var boolean enables more ways of finding the parameter data in the request.
77
+	 * If you need backward compatibility with Restler 2 or below turn this off
78
+	 */
79
+	public static $smartParameterParsing = true;
80
+
81
+	// ==================================================================
82
+	//
83
+	// API Version Management
84
+	//
85
+	// ------------------------------------------------------------------
86
+
87
+	/**
88
+	 * @var null|string name that is used for vendor specific media type and
89
+	 * api version using the Accept Header for example
90
+	 * application/vnd.{vendor}-v1+json
91
+	 *
92
+	 * Keep this null if you do not want to use vendor MIME for specifying api version
93
+	 */
94
+	public static $apiVendor = null;
95
+
96
+	/**
97
+	 * @var bool set it to true to force vendor specific MIME for versioning.
98
+	 * It will be automatically set to true when Defaults::$vendor is not
99
+	 * null and client is requesting for the custom MIME type
100
+	 */
101
+	public static $useVendorMIMEVersioning = false;
102
+
103
+	/**
104
+	 * @var bool set it to true to use enableUrl based versioning
105
+	 */
106
+	public static $useUrlBasedVersioning = false;
107
+
108
+
109
+	// ==================================================================
110
+	//
111
+	// Request
112
+	//
113
+	// ------------------------------------------------------------------
114
+
115
+	/**
116
+	 * @var string name to be used for the method parameter to capture the
117
+	 *             entire request data
118
+	 */
119
+	public static $fullRequestDataName = 'request_data';
120
+
121
+	/**
122
+	 * @var string name of the property that can sent through $_GET or $_POST to
123
+	 *             override the http method of the request. Set it to null or
124
+	 *             blank string to disable http method override through request
125
+	 *             parameters.
126
+	 */
127
+	public static $httpMethodOverrideProperty = 'http_method';
128
+
129
+	/**
130
+	 * @var bool should auto validating api parameters should be enabled by
131
+	 *           default or not. Set this to false to avoid validation.
132
+	 */
133
+	public static $autoValidationEnabled = true;
134
+
135
+	/**
136
+	 * @var string name of the class that implements iUser interface to identify
137
+	 *             the user for caching purposes
138
+	 */
139
+	public static $userIdentifierClass = 'Luracast\\Restler\\User';
140
+
141
+	// ==================================================================
142
+	//
143
+	// Response
144
+	//
145
+	// ------------------------------------------------------------------
146
+
147
+	/**
148
+	 * @var bool HTTP status codes are set on all responses by default.
149
+	 * Some clients (like flash, mobile) have trouble dealing with non-200
150
+	 * status codes on error responses.
151
+	 *
152
+	 * You can set it to true to force a HTTP 200 status code on all responses,
153
+	 * even when errors occur. If you suppress status codes, look for an error
154
+	 * response to determine if an error occurred.
155
+	 */
156
+	public static $suppressResponseCode = false;
157
+
158
+	public static $supportedCharsets = array('utf-8', 'iso-8859-1');
159
+	public static $supportedLanguages = array('en', 'en-US');
160
+
161
+	public static $charset = 'utf-8';
162
+	public static $language = 'en';
163
+
164
+	/**
165
+	 * @var bool when set to true, it will exclude the response body
166
+	 */
167
+	public static $emptyBodyForNullResponse = true;
168
+
169
+	/**
170
+	 * @var bool when set to true, the response will not be outputted directly into the buffer.
171
+	 * If set, Restler::handle() will return the response as a string.
172
+	 */
173
+	public static $returnResponse = false;
174
+
175
+	/**
176
+	 * @var bool enables CORS support
177
+	 */
178
+	public static $crossOriginResourceSharing = false;
179
+	public static $accessControlAllowOrigin = '*';
180
+	public static $accessControlAllowMethods =
181
+		'GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD';
182
+
183
+	// ==================================================================
184
+	//
185
+	// Header
186
+	//
187
+	// ------------------------------------------------------------------
188
+
189
+	/**
190
+	 * @var array default Cache-Control template that used to set the
191
+	 * Cache-Control header and has two values, first one is used when
192
+	 * Defaults::$headerExpires is 0 and second one when it has some time
193
+	 * value specified. When only one value is specified it will be used for
194
+	 * both cases
195
+	 */
196
+	public static $headerCacheControl = array(
197
+		'no-cache, must-revalidate',
198
+
199
+		/* "public, " or "private, " will be prepended based on api method
200 200
          * called (public or protected)
201 201
          */
202
-        'max-age={expires}, must-revalidate',
203
-
204
-    );
205
-
206
-
207
-    /**
208
-     * @var int sets the content to expire immediately when set to zero
209
-     * alternatively you can specify the number of seconds the content will
210
-     * expire. This setting can be altered at api level using php doc comment
211
-     * with @expires numOfSeconds
212
-     */
213
-    public static $headerExpires = 0;
214
-
215
-    // ==================================================================
216
-    //
217
-    // Access Control
218
-    //
219
-    // ------------------------------------------------------------------
220
-
221
-    /**
222
-     * @var null|callable if the api methods are under access control mechanism
223
-     * you can attach a function here that returns true or false to determine
224
-     * visibility of a protected api method. this function will receive method
225
-     * info as the only parameter.
226
-     */
227
-    public static $accessControlFunction = null;
228
-
229
-    /**
230
-     * @var int set the default api access mode
231
-     *      value of 0 = public api
232
-     *      value of 1 = hybrid api using `@access hybrid` comment
233
-     *      value of 2 = protected api using `@access protected` comment
234
-     *      value of 3 = protected api using `protected function` method
235
-     */
236
-    public static $apiAccessLevel = 0;
237
-
238
-    /**
239
-     * @var string authentication method to be called in iAuthenticate
240
-     * Interface
241
-     */
242
-    public static $authenticationMethod = '__isAllowed';
243
-
244
-    /**
245
-     * @var int time in milliseconds for bandwidth throttling,
246
-     * which is the minimum response time for each api request. You can
247
-     * change it per api method by setting `@throttle 3000` in php doc
248
-     * comment either at the method level or class level
249
-     */
250
-    public static $throttle = 0;
251
-
252
-    // ==================================================================
253
-    //
254
-    // Overrides for API User
255
-    //
256
-    // ------------------------------------------------------------------
257
-
258
-    /**
259
-     * @var array use 'alternativeName'=> 'actualName' to set alternative
260
-     * names that can be used to represent the api method parameters and/or
261
-     * static properties of Defaults
262
-     */
263
-    public static $aliases = array(
264
-        /**
265
-         * suppress_response_codes=true as an URL parameter to force
266
-         * a HTTP 200 status code on all responses
267
-         */
268
-        'suppress_response_codes' => 'suppressResponseCode',
269
-    );
270
-
271
-    /**
272
-     * @var array determines the defaults that can be overridden by the api
273
-     * user by passing them as URL parameters
274
-     */
275
-    public static $overridables = array(
276
-        'suppressResponseCode',
277
-    );
278
-
279
-    /**
280
-     * @var array contains validation details for defaults to be used when
281
-     * set through URL parameters
282
-     */
283
-    public static $validation = array(
284
-        'suppressResponseCode' => array('type' => 'bool'),
285
-        'headerExpires' => array('type' => 'int', 'min' => 0),
286
-    );
287
-
288
-    // ==================================================================
289
-    //
290
-    // Overrides API Developer
291
-    //
292
-    // ------------------------------------------------------------------
293
-
294
-    /**
295
-     * @var array determines what are the phpdoc comment tags that will
296
-     * override the Defaults here with their values
297
-     */
298
-    public static $fromComments = array(
299
-
300
-        /**
301
-         * use PHPDoc comments such as the following
302
-         * `
303
-         *
304
-         * @cache no-cache, must-revalidate` to set the Cache-Control header
305
-         *        for a specific api method
306
-         */
307
-        'cache' => 'headerCacheControl',
308
-
309
-        /**
310
-         * use PHPDoc comments such as the following
311
-         * `
312
-         *
313
-         * @expires 50` to set the Expires header
314
-         *          for a specific api method
315
-         */
316
-        'expires' => 'headerExpires',
317
-
318
-        /**
319
-         * use PHPDoc comments such as the following
320
-         * `
321
-         *
322
-         * @throttle 300`
323
-         *           to set the bandwidth throttling for 300 milliseconds
324
-         *           for a specific api method
325
-         */
326
-        'throttle' => 'throttle',
327
-
328
-        /**
329
-         * enable or disable smart auto routing from method comments
330
-         * this one is hardwired so cant be turned off
331
-         * it is placed here just for documentation purpose
332
-         */
333
-        'smart-auto-routing' => 'smartAutoRouting',
334
-    );
335
-
336
-    // ==================================================================
337
-    //
338
-    // Util
339
-    //
340
-    // ------------------------------------------------------------------
341
-
342
-    /**
343
-     * Use this method to set value to a static properly of Defaults when
344
-     * you want to make sure only proper values are taken in with the help of
345
-     * validation
346
-     *
347
-     * @static
348
-     *
349
-     * @param string $name  name of the static property
350
-     * @param mixed  $value value to set the property to
351
-     *
352
-     * @return bool
353
-     */
354
-    public static function setProperty($name, $value)
355
-    {
356
-        if (!property_exists(__CLASS__, $name)) return false;
357
-        if (@is_array(Defaults::$validation[$name])) {
358
-            $info = new ValidationInfo(Defaults::$validation[$name]);
359
-            $value = Validator::validate($value, $info);
360
-        }
361
-        Defaults::$$name = $value;
362
-        return true;
363
-    }
202
+		'max-age={expires}, must-revalidate',
203
+
204
+	);
205
+
206
+
207
+	/**
208
+	 * @var int sets the content to expire immediately when set to zero
209
+	 * alternatively you can specify the number of seconds the content will
210
+	 * expire. This setting can be altered at api level using php doc comment
211
+	 * with @expires numOfSeconds
212
+	 */
213
+	public static $headerExpires = 0;
214
+
215
+	// ==================================================================
216
+	//
217
+	// Access Control
218
+	//
219
+	// ------------------------------------------------------------------
220
+
221
+	/**
222
+	 * @var null|callable if the api methods are under access control mechanism
223
+	 * you can attach a function here that returns true or false to determine
224
+	 * visibility of a protected api method. this function will receive method
225
+	 * info as the only parameter.
226
+	 */
227
+	public static $accessControlFunction = null;
228
+
229
+	/**
230
+	 * @var int set the default api access mode
231
+	 *      value of 0 = public api
232
+	 *      value of 1 = hybrid api using `@access hybrid` comment
233
+	 *      value of 2 = protected api using `@access protected` comment
234
+	 *      value of 3 = protected api using `protected function` method
235
+	 */
236
+	public static $apiAccessLevel = 0;
237
+
238
+	/**
239
+	 * @var string authentication method to be called in iAuthenticate
240
+	 * Interface
241
+	 */
242
+	public static $authenticationMethod = '__isAllowed';
243
+
244
+	/**
245
+	 * @var int time in milliseconds for bandwidth throttling,
246
+	 * which is the minimum response time for each api request. You can
247
+	 * change it per api method by setting `@throttle 3000` in php doc
248
+	 * comment either at the method level or class level
249
+	 */
250
+	public static $throttle = 0;
251
+
252
+	// ==================================================================
253
+	//
254
+	// Overrides for API User
255
+	//
256
+	// ------------------------------------------------------------------
257
+
258
+	/**
259
+	 * @var array use 'alternativeName'=> 'actualName' to set alternative
260
+	 * names that can be used to represent the api method parameters and/or
261
+	 * static properties of Defaults
262
+	 */
263
+	public static $aliases = array(
264
+		/**
265
+		 * suppress_response_codes=true as an URL parameter to force
266
+		 * a HTTP 200 status code on all responses
267
+		 */
268
+		'suppress_response_codes' => 'suppressResponseCode',
269
+	);
270
+
271
+	/**
272
+	 * @var array determines the defaults that can be overridden by the api
273
+	 * user by passing them as URL parameters
274
+	 */
275
+	public static $overridables = array(
276
+		'suppressResponseCode',
277
+	);
278
+
279
+	/**
280
+	 * @var array contains validation details for defaults to be used when
281
+	 * set through URL parameters
282
+	 */
283
+	public static $validation = array(
284
+		'suppressResponseCode' => array('type' => 'bool'),
285
+		'headerExpires' => array('type' => 'int', 'min' => 0),
286
+	);
287
+
288
+	// ==================================================================
289
+	//
290
+	// Overrides API Developer
291
+	//
292
+	// ------------------------------------------------------------------
293
+
294
+	/**
295
+	 * @var array determines what are the phpdoc comment tags that will
296
+	 * override the Defaults here with their values
297
+	 */
298
+	public static $fromComments = array(
299
+
300
+		/**
301
+		 * use PHPDoc comments such as the following
302
+		 * `
303
+		 *
304
+		 * @cache no-cache, must-revalidate` to set the Cache-Control header
305
+		 *        for a specific api method
306
+		 */
307
+		'cache' => 'headerCacheControl',
308
+
309
+		/**
310
+		 * use PHPDoc comments such as the following
311
+		 * `
312
+		 *
313
+		 * @expires 50` to set the Expires header
314
+		 *          for a specific api method
315
+		 */
316
+		'expires' => 'headerExpires',
317
+
318
+		/**
319
+		 * use PHPDoc comments such as the following
320
+		 * `
321
+		 *
322
+		 * @throttle 300`
323
+		 *           to set the bandwidth throttling for 300 milliseconds
324
+		 *           for a specific api method
325
+		 */
326
+		'throttle' => 'throttle',
327
+
328
+		/**
329
+		 * enable or disable smart auto routing from method comments
330
+		 * this one is hardwired so cant be turned off
331
+		 * it is placed here just for documentation purpose
332
+		 */
333
+		'smart-auto-routing' => 'smartAutoRouting',
334
+	);
335
+
336
+	// ==================================================================
337
+	//
338
+	// Util
339
+	//
340
+	// ------------------------------------------------------------------
341
+
342
+	/**
343
+	 * Use this method to set value to a static properly of Defaults when
344
+	 * you want to make sure only proper values are taken in with the help of
345
+	 * validation
346
+	 *
347
+	 * @static
348
+	 *
349
+	 * @param string $name  name of the static property
350
+	 * @param mixed  $value value to set the property to
351
+	 *
352
+	 * @return bool
353
+	 */
354
+	public static function setProperty($name, $value)
355
+	{
356
+		if (!property_exists(__CLASS__, $name)) return false;
357
+		if (@is_array(Defaults::$validation[$name])) {
358
+			$info = new ValidationInfo(Defaults::$validation[$name]);
359
+			$value = Validator::validate($value, $info);
360
+		}
361
+		Defaults::$$name = $value;
362
+		return true;
363
+	}
364 364
 
365 365
 }
366 366
 
Please login to merge, or discard this patch.
htdocs/includes/restler/framework/Luracast/Restler/ApcCache.php 1 patch
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -17,98 +17,98 @@
 block discarded – undo
17 17
  */
18 18
 class ApcCache implements iCache
19 19
 {
20
-    /**
21
-     * The namespace that all of the cached entries will be stored under.  This allows multiple APIs to run concurrently.
22
-     *
23
-     * @var string
24
-     */
25
-    static public $namespace = 'restler';
20
+	/**
21
+	 * The namespace that all of the cached entries will be stored under.  This allows multiple APIs to run concurrently.
22
+	 *
23
+	 * @var string
24
+	 */
25
+	static public $namespace = 'restler';
26 26
 
27
-    /**
28
-     * store data in the cache
29
-     *
30
-     *
31
-     * @param string $name
32
-     * @param mixed $data
33
-     *
34
-     * @return boolean true if successful
35
-     */
36
-    public function set($name, $data)
37
-    {
38
-        function_exists('apc_store') || $this->apcNotAvailable();
27
+	/**
28
+	 * store data in the cache
29
+	 *
30
+	 *
31
+	 * @param string $name
32
+	 * @param mixed $data
33
+	 *
34
+	 * @return boolean true if successful
35
+	 */
36
+	public function set($name, $data)
37
+	{
38
+		function_exists('apc_store') || $this->apcNotAvailable();
39 39
 
40
-        try {
41
-            return apc_store(self::$namespace . "-" . $name, $data);
42
-        } catch
43
-        (\Exception $exception) {
44
-            return false;
45
-        }
46
-    }
40
+		try {
41
+			return apc_store(self::$namespace . "-" . $name, $data);
42
+		} catch
43
+		(\Exception $exception) {
44
+			return false;
45
+		}
46
+	}
47 47
 
48
-    private function apcNotAvailable()
49
-    {
50
-        throw new \Exception('APC is not available for use as Restler Cache. Please make sure the module is installed. http://php.net/manual/en/apc.installation.php');
51
-    }
48
+	private function apcNotAvailable()
49
+	{
50
+		throw new \Exception('APC is not available for use as Restler Cache. Please make sure the module is installed. http://php.net/manual/en/apc.installation.php');
51
+	}
52 52
 
53
-    /**
54
-     * retrieve data from the cache
55
-     *
56
-     *
57
-     * @param string $name
58
-     * @param bool $ignoreErrors
59
-     *
60
-     * @throws \Exception
61
-     * @return mixed
62
-     */
63
-    public function get($name, $ignoreErrors = false)
64
-    {
65
-        function_exists('apc_fetch') || $this->apcNotAvailable();
53
+	/**
54
+	 * retrieve data from the cache
55
+	 *
56
+	 *
57
+	 * @param string $name
58
+	 * @param bool $ignoreErrors
59
+	 *
60
+	 * @throws \Exception
61
+	 * @return mixed
62
+	 */
63
+	public function get($name, $ignoreErrors = false)
64
+	{
65
+		function_exists('apc_fetch') || $this->apcNotAvailable();
66 66
 
67
-        try {
68
-            return apc_fetch(self::$namespace . "-" . $name);
69
-        } catch (\Exception $exception) {
70
-            if (!$ignoreErrors) {
71
-                throw $exception;
72
-            }
73
-            return null;
74
-        }
75
-    }
67
+		try {
68
+			return apc_fetch(self::$namespace . "-" . $name);
69
+		} catch (\Exception $exception) {
70
+			if (!$ignoreErrors) {
71
+				throw $exception;
72
+			}
73
+			return null;
74
+		}
75
+	}
76 76
 
77
-    /**
78
-     * delete data from the cache
79
-     *
80
-     *
81
-     * @param string $name
82
-     * @param bool $ignoreErrors
83
-     *
84
-     * @throws \Exception
85
-     * @return boolean true if successful
86
-     */
87
-    public function clear($name, $ignoreErrors = false)
88
-    {
89
-        function_exists('apc_delete') || $this->apcNotAvailable();
77
+	/**
78
+	 * delete data from the cache
79
+	 *
80
+	 *
81
+	 * @param string $name
82
+	 * @param bool $ignoreErrors
83
+	 *
84
+	 * @throws \Exception
85
+	 * @return boolean true if successful
86
+	 */
87
+	public function clear($name, $ignoreErrors = false)
88
+	{
89
+		function_exists('apc_delete') || $this->apcNotAvailable();
90 90
 
91
-        try {
92
-            apc_delete(self::$namespace . "-" . $name);
93
-        } catch (\Exception $exception) {
94
-            if (!$ignoreErrors) {
95
-                throw $exception;
96
-            }
97
-        }
98
-    }
91
+		try {
92
+			apc_delete(self::$namespace . "-" . $name);
93
+		} catch (\Exception $exception) {
94
+			if (!$ignoreErrors) {
95
+				throw $exception;
96
+			}
97
+		}
98
+	}
99 99
 
100
-    /**
101
-     * check if the given name is cached
102
-     *
103
-     *
104
-     * @param string $name
105
-     *
106
-     * @return boolean true if cached
107
-     */
108
-    public function isCached($name)
109
-    {
110
-        function_exists('apc_exists') || $this->apcNotAvailable();
111
-        return apc_exists(self::$namespace . "-" . $name);
112
-    }
100
+	/**
101
+	 * check if the given name is cached
102
+	 *
103
+	 *
104
+	 * @param string $name
105
+	 *
106
+	 * @return boolean true if cached
107
+	 */
108
+	public function isCached($name)
109
+	{
110
+		function_exists('apc_exists') || $this->apcNotAvailable();
111
+		return apc_exists(self::$namespace . "-" . $name);
112
+	}
113 113
 
114 114
 }
115 115
\ No newline at end of file
Please login to merge, or discard this patch.
htdocs/includes/restler/framework/Luracast/Restler/Util.php 1 patch
Indentation   +224 added lines, -224 removed lines patch added patch discarded remove patch
@@ -15,238 +15,238 @@
 block discarded – undo
15 15
  */
16 16
 class Util
17 17
 {
18
-    /**
19
-     * @var Restler instance injected at runtime
20
-     */
21
-    public static $restler;
18
+	/**
19
+	 * @var Restler instance injected at runtime
20
+	 */
21
+	public static $restler;
22 22
 
23
-    /**
24
-     * verify if the given data type string is scalar or not
25
-     *
26
-     * @static
27
-     *
28
-     * @param string $type data type as string
29
-     *
30
-     * @return bool true or false
31
-     */
32
-    public static function isObjectOrArray($type)
33
-    {
34
-        if (is_array($type)) {
35
-            foreach ($type as $t) {
36
-                if (static::isObjectOrArray($t)) {
37
-                    return true;
38
-                }
39
-            }
40
-            return false;
41
-        }
42
-        return !(boolean)strpos('|bool|boolean|int|float|string|', $type);
43
-    }
23
+	/**
24
+	 * verify if the given data type string is scalar or not
25
+	 *
26
+	 * @static
27
+	 *
28
+	 * @param string $type data type as string
29
+	 *
30
+	 * @return bool true or false
31
+	 */
32
+	public static function isObjectOrArray($type)
33
+	{
34
+		if (is_array($type)) {
35
+			foreach ($type as $t) {
36
+				if (static::isObjectOrArray($t)) {
37
+					return true;
38
+				}
39
+			}
40
+			return false;
41
+		}
42
+		return !(boolean)strpos('|bool|boolean|int|float|string|', $type);
43
+	}
44 44
 
45
-    /**
46
-     * Get the value deeply nested inside an array / object
47
-     *
48
-     * Using isset() to test the presence of nested value can give a false positive
49
-     *
50
-     * This method serves that need
51
-     *
52
-     * When the deeply nested property is found its value is returned, otherwise
53
-     * false is returned.
54
-     *
55
-     * @param array|object $from    array to extract the value from
56
-     * @param string|array $key     ... pass more to go deeply inside the array
57
-     *                              alternatively you can pass a single array
58
-     *
59
-     * @return null|mixed null when not found, value otherwise
60
-     */
61
-    public static function nestedValue($from, $key/**, $key2 ... $key`n` */)
62
-    {
63
-        if (is_array($key)) {
64
-            $keys = $key;
65
-        } else {
66
-            $keys = func_get_args();
67
-            array_shift($keys);
68
-        }
69
-        foreach ($keys as $key) {
70
-            if (is_array($from) && isset($from[$key])) {
71
-                $from = $from[$key];
72
-                continue;
73
-            } elseif (is_object($from) && isset($from->{$key})) {
74
-                $from = $from->{$key};
75
-                continue;
76
-            }
77
-            return null;
78
-        }
79
-        return $from;
80
-    }
45
+	/**
46
+	 * Get the value deeply nested inside an array / object
47
+	 *
48
+	 * Using isset() to test the presence of nested value can give a false positive
49
+	 *
50
+	 * This method serves that need
51
+	 *
52
+	 * When the deeply nested property is found its value is returned, otherwise
53
+	 * false is returned.
54
+	 *
55
+	 * @param array|object $from    array to extract the value from
56
+	 * @param string|array $key     ... pass more to go deeply inside the array
57
+	 *                              alternatively you can pass a single array
58
+	 *
59
+	 * @return null|mixed null when not found, value otherwise
60
+	 */
61
+	public static function nestedValue($from, $key/**, $key2 ... $key`n` */)
62
+	{
63
+		if (is_array($key)) {
64
+			$keys = $key;
65
+		} else {
66
+			$keys = func_get_args();
67
+			array_shift($keys);
68
+		}
69
+		foreach ($keys as $key) {
70
+			if (is_array($from) && isset($from[$key])) {
71
+				$from = $from[$key];
72
+				continue;
73
+			} elseif (is_object($from) && isset($from->{$key})) {
74
+				$from = $from->{$key};
75
+				continue;
76
+			}
77
+			return null;
78
+		}
79
+		return $from;
80
+	}
81 81
 
82
-    public static function getResourcePath(
83
-        $className,
84
-        $resourcePath = null,
85
-        $prefix = ''
86
-    ) {
87
-        if (is_null($resourcePath)) {
88
-            if (Defaults::$autoRoutingEnabled) {
89
-                $resourcePath = strtolower($className);
90
-                if (false !== ($index = strrpos($className, '\\'))) {
91
-                    $resourcePath = substr($resourcePath, $index + 1);
92
-                }
93
-                if (false !== ($index = strrpos($resourcePath, '_'))) {
94
-                    $resourcePath = substr($resourcePath, $index + 1);
95
-                }
96
-            } else {
97
-                $resourcePath = '';
98
-            }
99
-        } else {
100
-            $resourcePath = trim($resourcePath, '/');
101
-        }
102
-        if (strlen($resourcePath) > 0) {
103
-            $resourcePath .= '/';
104
-        }
105
-        return $prefix . $resourcePath;
106
-    }
82
+	public static function getResourcePath(
83
+		$className,
84
+		$resourcePath = null,
85
+		$prefix = ''
86
+	) {
87
+		if (is_null($resourcePath)) {
88
+			if (Defaults::$autoRoutingEnabled) {
89
+				$resourcePath = strtolower($className);
90
+				if (false !== ($index = strrpos($className, '\\'))) {
91
+					$resourcePath = substr($resourcePath, $index + 1);
92
+				}
93
+				if (false !== ($index = strrpos($resourcePath, '_'))) {
94
+					$resourcePath = substr($resourcePath, $index + 1);
95
+				}
96
+			} else {
97
+				$resourcePath = '';
98
+			}
99
+		} else {
100
+			$resourcePath = trim($resourcePath, '/');
101
+		}
102
+		if (strlen($resourcePath) > 0) {
103
+			$resourcePath .= '/';
104
+		}
105
+		return $prefix . $resourcePath;
106
+	}
107 107
 
108
-    /**
109
-     * Compare two strings and remove the common
110
-     * sub string from the first string and return it
111
-     *
112
-     * @static
113
-     *
114
-     * @param string $fromPath
115
-     * @param string $usingPath
116
-     * @param string $char
117
-     *            optional, set it as
118
-     *            blank string for char by char comparison
119
-     *
120
-     * @return string
121
-     */
122
-    public static function removeCommonPath($fromPath, $usingPath, $char = '/')
123
-    {
124
-        if (empty($fromPath)) {
125
-            return '';
126
-        }
127
-        $fromPath = explode($char, $fromPath);
128
-        $usingPath = explode($char, $usingPath);
129
-        while (count($usingPath)) {
130
-            if (count($fromPath) && $fromPath[0] == $usingPath[0]) {
131
-                array_shift($fromPath);
132
-            } else {
133
-                break;
134
-            }
135
-            array_shift($usingPath);
136
-        }
137
-        return implode($char, $fromPath);
138
-    }
108
+	/**
109
+	 * Compare two strings and remove the common
110
+	 * sub string from the first string and return it
111
+	 *
112
+	 * @static
113
+	 *
114
+	 * @param string $fromPath
115
+	 * @param string $usingPath
116
+	 * @param string $char
117
+	 *            optional, set it as
118
+	 *            blank string for char by char comparison
119
+	 *
120
+	 * @return string
121
+	 */
122
+	public static function removeCommonPath($fromPath, $usingPath, $char = '/')
123
+	{
124
+		if (empty($fromPath)) {
125
+			return '';
126
+		}
127
+		$fromPath = explode($char, $fromPath);
128
+		$usingPath = explode($char, $usingPath);
129
+		while (count($usingPath)) {
130
+			if (count($fromPath) && $fromPath[0] == $usingPath[0]) {
131
+				array_shift($fromPath);
132
+			} else {
133
+				break;
134
+			}
135
+			array_shift($usingPath);
136
+		}
137
+		return implode($char, $fromPath);
138
+	}
139 139
 
140
-    /**
141
-     * Compare two strings and split the common
142
-     * sub string from the first string and return it as array
143
-     *
144
-     * @static
145
-     *
146
-     * @param string $fromPath
147
-     * @param string $usingPath
148
-     * @param string $char
149
-     *            optional, set it as
150
-     *            blank string for char by char comparison
151
-     *
152
-     * @return array with 2 strings first is the common string and second is the remaining in $fromPath
153
-     */
154
-    public static function splitCommonPath($fromPath, $usingPath, $char = '/')
155
-    {
156
-        if (empty($fromPath)) {
157
-            return array('', '');
158
-        }
159
-        $fromPath = explode($char, $fromPath);
160
-        $usingPath = explode($char, $usingPath);
161
-        $commonPath = array();
162
-        while (count($usingPath)) {
163
-            if (count($fromPath) && $fromPath[0] == $usingPath[0]) {
164
-                $commonPath [] = array_shift($fromPath);
165
-            } else {
166
-                break;
167
-            }
168
-            array_shift($usingPath);
169
-        }
170
-        return array(implode($char, $commonPath), implode($char, $fromPath));
171
-    }
140
+	/**
141
+	 * Compare two strings and split the common
142
+	 * sub string from the first string and return it as array
143
+	 *
144
+	 * @static
145
+	 *
146
+	 * @param string $fromPath
147
+	 * @param string $usingPath
148
+	 * @param string $char
149
+	 *            optional, set it as
150
+	 *            blank string for char by char comparison
151
+	 *
152
+	 * @return array with 2 strings first is the common string and second is the remaining in $fromPath
153
+	 */
154
+	public static function splitCommonPath($fromPath, $usingPath, $char = '/')
155
+	{
156
+		if (empty($fromPath)) {
157
+			return array('', '');
158
+		}
159
+		$fromPath = explode($char, $fromPath);
160
+		$usingPath = explode($char, $usingPath);
161
+		$commonPath = array();
162
+		while (count($usingPath)) {
163
+			if (count($fromPath) && $fromPath[0] == $usingPath[0]) {
164
+				$commonPath [] = array_shift($fromPath);
165
+			} else {
166
+				break;
167
+			}
168
+			array_shift($usingPath);
169
+		}
170
+		return array(implode($char, $commonPath), implode($char, $fromPath));
171
+	}
172 172
 
173
-    /**
174
-     * Parses the request to figure out the http request type
175
-     *
176
-     * @static
177
-     *
178
-     * @return string which will be one of the following
179
-     *        [GET, POST, PUT, PATCH, DELETE]
180
-     * @example GET
181
-     */
182
-    public static function getRequestMethod()
183
-    {
184
-        $method = $_SERVER['REQUEST_METHOD'];
185
-        if (isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) {
186
-            $method = $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'];
187
-        } elseif (
188
-            !empty(Defaults::$httpMethodOverrideProperty)
189
-            && isset($_REQUEST[Defaults::$httpMethodOverrideProperty])
190
-        ) {
191
-            // support for exceptional clients who can't set the header
192
-            $m = strtoupper($_REQUEST[Defaults::$httpMethodOverrideProperty]);
193
-            if ($m == 'PUT' || $m == 'DELETE' ||
194
-                $m == 'POST' || $m == 'PATCH'
195
-            ) {
196
-                $method = $m;
197
-            }
198
-        }
199
-        // support for HEAD request
200
-        if ($method == 'HEAD') {
201
-            $method = 'GET';
202
-        }
203
-        return $method;
204
-    }
173
+	/**
174
+	 * Parses the request to figure out the http request type
175
+	 *
176
+	 * @static
177
+	 *
178
+	 * @return string which will be one of the following
179
+	 *        [GET, POST, PUT, PATCH, DELETE]
180
+	 * @example GET
181
+	 */
182
+	public static function getRequestMethod()
183
+	{
184
+		$method = $_SERVER['REQUEST_METHOD'];
185
+		if (isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) {
186
+			$method = $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'];
187
+		} elseif (
188
+			!empty(Defaults::$httpMethodOverrideProperty)
189
+			&& isset($_REQUEST[Defaults::$httpMethodOverrideProperty])
190
+		) {
191
+			// support for exceptional clients who can't set the header
192
+			$m = strtoupper($_REQUEST[Defaults::$httpMethodOverrideProperty]);
193
+			if ($m == 'PUT' || $m == 'DELETE' ||
194
+				$m == 'POST' || $m == 'PATCH'
195
+			) {
196
+				$method = $m;
197
+			}
198
+		}
199
+		// support for HEAD request
200
+		if ($method == 'HEAD') {
201
+			$method = 'GET';
202
+		}
203
+		return $method;
204
+	}
205 205
 
206
-    /**
207
-     * Pass any content negotiation header such as Accept,
208
-     * Accept-Language to break it up and sort the resulting array by
209
-     * the order of negotiation.
210
-     *
211
-     * @static
212
-     *
213
-     * @param string $accept header value
214
-     *
215
-     * @return array sorted by the priority
216
-     */
217
-    public static function sortByPriority($accept)
218
-    {
219
-        $acceptList = array();
220
-        $accepts = explode(',', strtolower($accept));
221
-        if (!is_array($accepts)) {
222
-            $accepts = array($accepts);
223
-        }
224
-        foreach ($accepts as $pos => $accept) {
225
-            $parts = explode(';', $accept);
226
-            $type = trim(array_shift($parts));
227
-            $parameters = [];
228
-            foreach ($parts as $part) {
229
-                $part = explode('=', $part);
230
-                if (2 !== count($part)) {
231
-                    continue;
232
-                }
233
-                $key = strtolower(trim($part[0]));
234
-                $parameters[$key] = trim($part[1], ' "');
235
-            }
236
-            $quality = isset($parameters['q']) ? (float)$parameters['q'] : (1000 - $pos) / 1000;
237
-            $acceptList[$type] = $quality;
238
-        }
239
-        arsort($acceptList);
240
-        return $acceptList;
241
-    }
206
+	/**
207
+	 * Pass any content negotiation header such as Accept,
208
+	 * Accept-Language to break it up and sort the resulting array by
209
+	 * the order of negotiation.
210
+	 *
211
+	 * @static
212
+	 *
213
+	 * @param string $accept header value
214
+	 *
215
+	 * @return array sorted by the priority
216
+	 */
217
+	public static function sortByPriority($accept)
218
+	{
219
+		$acceptList = array();
220
+		$accepts = explode(',', strtolower($accept));
221
+		if (!is_array($accepts)) {
222
+			$accepts = array($accepts);
223
+		}
224
+		foreach ($accepts as $pos => $accept) {
225
+			$parts = explode(';', $accept);
226
+			$type = trim(array_shift($parts));
227
+			$parameters = [];
228
+			foreach ($parts as $part) {
229
+				$part = explode('=', $part);
230
+				if (2 !== count($part)) {
231
+					continue;
232
+				}
233
+				$key = strtolower(trim($part[0]));
234
+				$parameters[$key] = trim($part[1], ' "');
235
+			}
236
+			$quality = isset($parameters['q']) ? (float)$parameters['q'] : (1000 - $pos) / 1000;
237
+			$acceptList[$type] = $quality;
238
+		}
239
+		arsort($acceptList);
240
+		return $acceptList;
241
+	}
242 242
 
243
-    public static function getShortName($className)
244
-    {
245
-    	// @CHANGE LDR
246
-    	if (!is_string($className)) return;
243
+	public static function getShortName($className)
244
+	{
245
+		// @CHANGE LDR
246
+		if (!is_string($className)) return;
247 247
     	
248
-    	$className = explode('\\', $className);
249
-        return end($className);
250
-    }
248
+		$className = explode('\\', $className);
249
+		return end($className);
250
+	}
251 251
 }
252 252
 
Please login to merge, or discard this patch.
htdocs/includes/restler/framework/Luracast/Restler/UI/Tags.php 1 patch
Indentation   +225 added lines, -225 removed lines patch added patch discarded remove patch
@@ -34,249 +34,249 @@
 block discarded – undo
34 34
  */
35 35
 class Tags implements ArrayAccess, Countable
36 36
 {
37
-    public static $humanReadable = true;
38
-    public static $initializer = null;
39
-    protected static $instances = array();
40
-    public $prefix = '';
41
-    public $indent = '    ';
42
-    public $tag;
43
-    protected $attributes = array();
44
-    protected $children = array();
45
-    protected $_parent;
37
+	public static $humanReadable = true;
38
+	public static $initializer = null;
39
+	protected static $instances = array();
40
+	public $prefix = '';
41
+	public $indent = '    ';
42
+	public $tag;
43
+	protected $attributes = array();
44
+	protected $children = array();
45
+	protected $_parent;
46 46
 
47
-    public function __construct($name = null, array $children = array())
48
-    {
49
-        $this->tag = $name;
50
-        $c = array();
51
-        foreach ($children as $child) {
52
-            is_array($child)
53
-                ? $c = array_merge($c, $child)
54
-                : $c [] = $child;
55
-        }
56
-        $this->markAsChildren($c);
57
-        $this->children = $c;
58
-        if (static::$initializer)
59
-            call_user_func_array(static::$initializer, array(& $this));
60
-    }
47
+	public function __construct($name = null, array $children = array())
48
+	{
49
+		$this->tag = $name;
50
+		$c = array();
51
+		foreach ($children as $child) {
52
+			is_array($child)
53
+				? $c = array_merge($c, $child)
54
+				: $c [] = $child;
55
+		}
56
+		$this->markAsChildren($c);
57
+		$this->children = $c;
58
+		if (static::$initializer)
59
+			call_user_func_array(static::$initializer, array(& $this));
60
+	}
61 61
 
62
-    /**
63
-     * Get Tag by id
64
-     *
65
-     * Retrieve a tag by its id attribute
66
-     *
67
-     * @param string $id
68
-     *
69
-     * @return Tags|null
70
-     */
71
-    public static function byId($id)
72
-    {
73
-        return Util::nestedValue(static::$instances, $id);
74
-    }
62
+	/**
63
+	 * Get Tag by id
64
+	 *
65
+	 * Retrieve a tag by its id attribute
66
+	 *
67
+	 * @param string $id
68
+	 *
69
+	 * @return Tags|null
70
+	 */
71
+	public static function byId($id)
72
+	{
73
+		return Util::nestedValue(static::$instances, $id);
74
+	}
75 75
 
76
-    /**
77
-     * @param       $name
78
-     * @param array $children
79
-     *
80
-     * @return Tags
81
-     */
82
-    public static function __callStatic($name, array $children)
83
-    {
84
-        return new static($name, $children);
85
-    }
76
+	/**
77
+	 * @param       $name
78
+	 * @param array $children
79
+	 *
80
+	 * @return Tags
81
+	 */
82
+	public static function __callStatic($name, array $children)
83
+	{
84
+		return new static($name, $children);
85
+	}
86 86
 
87
-    public function toString($prefix = '', $indent = '    ')
88
-    {
89
-        $this->prefix = $prefix;
90
-        $this->indent = $indent;
91
-        return $this->__toString();
92
-    }
87
+	public function toString($prefix = '', $indent = '    ')
88
+	{
89
+		$this->prefix = $prefix;
90
+		$this->indent = $indent;
91
+		return $this->__toString();
92
+	}
93 93
 
94
-    public function __toString()
95
-    {
96
-        $children = '';
97
-        if (static::$humanReadable) {
98
-            $lineBreak = false;
99
-            foreach ($this->children as $key => $child) {
100
-                $prefix = $this->prefix;
101
-                if (!is_null($this->tag))
102
-                    $prefix .= $this->indent;
103
-                if ($child instanceof $this) {
104
-                    $child->prefix = $prefix;
105
-                    $child->indent = $this->indent;
106
-                    $children .= PHP_EOL . $child;
107
-                    $lineBreak = true;
108
-                } else {
109
-                    $children .= $child;
110
-                }
111
-            }
112
-            if ($lineBreak)
113
-                $children .= PHP_EOL . $this->prefix;
114
-        } else {
115
-            $children = implode('', $this->children);
116
-        }
117
-        if (is_null($this->tag))
118
-            return $children;
119
-        $attributes = '';
120
-        foreach ($this->attributes as $attribute => &$value)
121
-            $attributes .= " $attribute=\"$value\"";
94
+	public function __toString()
95
+	{
96
+		$children = '';
97
+		if (static::$humanReadable) {
98
+			$lineBreak = false;
99
+			foreach ($this->children as $key => $child) {
100
+				$prefix = $this->prefix;
101
+				if (!is_null($this->tag))
102
+					$prefix .= $this->indent;
103
+				if ($child instanceof $this) {
104
+					$child->prefix = $prefix;
105
+					$child->indent = $this->indent;
106
+					$children .= PHP_EOL . $child;
107
+					$lineBreak = true;
108
+				} else {
109
+					$children .= $child;
110
+				}
111
+			}
112
+			if ($lineBreak)
113
+				$children .= PHP_EOL . $this->prefix;
114
+		} else {
115
+			$children = implode('', $this->children);
116
+		}
117
+		if (is_null($this->tag))
118
+			return $children;
119
+		$attributes = '';
120
+		foreach ($this->attributes as $attribute => &$value)
121
+			$attributes .= " $attribute=\"$value\"";
122 122
 
123
-        if (count($this->children))
124
-            return static::$humanReadable
125
-                ? "$this->prefix<{$this->tag}{$attributes}>"
126
-                . "$children"
127
-                . "</{$this->tag}>"
128
-                : "<{$this->tag}{$attributes}>$children</{$this->tag}>";
123
+		if (count($this->children))
124
+			return static::$humanReadable
125
+				? "$this->prefix<{$this->tag}{$attributes}>"
126
+				. "$children"
127
+				. "</{$this->tag}>"
128
+				: "<{$this->tag}{$attributes}>$children</{$this->tag}>";
129 129
 
130
-        return "$this->prefix<{$this->tag}{$attributes}/>";
131
-    }
130
+		return "$this->prefix<{$this->tag}{$attributes}/>";
131
+	}
132 132
 
133
-    public function toArray()
134
-    {
135
-        $r = array();
136
-        $r['attributes'] = $this->attributes;
137
-        $r['tag'] = $this->tag;
138
-        $children = array();
139
-        foreach ($this->children as $key => $child) {
140
-            $children[$key] = $child instanceof $this
141
-                ? $child->toArray()
142
-                : $child;
143
-        }
144
-        $r['children'] = $children;
145
-        return $r;
146
-    }
133
+	public function toArray()
134
+	{
135
+		$r = array();
136
+		$r['attributes'] = $this->attributes;
137
+		$r['tag'] = $this->tag;
138
+		$children = array();
139
+		foreach ($this->children as $key => $child) {
140
+			$children[$key] = $child instanceof $this
141
+				? $child->toArray()
142
+				: $child;
143
+		}
144
+		$r['children'] = $children;
145
+		return $r;
146
+	}
147 147
 
148
-    /**
149
-     * Set the id attribute of the current tag
150
-     *
151
-     * @param string $value
152
-     *
153
-     * @return string
154
-     */
155
-    public function id($value)
156
-    {
157
-        if (!empty($value) && is_string($value)) {
158
-            $this->attributes['id'] = $value;
159
-            static::$instances[$value] = $this;
160
-        }
161
-        return $this;
162
-    }
148
+	/**
149
+	 * Set the id attribute of the current tag
150
+	 *
151
+	 * @param string $value
152
+	 *
153
+	 * @return string
154
+	 */
155
+	public function id($value)
156
+	{
157
+		if (!empty($value) && is_string($value)) {
158
+			$this->attributes['id'] = $value;
159
+			static::$instances[$value] = $this;
160
+		}
161
+		return $this;
162
+	}
163 163
 
164
-    public function __get($name)
165
-    {
166
-        if ('parent' == $name)
167
-            return $this->_parent;
168
-        if (isset($this->attributes[$name]))
169
-            return $this->attributes[$name];
170
-        return;
171
-    }
164
+	public function __get($name)
165
+	{
166
+		if ('parent' == $name)
167
+			return $this->_parent;
168
+		if (isset($this->attributes[$name]))
169
+			return $this->attributes[$name];
170
+		return;
171
+	}
172 172
 
173
-    public function __set($name, $value)
174
-    {
175
-        if ('parent' == $name) {
176
-            if ($this->_parent) {
177
-                unset($this->_parent[array_search($this, $this->_parent->children)]);
178
-            }
179
-            if (!empty($value)) {
180
-                $value[] = $this;
181
-            }
182
-        }
183
-    }
173
+	public function __set($name, $value)
174
+	{
175
+		if ('parent' == $name) {
176
+			if ($this->_parent) {
177
+				unset($this->_parent[array_search($this, $this->_parent->children)]);
178
+			}
179
+			if (!empty($value)) {
180
+				$value[] = $this;
181
+			}
182
+		}
183
+	}
184 184
 
185
-    public function __isset($name)
186
-    {
187
-        return isset($this->attributes[$name]);
188
-    }
185
+	public function __isset($name)
186
+	{
187
+		return isset($this->attributes[$name]);
188
+	}
189 189
 
190
-    /**
191
-     * @param $attribute
192
-     * @param $value
193
-     *
194
-     * @return Tags
195
-     */
196
-    public function __call($attribute, $value)
197
-    {
198
-        if (is_null($value)) {
199
-            return isset($this->attributes[$attribute])
200
-                ? $this->attributes[$attribute]
201
-                : null;
202
-        }
203
-        $value = $value[0];
204
-        if (is_null($value)) {
205
-            unset($this->attributes[$attribute]);
206
-            return $this;
207
-        }
208
-        $this->attributes[$attribute] = is_bool($value)
209
-            ? ($value ? 'true' : 'false')
210
-            : @(string)$value;
211
-        return $this;
212
-    }
190
+	/**
191
+	 * @param $attribute
192
+	 * @param $value
193
+	 *
194
+	 * @return Tags
195
+	 */
196
+	public function __call($attribute, $value)
197
+	{
198
+		if (is_null($value)) {
199
+			return isset($this->attributes[$attribute])
200
+				? $this->attributes[$attribute]
201
+				: null;
202
+		}
203
+		$value = $value[0];
204
+		if (is_null($value)) {
205
+			unset($this->attributes[$attribute]);
206
+			return $this;
207
+		}
208
+		$this->attributes[$attribute] = is_bool($value)
209
+			? ($value ? 'true' : 'false')
210
+			: @(string)$value;
211
+		return $this;
212
+	}
213 213
 
214
-    public function offsetGet($index)
215
-    {
216
-        if ($this->offsetExists($index)) {
217
-            return $this->children[$index];
218
-        }
219
-        return false;
220
-    }
214
+	public function offsetGet($index)
215
+	{
216
+		if ($this->offsetExists($index)) {
217
+			return $this->children[$index];
218
+		}
219
+		return false;
220
+	}
221 221
 
222
-    public function offsetExists($index)
223
-    {
224
-        return isset($this->children[$index]);
225
-    }
222
+	public function offsetExists($index)
223
+	{
224
+		return isset($this->children[$index]);
225
+	}
226 226
 
227
-    public function offsetSet($index, $value)
228
-    {
229
-        if ($index) {
230
-            $this->children[$index] = $value;
231
-        } elseif (is_array($value)) {
232
-            $c = array();
233
-            foreach ($value as $child) {
234
-                is_array($child)
235
-                    ? $c = array_merge($c, $child)
236
-                    : $c [] = $child;
237
-            }
238
-            $this->markAsChildren($c);
239
-            $this->children += $c;
240
-        } else {
241
-            $c = array($value);
242
-            $this->markAsChildren($c);
243
-            $this->children[] = $value;
244
-        }
245
-        return true;
246
-    }
227
+	public function offsetSet($index, $value)
228
+	{
229
+		if ($index) {
230
+			$this->children[$index] = $value;
231
+		} elseif (is_array($value)) {
232
+			$c = array();
233
+			foreach ($value as $child) {
234
+				is_array($child)
235
+					? $c = array_merge($c, $child)
236
+					: $c [] = $child;
237
+			}
238
+			$this->markAsChildren($c);
239
+			$this->children += $c;
240
+		} else {
241
+			$c = array($value);
242
+			$this->markAsChildren($c);
243
+			$this->children[] = $value;
244
+		}
245
+		return true;
246
+	}
247 247
 
248
-    public function offsetUnset($index)
249
-    {
250
-        $this->children[$index]->_parent = null;
251
-        unset($this->children[$index]);
252
-        return true;
253
-    }
248
+	public function offsetUnset($index)
249
+	{
250
+		$this->children[$index]->_parent = null;
251
+		unset($this->children[$index]);
252
+		return true;
253
+	}
254 254
 
255
-    public function getContents()
256
-    {
257
-        return $this->children;
258
-    }
255
+	public function getContents()
256
+	{
257
+		return $this->children;
258
+	}
259 259
 
260
-    public function count()
261
-    {
262
-        return count($this->children);
263
-    }
260
+	public function count()
261
+	{
262
+		return count($this->children);
263
+	}
264 264
 
265
-    private function markAsChildren(& $children)
266
-    {
267
-        foreach ($children as $i => $child) {
268
-            if (is_string($child))
269
-                continue;
270
-            if (!is_object($child)) {
271
-                unset($children[$i]);
272
-                continue;
273
-            }
274
-            //echo $child;
275
-            if (isset($child->_parent) && $child->_parent != $this) {
276
-                //remove from current parent
277
-                unset($child->_parent[array_search($child, $child->_parent->children)]);
278
-            }
279
-            $child->_parent = $this;
280
-        }
281
-    }
265
+	private function markAsChildren(& $children)
266
+	{
267
+		foreach ($children as $i => $child) {
268
+			if (is_string($child))
269
+				continue;
270
+			if (!is_object($child)) {
271
+				unset($children[$i]);
272
+				continue;
273
+			}
274
+			//echo $child;
275
+			if (isset($child->_parent) && $child->_parent != $this) {
276
+				//remove from current parent
277
+				unset($child->_parent[array_search($child, $child->_parent->children)]);
278
+			}
279
+			$child->_parent = $this;
280
+		}
281
+	}
282 282
 }
283 283
\ No newline at end of file
Please login to merge, or discard this patch.
htdocs/includes/restler/framework/Luracast/Restler/UI/FormStyles.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -14,46 +14,46 @@
 block discarded – undo
14 14
  */
15 15
 class FormStyles
16 16
 {
17
-    public static $html = array(
18
-        'form' => 'form[role=form id=$id# name=$name# method=$method# action=$action# enctype=$enctype#]',
19
-        'input' => '.row>section>label{$label#}^input[id=$id# name=$name# value=$value# type=$type# required=$required# autofocus=$autofocus# placeholder=$default# accept=$accept# disabled=$disabled#]',
20
-        'textarea' => '.row>label{$label#}^textarea[id=$id# name=$name# required=$required# autofocus=$autofocus# placeholder=$default# rows=3 disabled=$disabled#]{$value#}',
21
-        'radio' => '.row>section>label{$label#}^span>label*options>input[id=$id# name=$name# value=$value# type=radio checked=$selected# required=$required# disabled=$disabled#]+{ $text#}',
22
-        'select' => '.row>label{$label#}^select[id=$id# name=$name# required=$required#]>option[value]+option[value=$value# selected=$selected# disabled=$disabled#]{$text#}*options',
23
-        'submit' => '.row>label{ &nbsp; }^button[id=$id# type=submit disabled=$disabled#]{$label#}',
24
-        'fieldset' => 'fieldset>legend{$label#}',
25
-        'checkbox' => '.row>label>input[id=$id# name=$name# value=$value# type=checkbox checked=$selected# required=$required# autofocus=$autofocus# accept=$accept# disabled=$disabled#]+{$label#}',
26
-        //------------- TYPE BASED STYLES ---------------------//
27
-        'checkbox-array' => 'fieldset>legend{$label#}+section*options>label>input[name=$name# value=$value# type=checkbox checked=$selected# required=$required# autofocus=$autofocus# accept=$accept#]+{ $text#}',
28
-        'select-array' => 'label{$label#}+select[name=$name# required=$required# multiple style="height: auto;background-image: none; outline: inherit;"]>option[value=$value# selected=$selected#]{$text#}*options',
29
-    );
30
-    public static $bootstrap3 = array(
31
-        'form' => 'form[role=form id=$id# name=$name# method=$method# action=$action# enctype=$enctype#]',
32
-        'input' => '.form-group.$error#>label{$label#}+input.form-control[id=$id# name=$name# value=$value# type=$type# required=$required# autofocus=$autofocus# placeholder=$default# accept=$accept# disabled=$disabled#]+small.help-block>{$message#}',
33
-        'textarea' => '.form-group>label{$label#}+textarea.form-control[id=$id# name=$name# required=$required# autofocus=$autofocus# placeholder=$default# rows=3 disabled=$disabled#]{$value#}+small.help-block>{$message#}',
34
-        'radio' => 'fieldset>legend{$label#}>.radio*options>label>input.radio[name=$name# value=$value# type=radio checked=$selected# required=$required# disabled=$disabled#]{$text#}+p.help-block>{$message#}',
35
-        'select' => '.form-group>label{$label#}+select.form-control[id=$id# name=$name# multiple=$multiple# required=$required#]>option[value]+option[value=$value# selected=$selected# disabled=$disabled#]{$text#}*options',
36
-        'submit' => 'button.btn.btn-primary[id=$id# type=submit]{$label#} disabled=$disabled#',
37
-        'fieldset' => 'fieldset>legend{$label#}',
38
-        'checkbox' => '.checkbox>label>input[id=$id# name=$name# value=$value# type=checkbox checked=$selected# required=$required# autofocus=$autofocus# disabled=$disabled#]+{$label#}^p.help-block>{$error#}',
39
-        //------------- TYPE BASED STYLES ---------------------//
40
-        'checkbox-array' => 'fieldset>legend{$label#}>.checkbox*options>label>input[name=$name# value=$value# type=checkbox checked=$selected# required=$required#]{$text#}',
41
-        'select-array' => '.form-group>label{$label#}+select.form-control[name=$name# multiple=$multiple# required=$required#] size=$options#>option[value=$value# selected=$selected#]{$text#}*options',
42
-        //------------- CUSTOM STYLES ---------------------//
43
-        'radio-inline' => '.form-group>label{$label# : &nbsp;}+label.radio-inline*options>input.radio[name=$name# value=$value# type=radio checked=$selected# required=$required#]+{$text#}',
44
-    );
45
-    public static $foundation5 = array(
46
-        'form' => 'form[id=$id# name=$name# method=$method# action=$action# enctype=$enctype#]',
47
-        'input' => 'label{$label#}+input[id=$id# name=$name# value=$value# type=$type# required=$required# autofocus=$autofocus# placeholder=$default# accept=$accept# disabled=$disabled#]',
48
-        'textarea' => 'label{$label#}+textarea[id=$id# name=$name# required=$required# autofocus=$autofocus# placeholder=$default# rows=3 disabled=$disabled#]{$value#}',
49
-        'radio' => 'label{$label# : &nbsp;}+label.radio-inline*options>input.radio[name=$name# value=$value# type=radio checked=$selected# required=$required# disabled=$disabled#]+{$text#}',
50
-        'select' => 'label{$label#}+select[id=$id# name=$name# required=$required#]>option[value]+option[value=$value# selected=$selected# disabled=$disabled#]{$text#}*options',
51
-        'submit' => 'button.button[id=$id# type=submit disabled=$disabled#]{$label#}',
52
-        'fieldset' => 'fieldset>legend{$label#}',
53
-        'checkbox' => 'label>input[id=$id# name=$name# value=$value# type=checkbox checked=$selected# required=$required# autofocus=$autofocus# disabled=$disabled#]+{ $label#}',
54
-        //------------- TYPE BASED STYLES ---------------------//
55
-        'checkbox-array' => 'fieldset>legend{$label#}+label*options>input[name=$name# value=$value# type=checkbox checked=$selected# required=$required# autofocus=$autofocus#]+{ $text#}',
56
-        'select-array' => 'label{$label#}+select[name=$name# required=$required# multiple style="height: auto;background-image: none; outline: inherit;"]>option[value=$value# selected=$selected#]{$text#}*options',
57
-        //------------- CUSTOM STYLES ---------------------//
58
-    );
17
+	public static $html = array(
18
+		'form' => 'form[role=form id=$id# name=$name# method=$method# action=$action# enctype=$enctype#]',
19
+		'input' => '.row>section>label{$label#}^input[id=$id# name=$name# value=$value# type=$type# required=$required# autofocus=$autofocus# placeholder=$default# accept=$accept# disabled=$disabled#]',
20
+		'textarea' => '.row>label{$label#}^textarea[id=$id# name=$name# required=$required# autofocus=$autofocus# placeholder=$default# rows=3 disabled=$disabled#]{$value#}',
21
+		'radio' => '.row>section>label{$label#}^span>label*options>input[id=$id# name=$name# value=$value# type=radio checked=$selected# required=$required# disabled=$disabled#]+{ $text#}',
22
+		'select' => '.row>label{$label#}^select[id=$id# name=$name# required=$required#]>option[value]+option[value=$value# selected=$selected# disabled=$disabled#]{$text#}*options',
23
+		'submit' => '.row>label{ &nbsp; }^button[id=$id# type=submit disabled=$disabled#]{$label#}',
24
+		'fieldset' => 'fieldset>legend{$label#}',
25
+		'checkbox' => '.row>label>input[id=$id# name=$name# value=$value# type=checkbox checked=$selected# required=$required# autofocus=$autofocus# accept=$accept# disabled=$disabled#]+{$label#}',
26
+		//------------- TYPE BASED STYLES ---------------------//
27
+		'checkbox-array' => 'fieldset>legend{$label#}+section*options>label>input[name=$name# value=$value# type=checkbox checked=$selected# required=$required# autofocus=$autofocus# accept=$accept#]+{ $text#}',
28
+		'select-array' => 'label{$label#}+select[name=$name# required=$required# multiple style="height: auto;background-image: none; outline: inherit;"]>option[value=$value# selected=$selected#]{$text#}*options',
29
+	);
30
+	public static $bootstrap3 = array(
31
+		'form' => 'form[role=form id=$id# name=$name# method=$method# action=$action# enctype=$enctype#]',
32
+		'input' => '.form-group.$error#>label{$label#}+input.form-control[id=$id# name=$name# value=$value# type=$type# required=$required# autofocus=$autofocus# placeholder=$default# accept=$accept# disabled=$disabled#]+small.help-block>{$message#}',
33
+		'textarea' => '.form-group>label{$label#}+textarea.form-control[id=$id# name=$name# required=$required# autofocus=$autofocus# placeholder=$default# rows=3 disabled=$disabled#]{$value#}+small.help-block>{$message#}',
34
+		'radio' => 'fieldset>legend{$label#}>.radio*options>label>input.radio[name=$name# value=$value# type=radio checked=$selected# required=$required# disabled=$disabled#]{$text#}+p.help-block>{$message#}',
35
+		'select' => '.form-group>label{$label#}+select.form-control[id=$id# name=$name# multiple=$multiple# required=$required#]>option[value]+option[value=$value# selected=$selected# disabled=$disabled#]{$text#}*options',
36
+		'submit' => 'button.btn.btn-primary[id=$id# type=submit]{$label#} disabled=$disabled#',
37
+		'fieldset' => 'fieldset>legend{$label#}',
38
+		'checkbox' => '.checkbox>label>input[id=$id# name=$name# value=$value# type=checkbox checked=$selected# required=$required# autofocus=$autofocus# disabled=$disabled#]+{$label#}^p.help-block>{$error#}',
39
+		//------------- TYPE BASED STYLES ---------------------//
40
+		'checkbox-array' => 'fieldset>legend{$label#}>.checkbox*options>label>input[name=$name# value=$value# type=checkbox checked=$selected# required=$required#]{$text#}',
41
+		'select-array' => '.form-group>label{$label#}+select.form-control[name=$name# multiple=$multiple# required=$required#] size=$options#>option[value=$value# selected=$selected#]{$text#}*options',
42
+		//------------- CUSTOM STYLES ---------------------//
43
+		'radio-inline' => '.form-group>label{$label# : &nbsp;}+label.radio-inline*options>input.radio[name=$name# value=$value# type=radio checked=$selected# required=$required#]+{$text#}',
44
+	);
45
+	public static $foundation5 = array(
46
+		'form' => 'form[id=$id# name=$name# method=$method# action=$action# enctype=$enctype#]',
47
+		'input' => 'label{$label#}+input[id=$id# name=$name# value=$value# type=$type# required=$required# autofocus=$autofocus# placeholder=$default# accept=$accept# disabled=$disabled#]',
48
+		'textarea' => 'label{$label#}+textarea[id=$id# name=$name# required=$required# autofocus=$autofocus# placeholder=$default# rows=3 disabled=$disabled#]{$value#}',
49
+		'radio' => 'label{$label# : &nbsp;}+label.radio-inline*options>input.radio[name=$name# value=$value# type=radio checked=$selected# required=$required# disabled=$disabled#]+{$text#}',
50
+		'select' => 'label{$label#}+select[id=$id# name=$name# required=$required#]>option[value]+option[value=$value# selected=$selected# disabled=$disabled#]{$text#}*options',
51
+		'submit' => 'button.button[id=$id# type=submit disabled=$disabled#]{$label#}',
52
+		'fieldset' => 'fieldset>legend{$label#}',
53
+		'checkbox' => 'label>input[id=$id# name=$name# value=$value# type=checkbox checked=$selected# required=$required# autofocus=$autofocus# disabled=$disabled#]+{ $label#}',
54
+		//------------- TYPE BASED STYLES ---------------------//
55
+		'checkbox-array' => 'fieldset>legend{$label#}+label*options>input[name=$name# value=$value# type=checkbox checked=$selected# required=$required# autofocus=$autofocus#]+{ $text#}',
56
+		'select-array' => 'label{$label#}+select[name=$name# required=$required# multiple style="height: auto;background-image: none; outline: inherit;"]>option[value=$value# selected=$selected#]{$text#}*options',
57
+		//------------- CUSTOM STYLES ---------------------//
58
+	);
59 59
 }
60 60
\ No newline at end of file
Please login to merge, or discard this patch.
htdocs/includes/restler/framework/Luracast/Restler/UI/Nav.php 1 patch
Indentation   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -23,201 +23,201 @@
 block discarded – undo
23 23
  */
24 24
 class Nav
25 25
 {
26
-    protected static $tree = array();
27
-    public static $root = 'home';
26
+	protected static $tree = array();
27
+	public static $root = 'home';
28 28
 
29
-    /**
30
-     * @var array all paths beginning with any of the following will be excluded
31
-     * from documentation. if an empty string is given it will exclude the root
32
-     */
33
-    public static $excludedPaths = array('');
34
-    /**
35
-     * @var array prefix additional menu items with one of the following syntax
36
-     *            [$path => $text]
37
-     *            [$path]
38
-     *            [$path => ['text' => $text, 'url' => $url, 'trail'=> $trail]]
39
-     */
40
-    public static $prepends = array();
41
-    /**
42
-     * @var array suffix additional menu items with one of the following syntax
43
-     *            [$path => $text]
44
-     *            [$path]
45
-     *            [$path => ['text' => $text, 'url' => $url, 'trail'=> $trail]]
46
-     */
47
-    public static $appends = array();
29
+	/**
30
+	 * @var array all paths beginning with any of the following will be excluded
31
+	 * from documentation. if an empty string is given it will exclude the root
32
+	 */
33
+	public static $excludedPaths = array('');
34
+	/**
35
+	 * @var array prefix additional menu items with one of the following syntax
36
+	 *            [$path => $text]
37
+	 *            [$path]
38
+	 *            [$path => ['text' => $text, 'url' => $url, 'trail'=> $trail]]
39
+	 */
40
+	public static $prepends = array();
41
+	/**
42
+	 * @var array suffix additional menu items with one of the following syntax
43
+	 *            [$path => $text]
44
+	 *            [$path]
45
+	 *            [$path => ['text' => $text, 'url' => $url, 'trail'=> $trail]]
46
+	 */
47
+	public static $appends = array();
48 48
 
49
-    public static $addExtension = true;
49
+	public static $addExtension = true;
50 50
 
51
-    protected static $extension = '';
52
-    protected static $activeTrail = '';
53
-    protected static $url;
51
+	protected static $extension = '';
52
+	protected static $activeTrail = '';
53
+	protected static $url;
54 54
 
55
-    public static function get($for = '', $activeTrail = null)
56
-    {
57
-        if (empty(static::$tree)) {
58
-            /** @var Restler $restler */
59
-            $restler = Scope::get('Restler');
60
-            if (static::$addExtension)
61
-                static::$extension = isset($restler->responseFormat)
62
-                    ? '.' . $restler->responseFormat->getExtension()
63
-                    : '.html';
64
-            static::$url = $restler->getBaseUrl();
65
-            if (empty(static::$url))
66
-                static::$url = '';
67
-            static::$activeTrail = $activeTrail = empty($activeTrail)
68
-                ? (empty($restler->url) || $restler->url == 'index'
69
-                    ? static::$root
70
-                    : $restler->url
71
-                )
72
-                : $activeTrail;
73
-            if (static::$addExtension)
74
-                static::$extension = isset($restler->responseFormat)
75
-                    ? '.' . $restler->responseFormat->getExtension()
76
-                    : '.html';
77
-            static::addUrls(static::$prepends);
78
-            $map = Routes::findAll(
79
-                static::$excludedPaths,
80
-                array('POST', 'DELETE', 'PUT', 'PATCH'),
81
-                $restler->getRequestedApiVersion()
82
-            );
83
-            foreach ($map as $path => $data) {
84
-                foreach ($data as $item) {
85
-                    $access = $item['access'];
86
-                    $route = $item['route'];
87
-                    $url = $route['url'];
88
-                    if ($access && !Text::contains($url, '{')) {
89
-                        $label = Util::nestedValue(
90
-                            $route,
91
-                            'metadata',
92
-                            CommentParser::$embeddedDataName,
93
-                            'label'
94
-                        );
95
-                        if (!empty($url)) {
96
-                            $url .= static::$extension;
97
-                        }
98
-                        static::add($url, $label);
99
-                    }
100
-                }
101
-            }
102
-            static::addUrls(static::$appends);
103
-        } elseif (empty($activeTrail)) {
104
-            $activeTrail = static::$activeTrail;
105
-        }
106
-        $tree = static::$tree;
107
-        $activeTrail = explode('/', $activeTrail);
108
-        $nested = & static::nested($tree, $activeTrail);
109
-        if (is_array($nested)) {
110
-            $nested['active'] = true;
111
-        }
112
-        if (!empty($for)) {
113
-            $for = explode('/', $for);
114
-            $tree = static::nested($tree, $for)['children'];
115
-        }
116
-        return array_filter($tree);
117
-    }
55
+	public static function get($for = '', $activeTrail = null)
56
+	{
57
+		if (empty(static::$tree)) {
58
+			/** @var Restler $restler */
59
+			$restler = Scope::get('Restler');
60
+			if (static::$addExtension)
61
+				static::$extension = isset($restler->responseFormat)
62
+					? '.' . $restler->responseFormat->getExtension()
63
+					: '.html';
64
+			static::$url = $restler->getBaseUrl();
65
+			if (empty(static::$url))
66
+				static::$url = '';
67
+			static::$activeTrail = $activeTrail = empty($activeTrail)
68
+				? (empty($restler->url) || $restler->url == 'index'
69
+					? static::$root
70
+					: $restler->url
71
+				)
72
+				: $activeTrail;
73
+			if (static::$addExtension)
74
+				static::$extension = isset($restler->responseFormat)
75
+					? '.' . $restler->responseFormat->getExtension()
76
+					: '.html';
77
+			static::addUrls(static::$prepends);
78
+			$map = Routes::findAll(
79
+				static::$excludedPaths,
80
+				array('POST', 'DELETE', 'PUT', 'PATCH'),
81
+				$restler->getRequestedApiVersion()
82
+			);
83
+			foreach ($map as $path => $data) {
84
+				foreach ($data as $item) {
85
+					$access = $item['access'];
86
+					$route = $item['route'];
87
+					$url = $route['url'];
88
+					if ($access && !Text::contains($url, '{')) {
89
+						$label = Util::nestedValue(
90
+							$route,
91
+							'metadata',
92
+							CommentParser::$embeddedDataName,
93
+							'label'
94
+						);
95
+						if (!empty($url)) {
96
+							$url .= static::$extension;
97
+						}
98
+						static::add($url, $label);
99
+					}
100
+				}
101
+			}
102
+			static::addUrls(static::$appends);
103
+		} elseif (empty($activeTrail)) {
104
+			$activeTrail = static::$activeTrail;
105
+		}
106
+		$tree = static::$tree;
107
+		$activeTrail = explode('/', $activeTrail);
108
+		$nested = & static::nested($tree, $activeTrail);
109
+		if (is_array($nested)) {
110
+			$nested['active'] = true;
111
+		}
112
+		if (!empty($for)) {
113
+			$for = explode('/', $for);
114
+			$tree = static::nested($tree, $for)['children'];
115
+		}
116
+		return array_filter($tree);
117
+	}
118 118
 
119
-    protected static function & nested(array & $tree, array $parts)
120
-    {
121
-        if (!empty($parts)) {
122
-            $part = array_shift($parts);
123
-            if (empty($tree[$part])) {
124
-                return $tree[$part];
125
-            } elseif (empty($parts)) {
126
-                return static::nested($tree[$part], $parts);
127
-            } elseif (!empty($tree[$part]['children'])) {
128
-                return static::nested($tree[$part]['children'], $parts);
129
-            }
130
-        } else {
131
-            return $tree;
132
-        }
133
-        $value = null;
134
-        return $value;
135
-    }
119
+	protected static function & nested(array & $tree, array $parts)
120
+	{
121
+		if (!empty($parts)) {
122
+			$part = array_shift($parts);
123
+			if (empty($tree[$part])) {
124
+				return $tree[$part];
125
+			} elseif (empty($parts)) {
126
+				return static::nested($tree[$part], $parts);
127
+			} elseif (!empty($tree[$part]['children'])) {
128
+				return static::nested($tree[$part]['children'], $parts);
129
+			}
130
+		} else {
131
+			return $tree;
132
+		}
133
+		$value = null;
134
+		return $value;
135
+	}
136 136
 
137
-    public static function addUrls(array $urls)
138
-    {
139
-        foreach ($urls as $url => $label) {
140
-            $trail = null;
141
-            if (is_array($label)) {
142
-                if (isset($label['trail'])) {
143
-                    $trail = $label['trail'];
144
-                }
145
-                if (isset($label['url'])) {
146
-                    $url = $label['url'];
147
-                    $label = isset($label['label']) ? $label['label'] : null;
148
-                } else {
149
-                    $url = current(array_keys($label));
150
-                    $label = current($label);
151
-                }
137
+	public static function addUrls(array $urls)
138
+	{
139
+		foreach ($urls as $url => $label) {
140
+			$trail = null;
141
+			if (is_array($label)) {
142
+				if (isset($label['trail'])) {
143
+					$trail = $label['trail'];
144
+				}
145
+				if (isset($label['url'])) {
146
+					$url = $label['url'];
147
+					$label = isset($label['label']) ? $label['label'] : null;
148
+				} else {
149
+					$url = current(array_keys($label));
150
+					$label = current($label);
151
+				}
152 152
 
153
-            }
154
-            if (is_numeric($url)) {
155
-                $url = $label;
156
-                $label = null;
157
-            }
158
-            static::add($url, $label, $trail);
159
-        }
160
-        return static::$tree;
161
-    }
153
+			}
154
+			if (is_numeric($url)) {
155
+				$url = $label;
156
+				$label = null;
157
+			}
158
+			static::add($url, $label, $trail);
159
+		}
160
+		return static::$tree;
161
+	}
162 162
 
163
-    public static function add($url, $label = null, $trail = null)
164
-    {
165
-        $r = parse_url($url);
166
-        if (is_null($trail)) {
167
-            $trail = isset($r['path']) ? $r['path'] : static::$root;
168
-        }
169
-        //remove / prefix and / suffixes and any extension
170
-        $trail = strtok(trim($trail, '/'), '.');
171
-        $parts = explode('/', $trail);
172
-        if (count($parts) == 1 && empty($parts[0]))
173
-            $parts = array(static::$root);
174
-        if (isset($r['fragment'])) {
175
-            $parts[] = $r['fragment'];
176
-            if (is_null($label)) {
177
-                $label = Text::title($r['fragment']);
178
-            }
179
-        }
180
-        if (empty($r['scheme'])) {
181
-            //relative url found
182
-            if (empty($url)) {
183
-                $label = Text::title(static::$root);
184
-                $url = static::$url;
185
-            } else {
186
-                $url = static::$url . '/' . ltrim($url, '/');
187
-            }
188
-        }
189
-        if (is_null($label)) {
190
-            $label = Text::title(strtok(end($parts), '.'));
191
-        }
192
-        $r['url'] = $url;
193
-        $r['path'] = $trail;
194
-        $r['parts'] = $parts;
195
-        $r['label'] = $label;
196
-        static::build($r);
197
-        return $r;
198
-    }
163
+	public static function add($url, $label = null, $trail = null)
164
+	{
165
+		$r = parse_url($url);
166
+		if (is_null($trail)) {
167
+			$trail = isset($r['path']) ? $r['path'] : static::$root;
168
+		}
169
+		//remove / prefix and / suffixes and any extension
170
+		$trail = strtok(trim($trail, '/'), '.');
171
+		$parts = explode('/', $trail);
172
+		if (count($parts) == 1 && empty($parts[0]))
173
+			$parts = array(static::$root);
174
+		if (isset($r['fragment'])) {
175
+			$parts[] = $r['fragment'];
176
+			if (is_null($label)) {
177
+				$label = Text::title($r['fragment']);
178
+			}
179
+		}
180
+		if (empty($r['scheme'])) {
181
+			//relative url found
182
+			if (empty($url)) {
183
+				$label = Text::title(static::$root);
184
+				$url = static::$url;
185
+			} else {
186
+				$url = static::$url . '/' . ltrim($url, '/');
187
+			}
188
+		}
189
+		if (is_null($label)) {
190
+			$label = Text::title(strtok(end($parts), '.'));
191
+		}
192
+		$r['url'] = $url;
193
+		$r['path'] = $trail;
194
+		$r['parts'] = $parts;
195
+		$r['label'] = $label;
196
+		static::build($r);
197
+		return $r;
198
+	}
199 199
 
200
-    public static function build(array $r)
201
-    {
202
-        $p = & static::$tree;
203
-        $parts = $r['parts'];
204
-        $last = count($parts) - 1;
205
-        foreach ($parts as $i => $part) {
206
-            if ($i == $last) {
207
-                $p[$part]['text'] = $r['label'];
208
-                $p[$part]['href'] = $r['url'];
209
-                $p[$part]['class'] = Text::slug($part);
210
-                /* dynamically do it at run time instead
200
+	public static function build(array $r)
201
+	{
202
+		$p = & static::$tree;
203
+		$parts = $r['parts'];
204
+		$last = count($parts) - 1;
205
+		foreach ($parts as $i => $part) {
206
+			if ($i == $last) {
207
+				$p[$part]['text'] = $r['label'];
208
+				$p[$part]['href'] = $r['url'];
209
+				$p[$part]['class'] = Text::slug($part);
210
+				/* dynamically do it at run time instead
211 211
                 if ($r['path'] == static::$activeTrail)
212 212
                     $p[$part]['active'] = true;
213 213
                 */
214
-            } elseif (!isset($p[$part])) {
215
-                $p[$part] = array();
216
-                $p[$part]['text'] = Text::title($part);
217
-                $p[$part]['href'] = '#';
218
-                $p[$part]['children'] = array();
219
-            }
220
-            $p = & $p[$part]['children'];
221
-        }
222
-    }
214
+			} elseif (!isset($p[$part])) {
215
+				$p[$part] = array();
216
+				$p[$part]['text'] = Text::title($part);
217
+				$p[$part]['href'] = '#';
218
+				$p[$part]['children'] = array();
219
+			}
220
+			$p = & $p[$part]['children'];
221
+		}
222
+	}
223 223
 }
Please login to merge, or discard this patch.
htdocs/includes/restler/framework/Luracast/Restler/UI/Forms.php 1 patch
Indentation   +428 added lines, -428 removed lines patch added patch discarded remove patch
@@ -34,453 +34,453 @@
 block discarded – undo
34 34
  */
35 35
 class Forms implements iFilter
36 36
 {
37
-    const FORM_KEY = 'form_key';
38
-    public static $filterFormRequestsOnly = false;
37
+	const FORM_KEY = 'form_key';
38
+	public static $filterFormRequestsOnly = false;
39 39
 
40
-    public static $excludedPaths = array();
40
+	public static $excludedPaths = array();
41 41
 
42
-    private static $style;
43
-    /**
44
-     * @var bool should we fill up the form using given data?
45
-     */
46
-    public static $preFill = true;
47
-    /**
48
-     * @var ValidationInfo
49
-     */
50
-    public static $validationInfo = null;
51
-    protected static $inputTypes = array(
52
-        'hidden',
53
-        'password',
54
-        'button',
55
-        'image',
56
-        'file',
57
-        'reset',
58
-        'submit',
59
-        'search',
60
-        'checkbox',
61
-        'radio',
62
-        'email',
63
-        'text',
64
-        'color',
65
-        'date',
66
-        'datetime',
67
-        'datetime-local',
68
-        'email',
69
-        'month',
70
-        'number',
71
-        'range',
72
-        'search',
73
-        'tel',
74
-        'time',
75
-        'url',
76
-        'week',
77
-    );
78
-    protected static $fileUpload = false;
79
-    private static $key = array();
80
-    /**
81
-     * @var ApiMethodInfo;
82
-     */
83
-    private static $info;
42
+	private static $style;
43
+	/**
44
+	 * @var bool should we fill up the form using given data?
45
+	 */
46
+	public static $preFill = true;
47
+	/**
48
+	 * @var ValidationInfo
49
+	 */
50
+	public static $validationInfo = null;
51
+	protected static $inputTypes = array(
52
+		'hidden',
53
+		'password',
54
+		'button',
55
+		'image',
56
+		'file',
57
+		'reset',
58
+		'submit',
59
+		'search',
60
+		'checkbox',
61
+		'radio',
62
+		'email',
63
+		'text',
64
+		'color',
65
+		'date',
66
+		'datetime',
67
+		'datetime-local',
68
+		'email',
69
+		'month',
70
+		'number',
71
+		'range',
72
+		'search',
73
+		'tel',
74
+		'time',
75
+		'url',
76
+		'week',
77
+	);
78
+	protected static $fileUpload = false;
79
+	private static $key = array();
80
+	/**
81
+	 * @var ApiMethodInfo;
82
+	 */
83
+	private static $info;
84 84
 
85
-    public static function setStyles(HtmlForm $style)
86
-    {
87
-        static::$style = get_class($style);
88
-    }
85
+	public static function setStyles(HtmlForm $style)
86
+	{
87
+		static::$style = get_class($style);
88
+	}
89 89
 
90
-    /**
91
-     * Get the form
92
-     *
93
-     * @param string $method   http method to submit the form
94
-     * @param string $action   relative path from the web root. When set to null
95
-     *                         it uses the current api method's path
96
-     * @param bool   $dataOnly if you want to render the form yourself use this
97
-     *                         option
98
-     * @param string $prefix   used for adjusting the spacing in front of
99
-     *                         form elements
100
-     * @param string $indent   used for adjusting indentation
101
-     *
102
-     * @return array|T
103
-     *
104
-     * @throws RestException
105
-     */
106
-    public static function get($method = 'POST', $action = null, $dataOnly = false, $prefix = '', $indent = '    ')
107
-    {
108
-        if (!static::$style) {
109
-            static::$style = 'Luracast\\Restler\\UI\HtmlForm';
110
-        }
90
+	/**
91
+	 * Get the form
92
+	 *
93
+	 * @param string $method   http method to submit the form
94
+	 * @param string $action   relative path from the web root. When set to null
95
+	 *                         it uses the current api method's path
96
+	 * @param bool   $dataOnly if you want to render the form yourself use this
97
+	 *                         option
98
+	 * @param string $prefix   used for adjusting the spacing in front of
99
+	 *                         form elements
100
+	 * @param string $indent   used for adjusting indentation
101
+	 *
102
+	 * @return array|T
103
+	 *
104
+	 * @throws RestException
105
+	 */
106
+	public static function get($method = 'POST', $action = null, $dataOnly = false, $prefix = '', $indent = '    ')
107
+	{
108
+		if (!static::$style) {
109
+			static::$style = 'Luracast\\Restler\\UI\HtmlForm';
110
+		}
111 111
 
112
-        try {
113
-            /** @var Restler $restler */
114
-            $restler = Scope::get('Restler');
115
-            if (is_null($action)) {
116
-                $action = $restler->url;
117
-            }
112
+		try {
113
+			/** @var Restler $restler */
114
+			$restler = Scope::get('Restler');
115
+			if (is_null($action)) {
116
+				$action = $restler->url;
117
+			}
118 118
 
119
-            $info = $restler->url == $action
120
-            && Util::getRequestMethod() == $method
121
-                ? $restler->apiMethodInfo
122
-                : Routes::find(
123
-                    trim($action, '/'),
124
-                    $method,
125
-                    $restler->getRequestedApiVersion(),
126
-                    static::$preFill ||
127
-                    ($restler->requestMethod == $method &&
128
-                        $restler->url == $action)
129
-                        ? $restler->getRequestData()
130
-                        : array()
131
-                );
119
+			$info = $restler->url == $action
120
+			&& Util::getRequestMethod() == $method
121
+				? $restler->apiMethodInfo
122
+				: Routes::find(
123
+					trim($action, '/'),
124
+					$method,
125
+					$restler->getRequestedApiVersion(),
126
+					static::$preFill ||
127
+					($restler->requestMethod == $method &&
128
+						$restler->url == $action)
129
+						? $restler->getRequestData()
130
+						: array()
131
+				);
132 132
 
133
-        } catch (RestException $e) {
134
-            //echo $e->getErrorMessage();
135
-            $info = false;
136
-        }
137
-        if (!$info) {
138
-            throw new RestException(500, 'invalid action path for form `' . $method . ' ' . $action . '`');
139
-        }
140
-        static::$info = $info;
141
-        $m = $info->metadata;
142
-        $r = static::fields($dataOnly);
143
-        if ($method != 'GET' && $method != 'POST') {
144
-            if (empty(Defaults::$httpMethodOverrideProperty)) {
145
-                throw new RestException(
146
-                    500,
147
-                    'Forms require `Defaults::\$httpMethodOverrideProperty`' .
148
-                    "for supporting HTTP $method"
149
-                );
150
-            }
151
-            if ($dataOnly) {
152
-                $r[] = array(
153
-                    'tag'   => 'input',
154
-                    'name'  => Defaults::$httpMethodOverrideProperty,
155
-                    'type'  => 'hidden',
156
-                    'value' => 'method',
157
-                );
158
-            } else {
159
-                $r[] = T::input()
160
-                    ->name(Defaults::$httpMethodOverrideProperty)
161
-                    ->value($method)
162
-                    ->type('hidden');
163
-            }
133
+		} catch (RestException $e) {
134
+			//echo $e->getErrorMessage();
135
+			$info = false;
136
+		}
137
+		if (!$info) {
138
+			throw new RestException(500, 'invalid action path for form `' . $method . ' ' . $action . '`');
139
+		}
140
+		static::$info = $info;
141
+		$m = $info->metadata;
142
+		$r = static::fields($dataOnly);
143
+		if ($method != 'GET' && $method != 'POST') {
144
+			if (empty(Defaults::$httpMethodOverrideProperty)) {
145
+				throw new RestException(
146
+					500,
147
+					'Forms require `Defaults::\$httpMethodOverrideProperty`' .
148
+					"for supporting HTTP $method"
149
+				);
150
+			}
151
+			if ($dataOnly) {
152
+				$r[] = array(
153
+					'tag'   => 'input',
154
+					'name'  => Defaults::$httpMethodOverrideProperty,
155
+					'type'  => 'hidden',
156
+					'value' => 'method',
157
+				);
158
+			} else {
159
+				$r[] = T::input()
160
+					->name(Defaults::$httpMethodOverrideProperty)
161
+					->value($method)
162
+					->type('hidden');
163
+			}
164 164
 
165
-            $method = 'POST';
166
-        }
167
-        if (session_id() != '') {
168
-            $form_key = static::key($method, $action);
169
-            if ($dataOnly) {
170
-                $r[] = array(
171
-                    'tag'   => 'input',
172
-                    'name'  => static::FORM_KEY,
173
-                    'type'  => 'hidden',
174
-                    'value' => 'hidden',
175
-                );
176
-            } else {
177
-                $key = T::input()
178
-                    ->name(static::FORM_KEY)
179
-                    ->type('hidden')
180
-                    ->value($form_key);
181
-                $r[] = $key;
182
-            }
183
-        }
165
+			$method = 'POST';
166
+		}
167
+		if (session_id() != '') {
168
+			$form_key = static::key($method, $action);
169
+			if ($dataOnly) {
170
+				$r[] = array(
171
+					'tag'   => 'input',
172
+					'name'  => static::FORM_KEY,
173
+					'type'  => 'hidden',
174
+					'value' => 'hidden',
175
+				);
176
+			} else {
177
+				$key = T::input()
178
+					->name(static::FORM_KEY)
179
+					->type('hidden')
180
+					->value($form_key);
181
+				$r[] = $key;
182
+			}
183
+		}
184 184
 
185
-        $s = array(
186
-            'tag'   => 'button',
187
-            'type'  => 'submit',
188
-            'label' =>
189
-                Util::nestedValue($m, 'return', CommentParser::$embeddedDataName, 'label')
190
-                    ?: 'Submit'
191
-        );
185
+		$s = array(
186
+			'tag'   => 'button',
187
+			'type'  => 'submit',
188
+			'label' =>
189
+				Util::nestedValue($m, 'return', CommentParser::$embeddedDataName, 'label')
190
+					?: 'Submit'
191
+		);
192 192
 
193
-        if (!$dataOnly) {
194
-            $s = Emmet::make(static::style('submit', $m), $s);
195
-        }
196
-        $r[] = $s;
197
-        $t = array(
198
-            'action' => $restler->getBaseUrl() . '/' . rtrim($action, '/'),
199
-            'method' => $method,
200
-        );
201
-        if (static::$fileUpload) {
202
-            static::$fileUpload = false;
203
-            $t['enctype'] = 'multipart/form-data';
204
-        }
205
-        if (isset($m[CommentParser::$embeddedDataName])) {
206
-            $t += $m[CommentParser::$embeddedDataName];
207
-        }
208
-        if (!$dataOnly) {
209
-            $t = Emmet::make(static::style('form', $m), $t);
210
-            $t->prefix = $prefix;
211
-            $t->indent = $indent;
212
-            $t[] = $r;
213
-        } else {
214
-            $t['fields'] = $r;
215
-        }
216
-        return $t;
217
-    }
193
+		if (!$dataOnly) {
194
+			$s = Emmet::make(static::style('submit', $m), $s);
195
+		}
196
+		$r[] = $s;
197
+		$t = array(
198
+			'action' => $restler->getBaseUrl() . '/' . rtrim($action, '/'),
199
+			'method' => $method,
200
+		);
201
+		if (static::$fileUpload) {
202
+			static::$fileUpload = false;
203
+			$t['enctype'] = 'multipart/form-data';
204
+		}
205
+		if (isset($m[CommentParser::$embeddedDataName])) {
206
+			$t += $m[CommentParser::$embeddedDataName];
207
+		}
208
+		if (!$dataOnly) {
209
+			$t = Emmet::make(static::style('form', $m), $t);
210
+			$t->prefix = $prefix;
211
+			$t->indent = $indent;
212
+			$t[] = $r;
213
+		} else {
214
+			$t['fields'] = $r;
215
+		}
216
+		return $t;
217
+	}
218 218
 
219
-    public static function style($name, array $metadata, $type = '')
220
-    {
221
-        if (isset($metadata[CommentParser::$embeddedDataName][$name])) {
222
-            return $metadata[CommentParser::$embeddedDataName][$name];
223
-        }
224
-        $style = static::$style . '::' . $name;
225
-        $typedStyle = $style . '_' . $type;
226
-        if (defined($typedStyle)) {
227
-            return constant($typedStyle);
228
-        }
229
-        if (defined($style)) {
230
-            return constant($style);
231
-        }
232
-        return null;
233
-    }
219
+	public static function style($name, array $metadata, $type = '')
220
+	{
221
+		if (isset($metadata[CommentParser::$embeddedDataName][$name])) {
222
+			return $metadata[CommentParser::$embeddedDataName][$name];
223
+		}
224
+		$style = static::$style . '::' . $name;
225
+		$typedStyle = $style . '_' . $type;
226
+		if (defined($typedStyle)) {
227
+			return constant($typedStyle);
228
+		}
229
+		if (defined($style)) {
230
+			return constant($style);
231
+		}
232
+		return null;
233
+	}
234 234
 
235
-    public static function fields($dataOnly = false)
236
-    {
237
-        $m = static::$info->metadata;
238
-        $params = $m['param'];
239
-        $values = static::$info->parameters;
240
-        $r = array();
241
-        foreach ($params as $k => $p) {
242
-            $value = Util::nestedValue($values, $k);
243
-            if (
244
-                is_scalar($value) ||
245
-                ($p['type'] == 'array' && is_array($value) && $value == array_values($value)) ||
246
-                is_object($value) && $p['type'] == get_class($value)
247
-            ) {
248
-                $p['value'] = $value;
249
-            }
250
-            static::$validationInfo = $v = new ValidationInfo($p);
251
-            if ($v->from == 'path') {
252
-                continue;
253
-            }
254
-            if (!empty($v->children)) {
255
-                $t = Emmet::make(static::style('fieldset', $m), array('label' => $v->label));
256
-                foreach ($v->children as $n => $c) {
257
-                    $value = Util::nestedValue($v->value, $n);
258
-                    if (
259
-                        is_scalar($value) ||
260
-                        ($c['type'] == 'array' && is_array($value) && $value == array_values($value)) ||
261
-                        is_object($value) && $c['type'] == get_class($value)
262
-                    ) {
263
-                        $c['value'] = $value;
264
-                    }
265
-                    static::$validationInfo = $vc = new ValidationInfo($c);
266
-                    if ($vc->from == 'path') {
267
-                        continue;
268
-                    }
269
-                    $vc->name = $v->name . '[' . $vc->name . ']';
270
-                    $t [] = static::field($vc, $dataOnly);
271
-                }
272
-                $r[] = $t;
273
-                static::$validationInfo = null;
274
-            } else {
275
-                $f = static::field($v, $dataOnly);
276
-                $r [] = $f;
277
-            }
278
-            static::$validationInfo = null;
279
-        }
280
-        return $r;
281
-    }
235
+	public static function fields($dataOnly = false)
236
+	{
237
+		$m = static::$info->metadata;
238
+		$params = $m['param'];
239
+		$values = static::$info->parameters;
240
+		$r = array();
241
+		foreach ($params as $k => $p) {
242
+			$value = Util::nestedValue($values, $k);
243
+			if (
244
+				is_scalar($value) ||
245
+				($p['type'] == 'array' && is_array($value) && $value == array_values($value)) ||
246
+				is_object($value) && $p['type'] == get_class($value)
247
+			) {
248
+				$p['value'] = $value;
249
+			}
250
+			static::$validationInfo = $v = new ValidationInfo($p);
251
+			if ($v->from == 'path') {
252
+				continue;
253
+			}
254
+			if (!empty($v->children)) {
255
+				$t = Emmet::make(static::style('fieldset', $m), array('label' => $v->label));
256
+				foreach ($v->children as $n => $c) {
257
+					$value = Util::nestedValue($v->value, $n);
258
+					if (
259
+						is_scalar($value) ||
260
+						($c['type'] == 'array' && is_array($value) && $value == array_values($value)) ||
261
+						is_object($value) && $c['type'] == get_class($value)
262
+					) {
263
+						$c['value'] = $value;
264
+					}
265
+					static::$validationInfo = $vc = new ValidationInfo($c);
266
+					if ($vc->from == 'path') {
267
+						continue;
268
+					}
269
+					$vc->name = $v->name . '[' . $vc->name . ']';
270
+					$t [] = static::field($vc, $dataOnly);
271
+				}
272
+				$r[] = $t;
273
+				static::$validationInfo = null;
274
+			} else {
275
+				$f = static::field($v, $dataOnly);
276
+				$r [] = $f;
277
+			}
278
+			static::$validationInfo = null;
279
+		}
280
+		return $r;
281
+	}
282 282
 
283
-    /**
284
-     * @param ValidationInfo $p
285
-     *
286
-     * @param bool           $dataOnly
287
-     *
288
-     * @return array|T
289
-     */
290
-    public static function field(ValidationInfo $p, $dataOnly = false)
291
-    {
292
-        if (is_string($p->value)) {
293
-            //prevent XSS attacks
294
-            $p->value = htmlspecialchars($p->value, ENT_QUOTES | ENT_HTML401, 'UTF-8');
295
-        }
296
-        $type = $p->field ?: static::guessFieldType($p);
297
-        $tag = in_array($type, static::$inputTypes)
298
-            ? 'input' : $type;
299
-        $options = array();
300
-        $name = $p->name;
301
-        $multiple = null;
302
-        if ($p->type == 'array' && $p->contentType != 'associative') {
303
-            $name .= '[]';
304
-            $multiple = true;
305
-        }
306
-        if ($p->choice) {
307
-            foreach ($p->choice as $i => $choice) {
308
-                $option = array('name' => $name, 'value' => $choice);
309
-                $option['text'] = isset($p->rules['select'][$i])
310
-                    ? $p->rules['select'][$i]
311
-                    : $choice;
312
-                if ($choice == $p->value) {
313
-                    $option['selected'] = true;
314
-                }
315
-                $options[] = $option;
316
-            }
317
-        } elseif ($p->type == 'boolean' || $p->type == 'bool') {
318
-            if (Text::beginsWith($type, 'radio') || Text::beginsWith($type, 'select')) {
319
-                $options[] = array(
320
-                    'name'  => $p->name,
321
-                    'text'  => ' Yes ',
322
-                    'value' => 'true'
323
-                );
324
-                $options[] = array(
325
-                    'name'  => $p->name,
326
-                    'text'  => ' No ',
327
-                    'value' => 'false'
328
-                );
329
-                if ($p->value || $p->default) {
330
-                    $options[0]['selected'] = true;
331
-                }
332
-            } else { //checkbox
333
-                $r = array(
334
-                    'tag'     => $tag,
335
-                    'name'    => $name,
336
-                    'type'    => $type,
337
-                    'label'   => $p->label,
338
-                    'value'   => 'true',
339
-                    'default' => $p->default,
340
-                );
341
-                $r['text'] = 'Yes';
342
-                if ($p->default) {
343
-                    $r['selected'] = true;
344
-                }
345
-                if (isset($p->rules)) {
346
-                    $r += $p->rules;
347
-                }
348
-            }
349
-        }
350
-        if (empty($r)) {
351
-            $r = array(
352
-                'tag'      => $tag,
353
-                'name'     => $name,
354
-                'type'     => $type,
355
-                'label'    => $p->label,
356
-                'value'    => $p->value,
357
-                'default'  => $p->default,
358
-                'options'  => & $options,
359
-                'multiple' => $multiple,
360
-            );
361
-            if (isset($p->rules)) {
362
-                $r += $p->rules;
363
-            }
364
-        }
365
-        if ($type == 'file') {
366
-            static::$fileUpload = true;
367
-            if (empty($r['accept'])) {
368
-                $r['accept'] = implode(', ', UploadFormat::$allowedMimeTypes);
369
-            }
370
-        }
371
-        if (!empty(Validator::$exceptions[$name]) && static::$info->url == Scope::get('Restler')->url) {
372
-            $r['error'] = 'has-error';
373
-            $r['message'] = Validator::$exceptions[$p->name]->getMessage();
374
-        }
283
+	/**
284
+	 * @param ValidationInfo $p
285
+	 *
286
+	 * @param bool           $dataOnly
287
+	 *
288
+	 * @return array|T
289
+	 */
290
+	public static function field(ValidationInfo $p, $dataOnly = false)
291
+	{
292
+		if (is_string($p->value)) {
293
+			//prevent XSS attacks
294
+			$p->value = htmlspecialchars($p->value, ENT_QUOTES | ENT_HTML401, 'UTF-8');
295
+		}
296
+		$type = $p->field ?: static::guessFieldType($p);
297
+		$tag = in_array($type, static::$inputTypes)
298
+			? 'input' : $type;
299
+		$options = array();
300
+		$name = $p->name;
301
+		$multiple = null;
302
+		if ($p->type == 'array' && $p->contentType != 'associative') {
303
+			$name .= '[]';
304
+			$multiple = true;
305
+		}
306
+		if ($p->choice) {
307
+			foreach ($p->choice as $i => $choice) {
308
+				$option = array('name' => $name, 'value' => $choice);
309
+				$option['text'] = isset($p->rules['select'][$i])
310
+					? $p->rules['select'][$i]
311
+					: $choice;
312
+				if ($choice == $p->value) {
313
+					$option['selected'] = true;
314
+				}
315
+				$options[] = $option;
316
+			}
317
+		} elseif ($p->type == 'boolean' || $p->type == 'bool') {
318
+			if (Text::beginsWith($type, 'radio') || Text::beginsWith($type, 'select')) {
319
+				$options[] = array(
320
+					'name'  => $p->name,
321
+					'text'  => ' Yes ',
322
+					'value' => 'true'
323
+				);
324
+				$options[] = array(
325
+					'name'  => $p->name,
326
+					'text'  => ' No ',
327
+					'value' => 'false'
328
+				);
329
+				if ($p->value || $p->default) {
330
+					$options[0]['selected'] = true;
331
+				}
332
+			} else { //checkbox
333
+				$r = array(
334
+					'tag'     => $tag,
335
+					'name'    => $name,
336
+					'type'    => $type,
337
+					'label'   => $p->label,
338
+					'value'   => 'true',
339
+					'default' => $p->default,
340
+				);
341
+				$r['text'] = 'Yes';
342
+				if ($p->default) {
343
+					$r['selected'] = true;
344
+				}
345
+				if (isset($p->rules)) {
346
+					$r += $p->rules;
347
+				}
348
+			}
349
+		}
350
+		if (empty($r)) {
351
+			$r = array(
352
+				'tag'      => $tag,
353
+				'name'     => $name,
354
+				'type'     => $type,
355
+				'label'    => $p->label,
356
+				'value'    => $p->value,
357
+				'default'  => $p->default,
358
+				'options'  => & $options,
359
+				'multiple' => $multiple,
360
+			);
361
+			if (isset($p->rules)) {
362
+				$r += $p->rules;
363
+			}
364
+		}
365
+		if ($type == 'file') {
366
+			static::$fileUpload = true;
367
+			if (empty($r['accept'])) {
368
+				$r['accept'] = implode(', ', UploadFormat::$allowedMimeTypes);
369
+			}
370
+		}
371
+		if (!empty(Validator::$exceptions[$name]) && static::$info->url == Scope::get('Restler')->url) {
372
+			$r['error'] = 'has-error';
373
+			$r['message'] = Validator::$exceptions[$p->name]->getMessage();
374
+		}
375 375
 
376
-        if (true === $p->required) {
377
-            $r['required'] = 'required';
378
-        }
379
-        if (isset($p->rules['autofocus'])) {
380
-            $r['autofocus'] = 'autofocus';
381
-        }
382
-        /*
376
+		if (true === $p->required) {
377
+			$r['required'] = 'required';
378
+		}
379
+		if (isset($p->rules['autofocus'])) {
380
+			$r['autofocus'] = 'autofocus';
381
+		}
382
+		/*
383 383
         echo "<pre>";
384 384
         print_r($r);
385 385
         echo "</pre>";
386 386
         */
387
-        if ($dataOnly) {
388
-            return $r;
389
-        }
390
-        if (isset($p->rules['form'])) {
391
-            return Emmet::make($p->rules['form'], $r);
392
-        }
393
-        $m = static::$info->metadata;
394
-        $t = Emmet::make(static::style($type, $m, $p->type) ?: static::style($tag, $m, $p->type), $r);
395
-        return $t;
396
-    }
387
+		if ($dataOnly) {
388
+			return $r;
389
+		}
390
+		if (isset($p->rules['form'])) {
391
+			return Emmet::make($p->rules['form'], $r);
392
+		}
393
+		$m = static::$info->metadata;
394
+		$t = Emmet::make(static::style($type, $m, $p->type) ?: static::style($tag, $m, $p->type), $r);
395
+		return $t;
396
+	}
397 397
 
398
-    protected static function guessFieldType(ValidationInfo $p, $type = 'type')
399
-    {
400
-        if (in_array($p->$type, static::$inputTypes)) {
401
-            return $p->$type;
402
-        }
403
-        if ($p->choice) {
404
-            return $p->type == 'array' ? 'checkbox' : 'select';
405
-        }
406
-        switch ($p->$type) {
407
-            case 'boolean':
408
-                return 'radio';
409
-            case 'int':
410
-            case 'number':
411
-            case 'float':
412
-                return 'number';
413
-            case 'array':
414
-                return static::guessFieldType($p, 'contentType');
415
-        }
416
-        if ($p->name == 'password') {
417
-            return 'password';
418
-        }
419
-        return 'text';
420
-    }
398
+	protected static function guessFieldType(ValidationInfo $p, $type = 'type')
399
+	{
400
+		if (in_array($p->$type, static::$inputTypes)) {
401
+			return $p->$type;
402
+		}
403
+		if ($p->choice) {
404
+			return $p->type == 'array' ? 'checkbox' : 'select';
405
+		}
406
+		switch ($p->$type) {
407
+			case 'boolean':
408
+				return 'radio';
409
+			case 'int':
410
+			case 'number':
411
+			case 'float':
412
+				return 'number';
413
+			case 'array':
414
+				return static::guessFieldType($p, 'contentType');
415
+		}
416
+		if ($p->name == 'password') {
417
+			return 'password';
418
+		}
419
+		return 'text';
420
+	}
421 421
 
422
-    /**
423
-     * Get the form key
424
-     *
425
-     * @param string $method   http method for form key
426
-     * @param string $action   relative path from the web root. When set to null
427
-     *                         it uses the current api method's path
428
-     *
429
-     * @return string generated form key
430
-     */
431
-    public static function key($method = 'POST', $action = null)
432
-    {
433
-        if (is_null($action)) {
434
-            $action = Scope::get('Restler')->url;
435
-        }
436
-        $target = "$method $action";
437
-        if (empty(static::$key[$target])) {
438
-            static::$key[$target] = md5($target . User::getIpAddress() . uniqid(mt_rand()));
439
-        }
440
-        $_SESSION[static::FORM_KEY] = static::$key;
441
-        return static::$key[$target];
442
-    }
422
+	/**
423
+	 * Get the form key
424
+	 *
425
+	 * @param string $method   http method for form key
426
+	 * @param string $action   relative path from the web root. When set to null
427
+	 *                         it uses the current api method's path
428
+	 *
429
+	 * @return string generated form key
430
+	 */
431
+	public static function key($method = 'POST', $action = null)
432
+	{
433
+		if (is_null($action)) {
434
+			$action = Scope::get('Restler')->url;
435
+		}
436
+		$target = "$method $action";
437
+		if (empty(static::$key[$target])) {
438
+			static::$key[$target] = md5($target . User::getIpAddress() . uniqid(mt_rand()));
439
+		}
440
+		$_SESSION[static::FORM_KEY] = static::$key;
441
+		return static::$key[$target];
442
+	}
443 443
 
444
-    /**
445
-     * Access verification method.
446
-     *
447
-     * API access will be denied when this method returns false
448
-     *
449
-     * @return boolean true when api access is allowed false otherwise
450
-     *
451
-     * @throws RestException 403 security violation
452
-     */
453
-    public function __isAllowed()
454
-    {
455
-        if (session_id() == '') {
456
-            session_start();
457
-        }
458
-        /** @var Restler $restler */
459
-        $restler = $this->restler;
460
-        $url = $restler->url;
461
-        foreach (static::$excludedPaths as $exclude) {
462
-            if (empty($exclude)) {
463
-                if ($url == $exclude) {
464
-                    return true;
465
-                }
466
-            } elseif (Text::beginsWith($url, $exclude)) {
467
-                return true;
468
-            }
469
-        }
470
-        $check = static::$filterFormRequestsOnly
471
-            ? $restler->requestFormat instanceof UrlEncodedFormat || $restler->requestFormat instanceof UploadFormat
472
-            : true;
473
-        if (!empty($_POST) && $check) {
474
-            if (
475
-                isset($_POST[static::FORM_KEY]) &&
476
-                ($target = Util::getRequestMethod() . ' ' . $restler->url) &&
477
-                isset($_SESSION[static::FORM_KEY][$target]) &&
478
-                $_POST[static::FORM_KEY] == $_SESSION[static::FORM_KEY][$target]
479
-            ) {
480
-                return true;
481
-            }
482
-            throw new RestException(403, 'Insecure form submission');
483
-        }
484
-        return true;
485
-    }
444
+	/**
445
+	 * Access verification method.
446
+	 *
447
+	 * API access will be denied when this method returns false
448
+	 *
449
+	 * @return boolean true when api access is allowed false otherwise
450
+	 *
451
+	 * @throws RestException 403 security violation
452
+	 */
453
+	public function __isAllowed()
454
+	{
455
+		if (session_id() == '') {
456
+			session_start();
457
+		}
458
+		/** @var Restler $restler */
459
+		$restler = $this->restler;
460
+		$url = $restler->url;
461
+		foreach (static::$excludedPaths as $exclude) {
462
+			if (empty($exclude)) {
463
+				if ($url == $exclude) {
464
+					return true;
465
+				}
466
+			} elseif (Text::beginsWith($url, $exclude)) {
467
+				return true;
468
+			}
469
+		}
470
+		$check = static::$filterFormRequestsOnly
471
+			? $restler->requestFormat instanceof UrlEncodedFormat || $restler->requestFormat instanceof UploadFormat
472
+			: true;
473
+		if (!empty($_POST) && $check) {
474
+			if (
475
+				isset($_POST[static::FORM_KEY]) &&
476
+				($target = Util::getRequestMethod() . ' ' . $restler->url) &&
477
+				isset($_SESSION[static::FORM_KEY][$target]) &&
478
+				$_POST[static::FORM_KEY] == $_SESSION[static::FORM_KEY][$target]
479
+			) {
480
+				return true;
481
+			}
482
+			throw new RestException(403, 'Insecure form submission');
483
+		}
484
+		return true;
485
+	}
486 486
 }
Please login to merge, or discard this patch.