seblucas /
cops
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * COPS (Calibre OPDS PHP Server) class file |
||
| 4 | * |
||
| 5 | * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) |
||
| 6 | * @author S�bastien Lucas <[email protected]> |
||
| 7 | */ |
||
| 8 | |||
| 9 | require_once('base.php'); |
||
| 10 | |||
| 11 | class CustomColumn extends Base { |
||
| 12 | const ALL_CUSTOMS_ID = "cops:custom"; |
||
| 13 | |||
| 14 | const SQL_COUNT_CUSTOM_VALUES = |
||
| 15 | "select count(distinct {0}.id) as count |
||
| 16 | from {0} |
||
| 17 | inner join {1} as link on {0}.id = link.{2} |
||
| 18 | 6 | inner join ({3}) as filter on filter.id = link.book"; |
|
| 19 | 6 | const SQL_ALL_CUSTOMS = |
|
| 20 | 6 | "select {0}.id as id, {0}.value as name, count(*) as count |
|
| 21 | 6 | from {0} |
|
| 22 | 6 | inner join {1} as link on {0}.id = link.{2} |
|
| 23 | inner join ({3}) as filter on filter.id = link.book |
||
| 24 | 3 | group by {0}.id, {0}.value |
|
| 25 | 3 | order by {0}.value"; |
|
| 26 | |||
| 27 | public $id; |
||
| 28 | 6 | public $name; |
|
| 29 | 6 | public $customId; |
|
| 30 | |||
| 31 | public function __construct($pid, $pname, $pcustomId) { |
||
| 32 | 10 | $this->id = $pid; |
|
| 33 | 10 | $this->name = $pname; |
|
| 34 | $this->customId = $pcustomId; |
||
| 35 | } |
||
| 36 | 6 | ||
| 37 | 6 | public function getUri () { |
|
| 38 | return "?page=".parent::PAGE_CUSTOM_DETAIL."&custom={$this->customId}&id={$this->id}"; |
||
| 39 | } |
||
| 40 | 6 | ||
| 41 | 6 | public function getEntryId () { |
|
| 42 | return self::ALL_CUSTOMS_ID.":".$this->customId.":".$this->id; |
||
| 43 | } |
||
| 44 | 7 | ||
| 45 | 7 | public static function getTableName ($customId) { |
|
| 46 | return "custom_column_{$customId}"; |
||
| 47 | } |
||
| 48 | 4 | ||
| 49 | 4 | public static function getTableLinkName ($customId) { |
|
| 50 | return "books_custom_column_{$customId}_link"; |
||
| 51 | } |
||
| 52 | 7 | ||
| 53 | 7 | public static function getTableLinkColumn ($customId) { |
|
|
0 ignored issues
–
show
|
|||
| 54 | 7 | return "value"; |
|
| 55 | 7 | } |
|
| 56 | 7 | ||
| 57 | public static function getAllCustomsId ($customId) { |
||
| 58 | return self::ALL_CUSTOMS_ID . ":" . $customId; |
||
| 59 | 4 | } |
|
| 60 | 4 | ||
| 61 | 4 | public static function getUriAllCustoms ($customId) { |
|
| 62 | 4 | return "?page=" . parent::PAGE_ALL_CUSTOMS . "&custom={$customId}"; |
|
| 63 | 4 | } |
|
| 64 | |||
| 65 | public static function getAllTitle ($customId) { |
||
| 66 | $result = parent::getDb ()->prepare('select name from custom_columns where id = ?'); |
||
|
0 ignored issues
–
show
It seems like you call parent on a different method (
getDb() instead of getAllTitle()). Are you sure this is correct? If so, you might want to change this to $this->getDb().
This check looks for a call to a parent method whose name is different than the method from which it is called. Consider the following code: class Daddy
{
protected function getFirstName()
{
return "Eidur";
}
protected function getSurName()
{
return "Gudjohnsen";
}
}
class Son
{
public function getFirstName()
{
return parent::getSurname();
}
}
The Loading history...
|
|||
| 67 | $result->execute (array ($customId)); |
||
| 68 | 4 | $post = $result->fetchObject (); |
|
| 69 | 4 | return $post->name; |
|
| 70 | 4 | } |
|
| 71 | 4 | ||
| 72 | 4 | public static function getCustomId ($lookup) { |
|
| 73 | 4 | $result = parent::getDb ()->prepare('select id from custom_columns where label = ?'); |
|
|
0 ignored issues
–
show
It seems like you call parent on a different method (
getDb() instead of getCustomId()). Are you sure this is correct? If so, you might want to change this to $this->getDb().
This check looks for a call to a parent method whose name is different than the method from which it is called. Consider the following code: class Daddy
{
protected function getFirstName()
{
return "Eidur";
}
protected function getSurName()
{
return "Gudjohnsen";
}
}
class Son
{
public function getFirstName()
{
return parent::getSurname();
}
}
The Loading history...
|
|||
| 74 | $result->execute (array ($lookup)); |
||
| 75 | if ($post = $result->fetchObject ()) { |
||
| 76 | 3 | return $post->id; |
|
| 77 | 3 | } |
|
| 78 | 3 | return NULL; |
|
| 79 | 3 | } |
|
| 80 | 3 | ||
| 81 | public static function getCount($customId) { |
||
| 82 | $sql = str_format(self::SQL_COUNT_CUSTOM_VALUES, |
||
| 83 | self::getTableName ($customId), |
||
| 84 | self::getTableLinkName($customId), |
||
| 85 | 3 | self::getTableLinkColumn($customId), |
|
| 86 | 3 | '{0}'); |
|
| 87 | $nCustoms = parent::executeFilteredQuerySingle ($sql); |
||
|
0 ignored issues
–
show
It seems like you call parent on a different method (
executeFilteredQuerySingle() instead of getCount()). Are you sure this is correct? If so, you might want to change this to $this->executeFilteredQuerySingle().
This check looks for a call to a parent method whose name is different than the method from which it is called. Consider the following code: class Daddy
{
protected function getFirstName()
{
return "Eidur";
}
protected function getSurName()
{
return "Gudjohnsen";
}
}
class Son
{
public function getFirstName()
{
return parent::getSurname();
}
}
The Loading history...
|
|||
| 88 | $entry = new Entry (self::getAllTitle ($customId), self::getAllCustomsId ($customId), |
||
| 89 | str_format (localize("tags.alphabetical", $nCustoms), $nCustoms), "text", |
||
| 90 | 3 | array ( new LinkNavigation (self::getUriAllCustoms ($customId))), "", $nCustoms); |
|
| 91 | 3 | return $entry; |
|
| 92 | 3 | } |
|
| 93 | |||
| 94 | 3 | public static function getCustomById ($customId, $id) { |
|
| 95 | 3 | $result = parent::getDb ()->prepare('select id, value as name from ' . self::getTableName ($customId) . ' where id = ?'); |
|
|
0 ignored issues
–
show
It seems like you call parent on a different method (
getDb() instead of getCustomById()). Are you sure this is correct? If so, you might want to change this to $this->getDb().
This check looks for a call to a parent method whose name is different than the method from which it is called. Consider the following code: class Daddy
{
protected function getFirstName()
{
return "Eidur";
}
protected function getSurName()
{
return "Gudjohnsen";
}
}
class Son
{
public function getFirstName()
{
return parent::getSurname();
}
}
The Loading history...
|
|||
| 96 | 3 | $result->execute (array ($id)); |
|
| 97 | 3 | if ($post = $result->fetchObject ()) { |
|
| 98 | 3 | return new CustomColumn ($post->id, $post->name, $customId); |
|
| 99 | 3 | } |
|
| 100 | return NULL; |
||
| 101 | } |
||
| 102 | |||
| 103 | public static function getAllCustoms($customId) { |
||
| 104 | $sql = str_format(self::SQL_ALL_CUSTOMS, |
||
| 105 | self::getTableName ($customId), |
||
| 106 | self::getTableLinkName($customId), |
||
| 107 | self::getTableLinkColumn($customId), |
||
| 108 | '{0}'); |
||
| 109 | list (, $result) = parent::executeFilteredQuery($sql, array(), -1); |
||
|
0 ignored issues
–
show
It seems like you call parent on a different method (
executeFilteredQuery() instead of getAllCustoms()). Are you sure this is correct? If so, you might want to change this to $this->executeFilteredQuery().
This check looks for a call to a parent method whose name is different than the method from which it is called. Consider the following code: class Daddy
{
protected function getFirstName()
{
return "Eidur";
}
protected function getSurName()
{
return "Gudjohnsen";
}
}
class Son
{
public function getFirstName()
{
return parent::getSurname();
}
}
The Loading history...
|
|||
| 110 | $entryArray = array(); |
||
| 111 | while ($post = $result->fetchObject ()) |
||
| 112 | { |
||
| 113 | $customColumn = new CustomColumn ($post->id, $post->name, $customId); |
||
| 114 | array_push ($entryArray, new Entry ($customColumn->name, $customColumn->getEntryId (), |
||
| 115 | str_format (localize("bookword", $post->count), $post->count), "text", |
||
| 116 | array ( new LinkNavigation ($customColumn->getUri ())), "", $post->count)); |
||
| 117 | } |
||
| 118 | return $entryArray; |
||
| 119 | } |
||
| 120 | } |
||
| 121 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.