Просмотр файла mc-2.7.0/modules/html/helpers/html_widget.php

Размер файла: 2.37Kb
  1. <?php
  2.  
  3. /**
  4. * MobileCMS
  5. *
  6. * Open source content management system for mobile sites
  7. *
  8. * @author MobileCMS Team <support@mobilecms.pro>
  9. * @copyright Copyright (c) 2011-2019, MobileCMS Team
  10. * @link https://mobilecms.pro Official site
  11. * @license MIT license
  12. */
  13. defined('IN_SYSTEM') or die('<b>403<br />Запрет доступа!</b>');
  14.  
  15. //---------------------------------------------
  16.  
  17. /**
  18. * Виджет html вставок
  19. */
  20. class html_widget {
  21.  
  22. /**
  23. * Показ виджета
  24. */
  25. public static function display($widget_id) {
  26. $db = Registry::get('db');
  27. $widget = $db->get_row("SELECT * FROM #__index_page_widgets WHERE widget_id = $widget_id");
  28. $config = parse_ini_string($widget['config']);
  29. if (empty($config['code']))
  30. return 'Виджет &laquo;' . $widget['title'] . '&raquo; не настроен, либо настроен не верно!<br />';
  31. $code = $config['code'];
  32. $code = str_replace('{ICON}', '<img src="' . URL . 'views/' . THEME . '/images/icon.png" alt="" />', $code);
  33. $code = str_replace('{URL}', URL, $code);
  34. $code = str_replace('{EXT}', EXT, $code);
  35. return $code . '<br />';
  36. }
  37.  
  38. /**
  39. * Настройка виджета
  40. */
  41. public static function setup($widget) {
  42. $db = Registry::get('db');
  43. $tpl = Registry::get('tpl');
  44.  
  45. if (isset($_POST['submit'])) {
  46. if (!$error) {
  47. $code = str_replace("\n", "", $_POST['code']);
  48. $code = str_replace("\r", "", $code);
  49.  
  50. $config = 'code = "' . mysqli_real_escape_string($this->db->db_link, $code) . '"';
  51.  
  52. $db->query("UPDATE #__index_page_widgets SET
  53. config = '$config'
  54. WHERE widget_id = '" . $widget['widget_id'] . "'
  55. ");
  56.  
  57. a_notice('Изменения сохранены', a_url('index_page/admin'));
  58. }
  59. }
  60. if (!isset($_POST['submit']) OR $error) {
  61. $config = parse_ini_string($widget['config']);
  62.  
  63. $form_data = '
  64. <p>
  65. <label>HTML/текстовая вставка:</label>
  66. <textarea name="code">' . htmlspecialchars($config['code']) . '</textarea>
  67. </p>';
  68.  
  69. $tpl->assign(array(
  70. 'form_data' => $form_data,
  71. 'error' => $error
  72. ));
  73.  
  74. $tpl->display('widget_setup');
  75. }
  76. }
  77.  
  78. }
  79.  
  80. ?>