Completed
Push — master ( 306060...2234f3 )
by Markus
03:46
created
sendtomail.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -78,9 +78,9 @@
 block discarded – undo
78 78
 $mail->AltBody = "Sent by COPS";
79 79
 
80 80
 if (!$mail->Send()) {
81
-   echo localize ("mail.messagenotsent");
82
-   echo 'Mailer Error: ' . $mail->ErrorInfo;
83
-   exit;
81
+    echo localize ("mail.messagenotsent");
82
+    echo 'Mailer Error: ' . $mail->ErrorInfo;
83
+    exit;
84 84
 }
85 85
 
86 86
 echo localize ("mail.messagesent");
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -2,11 +2,11 @@  discard block
 block discarded – undo
2 2
 
3 3
 require_once ("config.php");
4 4
 
5
-function checkConfiguration () {
5
+function checkConfiguration() {
6 6
     global $config;
7 7
 
8
-    if (is_null ($config['cops_mail_configuration']) ||
9
-        !is_array ($config['cops_mail_configuration']) ||
8
+    if (is_null($config['cops_mail_configuration']) ||
9
+        !is_array($config['cops_mail_configuration']) ||
10 10
         empty ($config['cops_mail_configuration']["smtp.host"]) ||
11 11
         empty ($config['cops_mail_configuration']["address.from"])) {
12 12
         return "NOK. bad configuration.";
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
     return False;
15 15
 }
16 16
 
17
-function checkRequest ($idData, $emailDest) {
17
+function checkRequest($idData, $emailDest) {
18 18
     if (empty ($idData)) {
19 19
         return 'No data sent.';
20 20
     }
@@ -28,22 +28,22 @@  discard block
 block discarded – undo
28 28
 
29 29
 global $config;
30 30
 
31
-if ($error = checkConfiguration ()) {
31
+if ($error = checkConfiguration()) {
32 32
     echo $error;
33 33
     exit;
34 34
 }
35 35
 
36 36
 $idData = $_REQUEST["data"];
37 37
 $emailDest = $_REQUEST["email"];
38
-if ($error = checkRequest ($idData, $emailDest)) {
38
+if ($error = checkRequest($idData, $emailDest)) {
39 39
     echo $error;
40 40
     exit;
41 41
 }
42 42
 
43 43
 $book = Book::getBookByDataId($idData);
44
-$data = $book->getDataById ($idData);
44
+$data = $book->getDataById($idData);
45 45
 
46
-if (filesize ($data->getLocalPath ()) > 10 * 1024 * 1024) {
46
+if (filesize($data->getLocalPath()) > 10 * 1024 * 1024) {
47 47
     echo 'Attachment too big';
48 48
     exit;
49 49
 }
@@ -65,23 +65,23 @@  discard block
 block discarded – undo
65 65
 $mail->From = $config['cops_mail_configuration']["address.from"];
66 66
 $mail->FromName = $config['cops_title_default'];
67 67
 
68
-foreach (explode (";", $emailDest) as $emailAddress) {
68
+foreach (explode(";", $emailDest) as $emailAddress) {
69 69
     if (empty ($emailAddress)) { continue; }
70 70
     $mail->AddAddress($emailAddress);
71 71
 }
72 72
 
73
-$mail->AddAttachment($data->getLocalPath ());
73
+$mail->AddAttachment($data->getLocalPath());
74 74
 
75 75
 $mail->IsHTML(true);
76
-$mail->Subject = 'Sent by COPS : ' . $data->getUpdatedFilename ();
77
-$mail->Body    = "<h1>" . $book->title . "</h1><h2>" . $book->getAuthorsName () . "</h2>" . $book->getComment ();
76
+$mail->Subject = 'Sent by COPS : ' . $data->getUpdatedFilename();
77
+$mail->Body    = "<h1>" . $book->title . "</h1><h2>" . $book->getAuthorsName() . "</h2>" . $book->getComment();
78 78
 $mail->AltBody = "Sent by COPS";
79 79
 
80 80
 if (!$mail->Send()) {
81
-   echo localize ("mail.messagenotsent");
81
+   echo localize("mail.messagenotsent");
82 82
    echo 'Mailer Error: ' . $mail->ErrorInfo;
83 83
    exit;
84 84
 }
85 85
 
86
-echo localize ("mail.messagesent");
86
+echo localize("mail.messagesent");
87 87
 
Please login to merge, or discard this patch.
transliteration.php 2 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,73 +91,73 @@  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
         }
139 139
         $result .= _transliteration_replace($ord, $unknown, $source_langcode);
140 140
         $head = '';
141
-      }
142
-      elseif ($c < "\x80") {
141
+        }
142
+        elseif ($c < "\x80") {
143 143
         // ASCII byte.
144 144
         $result .= $c;
145 145
         $head = '';
146
-      }
147
-      elseif ($c < "\xc0") {
146
+        }
147
+        elseif ($c < "\xc0") {
148 148
         // Illegal tail bytes.
149 149
         if ($head == '') {
150
-          $result .= $unknown;
150
+            $result .= $unknown;
151
+        }
151 152
         }
152
-      }
153
-      else {
153
+        else {
154 154
         // Miscellaneous freaks.
155 155
         $result .= $unknown;
156 156
         $head = '';
157
-      }
157
+        }
158 158
     }
159
-  }
160
-  return $result;
159
+    }
160
+    return $result;
161 161
 }
162 162
 
163 163
 /**
@@ -176,36 +176,36 @@  discard block
 block discarded – undo
176 176
  *   ASCII replacement character.
177 177
  */
178 178
 function _transliteration_replace($ord, $unknown = '?', $langcode = NULL) {
179
-  static $map = array();
179
+    static $map = array();
180 180
 
181
-  //GL: set language later
182
-  /*
181
+    //GL: set language later
182
+    /*
183 183
   if (!isset($langcode)) {
184 184
     global $language;
185 185
     $langcode = $language->language;
186 186
   }
187 187
   */
188 188
 
189
-  $bank = $ord >> 8;
189
+    $bank = $ord >> 8;
190 190
 
191
-  if (!isset($map[$bank][$langcode])) {
191
+    if (!isset($map[$bank][$langcode])) {
192 192
     $file = './resources/transliteration-data/' . sprintf('x%02x', $bank) . '.php';  
193 193
     if (file_exists($file)) {
194
-      include $file;
195
-      if ($langcode != 'en' && isset($variant[$langcode])) {
194
+        include $file;
195
+        if ($langcode != 'en' && isset($variant[$langcode])) {
196 196
         // Merge in language specific mappings.
197 197
         $map[$bank][$langcode] = $variant[$langcode] + $base;
198
-      }
199
-      else {
198
+        }
199
+        else {
200 200
         $map[$bank][$langcode] = $base;
201
-      }
201
+        }
202 202
     }
203 203
     else {
204
-      $map[$bank][$langcode] = array();
204
+        $map[$bank][$langcode] = array();
205
+    }
205 206
     }
206
-  }
207 207
 
208
-  $ord = $ord & 255;
208
+    $ord = $ord & 255;
209 209
 
210
-  return isset($map[$bank][$langcode][$ord]) ? $map[$bank][$langcode][$ord] : $unknown;
210
+    return isset($map[$bank][$langcode][$ord]) ? $map[$bank][$langcode][$ord] : $unknown;
211 211
 }
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!
@@ -207,5 +207,5 @@  discard block
 block discarded – undo
207 207
 
208 208
   $ord = $ord & 255;
209 209
 
210
-  return isset($map[$bank][$langcode][$ord]) ? $map[$bank][$langcode][$ord] : $unknown;
210
+  return isset($map[$bank][$langcode][$ord])?$map[$bank][$langcode][$ord]:$unknown;
211 211
 }
Please login to merge, or discard this patch.
lib/Language.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -17,17 +17,17 @@  discard block
 block discarded – undo
17 17
         $this->lang_code = $plang_code;
18 18
     }
