示例#1
0
 public function renderContent($setting)
 {
     $t = array('name' => '', 'loadmodule' => '', 'hookmodule' => '');
     $setting = array_merge($t, $setting);
     $data = PsPagebuilderHelper::moduleExec($setting['hookmodule'], $setting['loadmodule']);
     $setting['content'] = $data;
     $setting['tabname'] = 'blogs' . time();
     $output = array('type' => 'module', 'data' => $setting);
     return $output;
 }
示例#2
0
 public function getWidgets()
 {
     $output = array();
     if ($this->id) {
         $ws = unserialize(PsPagebuilderHelper::clearUnexpected(trim($this->widget)));
         return $ws;
     }
     return $output;
 }
 public function renderView()
 {
     if (Tools::getValue('widgetaction')) {
         $wobj = $this->profile->loadWidgetObject(Tools::getValue('type'), $this);
         if ($wobj) {
             $template = $this->createTemplate('widget_action_content.tpl');
             $content = $wobj->renderAdminContent();
             $template->assign(array('content' => $content, 'test' => ''));
         } else {
             $template = $this->createTemplate('widegt_error.tpl');
         }
         return $template->fetch();
     } else {
         if ($this->ajax) {
             $method = 'ajaxDo' . Tools::ucfirst(trim(Tools::getValue('action')));
             if (method_exists($this, $method)) {
                 echo $this->{$method}();
             }
             exit;
         } else {
             $link = $this->context->link;
             $template = $this->createTemplate('editor.tpl');
             $profiles = $this->profile->getList();
             $layoutjson = '';
             if ($this->profile->layout) {
                 $layoutjson = str_replace('\'', '\\\'', trim($this->profile->layout));
             }
             $output = array();
             $profiles = $this->profile->getList();
             foreach ($profiles as $row) {
                 $output[] = array('name' => $row['name'] ? $row['name'] : $this->l('No Name'), 'id' => $row['id_pagebuilderprofile'], 'isdefault' => $row['isdefault']);
             }
             $sfxclss = PsPagebuilderHelper::detectSfxClasses();
             Media::addJsDef(array('PS_PAGEbuilder_URL' => $link->getAdminLink('AdminPspagebuilderProfile'), 'PTS_PAGEBUILDER_FILE_URI' => _PAGEBUILDER_IMAGE_URL_, 'PTS_PAGEBUILDER_FILE_MANAGEMENT' => $link->getAdminLink('AdminPspagebuilderImage'), 'widgetform' => $link->getAdminLink('AdminPspagebuilderProfile') . '&ajax=true', 'listwidgets' => $link->getAdminLink('AdminPspagebuilderProfile') . '&ajax=true', 'widgetdata' => ''));
             $template->assign(array('savelayout' => $link->getAdminLink('AdminPspagebuilderProfile') . '&savelayout=true', 'id_pagebuilderprofile' => $this->profile->id, 'showed' => 1, 'profile' => $this->profile, 'moduleInShop' => $this->profile->checkProfileInShop(), 'profiles' => $output, 'profile_link' => $link->getAdminLink('AdminPspagebuilderProfile'), 'layoutjson' => $layoutjson, 'sfxclss' => $sfxclss));
             return $template->fetch();
         }
     }
 }
