plugin.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * This plugin allows you to configure a footer note to plug some additional features. In a way, it works a bit like
  4. * any block plugin to be added in a region.
  5. *
  6. * @package chamilo.plugin
  7. *
  8. * @author Julio Montoya <gugli100@gmail.com>
  9. */
  10. /**
  11. * Plugin details (must be present).
  12. */
  13. /* Plugin config */
  14. $plugin_info = CustomFooterPlugin::create()->get_info();
  15. //the plugin title
  16. $plugin_info['title'] = 'Custom Footer';
  17. //the comments that go with the plugin
  18. $plugin_info['comment'] = "Drives configuration parameters that plugs custom footer notes";
  19. //the plugin version
  20. $plugin_info['version'] = '1.0';
  21. //the plugin author
  22. $plugin_info['author'] = 'Valery Fremaux, Julio Montoya';
  23. /* Plugin optional settings */
  24. /*
  25. * This form will be showed in the plugin settings once the plugin was installed
  26. * in the plugin/hello_world/index.php you can have access to the value: $plugin_info['settings']['hello_world_show_type']
  27. */
  28. $form = new FormValidator('customfooter_form');
  29. $plugininstance = CustomFooterPlugin::create();
  30. $config = api_get_settings_params(
  31. ['subkey = ? ' => 'customfooter', ' AND category = ? ' => 'Plugins']
  32. );
  33. $form_settings = [];
  34. foreach ($config as $fooid => $configrecord) {
  35. $canonic = preg_replace('/^customfooter_/', '', $configrecord['variable']);
  36. if (in_array($canonic, ['footer_left', 'footer_right'])) {
  37. $form_settings[$canonic] = $configrecord['selected_value'];
  38. }
  39. }
  40. // A simple select.
  41. $form->addElement('text', 'footer_left', $plugininstance->get_lang('footerleft'));
  42. $form->addElement('text', 'footer_right', $plugininstance->get_lang('footerright'));
  43. $form->addButtonSave($plugininstance->get_lang('Save'));
  44. $form->setDefaults($form_settings);
  45. $plugin_info['settings_form'] = $form;