Passed
Push — master ( 0cbb2e...6335df )
by Sébastien
12:28 queued 10:49
created
lib/Tag.php 4 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -47,6 +47,10 @@
 block discarded – undo
47 47
         return Base::getEntryArrayWithBookNumber (self::SQL_ALL_TAGS, self::TAG_COLUMNS, array (), "Tag");
48 48
     }
49 49
 
50
+    /**
51
+     * @param string $query
52
+     * @param integer $numberPerPage
53
+     */
50 54
     public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
51 55
         $columns  = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
52 56
         $sql = 'select {0} from tags where upper (tags.name) like ? {1} order by tags.name';
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -20,44 +20,44 @@
 block discarded – undo
20 20
         $this->name = $post->name;
21 21
     }
22 22
 
23
-    public function getUri () {
24
-        return "?page=".parent::PAGE_TAG_DETAIL."&id=$this->id";
23
+    public function getUri() {
24
+        return "?page=" . parent::PAGE_TAG_DETAIL . "&id=$this->id";
25 25
     }
26 26
 
27
-    public function getEntryId () {
28
-        return self::ALL_TAGS_ID.":".$this->id;
27
+    public function getEntryId() {
28
+        return self::ALL_TAGS_ID . ":" . $this->id;
29 29
     }
30 30
 
31 31
     public static function getCount() {
32 32
         // str_format (localize("tags.alphabetical", count(array))
33
-        return parent::getCountGeneric ("tags", self::ALL_TAGS_ID, parent::PAGE_ALL_TAGS);
33
+        return parent::getCountGeneric("tags", self::ALL_TAGS_ID, parent::PAGE_ALL_TAGS);
34 34
     }
35 35
 
36
-    public static function getTagById ($tagId) {
37
-        $result = parent::getDb ()->prepare('select id, name  from tags where id = ?');
38
-        $result->execute (array ($tagId));
39
-        if ($post = $result->fetchObject ()) {
40
-            return new Tag ($post);
36
+    public static function getTagById($tagId) {
37
+        $result = parent::getDb()->prepare('select id, name  from tags where id = ?');
38
+        $result->execute(array($tagId));
39
+        if ($post = $result->fetchObject()) {
40
+            return new Tag($post);
41 41
         }
42 42
         return NULL;
43 43
     }
44 44
 
45 45
     public static function getAllTags() {
46
-        return Base::getEntryArrayWithBookNumber (self::SQL_ALL_TAGS, self::TAG_COLUMNS, array (), "Tag");
46
+        return Base::getEntryArrayWithBookNumber(self::SQL_ALL_TAGS, self::TAG_COLUMNS, array(), "Tag");
47 47
     }
48 48
 
49 49
     public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
50
-        $columns  = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
50
+        $columns = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
51 51
         $sql = 'select {0} from tags where upper (tags.name) like ? {1} order by tags.name';
52
-        list ($totalNumber, $result) = parent::executeQuery ($sql, $columns, "", array ('%' . $query . '%'), $n, $database, $numberPerPage);
52
+        list ($totalNumber, $result) = parent::executeQuery($sql, $columns, "", array('%' . $query . '%'), $n, $database, $numberPerPage);
53 53
         $entryArray = array();
54
-        while ($post = $result->fetchObject ())
54
+        while ($post = $result->fetchObject())
55 55
         {
56
-            $tag = new Tag ($post);
57
-            array_push ($entryArray, new Entry ($tag->name, $tag->getEntryId (),
58
-                str_format (localize("bookword", $post->count), $post->count), "text",
59
-                array ( new LinkNavigation ($tag->getUri ()))));
56
+            $tag = new Tag($post);
57
+            array_push($entryArray, new Entry($tag->name, $tag->getEntryId(),
58
+                str_format(localize("bookword", $post->count), $post->count), "text",
59
+                array(new LinkNavigation($tag->getUri()))));
60 60
         }
61
-        return array ($entryArray, $totalNumber);
61
+        return array($entryArray, $totalNumber);
62 62
     }
63 63
 }
Please login to merge, or discard this patch.
Braces   +15 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,25 +15,30 @@  discard block
 block discarded – undo
15 15
     public $id;
16 16
     public $name;
17 17
 
18
-    public function __construct($post) {
18
+    public function __construct($post)
19
+    {
19 20
         $this->id = $post->id;
20 21
         $this->name = $post->name;
21 22
     }
22 23
 
23
-    public function getUri () {
24
+    public function getUri ()
25
+    {
24 26
         return "?page=".parent::PAGE_TAG_DETAIL."&id=$this->id";
25 27
     }
26 28
 
27
-    public function getEntryId () {
29
+    public function getEntryId ()
30
+    {
28 31
         return self::ALL_TAGS_ID.":".$this->id;
29 32
     }
30 33
 
31
-    public static function getCount() {
34
+    public static function getCount()
35
+    {
32 36
         // str_format (localize("tags.alphabetical", count(array))
33 37
         return parent::getCountGeneric ("tags", self::ALL_TAGS_ID, parent::PAGE_ALL_TAGS);
34 38
     }
35 39
 
36
-    public static function getTagById ($tagId) {
40
+    public static function getTagById ($tagId)
41
+    {
37 42
         $result = parent::getDb ()->prepare('select id, name  from tags where id = ?');
38 43
         $result->execute (array ($tagId));
39 44
         if ($post = $result->fetchObject ()) {
@@ -42,17 +47,18 @@  discard block
 block discarded – undo
42 47
         return NULL;
43 48
     }
44 49
 
45
-    public static function getAllTags() {
50
+    public static function getAllTags()
51
+    {
46 52
         return Base::getEntryArrayWithBookNumber (self::SQL_ALL_TAGS, self::TAG_COLUMNS, array (), "Tag");
47 53
     }
48 54
 
49
-    public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
55
+    public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL)
56
+    {
50 57
         $columns  = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
51 58
         $sql = 'select {0} from tags where upper (tags.name) like ? {1} order by tags.name';
52 59
         list ($totalNumber, $result) = parent::executeQuery ($sql, $columns, "", array ('%' . $query . '%'), $n, $database, $numberPerPage);
53 60
         $entryArray = array();
54
-        while ($post = $result->fetchObject ())
55
-        {
61
+        while ($post = $result->fetchObject ()) {
56 62
             $tag = new Tag ($post);
57 63
             array_push ($entryArray, new Entry ($tag->name, $tag->getEntryId (),
58 64
                 str_format (localize("bookword", $post->count), $post->count), "text",
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,14 +39,14 @@
 block discarded – undo
39 39
         if ($post = $result->fetchObject ()) {
40 40
             return new Tag ($post);
41 41
         }
42
-        return NULL;
42
+        return null;
43 43
     }
44 44
 
45 45
     public static function getAllTags() {
46 46
         return Base::getEntryArrayWithBookNumber (self::SQL_ALL_TAGS, self::TAG_COLUMNS, array (), "Tag");
47 47
     }
48 48
 
49
-    public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
49
+    public static function getAllTagsByQuery($query, $n, $database = null, $numberPerPage = null) {
50 50
         $columns  = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
51 51
         $sql = 'select {0} from tags where upper (tags.name) like ? {1} order by tags.name';
52 52
         list ($totalNumber, $result) = parent::executeQuery ($sql, $columns, "", array ('%' . $query . '%'), $n, $database, $numberPerPage);
Please login to merge, or discard this patch.
fetch.php 3 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
19 19
         }
20 20
     }
21 21
 
22
-    $expires = 60*60*24*14;
22
+    $expires = 60 * 60 * 24 * 14;
23 23
     header('Pragma: public');
24 24
     header('Cache-Control: maxage=' . $expires);
25
-    header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
25
+    header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');
26 26
     $bookId = getURLParam('id', NULL);
27 27
     $type   = getURLParam('type', 'jpg');
28 28
     $idData = getURLParam('data', NULL);
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     }
34 34
 
35 35
     if (!$book) {
36
-        notFound ();
36
+        notFound();
37 37
         return;
38 38
     }
39 39
 
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
             header('Content-Type: image/jpeg');
56 56
             //by default, we don't cache
57 57
             $thumbnailCacheFullpath = null;
58
-            if ( isset($config['cops_thumbnail_cache_directory']) && $config['cops_thumbnail_cache_directory'] !== '' ) {
58
+            if (isset($config['cops_thumbnail_cache_directory']) && $config['cops_thumbnail_cache_directory'] !== '') {
59 59
                 $thumbnailCacheFullpath = $config['cops_thumbnail_cache_directory'];
60 60
                 //if multiple databases, add a subfolder with the database ID
61
-                $thumbnailCacheFullpath .= !is_null(GetUrlParam (DB)) ? 'db-' . GetUrlParam (DB) . DIRECTORY_SEPARATOR : '';
61
+                $thumbnailCacheFullpath .= !is_null(GetUrlParam(DB))?'db-' . GetUrlParam(DB) . DIRECTORY_SEPARATOR:'';
62 62
                 //when there are lots of thumbnails, it's better to save files in subfolders, so if the book's uuid is
63 63
                 //"01234567-89ab-cdef-0123-456789abcdef", we will save the thumbnail in .../0/12/34567-89ab-cdef-0123-456789abcdef-...
64 64
                 $thumbnailCacheFullpath .= substr($book->uuid, 0, 1) . DIRECTORY_SEPARATOR . substr($book->uuid, 1, 2) . DIRECTORY_SEPARATOR;
65 65
                 //check if cache folder exists or create it
66
-                if ( file_exists($thumbnailCacheFullpath) || mkdir($thumbnailCacheFullpath, 0700, true) ) {
66
+                if (file_exists($thumbnailCacheFullpath) || mkdir($thumbnailCacheFullpath, 0700, true)) {
67 67
                     //we name the thumbnail from the book's uuid and it's dimensions (width and/or height)
68 68
                     $thumbnailCacheName = substr($book->uuid, 3) . '-' . getURLParam('width') . 'x' . getURLParam('height') . '.jpg';
69 69
                     $thumbnailCacheFullpath = $thumbnailCacheFullpath . $thumbnailCacheName;
@@ -73,20 +73,20 @@  discard block
 block discarded – undo
73 73
                 }
74 74
             }
75 75
 
76
-            if ( $thumbnailCacheFullpath !== null && file_exists($thumbnailCacheFullpath) ) {
76
+            if ($thumbnailCacheFullpath !== null && file_exists($thumbnailCacheFullpath)) {
77 77
                 //return the already cached thumbnail
78
-                readfile( $thumbnailCacheFullpath );
78
+                readfile($thumbnailCacheFullpath);
79 79
                 return;
80 80
             }
81 81
 
82
-            if ($book->getThumbnail (getURLParam('width'), getURLParam('height'), $thumbnailCacheFullpath)) {
82
+            if ($book->getThumbnail(getURLParam('width'), getURLParam('height'), $thumbnailCacheFullpath)) {
83 83
                 //if we don't cache the thumbnail, imagejpeg() in $book->getThumbnail() already return the image data
84
-                if ( $thumbnailCacheFullpath === null ) {
84
+                if ($thumbnailCacheFullpath === null) {
85 85
                     // The cover had to be resized
86 86
                     return;
87 87
                 } else {
88 88
                     //return the just cached thumbnail
89
-                    readfile( $thumbnailCacheFullpath );
89
+                    readfile($thumbnailCacheFullpath);
90 90
                     return;
91 91
                 }
92 92
             }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -49,8 +49,7 @@
 block discarded – undo
49 49
         }
50 50
     }
51 51
 
52
-    switch ($type)
53
-    {
52
+    switch ($type) {
54 53
         case 'jpg':
55 54
             header('Content-Type: image/jpeg');
56 55
             //by default, we don't cache
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,9 +23,9 @@
 block discarded – undo
23 23
     header('Pragma: public');
24 24
     header('Cache-Control: maxage=' . $expires);
25 25
     header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
26
-    $bookId = getURLParam('id', NULL);
26
+    $bookId = getURLParam('id', null);
27 27
     $type   = getURLParam('type', 'jpg');
28
-    $idData = getURLParam('data', NULL);
28
+    $idData = getURLParam('data', null);
29 29
     if (is_null($bookId)) {
30 30
         $book = Book::getBookByDataId($idData);
31 31
     } else {
Please login to merge, or discard this patch.
config_default.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
      *
190 190
      * Note that the composite custom columns are not supported
191 191
      */
192
-    $config['cops_calibre_custom_column_list'] = array ();
192
+    $config['cops_calibre_custom_column_list'] = array();
193 193
 
194 194
     /*
195 195
      * Custom Columns for the book preview panel
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
      *
200 200
      * Note that the composite custom columns are not supported
201 201
      */
202
-    $config['cops_calibre_custom_column_preview'] = array ();
202
+    $config['cops_calibre_custom_column_preview'] = array();
203 203
 
204 204
     /*
205 205
      * Rename .epub to .kepub.epub if downloaded from a Kobo eReader
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
      *                                           "address.from"  => "[email protected]"
232 232
      *                                           );
233 233
      */
234
-    $config['cops_mail_configuration'] = NULL;
234
+    $config['cops_mail_configuration'] = null;
235 235
 
236 236
     /*
237 237
      * Use filter in HTML catalog
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
      * array( "username" => "xxx", "password" => "secret") : Enable PHP password protection
304 304
      * NULL : Disable PHP password protection (You can still use htpasswd)
305 305
      */
306
-    $config['cops_basic_authentication'] = NULL;
306
+    $config['cops_basic_authentication'] = null;
307 307
 
308 308
     /*
309 309
      * Which template is used by default :
Please login to merge, or discard this patch.
epubreader.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 
16 16
 $idData = getURLParam('data', NULL);
17 17
 $add = 'data=' . $idData . '&';
18
-if (!is_null (GetUrlParam (DB))) {
19
-    $add .= DB . '=' . GetUrlParam (DB) . '&';
18
+if (!is_null(GetUrlParam(DB))) {
19
+    $add .= DB . '=' . GetUrlParam(DB) . '&';
20 20
 }
21 21
 $myBook = Book::getBookByDataId($idData);
22 22
 
@@ -37,10 +37,10 @@  discard block
 block discarded – undo
37 37
         Monocle.DEBUG = true;
38 38
         var bookData = {
39 39
           getComponents: function() {
40
-            <?php echo 'return [' . implode(', ', array_map(function($comp) { return "'" . $comp . "'"; }, $book->components ())) . '];'; ?>
40
+            <?php echo 'return [' . implode(', ', array_map(function($comp) { return "'" . $comp . "'"; }, $book->components())) . '];'; ?>
41 41
           },
42 42
           getContents: function() {
43
-            <?php echo 'return [' . implode(', ', array_map(function($content) { return "{title: '" . addslashes($content['title']) . "', src: '". $content['src'] . "'}"; }, $book->contents())) . '];'; ?>
43
+            <?php echo 'return [' . implode(', ', array_map(function($content) { return "{title: '" . addslashes($content['title']) . "', src: '" . $content['src'] . "'}"; }, $book->contents())) . '];'; ?>
44 44
           },
45 45
           getComponent: function (componentId) {
46 46
             return { url: "epubfs.php?<?php echo $add ?>comp="  + componentId };
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
 
14 14
 header('Content-Type: text/html;charset=utf-8');
15 15
 
16
-$idData = getURLParam('data', NULL);
16
+$idData = getURLParam('data', null);
17 17
 $add = 'data=' . $idData . '&';
18 18
 if (!is_null (GetUrlParam (DB))) {
19 19
     $add .= DB . '=' . GetUrlParam (DB) . '&';
Please login to merge, or discard this patch.
index.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -37,14 +37,14 @@
 block discarded – undo
37 37
     header('Content-Type:text/html;charset=utf-8');
38 38
 
39 39
     $data = array('title'                 => $config['cops_title_default'],
40
-                  'version'               => VERSION,
41
-                  'opds_url'              => $config['cops_full_url'] . 'feed.php',
42
-                  'customHeader'          => '',
43
-                  'template'              => getCurrentTemplate(),
44
-                  'server_side_rendering' => useServerSideRendering(),
45
-                  'current_css'           => getCurrentCss(),
46
-                  'favico'                => $config['cops_icon'],
47
-                  'getjson_url'           => 'getJSON.php?' . addURLParameter(getQueryString(), 'complete', 1));
40
+                    'version'               => VERSION,
41
+                    'opds_url'              => $config['cops_full_url'] . 'feed.php',
42
+                    'customHeader'          => '',
43
+                    'template'              => getCurrentTemplate(),
44
+                    'server_side_rendering' => useServerSideRendering(),
45
+                    'current_css'           => getCurrentCss(),
46
+                    'favico'                => $config['cops_icon'],
47
+                    'getjson_url'           => 'getJSON.php?' . addURLParameter(getQueryString(), 'complete', 1));
48 48
     if (preg_match('/Kindle/', $_SERVER['HTTP_USER_AGENT'])) {
49 49
         $data['customHeader'] = '<style media="screen" type="text/css"> html { font-size: 75%; -webkit-text-size-adjust: 75%; -ms-text-size-adjust: 75%; }</style>';
50 50
     }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
     }
51 51
     $headcontent = file_get_contents('templates/' . getCurrentTemplate() . '/file.html');
52 52
     $template = new doT();
53
-    $dot = $template->template($headcontent, NULL);
53
+    $dot = $template->template($headcontent, null);
54 54
     echo($dot($data));
55 55
 ?><body>
56 56
 <?php
Please login to merge, or discard this patch.
transliteration.php 4 patches
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -26,56 +26,56 @@  discard block
 block discarded – undo
26 26
  *   Transliterated text.
27 27
  */
28 28
 function _transliteration_process($string, $unknown = '?', $source_langcode = NULL) {
29
-  // ASCII is always valid NFC! If we're only ever given plain ASCII, we can
30
-  // avoid the overhead of initializing the decomposition tables by skipping
31
-  // out early.
32
-  if (!preg_match('/[\x80-\xff]/', $string)) {
29
+    // ASCII is always valid NFC! If we're only ever given plain ASCII, we can
30
+    // avoid the overhead of initializing the decomposition tables by skipping
31
+    // out early.
32
+    if (!preg_match('/[\x80-\xff]/', $string)) {
33 33
     return $string;
34
-  }
34
+    }
35 35
 
36
-  static $tail_bytes;
36
+    static $tail_bytes;
37 37
 
38
-  if (!isset($tail_bytes)) {
38
+    if (!isset($tail_bytes)) {
39 39
     // Each UTF-8 head byte is followed by a certain number of tail bytes.
40 40
     $tail_bytes = array();
41 41
     for ($n = 0; $n < 256; $n++) {
42
-      if ($n < 0xc0) {
42
+        if ($n < 0xc0) {
43 43
         $remaining = 0;
44
-      }
45
-      elseif ($n < 0xe0) {
44
+        }
45
+        elseif ($n < 0xe0) {
46 46
         $remaining = 1;
47
-      }
48
-      elseif ($n < 0xf0) {
47
+        }
48
+        elseif ($n < 0xf0) {
49 49
         $remaining = 2;
50
-      }
51
-      elseif ($n < 0xf8) {
50
+        }
51
+        elseif ($n < 0xf8) {
52 52
         $remaining = 3;
53
-      }
54
-      elseif ($n < 0xfc) {
53
+        }
54
+        elseif ($n < 0xfc) {
55 55
         $remaining = 4;
56
-      }
57
-      elseif ($n < 0xfe) {
56
+        }
57
+        elseif ($n < 0xfe) {
58 58
         $remaining = 5;
59
-      }
60
-      else {
59
+        }
60
+        else {
61 61
         $remaining = 0;
62
-      }
63
-      $tail_bytes[chr($n)] = $remaining;
62
+        }
63
+        $tail_bytes[chr($n)] = $remaining;
64
+    }
64 65
     }
65
-  }
66 66
 
67
-  // Chop the text into pure-ASCII and non-ASCII areas; large ASCII parts can
68
-  // be handled much more quickly. Don't chop up Unicode areas for punctuation,
69
-  // though, that wastes energy.
70
-  preg_match_all('/[\x00-\x7f]+|[\x80-\xff][\x00-\x40\x5b-\x5f\x7b-\xff]*/', $string, $matches);
67
+    // Chop the text into pure-ASCII and non-ASCII areas; large ASCII parts can
68
+    // be handled much more quickly. Don't chop up Unicode areas for punctuation,
69
+    // though, that wastes energy.
70
+    preg_match_all('/[\x00-\x7f]+|[\x80-\xff][\x00-\x40\x5b-\x5f\x7b-\xff]*/', $string, $matches);
71 71
 
72
-  $result = '';
73
-  foreach ($matches[0] as $str) {
72
+    $result = '';
73
+    foreach ($matches[0] as $str) {
74 74
     if ($str[0] < "\x80") {
75
-      // ASCII chunk: guaranteed to be valid UTF-8 and in normal form C, so
76
-      // skip over it.
77
-      $result .= $str;
78
-      continue;
75
+        // ASCII chunk: guaranteed to be valid UTF-8 and in normal form C, so
76
+        // skip over it.
77
+        $result .= $str;
78
+        continue;
79 79
     }
80 80
 
81 81
     // We'll have to examine the chunk byte by byte to ensure that it consists
@@ -91,72 +91,72 @@  discard block
 block discarded – undo
91 91
     $len = $chunk + 1;
92 92
 
93 93
     for ($i = -1; --$len; ) {
94
-      $c = $str[++$i];
95
-      if ($remaining = $tail_bytes[$c]) {
94
+        $c = $str[++$i];
95
+        if ($remaining = $tail_bytes[$c]) {
96 96
         // UTF-8 head byte!
97 97
         $sequence = $head = $c;
98 98
         do {
99
-          // Look for the defined number of tail bytes...
100
-          if (--$len && ($c = $str[++$i]) >= "\x80" && $c < "\xc0") {
99
+            // Look for the defined number of tail bytes...
100
+            if (--$len && ($c = $str[++$i]) >= "\x80" && $c < "\xc0") {
101 101
             // Legal tail bytes are nice.
102 102
             $sequence .= $c;
103
-          }
104
-          else {
103
+            }
104
+            else {
105 105
             if ($len == 0) {
106
-              // Premature end of string! Drop a replacement character into
107
-              // output to represent the invalid UTF-8 sequence.
108
-              $result .= $unknown;
109
-              break 2;
106
+                // Premature end of string! Drop a replacement character into
107
+                // output to represent the invalid UTF-8 sequence.
108
+                $result .= $unknown;
109
+                break 2;
110 110
             }
111 111
             else {
112
-              // Illegal tail byte; abandon the sequence.
113
-              $result .= $unknown;
114
-              // Back up and reprocess this byte; it may itself be a legal
115
-              // ASCII or UTF-8 sequence head.
116
-              --$i;
117
-              ++$len;
118
-              continue 2;
112
+                // Illegal tail byte; abandon the sequence.
113
+                $result .= $unknown;
114
+                // Back up and reprocess this byte; it may itself be a legal
115
+                // ASCII or UTF-8 sequence head.
116
+                --$i;
117
+                ++$len;
118
+                continue 2;
119
+            }
119 120
             }
120
-          }
121 121
         } while (--$remaining);
122 122
 
123 123
         $n = ord($head);
124 124
         if ($n <= 0xdf) {
125
-          $ord = ($n - 192) * 64 + (ord($sequence[1]) - 128);
125
+            $ord = ($n - 192) * 64 + (ord($sequence[1]) - 128);
126 126
         }
127 127
         elseif ($n <= 0xef) {
128
-          $ord = ($n - 224) * 4096 + (ord($sequence[1]) - 128) * 64 + (ord($sequence[2]) - 128);
128
+            $ord = ($n - 224) * 4096 + (ord($sequence[1]) - 128) * 64 + (ord($sequence[2]) - 128);
129 129
         }
130 130
         elseif ($n <= 0xf7) {
131
-          $ord = ($n - 240) * 262144 + (ord($sequence[1]) - 128) * 4096 + (ord($sequence[2]) - 128) * 64 + (ord($sequence[3]) - 128);
131
+            $ord = ($n - 240) * 262144 + (ord($sequence[1]) - 128) * 4096 + (ord($sequence[2]) - 128) * 64 + (ord($sequence[3]) - 128);
132 132
         }
133 133
         elseif ($n <= 0xfb) {
134
-          $ord = ($n - 248) * 16777216 + (ord($sequence[1]) - 128) * 262144 + (ord($sequence[2]) - 128) * 4096 + (ord($sequence[3]) - 128) * 64 + (ord($sequence[4]) - 128);
134
+            $ord = ($n - 248) * 16777216 + (ord($sequence[1]) - 128) * 262144 + (ord($sequence[2]) - 128) * 4096 + (ord($sequence[3]) - 128) * 64 + (ord($sequence[4]) - 128);
135 135
         }
136 136
         elseif ($n <= 0xfd) {
137
-          $ord = ($n - 252) * 1073741824 + (ord($sequence[1]) - 128) * 16777216 + (ord($sequence[2]) - 128) * 262144 + (ord($sequence[3]) - 128) * 4096 + (ord($sequence[4]) - 128) * 64 + (ord($sequence[5]) - 128);
137
+            $ord = ($n - 252) * 1073741824 + (ord($sequence[1]) - 128) * 16777216 + (ord($sequence[2]) - 128) * 262144 + (ord($sequence[3]) - 128) * 4096 + (ord($sequence[4]) - 128) * 64 + (ord($sequence[5]) - 128);
138 138
         } else {
139
-          $ord = $n;
139
+            $ord = $n;
140 140
         }
141 141
         $result .= _transliteration_replace($ord, $unknown, $source_langcode);
142 142
         $head = '';
143
-      } elseif ($c < "\x80") {
143
+        } elseif ($c < "\x80") {
144 144
         // ASCII byte.
145 145
         $result .= $c;
146 146
         $head = '';
147
-      } elseif ($c < "\xc0") {
147
+        } elseif ($c < "\xc0") {
148 148
         // Illegal tail bytes.
149 149
         if ($head == '') {
150
-          $result .= $unknown;
150
+            $result .= $unknown;
151 151
         }
152
-      } else {
152
+        } else {
153 153
         // Miscellaneous freaks.
154 154
         $result .= $unknown;
155 155
         $head = '';
156
-      }
156
+        }
157 157
     }
158
-  }
159
-  return $result;
158
+    }
159
+    return $result;
160 160
 }
161 161
 
162 162
 /**
@@ -175,38 +175,38 @@  discard block
 block discarded – undo
175 175
  *   ASCII replacement character.
176 176
  */
177 177
 function _transliteration_replace($ord, $unknown = '?', $langcode = NULL) {
178
-  static $map = array();
178
+    static $map = array();
179 179
 
180
-  //GL: set language later
181
-  /*
180
+    //GL: set language later
181
+    /*
182 182
   if (!isset($langcode)) {
183 183
     global $language;
184 184
     $langcode = $language->language;
185 185
   }
186 186
   */
187 187
 
188
-  $bank = $ord >> 8;
188
+    $bank = $ord >> 8;
189 189
 
190
-  if (!isset($map[$bank][$langcode])) {
190
+    if (!isset($map[$bank][$langcode])) {
191 191
     $file = './resources/transliteration-data/' . sprintf('x%02x', $bank) . '.php';  
192 192
     if (file_exists($file)) {
193
-      $base = array();
194
-      $variant = array();
195
-      include $file;
196
-      if ($langcode != 'en' && isset($variant[$langcode])) {
193
+        $base = array();
194
+        $variant = array();
195
+        include $file;
196
+        if ($langcode != 'en' && isset($variant[$langcode])) {
197 197
         // Merge in language specific mappings.
198 198
         $map[$bank][$langcode] = $variant[$langcode] + $base;
199
-      }
200
-      else {
199
+        }
200
+        else {
201 201
         $map[$bank][$langcode] = $base;
202
-      }
202
+        }
203 203
     }
204 204
     else {
205
-      $map[$bank][$langcode] = array();
205
+        $map[$bank][$langcode] = array();
206
+    }
206 207
     }
207
-  }
208 208
 
209
-  $ord = $ord & 255;
209
+    $ord = $ord & 255;
210 210
 
211
-  return isset($map[$bank][$langcode][$ord]) ? $map[$bank][$langcode][$ord] : $unknown;
211
+    return isset($map[$bank][$langcode][$ord]) ? $map[$bank][$langcode][$ord] : $unknown;
212 212
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
     // Counting down is faster. I'm *so* sorry.
91 91
     $len = $chunk + 1;
92 92
 
93
-    for ($i = -1; --$len; ) {
93
+    for ($i = -1; --$len;) {
94 94
       $c = $str[++$i];
95 95
       if ($remaining = $tail_bytes[$c]) {
96 96
         // UTF-8 head byte!
@@ -208,5 +208,5 @@  discard block
 block discarded – undo
208 208
 
209 209
   $ord = $ord & 255;
210 210
 
211
-  return isset($map[$bank][$langcode][$ord]) ? $map[$bank][$langcode][$ord] : $unknown;
211
+  return isset($map[$bank][$langcode][$ord])?$map[$bank][$langcode][$ord]:$unknown;
212 212
 }
Please login to merge, or discard this patch.
Braces   +18 added lines, -30 removed lines patch added patch discarded remove patch
@@ -25,7 +25,8 @@  discard block
 block discarded – undo
25 25
  * @return
26 26
  *   Transliterated text.
27 27
  */
28
-function _transliteration_process($string, $unknown = '?', $source_langcode = NULL) {
28
+function _transliteration_process($string, $unknown = '?', $source_langcode = NULL)
29
+{
29 30
   // ASCII is always valid NFC! If we're only ever given plain ASCII, we can
30 31
   // avoid the overhead of initializing the decomposition tables by skipping
31 32
   // out early.
@@ -41,23 +42,17 @@  discard block
 block discarded – undo
41 42
     for ($n = 0; $n < 256; $n++) {
42 43
       if ($n < 0xc0) {
43 44
         $remaining = 0;
44
-      }
45
-      elseif ($n < 0xe0) {
45
+      } elseif ($n < 0xe0) {
46 46
         $remaining = 1;
47
-      }
48
-      elseif ($n < 0xf0) {
47
+      } elseif ($n < 0xf0) {
49 48
         $remaining = 2;
50
-      }
51
-      elseif ($n < 0xf8) {
49
+      } elseif ($n < 0xf8) {
52 50
         $remaining = 3;
53
-      }
54
-      elseif ($n < 0xfc) {
51
+      } elseif ($n < 0xfc) {
55 52
         $remaining = 4;
56
-      }
57
-      elseif ($n < 0xfe) {
53
+      } elseif ($n < 0xfe) {
58 54
         $remaining = 5;
59
-      }
60
-      else {
55
+      } else {
61 56
         $remaining = 0;
62 57
       }
63 58
       $tail_bytes[chr($n)] = $remaining;
@@ -100,15 +95,13 @@  discard block
 block discarded – undo
100 95
           if (--$len && ($c = $str[++$i]) >= "\x80" && $c < "\xc0") {
101 96
             // Legal tail bytes are nice.
102 97
             $sequence .= $c;
103
-          }
104
-          else {
98
+          } else {
105 99
             if ($len == 0) {
106 100
               // Premature end of string! Drop a replacement character into
107 101
               // output to represent the invalid UTF-8 sequence.
108 102
               $result .= $unknown;
109 103
               break 2;
110
-            }
111
-            else {
104
+            } else {
112 105
               // Illegal tail byte; abandon the sequence.
113 106
               $result .= $unknown;
114 107
               // Back up and reprocess this byte; it may itself be a legal
@@ -123,17 +116,13 @@  discard block
 block discarded – undo
123 116
         $n = ord($head);
124 117
         if ($n <= 0xdf) {
125 118
           $ord = ($n - 192) * 64 + (ord($sequence[1]) - 128);
126
-        }
127
-        elseif ($n <= 0xef) {
119
+        } elseif ($n <= 0xef) {
128 120
           $ord = ($n - 224) * 4096 + (ord($sequence[1]) - 128) * 64 + (ord($sequence[2]) - 128);
129
-        }
130
-        elseif ($n <= 0xf7) {
121
+        } elseif ($n <= 0xf7) {
131 122
           $ord = ($n - 240) * 262144 + (ord($sequence[1]) - 128) * 4096 + (ord($sequence[2]) - 128) * 64 + (ord($sequence[3]) - 128);
132
-        }
133
-        elseif ($n <= 0xfb) {
123
+        } elseif ($n <= 0xfb) {
134 124
           $ord = ($n - 248) * 16777216 + (ord($sequence[1]) - 128) * 262144 + (ord($sequence[2]) - 128) * 4096 + (ord($sequence[3]) - 128) * 64 + (ord($sequence[4]) - 128);
135
-        }
136
-        elseif ($n <= 0xfd) {
125
+        } elseif ($n <= 0xfd) {
137 126
           $ord = ($n - 252) * 1073741824 + (ord($sequence[1]) - 128) * 16777216 + (ord($sequence[2]) - 128) * 262144 + (ord($sequence[3]) - 128) * 4096 + (ord($sequence[4]) - 128) * 64 + (ord($sequence[5]) - 128);
138 127
         } else {
139 128
           $ord = $n;
@@ -174,7 +163,8 @@  discard block
 block discarded – undo
174 163
  * @return
175 164
  *   ASCII replacement character.
176 165
  */
177
-function _transliteration_replace($ord, $unknown = '?', $langcode = NULL) {
166
+function _transliteration_replace($ord, $unknown = '?', $langcode = NULL)
167
+{
178 168
   static $map = array();
179 169
 
180 170
   //GL: set language later
@@ -196,12 +186,10 @@  discard block
 block discarded – undo
196 186
       if ($langcode != 'en' && isset($variant[$langcode])) {
197 187
         // Merge in language specific mappings.
198 188
         $map[$bank][$langcode] = $variant[$langcode] + $base;
199
-      }
200
-      else {
189
+      } else {
201 190
         $map[$bank][$langcode] = $base;
202 191
       }
203
-    }
204
-    else {
192
+    } else {
205 193
       $map[$bank][$langcode] = array();
206 194
     }
207 195
   }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  * @return
26 26
  *   Transliterated text.
27 27
  */
28
-function _transliteration_process($string, $unknown = '?', $source_langcode = NULL) {
28
+function _transliteration_process($string, $unknown = '?', $source_langcode = null) {
29 29
   // ASCII is always valid NFC! If we're only ever given plain ASCII, we can
30 30
   // avoid the overhead of initializing the decomposition tables by skipping
31 31
   // out early.
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
  * @return
175 175
  *   ASCII replacement character.
176 176
  */
177
-function _transliteration_replace($ord, $unknown = '?', $langcode = NULL) {
177
+function _transliteration_replace($ord, $unknown = '?', $langcode = null) {
178 178
   static $map = array();
179 179
 
180 180
   //GL: set language later
Please login to merge, or discard this patch.
lib/CustomColumnTypeInteger.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,9 @@
 block discarded – undo
55 55
     public function getDescription()
56 56
     {
57 57
         $desc = $this->getDatabaseDescription();
58
-        if ($desc === NULL || empty($desc)) $desc = str_format(localize("customcolumn.description"), $this->getTitle());
58
+        if ($desc === NULL || empty($desc)) {
59
+            $desc = str_format(localize("customcolumn.description"), $this->getTitle());
60
+        }
59 61
         return $desc;
60 62
     }
61 63
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     public function getDescription()
56 56
     {
57 57
         $desc = $this->getDatabaseDescription();
58
-        if ($desc === NULL || empty($desc)) $desc = str_format(localize("customcolumn.description"), $this->getTitle());
58
+        if ($desc === null || empty($desc)) $desc = str_format(localize("customcolumn.description"), $this->getTitle());
59 59
         return $desc;
60 60
     }
61 61
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         if ($post = $result->fetchObject()) {
69 69
             return new CustomColumn($post->value, $post->value, $this);
70 70
         }
71
-        return new CustomColumn(NULL, localize("customcolumn.int.unknown"), $this);
71
+        return new CustomColumn(null, localize("customcolumn.int.unknown"), $this);
72 72
     }
73 73
 
74 74
     public function isSearchable()
Please login to merge, or discard this patch.
lib/PageAllAuthorsLetter.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,10 +8,10 @@
 block discarded – undo
8 8
 
9 9
 class PageAllAuthorsLetter extends Page
10 10
 {
11
-    public function InitializeContent ()
11
+    public function InitializeContent()
12 12
     {
13
-        $this->idPage = Author::getEntryIdByLetter ($this->idGet);
14
-        $this->entryArray = Author::getAuthorsByStartingLetter ($this->idGet);
15
-        $this->title = str_format (localize ("splitByLetter.letter"), str_format (localize ("authorword", count ($this->entryArray)), count ($this->entryArray)), $this->idGet);
13
+        $this->idPage = Author::getEntryIdByLetter($this->idGet);
14
+        $this->entryArray = Author::getAuthorsByStartingLetter($this->idGet);
15
+        $this->title = str_format(localize("splitByLetter.letter"), str_format(localize("authorword", count($this->entryArray)), count($this->entryArray)), $this->idGet);
16 16
     }
17 17
 }
Please login to merge, or discard this patch.
lib/Serie.php 4 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -21,44 +21,44 @@
 block discarded – undo
21 21
         $this->name = $post->name;
22 22
     }
23 23
 
24
-    public function getUri () {
25
-        return "?page=".parent::PAGE_SERIE_DETAIL."&id=$this->id";
24
+    public function getUri() {
25
+        return "?page=" . parent::PAGE_SERIE_DETAIL . "&id=$this->id";
26 26
     }
27 27
 
28
-    public function getEntryId () {
29
-        return self::ALL_SERIES_ID.":".$this->id;
28
+    public function getEntryId() {
29
+        return self::ALL_SERIES_ID . ":" . $this->id;
30 30
     }
31 31
 
32 32
     public static function getCount() {
33 33
         // str_format (localize("series.alphabetical", count(array))
34
-        return parent::getCountGeneric ("series", self::ALL_SERIES_ID, parent::PAGE_ALL_SERIES);
34
+        return parent::getCountGeneric("series", self::ALL_SERIES_ID, parent::PAGE_ALL_SERIES);
35 35
     }
36 36
 
37
-    public static function getSerieByBookId ($bookId) {
38
-        $result = parent::getDb ()->prepare('select  series.id as id, name
37
+    public static function getSerieByBookId($bookId) {
38
+        $result = parent::getDb()->prepare('select  series.id as id, name
39 39
 from books_series_link, series
40 40
 where series.id = series and book = ?');
41
-        $result->execute (array ($bookId));
42
-        if ($post = $result->fetchObject ()) {
43
-            return new Serie ($post);
41
+        $result->execute(array($bookId));
42
+        if ($post = $result->fetchObject()) {
43
+            return new Serie($post);
44 44
         }
45 45
         return NULL;
46 46
     }
47 47
 
48
-    public static function getSerieById ($serieId) {
49
-        $result = parent::getDb ()->prepare('select id, name  from series where id = ?');
50
-        $result->execute (array ($serieId));
51
-        if ($post = $result->fetchObject ()) {
52
-            return new Serie ($post);
48
+    public static function getSerieById($serieId) {
49
+        $result = parent::getDb()->prepare('select id, name  from series where id = ?');
50
+        $result->execute(array($serieId));
51
+        if ($post = $result->fetchObject()) {
52
+            return new Serie($post);
53 53
         }
54 54
         return NULL;
55 55
     }
56 56
 
57 57
     public static function getAllSeries() {
58
-        return Base::getEntryArrayWithBookNumber (self::SQL_ALL_SERIES, self::SERIES_COLUMNS, array (), "Serie");
58
+        return Base::getEntryArrayWithBookNumber(self::SQL_ALL_SERIES, self::SERIES_COLUMNS, array(), "Serie");
59 59
     }
60 60
 
61 61
     public static function getAllSeriesByQuery($query) {
62
-        return Base::getEntryArrayWithBookNumber (self::SQL_SERIES_FOR_SEARCH, self::SERIES_COLUMNS, array ('%' . $query . '%'), "Serie");
62
+        return Base::getEntryArrayWithBookNumber(self::SQL_SERIES_FOR_SEARCH, self::SERIES_COLUMNS, array('%' . $query . '%'), "Serie");
63 63
     }
64 64
 }
Please login to merge, or discard this patch.
Braces   +16 added lines, -8 removed lines patch added patch discarded remove patch
@@ -16,25 +16,30 @@  discard block
 block discarded – undo
16 16
     public $id;
17 17
     public $name;
18 18
 
19
-    public function __construct($post) {
19
+    public function __construct($post)
20
+    {
20 21
         $this->id = $post->id;
21 22
         $this->name = $post->name;
22 23
     }
23 24
 
24
-    public function getUri () {
25
+    public function getUri ()
26
+    {
25 27
         return "?page=".parent::PAGE_SERIE_DETAIL."&id=$this->id";
26 28
     }
27 29
 
28
-    public function getEntryId () {
30
+    public function getEntryId ()
31
+    {
29 32
         return self::ALL_SERIES_ID.":".$this->id;
30 33
     }
31 34
 
32
-    public static function getCount() {
35
+    public static function getCount()
36
+    {
33 37
         // str_format (localize("series.alphabetical", count(array))
34 38
         return parent::getCountGeneric ("series", self::ALL_SERIES_ID, parent::PAGE_ALL_SERIES);
35 39
     }
36 40
 
37
-    public static function getSerieByBookId ($bookId) {
41
+    public static function getSerieByBookId ($bookId)
42
+    {
38 43
         $result = parent::getDb ()->prepare('select  series.id as id, name
39 44
 from books_series_link, series
40 45
 where series.id = series and book = ?');
@@ -45,7 +50,8 @@  discard block
 block discarded – undo
45 50
         return NULL;
46 51
     }
47 52
 
48
-    public static function getSerieById ($serieId) {
53
+    public static function getSerieById ($serieId)
54
+    {
49 55
         $result = parent::getDb ()->prepare('select id, name  from series where id = ?');
50 56
         $result->execute (array ($serieId));
51 57
         if ($post = $result->fetchObject ()) {
@@ -54,11 +60,13 @@  discard block
 block discarded – undo
54 60
         return NULL;
55 61
     }
56 62
 
57
-    public static function getAllSeries() {
63
+    public static function getAllSeries()
64
+    {
58 65
         return Base::getEntryArrayWithBookNumber (self::SQL_ALL_SERIES, self::SERIES_COLUMNS, array (), "Serie");
59 66
     }
60 67
 
61
-    public static function getAllSeriesByQuery($query) {
68
+    public static function getAllSeriesByQuery($query)
69
+    {
62 70
         return Base::getEntryArrayWithBookNumber (self::SQL_SERIES_FOR_SEARCH, self::SERIES_COLUMNS, array ('%' . $query . '%'), "Serie");
63 71
     }
64 72
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         if ($post = $result->fetchObject ()) {
43 43
             return new Serie ($post);
44 44
         }
45
-        return NULL;
45
+        return null;
46 46
     }
47 47
 
48 48
     public static function getSerieById ($serieId) {
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         if ($post = $result->fetchObject ()) {
52 52
             return new Serie ($post);
53 53
         }
54
-        return NULL;
54
+        return null;
55 55
     }
56 56
 
57 57
     public static function getAllSeries() {
Please login to merge, or discard this patch.
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -58,6 +58,9 @@
 block discarded – undo
58 58
         return Base::getEntryArrayWithBookNumber (self::SQL_ALL_SERIES, self::SERIES_COLUMNS, array (), "Serie");
59 59
     }
60 60
 
61
+    /**
62
+     * @param string $query
63
+     */
61 64
     public static function getAllSeriesByQuery($query) {
62 65
         return Base::getEntryArrayWithBookNumber (self::SQL_SERIES_FOR_SEARCH, self::SERIES_COLUMNS, array ('%' . $query . '%'), "Serie");
63 66
     }
Please login to merge, or discard this patch.