示例#4
0
 public function getFormHelper()
 {
     $default_lang = (int) Configuration::get('PS_LANG_DEFAULT');
     $styles = PsPagebuilderHelper::detectWidgetClasses();
     $this->fields_form[0]['form'] = array('legend' => array('title' => $this->l('Widget Info.')), 'input' => array(array('type' => 'hidden', 'label' => $this->l('Widget Key'), 'name' => 'wkey', 'default' => Tools::getValue('wkey'), 'desc' => $this->l('Using for show in Listing Widget Management')), array('type' => 'hidden', 'label' => $this->l('Widget Type'), 'name' => 'wtype', 'default' => $this->name, 'desc' => $this->l('Using for show in Listing Widget Management')), array('type' => 'text', 'label' => $this->l('Widget Name'), 'name' => 'widget_name', 'default' => '', 'desc' => $this->l('Using for show in Listing Widget Management')), array('type' => 'switch', 'label' => $this->l('Display Title'), 'desc' => $this->l('Show the title on the widget block'), 'name' => 'show_title', 'default' => 1, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled')))), array('type' => 'text', 'label' => $this->l('Widget Title'), 'name' => 'widget_title', 'default' => '', 'lang' => true, 'desc' => $this->l('This tile will be showed as header of widget block. Empty to disable')), array('type' => 'text', 'label' => $this->l('Addition Class'), 'name' => 'addition_cls', 'default' => '', 'desc' => $this->l('This class is used to make owner style for the widget.')), array('type' => 'select', 'label' => $this->l('Widget Box Style'), 'name' => 'stylecls', 'options' => array('query' => $styles['widget'], 'id' => 'class', 'name' => 'name'), 'default' => '', 'desc' => $this->l('These classes are automatic loaded in file pagebuider.css in module or actived theme'))), 'submit' => array('title' => $this->l('Save'), 'class' => 'button'));
     //d($styles);
     $helper = new HelperForm();
     $helper->module = new $this->mod_name();
     $helper->name_controller = $this->mod_name;
     $helper->identifier = $this->mod_name;
     $helper->token = Tools::getAdminTokenLite('AdminModules');
     foreach (Language::getLanguages(false) as $lang) {
         $helper->languages[] = array('id_lang' => $lang['id_lang'], 'iso_code' => $lang['iso_code'], 'name' => $lang['name'], 'is_default' => $default_lang == $lang['id_lang'] ? 1 : 0);
     }
     $helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->mod_name . '&widgets=1&rand=' . rand() . '&wtype=' . Tools::getValue('wtype');
     $helper->default_form_language = $default_lang;
     $helper->allow_employee_form_lang = $default_lang;
     $helper->toolbar_scroll = true;
     $helper->title = $this->mod_name;
     $helper->submit_action = 'save' . $this->mod_name;
     $helper->toolbar_btn = array('back' => array('desc' => $this->l('Back'), 'href' => AdminController::$currentIndex . '&configure=' . $this->mod_name . '&save' . $this->mod_name . '&token=' . Tools::getAdminTokenLite('AdminModules') . '&widgets=1&rand=' . rand()));
     return $helper;
 }
示例#5
0
 public function buildLayoutData($rows, $ws, $profile, $rl = 1)
 {
     $layout = array();
     $mcrypt = new PtsMcrypt();
     foreach ($rows as $rkey => $row) {
         $row->level = $rl;
         $row = PsPagebuilderHelper::mergeRowData($row);
         foreach ($row->cols as $ckey => $col) {
             $col = PsPagebuilderHelper::mergeColData($col);
             foreach ($col->widgets as $wkey => $w) {
                 $w->wkey = (string) $w->wkey;
                 if ($w && isset($w->wkey) && isset($ws[$w->wkey])) {
                     $content = trim($ws[$w->wkey]['config']);
                     if ($content) {
                         $widget = unserialize(PsPagebuilderHelper::clearUnexpected($content));
                         if (isset($widget['widget'])) {
                             foreach ($widget['widget'] as $k => $v) {
                                 $widget['widget'][$k] = $mcrypt->decode($v);
                             }
                             if (isset($widget['widget']['wtype'])) {
                                 $type = $widget['widget']['wtype'];
                                 $profile->loadWidgetObject($type, $this->context->controller);
                                 $tmp = $profile->getWidgetContent($type, $widget['widget']);
                                 $col->widgets[$wkey]->content = $this->getWidgetContent($w->wkey, $tmp['type'], $tmp['data']);
                             }
                         }
                     }
                 }
             }
             if (isset($col->rows)) {
                 $col->rows = $this->buildLayoutData($col->rows, $ws, $profile, $rl + 1);
             }
             $row->cols[$ckey] = $col;
         }
         $layout[$rkey] = $row;
     }
     return $layout;
 }