/upload/admin/controller/module/fb_mobile.php

https://bitbucket.org/elena_dyavolova/omf · PHP · 117 lines · 89 code · 28 blank · 0 comment · 12 complexity · dfe4ee31e7964138dbf778378007b596 MD5 · raw file

  1. <?php
  2. class ControllerModuleFbMobile extends Controller {
  3. private $error = array();
  4. public function index() {
  5. $this->load->language('module/fb_mobile');
  6. $this->document->setTitle($this->language->get('heading_title'));
  7. $this->load->model('setting/setting');
  8. if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
  9. $this->model_setting_setting->editSetting('fb_mobile', $this->request->post);
  10. $this->session->data['success'] = $this->language->get('text_success');
  11. $this->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'));
  12. }
  13. $this->data['heading_title'] = $this->language->get('heading_title');
  14. $this->data['facebook_app_id'] = $this->language->get('facebook_app_id');
  15. $this->data['facebook_app_secret'] = $this->language->get('facebook_app_secret');
  16. $this->data['text_enabled'] = $this->language->get('text_enabled');
  17. $this->data['text_disabled'] = $this->language->get('text_disabled');
  18. $this->data['text_content_top'] = $this->language->get('text_content_top');
  19. $this->data['text_content_bottom'] = $this->language->get('text_content_bottom');
  20. $this->data['text_column_left'] = $this->language->get('text_column_left');
  21. $this->data['text_column_right'] = $this->language->get('text_column_right');
  22. $this->data['entry_layout'] = $this->language->get('entry_layout');
  23. $this->data['entry_position'] = $this->language->get('entry_position');
  24. $this->data['entry_status'] = $this->language->get('entry_status');
  25. $this->data['entry_sort_order'] = $this->language->get('entry_sort_order');
  26. $this->data['button_save'] = $this->language->get('button_save');
  27. $this->data['button_cancel'] = $this->language->get('button_cancel');
  28. $this->data['button_add_module'] = $this->language->get('button_add_module');
  29. $this->data['button_remove'] = $this->language->get('button_remove');
  30. if (isset($this->error['warning'])) {
  31. $this->data['error_warning'] = $this->error['warning'];
  32. } else {
  33. $this->data['error_warning'] = '';
  34. }
  35. $this->data['breadcrumbs'] = array();
  36. $this->data['breadcrumbs'][] = array(
  37. 'text' => $this->language->get('text_home'),
  38. 'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),
  39. 'separator' => false
  40. );
  41. $this->data['breadcrumbs'][] = array(
  42. 'text' => $this->language->get('text_module'),
  43. 'href' => $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'),
  44. 'separator' => ' :: '
  45. );
  46. $this->data['breadcrumbs'][] = array(
  47. 'text' => $this->language->get('heading_title'),
  48. 'href' => $this->url->link('module/fb_mobile', 'token=' . $this->session->data['token'], 'SSL'),
  49. 'separator' => ' :: '
  50. );
  51. $this->data['action'] = $this->url->link('module/fb_mobile', 'token=' . $this->session->data['token'], 'SSL');
  52. $this->data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL');
  53. $this->data['modules'] = array();
  54. if (isset($this->request->post['fb_mobile_module'])) {
  55. $this->data['modules'] = $this->request->post['fb_mobile_module'];
  56. } elseif ($this->config->get('fb_mobile_module')) {
  57. $this->data['modules'] = $this->config->get('fb_mobile_module');
  58. }
  59. if (isset($this->request->post['app_id'])) {
  60. $this->data['app_id'] = $this->request->post['app_id'];
  61. } elseif ($this->config->get('app_id')) {
  62. $this->data['app_id'] = $this->config->get('app_id');
  63. }
  64. if (isset($this->request->post['app_secret'])) {
  65. $this->data['app_secret'] = $this->request->post['app_secret'];
  66. } else {
  67. $this->data['app_secret'] = $this->config->get('app_secret');
  68. }
  69. $this->load->model('design/layout');
  70. $this->data['layouts'] = $this->model_design_layout->getLayouts();
  71. $this->template = 'module/fb_mobile.tpl';
  72. $this->children = array(
  73. 'common/header',
  74. 'common/footer'
  75. );
  76. $this->response->setOutput($this->render());
  77. }
  78. private function validate() {
  79. if (!$this->user->hasPermission('modify', 'module/fb_mobile')) {
  80. $this->error['warning'] = $this->language->get('error_permission');
  81. }
  82. if (!$this->error) {
  83. return true;
  84. } else {
  85. return false;
  86. }
  87. }
  88. }
  89. ?>