1 | <?php |
||
75 | class EcommerceSiteTreeExtension_Controller extends Extension |
||
76 | { |
||
77 | /** |
||
78 | * standard SS method. |
||
79 | * Runs before the Page::init method is called. |
||
80 | */ |
||
81 | public function onBeforeInit() |
||
95 | |||
96 | /** |
||
97 | * Standard SS method. |
||
98 | * Runs after the Page::init method is called. |
||
99 | */ |
||
100 | public function onAfterInit() |
||
107 | |||
108 | /** |
||
109 | * This returns a link that displays just the cart, for use in ajax calls. |
||
110 | * |
||
111 | * @see ShoppingCart::showcart |
||
112 | * It uses AjaxSimpleCart.ss to render the cart. |
||
113 | * |
||
114 | * @return string |
||
115 | **/ |
||
116 | public function SimpleCartLinkAjax() |
||
120 | |||
121 | /** |
||
122 | * returns the current order. |
||
123 | * |
||
124 | * @return Order |
||
125 | **/ |
||
126 | public function Cart() |
||
130 | |||
131 | /** |
||
132 | * @return string (Link) |
||
133 | */ |
||
134 | public function ContinueShoppingLink() |
||
143 | |||
144 | |||
145 | /** |
||
146 | * Is the page a secure page? |
||
147 | * |
||
148 | * @return true/false |
||
149 | */ |
||
150 | public function isSecurePage() |
||
154 | |||
155 | /** |
||
156 | * Redirect users if found on incorrect domain |
||
157 | * Detects if $_GET['session'] is present, sets session |
||
158 | * and redirects back to "clean URL" |
||
159 | * Both _SECURE_URL and _STANDARD_URL must be defined, |
||
160 | * and include protocol (http(s)://mydomain.com) with no trailing slash. |
||
161 | * protected function secureHostSwitcher() |
||
162 | * { |
||
163 | * if (!DEFINED('_SECURE_URL') || !DEFINED('_STANDARD_URL')) { |
||
164 | * return false; |
||
165 | * } |
||
166 | * |
||
167 | * $protocol = Director::is_https() ? 'https://' : 'http://'; |
||
168 | * $currentUrlFull = $protocol.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; |
||
169 | * list($currentUrlFull) = explode('#', $currentUrlFull); |
||
170 | * $currentUrlWithoutHost = $_SERVER['REQUEST_URI']; |
||
171 | * //remove fragment...just to keep it simple... |
||
172 | * list($currentUrlWithoutHost) = explode('#', $currentUrlWithoutHost); |
||
173 | * $sessionPartOfURL = ''; |
||
174 | * $sessionID = session_id(); |
||
175 | * if ($sessionID) { |
||
176 | * if (strpos($currentUrlWithoutHost, '?')) { |
||
177 | * $sessionPartOfURL .= '&'; |
||
178 | * } else { |
||
179 | * $sessionPartOfURL = '?'; |
||
180 | * } |
||
181 | * $sessionPartOfURL .= 'session='.$sessionID; |
||
182 | * $currentUrlWithoutHost .= $sessionPartOfURL; |
||
183 | * } |
||
184 | * |
||
185 | * $isSecure = $this->owner->isSecurePage(); |
||
186 | * |
||
187 | * if ($isSecure && !preg_match('/^'.preg_quote(_SECURE_URL, '/').'/', $currentUrlFull)) { |
||
188 | * return $this->owner->redirect(_SECURE_URL.$currentUrlWithoutHost); |
||
189 | * } elseif (!$isSecure && !preg_match('/^'.preg_quote(_STANDARD_URL, '/').'/', $currentUrlFull)) { |
||
190 | * return $this->owner->redirect(_STANDARD_URL.$currentUrlWithoutHost); |
||
191 | * } |
||
192 | * |
||
193 | * if ($sessionID = $this->owner->request->getVar('session')) { |
||
194 | * $currentUrlFull = str_replace('?session='.$sessionID, '', $currentUrlFull); |
||
195 | * $currentUrlFull = str_replace('&session='.$sessionID, '', $currentUrlFull); |
||
196 | * // force hard-coded session setting |
||
197 | * @session_write_close(); |
||
198 | * @session_id($sessionID); |
||
199 | * @session_start(); |
||
200 | * header('location: '.$currentUrlFull, 302); |
||
201 | * exit; |
||
202 | * } |
||
203 | *} |
||
204 | */ |
||
205 | } |
||
206 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.