Changeset 2879
- Timestamp:
- 01/13/11 17:08:52 (13 years ago)
- Location:
- plugins/myGmaps/branches
- Files:
-
- 2 added
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/myGmaps/branches/_admin.php
r2868 r2879 64 64 { 65 65 return 66 '<script type="text/javascript">'."\n". 66 dcPage::jsLoad('index.php?pf=myGmaps/js/_post.js'); 67 /*'<script type="text/javascript">'."\n". 67 68 '$(document).ready(function() {'."\n". 68 69 '$(\'a.map-remove\').click(function() {'."\n". … … 88 89 'color : #06c !important;'."\n". 89 90 '}'."\n". 90 '</style>'; 91 '</style>';*/ 91 92 92 93 } … … 102 103 echo 103 104 '<fieldset><legend>'.__('Google Map').'</legend>'. 104 '<p><a href="plugin.php?p=myGmaps&post_id='.$id.'">'.__('Add a map to entry').'</a></p>'.105 '<p><a class="add-maps" href="plugin.php?p=myGmaps&go=maps_popup&popup=1&post_id='.$id.'">'.__('Add a map to entry').'</a></p>'. 105 106 '</fieldset>'; 106 107 } else { -
plugins/myGmaps/branches/inc/lib.my.gmaps.ui.php
r2877 r2879 119 119 $res .= 120 120 '<td class="nowrap">'. 121 form::checkbox(array(' ids[]'),$this->rs->post_id,'','','',!$this->rs->isEditable()).'</td>'.121 form::checkbox(array('entries[]'),$this->rs->post_id,'','','',!$this->rs->isEditable()).'</td>'. 122 122 '<td class="maximal"><a href="'.$p_url.'&go=map&id='.$this->rs->post_id.'">'. 123 123 html::escapeHTML($this->rs->post_title).'</a></td>'. -
plugins/myGmaps/branches/index.php
r2868 r2879 13 13 if (!defined('DC_CONTEXT_ADMIN')) return; 14 14 15 $p_url = 'plugin.php?p=myGmaps'; 15 $p_url = 'plugin.php?p=myGmaps'; 16 $filters = array( 17 'user_id', 18 'cat_id', 19 'status', 20 'post_maps', 21 'month', 22 'lang', 23 'sortby', 24 'order', 25 'page', 26 'nb' 27 ); 16 28 17 29 $go = isset($_GET['go']) ? $_GET['go'] : 'maps'; … … 23 35 require_once dirname(__FILE__).'/map.php'; 24 36 } 25 elseif ($go === 'popup') { 26 require_once dirname(__FILE__).'/popup.php'; 37 elseif ($go === 'maps_actions') { 38 require_once dirname(__FILE__).'/maps_actions.php'; 39 } 40 elseif ($go === 'maps_popup') { 41 require_once dirname(__FILE__).'/maps_popup.php'; 27 42 } 28 43 44 29 45 ?> -
plugins/myGmaps/branches/js/_map.js
r2877 r2879 24 24 // Hide some fields 25 25 $('#description-area label').toggleWithLegend($('#description-area').children().not('label'), { 26 cookie: 'dcx_map_description', 27 hide: $('#post_content').val() == myGmaps.msg.no_description 26 cookie: 'dcx_map_description' 28 27 }); 29 28 $('#map-details-area label').toggleWithLegend($('#map-details'), { … … 31 30 }); 32 31 $('#notes-area label').toggleWithLegend($('#notes-area').children().not('label'), { 33 cookie: 'dcx_post_notes', 34 hide: $('#post_notes').val() == '' 32 cookie: 'dcx_post_notes' 35 33 }); 36 34 -
plugins/myGmaps/branches/maps.php
r2877 r2879 11 11 # -- END LICENSE BLOCK ------------------------------------ 12 12 13 $tab 13 $tab = isset($_GET['tab']) ? $_GET['tab'] : 'list'; 14 14 15 15 # Save config … … 43 43 } 44 44 http::redirect($p_url.'&go=maps&tab=icons&del=1'); 45 } catch (Exception $e) {46 $core->error->add($e->getMessage());47 }48 }49 # Actions50 if (!empty($_POST['action']))51 {52 try {53 $ids = $_POST['ids'];54 $act = $_POST['action'];55 $redir = 0;56 # Change map posts status57 if ($act === 'published' || $act === 'pending' || $act === 'unpublished') {58 foreach ($ids as $id) {59 switch ($act) {60 case 'published' : $status = 1; break;61 case 'pending' : $status = -2; break;62 case 'unpublished' : $status = 0; break;63 default : $status = 1; break;64 }65 $core->blog->updPostStatus($id,$status);66 }67 $redir = 1;68 }69 # change category or author70 if ($act === 'category' || $act === 'author') {71 require_once dirname(__FILE__).'/maps_actions.php';72 exit;73 }74 # Delete map posts75 if ($act === 'delete') {76 foreach ($ids as $id) {77 # --BEHAVIOR-- adminBeforePostDelete78 $core->callBehavior('adminBeforePostDelete',$id);79 $core->blog->delPost($id);80 }81 $redir = 2;82 }83 http::redirect($p_url.'&act='.$redir);84 45 } catch (Exception $e) { 85 46 $core->error->add($e->getMessage()); … … 305 266 } 306 267 if (isset($_GET['act']) && $_GET['act'] === '2') { 268 $msg = __('Selected map posts categories have been successfully changed'); 269 } 270 if (isset($_GET['act']) && $_GET['act'] === '3') { 271 $msg = __('Selected map posts authors have been successfully changed'); 272 } 273 if (isset($_GET['act']) && $_GET['act'] === '4') { 307 274 $msg = __('Selected map posts have been successfully deleted'); 308 275 } … … 360 327 '</form>'; 361 328 329 $hidden_fields = ''; 330 foreach ($filters as $k) { 331 if (array_key_exists($k,$_GET)) { 332 $hidden_fields .= form::hidden(array($k),$_GET[$k]); 333 } 334 } 362 335 # Show posts 363 336 $post_list->display($page,$nb_per_page,$p_url, 364 '<form action="'.$p_url.' " method="post" id="form-entries">'.337 '<form action="'.$p_url.'&go=maps_actions" method="post" id="form-entries">'. 365 338 366 339 '%s'. … … 371 344 '<p class="col right">'.__('Selected map elements action:').' '. 372 345 form::combo('action',$combo_action). 346 $hidden_fields. 373 347 '<input type="submit" value="'.__('ok').'" /></p>'. 374 348 $core->formNonce(). -
plugins/myGmaps/branches/maps_actions.php
r2864 r2879 11 11 # -- END LICENSE BLOCK ------------------------------------ 12 12 13 require_once DC_ROOT.'/inc/admin/prepend.php'; 13 $entries = isset($_POST['entries']) ? $_POST['entries'] : array(); 14 $action = isset($_POST['action']) ? $_POST['action'] : ''; 15 $redir = isset($_POST['redir']) ? $_POST['redir'] : $p_url; 16 17 foreach ($entries as $k => $v) { 18 $entries[$k] = (integer) $v; 19 } 14 20 15 dcPage::check('usage,contentadmin'); 21 $params['sql'] = 'AND P.post_id IN('.implode(',',$entries).') '; 22 $params['post_type'] = 'map'; 23 $params['no_content'] = true; 16 24 17 $p arams = array();25 $posts = $core->blog->getPosts($params); 18 26 19 $p_url = 'plugin.php?p='.basename(dirname(__FILE__)); 27 foreach ($filters as $k) { 28 if (array_key_exists($k,$_POST)) { 29 $redir .= sprintf('&%s=%s',$k,$_POST[$k]); 30 } 31 } 20 32 21 33 /* Actions 22 34 -------------------------------------------------------- */ 23 if (!empty($ _POST['action']) && !empty($_POST['entries']))35 if (!empty($action) && count(entries) > 0) 24 36 { 25 $entries = $_POST['entries']; 26 $action = $_POST['action']; 27 28 if (isset($_POST['redir']) && strpos($_POST['redir'],'://') === false) 29 { 30 $redir = $_POST['redir']; 31 } 32 else 33 { 34 $redir = 35 'plugin.php?p=myGmaps&do=list'. 36 '&user_id='.$_POST['user_id']. 37 '&cat_id='.$_POST['cat_id']. 38 '&status='.$_POST['status']. 39 '&selected='.$_POST['selected']. 40 '&month='.$_POST['month']. 41 '&lang='.$_POST['lang']. 42 '&sortby='.$_POST['sortby']. 43 '&order='.$_POST['order']. 44 '&page='.$_POST['page']. 45 '&nb='.$_POST['nb']; 46 } 47 48 foreach ($entries as $k => $v) { 49 $entries[$k] = (integer) $v; 50 } 51 52 $params['sql'] = 'AND P.post_id IN('.implode(',',$entries).') '; 53 54 if (!isset($_POST['full_content']) || empty($_POST['full_content'])) { 55 $params['no_content'] = true; 56 } 57 58 $params['post_type'] = 'map'; 59 60 61 $posts = $core->blog->getPosts($params); 62 63 # --BEHAVIOR-- adminPostsActions 64 $core->callBehavior('adminPostsActions',$core,$posts,$action,$redir); 65 66 if (preg_match('/^(publish|unpublish|schedule|pending)$/',$action)) 67 { 68 switch ($action) { 69 case 'unpublish' : $status = 0; break; 70 case 'schedule' : $status = -1; break; 71 case 'pending' : $status = -2; break; 72 default : $status = 1; break; 37 try { 38 $act = null; 39 # Change map posts status 40 if ($action === 'published' || $action === 'pending' || $action === 'unpublished') { 41 foreach ($entries as $id) { 42 switch ($action) { 43 case 'published' : $status = 1; break; 44 case 'pending' : $status = -2; break; 45 case 'unpublished' : $status = 0; break; 46 default : $status = 1; break; 47 } 48 $core->blog->updPostStatus($id,$status); 49 } 50 $act = 1; 73 51 } 74 75 try52 # Change map posts category 53 if ($action == 'category' && isset($_POST['new_cat_id'])) 76 54 { 77 55 while ($posts->fetch()) { 78 $core->blog->updPostStatus($posts->post_id,$status);79 }80 81 http::redirect($redir);82 }83 catch (Exception $e)84 {85 $core->error->add($e->getMessage());86 }87 }88 elseif ($action == 'selected' || $action == 'unselected')89 {90 try91 {92 while ($posts->fetch()) {93 $core->blog->updPostSelected($posts->post_id,$action == 'selected');94 }95 96 http::redirect($redir);97 }98 catch (Exception $e)99 {100 $core->error->add($e->getMessage());101 }102 }103 elseif ($action == 'delete')104 {105 try106 {107 while ($posts->fetch()) {108 # --BEHAVIOR-- adminBeforePostDelete109 $core->callBehavior('adminBeforePostDelete',$posts->post_id);110 $core->blog->delPost($posts->post_id);111 }112 113 http::redirect($redir);114 }115 catch (Exception $e)116 {117 $core->error->add($e->getMessage());118 }119 120 }121 elseif ($action == 'category' && isset($_POST['new_cat_id']))122 {123 try124 {125 while ($posts->fetch())126 {127 56 $new_cat_id = (integer) $_POST['new_cat_id']; 128 57 $core->blog->updPostCategory($posts->post_id,$new_cat_id); 129 58 } 130 http::redirect($redir);59 $act = 2; 131 60 } 132 catch (Exception $e) 61 # Change map posts authors 62 if ($action == 'author' && isset($_POST['new_auth_id']) 63 && $core->auth->check('admin',$core->blog->id)) 133 64 { 134 $core->error->add($e->getMessage()); 135 } 136 } 137 elseif ($action == 'author' && isset($_POST['new_auth_id']) 138 && $core->auth->check('admin',$core->blog->id)) 139 { 140 $new_user_id = $_POST['new_auth_id']; 141 142 try 143 { 65 $new_user_id = $_POST['new_auth_id']; 66 144 67 if ($core->getUser($new_user_id)->isEmpty()) { 145 68 throw new Exception(__('This user does not exist')); … … 152 75 $cur->update('WHERE post_id = '.(integer) $posts->post_id); 153 76 } 154 155 http::redirect($redir); 77 $act = 3; 156 78 } 157 catch (Exception $e) 158 { 159 $core->error->add($e->getMessage()); 79 # Delete map posts 80 if ($action === 'delete') { 81 foreach ($entries as $id) { 82 # --BEHAVIOR-- adminBeforePostDelete 83 $core->callBehavior('adminBeforePostDelete',$id); 84 $core->blog->delPost($id); 85 } 86 $act = 4; 160 87 } 88 89 if (!is_null($act)) { 90 http::redirect($redir.'&act='.$act); 91 } 92 } catch (Exception $e) { 93 $core->error->add($e->getMessage()); 161 94 } 162 95 } 163 96 97 # --BEHAVIOR-- adminPostsActions 98 $core->callBehavior('adminPostsActions',$core,$posts,$action,$p_url); 99 164 100 /* DISPLAY 165 101 -------------------------------------------------------- */ 166 ?>167 <html>168 <head>169 <title><?php echo __('Google Maps'); ?></title>170 <?php171 echo172 dcPage::jsMetaEditor().173 # --BEHAVIOR-- adminBeforePostDelete174 $core->callBehavior('adminPostsActionsHeaders')175 ?>176 </head>177 <body>178 <?php179 102 180 if (!isset($action)) { 181 //dcPage::close(); 182 exit; 183 } 103 echo 104 '<html>'. 105 '<head>'. 106 '<title>'.__('Google Maps').'</title>'. 107 dcPage::jsMetaEditor(); 108 # --BEHAVIOR-- adminBeforePostDelete 109 $core->callBehavior('adminPostsActionsHeaders'); 110 echo 111 '</head>'. 112 '<body>'; 184 113 185 $hidden_fields = '';114 $hidden_fields = form::hidden('redir',$redir); 186 115 while ($posts->fetch()) { 187 116 $hidden_fields .= form::hidden(array('entries[]'),$posts->post_id); 188 }189 190 if (isset($_POST['redir']) && strpos($_POST['redir'],'://') === false)191 {192 $hidden_fields .= form::hidden(array('redir'),html::escapeURL($_POST['redir']));193 }194 else195 {196 $hidden_fields .=197 form::hidden(array('user_id'),$_POST['user_id']).198 form::hidden(array('cat_id'),$_POST['cat_id']).199 form::hidden(array('status'),$_POST['status']).200 form::hidden(array('selected'),$_POST['selected']).201 form::hidden(array('month'),$_POST['month']).202 form::hidden(array('lang'),$_POST['lang']).203 form::hidden(array('sortby'),$_POST['sortby']).204 form::hidden(array('order'),$_POST['order']).205 form::hidden(array('page'),$_POST['page']).206 form::hidden(array('nb'),$_POST['nb']);207 }208 209 if (isset($_POST['post_type'])) {210 $hidden_fields .= form::hidden(array('post_type'),$_POST['post_type']);211 117 } 212 118 … … 214 120 $core->callBehavior('adminPostsActionsContent',$core,$action,$hidden_fields); 215 121 216 if ($action == 'category')122 if ($action === 'category') 217 123 { 218 echo '<h2>'.html::escapeHTML($core->blog->name).' › '.__('Google Maps').' › '.__('Change category for map elements').'</h2>'; 124 echo 125 '<h2>'. 126 html::escapeHTML($core->blog->name).' › '. 127 '<a href="'.$p_url.'">'.__('Google Maps').'</a> › '. 128 __('Change category for map elements'). 129 '</h2>'; 219 130 220 131 # categories list … … 232 143 233 144 echo 234 '<form action="'.$p_url.' " method="post">'.145 '<form action="'.$p_url.'&go=maps_actions" method="post">'. 235 146 '<p><label class="classic">'.__('Category:').' '. 236 147 form::combo('new_cat_id',$categories_combo,''). … … 244 155 '</form>'; 245 156 } 246 elseif ($action == 'author' && $core->auth->check('admin',$core->blog->id))157 elseif ($action === 'author' && $core->auth->check('admin',$core->blog->id)) 247 158 { 248 echo '<h2>'.html::escapeHTML($core->blog->name).' › '.__('Google Maps').' › '.__('Change author for map elements').'</h2>'; 159 echo 160 '<h2>'. 161 html::escapeHTML($core->blog->name).' › '. 162 '<a href="'.$p_url.'">'.__('Google Maps').'</a> › '. 163 __('Change author for map elements'). 164 '</h2>'; 249 165 250 166 echo 251 '<form action="'.$p_url.' " method="post">'.167 '<form action="'.$p_url.'&go=maps_actions" method="post">'. 252 168 '<p><label class="classic">'.__('Author ID:').' '. 253 169 form::field('new_auth_id',20,255). … … 262 178 } 263 179 264 echo '<p><a class="back" href="'.html::escapeURL($redir).'">'.__('back').'</a></p>'; 180 $posts_list = ''; 181 182 while ($posts->fetch()) { 183 $link = sprintf('<a href="%s">%s</a>',$p_url.'&go=map&id='.$posts->post_id,$posts->post_title); 184 $posts_list .= sprintf('<li>#%s - %s</li>',$posts->post_id,$link); 185 } 186 187 if ($posts_list !== '') { 188 echo sprintf('<p><ul>%s</ul></p>',$posts_list); 189 } 190 191 echo 192 '<p><a class="back" href="'.html::escapeURL($p_url).'">'.__('back').'</a></p>'. 193 '</body>'. 194 '</html>'; 265 195 266 196 ?> 267 </body>268 </html>
Note: See TracChangeset
for help on using the changeset viewer.