예제 #1
0
        ?>
		<a onclick="return false;" class="lofaddnew-block-item lofaddnew-block-<?php 
        echo $id_position;
        ?>
" href="<?php 
        echo _MODULE_DIR_ . $this->name . '/popup.php?id_shop=' . (int) $this->context->shop->id . '&id_position=' . $id_position . '&addBlock&bo_theme=' . $employee->bo_theme . '&id_divposition=lofposition-' . $id_position . '&id_lang=' . $cookie->id_lang . '&nb=' . count($blocks) . '&token=' . Tools::getValue('token') . '&secure_key=' . $this->secure_key;
        ?>
" title="add"><img border="0" src="../img/admin/add.gif"/><?php 
        echo $this->l('Add new block');
        ?>
</a><br/>
	<?php 
    }
    if ($blocks) {
        foreach ($blocks as $key => $b) {
            $items = LofBlock::getItems($b['id_loffc_block'], $cookie->id_lang);
            $obj = new LofBlock($b['id_loffc_block']);
            echo $key % 3 == 0 ? '<div class="clear">&nbsp;</div>' : '';
            ?>
			<div class="lof-block <?php 
            echo $key % 3 == 2 ? 'lof-block-right' : '';
            ?>
">
				<form id="form-<?php 
            echo $b['id_loffc_block'];
            ?>
" action="<?php 
            echo $this->base_config_url . '&rand=' . rand();
            ?>
" method="post" enctype="multipart/form-data">
					<div class="lof-load" style="display:none;"></div>
예제 #2
0
        if (Validate::isLoadedObject($obj = new LofItem($ids[2]))) {
            if (!$obj->delete()) {
                $json_data['result'] = 0;
                $json_data['error'] = $module->l('can\'t delete');
            }
        } else {
            $json_data['result'] = 0;
            $json_data['error'] = $module->l('can\'t create object');
        }
    }
    die(json_encode($json_data));
}
if (isset($_GET['lofajax']) && $_GET['task'] == 'updateBlock') {
    $json_data = array();
    $json_data['result'] = 1;
    if (Validate::isLoadedObject($obj = new LofBlock(Tools::getValue('id_loffc_block')))) {
        $errors = array();
        $titles = array();
        foreach ($module->_languages as $language) {
            $titles[$language['id_lang']] = Tools::getValue('title_' . $language['id_lang']);
        }
        if (!Tools::getValue('title_' . $module->_defaultFormLanguage)) {
            $errors[] = $module->l('the field Title is required at least in ' . $defaultLanguage->name);
        }
        foreach ($titles as $key => $val) {
            if (!Validate::isGenericName($val)) {
                $errors[] = $module->l('the field Title is invalid');
            }
        }
        if (Tools::getValue('width') && !Validate::isFloat(Tools::getValue('width'))) {
            $errors[] = $module->l('the field Width is invalid');
예제 #3
0
 foreach ($titles as $key => $val) {
     if (!Validate::isGenericName($val)) {
         $errors[] = $module->l('the field Title is invalid');
     }
 }
 if (Tools::getValue('width') && !Validate::isFloat(Tools::getValue('width'))) {
     $errors[] = $module->l('the field Width is invalid');
 }
 if ($totalWidth + Tools::getValue('width') > 100) {
     $errors[] = $module->l('Width total is invalid(>100)');
 }
 if (!Tools::getValue('id_position')) {
     $errors[] = $module->l('the field Position is invalid');
 }
 if (!sizeof($errors)) {
     $objBlock = new LofBlock();
     $objBlock->title = $titles;
     $objBlock->width = Tools::getValue('width');
     $objBlock->show_title = Tools::getValue('show_title');
     $objBlock->id_position = Tools::getValue('id_position');
     $objBlock->is_link = Tools::isSubmit('link_title');
     if ($objBlock->is_link) {
         $objBlock->linktype = Tools::getValue('linktype');
         $objBlock->target = Tools::getValue('target');
         switch ($objBlock->linktype) {
             case 'product':
                 $objBlock->link_content = Tools::getValue('link_type_product');
                 break;
             case 'category':
                 $objBlock->link_content = Tools::getValue('link_type_category');
                 break;
예제 #4
0
 /**
  * Render processing form && process saving data.
  */
 public function getContent()
 {
     $html = "";
     if (Tools::isSubmit('submit')) {
         if (!sizeof($this->_postErrors)) {
             $definedConfigs = array('theme' => '', 'class' => '');
             foreach ($definedConfigs as $config => $key) {
                 if (strlen($this->name . '_' . $config) >= 32) {
                     echo $this->name . '_' . $config;
                 } else {
                     Configuration::updateValue($this->name . '_' . $config, Tools::getValue($config), true);
                 }
             }
             $html .= '<div class="conf confirm">' . $this->l('Settings updated successful') . '</div>';
         } else {
             foreach ($this->_postErrors as $err) {
                 $html .= '<div class="alert error">' . $err . '</div>';
             }
         }
     } elseif (isset($_GET['submitDeleteBlock'])) {
         if (Tools::getValue('id_loffc_block') && Validate::isLoadedObject($obj = new LofBlock(Tools::getValue('id_loffc_block'))) && $obj->delete()) {
             Tools::redirectAdmin($this->base_config_url . '&lofconf=1');
         } else {
             Tools::redirectAdmin($this->base_config_url . '&lofconf=2');
         }
     } elseif (Tools::isSubmit('submitDeleteData')) {
         $shops = Tools::getValue('shops');
         $items = Db::getInstance()->ExecuteS(' SELECT * FROM `' . _DB_PREFIX_ . 'loffc_block_item`');
         foreach ($items as $item) {
             $sql = 'DELETE FROM `' . _DB_PREFIX_ . 'loffc_block_item_shop` WHERE `id_loffc_block_item` = ' . (int) $item['id_loffc_block_item'] . ' AND `id_shop` IN (' . implode(',', $shops) . ')';
             Db::getInstance()->execute($sql);
             $sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'loffc_block_item_shop` WHERE `id_loffc_block_item` = ' . (int) $item['id_loffc_block_item'];
             if (!($result = Db::getInstance()->executes($sql))) {
                 $obj = new LofItem((int) $item['id_loffc_block_item']);
                 $obj->delete();
             }
         }
         $blocks = Db::getInstance()->ExecuteS(' SELECT * FROM `' . _DB_PREFIX_ . 'loffc_block`');
         if ($blocks) {
             foreach ($blocks as $block) {
                 $sql = 'DELETE FROM `' . _DB_PREFIX_ . 'loffc_block_shop` WHERE `id_loffc_block` = ' . (int) $block['id_loffc_block'] . ' AND `id_shop` IN (' . implode(',', $shops) . ')';
                 Db::getInstance()->execute($sql);
                 $sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'loffc_block_shop` WHERE `id_loffc_block` = ' . (int) $block['id_loffc_block'];
                 if (!($result = Db::getInstance()->executes($sql))) {
                     $obj = new LofBlock((int) $block['id_loffc_block']);
                     $obj->delete();
                 }
             }
         }
     }
     $this->_params = new LofFooterCustomParams($this->name, $this->hookAssign);
     if (Tools::getValue('lofconf') == 1) {
         $html .= '<div class="conf confirm">' . $this->l('Delete Block successful') . '</div>';
     } elseif (Tools::getValue('lofconf') == 2) {
         $html .= '<div class="alert error">' . $this->l('Delete Block error') . '</div>';
     }
     if (sizeof($this->_postErrors)) {
         foreach ($this->_postErrors as $err) {
             $html .= '<div class="alert error">' . $err . '</div>';
         }
     }
     return $html . $this->_getFormConfig();
 }