Completed
Pull Request — master (#1130)
by
unknown
02:11
created
controller/WebController.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
         // specify where to look for templates and cache
38 38
         $loader = new Twig_Loader_Filesystem('view');
39 39
         // initialize Twig environment
40
-        $this->twig = new Twig_Environment($loader, array('cache' => $tmpDir,'auto_reload' => true));
40
+        $this->twig = new Twig_Environment($loader, array('cache' => $tmpDir, 'auto_reload' => true));
41 41
         $this->twig->addExtension(new Twig_Extensions_Extension_I18n());
42 42
         // used for setting the base href for the relative urls
43 43
         $this->twig->addGlobal("BaseHref", $this->getBaseHref());
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         $this->twig->addFilter(new Twig_SimpleFilter('link_url', array($this, 'linkUrlFilter')));
61 61
 
62 62
         // register a Twig filter for generating strings from language codes with CLDR
63
-        $langFilter = new Twig_SimpleFilter('lang_name', function ($langcode, $lang) {
63
+        $langFilter = new Twig_SimpleFilter('lang_name', function($langcode, $lang) {
64 64
             return Language::getName($langcode, $lang);
65 65
         });
66 66
         $this->twig->addFilter($langFilter);
@@ -235,16 +235,16 @@  discard block
 block discarded – undo
235 235
 
236 236
     private function createFeedbackHeaders($fromName, $fromEmail, $toMail, $sender)
237 237
     {
238
-        $headers = "MIME-Version: 1.0" . "\r\n";
239
-        $headers .= "Content-type: text/html; charset=UTF-8" . "\r\n";
238
+        $headers = "MIME-Version: 1.0"."\r\n";
239
+        $headers .= "Content-type: text/html; charset=UTF-8"."\r\n";
240 240
         if (!empty($toMail)) {
241
-            $headers .= "Cc: " . $this->model->getConfig()->getFeedbackAddress() . "\r\n";
241
+            $headers .= "Cc: ".$this->model->getConfig()->getFeedbackAddress()."\r\n";
242 242
         }
243 243
         if (!empty($fromEmail)) {
244 244
             $headers .= "Reply-To: $fromName <$fromEmail>\r\n";
245 245
         }
246 246
         $service = $this->model->getConfig()->getServiceName();
247
-        return $headers . "From: $fromName via $service <$sender>";
247
+        return $headers."From: $fromName via $service <$sender>";
248 248
     }
249 249
 
250 250
     /**
@@ -258,9 +258,9 @@  discard block
 block discarded – undo
258 258
     public function sendFeedback($request, $message, $messageSubject, $fromName = null, $fromEmail = null, $fromVocab = null, $toMail = null)
259 259
     {
260 260
         $toAddress = ($toMail) ? $toMail : $this->model->getConfig()->getFeedbackAddress();
261
-        $messageSubject = "[" . $this->model->getConfig()->getServiceName() . "] " . $messageSubject;
261
+        $messageSubject = "[".$this->model->getConfig()->getServiceName()."] ".$messageSubject;
262 262
         if ($fromVocab !== null && $fromVocab !== '') {
263
-            $message = 'Feedback from vocab: ' . strtoupper($fromVocab) . "<br />" . $message;
263
+            $message = 'Feedback from vocab: '.strtoupper($fromVocab)."<br />".$message;
264 264
         }
265 265
         $envelopeSender = $this->model->getConfig()->getFeedbackEnvelopeSender();
266 266
         // determine the sender address of the message
@@ -273,10 +273,10 @@  discard block
 block discarded – undo
273 273
         $headers = $this->createFeedbackHeaders($fromName, $fromEmail, $toMail, $sender);
274 274
         $params = empty($envelopeSender) ? '' : "-f $envelopeSender";
275 275
         // adding some information about the user for debugging purposes.
276
-        $message = $message . "<br /><br /> Debugging information:"
277
-            . "<br />Timestamp: " . date(DATE_RFC2822)
278
-            . "<br />User agent: " . $request->getServerConstant('HTTP_USER_AGENT')
279
-            . "<br />Referer: " . $request->getServerConstant('HTTP_REFERER');
276
+        $message = $message."<br /><br /> Debugging information:"
277
+            . "<br />Timestamp: ".date(DATE_RFC2822)
278
+            . "<br />User agent: ".$request->getServerConstant('HTTP_USER_AGENT')
279
+            . "<br />Referer: ".$request->getServerConstant('HTTP_REFERER');
280 280
 
281 281
         try {
282 282
             mail($toAddress, $messageSubject, $message, $headers, $params);
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
             header("HTTP/1.0 404 Not Found");
285 285
             $template = $this->twig->loadTemplate('error-page.twig');
286 286
             if ($this->model->getConfig()->getLogCaughtExceptions()) {
287
-                error_log('Caught exception: ' . $e->getMessage());
287
+                error_log('Caught exception: '.$e->getMessage());
288 288
             }
289 289
 
290 290
             echo $template->render(
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
         $vocids = ($vocabs !== null && $vocabs !== '') ? explode(' ', $vocabs) : null;
332 332
         $vocabObjects = array();
333 333
         if ($vocids) {
334
-            foreach($vocids as $vocid) {
334
+            foreach ($vocids as $vocid) {
335 335
                 $vocabObjects[] = $this->model->getVocabulary($vocid);
336 336
             }
337 337
         }
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
         } catch (Exception $e) {
343 343
             header("HTTP/1.0 404 Not Found");
344 344
             if ($this->model->getConfig()->getLogCaughtExceptions()) {
345
-                error_log('Caught exception: ' . $e->getMessage());
345
+                error_log('Caught exception: '.$e->getMessage());
346 346
             }
347 347
             $this->invokeGenericErrorPage($request, $e->getMessage());
348 348
             return;
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
                 'search_count' => $counts,
359 359
                 'languages' => $this->languages,
360 360
                 'search_results' => $searchResults,
361
-                'rest' => $parameters->getOffset()>0,
361
+                'rest' => $parameters->getOffset() > 0,
362 362
                 'global_search' => true,
363 363
                 'term' => $request->getQueryParamRaw('q'),
364 364
                 'lang_list' => $langList,
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
         } catch (Exception $e) {
384 384
             header("HTTP/1.0 404 Not Found");
385 385
             if ($this->model->getConfig()->getLogCaughtExceptions()) {
386
-                error_log('Caught exception: ' . $e->getMessage());
386
+                error_log('Caught exception: '.$e->getMessage());
387 387
             }
388 388
 
389 389
             echo $template->render(
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
         } catch (Exception $e) {
405 405
             header("HTTP/1.0 404 Not Found");
406 406
             if ($this->model->getConfig()->getLogCaughtExceptions()) {
407
-                error_log('Caught exception: ' . $e->getMessage());
407
+                error_log('Caught exception: '.$e->getMessage());
408 408
             }
409 409
 
410 410
             echo $template->render(
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
                 'vocab' => $vocab,
422 422
                 'search_results' => $searchResults,
423 423
                 'search_count' => $counts,
424
-                'rest' => $parameters->getOffset()>0,
424
+                'rest' => $parameters->getOffset() > 0,
425 425
                 'limit_parent' => $parameters->getParentLimit(),
426 426
                 'limit_type' =>  $request->getQueryParam('type') ? explode('+', $request->getQueryParam('type')) : null,
427 427
                 'limit_group' => $parameters->getGroupLimit(),
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
      * Loads and renders the view containing a list of recent changes in the vocabulary.
553 553
      * @param Request $request
554 554
      */
555
-    public function invokeChangeList($request, $prop='dc:created')
555
+    public function invokeChangeList($request, $prop = 'dc:created')
556 556
     {
557 557
         $offset = ($request->getQueryParam('offset') && is_numeric($request->getQueryParam('offset')) && $request->getQueryParam('offset') >= 0) ? $request->getQueryParam('offset') : 0;
558 558
         $limit = ($request->getQueryParam('limit') && is_numeric($request->getQueryParam('limit')) && $request->getQueryParam('limit') >= 0) ? $request->getQueryParam('limit') : 200;
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
      * @param int $limit maximum number of concepts to return
581 581
      * @return Array list of concepts
582 582
      */
583
-    public function getChangeList($request, $prop, $offset=0, $limit=200)
583
+    public function getChangeList($request, $prop, $offset = 0, $limit = 200)
584 584
     {
585 585
         // set language parameters for gettext
586 586
         $this->setLanguageProperties($request->getLang());
@@ -596,9 +596,9 @@  discard block
 block discarded – undo
596 596
     public function formatChangeList($changeList, $lang)
597 597
     {
598 598
         $formatByDate = array();
599
-        foreach($changeList as $concept) {
599
+        foreach ($changeList as $concept) {
600 600
             $concept['datestring'] = Punic\Calendar::formatDate($concept['date'], 'medium', $lang);
601
-            $formatByDate[Punic\Calendar::getMonthName($concept['date'], 'wide', $lang, true) . Punic\Calendar::format($concept['date'], ' y', $lang) ][strtolower($concept['prefLabel'])] = $concept;
601
+            $formatByDate[Punic\Calendar::getMonthName($concept['date'], 'wide', $lang, true).Punic\Calendar::format($concept['date'], ' y', $lang)][strtolower($concept['prefLabel'])] = $concept;
602 602
         }
603 603
         return $formatByDate;
604 604
     }
Please login to merge, or discard this patch.