Code Duplication    Length = 17-18 lines in 6 locations

lib/CustomColumnTypeBool.php 1 location

@@ 54-70 (lines=17) @@
51
        return new CustomColumn($id, localize($this->BOOLEAN_NAMES[$id]), $this);
52
    }
53
54
    protected function getAllCustomValuesFromDatabase()
55
    {
56
        $queryFormat = "SELECT coalesce({0}.value, -1) AS id, count(*) AS count FROM books LEFT JOIN {0} ON  books.id = {0}.book GROUP BY {0}.value ORDER BY {0}.value";
57
        $query = str_format($queryFormat, $this->getTableName());
58
        $result = Base::getDb()->query($query);
59
60
        $entryArray = array();
61
        while ($post = $result->fetchObject()) {
62
            $entryPContent = str_format(localize("bookword", $post->count), $post->count);
63
            $entryPLinkArray = array(new LinkNavigation ($this->getUri($post->id)));
64
65
            $entry = new Entry(localize($this->BOOLEAN_NAMES[$post->id]), $this->getEntryId($post->id), $entryPContent, $this->datatype, $entryPLinkArray, "", $post->count);
66
67
            array_push($entryArray, $entry);
68
        }
69
        return $entryArray;
70
    }
71
72
    public function getDescription()
73
    {

lib/CustomColumnTypeEnumeration.php 1 location

@@ 63-79 (lines=17) @@
60
        return NULL;
61
    }
62
63
    protected function getAllCustomValuesFromDatabase()
64
    {
65
        $queryFormat = "SELECT {0}.id AS id, {0}.value AS name, count(*) AS count FROM {0}, {1} WHERE {0}.id = {1}.{2} GROUP BY {0}.id, {0}.value ORDER BY {0}.value";
66
        $query = str_format($queryFormat, $this->getTableName(), $this->getTableLinkName(), $this->getTableLinkColumn());
67
68
        $result = Base::getDb()->query($query);
69
        $entryArray = array();
70
        while ($post = $result->fetchObject()) {
71
            $entryPContent = str_format(localize("bookword", $post->count), $post->count);
72
            $entryPLinkArray = array(new LinkNavigation ($this->getUri($post->id)));
73
74
            $entry = new Entry ($post->name, $this->getEntryId($post->id), $entryPContent, $this->datatype, $entryPLinkArray, "", $post->count);
75
76
            array_push($entryArray, $entry);
77
        }
78
        return $entryArray;
79
    }
80
81
    public function getDescription()
82
    {

lib/CustomColumnTypeFloat.php 1 location

@@ 37-53 (lines=17) @@
34
        return new CustomColumn($id, $id, $this);
35
    }
36
37
    protected function getAllCustomValuesFromDatabase()
38
    {
39
        $queryFormat = "SELECT value AS id, count(*) AS count FROM {0} GROUP BY value";
40
        $query = str_format($queryFormat, $this->getTableName());
41
42
        $result = Base::getDb()->query($query);
43
        $entryArray = array();
44
        while ($post = $result->fetchObject()) {
45
            $entryPContent = str_format(localize("bookword", $post->count), $post->count);
46
            $entryPLinkArray = array(new LinkNavigation($this->getUri($post->id)));
47
48
            $entry = new Entry($post->id, $this->getEntryId($post->id), $entryPContent, $this->datatype, $entryPLinkArray, "", $post->count);
49
50
            array_push($entryArray, $entry);
51
        }
52
        return $entryArray;
53
    }
54
55
    public function getDescription()
56
    {

lib/CustomColumnTypeInteger.php 1 location

@@ 37-53 (lines=17) @@
34
        return new CustomColumn($id, $id, $this);
35
    }
36
37
    protected function getAllCustomValuesFromDatabase()
38
    {
39
        $queryFormat = "SELECT value AS id, count(*) AS count FROM {0} GROUP BY value";
40
        $query = str_format($queryFormat, $this->getTableName());
41
42
        $result = Base::getDb()->query($query);
43
        $entryArray = array();
44
        while ($post = $result->fetchObject()) {
45
            $entryPContent = str_format(localize("bookword", $post->count), $post->count);
46
            $entryPLinkArray = array(new LinkNavigation($this->getUri($post->id)));
47
48
            $entry = new Entry($post->id, $this->getEntryId($post->id), $entryPContent, $this->datatype, $entryPLinkArray, "", $post->count);
49
50
            array_push($entryArray, $entry);
51
        }
52
        return $entryArray;
53
    }
54
55
    public function getDescription()
56
    {

lib/CustomColumnTypeSeries.php 1 location

@@ 63-79 (lines=17) @@
60
        return NULL;
61
    }
62
63
    protected function getAllCustomValuesFromDatabase()
64
    {
65
        $queryFormat = "SELECT {0}.id AS id, {0}.value AS name, count(*) AS count FROM {0}, {1} WHERE {0}.id = {1}.{2} GROUP BY {0}.id, {0}.value ORDER BY {0}.value";
66
        $query = str_format($queryFormat, $this->getTableName(), $this->getTableLinkName(), $this->getTableLinkColumn());
67
68
        $result = Base::getDb()->query($query);
69
        $entryArray = array();
70
        while ($post = $result->fetchObject()) {
71
            $entryPContent = str_format(localize("bookword", $post->count), $post->count);
72
            $entryPLinkArray = array(new LinkNavigation($this->getUri($post->id)));
73
74
            $entry = new Entry($post->name, $this->getEntryId($post->id), $entryPContent, $this->datatype, $entryPLinkArray, "", $post->count);
75
76
            array_push($entryArray, $entry);
77
        }
78
        return $entryArray;
79
    }
80
81
    public function getDescription()
82
    {

lib/CustomColumnTypeText.php 1 location

@@ 63-80 (lines=18) @@
60
        return NULL;
61
    }
62
63
    protected function getAllCustomValuesFromDatabase()
64
    {
65
        $queryFormat = "SELECT {0}.id AS id, {0}.value AS name, count(*) AS count FROM {0}, {1} WHERE {0}.id = {1}.{2} GROUP BY {0}.id, {0}.value ORDER BY {0}.value";
66
        $query = str_format($queryFormat, $this->getTableName(), $this->getTableLinkName(), $this->getTableLinkColumn());
67
68
        $result = Base::getDb()->query($query);
69
        $entryArray = array();
70
        while ($post = $result->fetchObject())
71
        {
72
            $entryPContent = str_format(localize("bookword", $post->count), $post->count);
73
            $entryPLinkArray = array(new LinkNavigation ($this->getUri($post->id)));
74
75
            $entry = new Entry($post->name, $this->getEntryId($post->id), $entryPContent, $this->datatype, $entryPLinkArray, "", $post->count);
76
77
            array_push($entryArray, $entry);
78
        }
79
        return $entryArray;
80
    }
81
82
    public function getDescription()
83
    {