]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/Imdb.php
Normalize header
[SourceForge/phpwiki.git] / lib / plugin / Imdb.php
1 <?php // -*-php-*-
2 rcs_id('$Id$');
3 /*
4  * Copyright 2004 $ThePhpWikiProgrammingTeam
5  * 
6  * This file is (not yet) part of PhpWiki.
7  *
8  * PhpWiki is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * PhpWiki is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with PhpWiki; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 /**
24  * Query results from a local imdb copy.
25  * see amdbfront for the conversion.
26  * "imdb = mysql://user:pass@localhost/imdb" in lib/plugin/SqlResult.ini
27  *
28  * Queries:
29  * <?plugin Imdb query=movie_main title||="Sample Movie (2002)" ?>
30  * <?plugin Imdb query=movie_combined title||="Sample Movie (2002)" ?>
31  * <?plugin Imdb query=movie_full title||="Sample Movie (2002)" ?>
32  * <?plugin Imdb query=movie_company_credits title||="Sample Movie (2002)" ?>
33  * <?plugin Imdb query=name name||="Lastname, Firstname (I)" ?>
34  * More title queries:
35  *  business, moviebudgets, colorinfo, mpaaratingsreasons,
36  *  akatitles, alternateversions, miscellaneouscompanies, moviecountries,
37  *  certificates, completecast, completecrew, crazycredits, genres, goofs,
38  *  keywords, movielinks, plot, quotes, ratings, soundtracks, specialeffectscompanies,
39  *  taglines, trivia, distributors, language, laserdisc, literature, locations,
40  *  miscellaneouscompanies, productioncompanies, releasedates, runningtimes, soundmix,
41  *  technical
42  * More name queries:
43  *   akanames, guestappearances, biographies
44  *   job.descriptions
45  *
46  * @author: ReiniUrban
47  */
48
49 include_once("lib/plugin/SqlResult.php");
50
51 class WikiPlugin_Imdb
52 extends WikiPlugin_SqlResult
53 {
54     function getName () {
55         return _("Imdb");
56     }
57
58     function getDescription () {
59         return _("Query a local imdb database");
60     }
61
62     function getVersion() {
63         return preg_replace("/[Revision: $]/", '',
64                             "\$Revision$");
65     }
66
67     function getDefaultArguments() {
68         return array(
69                      'query'       => false, // what
70                      'template'    => false, // TODO: use a custom <theme>/template.tmpl for the result
71                      'where'       => false, // custom filter for the query
72                      'title'       => false, // custom filter for the query
73                      'name'        => false, // custom filter for the query
74                      'sortby'      => false, // for paging, default none
75                      'limit'       => false, // for paging, default: only the first 50 
76                     );
77     }
78
79     function run($dbi, $argstr, &$request, $basepage) {
80         $args = $this->getArgs($argstr, $request);
81         extract($args);
82         include_once("lib/imdb.php");
83         $imdb = new imdb();
84
85         if (method_exists($imdb, $query)) {
86             $SqlResult = $imdb->$query($title ? $title : $name);
87         } else {
88             $SqlResult = array();
89         }
90
91         // if ($limit) ; // TODO: fill paging vars (see PageList)
92         if ($ordered) {
93             $html = HTML::ol(array('class'=>'sqlresult'));
94             foreach ($SqlResult as $row) {
95                 $html->pushContent(HTML::li(array('class'=> $i++ % 2 ? 'evenrow' : 'oddrow'), $row[0]));
96             }
97         } else {
98             $html = HTML::table(array('class'=>'sqlresult'));
99             $i = 0;
100             foreach ($SqlResult as $row) {
101                 $tr = HTML::tr(array('class'=> $i++ % 2 ? 'evenrow' : 'oddrow'));
102                 foreach ($row as $col) {
103                     $tr->pushContent(HTML::td($col));
104                 }
105                 $html->pushContent($tr);
106             }
107         }
108         // if ($limit) ; // do paging via pagelink template
109         return $html;
110     }
111 };
112
113 // For emacs users
114 // Local Variables:
115 // mode: php
116 // tab-width: 8
117 // c-basic-offset: 4
118 // c-hanging-comment-ender-p: nil
119 // indent-tabs-mode: nil
120 // End:
121 ?>