Passed
Push — master ( 1a2937...7c8e79 )
by Markus
14:21
created
sendtomail.php 1 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 1 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/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/PageAllBooksLetter.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -8,15 +8,15 @@
 block discarded – undo
8 8
 
9 9
 class PageAllBooksLetter extends Page
10 10
 {
11
-    public function InitializeContent ()
11
+    public function InitializeContent()
12 12
     {
13
-        list ($this->entryArray, $this->totalNumber) = Book::getBooksByStartingLetter ($this->idGet, $this->n);
14
-        $this->idPage = Book::getEntryIdByLetter ($this->idGet);
13
+        list ($this->entryArray, $this->totalNumber) = Book::getBooksByStartingLetter($this->idGet, $this->n);
14
+        $this->idPage = Book::getEntryIdByLetter($this->idGet);
15 15
 
16 16
         $count = $this->totalNumber;
17 17
         if ($count == -1)
18
-            $count = count ($this->entryArray);
18
+            $count = count($this->entryArray);
19 19
 
20
-        $this->title = str_format (localize ("splitByLetter.letter"), str_format (localize ("bookword", $count), $count), $this->idGet);
20
+        $this->title = str_format(localize("splitByLetter.letter"), str_format(localize("bookword", $count), $count), $this->idGet);
21 21
     }
22 22
 }
Please login to merge, or discard this patch.
lib/PageLanguageDetail.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,11 +8,11 @@
 block discarded – undo
8 8
 
9 9
 class PageLanguageDetail extends Page
10 10
 {
11
-    public function InitializeContent ()
11
+    public function InitializeContent()
12 12
     {
13
-        $language = Language::getLanguageById ($this->idGet);
14
-        $this->idPage = $language->getEntryId ();
13
+        $language = Language::getLanguageById($this->idGet);
14
+        $this->idPage = $language->getEntryId();
15 15
         $this->title = $language->lang_code;
16
-        list ($this->entryArray, $this->totalNumber) = Book::getBooksByLanguage ($this->idGet, $this->n);
16
+        list ($this->entryArray, $this->totalNumber) = Book::getBooksByLanguage($this->idGet, $this->n);
17 17
     }
18 18
 }
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/EntryBook.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -11,23 +11,23 @@
 block discarded – undo
11 11
     public $book;
12 12
 
13 13
     public function __construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray, $pbook) {
14
-        parent::__construct ($ptitle, $pid, $pcontent, $pcontentType, $plinkArray);
14
+        parent::__construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray);
15 15
         $this->book = $pbook;
16 16
         $this->localUpdated = $pbook->timestamp;
17 17
     }
18 18
 
19
-    public function getCoverThumbnail () {
19
+    public function getCoverThumbnail() {
20 20
         foreach ($this->linkArray as $link) {
21 21
             if ($link->rel == Link::OPDS_THUMBNAIL_TYPE)
22
-                return $link->hrefXhtml ();
22
+                return $link->hrefXhtml();
23 23
         }
24 24
         return null;
25 25
     }
26 26
 
27
-    public function getCover () {
27
+    public function getCover() {
28 28
         foreach ($this->linkArray as $link) {
29 29
             if ($link->rel == Link::OPDS_IMAGE_TYPE)
30
-                return $link->hrefXhtml ();
30
+                return $link->hrefXhtml();
31 31
         }
32 32
         return null;
33 33
     }
Please login to merge, or discard this patch.