Exemplo n.º 1
0
 public function InitializeContent()
 {
     global $config;
     $this->title = $config['cops_title_default'];
     $this->subtitle = $config['cops_subtitle_default'];
     if (Base::noDatabaseSelected()) {
         $i = 0;
         foreach (Base::getDbNameList() as $key) {
             $nBooks = Book::getBookCount($i);
             array_push($this->entryArray, new Entry($key, "cops:{$i}:catalog", str_format(localize("bookword", $nBooks), $nBooks), "text", array(new LinkNavigation("?" . DB . "={$i}")), "", $nBooks));
             $i++;
             Base::clearDb();
         }
     } else {
         if (!in_array(PageQueryResult::SCOPE_AUTHOR, getCurrentOption('ignored_categories'))) {
             array_push($this->entryArray, Author::getCount());
         }
         if (!in_array(PageQueryResult::SCOPE_SERIES, getCurrentOption('ignored_categories'))) {
             $series = Serie::getCount();
             if (!is_null($series)) {
                 array_push($this->entryArray, $series);
             }
         }
         if (!in_array(PageQueryResult::SCOPE_PUBLISHER, getCurrentOption('ignored_categories'))) {
             $publisher = Publisher::getCount();
             if (!is_null($publisher)) {
                 array_push($this->entryArray, $publisher);
             }
         }
         if (!in_array(PageQueryResult::SCOPE_TAG, getCurrentOption('ignored_categories'))) {
             $tags = Tag::getCount();
             if (!is_null($tags)) {
                 array_push($this->entryArray, $tags);
             }
         }
         if (!in_array(PageQueryResult::SCOPE_RATING, getCurrentOption('ignored_categories'))) {
             $rating = Rating::getCount();
             if (!is_null($rating)) {
                 array_push($this->entryArray, $rating);
             }
         }
         if (!in_array("language", getCurrentOption('ignored_categories'))) {
             $languages = Language::getCount();
             if (!is_null($languages)) {
                 array_push($this->entryArray, $languages);
             }
         }
         foreach ($config['cops_calibre_custom_column'] as $lookup) {
             $customColumn = CustomColumnType::createByLookup($lookup);
             if (!is_null($customColumn) && $customColumn->isSearchable()) {
                 array_push($this->entryArray, $customColumn->getCount());
             }
         }
         $this->entryArray = array_merge($this->entryArray, Book::getCount());
         if (Base::isMultipleDatabaseEnabled()) {
             $this->title = Base::getDbName();
         }
     }
 }
Exemplo n.º 2
0
 public function testGetURI()
 {
     global $config;
     $config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/";
     $_GET["custom"] = "11";
     $config['cops_calibre_custom_column'] = array("custom_01", "custom_02", "custom_03", "custom_04", "custom_05", "custom_06", "custom_07", "custom_08", "custom_09", "custom_10", "custom_11");
     Base::clearDb();
     $custom = CustomColumnType::createByLookup("custom_01")->getCustom("1");
     $this->assertEquals($custom->customColumnType->getQuery("1"), $custom->getQuery());
     $custom = CustomColumnType::createByLookup("custom_02")->getCustom("3");
     $this->assertEquals($custom->customColumnType->getQuery("3"), $custom->getQuery());
     $custom = CustomColumnType::createByLookup("custom_03")->getCustom("3");
     $this->assertEquals($custom->customColumnType->getQuery("3"), $custom->getQuery());
     $custom = CustomColumnType::createByLookup("custom_04")->getCustom("4");
     $this->assertEquals($custom->customColumnType->getQuery("4"), $custom->getQuery());
     $custom = CustomColumnType::createByLookup("custom_05")->getCustom("6");
     $this->assertEquals($custom->customColumnType->getQuery("6"), $custom->getQuery());
     $custom = CustomColumnType::createByLookup("custom_06")->getCustom("2016-04-24");
     $this->assertEquals($custom->customColumnType->getQuery("2016-04-24"), $custom->getQuery());
     $custom = CustomColumnType::createByLookup("custom_07")->getCustom("11.0");
     $this->assertEquals($custom->customColumnType->getQuery("11.0"), $custom->getQuery());
     $custom = CustomColumnType::createByLookup("custom_08")->getCustom("-2");
     $this->assertEquals($custom->customColumnType->getQuery("-2"), $custom->getQuery());
     $custom = CustomColumnType::createByLookup("custom_09")->getCustom("0");
     $this->assertEquals($custom->customColumnType->getQuery("0"), $custom->getQuery());
     $custom = CustomColumnType::createByLookup("custom_09")->getCustom("1");
     $this->assertEquals($custom->customColumnType->getQuery("1"), $custom->getQuery());
     $custom = CustomColumnType::createByLookup("custom_10")->getCustom("-1");
     $this->assertEquals($custom->customColumnType->getQuery("-1"), $custom->getQuery());
     $custom = CustomColumnType::createByLookup("custom_10")->getCustom("0");
     $this->assertEquals($custom->customColumnType->getQuery("0"), $custom->getQuery());
     $custom = CustomColumnType::createByLookup("custom_10")->getCustom("1");
     $this->assertEquals($custom->customColumnType->getQuery("1"), $custom->getQuery());
     $_GET["custom"] = NULL;
     $config['cops_calibre_custom_column'] = array();
     $config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/";
     Base::clearDb();
 }
Exemplo n.º 3
0
 /**
  * The values of all the specified columns
  *
  * @param string[] $columns
  * @return CustomColumn[]
  */
 public function getCustomColumnValues($columns, $asArray = false)
 {
     $result = array();
     foreach ($columns as $lookup) {
         $col = CustomColumnType::createByLookup($lookup);
         if (!is_null($col)) {
             $cust = $col->getCustomByBook($this);
             if (!is_null($cust)) {
                 if ($asArray) {
                     array_push($result, $cust->toArray());
                 } else {
                     array_push($result, $cust);
                 }
             }
         }
     }
     return $result;
 }