DictionaryPlugin.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Class DictionaryPlugin.
  5. */
  6. class DictionaryPlugin extends Plugin
  7. {
  8. /**
  9. * DictionaryPlugin constructor.
  10. */
  11. protected function __construct()
  12. {
  13. parent::__construct(
  14. '1.0',
  15. 'Julio Montoya',
  16. [
  17. 'enable_plugin_dictionary' => 'boolean',
  18. ]
  19. );
  20. }
  21. /**
  22. * @return DictionaryPlugin|null
  23. */
  24. public static function create()
  25. {
  26. static $result = null;
  27. return $result ? $result : $result = new self();
  28. }
  29. /**
  30. * Installation process.
  31. */
  32. public function install()
  33. {
  34. $sql = "CREATE TABLE IF NOT EXISTS plugin_dictionary (
  35. id INT NOT NULL AUTO_INCREMENT,
  36. term VARCHAR(255) NOT NULL,
  37. definition LONGTEXT NOT NULL,
  38. PRIMARY KEY (id));
  39. ";
  40. Database::query($sql);
  41. }
  42. /**
  43. * Uninstall process.
  44. */
  45. public function uninstall()
  46. {
  47. $sql = "DROP TABLE IF EXISTS plugin_dictionary";
  48. Database::query($sql);
  49. }
  50. }