* 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
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.
+++ /dev/null
-<?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');
--- /dev/null
+<?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_FIELDS_TO is a array to define which imdbwebfield (see TOOL_IMDBWEB_FIELDS) should be saved into
+ * a bibliotheca field. Those or the fields a collection can have. Use the identifier of a field.
+ * Depends on your settings so make sure everything is setup first. Leave it commented if not needed.
+ * 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_FIELDS_TO',
+ array(
+ 'getCast' => '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');
* @param mysqli $db
* @param Doomguy $user
*/
- public function __construct($db, $user) {
+ public function __construct(mysqli $db, Doomguy $user) {
$this->_DB = $db;
$this->_User = $user;
}
* @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;
*
* @return array
*/
- public function allowedPageRequests() {
+ public function allowedPageRequests(): array {
return $this->_allowedPageRequests;
}
}
*
* @param mysqli $databaseConnectionObject
* @param Doomguy $userObj
+ *
*/
- public function __construct($databaseConnectionObject, $userObj) {
+ public function __construct(mysqli $databaseConnectionObject, Doomguy $userObj) {
$this->_DB = $databaseConnectionObject;
$this->_User = $userObj;
}
* 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`
*
* @return array
*/
- public function getDefaultCreationInfo() {
+ public function getDefaultCreationInfo(): array {
return array(
'id' => $this->_User->param('id'),
'group' => $this->_User->param('baseGroupId'),
<?php foreach($TemplateData['existingFields'] as $k=>$v) { ?>
<div data-field-id="<?php echo $k; ?>">
<span class="uk-sortable-handle uk-margin-small-right" uk-icon="icon: table"></span>
- <?php echo $v['displayname']; ?> (<?php echo $v['type']; ?>)
+ <?php echo $v['displayname']; ?> (<?php echo $v['type'],'; ',$v['identifier']; ?>)
</div>
<?php } ?>
</div>
<?php foreach($TemplateData['availableFields'] as $k=>$v) { ?>
<div data-field-id="<?php echo $k; ?>">
<span class="uk-sortable-handle uk-margin-small-right" uk-icon="icon: table"></span>
- <?php echo $v['displayname']; ?> (<?php echo $v['type']; ?>)
+ <?php echo $v['displayname']; ?> (<?php echo $v['type'],'; ',$v['identifier']; ?>)
</div>
<?php } ?>
</div>
<div class="uk-width-1-2@s">
<select class="uk-select" name="fdata[into][<?php echo $k; ?>]">
<option value="">None</option>
- <?php echo $TemplateData['saveToSelection']; ?>
+ <?php echo toolMethod_GetTargetSelection($TemplateData['saveToSelection'],$k); ?>
</select>
</div>
$collectionFields = $ManangeCollectionsFields->getExistingFields(false, true);
if(!empty($collectionFields)) {
foreach ($collectionFields as $k=>$v) {
- $TemplateData['saveToSelection'] .= "<option value='".$k."'>".$v['displayname']."</option>\n";
+ $TemplateData['saveToSelection'] .= "<option value='".$k."' sel_".$v['identifier'].">".$v['displayname']."</option>\n";
}
}
}
}
}
+
+
+/**
+ * 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;
+}