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