Changeset 25817 for extensions/AdminTools
- Timestamp:
- Dec 7, 2013, 6:43:09 PM (10 years ago)
- Location:
- extensions/AdminTools
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/AdminTools/include/MultiView.class.php
r25791 r25817 212 212 } 213 213 } 214 215 /** 216 * Register custom API methods 217 */ 218 public static function register_ws($arr) 219 { 220 $service = &$arr[0]; 221 222 $service->addMethod( 223 'multiView.getData', 224 array('MultiView', 'ws_get_data'), 225 array(), 226 'AdminTools private method.', 227 null, 228 array('admin_only' => true, 'hidden' => true) 229 ); 230 } 231 232 /** 233 * API method 234 * Return full list of users, themes and languages 235 */ 236 public static function ws_get_data($params) 237 { 238 global $conf; 239 240 // get users 241 $query = ' 242 SELECT 243 '.$conf['user_fields']['id'].' AS id, 244 '.$conf['user_fields']['username'].' AS username 245 FROM '.USERS_TABLE.' 246 ORDER BY CONVERT('.$conf['user_fields']['username'].', CHAR) 247 ;'; 248 $out['users'] = array_from_query($query); 249 250 // get themes 251 include_once(PHPWG_ROOT_PATH.'admin/include/themes.class.php'); 252 $themes = new themes(); 253 foreach (array_keys($themes->db_themes_by_id) as $theme) 254 { 255 if (!empty($theme)) 256 { 257 $out['themes'][] = $theme; 258 } 259 } 260 261 // get languages 262 foreach (get_languages() as $code => $name) 263 { 264 $out['languages'][] = array( 265 'id' => $code, 266 'name' => $name, 267 ); 268 } 269 270 return $out; 271 } 214 272 } -
extensions/AdminTools/include/events.inc.php
r25791 r25817 81 81 ); 82 82 83 // gets tags 83 // gets tags (full available list is loaded in ajax) 84 84 $query = ' 85 85 SELECT id, name … … 89 89 ;'; 90 90 $tag_selection = get_taglist($query); 91 92 $query = '93 SELECT id, name94 FROM '.TAGS_TABLE.'95 ;';96 $tags = get_taglist($query, false);97 91 98 92 $tpl_vars['QUICK_EDIT'] = array( … … 105 99 'date_creation_time' => substr($picture['current']['date_creation'], 11, 5), 106 100 'tag_selection' => $tag_selection, 107 'tags' => $tags,108 101 ); 109 102 } … … 146 139 $tpl_vars['QUICK_EDIT']['img'] = DerivativeImage::get_one(IMG_SQUARE, $image_infos)->get_url(); 147 140 } 148 }149 150 151 // get users152 $query = '153 SELECT154 '.$conf['user_fields']['id'].' AS id,155 '.$conf['user_fields']['username'].' AS username156 FROM '.USERS_TABLE.'157 ORDER BY CONVERT('.$conf['user_fields']['username'].', CHAR)158 ;';159 $tpl_vars['USERS'] = simple_hash_from_query($query, 'id', 'username');160 161 // get themes162 include_once(PHPWG_ROOT_PATH.'admin/include/themes.class.php');163 $themes = new themes();164 foreach (array_keys($themes->db_themes_by_id) as $theme)165 {166 if (!empty($theme))167 {168 $tpl_vars['THEMES'][$theme] = $theme;169 }170 }171 172 // get languages173 foreach (get_languages() as $code => $name)174 {175 $tpl_vars['LANGS'][$code] = $name;176 141 } 177 142 -
extensions/AdminTools/main.inc.php
r25791 r25817 35 35 add_event_handler('init', array(&$MultiView, 'init')); 36 36 37 add_event_handler('ws_add_methods', array('MultiView', 'register_ws')); 38 37 39 38 40 // +-----------------------------------------------------------------------+ -
extensions/AdminTools/template/public_controller.tpl
r25791 r25817 9 9 {combine_css id='colorbox' path='themes/default/js/plugins/colorbox/style2/colorbox.css'} 10 10 11 {*<!-- tokeninput -->*} 12 {combine_script id='jquery.tokeninput' load='footer' require='jquery' path='themes/default/js/plugins/jquery.tokeninput.js'} 13 {combine_css path='themes/default/js/plugins/jquery.tokeninput.css'} 11 {if isset($ato.IS_PICTURE)} 12 {*<!-- tokeninput -->*} 13 {combine_script id='jquery.tokeninput' load='footer' require='jquery' path='themes/default/js/plugins/jquery.tokeninput.js'} 14 {combine_css path='themes/default/js/plugins/jquery.tokeninput.css'} 14 15 15 {*<!-- datepicker -->*}16 {combine_script id='jquery.ui.datepicker' load='footer' path='themes/default/js/ui/jquery.ui.datepicker.js'}16 {*<!-- datepicker -->*} 17 {combine_script id='jquery.ui.datepicker' load='footer' path='themes/default/js/ui/jquery.ui.datepicker.js'} 17 18 18 {assign var=datepicker_language value='themes/default/js/ui/i18n/jquery.ui.datepicker-'|cat:$lang_info.code|cat:'.js'} 19 {if 'PHPWG_ROOT_PATH'|constant|cat:$datepicker_language|file_exists} 20 {combine_script id='jquery.ui.datepicker-'|cat:$lang_info.code load='footer' path=$datepicker_language} 19 {assign var=datepicker_language value='themes/default/js/ui/i18n/jquery.ui.datepicker-'|cat:$lang_info.code|cat:'.js'} 20 {if 'PHPWG_ROOT_PATH'|constant|cat:$datepicker_language|file_exists} 21 {combine_script id='jquery.ui.datepicker-'|cat:$lang_info.code load='footer' path=$datepicker_language} 22 {/if} 23 24 {combine_css path='themes/default/js/ui/theme/jquery.ui.core.css'} 25 {combine_css path='themes/default/js/ui/theme/jquery.ui.theme.css'} 26 {combine_css path='themes/default/js/ui/theme/jquery.ui.datepicker.css'} 21 27 {/if} 28 {/if} 22 29 23 {combine_css path='themes/default/js/ui/theme/jquery.ui.core.css'} 24 {combine_css path='themes/default/js/ui/theme/jquery.ui.theme.css'} 25 {combine_css path='themes/default/js/ui/theme/jquery.ui.datepicker.css'} 30 {combine_script id='admintools.controller' load='footer' require='jquery' path=$ADMINTOOLS_PATH|cat:'template/public_controller.js'} 31 {/strip} 32 33 {footer_script require='admintools.controller'} 34 AdminTools.urlWS = '{$ROOT_URL}ws.php?format=json&method='; 35 AdminTools.multiView = { 36 'view_as': "{$ato.MULTIVIEW.view_as}", 37 'theme': "{$ato.MULTIVIEW.theme}", 38 'lang': "{$ato.MULTIVIEW.lang}" 39 }; 40 41 AdminTools.init(); 42 {if $themeconf.mobile} 43 AdminTools.initMobile(); 26 44 {/if} 27 {/strip} 45 {if isset($ato.U_SET_REPRESENTATIVE)} 46 AdminTools.initRepresentative({$current.id}, {$ato.CATEGORY_ID}); 47 {/if} 48 {if isset($ato.U_CADDIE) and isset($ato.IS_PICTURE)} 49 AdminTools.initCaddie({$current.id}); 50 {/if} 51 {if isset($ato.QUICK_EDIT)} 52 AdminTools.initQuickEdit({intval(isset($ato.IS_PICTURE))}, { 53 hintText: '{'Type in a search term'|@translate}', 54 noResultsText: '{'No results'|@translate}', 55 searchingText: '{'Searching...'|@translate}', 56 newText: ' ({'new'|@translate})' 57 }); 58 {/if} 59 {/footer_script} 28 60 29 61 <div id="ato_header_closed"><a href="#" class="icon-tools"></a></div> … … 63 95 {/if} 64 96 65 <li class="parent right "><a class="icon-cog-alt" href="#">{'Tools'|translate}</a>97 <li class="parent right multiview"><a class="icon-cog-alt" href="#">{'Tools'|translate}</a> 66 98 <ul> 67 99 <li><label>{'View as'|translate}</label> 68 <select class="switcher" data-type="view_as"> 69 {html_options options=$ato.USERS selected=$ato.MULTIVIEW.view_as} 70 </select> 100 <select class="switcher" data-type="view_as"></select> 71 101 </li> 72 102 <li><label>{'Theme'|translate}</label> 73 <select class="switcher" data-type="theme"> 74 {html_options options=$ato.THEMES selected=$ato.MULTIVIEW.theme} 75 </select> 103 <select class="switcher" data-type="theme"></select> 76 104 </li> 77 105 <li><label>{'Language'|translate}</label> 78 <select class="switcher" data-type="lang"> 79 {html_options options=$ato.LANGS selected=$ato.MULTIVIEW.lang} 80 </select> 106 <select class="switcher" data-type="lang"></select> 81 107 </li> 82 108 <li><a class="icon-ato-check{if !$ato.MULTIVIEW.show_queries}-empty{/if}" href="{$ato.U_SELF}ato_show_queries={(int)!$ato.MULTIVIEW.show_queries}">{'Show SQL queries'|translate}</a></li> … … 99 125 {if isset($ato.QUICK_EDIT)} 100 126 <div style="display:none;"> 101 <div id="ato_quick_edit" >127 <div id="ato_quick_edit" title="{'Quick edit'|translate}"> 102 128 <form method="post" action="{$ato.U_SELF}"> 103 129 <fieldset class="left"> … … 141 167 </div> 142 168 {/if} 143 144 {footer_script require='jquery'}145 (function($){146 function moveBody(dir, anim) {147 var operator = dir=='show' ? '+=' : '-=';148 149 if (anim) {150 $('body').animate({ldelim}'margin-top': operator+ato_height});151 152 if ($('#the_page, [data-role="page"]').css('position')=='absolute') {153 $('#the_page, [data-role="page"]').animate({ldelim}'top': operator+ato_height});154 }155 }156 else {157 $('body').css({ldelim}'margin-top': operator+ato_height});158 159 if ($('#the_page, [data-role="page"]').css('position')=='absolute') {160 $('#the_page, [data-role="page"]').css({ldelim}'top': operator+ato_height});161 }162 }163 }164 165 var $ato = $('#ato_header'),166 $ato_closed = $('#ato_header_closed'),167 ato_height = 28,168 urlWS = '{$ROOT_URL}ws.php?format=json&method=';169 170 $('body').prepend($ato); // ensure the bar is at the begining171 172 {if $themeconf.mobile}173 var $headerbar = $('div[data-role="header"] .title');174 if ($headerbar.length == 1) {175 $ato_closed.addClass('smartpocket');176 $ato_closed.find('a').attr({177 'data-iconpos':'notext',178 'data-role':'button'179 });180 $headerbar.prepend($ato_closed);181 }182 {/if}183 184 if (window.localStorage.ato_panel_open == null) {185 window.localStorage.ato_panel_open = "true";186 }187 188 if (window.localStorage.ato_panel_open == "true") {189 $ato.show();190 moveBody('show', false);191 }192 else {193 $ato_closed.show();194 }195 196 {*<!-- sub menus -->*}197 $ato.find('.parent').on({198 'click': function(){199 $(this).find('ul').toggle();200 },201 'mouseleave': function(e) {202 if (e.target.tagName.toLowerCase() != "select") {203 $(this).find('ul').hide();204 }205 }206 });207 $ato.find('.parent>a').on('click', function(e) {208 e.preventDefault();209 });210 $ato.find('.parent ul').on('mouseleave', function(e) {211 if (e.target.tagName.toLowerCase() != "select") {212 $(this).hide();213 }214 });215 216 {*<!-- select boxes -->*}217 $ato.find('.switcher').on({218 'change': function() {219 window.location.href = '{$ato.U_SELF}ato_'+ $(this).data('type') +'='+ $(this).val();220 },221 'click': function(e) {222 e.stopPropagation();223 }224 });225 226 {*<!-- toggle toolbar -->*}227 $ato.find('.close-panel').on('click', function(e) {228 $ato.slideUp();229 $ato_closed.slideDown();230 moveBody('hide', true);231 232 window.localStorage.ato_panel_open = "false";233 e.preventDefault();234 });235 236 $ato_closed.on('click', function(e) {237 $ato.slideDown();238 $ato_closed.slideUp();239 moveBody('show', true);240 241 window.localStorage.ato_panel_open = "true";242 e.preventDefault();243 });244 245 {*<!-- set representative -->*}246 {if isset($ato.U_SET_REPRESENTATIVE)}247 $ato.find('.set-representative').on('click', function(e) {248 249 if (!$(this).parent().hasClass('disabled')) {250 $(this).parent().addClass('disabled')251 252 $.ajax({253 method: 'POST',254 url: urlWS + 'pwg.categories.setRepresentative',255 dataType: 'json',256 data: {257 image_id: {$current.id},258 category_id: {$ato.CATEGORY_ID}259 },260 success: function() {261 alert('ok');262 },263 fail: function(num, text) {264 alert(num + ' ' + text);265 }266 });267 }268 269 e.preventDefault();270 });271 {/if}272 273 {*<!-- add to caddie -->*}274 {if isset($ato.U_CADDIE) and isset($ato.IS_PICTURE)}275 $ato.find('.add-caddie').on('click', function(e) {276 277 if (!$(this).parent().hasClass('disabled')) {278 $(this).parent().addClass('disabled')279 280 $.ajax({281 method: 'POST',282 url: urlWS + 'pwg.caddie.add',283 dataType: 'json',284 data: {285 image_id: {$current.id}286 },287 success: function() {288 alert('ok');289 },290 fail: function(num, text) {291 alert(num + ' ' + text);292 }293 });294 }295 296 e.preventDefault();297 });298 {/if}299 300 {* <!-- quick edit -->*}301 {if isset($ato.QUICK_EDIT)}302 var $ato_edit = $('#ato_quick_edit');303 304 305 setTimeout(function() {306 var bg_color = 'white';307 var selectors = ['#the_page #content', '[data-role="page"]', 'body'];308 309 for (var i=0; i<selectors.length; i++) {310 var color = $(selectors[i]).css('background-color');311 console.log(selectors[i], color);312 if (color && color!='transparent') {313 bg_color = color;314 break;315 }316 }317 318 $ato_edit.css('background-color', bg_color);319 }, 1000);320 321 $ato_edit.find('.close-edit').on('click', function(e) {322 $.colorbox.close()323 e.preventDefault();324 });325 326 {if isset($ato.IS_PICTURE)}327 $ato_edit.find('.datepicker').datepicker({328 dateFormat: 'yy-mm-dd'329 });330 331 $ato_edit.find('.tags').tokenInput(332 [{foreach from=$ato.QUICK_EDIT.tags item=tag name=tags}{ldelim}"name":"{$tag.name|escape:javascript}","id":"{$tag.id}"{rdelim}{if !$smarty.foreach.tags.last},{/if}{/foreach}],333 {334 hintText: '{'Type in a search term'|@translate}',335 noResultsText: '{'No results'|@translate}',336 searchingText: '{'Searching...'|@translate}',337 newText: ' ({'new'|@translate})',338 animateDropdown: false,339 preventDuplicates: true,340 allowFreeTagging: true341 }342 );343 {/if}344 345 $(".edit-quick").colorbox({346 inline: true,347 transition: 'none',348 title: '{'Quick edit'|translate|escape:javascript}',349 width: 500,350 top: 50351 });352 {/if}353 354 }(jQuery));355 {/footer_script}
Note: See TracChangeset
for help on using the changeset viewer.