Did a new mod to videodb. To be able to add custom genres, and automatically add imdb genres:
OPEN edit.php
FIND
// check if genre is found- otherwise fail silently
if (is_numeric($genre = getGenreId($gname)))
{
$genres[] = $genre;
}
if (is_numeric($genre = getGenreId($gname)))
{
$genres[] = $genre;
}
REPLACE WITH
// BEGIN MOD - add genres
/*
// check if genre is found- otherwise fail silently
if (is_numeric($genre = getGenreId($gname)))
{
$genres[] = $genre;
}
*/
// check if genre is found- otherwise add genre
if (is_numeric($genre = getGenreId($gname)))
{
$genres[] = $genre;
} elseif(!empty($gname)) {
$genres[]=addGenre($gname);
}
// END MOD
/*
// check if genre is found- otherwise fail silently
if (is_numeric($genre = getGenreId($gname)))
{
$genres[] = $genre;
}
*/
// check if genre is found- otherwise add genre
if (is_numeric($genre = getGenreId($gname)))
{
$genres[] = $genre;
} elseif(!empty($gname)) {
$genres[]=addGenre($gname);
}
// END MOD
OPEN core/genres.php
FIND
$SELECT = 'SELECT genres.id, genres.name
FROM '.TBL_GENRES.' AS genres, '.TBL_VIDEOGENRE.' AS videogenre
WHERE genres.id = videogenre.genre_id
AND videogenre.video_id = '.$id;
FROM '.TBL_GENRES.' AS genres, '.TBL_VIDEOGENRE.' AS videogenre
WHERE genres.id = videogenre.genre_id
AND videogenre.video_id = '.$id;
AFTER, ADD
// BEGIN MOD - genres
$SELECT .= ' ORDER BY genres.name';
// END MOD
$SELECT .= ' ORDER BY genres.name';
// END MOD
FIND
runSQL('INSERT INTO '.TBL_VIDEOGENRE.' SET video_id = '.$id.', genre_id = '.$genre);
REPLACE WITH
// BEGIN MOD - custom genres
/*
runSQL('INSERT INTO '.TBL_VIDEOGENRE.' SET video_id = '.$id.', genre_id = '.$genre);
*/
if(!empty($genre)){
if(!is_numeric($genre)){
$genre=runSQL('INSERT INTO '. TBL_GENRES.' SET name="'.addslashes($genre).'"');
}
runSQL('INSERT INTO '.TBL_VIDEOGENRE.' SET video_id = '.$id.', genre_id = '.$genre);
}
// END MOD
/*
runSQL('INSERT INTO '.TBL_VIDEOGENRE.' SET video_id = '.$id.', genre_id = '.$genre);
*/
if(!empty($genre)){
if(!is_numeric($genre)){
$genre=runSQL('INSERT INTO '. TBL_GENRES.' SET name="'.addslashes($genre).'"');
}
runSQL('INSERT INTO '.TBL_VIDEOGENRE.' SET video_id = '.$id.', genre_id = '.$genre);
}
// END MOD
OPEN /templates/elegant/edit.tpl
FIND
{$genreselect}
AFTER, ADD
{* BEGIN MOD - custom genres *}
<label for="other">New genre: </label><input id="other" maxlength="32" name="genres[]" size="15" type="text" />
{* END MOD *}
<label for="other">New genre: </label><input id="other" maxlength="32" name="genres[]" size="15" type="text" />
{* END MOD *}
[edit] Made a mistake. Selecting "Add missing" won't add genres the way originally written. To fix this:
OPEN edit.php
FIND:
REPLACE WITH:
// BEGIN MOD
/*
if (count($genres) == 0 || ($lookup > 1))
*/
if (count($genres) == 1 || ($lookup > 1))
// END MOD
/*
if (count($genres) == 0 || ($lookup > 1))
*/
if (count($genres) == 1 || ($lookup > 1))
// END MOD
This entry was posted
on Monday, March 8th, 2010 at 5:19 pm and is filed under PHP programming, videodb.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
2 comments so far
Leave a reply
You must be logged in to post a comment.