Переглянути джерело

Fix plugins with new structure

jmontoyaa 8 роки тому
батько
коміт
8bba3ea664

+ 6 - 2
main/admin/configure_plugin.php

@@ -22,7 +22,6 @@ if (!in_array($pluginName, $installedPlugins) || empty($pluginInfo)) {
     api_not_allowed(true);
 }
 
-global $_configuration;
 $content = '';
 $currentUrl = api_get_self() . "?name=$pluginName";
 
@@ -75,7 +74,7 @@ if (isset($form)) {
                 null,
                 null,
                 null,
-                $_configuration['access_url'],
+                $accessUrlId,
                 1
             );
         }
@@ -105,6 +104,11 @@ $interbreadcrumb[] = array(
     'name' => get_lang('Plugins')
 );
 
+$interbreadcrumb[] = array(
+    'url' => '#',
+    'name' => Security::remove_XSS($pluginName)
+);
+
 $tpl = new Template($pluginName, true, true, false, true, false);
 $tpl->assign('content', $content);
 $tpl->display_one_col_template();

+ 2 - 0
main/inc/ajax/plugin.ajax.php

@@ -12,6 +12,8 @@ api_block_anonymous_users();
 
 $action = $_REQUEST['a'];
 
+\Chamilo\CoreBundle\Framework\Container::$legacyTemplate = '@ChamiloTheme/Layout/no_layout.html.twig';
+
 switch ($action) {
     case 'md_to_html':
         $plugin = isset($_GET['plugin']) ? $_GET['plugin'] : '';

+ 2 - 2
plugin/add_cas_login_button/index.php

@@ -1,12 +1,12 @@
 <?php
 // Show the CAS button to login using CAS
-require_once api_get_path(SYS_PATH).'main/auth/cas/authcas.php';
+//require_once api_get_path(SYS_PATH).'main/auth/cas/authcas.php';
 
 $_template['show_message'] = false;
 
 if (api_is_anonymous()) {
     $_template['cas_activated'] = api_is_cas_activated();
-    $_template['cas_configured'] = cas_configured();
+    $_template['cas_configured'] = api_cas_configured();
     $_template['show_message'] = true;
     // the default title
     $button_label = "Connexion via CAS";

+ 1 - 1
plugin/add_cas_login_button/plugin.php

@@ -36,4 +36,4 @@ $form->setDefaults($defaults);
 $plugin_info['settings_form'] = $form;
 
 //set the templates that are going to be used
-$plugin_info['templates']   = array('template.tpl');
+$plugin_info['templates'] = array('template.html.twig');

+ 0 - 0
plugin/add_cas_login_button/css.css → plugin/add_cas_login_button/public/css.css


+ 1 - 1
plugin/add_cas_login_button/template.tpl → plugin/add_cas_login_button/template.html.twig

@@ -1,5 +1,5 @@
 {% if add_cas_login_button.show_message %}
-    <link href="{{ _p.web_plugin }}add_cas_login_button/css.css" rel="stylesheet" type="text/css">
+    <link href="{{ asset('plugins/add_cas_login_button/css.css') }}" rel="stylesheet" type="text/css">
     <div class="well">
         {% if add_cas_login_button.url_label %}
             <img src="{{ add_cas_login_button.url_label }}" class='cas_plugin_image'/>

+ 1 - 1
plugin/add_cas_logout_button/index.php

@@ -1,6 +1,6 @@
 <?php
 // Show the CAS button to logout to your CAS session
-global $_user;
+$_user = api_get_user_info();
 $_template['show_message']   = false;
 
 if (!api_is_anonymous() &&

+ 11 - 14
plugin/add_cas_logout_button/plugin.php

@@ -1,6 +1,7 @@
 <?php
 /**
- * This script is a configuration file for the date plugin. You can use it as a master for other platform plugins (course plugins are slightly different).
+ * This script is a configuration file for the date plugin.
+ * You can use it as a master for other platform plugins (course plugins are slightly different).
  * These settings will be used in the administration interface for plugins (Chamilo configuration settings->Plugins)
  * @package chamilo.plugin
  * @author Julio Montoya <gugli100@gmail.com>
@@ -10,30 +11,26 @@
  */
 
 //the plugin title
-$plugin_info['title']      = 'Add a button to logout from CAS';
-
+$plugin_info['title'] = 'Add a button to logout from CAS';
 //the comments that go with the plugin
-$plugin_info['comment']     = "If CAS is activated, this plugin add a text and a button on the user page to logout from a CAS session. Configure plugin to add title, comment and logo.";
+$plugin_info['comment'] = "If CAS is activated, this plugin add a text and a button on the user page to logout from a CAS session. Configure plugin to add title, comment and logo.";
 //the plugin version
-$plugin_info['version']     = '1.0';
+$plugin_info['version'] = '1.0';
 //the plugin author
-$plugin_info['author']      = 'Hubert Borderiou';
+$plugin_info['author'] = 'Hubert Borderiou';
 //the plugin configuration
 $form = new FormValidator('add_cas_button_form');
 $form->addElement('text', 'cas_logout_label', 'CAS logout title', '');
 $form->addElement('text', 'cas_logout_comment', 'CAS logout description', '');
 $form->addElement('text', 'cas_logout_image_url', 'Logo URL if any (image, 50px height)');
 $form->addButtonSave(get_lang('Save'), 'submit_button');
-//get default value for form
-$tab_default_add_cas_logout_button_cas_logout_label = api_get_setting('add_cas_logout_button_cas_logout_label');
-$tab_default_add_cas_logout_button_cas_logout_comment = api_get_setting('add_cas_logout_button_cas_logout_comment');
-$tab_default_add_cas_logout_button_cas_logout_image_url = api_get_setting('add_cas_logout_button_cas_logout_image_url');
-$defaults['cas_logout_label'] = $tab_default_add_cas_logout_button_cas_logout_label['add_cas_logout_button'];
-$defaults['cas_logout_comment'] = $tab_default_add_cas_logout_button_cas_logout_comment['add_cas_logout_button'];
-$defaults['cas_logout_image_url'] = $tab_default_add_cas_logout_button_cas_logout_image_url['add_cas_logout_button'];
+
+$defaults['cas_logout_label'] = api_get_plugin_setting('add_cas_logout_button', 'add_cas_logout_button_cas_logout_label');
+$defaults['cas_logout_comment'] = api_get_plugin_setting('add_cas_logout_button','add_cas_logout_button_cas_logout_comment');
+$defaults['cas_logout_image_url'] = api_get_plugin_setting('add_cas_logout_button','add_cas_logout_button_cas_logout_image_url');
 $form->setDefaults($defaults);
 //display form
 $plugin_info['settings_form'] = $form;
 
 // Set the templates that are going to be used
-$plugin_info['templates']   = array('template.tpl');
+$plugin_info['templates'] = array('template.html.twig');

+ 0 - 0
plugin/add_cas_logout_button/css.css → plugin/add_cas_logout_button/public/css.css


+ 1 - 2
plugin/add_cas_logout_button/template.tpl → plugin/add_cas_logout_button/template.html.twig

@@ -1,5 +1,5 @@
 {% if add_cas_logout_button.show_message %}
-    <link href="{{ _p.web_plugin }}add_cas_logout_button/css.css" rel="stylesheet" type="text/css"> 
+    <link href="{{ asset('plugins/add_cas_logout_button/css.css') }}" rel="stylesheet" type="text/css">
     <div class="well">
         {% if add_cas_logout_button.logout_image_url %}
             <img src="{{add_cas_logout_button.logout_image_url}}" class='cas_plugin_image'/>
@@ -10,6 +10,5 @@
         {% endif %}
         <div class='cas_plugin_comm'>{{add_cas_logout_button.logout_comment}}</div>
         <button class="btn btn-default" onclick="javascript:self.location.href='main/auth/cas/logout.php'">{{"Logout"|get_lang}}</button>
-        
     </div>
 {% endif %}

+ 0 - 0
plugin/add_facebook_login_button/img/index.html


+ 7 - 11
plugin/add_facebook_login_button/index.php

@@ -1,17 +1,13 @@
 <?php
 // Show the FACEBOOK login button
-$_template['show_message']   = false;
-
-//if (api_is_anonymous() && api_get_setting('facebook_login_activate') == 'true') {
+// the default title
 if (api_is_anonymous()) {
-    require_once api_get_path(SYS_CODE_PATH)."auth/external_login/facebook.inc.php";
-    $_template['show_message']   = true;
-    // the default title
-    $button_url = api_get_path(WEB_PLUGIN_PATH)."add_facebook_login_button/img/cnx_fb.png";
-    $href_link = facebookGetLoginUrl();
+    $button_url = api_get_path(WEB_PLUGIN_ASSET_PATH)."add_facebook_login_button/img/cnx_fb.png";
     if (!empty($plugin_info['settings']['add_facebook_login_button_facebook_button_url'])) {
-        $button_url = api_htmlentities($plugin_info['settings']['add_facebook_login_button_facebook_button_url']);
-    }    
+        $button_url = api_htmlentities(
+            $plugin_info['settings']['add_facebook_login_button_facebook_button_url']
+        );
+    }
     $_template['facebook_button_url'] = $button_url;
-    $_template['facebook_href_link'] = $href_link;    
 }
+

+ 5 - 8
plugin/add_facebook_login_button/plugin.php

@@ -1,6 +1,7 @@
 <?php
 /**
- * This script is a configuration file for the date plugin. You can use it as a master for other platform plugins (course plugins are slightly different).
+ * This script is a configuration file for the date plugin.
+ * You can use it as a master for other platform plugins (course plugins are slightly different).
  * These settings will be used in the administration interface for plugins (Chamilo configuration settings->Plugins)
  * @package chamilo.plugin
  * @author Julio Montoya <gugli100@gmail.com>
@@ -13,7 +14,7 @@
 $plugin_info['title'] = 'Add a button to login using FACEBOOK account';
 
 //the comments that go with the plugin
-$plugin_info['comment'] = "If Facebook authntification is activated, this plugin add a button Facebook Connexion on the login page. Configure plugin to add title, comment and logo. Should be place in login_top region";
+$plugin_info['comment'] = "This plugin add a button Facebook Connexion on the login page. Configure plugin to add title, comment and logo. Should be place in login_top region";
 //the plugin version
 $plugin_info['version'] = '1.0';
 //the plugin author
@@ -27,14 +28,10 @@ $form->addElement(
     ''
 );
 $form->addButtonSave(get_lang('Save'), 'submit_button');
-//get default value for form
-$tab_default_add_facebook_login_button_facebook_button_url = api_get_setting(
-    'add_facebook_login_button_facebook_button_url'
-);
-$defaults['facebook_button_url'] = $tab_default_add_facebook_login_button_facebook_button_url['add_facebook_login_button'];
+$defaults['facebook_button_url'] = api_get_plugin_setting('add_facebook_login_button', 'add_facebook_login_button_facebook_button_url');
 $form->setDefaults($defaults);
 //display form
 $plugin_info['settings_form'] = $form;
 
 // Set the templates that are going to be used
-$plugin_info['templates'] = array('template.tpl');
+$plugin_info['templates'] = array('template.html.twig');

+ 0 - 0
plugin/add_facebook_login_button/css.css → plugin/add_facebook_login_button/public/css.css


+ 0 - 0
plugin/add_facebook_login_button/img/cnx_fb.png → plugin/add_facebook_login_button/public/img/cnx_fb.png


+ 4 - 4
plugin/add_facebook_login_button/template.html.twig

@@ -1,5 +1,5 @@
 {% if add_facebook_login_button.show_message %}
-<a href="{{add_facebook_login_button.facebook_href_link}}">
-    <img src="{{add_facebook_login_button.facebook_button_url}}" style="margin-left:15px; border-radius:0"/>
-</a>
-{% endif %}
+    <a href="{{ url('facebook_login') }}"/>
+    <img src="{{ asset('plugins/add_facebook_login_button/img/cnx_fb.png') }}">
+    </a>
+{% endif %}

+ 4 - 4
plugin/add_shibboleth_login_button/index.php

@@ -1,20 +1,20 @@
 <?php
 // Show the Shibboleth button to login using SHIBBOLETH
 
-$_template['show_message']   = false;
+$_template['show_message'] = false;
 
 if (api_is_anonymous()) {
-    $_template['show_message']   = true;
+    $_template['show_message'] = true;
     // the default title
     $button_label = "Connexion via Shibboleth";
     if (!empty($plugin_info['settings']['add_shibboleth_login_button_shibboleth_button_label'])) {
         $button_label = api_htmlentities($plugin_info['settings']['add_shibboleth_login_button_shibboleth_button_label']);
     }
     // the comm
-    $comm_label = api_htmlentities($plugin_info['settings']['add_shibboleth_login_button_shibboleth_button_comment']);;
+    $comm_label = api_htmlentities($plugin_info['settings']['add_shibboleth_login_button_shibboleth_button_comment']);
     // URL of the image
     $url_label = $plugin_info['settings']['add_shibboleth_login_button_shibboleth_image_url'];
-    
+
     $_template['button_label'] = $button_label;
     $_template['comm_label'] = $comm_label;
     $_template['url_label'] = $url_label;

+ 1 - 1
plugin/add_shibboleth_login_button/plugin.php

@@ -60,4 +60,4 @@ $form->setDefaults($defaults);
 $plugin_info['settings_form'] = $form;
 
 //set the templates that are going to be used
-$plugin_info['templates'] = array('template.tpl');
+$plugin_info['templates'] = array('template.html.twig');

+ 0 - 0
plugin/add_shibboleth_login_button/css.css → plugin/add_shibboleth_login_button/public/css.css


+ 1 - 2
plugin/add_shibboleth_login_button/template.tpl → plugin/add_shibboleth_login_button/template.html.twig

@@ -1,6 +1,5 @@
-
 {% if add_shibboleth_login_button.show_message %}
-    <link href="{{ _p.web_plugin }}add_shibboleth_login_button/css.css" rel="stylesheet" type="text/css"> 
+    <link href="{{ asset('plugins/add_shibboleth_login_button/css.css') }}" rel="stylesheet" type="text/css">
     <div class="well">
         {% if add_shibboleth_login_button.url_label %}
             <img src="{{ add_shibboleth_login_button.url_label }}" class='shibboleth_plugin_image'/>