19 19
 
20
-    public function getUri () {
21
-        return "?page=".parent::PAGE_LANGUAGE_DETAIL."&id=$this->id";
20
+    public function getUri() {
21
+        return "?page=" . parent::PAGE_LANGUAGE_DETAIL . "&id=$this->id";
22 22
     }
23 23
 
24
-    public function getEntryId () {
25
-        return self::ALL_LANGUAGES_ID.":".$this->id;
24
+    public function getEntryId() {
25
+        return self::ALL_LANGUAGES_ID . ":" . $this->id;
26 26
     }
27 27
 
28
-    public static function getLanguageString ($code) {
29
-        $string = localize("languages.".$code);
30
-        if (preg_match ("/^languages/", $string)) {
28
+    public static function getLanguageString($code) {
29
+        $string = localize("languages." . $code);
30
+        if (preg_match("/^languages/", $string)) {
31 31
             return $code;
32 32
         }
33 33
         return $string;
@@ -35,14 +35,14 @@  discard block
 block discarded – undo
35 35
 
36 36
     public static function getCount() {
37 37
         // str_format (localize("languages.alphabetical", count(array))
38
-        return parent::getCountGeneric ("languages", self::ALL_LANGUAGES_ID, parent::PAGE_ALL_LANGUAGES);
38
+        return parent::getCountGeneric("languages", self::ALL_LANGUAGES_ID, parent::PAGE_ALL_LANGUAGES);
39 39
     }
40 40
 
41
-    public static function getLanguageById ($languageId) {
42
-        $result = parent::getDb ()->prepare('select id, lang_code  from languages where id = ?');
43
-        $result->execute (array ($languageId));
44
-        if ($post = $result->fetchObject ()) {
45
-            return new Language ($post->id, Language::getLanguageString ($post->lang_code));
41
+    public static function getLanguageById($languageId) {
42
+        $result = parent::getDb()->prepare('select id, lang_code  from languages where id = ?');
43
+        $result->execute(array($languageId));
44
+        if ($post = $result->fetchObject()) {
45
+            return new Language($post->id, Language::getLanguageString($post->lang_code));
46 46
         }
47 47
         return NULL;
48 48
     }
@@ -50,18 +50,18 @@  discard block
 block discarded – undo
50 50
 
51 51
 
52 52
     public static function getAllLanguages() {
53
-        $result = parent::getDb ()->query('select languages.id as id, languages.lang_code as lang_code, count(*) as count
53
+        $result = parent::getDb()->query('select languages.id as id, languages.lang_code as lang_code, count(*) as count
54 54
 from languages, books_languages_link
55 55
 where languages.id = books_languages_link.lang_code
56 56
 group by languages.id, books_languages_link.lang_code
57 57
 order by languages.lang_code');
58 58
         $entryArray = array();
59
-        while ($post = $result->fetchObject ())
59
+        while ($post = $result->fetchObject())
60 60
         {
61
-            $language = new Language ($post->id, $post->lang_code);
62
-            array_push ($entryArray, new Entry (Language::getLanguageString ($language->lang_code), $language->getEntryId (),
63
-                str_format (localize("bookword", $post->count), $post->count), "text",
64
-                array ( new LinkNavigation ($language->getUri ())), "", $post->count));
61
+            $language = new Language($post->id, $post->lang_code);
62
+            array_push($entryArray, new Entry(Language::getLanguageString($language->lang_code), $language->getEntryId(),
63
+                str_format(localize("bookword", $post->count), $post->count), "text",
64
+                array(new LinkNavigation($language->getUri())), "", $post->count));
65 65
         }
66 66
         return $entryArray;
67 67
     }
Please login to merge, or discard this patch.
lib/PageQueryResult.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -15,16 +15,16 @@  discard block
 block discarded – undo
15 15
     const SCOPE_BOOK = "book";
16 16
     const SCOPE_PUBLISHER = "publisher";
17 17
 
18
-    private function useTypeahead () {
19
-        return !is_null (getURLParam ("search"));
18
+    private function useTypeahead() {
19
+        return !is_null(getURLParam("search"));
20 20
     }
21 21
 
22
-    private function searchByScope ($scope, $limit = FALSE) {
22
+    private function searchByScope($scope, $limit = FALSE) {
23 23
         $n = $this->n;
24 24
         $numberPerPage = NULL;
25 25
         $queryNormedAndUp = $this->query;
26
-        if (useNormAndUp ()) {
27
-            $queryNormedAndUp = normAndUp ($this->query);
26
+        if (useNormAndUp()) {
27
+            $queryNormedAndUp = normAndUp($this->query);
28 28
         }
29 29
         if ($limit) {
30 30
             $n = 1;
@@ -32,59 +32,59 @@  discard block
 block discarded – undo
32 32
         }
33 33
         switch ($scope) {
34 34
             case self::SCOPE_BOOK :
35
-                $array = Book::getBooksByStartingLetter ('%' . $queryNormedAndUp, $n, NULL, $numberPerPage);
35
+                $array = Book::getBooksByStartingLetter('%' . $queryNormedAndUp, $n, NULL, $numberPerPage);
36 36
                 break;
37 37
             case self::SCOPE_AUTHOR :
38
-                $array = Author::getAuthorsForSearch ('%' . $queryNormedAndUp);
38
+                $array = Author::getAuthorsForSearch('%' . $queryNormedAndUp);
39 39
                 break;
40 40
             case self::SCOPE_SERIES :
41
-                $array = Serie::getAllSeriesByQuery ($queryNormedAndUp);
41
+                $array = Serie::getAllSeriesByQuery($queryNormedAndUp);
42 42
                 break;
43 43
             case self::SCOPE_TAG :
44
-                $array = Tag::getAllTagsByQuery ($queryNormedAndUp, $n, NULL, $numberPerPage);
44
+                $array = Tag::getAllTagsByQuery($queryNormedAndUp, $n, NULL, $numberPerPage);
45 45
                 break;
46 46
             case self::SCOPE_PUBLISHER :
47
-                $array = Publisher::getAllPublishersByQuery ($queryNormedAndUp);
47
+                $array = Publisher::getAllPublishersByQuery($queryNormedAndUp);
48 48
                 break;
49 49
             default:
50
-                $array = Book::getBooksByQuery (
51
-                    array ("all" => "%" . $queryNormedAndUp . "%"), $n);
50
+                $array = Book::getBooksByQuery(
51
+                    array("all" => "%" . $queryNormedAndUp . "%"), $n);
52 52
         }
53 53
 
54 54
         return $array;
55 55
     }
56 56
 
57
-    public function doSearchByCategory () {
58
-        $database = GetUrlParam (DB);
59
-        $out = array ();
57
+    public function doSearchByCategory() {
58
+        $database = GetUrlParam(DB);
59
+        $out = array();
60 60
         $pagequery = Base::PAGE_OPENSEARCH_QUERY;
61
-        $dbArray = array ("");
61
+        $dbArray = array("");
62 62
         $d = $database;
63 63
         $query = $this->query;
64 64
         // Special case when no databases were chosen, we search on all databases
65
-        if (Base::noDatabaseSelected ()) {
66
-            $dbArray = Base::getDbNameList ();
65
+        if (Base::noDatabaseSelected()) {
66
+            $dbArray = Base::getDbNameList();
67 67
             $d = 0;
68 68
         }
69 69
         foreach ($dbArray as $key) {
70
-            if (Base::noDatabaseSelected ()) {
71
-                array_push ($this->entryArray, new Entry ($key, DB . ":query:{$d}",
70
+            if (Base::noDatabaseSelected()) {
71
+                array_push($this->entryArray, new Entry($key, DB . ":query:{$d}",
72 72
                                         " ", "text",
73
-                                        array ( new LinkNavigation ("?" . DB . "={$d}")), "tt-header"));
74
-                Base::getDb ($d);
73
+                                        array(new LinkNavigation("?" . DB . "={$d}")), "tt-header"));
74
+                Base::getDb($d);
75 75
             }
76
-            foreach (array (PageQueryResult::SCOPE_BOOK,
76
+            foreach (array(PageQueryResult::SCOPE_BOOK,
77 77
                             PageQueryResult::SCOPE_AUTHOR,
78 78
                             PageQueryResult::SCOPE_SERIES,
79 79
                             PageQueryResult::SCOPE_TAG,
80 80
                             PageQueryResult::SCOPE_PUBLISHER) as $key) {
81
-                if (in_array($key, getCurrentOption ('ignored_categories'))) {
81
+                if (in_array($key, getCurrentOption('ignored_categories'))) {
82 82
                     continue;
83 83
                 }
84
-                $array = $this->searchByScope ($key, TRUE);
84
+                $array = $this->searchByScope($key, TRUE);
85 85
 
86 86
                 $i = 0;
87
-                if (count ($array) == 2 && is_array ($array [0])) {
87
+                if (count($array) == 2 && is_array($array [0])) {
88 88
                     $total = $array [1];
89 89
                     $array = $array [0];
90 90
                 } else {
@@ -97,32 +97,32 @@  discard block
 block discarded – undo
97 97
                     // str_format (localize("seriesword", count($array))
98 98
                     // str_format (localize("tagword", count($array))
99 99
                     // str_format (localize("publisherword", count($array))
100
-                    array_push ($this->entryArray, new Entry (str_format (localize ("search.result.{$key}"), $this->query), DB . ":query:{$d}:{$key}",
101
-                                        str_format (localize("{$key}word", $total), $total), "text",
102
-                                        array ( new LinkNavigation ("?page={$pagequery}&query={$query}&db={$d}&scope={$key}")),
103
-                                        Base::noDatabaseSelected () ? "" : "tt-header", $total));
100
+                    array_push($this->entryArray, new Entry(str_format(localize("search.result.{$key}"), $this->query), DB . ":query:{$d}:{$key}",
101
+                                        str_format(localize("{$key}word", $total), $total), "text",
102
+                                        array(new LinkNavigation("?page={$pagequery}&query={$query}&db={$d}&scope={$key}")),
103
+                                        Base::noDatabaseSelected()?"":"tt-header", $total));
104 104
                 }
105
-                if (!Base::noDatabaseSelected () && $this->useTypeahead ()) {
105
+                if (!Base::noDatabaseSelected() && $this->useTypeahead()) {
106 106
                     foreach ($array as $entry) {
107
-                        array_push ($this->entryArray, $entry);
107
+                        array_push($this->entryArray, $entry);
108 108
                         $i++;
109 109
                         if ($i > 4) { break; };
110 110
                     }
111 111
                 }
112 112
             }
113 113
             $d++;
114
-            if (Base::noDatabaseSelected ()) {
115
-                Base::clearDb ();
114
+            if (Base::noDatabaseSelected()) {
115
+                Base::clearDb();
116 116
             }
117 117
         }
118 118
         return $out;
119 119
     }
120 120
 
121
-    public function InitializeContent ()
121
+    public function InitializeContent()
122 122
     {
123
-        $scope = getURLParam ("scope");
123
+        $scope = getURLParam("scope");
124 124
         if (empty ($scope)) {
125
-            $this->title = str_format (localize ("search.result"), $this->query);
125
+            $this->title = str_format(localize("search.result"), $this->query);
126 126
         } else {
127 127
             // Comment to help the perl i18n script
128 128
             // str_format (localize ("search.result.author"), $this->query)
@@ -130,31 +130,31 @@  discard block
 block discarded – undo
130 130
             // str_format (localize ("search.result.series"), $this->query)
131 131
             // str_format (localize ("search.result.book"), $this->query)
132 132
             // str_format (localize ("search.result.publisher"), $this->query)
133
-            $this->title = str_format (localize ("search.result.{$scope}"), $this->query);
133
+            $this->title = str_format(localize("search.result.{$scope}"), $this->query);
134 134
         }
135 135
 
136 136
         $crit = "%" . $this->query . "%";
137 137
 
138 138
         // Special case when we are doing a search and no database is selected
139
-        if (Base::noDatabaseSelected () && !$this->useTypeahead ()) {
139
+        if (Base::noDatabaseSelected() && !$this->useTypeahead()) {
140 140
             $i = 0;
141
-            foreach (Base::getDbNameList () as $key) {
142
-                Base::clearDb ();
143
-                list ($array, $totalNumber) = Book::getBooksByQuery (array ("all" => $crit), 1, $i, 1);
144
-                array_push ($this->entryArray, new Entry ($key, DB . ":query:{$i}",
145
-                                        str_format (localize ("bookword", $totalNumber), $totalNumber), "text",
146
-                                        array ( new LinkNavigation ("?" . DB . "={$i}&page=9&query=" . $this->query)), "", $totalNumber));
141
+            foreach (Base::getDbNameList() as $key) {
142
+                Base::clearDb();
143
+                list ($array, $totalNumber) = Book::getBooksByQuery(array("all" => $crit), 1, $i, 1);
144
+                array_push($this->entryArray, new Entry($key, DB . ":query:{$i}",
145
+                                        str_format(localize("bookword", $totalNumber), $totalNumber), "text",
146
+                                        array(new LinkNavigation("?" . DB . "={$i}&page=9&query=" . $this->query)), "", $totalNumber));
147 147
                 $i++;
148 148
             }
149 149
             return;
150 150
         }
151 151
         if (empty ($scope)) {
152
-            $this->doSearchByCategory ();
152
+            $this->doSearchByCategory();
153 153
             return;
154 154
         }
155 155
 
156
-        $array = $this->searchByScope ($scope);
157
-        if (count ($array) == 2 && is_array ($array [0])) {
156
+        $array = $this->searchByScope($scope);
157
+        if (count($array) == 2 && is_array($array [0])) {
158 158
             list ($this->entryArray, $this->totalNumber) = $array;
159 159
         } else {
160 160
             $this->entryArray = $array;
Please login to merge, or discard this patch.
lib/PageCustomDetail.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -8,12 +8,12 @@
 block discarded – undo
8 8
 
9 9
 class PageCustomDetail extends Page
10 10
 {
11
-    public function InitializeContent ()
11
+    public function InitializeContent()
12 12
     {
13
-        $customId = getURLParam ("custom", NULL);
14
-        $custom = CustomColumn::getCustomById ($customId, $this->idGet);
15
-        $this->idPage = $custom->getEntryId ();
13
+        $customId = getURLParam("custom", NULL);
14
+        $custom = CustomColumn::getCustomById($customId, $this->idGet);
15
+        $this->idPage = $custom->getEntryId();
16 16
         $this->title = $custom->name;
17
-        list ($this->entryArray, $this->totalNumber) = Book::getBooksByCustom ($customId, $this->idGet, $this->n);
17
+        list ($this->entryArray, $this->totalNumber) = Book::getBooksByCustom($customId, $this->idGet, $this->n);
18 18
     }
19 19
 }
Please login to merge, or discard this patch.
lib/PageBookDetail.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,9 +8,9 @@
 block discarded – undo
8 8
 
9 9
 class PageBookDetail extends Page
10 10
 {
11
-    public function InitializeContent ()
11
+    public function InitializeContent()
12 12
     {
13
-        $this->book = Book::getBookById ($this->idGet);
13
+        $this->book = Book::getBookById($this->idGet);
14 14
         $this->title = $this->book->title;
15 15
     }
16 16
 }
Please login to merge, or discard this patch.
lib/CustomColumn.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -19,80 +19,80 @@
 block discarded – undo
19 19
         $this->customId = $pcustomId;
20 20
     }
21 21
 
22
-    public function getUri () {
23
-        return "?page=".parent::PAGE_CUSTOM_DETAIL."&custom={$this->customId}&id={$this->id}";
22
+    public function getUri() {
23
+        return "?page=" . parent::PAGE_CUSTOM_DETAIL . "&custom={$this->customId}&id={$this->id}";
24 24
     }
25 25
 
26
-    public function getEntryId () {
27
-        return self::ALL_CUSTOMS_ID.":".$this->customId.":".$this->id;
26
+    public function getEntryId() {
27
+        return self::ALL_CUSTOMS_ID . ":" . $this->customId . ":" . $this->id;
28 28
     }
29 29
 
30
-    public static function getTableName ($customId) {
30
+    public static function getTableName($customId) {
31 31
         return "custom_column_{$customId}";
32 32
     }
33 33
 
34
-    public static function getTableLinkName ($customId) {
34
+    public static function getTableLinkName($customId) {
35 35
         return "books_custom_column_{$customId}_link";
36 36
     }
37 37
 
38
-    public static function getTableLinkColumn ($customId) {
38
+    public static function getTableLinkColumn($customId) {
39 39
         return "value";
40 40
     }
41 41
 
42
-    public static function getAllCustomsId ($customId) {
42
+    public static function getAllCustomsId($customId) {
43 43
         return self::ALL_CUSTOMS_ID . ":" . $customId;
44 44
     }
45 45
 
46
-    public static function getUriAllCustoms ($customId) {
46
+    public static function getUriAllCustoms($customId) {
47 47
         return "?page=" . parent::PAGE_ALL_CUSTOMS . "&custom={$customId}";
48 48
     }
49 49
 
50
-    public static function getAllTitle ($customId) {
51
-        $result = parent::getDb ()->prepare('select name from custom_columns where id = ?');
52
-        $result->execute (array ($customId));
53
-        $post = $result->fetchObject ();
50
+    public static function getAllTitle($customId) {
51
+        $result = parent::getDb()->prepare('select name from custom_columns where id = ?');
52
+        $result->execute(array($customId));
53
+        $post = $result->fetchObject();
54 54
         return $post->name;
55 55
     }
56 56
 
57
-    public static function getCustomId ($lookup) {
58
-        $result = parent::getDb ()->prepare('select id from custom_columns where label = ?');
59
-        $result->execute (array ($lookup));
60
-        if ($post = $result->fetchObject ()) {
57
+    public static function getCustomId($lookup) {
58
+        $result = parent::getDb()->prepare('select id from custom_columns where label = ?');
59
+        $result->execute(array($lookup));
60
+        if ($post = $result->fetchObject()) {
61 61
             return $post->id;
62 62
         }
63 63
         return NULL;
64 64
     }
65 65
 
66 66
     public static function getCount($customId) {
67
-        $nCustoms = parent::executeQuerySingle ('select count(*) from ' . self::getTableName ($customId));
68
-        $entry = new Entry (self::getAllTitle ($customId), self::getAllCustomsId ($customId),
69
-            str_format (localize("tags.alphabetical", $nCustoms), $nCustoms), "text",
70
-            array ( new LinkNavigation (self::getUriAllCustoms ($customId))), "", $nCustoms);
67
+        $nCustoms = parent::executeQuerySingle('select count(*) from ' . self::getTableName($customId));
68
+        $entry = new Entry(self::getAllTitle($customId), self::getAllCustomsId($customId),
69
+            str_format(localize("tags.alphabetical", $nCustoms), $nCustoms), "text",
70
+            array(new LinkNavigation(self::getUriAllCustoms($customId))), "", $nCustoms);
71 71
         return $entry;
72 72
     }
73 73
 
74
-    public static function getCustomById ($customId, $id) {
75
-        $result = parent::getDb ()->prepare('select id, value as name from ' . self::getTableName ($customId) . ' where id = ?');
76
-        $result->execute (array ($id));
77
-        if ($post = $result->fetchObject ()) {
78
-            return new CustomColumn ($post->id, $post->name, $customId);
74
+    public static function getCustomById($customId, $id) {
75
+        $result = parent::getDb()->prepare('select id, value as name from ' . self::getTableName($customId) . ' where id = ?');
76
+        $result->execute(array($id));
77
+        if ($post = $result->fetchObject()) {
78
+            return new CustomColumn($post->id, $post->name, $customId);
79 79
         }
80 80
         return NULL;
81 81
     }
82 82
 
83 83
     public static function getAllCustoms($customId) {
84
-        $result = parent::getDb ()->query(str_format ('select {0}.id as id, {0}.value as name, count(*) as count
84
+        $result = parent::getDb()->query(str_format('select {0}.id as id, {0}.value as name, count(*) as count
85 85
 from {0}, {1}
86 86
 where {0}.id = {1}.{2}
87 87
 group by {0}.id, {0}.value
88
-order by {0}.value', self::getTableName ($customId), self::getTableLinkName ($customId), self::getTableLinkColumn ($customId)));
88
+order by {0}.value', self::getTableName($customId), self::getTableLinkName($customId), self::getTableLinkColumn($customId)));
89 89
         $entryArray = array();
90
-        while ($post = $result->fetchObject ())
90
+        while ($post = $result->fetchObject())
91 91
         {
92
-            $customColumn = new CustomColumn ($post->id, $post->name, $customId);
93
-            array_push ($entryArray, new Entry ($customColumn->name, $customColumn->getEntryId (),
94
-                str_format (localize("bookword", $post->count), $post->count), "text",
95
-                array ( new LinkNavigation ($customColumn->getUri ())), "", $post->count));
92
+            $customColumn = new CustomColumn($post->id, $post->name, $customId);
93
+            array_push($entryArray, new Entry($customColumn->name, $customColumn->getEntryId(),
94
+                str_format(localize("bookword", $post->count), $post->count), "text",
95
+                array(new LinkNavigation($customColumn->getUri())), "", $post->count));
96 96
         }
97 97
         return $entryArray;
98 98
     }
Please login to merge, or discard this patch.
lib/Page.php 1 patch
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -22,55 +22,55 @@  discard block
 block discarded – undo
22 22
     public $totalNumber = -1;
23 23
     public $entryArray = array();
24 24
 
25
-    public static function getPage ($pageId, $id, $query, $n)
25
+    public static function getPage($pageId, $id, $query, $n)
26 26
     {
27 27
         switch ($pageId) {
28 28
             case Base::PAGE_ALL_AUTHORS :
29
-                return new PageAllAuthors ($id, $query, $n);
29
+                return new PageAllAuthors($id, $query, $n);
30 30
             case Base::PAGE_AUTHORS_FIRST_LETTER :
31
-                return new PageAllAuthorsLetter ($id, $query, $n);
31
+                return new PageAllAuthorsLetter($id, $query, $n);
32 32
             case Base::PAGE_AUTHOR_DETAIL :
33
-                return new PageAuthorDetail ($id, $query, $n);
33
+                return new PageAuthorDetail($id, $query, $n);
34 34
             case Base::PAGE_ALL_TAGS :
35
-                return new PageAllTags ($id, $query, $n);
35
+                return new PageAllTags($id, $query, $n);
36 36
             case Base::PAGE_TAG_DETAIL :
37
-                return new PageTagDetail ($id, $query, $n);
37
+                return new PageTagDetail($id, $query, $n);
38 38
             case Base::PAGE_ALL_LANGUAGES :
39
-                return new PageAllLanguages ($id, $query, $n);
39
+                return new PageAllLanguages($id, $query, $n);
40 40
             case Base::PAGE_LANGUAGE_DETAIL :
41
-                return new PageLanguageDetail ($id, $query, $n);
41
+                return new PageLanguageDetail($id, $query, $n);
42 42
             case Base::PAGE_ALL_CUSTOMS :
43
-                return new PageAllCustoms ($id, $query, $n);
43
+                return new PageAllCustoms($id, $query, $n);
44 44
             case Base::PAGE_CUSTOM_DETAIL :
45
-                return new PageCustomDetail ($id, $query, $n);
45
+                return new PageCustomDetail($id, $query, $n);
46 46
             case Base::PAGE_ALL_RATINGS :
47
-                return new PageAllRating ($id, $query, $n);
47
+                return new PageAllRating($id, $query, $n);
48 48
             case Base::PAGE_RATING_DETAIL :
49
-                return new PageRatingDetail ($id, $query, $n);
49
+                return new PageRatingDetail($id, $query, $n);
50 50
             case Base::PAGE_ALL_SERIES :
51
-                return new PageAllSeries ($id, $query, $n);
51
+                return new PageAllSeries($id, $query, $n);
52 52
             case Base::PAGE_ALL_BOOKS :
53
-                return new PageAllBooks ($id, $query, $n);
53
+                return new PageAllBooks($id, $query, $n);
54 54
             case Base::PAGE_ALL_BOOKS_LETTER:
55
-                return new PageAllBooksLetter ($id, $query, $n);
55
+                return new PageAllBooksLetter($id, $query, $n);
56 56
             case Base::PAGE_ALL_RECENT_BOOKS :
57
-                return new PageRecentBooks ($id, $query, $n);
57
+                return new PageRecentBooks($id, $query, $n);
58 58
             case Base::PAGE_SERIE_DETAIL :
59
-                return new PageSerieDetail ($id, $query, $n);
59
+                return new PageSerieDetail($id, $query, $n);
60 60
             case Base::PAGE_OPENSEARCH_QUERY :
61
-                return new PageQueryResult ($id, $query, $n);
61
+                return new PageQueryResult($id, $query, $n);
62 62
             case Base::PAGE_BOOK_DETAIL :
63
-                return new PageBookDetail ($id, $query, $n);
63
+                return new PageBookDetail($id, $query, $n);
64 64
             case Base::PAGE_ALL_PUBLISHERS:
65
-                return new PageAllPublishers ($id, $query, $n);
65
+                return new PageAllPublishers($id, $query, $n);
66 66
             case Base::PAGE_PUBLISHER_DETAIL :
67
-                return new PagePublisherDetail ($id, $query, $n);
67
+                return new PagePublisherDetail($id, $query, $n);
68 68
             case Base::PAGE_ABOUT :
69
-                return new PageAbout ($id, $query, $n);
69
+                return new PageAbout($id, $query, $n);
70 70
             case Base::PAGE_CUSTOMIZE :
71
-                return new PageCustomize ($id, $query, $n);
71
+                return new PageCustomize($id, $query, $n);
72 72
             default:
73
-                $page = new Page ($id, $query, $n);
73
+                $page = new Page($id, $query, $n);
74 74
                 $page->idPage = "cops:catalog";
75 75
                 return $page;
76 76
         }
@@ -83,96 +83,96 @@  discard block
 block discarded – undo
83 83
         $this->query = $pquery;
84 84
         $this->n = $pn;
85 85
         $this->favicon = $config['cops_icon'];
86
-        $this->authorName = empty($config['cops_author_name']) ? utf8_encode('Sébastien Lucas') : $config['cops_author_name'];
87
-        $this->authorUri = empty($config['cops_author_uri']) ? 'http://blog.slucas.fr' : $config['cops_author_uri'];
88
-        $this->authorEmail = empty($config['cops_author_email']) ? '[email protected]' : $config['cops_author_email'];
86
+        $this->authorName = empty($config['cops_author_name'])?utf8_encode('Sébastien Lucas'):$config['cops_author_name'];
87
+        $this->authorUri = empty($config['cops_author_uri'])?'http://blog.slucas.fr':$config['cops_author_uri'];
88
+        $this->authorEmail = empty($config['cops_author_email'])?'[email protected]':$config['cops_author_email'];
89 89
     }
90 90
 
91
-    public function InitializeContent ()
91
+    public function InitializeContent()
92 92
     {
93 93
         global $config;
94 94
         $this->title = $config['cops_title_default'];
95 95
         $this->subtitle = $config['cops_subtitle_default'];
96
-        if (Base::noDatabaseSelected ()) {
96
+        if (Base::noDatabaseSelected()) {
97 97
             $i = 0;
98
-            foreach (Base::getDbNameList () as $key) {
99
-                $nBooks = Book::getBookCount ($i);
100
-                array_push ($this->entryArray, new Entry ($key, "cops:{$i}:catalog",
101
-                                        str_format (localize ("bookword", $nBooks), $nBooks), "text",
102
-                                        array ( new LinkNavigation ("?" . DB . "={$i}")), "", $nBooks));
98
+            foreach (Base::getDbNameList() as $key) {
99
+                $nBooks = Book::getBookCount($i);
100
+                array_push($this->entryArray, new Entry($key, "cops:{$i}:catalog",
101
+                                        str_format(localize("bookword", $nBooks), $nBooks), "text",
102
+                                        array(new LinkNavigation("?" . DB . "={$i}")), "", $nBooks));
103 103
                 $i++;
104
-                Base::clearDb ();
104
+                Base::clearDb();
105 105
             }
106 106
         } else {
107
-            if (!in_array (PageQueryResult::SCOPE_AUTHOR, getCurrentOption ('ignored_categories'))) {
108
-                array_push ($this->entryArray, Author::getCount());
107
+            if (!in_array(PageQueryResult::SCOPE_AUTHOR, getCurrentOption('ignored_categories'))) {
108
+                array_push($this->entryArray, Author::getCount());
109 109
             }
110
-            if (!in_array (PageQueryResult::SCOPE_SERIES, getCurrentOption ('ignored_categories'))) {
110
+            if (!in_array(PageQueryResult::SCOPE_SERIES, getCurrentOption('ignored_categories'))) {
111 111
                 $series = Serie::getCount();
112
-                if (!is_null ($series)) array_push ($this->entryArray, $series);
112
+                if (!is_null($series)) array_push($this->entryArray, $series);
113 113
             }
114
-            if (!in_array (PageQueryResult::SCOPE_PUBLISHER, getCurrentOption ('ignored_categories'))) {
114
+            if (!in_array(PageQueryResult::SCOPE_PUBLISHER, getCurrentOption('ignored_categories'))) {
115 115
                 $publisher = Publisher::getCount();
116
-                if (!is_null ($publisher)) array_push ($this->entryArray, $publisher);
116
+                if (!is_null($publisher)) array_push($this->entryArray, $publisher);
117 117
             }
118
-            if (!in_array (PageQueryResult::SCOPE_TAG, getCurrentOption ('ignored_categories'))) {
118
+            if (!in_array(PageQueryResult::SCOPE_TAG, getCurrentOption('ignored_categories'))) {
119 119
                 $tags = Tag::getCount();
120
-                if (!is_null ($tags)) array_push ($this->entryArray, $tags);
120
+                if (!is_null($tags)) array_push($this->entryArray, $tags);
121 121
             }
122
-            if (!in_array (PageQueryResult::SCOPE_RATING, getCurrentOption ('ignored_categories'))) {
122
+            if (!in_array(PageQueryResult::SCOPE_RATING, getCurrentOption('ignored_categories'))) {
123 123
                 $rating = Rating::getCount();
124
-                if (!is_null ($rating)) array_push ($this->entryArray, $rating);
124
+                if (!is_null($rating)) array_push($this->entryArray, $rating);
125 125
             }
126
-            if (!in_array ("language", getCurrentOption ('ignored_categories'))) {
126
+            if (!in_array("language", getCurrentOption('ignored_categories'))) {
127 127
                 $languages = Language::getCount();
128
-                if (!is_null ($languages)) array_push ($this->entryArray, $languages);
128
+                if (!is_null($languages)) array_push($this->entryArray, $languages);
129 129
             }
130 130
             foreach ($config['cops_calibre_custom_column'] as $lookup) {
131
-                $customId = CustomColumn::getCustomId ($lookup);
132
-                if (!is_null ($customId)) {
133
-                    array_push ($this->entryArray, CustomColumn::getCount($customId));
131
+                $customId = CustomColumn::getCustomId($lookup);
132
+                if (!is_null($customId)) {
133
+                    array_push($this->entryArray, CustomColumn::getCount($customId));
134 134
                 }
135 135
             }
136
-            $this->entryArray = array_merge ($this->entryArray, Book::getCount());
136
+            $this->entryArray = array_merge($this->entryArray, Book::getCount());
137 137
 
138
-            if (Base::isMultipleDatabaseEnabled ()) $this->title =  Base::getDbName ();
138
+            if (Base::isMultipleDatabaseEnabled()) $this->title = Base::getDbName();
139 139
         }
140 140
     }
141 141
 
142
-    public function isPaginated ()
142
+    public function isPaginated()
143 143
     {
144
-        return (getCurrentOption ("max_item_per_page") != -1 &&
144
+        return (getCurrentOption("max_item_per_page") != -1 &&
145 145
                 $this->totalNumber != -1 &&
146
-                $this->totalNumber > getCurrentOption ("max_item_per_page"));
146
+                $this->totalNumber > getCurrentOption("max_item_per_page"));
147 147
     }
148 148
 
149
-    public function getNextLink ()
149
+    public function getNextLink()
150 150
     {
151
-        $currentUrl = preg_replace ("/\&n=.*?$/", "", "?" . getQueryString ());
152
-        if (($this->n) * getCurrentOption ("max_item_per_page") < $this->totalNumber) {
153
-            return new LinkNavigation ($currentUrl . "&n=" . ($this->n + 1), "next", localize ("paging.next.alternate"));
151
+        $currentUrl = preg_replace("/\&n=.*?$/", "", "?" . getQueryString());
152
+        if (($this->n) * getCurrentOption("max_item_per_page") < $this->totalNumber) {
153
+            return new LinkNavigation($currentUrl . "&n=" . ($this->n + 1), "next", localize("paging.next.alternate"));
154 154
         }
155 155
         return NULL;
156 156
     }
157 157
 
158
-    public function getPrevLink ()
158
+    public function getPrevLink()
159 159
     {
160
-        $currentUrl = preg_replace ("/\&n=.*?$/", "", "?" . getQueryString ());
160
+        $currentUrl = preg_replace("/\&n=.*?$/", "", "?" . getQueryString());
161 161
         if ($this->n > 1) {
162
-            return new LinkNavigation ($currentUrl . "&n=" . ($this->n - 1), "previous", localize ("paging.previous.alternate"));
162
+            return new LinkNavigation($currentUrl . "&n=" . ($this->n - 1), "previous", localize("paging.previous.alternate"));
163 163
         }
164 164
         return NULL;
165 165
     }
166 166
 
167
-    public function getMaxPage ()
167
+    public function getMaxPage()
168 168
     {
169
-        return ceil ($this->totalNumber / getCurrentOption ("max_item_per_page"));
169
+        return ceil($this->totalNumber / getCurrentOption("max_item_per_page"));
170 170
     }
171 171
 
172
-    public function containsBook ()
172
+    public function containsBook()
173 173
     {
174
-        if (count ($this->entryArray) == 0) return false;
175
-        if (get_class ($this->entryArray [0]) == "EntryBook") return true;
174
+        if (count($this->entryArray) == 0) return false;
175
+        if (get_class($this->entryArray [0]) == "EntryBook") return true;
176 176
         return false;
177 177
     }
178 178
 }
Please login to merge, or discard this patch.
lib/Data.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -58,25 +58,25 @@  discard block
 block discarded – undo
58 58
         $this->id = $post->id;
59 59
         $this->name = $post->name;
60 60
         $this->format = $post->format;
61
-        $this->realFormat = str_replace ("ORIGINAL_", "", $post->format);
62
-        $this->extension = strtolower ($this->realFormat);
61
+        $this->realFormat = str_replace("ORIGINAL_", "", $post->format);
62
+        $this->extension = strtolower($this->realFormat);
63 63
         $this->book = $book;
64 64
     }
65 65
 
66
-    public function isKnownType () {
67
-        return array_key_exists ($this->extension, self::$mimetypes);
66
+    public function isKnownType() {
67
+        return array_key_exists($this->extension, self::$mimetypes);
68 68
     }
69 69
 
70
-    public function getMimeType () {
70
+    public function getMimeType() {
71 71
         $result = "application/octet-stream";
72
-        if ($this->isKnownType ()) {
72
+        if ($this->isKnownType()) {
73 73
             return self::$mimetypes [$this->extension];
74 74
         } elseif (function_exists('finfo_open') === true) {
75 75
             $finfo = finfo_open(FILEINFO_MIME_TYPE);
76 76
 
77 77
             if (is_resource($finfo) === true)
78 78
             {
79
-                $result = finfo_file($finfo, $this->getLocalPath ());
79
+                $result = finfo_file($finfo, $this->getLocalPath());
80 80
             }
81 81
 
82 82
             finfo_close($finfo);
@@ -85,80 +85,80 @@  discard block
 block discarded – undo
85 85
         return $result;
86 86
     }
87 87
 
88
-    public function isEpubValidOnKobo () {
88
+    public function isEpubValidOnKobo() {
89 89
         return $this->format == "EPUB" || $this->format == "KEPUB";
90 90
     }
91 91
 
92
-    public function getFilename () {
93
-        return $this->name . "." . strtolower ($this->format);
92
+    public function getFilename() {
93
+        return $this->name . "." . strtolower($this->format);
94 94
     }
95 95
 
96
-    public function getUpdatedFilename () {
97
-        return $this->book->getAuthorsSort () . " - " . $this->book->title;
96
+    public function getUpdatedFilename() {
97
+        return $this->book->getAuthorsSort() . " - " . $this->book->title;
98 98
     }
99 99
 
100
-    public function getUpdatedFilenameEpub () {
101
-        return $this->getUpdatedFilename () . ".epub";
100
+    public function getUpdatedFilenameEpub() {
101
+        return $this->getUpdatedFilename() . ".epub";
102 102
     }
103 103
 
104
-    public function getUpdatedFilenameKepub () {
105
-        return $this->getUpdatedFilename () . ".kepub.epub";
104
+    public function getUpdatedFilenameKepub() {
105
+        return $this->getUpdatedFilename() . ".kepub.epub";
106 106
     }
107 107
 
108
-    public function getDataLink ($rel, $title = NULL) {
108
+    public function getDataLink($rel, $title = NULL) {
109 109
         global $config;
110 110
 
111 111
         if ($rel == Link::OPDS_ACQUISITION_TYPE && $config['cops_use_url_rewriting'] == "1") {
112 112
             return $this->getHtmlLinkWithRewriting($title);
113 113
         }
114 114
 
115
-        return self::getLink ($this->book, $this->extension, $this->getMimeType (), $rel, $this->getFilename (), $this->id, $title);
115
+        return self::getLink($this->book, $this->extension, $this->getMimeType(), $rel, $this->getFilename(), $this->id, $title);
116 116
     }
117 117
 
118
-    public function getHtmlLink () {
118
+    public function getHtmlLink() {
119 119
         return $this->getDataLink(Link::OPDS_ACQUISITION_TYPE)->href;
120 120
     }
121 121
 
122
-    public function getLocalPath () {
123
-        return $this->book->path . "/" . $this->getFilename ();
122
+    public function getLocalPath() {
123
+        return $this->book->path . "/" . $this->getFilename();
124 124
     }
125 125
 
126
-    public function getHtmlLinkWithRewriting ($title = NULL) {
126
+    public function getHtmlLinkWithRewriting($title = NULL) {
127 127
         global $config;
128 128
 
129 129
         $database = "";
130
-        if (!is_null (GetUrlParam (DB))) $database = GetUrlParam (DB) . "/";
130
+        if (!is_null(GetUrlParam(DB))) $database = GetUrlParam(DB) . "/";
131 131
 
132 132
         $href = "download/" . $this->id . "/" . $database;
133 133
 
134 134
         if ($config['cops_provide_kepub'] == "1" &&
135
-            $this->isEpubValidOnKobo () &&
135
+            $this->isEpubValidOnKobo() &&
136 136
             preg_match("/Kobo/", $_SERVER['HTTP_USER_AGENT'])) {
137
-            $href .= rawurlencode ($this->getUpdatedFilenameKepub ());
137
+            $href .= rawurlencode($this->getUpdatedFilenameKepub());
138 138
         } else {
139
-            $href .= rawurlencode ($this->getFilename ());
139
+            $href .= rawurlencode($this->getFilename());
140 140
         }
141
-        return new Link ($href, $this->getMimeType (), Link::OPDS_ACQUISITION_TYPE, $title);
141
+        return new Link($href, $this->getMimeType(), Link::OPDS_ACQUISITION_TYPE, $title);
142 142
     }
143 143
 
144
-    public static function getDataByBook ($book) {
145
-        $out = array ();
146
-        $result = parent::getDb ()->prepare('select id, format, name
144
+    public static function getDataByBook($book) {
145
+        $out = array();
146
+        $result = parent::getDb()->prepare('select id, format, name
147 147
                                              from data where book = ?');
148
-        $result->execute (array ($book->id));
148
+        $result->execute(array($book->id));
149 149
 
150
-        while ($post = $result->fetchObject ())
150
+        while ($post = $result->fetchObject())
151 151
         {
152
-            array_push ($out, new Data ($post, $book));
152
+            array_push($out, new Data($post, $book));
153 153
         }
154 154
         return $out;
155 155
     }
156 156
 
157
-    public static function handleThumbnailLink ($urlParam, $height) {
157
+    public static function handleThumbnailLink($urlParam, $height) {
158 158
         global $config;
159 159
 
160
-        if (is_null ($height)) {
161
-            if (preg_match ('/feed.php/', $_SERVER["SCRIPT_NAME"])) {
160
+        if (is_null($height)) {
161
+            if (preg_match('/feed.php/', $_SERVER["SCRIPT_NAME"])) {
162 162
                 $height = $config['cops_opds_thumbnail_height'];
163 163
             }
164 164
             else
@@ -173,13 +173,13 @@  discard block
 block discarded – undo
173 173
         return $urlParam;
174 174
     }
175 175
 
176
-    public static function getLink ($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL)
176
+    public static function getLink($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL)
177 177
     {
178 178
         global $config;
179 179
 
180 180
         $urlParam = addURLParameter("", "data", $idData);
181 181
 
182
-        if (Base::useAbsolutePath () ||
182
+        if (Base::useAbsolutePath() ||
183 183
             $rel == Link::OPDS_THUMBNAIL_TYPE ||
184 184
             ($type == "epub" && $config['cops_update_epub-metadata']))
185 185
         {
@@ -188,18 +188,18 @@  discard block
 block discarded – undo
188 188
                 $urlParam = self::handleThumbnailLink($urlParam, $height);
189 189
             }
190 190
             $urlParam = addURLParameter($urlParam, "id", $book->id);
191
-            if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB));
191
+            if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam(DB));
192 192
             if ($config['cops_thumbnail_handling'] != "1" &&
193 193
                 !empty ($config['cops_thumbnail_handling']) &&
194 194
                 $rel == Link::OPDS_THUMBNAIL_TYPE) {
195
-                return new Link ($config['cops_thumbnail_handling'], $mime, $rel, $title);
195
+                return new Link($config['cops_thumbnail_handling'], $mime, $rel, $title);
196 196
             } else {
197
-                return new Link ("fetch.php?" . $urlParam, $mime, $rel, $title);
197
+                return new Link("fetch.php?" . $urlParam, $mime, $rel, $title);
198 198
             }
199 199
         }
200 200
         else
201 201
         {
202
-            return new Link (str_replace('%2F','/',rawurlencode ($book->path."/".$filename)), $mime, $rel, $title);
202
+            return new Link(str_replace('%2F', '/', rawurlencode($book->path . "/" . $filename)), $mime, $rel, $title);
203 203
         }
204 204
     }
205 205
 }
Please login to merge, or discard this patch.