|
@@ 961-1030 (lines=70) @@
|
| 958 |
|
} |
| 959 |
|
} |
| 960 |
|
|
| 961 |
|
class CustomColumnTypeInteger extends CustomColumnType |
| 962 |
|
{ |
| 963 |
|
protected function __construct($pcustomId) |
| 964 |
|
{ |
| 965 |
|
parent::__construct($pcustomId, self::CUSTOM_TYPE_INT); |
| 966 |
|
} |
| 967 |
|
|
| 968 |
|
/** |
| 969 |
|
* Get the name of the sqlite table for this column |
| 970 |
|
* |
| 971 |
|
* @return string|null |
| 972 |
|
*/ |
| 973 |
|
private function getTableName() |
| 974 |
|
{ |
| 975 |
|
return "custom_column_{$this->customId}"; |
| 976 |
|
} |
| 977 |
|
|
| 978 |
|
public function getQuery($id) |
| 979 |
|
{ |
| 980 |
|
$query = str_format(Book::SQL_BOOKS_BY_CUSTOM_DIRECT, "{0}", "{1}", $this->getTableName()); |
| 981 |
|
return array($query, array($id)); |
| 982 |
|
} |
| 983 |
|
|
| 984 |
|
public function getCustom($id) |
| 985 |
|
{ |
| 986 |
|
return new CustomColumn($id, $id, $this); |
| 987 |
|
} |
| 988 |
|
|
| 989 |
|
protected function getAllCustomValuesFromDatabase() |
| 990 |
|
{ |
| 991 |
|
$queryFormat = "SELECT value AS id, count(*) AS count FROM {0} GROUP BY value"; |
| 992 |
|
$query = str_format($queryFormat, $this->getTableName()); |
| 993 |
|
|
| 994 |
|
$result = $this->getDb()->query($query); |
| 995 |
|
$entryArray = array(); |
| 996 |
|
while ($post = $result->fetchObject()) { |
| 997 |
|
$entryPContent = str_format(localize("bookword", $post->count), $post->count); |
| 998 |
|
$entryPLinkArray = array(new LinkNavigation($this->getUri($post->id))); |
| 999 |
|
|
| 1000 |
|
$entry = new Entry($post->id, $this->getEntryId($post->id), $entryPContent, $this->datatype, $entryPLinkArray, "", $post->count); |
| 1001 |
|
|
| 1002 |
|
array_push($entryArray, $entry); |
| 1003 |
|
} |
| 1004 |
|
return $entryArray; |
| 1005 |
|
} |
| 1006 |
|
|
| 1007 |
|
public function getDescription() |
| 1008 |
|
{ |
| 1009 |
|
$desc = $this->getDatabaseDescription(); |
| 1010 |
|
if ($desc === NULL || empty($desc)) $desc = str_format(localize("customcolumn.description"), $this->getTitle()); |
| 1011 |
|
return $desc; |
| 1012 |
|
} |
| 1013 |
|
|
| 1014 |
|
public function getCustomByBook($book) |
| 1015 |
|
{ |
| 1016 |
|
$queryFormat = "SELECT {0}.value AS value FROM {0} WHERE {0}.book = {1}"; |
| 1017 |
|
$query = str_format($queryFormat, $this->getTableName(), $book->id); |
| 1018 |
|
|
| 1019 |
|
$result = $this->getDb()->query($query); |
| 1020 |
|
if ($post = $result->fetchObject()) { |
| 1021 |
|
return new CustomColumn($post->value, $post->value, $this); |
| 1022 |
|
} |
| 1023 |
|
return new CustomColumn(NULL, localize("customcolumn.int.unknown"), $this); |
| 1024 |
|
} |
| 1025 |
|
|
| 1026 |
|
public function isSearchable() |
| 1027 |
|
{ |
| 1028 |
|
return true; |
| 1029 |
|
} |
| 1030 |
|
} |
| 1031 |
|
|
| 1032 |
|
class CustomColumnTypeFloat extends CustomColumnType |
| 1033 |
|
{ |
|
@@ 1032-1101 (lines=70) @@
|
| 1029 |
|
} |
| 1030 |
|
} |
| 1031 |
|
|
| 1032 |
|
class CustomColumnTypeFloat extends CustomColumnType |
| 1033 |
|
{ |
| 1034 |
|
protected function __construct($pcustomId) |
| 1035 |
|
{ |
| 1036 |
|
parent::__construct($pcustomId, self::CUSTOM_TYPE_FLOAT); |
| 1037 |
|
} |
| 1038 |
|
|
| 1039 |
|
/** |
| 1040 |
|
* Get the name of the sqlite table for this column |
| 1041 |
|
* |
| 1042 |
|
* @return string|null |
| 1043 |
|
*/ |
| 1044 |
|
private function getTableName() |
| 1045 |
|
{ |
| 1046 |
|
return "custom_column_{$this->customId}"; |
| 1047 |
|
} |
| 1048 |
|
|
| 1049 |
|
public function getQuery($id) |
| 1050 |
|
{ |
| 1051 |
|
$query = str_format(Book::SQL_BOOKS_BY_CUSTOM_DIRECT, "{0}", "{1}", $this->getTableName()); |
| 1052 |
|
return array($query, array($id)); |
| 1053 |
|
} |
| 1054 |
|
|
| 1055 |
|
public function getCustom($id) |
| 1056 |
|
{ |
| 1057 |
|
return new CustomColumn($id, $id, $this); |
| 1058 |
|
} |
| 1059 |
|
|
| 1060 |
|
protected function getAllCustomValuesFromDatabase() |
| 1061 |
|
{ |
| 1062 |
|
$queryFormat = "SELECT value AS id, count(*) AS count FROM {0} GROUP BY value"; |
| 1063 |
|
$query = str_format($queryFormat, $this->getTableName()); |
| 1064 |
|
|
| 1065 |
|
$result = $this->getDb()->query($query); |
| 1066 |
|
$entryArray = array(); |
| 1067 |
|
while ($post = $result->fetchObject()) { |
| 1068 |
|
$entryPContent = str_format(localize("bookword", $post->count), $post->count); |
| 1069 |
|
$entryPLinkArray = array(new LinkNavigation($this->getUri($post->id))); |
| 1070 |
|
|
| 1071 |
|
$entry = new Entry($post->id, $this->getEntryId($post->id), $entryPContent, $this->datatype, $entryPLinkArray, "", $post->count); |
| 1072 |
|
|
| 1073 |
|
array_push($entryArray, $entry); |
| 1074 |
|
} |
| 1075 |
|
return $entryArray; |
| 1076 |
|
} |
| 1077 |
|
|
| 1078 |
|
public function getDescription() |
| 1079 |
|
{ |
| 1080 |
|
$desc = $this->getDatabaseDescription(); |
| 1081 |
|
if ($desc === NULL || empty($desc)) $desc = str_format(localize("customcolumn.description"), $this->getTitle()); |
| 1082 |
|
return $desc; |
| 1083 |
|
} |
| 1084 |
|
|
| 1085 |
|
public function getCustomByBook($book) |
| 1086 |
|
{ |
| 1087 |
|
$queryFormat = "SELECT {0}.value AS value FROM {0} WHERE {0}.book = {1}"; |
| 1088 |
|
$query = str_format($queryFormat, $this->getTableName(), $book->id); |
| 1089 |
|
|
| 1090 |
|
$result = $this->getDb()->query($query); |
| 1091 |
|
if ($post = $result->fetchObject()) { |
| 1092 |
|
return new CustomColumn($post->value, $post->value, $this); |
| 1093 |
|
} |
| 1094 |
|
return new CustomColumn(NULL, localize("customcolumn.float.unknown"), $this); |
| 1095 |
|
} |
| 1096 |
|
|
| 1097 |
|
public function isSearchable() |
| 1098 |
|
{ |
| 1099 |
|
return true; |
| 1100 |
|
} |
| 1101 |
|
} |
| 1102 |
|
|
| 1103 |
|
class CustomColumnTypeComment extends CustomColumnType |
| 1104 |
|
{ |