From f80f9ed5f5ccab06f1f42d413df453fd6ccb9144 Mon Sep 17 00:00:00 2001 From: Banana Date: Sun, 17 Jan 2021 21:02:41 +0100 Subject: [PATCH] tool documentations. Tool imdbweb has its own config file and documentation --- CHANGELOG | 5 +++ documentation/setup/install.txt | 3 ++ documentation/tool-imdbweb.txt | 13 +++++++ documentation/tools.txt | 9 +++++ upgrade/from-version-1.0.txt | 4 ++ webclient/config/config-imdb.php.default | 23 ++++++++++++ webclient/lib/imdbwebparser.class.php | 37 +++++++++++++++---- .../lib/managecollectionfields.class.php | 12 ++++-- webclient/view/default/tool/tool-imdbweb.php | 11 +++++- 9 files changed, 105 insertions(+), 12 deletions(-) create mode 100644 documentation/tool-imdbweb.txt create mode 100644 documentation/tools.txt create mode 100644 webclient/config/config-imdb.php.default diff --git a/CHANGELOG b/CHANGELOG index 7eb9f9a..db4913f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,11 @@ * User management: Honor rights from current logged in user * Group management now available. But no relation check yet. * User management: Additional groups + * Page title available + * Deletion of a collection removes the storage too + * IMDB Tool. Order of save to field now A-Z + * Documentation for tools + * Documentation for tool imdbweb grabber. Default config added. 1.0 - Castle 20210106 * First usable version diff --git a/documentation/setup/install.txt b/documentation/setup/install.txt index 7598f8d..dc8a67f 100644 --- a/documentation/setup/install.txt +++ b/documentation/setup/install.txt @@ -13,6 +13,9 @@ Edit and fill in the DB details. Change PATH_ABSOLUTE to you installation path and PATH_WEB_STORAGE relative to your webroot. +Copy config-imdb.php.default to config-imdb.php. Read the tools.txt and tool-imdbweb.txt and make wanted changes +to that file + 4. Move files Move the content of webclient folder to your webspace. Make sure the location matches the PATH_ABSOLUTE config in config.php file diff --git a/documentation/tool-imdbweb.txt b/documentation/tool-imdbweb.txt new file mode 100644 index 0000000..4d19473 --- /dev/null +++ b/documentation/tool-imdbweb.txt @@ -0,0 +1,13 @@ +IMDB web parser tool + +It provides easy searching for a movie entry within https://www.imdb.com. +Creating a new one with the selected fields or updating an existing one. + +It uses: https://github.com/FabianBeiner/PHP-IMDB-Grabber with some modifications + +You can search for words or the exact imdb id, which is in tt* format of an entry url. +It searches for movies only. + +Which fields are available for you to select, are configured in the config.imdbweb.php file to make it +easier since not every field the tool provides are needed. +Follow the comments in the file for more details. diff --git a/documentation/tools.txt b/documentation/tools.txt new file mode 100644 index 0000000..8513379 --- /dev/null +++ b/documentation/tools.txt @@ -0,0 +1,9 @@ +Each collection can have additional tools. The availability is configured in collection management. + +A tool needs an DB entry in _tool and matching files in view/THEME/tool/. +Filenames are tool-ACTION.html|php +A option configuration file config/config-ACTION.php +A documentation is a must. + +As a base the provided imdbweb parse is already included. It makes it possible to search for a movie within +https://www.imdb.com and let you pick with information should be saved into the entry. diff --git a/upgrade/from-version-1.0.txt b/upgrade/from-version-1.0.txt index 87ae5a2..d065e0b 100644 --- a/upgrade/from-version-1.0.txt +++ b/upgrade/from-version-1.0.txt @@ -5,6 +5,10 @@ have on the old config files. After that you can delete config/database|path|sys # Deletion of config definition The definition of USER_DEFAULT_RIGHTS_STRING can be removed from config file. +# New config file +Copy config/config-imdbweb.php.default to config/config-imdbweb.php +See too-imdbweb.txt documentation for more information. + # DB changes. Run each line against your bibliotheca DB. # Replace #REPLACEME# with your table prefix. Default is bib UPDATE `#REPLACEME#_menu` SET `rights` = 'rw-rw----' WHERE `bib_menu`.`id` = 10; diff --git a/webclient/config/config-imdb.php.default b/webclient/config/config-imdb.php.default new file mode 100644 index 0000000..85375b1 --- /dev/null +++ b/webclient/config/config-imdb.php.default @@ -0,0 +1,23 @@ +sSearchFor = $options['sSearchFor']; } } + + $this->IMDB_BROWSER_AGENT = $options['browserAgent']; + $this->IMDB_BROWSER_LANG = $options['browserLang']; + $this->IMDB_BROWSER_ACCEPT = $options['browserAccept']; + + $this->_showFields = array(); + if(isset($options['showFields']) && !empty($options['showFields'])) { + $this->_showFields = $options['showFields']; + } } @@ -336,6 +360,7 @@ class IMDB $aData = []; foreach (get_class_methods(__CLASS__) as $method) { if (substr($method, 0, 3) === 'get' && $method !== 'getAll' && $method !== 'getCastImages') { + if(!empty($this->_showFields) && !in_array($method,$this->_showFields)) continue; $aData[$method] = [ 'name' => ltrim($method, 'get'), 'value' => $this->{$method}(), @@ -1717,23 +1742,21 @@ class IMDB curl_setopt_array( $oCurl, [ - CURLOPT_BINARYTRANSFER => ($bDownload ? true : false), CURLOPT_CONNECTTIMEOUT => $this->IMDB_TIMEOUT, CURLOPT_ENCODING => '', CURLOPT_FOLLOWLOCATION => 0, CURLOPT_FRESH_CONNECT => 0, CURLOPT_HEADER => ($bDownload ? false : true), CURLOPT_HTTPHEADER => [ - 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', - 'Accept-Charset: utf-8, iso-8859-1;q=0.5', - 'Accept-Language: ' . $this->IMDB_LANG, + 'Accept: '.$this->IMDB_BROWSER_ACCEPT, + 'Accept-Language: ' . $this->IMDB_BROWSER_LANG, ], CURLOPT_REFERER => 'https://www.imdb.com', CURLOPT_RETURNTRANSFER => 1, CURLOPT_SSL_VERIFYHOST => 0, CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_TIMEOUT => $this->IMDB_TIMEOUT, - CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0', + CURLOPT_USERAGENT => $this->IMDB_BROWSER_AGENT, CURLOPT_VERBOSE => 0, ] ); diff --git a/webclient/lib/managecollectionfields.class.php b/webclient/lib/managecollectionfields.class.php index ae091f2..640078c 100644 --- a/webclient/lib/managecollectionfields.class.php +++ b/webclient/lib/managecollectionfields.class.php @@ -247,9 +247,10 @@ class ManageCollectionFields { * Get the fields for currently loaded collection. * * @param bool $refresh True to reload from DB + * @param bool $sortAZ * @return array */ - public function getExistingFields($refresh=false) { + public function getExistingFields($refresh=false, $sortAZ=false) { if($refresh === false && !empty($this->_cacheExistingSysFields)) { return $this->_cacheExistingSysFields; } @@ -257,8 +258,13 @@ class ManageCollectionFields { $queryStr = "SELECT `cf`.`fk_field_id` AS id, `sf`.`type`, `sf`.`displayname`, `sf`.`identifier`, `sf`.`createstring` FROM `".DB_PREFIX."_collection_fields_".$this->_collectionId."` AS cf - LEFT JOIN `".DB_PREFIX."_sys_fields` AS sf ON `cf`.`fk_field_id` = `sf`.`id` - ORDER BY `cf`.`sort`"; + LEFT JOIN `".DB_PREFIX."_sys_fields` AS sf ON `cf`.`fk_field_id` = `sf`.`id`"; + if($sortAZ === true) { + $queryStr .= " ORDER BY `sf`.`displayname`"; + } + else { + $queryStr .= " ORDER BY `cf`.`sort`"; + } if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true)); try { $query = $this->_DB->query($queryStr); diff --git a/webclient/view/default/tool/tool-imdbweb.php b/webclient/view/default/tool/tool-imdbweb.php index c598b1f..68e6b40 100644 --- a/webclient/view/default/tool/tool-imdbweb.php +++ b/webclient/view/default/tool/tool-imdbweb.php @@ -22,10 +22,17 @@ */ require_once 'lib/imdbwebparser.class.php'; +if(file_exists(PATH_ABSOLUTE.'/config/config-imdbweb.php')) { + require_once 'config/config-imdbweb.php'; +} $IMDB = new IMDB(array( - 'sSearchFor' => 'movie', + 'sSearchFor' => TOOL_IMDBWEB_SEARCH, + 'showFields' => TOOL_IMDBWEB_FIELDS, 'storage' => PATH_SYSTEMOUT, + 'browserAgent' => TOOL_IMDBWEB_BROWSER_AGENT, + 'browserLang' => TOOL_IMDBWEB_BROWSER_ACCEPT_LANG, + 'browserAccept' => TOOL_IMDBWEB_BROWSER_ACCEPT, 'debug' => false )); @@ -36,7 +43,7 @@ $TemplateData['showMatchingForm'] = false; // prepare fields to save into selection // create one time and then reuse it -$collectionFields = $ManangeCollectionsFields->getExistingFields(); +$collectionFields = $ManangeCollectionsFields->getExistingFields(false, true); if(!empty($collectionFields)) { foreach ($collectionFields as $k=>$v) { $TemplateData['saveToSelection'] .= "\n"; -- 2.39.5