Changeset 11385
- Timestamp:
- Jun 15, 2011, 7:07:49 PM (13 years ago)
- Location:
- extensions/set_plugins
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/set_plugins/admin.php
r11249 r11385 2 2 // Chech whether we are indeed included by Piwigo. 3 3 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 4 5 // Fetch the template.6 global $template;7 //8 9 4 if (PHPWG_VERSION < 2.3 ) 10 5 $redirect_url = get_root_url().'admin.php?page='.'plugins_list'; … … 12 7 $redirect_url = get_root_url().'admin.php?page='.'plugins'; 13 8 redirect($redirect_url); 14 15 16 17 9 ?> -
extensions/set_plugins/admin.tpl
r11276 r11385 1 {footer_script }2 <!-- Show the title of the plugin --> 1 <meta http-equiv="X-UA-Compatible" content="IE=edge" /> 2 {footer_script } 3 3 {combine_script id="field_set" load="footer" path=$SET_PLUGINS_PATH|@cat:"js/field_set.js" require="jquery"} 4 {/footer_script} 4 5 5 {/footer_script} 6 {foreach from=$list item=plugin_state}1 7 {$list} 8 {/foreach} 6 9 7 <script type="text/javascript">8 {if isset($liste_plugins)}9 var no_affiche = true;10 {else}11 var no_affiche = false;12 {/if}13 </script>14 {if !isset($liste_plugins)}15 <div class="infos"></div>16 <div class="errors"></div>17 {/if}18 10 {if isset($liste_plugins)} 19 11 {foreach from=$plugin_states item=plugin_state} … … 25 17 {elseif $plugin_state == 'inactive'} 26 18 {'Last '|@translate} {'Inactive Plugins'|@translate} 27 {/if} 19 {/if} [{$nb_list}] 28 20 </legend> 29 21 <form action="{$action}" method="post" name="form_set_plugins" id="form_set_plugins"> 30 <input name="unset_plugins" type="submit" value="{'Deactivate'|@translate}" /> 31 <input name="set_plugins" type="submit" value="{'Activate'|@translate}" /> 32 <input name="nb" type="text" value="{$nb}" /> 22 <input class="button" name="unset_plugins" type="submit" value="{'Deactivate'|@translate}" /> 23 <input class="button" name="set_plugins" type="submit" value="{'Activate'|@translate}" /> 24 25 26 <label> {'nb'|@translate}:</label><input name="nb" type="text" value="{$nb}" size="5" /> 33 27 <input name="list_visible" id="list_visible" type="hidden" value="{$list_visible}" /> 34 </form> 35 <p> 28 29 <input name="add_plugins" type="hidden" id="add_plugins" value="{$add_plugins}" /> 30 <input class="button" type="submit" name="init_plugins" value="{'init'|@translate}" /> 31 <input type="hidden" id="set" name="set" value="{$set}" /> 32 <p> 36 33 37 34 {foreach from=$liste_plugins item=plugin name=plugins_loop} … … 50 47 {else} 51 48 {/if} 49 52 50 </td> 53 51 </tr> … … 65 63 66 64 {else} {/if} 65 67 66 </td> 68 </tr> 69 70 </table>67 </tr> </table> 68 </div> 69 71 70 72 </div>73 71 {/foreach} 74 72 </p> 75 73 </form> 76 74 </fieldset> 77 75 {/if} -
extensions/set_plugins/include/affiche.php
r11276 r11385 1 1 <?php 2 2 //================================================================================================= 3 global $conf ;4 global $ list_visible, $val_state,$liste_plugins,$nb,$infos_message,$erreur_message,$page;3 global $conf,$template,$page ; 4 global $infos_message,$erreur_message,$infos_warning; 5 5 6 if (isset($conf['set_plugins'])) 7 $set_plugins_parametres = unserialize($conf['set_plugins']); 6 global $user, $val; 7 global $list_visible, $state,$liste_plugins; 8 global $set_plugins_parametres; 9 global $nb,$liste,$state,$list_visible,$add_plugins; 10 if (isset($conf['set_plugins'])) $set_plugins_parametres = unserialize($conf['set_plugins']); 11 $nb=set_plugins_controler::set_var('nb','10'); 12 $liste = set_plugins_controler::set_var('list',array()); 13 $state=set_plugins_controler::set_var('state',"active"); 14 $list_visible=set_plugins_controler::set_var('list_visible',"on,on,on,on"); 15 $add_plugins=set_plugins_controler::set_var('add_plugins',""); 16 17 global $set; 18 if ( isset($_POST)) { 19 $set="true"; 20 }else{ 21 $set="false"; 22 } 8 23 9 $nb="10"; 10 if(isset($set_plugins_parametres) && isset($set_plugins_parametres['nb'])) 11 $nb=$set_plugins_parametres['nb']; 12 $nb=isset($_POST['nb'])?$_POST['nb']:$nb ; 24 if(isset($_POST)) 13 25 14 $liste=array(); 15 if(isset($set_plugins_parametres['list'])) 16 $liste=$set_plugins_parametres['list']; 17 $liste=isset($_POST['liste'])?$_POST['liste']:$liste ; 26 if(isset($_POST['add_plugins']) && $add_plugins!="" ){ 27 $liste= array_unique($liste); 28 if(!array_search($add_plugins, $liste)){ 29 array_push($liste, $add_plugins ); 30 } 31 $add_plugins=""; 32 unset( $_POST['add_plugins']); 33 } 18 34 19 $state="active"; 20 if(isset($set_plugins_parametres['state'])) 21 $state =$set_plugins_parametres['state']; 22 $state=isset($_POST['state'])?$_POST['state']:$state ; 35 if(count($liste )>0) 36 $liste_plugins=isset($_POST['liste_plugins'])?$_POST['liste_plugins']:$liste; 23 37 24 $list_visible="on,on,on,on"; 25 if(isset($set_plugins_parametres['list_visible'])) 26 $list_visible =$set_plugins_parametres['list_visible']; 27 $list_visible=(isset($_POST['list_visible']))?$_POST['list_visible']:$list_visible ; 38 if ( $set=="true"){ 39 set_plugins_controler::save_config(); 40 unset($_POST['list_visible']); 41 unset($_POST['nb']); 42 } 28 43 29 $set=isset($_POST['set'])?$_POST['set']:"true"; 30 31 $liste_plugins=$set=isset($_POST['liste_plugins'])?$_POST['liste_plugins']:$liste; 32 33 34 35 36 37 if (isset($_POST['set']) || isset($_POST['list_visible']) || isset($_POST['nb'])){ 38 save_config(); 39 } 40 $template->assign( array( 41 'nb' => $nb, 42 'state' => $state , 43 'set' => $set, 44 $template->assign( array( 44 45 'cl_plugins' => $cl_set_plugins_plugin , 45 46 'cl_version' => $cl_set_plugins_plugin['version'] , … … 47 48 'Version_pwg' => PHPWG_VERSION, 48 49 'SET_PLUGINS_PATH' => SET_PLUGINS_PATH, 49 'list_visible' => $list_visible 50 'set' => $set , 51 'nb' => $nb, 52 'state' => $state , 53 'list_visible' => $list_visible, 54 'add_plugins' => $add_plugins, 55 'nb_list' => count($liste), 56 //'action' => '' 50 57 ) 51 58 ); 52 59 53 $plugins = new plugins(); 54 $plugins->sort_fs_plugins('name'); 55 $plugins->get_merged_extensions(); 56 $plugins->get_incompatible_plugins(); 57 $merged_plugins = false; 60 $plugins = new plugins(); 61 $plugins->sort_fs_plugins('name'); 62 $plugins->get_incompatible_plugins(); 63 $redirect_url = get_root_url().'admin.php?page='.$_GET['page']; 64 $base_url = get_root_url().'admin.php?page='.$page['page']; 65 $action_url = $base_url.'&plugin='.'%s'.'&pwg_token='.get_pwg_token(); 66 //======================================================= 67 $liste_plugins = array(); 68 foreach($liste as $liste_id => $liste_plugin) { 69 $liste_plugins[]= $liste_plugin; 58 70 59 $redirect_url = get_root_url().'admin.php?page='.$_GET['page']; 60 $base_url = get_root_url().'admin.php?page='.$page['page']; 61 $action_url = $base_url.'&plugin='.'%s'.'&pwg_token='.get_pwg_token(); 62 //======================================================= 63 $liste_plugins = array(); 64 65 foreach($liste as $liste_id => $liste_plugin) { 66 $liste_plugins[]= $liste_plugin['plugin'] ; 67 } 68 71 } 69 72 //========================================================== 70 73 $liste_tpl=array(); 71 72 74 foreach($plugins->fs_plugins as $plugin_id => $fs_plugin) { 73 75 //==== test si $plugin_id fait partie de $liste_plugins ============== 74 76 $key = array_search($plugin_id, $liste_plugins,false); 75 76 77 if ($key!== false){ 77 $key = array_search($plugin_id, $liste_plugins);78 79 78 $tpl_plugin = array( 80 79 'NAME' => $fs_plugin['name'], 81 'VISIT_URL' => $fs_plugin['uri'], 82 'VERSION' => $fs_plugin['version'], 83 'DESC' => $fs_plugin['description'], 84 'AUTHOR' => $fs_plugin['author'], 85 'AUTHOR_URL' => @$fs_plugin['author uri'], 86 'U_ACTION' => sprintf($action_url, $plugin_id), 87 'INCOMPATIBLE' => isset($_SESSION['incompatible_plugins'][$plugin_id]), 88 ); 89 90 if (isset($plugins->db_plugins_by_id[$plugin_id])) 91 { 92 $tpl_plugin['STATE'] = $plugins->db_plugins_by_id[$plugin_id]['state']; 93 } 94 else 95 { 96 $tpl_plugin['STATE'] = 'uninstalled'; 97 } 98 99 if(isset($_SESSION['merged_extensions'])) 100 if (isset($fs_plugin['extension']) and in_array($fs_plugin['extension'], $_SESSION['merged_extensions'])) 101 { 102 switch($tpl_plugin['STATE']) 103 { 104 case 'active': $plugins->perform_action('deactivate', $plugin_id); 105 case 'inactive': $plugins->perform_action('uninstall', $plugin_id); 106 } 107 $tpl_plugin['STATE'] = 'merged'; 108 $tpl_plugin['DESC'] = l10n('THIS PLUGIN IS NOW PART OF PIWIGO CORE! DELETE IT NOW.'); 109 $merged_plugins = true; 110 } 111 112 // $template->append('plugins', $tpl_plugin); 113 $liste_tpl[]= $tpl_plugin ; 80 'U_ACTION' => sprintf($action_url, $plugin_id), 81 'STATE' => $plugins->db_plugins_by_id[$plugin_id]['state'] 82 ); 83 $liste_tpl[]= $tpl_plugin ; 114 84 } 115 85 } 116 $template->assign( array( 117 'liste_plugins' => $liste_tpl 118 119 ) 120 ); 86 $template->assign( array( 'liste_plugins' => $liste_tpl)); 87 121 88 122 //================================================================123 if (!isset($infos_message)){124 $infos_message = "";125 }126 if ($infos_message != "") {127 array_push($page['infos'], $infos_message);128 $infos_message="";129 }130 if (!isset($erreur_message)){131 $erreur_message = "";132 }133 if ($erreur_message != "") {134 135 array_push($page['errors'], $erreur_message);136 $erreur_message="";137 138 139 }140 141 //================================================================142 function save_config(){143 global $list_visible, $val_state,$liste_plugins,$nb,$page ;144 global $infos_message;145 $infos_message=l10n("save_config");146 $config=array();147 $config = array(148 'list_visible' => $list_visible,149 'state' => $val_state,150 'list'=>$liste_plugins,151 'nb' =>$nb152 );153 conf_update_param('set_plugins', pwg_db_real_escape_string(serialize($config)));154 }155 //==========================================================================================156 89 ?> -
extensions/set_plugins/js/field_set.js
r11276 r11385 1 function raffraichir() { 2 n = 1; 3 // jQuery("#form_set_plugins").submit(); 4 } 5 6 7 1 8 jQuery("fieldset").hide(); 2 9 jQuery(document).ready(function () { … … 10 17 } 11 18 var h_min = 0; 19 var liste_des_plugins = {}; 20 jQuery(window).load(function () { 21 if (jQuery(".titrePage").length >= 1) { 22 if (jQuery("span.sort").length >= 1) 23 jQuery("#titrePage").before(jQuery("span.sort")); 24 jQuery(".titrePage ").hide(); 25 } 12 26 13 jQuery(window).load(function () {14 27 if (jQuery("fieldset").length >= 1) { 15 16 jQuery("div.titrePage h2").parent().hide();17 18 28 var reg = new RegExp("[,]", "g"); 19 29 liste_visible = jQuery("input[name=list_visible]").val(); 20 n1 = liste_visible; 21 liste = n1.split(reg); 30 if (typeof liste_visible == "undefined") { 31 liste_visible = "on,on,on,on"; 32 jQuery("input[name=list_visible]").val(liste_visible); 33 } 34 liste = liste_visible.split(reg); 22 35 reg = new RegExp("['off']", "g"); 23 36 jQuery("fieldset").each( … … 35 48 liste[i] = "off"; 36 49 37 h_min = jQuery("#" + this.id + ' legend').height();38 jQuery(this).height(h_min + 5);50 h_min = jQuery("#" + this.id + ' legend').height(); 51 jQuery(this).height(h_min + 0); 39 52 40 53 jQuery("#" + this.id + ' legend').prepend( … … 58 71 59 72 n = jQuery(this).parent().hasClass("visible"); 60 jQuery(this).css("color", "red");73 // jQuery(this).css("color", "red"); 61 74 62 75 i = jQuery(jQuery(this).parent()).attr("rel"); 63 76 liste_visible = jQuery("input[name=list_visible]").val(); 64 liste = liste_visible.split(","); 77 if (typeof liste_visible == "undefined") { 78 liste_visible = "on,on,on,on"; 79 jQuery("input[name=list_visible]").val(liste_visible); 80 } 81 // src = jQuery(this).find("img").attr("src"); 65 82 if (n) { 66 jQuery(this).parent().height(h_min + 5);83 jQuery(this).parent().height(h_min + 0); 67 84 jQuery(this).parent().removeClass("visible"); 68 85 liste[i] = "off"; 86 jQuery(this).find("img").attr({ 87 src: plus_path 88 89 }); 69 90 } 70 91 else { … … 72 93 jQuery(this).parent().addClass("visible"); 73 94 liste[i] = "on"; 95 jQuery(this).find("img").attr({ 96 src: minus_path 97 98 }); 74 99 } 75 76 77 100 val = liste.join(","); 78 101 jQuery("input[name=list_visible]").val(val); 102 jQuery('#set').val("true"); 79 103 80 104 jQuery.ajax({ 81 105 type: "POST", 82 106 async: true, 83 data: "list_visible=" + val,107 data: { list_visible: val, set: "true" }, 84 108 success: function (msg) { 85 jQuery("#form_set_plugins").submit();109 // jQuery("#form_set_plugins").submit(); 86 110 } 87 111 }); … … 97 121 jQuery(this).click(function (event) { 98 122 jQuery(this).css("color", "red"); 99 action = jQuery(this).attr('rel'); 100 if (action == "Deactivate") 101 liste_plugins = jQuery(this).parent().parent().text(); 102 else if (action == "Activate") 103 liste_plugins = jQuery(this).parent().parent().text(); 104 123 jQuery('#set').val("true"); 105 124 }); // click 106 125 107 126 }); //each 108 109 127 jQuery("input[name=list_visible]").val(liste.join(",")); 110 128 jQuery("fieldset").show(); 111 129 } // fielset 112 130 //==================================================================== 113 jQuery("td a").click(function (event) { 114 l1 = jQuery('#liste').text(); 115 l = l1.split(new RegExp("\n", "g")); 131 jQuery(".pluginBox a").click(function (event) { 132 var link = event.target.href; 133 if (link.indexOf("?") != -1) { 134 var query = link.split("?")[1]; 135 eval("query = {" + query.replace(/&/ig, "\",").replace(/=/ig, ":\"") + "\"};"); 136 jQuery('#add_plugins').val(query.plugin); 137 jQuery('#set').val("true"); 138 val = liste.join(","); 116 139 117 list = jQuery('liste_plugins'); 140 jQuery.ajax({ 141 type: "POST", 142 async: true, 143 data: { add_plugins: query.plugin, 144 set: "true", 145 list_visible: val 146 } 147 , 148 success: function (data) { 149 // jQuery("#form_set_plugins").submit(); 118 150 119 var reg = new RegExp("[?]", "g"); 120 ret_args = new Array; 121 var args = event.target.href.split(reg)[1]; 122 reg = new RegExp("[&]", "g"); 123 var tableau = args.split(reg); 124 for (i = 0; i < tableau.length; i++) { 125 vals = tableau[i].split("="); 126 ret_args[vals[0]] = vals[1]; 151 } 152 }); 153 127 154 } 128 if (ret_args['action'] == "deactivate") {129 130 list = jQuery('list');131 n = 1;132 } else if (ret_args['action'] == "activate") {133 134 list = jQuery('liste_plugins');135 n = 0;136 }137 138 155 139 156 }) 140 157 141 158 }); // load 142 }); //ready159 }); //ready 143 160 -
extensions/set_plugins/main.inc.php
r11276 r11385 15 15 load_language('plugin.lang', SET_PLUGINS_PATH); 16 16 // Hook on to an event to show the administration page. 17 18 add_event_handler('get_admin_plugin_menu_links', 'set_plugins_admin_menu'); 19 // Add an entry to the 'Plugins' menu. 20 function set_plugins_admin_menu($menu) { 21 array_push( 22 $menu, 23 array( 24 'NAME' => 'Set_plugins', 25 'URL' => get_admin_plugin_menu_link(dirname(__FILE__)).'/admin.php' 26 ) 27 ); 28 return $menu; 29 } 30 31 add_event_handler('loc_end_page_header','set_plugins_add'); 32 function set_plugins_add() { 33 global $user, $template, $val,$page,$conf; 34 if (!isset($page['body_id'])) return; 35 if (!isset($page['body_id'])) return; 36 37 38 39 40 switch($page['body_id']){ 41 case 'theAdminPage': 42 switch($page['page']){ 43 case 'plugins_list': 44 if(!isset($template)) return ; 45 Affiche_set_plugins(); 46 //============================================================ 47 break; 48 49 case 'plugins': 50 if (!isset($page['tab'])) return; 51 if ($page['tab']!="installed") return ; 52 Affiche_set_plugins(); 53 break; 54 55 //============================================================================== 56 } 57 58 break; 17 global $infos_message,$erreur_message,$infos_warning; 59 18 60 19 61 }62 20 63 64 return false; 65 } 21 include_once(SET_PLUGINS_PATH.'set_plugins_class.php'); 22 $set_plugins_controler = new set_plugins_controler(); 23 $infos_message = ""; 24 $erreur_message = ""; 25 $infos_warning = ""; 26 // Add an entry to the 'Plugins' menu. 27 add_event_handler('get_admin_plugin_menu_links', array(&$set_plugins_controler,'set_plugins_admin_menu') ); 28 add_event_handler('loc_end_admin', array(&$set_plugins_controler,'cl_affiche_messages_admin')); 29 add_event_handler('loc_end_page_header',array(&$set_plugins_controler,'set_plugins_add')); 66 30 67 68 function Affiche_set_plugins(){ 69 global $user, $template, $val,$page,$conf; 70 include_once(SET_PLUGINS_PATH."include/constants.php"); 31 //======================================================= 71 32 72 $all_tpl_vars = $template->get_template_vars('plugins');73 if(!$all_tpl_vars) return;74 75 include_once(SET_PLUGINS_PATH.'include/affiche.php');76 $val_state="";77 if( isset($_POST['unset_plugins']) || isset($_POST['set_plugins']) ){78 if(isset($_POST['unset_plugins']) )79 $val_state='inactive';80 elseif(isset($_POST['set_plugins']) )81 $val_state='active';82 83 84 if($val_state!=""){85 if($val_state=="activate")86 $sens ="DESC";87 else88 $sens="ASC";89 //==== pré-liste ===90 $query = 'SELECT *91 FROM ' . PLUGINS_TABLE . '92 WHERE `state` NOT LIKE "'.$val_state. '" AND id!="' . "set_plugins" . '"93 ORDER BY `id` '.$sens.'94 LIMIT '.$nb.'95 ';96 $result = pwg_query($query);97 98 $query = '99 UPDATE '.PLUGINS_TABLE.'100 SET state="'.$val_state.'"101 WHERE `state` NOT LIKE "'.$val_state. '" AND id!="' . "set_plugins" . '"102 ORDER BY `id` '.$sens.'103 LIMIT '.$nb.';';104 pwg_query($query);105 //=====================================106 107 $liste_plugins = array();108 if($result)109 while ($row = pwg_db_fetch_assoc($result)) {110 111 $url = $row['id'] ;112 $vers= $row['version'];113 $state=$row['state'];114 array_push($liste_plugins, array('plugin' => $url,'version'=>$vers,'state' =>$state ) );115 }116 //=====================================117 118 119 $redirect_url = get_root_url().'admin.php?page='.$_GET['page'];120 save_config();121 unset ($_POST);122 redirect($redirect_url);123 }124 }125 $template->set_filenames(126 array(127 'plugin' => dirname(__FILE__).'/admin.tpl'128 )129 );130 $template->set_filenames(131 array( 'cl_plugin' => dirname(__FILE__).'/admin.tpl' )132 );133 134 135 //===========================================================136 $header_1='<div class="titlePage">137 <h2>'.l10n("set_plugins").l10n("Version").": ".$cl_set_plugins_plugin['version'] .'</h2>138 ';139 140 $bpplus=$header_1.$template->parse('cl_plugin', true);141 142 $template-> assign('ADMIN_CONTENT',$bpplus);143 144 $bpplus=$template->parse('plugins', true);145 $template-> concat('ADMIN_CONTENT',$bpplus);146 147 148 }149 33 ?>
Note: See TracChangeset
for help on using the changeset viewer.