From: Banana Date: Sun, 31 Jan 2021 17:08:03 +0000 (+0100) Subject: adding #2 and some php syntax features X-Git-Tag: 1.1~19 X-Git-Url: http://91.132.146.200/gitweb/?a=commitdiff_plain;h=f170eeac3b0f177f7f551f761df80baf9e4337bd;p=bibliotheca-php.git adding #2 and some php syntax features --- diff --git a/CHANGELOG b/CHANGELOG index c16af1d..7b38ab0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,8 @@ * Documentation for tools * Documentation for tool imdbweb grabber. Default config added. * Fixed bug #3 + * Added feature #2. There is now a new definition which defines the default targets of the imdb grabber values. + See the config-imdbweb.php.default for more details 1.0 - Castle 20210106 * First usable version diff --git a/documentation/tool-imdbweb.txt b/documentation/tool-imdbweb.txt index 4d19473..e3c4b29 100644 --- a/documentation/tool-imdbweb.txt +++ b/documentation/tool-imdbweb.txt @@ -11,3 +11,5 @@ 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. + +An option to make the target fields automatically selected by default to given values. diff --git a/webclient/config/config-imdb.php.default b/webclient/config/config-imdb.php.default deleted file mode 100644 index 85375b1..0000000 --- a/webclient/config/config-imdb.php.default +++ /dev/null @@ -1,23 +0,0 @@ - 'actors','getDescription' => 'description', 'getDirector' => 'directors', 'getGenre' => 'genres', + 'getPlot' => 'content', 'getRating' => 'imdbrating', 'getRuntime' => 'runtime','getTitle' => 'title', + 'getWriter' => 'writers', 'getYear' => 'year' + ) +); +*/ + +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'); diff --git a/webclient/lib/gorenest.class.php b/webclient/lib/gorenest.class.php index c7f10e4..5c14f6c 100644 --- a/webclient/lib/gorenest.class.php +++ b/webclient/lib/gorenest.class.php @@ -56,7 +56,7 @@ class GoreNest { * @param mysqli $db * @param Doomguy $user */ - public function __construct($db, $user) { + public function __construct(mysqli $db, Doomguy $user) { $this->_DB = $db; $this->_User = $user; } @@ -98,7 +98,7 @@ class GoreNest { * @param bool $reload * @return array */ - public function get($category,$reload=false) { + public function get(string $category, $reload=false) { $ret = array(); if(empty($category)) return false; @@ -120,7 +120,7 @@ class GoreNest { * * @return array */ - public function allowedPageRequests() { + public function allowedPageRequests(): array { return $this->_allowedPageRequests; } } diff --git a/webclient/lib/tentacle.class.php b/webclient/lib/tentacle.class.php index 7e6bab4..66ccd39 100644 --- a/webclient/lib/tentacle.class.php +++ b/webclient/lib/tentacle.class.php @@ -40,8 +40,9 @@ class Tentacle { * * @param mysqli $databaseConnectionObject * @param Doomguy $userObj + * */ - public function __construct($databaseConnectionObject, $userObj) { + public function __construct(mysqli $databaseConnectionObject, Doomguy $userObj) { $this->_DB = $databaseConnectionObject; $this->_User = $userObj; } @@ -50,10 +51,10 @@ class Tentacle { * Validate if given action is a valid tool and if the user has access * * @param string $identifier - * @return bool|mixed + * @return array */ - public function validate($identifier) { - $ret = false; + public function validate(string $identifier): array { + $ret = array(); $queryStr = "SELECT `name`,`description`,`action` FROM `".DB_PREFIX."_tool` @@ -79,7 +80,7 @@ class Tentacle { * * @return array */ - public function getDefaultCreationInfo() { + public function getDefaultCreationInfo(): array { return array( 'id' => $this->_User->param('id'), 'group' => $this->_User->param('baseGroupId'), diff --git a/webclient/view/default/managecollectionfields/managecollectionfields.html b/webclient/view/default/managecollectionfields/managecollectionfields.html index 8b4be13..332a2b1 100644 --- a/webclient/view/default/managecollectionfields/managecollectionfields.html +++ b/webclient/view/default/managecollectionfields/managecollectionfields.html @@ -14,7 +14,7 @@ $v) { ?>
- () + ()
@@ -35,7 +35,7 @@ $v) { ?>
- () + ()
diff --git a/webclient/view/default/tool/tool-imdbweb.html b/webclient/view/default/tool/tool-imdbweb.html index 2009d43..a2f2b0d 100644 --- a/webclient/view/default/tool/tool-imdbweb.html +++ b/webclient/view/default/tool/tool-imdbweb.html @@ -37,7 +37,7 @@
diff --git a/webclient/view/default/tool/tool-imdbweb.php b/webclient/view/default/tool/tool-imdbweb.php index 68e6b40..b3e3601 100644 --- a/webclient/view/default/tool/tool-imdbweb.php +++ b/webclient/view/default/tool/tool-imdbweb.php @@ -46,7 +46,7 @@ $TemplateData['showMatchingForm'] = false; $collectionFields = $ManangeCollectionsFields->getExistingFields(false, true); if(!empty($collectionFields)) { foreach ($collectionFields as $k=>$v) { - $TemplateData['saveToSelection'] .= "\n"; + $TemplateData['saveToSelection'] .= "\n"; } } @@ -157,3 +157,25 @@ if(isset($_POST['submitFormSave'])) { } } } + + +/** + * Helper function. Takes the prebuild options for the target selection field and search for a matching key. + * Since the optionString is prebuild, avoiding looping over and over again, the selection needs to be done + * by search and replace. + * Checks if TOOL_IMDBWEB_FIELDS_TO is defined and a matching key=>value pair is available + * + * @param string $optionString + * @param string $imdbKey + * @return string + */ +function toolMethod_GetTargetSelection(string $optionString, string $imdbKey): string { + if(defined('TOOL_IMDBWEB_FIELDS_TO') & !empty($imdbKey)) { + if(isset(TOOL_IMDBWEB_FIELDS_TO[$imdbKey])) { + $_k = "sel_".TOOL_IMDBWEB_FIELDS_TO[$imdbKey]; + $optionString = str_replace($_k,'selected="selected"',$optionString); + } + } + + return $optionString; +}