Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. <?php
  2.  
  3. class BlockVariousLinks extends Module
  4. {
  5. private $_html;
  6. function __construct()
  7. {
  8. $this->name = 'blockvariouslinks';
  9. $this->tab = 'Blocks';
  10. $this->version = 0.1;
  11.  
  12. parent::__construct();
  13.  
  14. $this->displayName = $this->l('Footer links block');
  15. $this->description = $this->l('Displays miscellaneous links (generally in footer)');
  16. }
  17.  
  18. function install()
  19. {
  20. if (!parent::install())
  21. return false;
  22. if (!$this->registerHook('footer'))
  23. return false;
  24. Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'block_cms`(`id_block`, `id_cms`) VALUES
  25. ('.intval($this->id).', 3),
  26. ('.intval($this->id).', 4)');
  27. return true;
  28. }
  29. public function uninstall()
  30. {
  31. Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'block_cms`
  32. WHERE `id_block` ='.intval($this->id));
  33. parent::uninstall();
  34. }
  35.  
  36. public function getContent()
  37. {
  38. if (isset($_POST['btnSubmit']))
  39. $this->_postProcess();
  40. $this-> _displayForm();
  41. return $this->_html;
  42. }
  43.  
  44. private function _displayForm()
  45. {
  46. global $cookie;
  47.  
  48. $this->_html .=
  49. '<form action="'.$_SERVER['REQUEST_URI'].'" method="post">
  50. <fieldset>
  51. <legend>'.$this->l('Selected files displayed').'</legend>
  52. <span>'.$this->l('Please check files that will be displayed in this module').'.</span><br /><br />
  53. <table cellspacing="0" cellpadding="0" class="table" style="width: 29.5em;">
  54. <thead>
  55. <tr>
  56. <th><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'categoryBox[]\', this.checked)" /></th>
  57. <th>'.$this->l('ID').'</th>
  58. <th>'.$this->l('Name').'</th>
  59. </tr>
  60. </thead>
  61. <tbody>';
  62. $cms = CMS::listCms($cookie->id_lang);
  63. foreach($cms AS $row)
  64. $this->_html.='
  65. <tr><td><input type="checkbox" class="noborder" value="'.$row['id_cms'].'" name="categoryBox[]" '.((CMS::isInBlock($row['id_cms'], $this->id)) ? 'checked="checked"' : '').'></td><td>'.$row['id_cms'].'</td><td>'.$row['meta_title'].'</td></tr>';
  66. $this->_html .='
  67. </tbody>
  68. </table>
  69. <br />
  70. <input type="submit" name="btnSubmit" class="button" value="'.$this->l('Update').'">
  71. </fieldset>
  72. </form>';
  73. }
  74.  
  75. private function _postProcess()
  76. {
  77. if (isset($_POST['categoryBox']) AND is_array($_POST['categoryBox']) AND count($_POST['categoryBox'] >= 1))
  78. {
  79. foreach ($_POST['categoryBox'] AS $row)
  80. $cms[] = intval($row);
  81. if (CMS::updateCmsToBlock($cms, $this->id))
  82. $this->_html .= '<div class="conf confirm">'.$this->l('Cms Updated').'</div>';
  83. }
  84. else
  85. CMS::updateCmsToBlock(array(), $this->id);
  86. }
  87.  
  88. /**
  89. * Returns module content
  90. *
  91. * @param array $params Parameters
  92. * @return string Content
  93. */
  94. function hookFooter($params)
  95. {
  96. global $smarty, $cookie;
  97. $cms = CMS::listCms($cookie->id_lang, $this->id);
  98. $id_cms = array();
  99. foreach($cms AS $row)
  100. $id_cms[] = intval($row['id_cms']);
  101.  
  102. $smarty->assign('cmslinks', CMS::getLinks($cookie->id_lang, $id_cms ? $id_cms : NULL));
  103. return $this->display(__FILE__, 'blockvariouslinks.tpl');
  104. }
  105.  
  106. }
  107.  
  108. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement