1 : <?php
2 :
3 : /**
4 : * Dictionaries of Old French and Latin
5 : *
6 : * PHP 5
7 : *
8 : * @category Application
9 : * @package DicFro
10 : * @author Michel Corne <mcorne@yahoo.com>
11 : * @copyright 2008-2010 Michel Corne
12 : * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3)
13 : * @link http://www.micmap.org/dicfro
14 : */
15 :
16 : require_once 'ViewHelper/Base.php';
17 :
18 : /**
19 : * Images View Helper
20 : *
21 : * @category Application
22 : * @package DicFro
23 : * @author Michel Corne <mcorne@yahoo.com>
24 : * @copyright 2008-2010 Michel Corne
25 : * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3)
26 : */
27 :
28 : class ViewHelper_Images extends ViewHelper_Base
29 : {
30 : /**
31 : * Image information
32 : * @var array
33 : */
34 : public $images = array(
35 : // dicfro home and default
36 : 'default' => array(
37 : 'file' => 'dicfro.jpg',
38 : 'source' => 'http://farm2.static.flickr.com/1147/533118282_dcd53c68cb.jpg',
39 : ),
40 : // information pages
41 : 'help' => array(
42 : 'file' => 'help.jpg',
43 : 'source' => 'http://www.cclspompano.com/448894_82304673.jpg',
44 : ),
45 : 'about' => array(
46 : 'file' => 'about.jpg',
47 : 'source' => '',
48 : ),
49 : // dictionnaires internes
50 : 'complement-godefroy' => array(
51 : 'file' => 'complement-godefroy.jpg',
52 : 'source' => 'http://farm1.static.flickr.com/137/327471676_7557f4d649.jpg',
53 : ),
54 : 'dictionnaire-godefroy' => array(
55 : 'file' => 'dictionnaire-godefroy.jpg',
56 : 'source' => 'http://upload.wikimedia.org/wikipedia/commons/a/a4/Old_book_bindings_cropped.jpg',
57 : ),
58 : 'gaffiot' => array(
59 : 'file' => 'gaffiot.jpg',
60 : 'source' => 'http://multimedia.fnac.com/multimedia/images_produits/ZoomPE/6/5/6/9782011667656.jpg',
61 : ),
62 : 'glossaire-chanson-de-roland' => array(
63 : 'file' => 'glossaire-chanson-de-roland.jpg',
64 : 'source' => 'http://www.hs-augsburg.de/~harsch/gallica/Chronologie/11siecle/Roland/rol_pict.jpg',
65 : ),
66 : 'glossaire-chretien-de-troyes' => array(
67 : 'file' => 'dictionnaire-chretien-de-troyes.jpg',
68 : 'source' => 'http://galatea.univ-tlse2.fr/pictura/UtpicturaServeur/Images/NePasOuvrir/0/A0709.jpg',
69 : ),
70 : 'glossaire-couronnement-de-louis' => array(
71 : 'file' => 'glossaire-couronnement-de-louis.jpg',
72 : 'source' => 'http://histoireenprimaire.free.fr/images/sacre_st_louis.jpg',
73 : ),
74 : 'glossaire-roman-de-la-rose' => array(
75 : 'file' => 'glossaire-roman-de-la-rose.jpg',
76 : 'source' => 'http://expositions.bnf.fr/livres/rose/index.htm',
77 : ),
78 : 'glossaire-roman-de-tristan' => array(
79 : 'file' => 'glossaire-roman-de-tristan.jpg',
80 : 'source' => 'http://beaujarret.fiftiz.fr/blog/images/b/e/beaujarret/121896783993.jpeg',
81 : ),
82 : 'lexique-godefroy' => array(
83 : 'file' => 'lexique-godefroy.jpg',
84 : 'source' => 'http://www.voilieraventures.com/photos/old%20book%206.gif',
85 : ),
86 : 'lexique-roman' => array(
87 : 'file' => 'lexique-roman.jpg',
88 : 'source' => 'http://www.histoiredesjuifs.com/images/1230%20Susskind_von_Trimberg.jpg',
89 : ),
90 : 'tableaux-de-conjugaison' => array(
91 : 'file' => 'tableaux-de-conjugaison.jpg',
92 : 'source' => 'http://ant_deus.pagesperso-orange.fr/veillesurmoi/verbes.jpg',
93 : ),
94 : 'vandaele' => array(
95 : 'file' => 'vandaele.jpg',
96 : 'source' => 'http://www.fleuron-du-cuir.com/images-ok/23-restauration-livre-ancien-03.jpg',
97 : ),
98 : );
99 :
100 : /**
101 : * Returns the image name
102 : *
103 : * @return string the image name
104 : */
105 : public function getImageName()
106 : {
107 3 : $name = $this->view->information?
108 1 : basename($this->view->information, '.phtml') :
109 3 : $this->view->dictionary;
110 :
111 3 : isset($this->images[$name]) or $name = 'default';
112 :
113 3 : return $name;
114 : }
115 :
116 : /**
117 : * Returns the image file name
118 : *
119 : * @return string the image pathname
120 : */
121 : public function getImageFile()
122 : {
123 1 : $name = $this->getImageName();
124 :
125 1 : return $this->view->setLinkUrl("img/pages/{$this->images[$name]['file']}");
126 : }
127 :
128 : /**
129 : * Returns the image source URL
130 : *
131 : * @return string the image source URL
132 : */
133 : public function getImageSourceUrl()
134 : {
135 1 : $name = $this->getImageName();
136 :
137 1 : return $this->images[$name]['source'];
138 : }
|