Dotclear

source: plugins/myGmaps/branches/inc/lib.my.gmaps.ui.php @ 2879

Revision 2879, 3.6 KB checked in by Tomtom33, 13 years ago (diff)

Watch out #5

Line 
1<?php
2
3class myGmapsUtils
4{
5     public static function getMapIcons()
6     {
7          $list = files::getDirList(path::real(dirname(__FILE__).'/../icons'));
8          return $list['files'];
9     }
10     
11     public static function getAdminIconURL($filename)
12     {
13          return sprintf('index.php?pf=myGmaps/icons/%s',$filename);
14     }
15     
16     public static function getMapIconsJS()
17     {
18          $root = path::real(dirname(__FILE__).'/../icons');
19          $icons = array();
20         
21          $mask = '#'.$root.'/(.*)#';
22         
23          foreach (self::getMapIcons() as $icon)
24          {
25               $icon = preg_replace('#'.$root.'/(.*)#',"'index.php?pf=myGmaps/icons/$1'",$icon); 
26               array_push($icons,$icon);
27          }
28         
29          return sprintf('myGmaps.icons = [%s];',implode(',',$icons));
30     }
31}
32
33class adminMyGmapsList extends adminGenericList
34{
35     public function display($page,$nb_per_page,$p_url,$enclose_block='')
36     {
37          if ($this->rs->isEmpty())
38          {
39               echo '<p><strong>'.__('No element').'</strong></p>';
40          }
41          else
42          {
43               $pager = new pager($page,$this->rs_count,$nb_per_page,10);
44               $pager->html_prev = $this->html_prev;
45               $pager->html_next = $this->html_next;
46               $pager->var_page = 'page';
47
48               $html_block =
49               '<table class="clear"><tr>'.
50               '<th colspan="2">'.__('Title').'</th>'.
51               '<th>'.__('Date').'</th>'.
52               '<th>'.__('Category').'</th>'.
53               '<th>'.__('Author').'</th>'.
54               '<th class="nowrap">'.__('Map element type').'</th>'.
55               '<th>'.__('Status').'</th>'.
56               '</tr>%s</table>';
57
58               if ($enclose_block) {
59                    $html_block = sprintf($enclose_block,$html_block);
60               }
61
62               echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
63
64               $blocks = explode('%s',$html_block);
65
66               echo $blocks[0];
67
68               while ($this->rs->fetch())
69               {
70                    echo $this->postLine($p_url);
71               }
72
73               echo $blocks[1];
74
75               echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
76          }
77     }
78
79     private function postLine($p_url)
80     {
81          if ($this->core->auth->check('categories',$this->core->blog->id)) {
82               $cat_link = '<a href="category.php?id=%s">%s</a>';
83          } else {
84               $cat_link = '%2$s';
85          }
86          $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
87          switch ($this->rs->post_status) {
88               case 1:
89                    $img_status = sprintf($img,__('published'),'check-on.png');
90                    break;
91               case -2:
92                    $img_status = sprintf($img,__('pending'),'check-wrn.png');
93                    break;
94               case 0:
95                    $img_status = sprintf($img,__('unpublished'),'check-off.png');
96                    break;
97          }
98          if ($this->rs->cat_title) {
99               $cat_title = sprintf($cat_link,$this->rs->cat_id,
100               html::escapeHTML($this->rs->cat_title));
101          } else {
102               $cat_title = __('None');
103          }
104
105          $res = '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'.
106          ' id="p'.$this->rs->post_id.'">';
107         
108          $type_list = array(
109               'none' => __('None'),
110               'marker' => __('Point of interest'),
111               'polyline' => __('Polyline'),
112               'polygon' => __('Polygon'),
113               'kml' => __('Included kml file')
114          );
115          $meta = unserialize($this->rs->post_meta);
116         
117          $type = array_key_exists($meta['elt_type'][0],$type_list) ? $type_list[$meta['elt_type'][0]] : '';
118
119          $res .=
120          '<td class="nowrap">'.
121          form::checkbox(array('entries[]'),$this->rs->post_id,'','','',!$this->rs->isEditable()).'</td>'.
122          '<td class="maximal"><a href="'.$p_url.'&amp;go=map&amp;id='.$this->rs->post_id.'">'.
123          html::escapeHTML($this->rs->post_title).'</a></td>'.
124          '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'.
125          '<td class="nowrap">'.$cat_title.'</td>'.
126          '<td class="nowrap">'.$this->rs->user_id.'</td>'.
127          '<td class="nowrap">'.$type.'</td>'.
128          '<td class="nowrap status">'.$img_status.'</td>'.
129          '</tr>';
130
131          return $res;
132     }
133}
134
135?>
Note: See TracBrowser for help on using the repository browser.

Sites map