]> 91.132.146.200 Git - bibliotheca-php.git/commitdiff
tool documentations. Tool imdbweb has its own config file and documentation
authorBanana <mail@bananas-playground.net>
Sun, 17 Jan 2021 20:02:41 +0000 (21:02 +0100)
committerBanana <mail@bananas-playground.net>
Sun, 17 Jan 2021 20:02:41 +0000 (21:02 +0100)
CHANGELOG
documentation/setup/install.txt
documentation/tool-imdbweb.txt [new file with mode: 0644]
documentation/tools.txt [new file with mode: 0644]
upgrade/from-version-1.0.txt
webclient/config/config-imdb.php.default [new file with mode: 0644]
webclient/lib/imdbwebparser.class.php
webclient/lib/managecollectionfields.class.php
webclient/view/default/tool/tool-imdbweb.php

index 7eb9f9a97ff9ac0f1299beb8bcd8bb30d7212f3f..db4913f88b5fc9a94fa8ab9d69de352863a53996 100644 (file)
--- 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
index 7598f8dd19e41597719509d122eb10588cb3a372..dc8a67f71eef2056e4032b60e97e3096bf46308c 100644 (file)
@@ -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 (file)
index 0000000..4d19473
--- /dev/null
@@ -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 (file)
index 0000000..8513379
--- /dev/null
@@ -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.
index 87ae5a260831ecaa93bc14e12b0e0fa065091b27..d065e0bf3fd866aad8bdaaca2c9d909849c10f33 100644 (file)
@@ -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 (file)
index 0000000..85375b1
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+/**
+ * Options for the grabber
+ *
+ * TOOL_IMDBWEB_SEARCH can be 'movie','tv','episode','game','all'. Default is movie
+ * TOOL_IMDBWEB_FIELDS is an array to define which fields from IMDB are displayed for selection
+ *             an empty array() shows all.
+ *             getAka, getAkas, getAspectRatio, getAwards, getBudget, getCast, getCastAndCharacter, CastAndCharacterAsUrl,
+ *             getCastAsUrl, getCertification, getColor, getCompany, getCompanyAsUrl, getCountry, getCountryAsUrl,
+ *             getCreator, getCreatorAsUrl, getDescription, getDirector, getDirectorAsUrl, getGenre, getGenreAsUrl,
+ *             getGross, getLanguage, getLanguageAsUrl, getLocation, getLocationAsUrl, getLocations, getMpaa, getPlot,
+ *             getPlotKeywords, getPoster, getRating, getRatingCount, getReleaseDate, getReleaseDates, getRuntime,
+ *             getSeasons, getSeasonsAsUrl, getSoundMix, getTagline, getTitle, getTrailerAsUrl, getUrl, getUserReview,
+ *             getVotes, getWriter, getWriterAsUrl, getYear
+ * TOOL_IMDBWEB_BROWSERSTRING a current browser agent string. Should be updated from time to time. See default config file.
+ * TOOL_IMDBWEB_BROWSER_ACCEPT_LANG should define in which language the content returns
+*/
+define('TOOL_IMDBWEB_SEARCH','movie');
+define('TOOL_IMDBWEB_FIELDS', array('getCast','getDescription', 'getDirector', 'getGenre', 'getPlot', 'getRating', 'getRuntime','getTitle', 'getWriter', 'getYear'));
+
+define('TOOL_IMDBWEB_BROWSER_AGENT','Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0');
+define('TOOL_IMDBWEB_BROWSER_ACCEPT','text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8');
+define('TOOL_IMDBWEB_BROWSER_ACCEPT_LANG','en-US,en;q=0.5');
index fc3ecc1b21980c62661e4d8f521b131c04ade19b..524a6c7c63858aa984ab30094631de8693e97d81 100644 (file)
@@ -29,7 +29,17 @@ class IMDB
        /**
         * Set the preferred language for the User Agent.
         */
-       private $IMDB_LANG = 'en-US,en;q=0.9';
+       private $IMDB_BROWSER_LANG;
+
+       /**
+        * @var string The accept string for curl call
+        */
+       private $IMDB_BROWSER_ACCEPT;
+
+       /**
+        * @var string The user-agent string fpr curl call
+        */
+       private $IMDB_BROWSER_AGENT;
 
        /**
         * Define the timeout for cURL requests.
@@ -133,6 +143,11 @@ class IMDB
         */
        private $sSearchFor = 'all';
 
+       /**
+        * @var array The fields to return at getAll
+        */
+       private $_showFields;
+
        /**
         * IMDB constructor. Can now set some options
         *
@@ -140,7 +155,7 @@ class IMDB
         *      int iCache Custom cache time in minutes.
         *      string sSearchFor What type to search for?
         *      string storage Where to store data. Absolute path
-        *      boolean debug Show depubg messages or not
+        *      boolean debug Show debug messages or not
         */
        public function __construct($options) {
 
@@ -169,6 +184,15 @@ class IMDB
                                $this->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,
                        ]
                );
index ae091f2170c47427e79681e2322ba2581e61bf57..640078c2950c957c2ef75b6f6a839e009b1bb357 100644 (file)
@@ -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);
index c598b1fccdd7eeac0def03995ff41446ba49ba51..68e6b406c8913905af85de85c82eff7160f9963a 100644 (file)
  */
 
 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'] .= "<option value='".$k."'>".$v['displayname']."</option>\n";