changed git call from https to git readonly
[atutor.git] / mods / wiki / plugins / aview / piclogocntrl.php
1 <?php 
2
3 /* 
4     This plugin allows users to select a logo graphic which will be available 
5     for use in the template.  Use the line:
6     
7     <img id=Logo src='/graphics/<?php  echo($ewiki_config['page_logo']);   ?>' alt='<?php  echo($ewiki_config['page_logo_alt']);   ?>'>    
8     
9     to insert the graphic.
10 */
11 /* 
12 * @author jeremy mikola <jmikola@arsjerm.net>
13 * @author andy fundinger <afundinger@burgiss.com> (Minor contributions and maintenance)
14 */
15
16
17 $ewiki_plugins['edit_save'][]        = 'ewiki_edit_save_piclogocntrl';
18 $ewiki_plugins['edit_form_append'][] = 'ewiki_edit_form_append_piclogocntrl';
19 $ewiki_plugins["handler"][]        = 'ewiki_set_pickedlogo';
20
21 // array lists all available logo files and titles
22 $piclogocntrlLogos = array(
23     'logo1_01.gif' => 'Logo 1',
24     'logo2_01.gif' => 'Logo 2',
25     'logo3_01.gif' => 'Logo 3',
26     'logo4_01.gif' => 'Logo 4');
27
28 define('DEFAULT_LOGO','BurgissGroup_01.gif');
29
30 function ewiki_set_pickedlogo($id, $data, $action){
31     global $ewiki_config,$piclogocntrlLogos;
32
33     if(isset($ewiki_config['page_logo'])){
34         return;
35     }
36
37     if(!($ewiki_config['page_logo']=$data['meta']['logo'])){
38         $ewiki_config['page_logo']=DEFAULT_LOGO;
39     }
40     
41     $ewiki_config['page_logo_alt']=$piclogocntrlLogos[$ewiki_config['page_logo']];
42 }
43
44 /**
45  * Save selected logo value by setting it in the meta field of save data array
46  * passed by reference.
47  * 
48  * @param array save associative array of ewiki form data
49  */
50 function ewiki_edit_save_piclogocntrl(&$save, &$old_data)
51 {
52     global $piclogocntrlLogos;
53     
54     if (isset($_REQUEST['piclogocntrlSelectLogo']) && array_key_exists($_REQUEST['piclogocntrlSelectLogo'], $piclogocntrlLogos)) {
55         $save['meta']['logo'] = $_REQUEST['piclogocntrlSelectLogo'];
56     }
57 }
58
59 /**
60  * generates html form output for the logo selection field.
61  *
62  * @param mixed id
63  * @param mixed data
64  * @param string action
65  * @return string html output for logo selection fields
66  */
67 function ewiki_edit_form_append_piclogocntrl ($id, $data, $action)
68 {
69     global $piclogocntrlLogos;
70     
71     /*
72      * problem: $data['meta'] is still serialized at this point. it should be
73      * unserialized and accessible as an array in order to fetch the currently
74      * selected logo value.
75      */        
76     
77     $o = '
78         <br /><label for="piclogocntrlSelectLogo">Please choose:</label>
79         <select id="piclogocntrlSelectLogo" name="piclogocntrlSelectLogo">';
80         
81     foreach ($piclogocntrlLogos as $filename => $title) {
82         $o .= '<option value="'.htmlentities($filename).'"'.
83             (isset($data['meta']['logo']) && $filename == $data['meta']['logo'] ? ' selected="selected"' : '').
84             '>'.htmlentities($title).'</option>';
85     }
86
87     $o .= '</select><br /><br />';
88     return($o);
89 }
90
91
92
93 ?>