Changeset 6813


Ignore:
Timestamp:
08/28/10 16:26:07 (9 years ago)
Author:
nikrou
Message:

Update tags with an ajax request

Location:
extensions/user_tags
Files:
11 edited
1 copied

Legend:

Unmodified
Added
Removed
  • extensions/user_tags/CHANGELOG

    r6812 r6813  
     1User Tags 0.3.0 - 2010-08-28 
     2================================ 
     3* update tags with ajax request 
     4 
    15User Tags 0.2.1 - 2010-08-28 
    26================================ 
  • extensions/user_tags/MANIFEST

    r6812 r6813  
    3333user_tags/include/default_values.inc.php 
    3434user_tags/include/t4u_config.class.php 
     35user_tags/include/t4u_admin_action.inc.php 
    3536user_tags/admin.php 
    3637user_tags/COPYING 
  • extensions/user_tags/admin.php

    r6806 r6813  
    2828$me = get_plugin_data($plugin_id); 
    2929$save_config = false; 
     30 
     31if (!empty($_GET['action']) && in_array($_GET['action'], array('add', 'get'))) { 
     32  include_once T4U_PLUGIN_ROOT . "/include/t4u_admin_action.inc.php"; 
     33} 
    3034 
    3135$status_options[null] = '----------'; 
  • extensions/user_tags/css/style.css

    r6798 r6813  
     1#flash-messages{position:fixed;width:60%;display:none;top:30%;left:200px;font-size:.85em;} 
     2#flash-messages div{margin-left:120px;min-height:30px;padding:10px;font-weight:bold;} 
     3#flash-messages div.errors{color:red;background-color:#ffe1e1;border:1px solid red;} 
     4#flash-messages div.infos{color:green;background-color:#98fb98;} 
    15#t4u-update{float:right;} 
    26#t4u-cancel,#t4u-update{margin-top:5px;} 
  • extensions/user_tags/include/t4u_admin_action.inc.php

    r6812 r6813  
    2424} 
    2525 
    26 define('T4U_PLUGIN_ROOT', dirname(__FILE__)); 
     26if (!empty($_GET['action']) && ($_GET['action']=='add')  
     27    && !empty($_POST['tags']) && $me->getPermission('add')) { 
     28  include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 
     29   
     30  $tag_ids = get_fckb_tag_ids($_POST['tags']); 
     31  set_tags($tag_ids, $_POST['image_id']); 
    2732 
    28 include_once T4U_PLUGIN_ROOT . "/include/constants.inc.php"; 
    29 include_once T4U_PLUGIN_ROOT . "/include/t4u_config.class.php"; 
     33  if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) { 
     34    header("Content-Type: application/json"); 
    3035 
    31 load_language('plugin.lang', T4U_PLUGIN_LANG); 
    32  
    33 $plugin_config = new t4u_Config(T4U_PLUGIN_ROOT, T4U_PLUGIN_NAME); 
    34 $plugin_config->load_config(); 
    35  
    36 if (defined('IN_ADMIN')) {  
    37   add_event_handler('get_admin_plugin_menu_links', array($plugin_config, 'plugin_admin_menu'));  
    38   add_event_handler('get_popup_help_content',  
    39                     array($plugin_config, 'get_admin_help'), 
    40                     EVENT_HANDLER_PRIORITY_NEUTRAL, 
    41                     2 
    42                     ); 
    43 } else { 
    44   include_once T4U_PLUGIN_ROOT . '/public.php'; 
     36    $message['info'] = l10n('Tags updated'); 
     37    echo json_encode($message); 
     38    exit(); 
     39  } else { 
     40    redirect(get_absolute_root_url().$_POST['referer']); 
     41  } 
     42} elseif (!empty($_GET['action']) && $_GET['action']=='get' && $me->getPermission('add')) { 
     43  include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 
     44       
     45  $query = ' 
     46SELECT 
     47    id AS tag_id, 
     48    name AS tag_name 
     49  FROM '.TAGS_TABLE.' 
     50;'; 
     51  header("Content-Type: application/json"); 
     52  echo json_encode(get_fckb_taglist($query)); 
     53  exit(); 
    4554} 
    46  
    47 set_plugin_data($plugin['id'], $plugin_config); 
    4855?> 
  • extensions/user_tags/include/t4u_config.class.php

    r6806 r6813  
    7676  } 
    7777 
     78 
     79  public function hasPermission($permission='add') { 
     80    return  
     81      (($this->getPermission($permission)!='') 
     82       and is_autorize_status(get_access_type_status($this->getPermission($permission)))); 
     83  } 
     84 
    7885  public function plugin_admin_menu($menu) { 
    7986    array_push($menu, 
     
    8693 
    8794  public function get_admin_help($help_content, $page) { 
    88     return load_language('help/'.$page.'.html', $this->plugin_dir .'/', array('return'=>true) ); 
     95    return load_language('help/'.$page.'.html',  
     96                         $this->plugin_dir .'/',  
     97                         array('return'=>true)  
     98                         ); 
     99  } 
     100   
     101  public function getActionUrl($action, $method='POST') { 
     102    $url = get_root_url().'admin.php?page=plugin'; 
     103    $file = basename($this->plugin_dir) . '/' .'admin.php'; 
     104    if (strtoupper($method)=='POST') { 
     105        $url .= '&section='.urlencode($file);       
     106        $url .= '&action='.urlencode($action);       
     107    } else { 
     108        $url .= '&section='.$file;            
     109        $url .= '&action='.$action;            
     110    } 
     111 
     112    return $url; 
    89113  } 
    90114 
  • extensions/user_tags/include/t4u_content.class.php

    r6812 r6813  
    2323{ 
    2424  public function __construct($config) { 
    25     $this->plugin_config = $config; 
    26  
    27     if (preg_match('!/t4u_addtags.*!', $_SERVER['QUERY_STRING'])  
    28         && !empty($_POST['tags']) 
    29         && $this->hasPermission('add')) { 
    30       include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 
    31  
    32       $tag_ids = get_fckb_tag_ids($_POST['tags']); 
    33       set_tags($tag_ids, $_POST['image_id']); 
    34       redirect(get_absolute_root_url().$_POST['referer']); 
    35     } 
    36  
    37     if (preg_match('!/t4u_gettags.*!', $_SERVER['QUERY_STRING']) 
    38         && $this->hasPermission('add')) { 
    39       include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 
    40  
    41       $query = ' 
    42 SELECT 
    43     id AS tag_id, 
    44     name AS tag_name 
    45   FROM '.TAGS_TABLE.' 
    46 ;'; 
    47       echo json_encode(get_fckb_taglist($query)); 
    48       exit(); 
    49     } 
     25    $this->plugin_config = &$config; 
    5026  } 
    5127 
     
    5329    global $template; 
    5430 
    55     if (!$this->hasPermission('add')) { 
     31    if (!$this->plugin_config->hasPermission('add')) { 
    5632      return false; 
    5733    } 
     
    6642    $template->assign('T4U_CSS', T4U_CSS); 
    6743    $template->assign('T4U_IMGS', T4U_IMGS); 
    68     $template->assign('T4U_ADD_SCRIPT', $this->public_addtags_url()); 
    69     $template->assign('T4U_GET_SCRIPT', $this->public_gettags_url()); 
     44    $template->assign('T4U_ADD_SCRIPT', $this->plugin_config->getActionUrl('add', 'GET')); 
     45    $template->assign('T4U_GET_SCRIPT', $this->plugin_config->getActionUrl('get', 'GET')); 
    7046    $template->assign('T4U_IMAGE_ID', $picture['id']); 
    7147    $template->assign('T4U_REFERER', htmlentities($picture['url'])); 
    72     $template->assign('T4U_PERMISSION_DELETE', $this->hasPermission('delete')); 
     48    $template->assign('T4U_PERMISSION_DELETE', $this->plugin_config->hasPermission('delete')); 
    7349 
    7450    $related_tags = array(); 
     
    8359    $template->assign_var_from_handle('PLUGIN_PICTURE_BEFORE', 'add_tags'); 
    8460  }     
    85  
    86   private function public_addtags_url() { 
    87     $url = get_root_url().'index'; 
    88     if ($GLOBALS['conf']['php_extension_in_urls']) { 
    89       $url .= '.php'; 
    90     } 
    91     if ($GLOBALS['conf']['question_mark_in_urls']) { 
    92       $url .= '?'; 
    93     } 
    94     $url .= '/t4u_addtags'; 
    95     return $url; 
    96   } 
    97  
    98   private function public_gettags_url() { 
    99     $url = get_root_url().'index'; 
    100     if ($GLOBALS['conf']['php_extension_in_urls']) { 
    101       $url .= '.php'; 
    102     } 
    103     if ($GLOBALS['conf']['question_mark_in_urls']) { 
    104       $url .= '?'; 
    105     } 
    106     $url .= '/t4u_gettags'; 
    107     return $url; 
    108   } 
    109  
    110   private function hasPermission($permission='add') { 
    111     return  
    112       (($this->plugin_config->getPermission($permission)!='') 
    113        and is_autorize_status(get_access_type_status($this->plugin_config->getPermission($permission)))); 
    114   } 
    11561} 
    11662?> 
  • extensions/user_tags/init.php

    r6806 r6813  
    3535 
    3636if (defined('IN_ADMIN')) {  
    37   add_event_handler('get_admin_plugin_menu_links', array($plugin_config, 'plugin_admin_menu'));  
     37  add_event_handler('get_admin_plugin_menu_links',  
     38                    array($plugin_config, 'plugin_admin_menu') 
     39                    );  
    3840  add_event_handler('get_popup_help_content',  
    3941                    array($plugin_config, 'get_admin_help'), 
  • extensions/user_tags/js/jquery.addtags.js

    r6806 r6813  
    1 eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('1G(1g(p,a,c,k,e,d){e=1g(c){1f(c<a?\'\':e(1F(c/a)))+((c=c%a)>1E?1i.1I(c+29):c.1J(1M))};1h(!\'\'.1k(/^/,1i)){1j(c--){d[e(c)]=k[c]||e(c)}k=[1g(e){1f d[e]}];e=1g(){1f\'\\\\w+\'};c=1};1j(c--){1h(k[c]){p=p.1k(1L 1K(\'\\\\b\'+e(c)+\'\\\\b\',\'g\'),k[c])}}1f p}(\'d h(y){$(\\\'#2-k\\\').A(\\\'2-3\\\').s(\\\'3\\\');B}$(d(){f 1=\\\'<c J="\\\'+4[\\\'K\\\']+\\\'" C="E" 7="2-G-c">\\\';1+=\\\'<r 7="a" 9="a">\\\';1+=z;1+=\\\'</r>\\\';1+=\\\'<e b="q" 9="w" 5="\\\'+4[\\\'H\\\']+\\\'">\\\';1+=\\\'<e b="q" 9="L" 5="\\\'+4[\\\'D\\\']+\\\'">\\\';1+=\\\'<e b="I" 7="2-k" 3="3" t="2-3" 5="\\\'+8[\\\'u\\\']+\\\'">\\\';1+=\\\'</c>\\\';v($(\\\'#m\\\').x>0){$(\\\'#m j.F\\\').1b(\\\'<16 7="2-15" 14="\\\'+4[\\\'12\\\']+\\\'" 13="\\\'+8[\\\'l\\\']+\\\'">\\\').17(\\\'M\\\',8[\\\'l\\\']).18(\\\'2-1e\\\').o(d(){$(i).1d(\\\'o\\\');f g=$(i).1c().19(\\\'j.5\\\');f 1a=g.p();g.p(1);$(\\\'#a\\\').11({10:4[\\\'R\\\'],S:8[\\\'Q\\\'],P:n,N:n,O:6,T:6,U:6,Z:h,Y:h,X:V,W:6})})}});\',1H,1N,\'|1O|1U|1V|1W|1T|1S|1P|1Q|1D|1X|1B|1r|1g|1p|1s|1n|1Y|1l|1o|1m|1q|1C|1z|1A|1t|1y|1x|1u|1v|1w|1h|1R|2j|2t|2u|2v|1f|2w|2y|2r|2n|2o|2p|2q|2x|2C|2F|2H|2G|2D|2z|2E|2A|2B|2s|2l|25|26|27|28|24|2m|23|1Z|20|21|22|2a|2b|2i|2k|2h|2g|2c|2d|2e\'.2f(\'|\'),0,{}))',62,168,'|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||return|function|if|String|while|replace|this|update|tags_value|td|input|click_to_add_tags|form|var|html|removeAttr|class|update_tags|select|hidden|false|click|type|Tags|name|35|parseInt|eval|62|fromCharCode|toString|RegExp|new|36|77|newRow|id|vocab|image_id|true|value|t4u|disabled|path|tags|t4u_onchange|t4u_edit_icon|alt|src|edit|fcbkcomplete|onremove|100|newel|maxitems|onselect||img|attr|parent|unbind|clickable|split|append|old_tags_value|addClass|length|find|filter_selected|json_url|label|addtags|t4u_image_id|submit|post|firstselected|item|related_tags|removeClass|method|action|t4u_referer|cache|t4u_get_script|complete_text|t4u_add_script|filter_hide|start_to_type|referer|filter_case|title'.split('|'),0,{})) 
     1eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(2($){$.c=2(s,1){$(s).l(\'\');$(s).Q().o(1).M(16).15(10)};$.Z.c=2(1){7.U(2(){T $.c(7,1)})};z 7})(V);2 I(1){b 9=\'\';i(1.G){9=\'<8 m="13">\'+1.G+\'</8>\'}X i(1.D){9=\'<8 m="Y">\'+1.D+\'</8>\'}i(9!=\'\'){$(\'W\').o(\'<8 5="B-u"></8>\');$(\'#B-u\').c(9)}}2 r(14){$(\'#3-E\').S(\'3-a\').11(\'a\');z}$(2(){b 4=\'<g 12="\'+6[\'L\']+\'" 17="J" 5="3-x-g">\';4+=\'<y 5="q" n="q">\';4+=N;4+=\'</y>\';4+=\'<k 5="3-P-5" j="C" n="R" f="\'+6[\'O\']+\'">\';4+=\'<k 5="3-K" j="C" n="K" f="\'+6[\'1p\']+\'">\';4+=\'<k 5="3-E" j="H" a="a" m="3-a" f="\'+h[\'1v\']+\'">\';4+=\'</g>\';i($(\'#w\').1w>0){$(\'#w v.1u\').o(\'<1t 5="3-1r" 1s="\'+6[\'18\']+\'" 1B="\'+h[\'A\']+\'">\').1D(\'1F\',h[\'A\']).1E(\'3-1C\').t(2(){$(7).1z(\'t\');b p=$(7).1A().1x(\'v.f\');b 1q=p.l();p.l(4);$(\'#q\').1e({1f:6[\'1d\'],1c:h[\'19\'],1a:F,1b:F,1g:d,1h:d,1n:d,1o:r,1m:r,1l:1i,1j:d});$(\'#3-x-g\').H(2(e){$.J(6[\'L\'],$(7).1k(),2(1){I(1)});e.1y()})})}});',62,104,'|data|function|t4u|newRow|id|path|this|div|message|disabled|var|flashMessage|true||value|form|vocab|if|type|input|html|class|name|append|tags_value|tags|t4u_onchange|source|click|messages|td|Tags|addtags|select|return|click_to_add_tags|flash|hidden|error|update|false|info|submit|t4u_form_sucess|post|referer|t4u_add_script|fadeIn|related_tags|t4u_image_id|image|hide|image_id|removeClass|new|each|jQuery|body|else|errors|fn|3000|removeAttr|action|infos|item|fadeOut|500|method|t4u_edit_icon|start_to_type|cache|filter_case|complete_text|t4u_get_script|fcbkcomplete|json_url|filter_hide|firstselected|100|newel|serialize|maxitems|onselect|filter_selected|onremove|t4u_referer|old_tags_value|edit|src|img|label|update_tags|length|find|preventDefault|unbind|parent|alt|clickable|attr|addClass|title'.split('|'),0,{})) 
  • extensions/user_tags/language/fr_FR/plugin.lang.php

    r6806 r6813  
    2323$lang['Start to type'] = 'Commencez à taper'; 
    2424$lang['Update tags'] = 'Mettre à jour les tags'; 
     25$lang['Tags updated'] = 'Les tags ont été mis à jour'; 
    2526$lang['Cancel'] = 'Annuler'; 
    2627 
  • extensions/user_tags/language/templates/plugin.lang.php

    r6806 r6813  
    2323$lang['Start to type'] = ''; 
    2424$lang['Update tags'] = ''; 
     25$lang['Tags updated'] = ''; 
    2526$lang['Cancel'] = ''; 
    2627 
  • extensions/user_tags/main.inc.php

    r6812 r6813  
    2222/* 
    2323Plugin Name: User Tags 
    24 Version: 0.2.1 
     24Version: 0.3.0 
    2525Description: Allow visitors to add tag to images 
    2626Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=441 
Note: See TracChangeset for help on using the changeset viewer.