Advertisement
Guest User

Untitled

a guest
Nov 13th, 2012
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.38 KB | None | 0 0
  1. <?php
  2.  
  3. class AdminVideoController extends ModuleAdminController {
  4.  
  5.     public function __construct()
  6.     {
  7.         $this->table = 'video';
  8.         $this->className = 'Video';
  9.         $this->lang = false;
  10.  
  11.         $this->fields_list = array(
  12.             'id_video' => array('title' => $this->l('ID'), 'align' => 'center'),
  13.             'title' => array('title' => $this->l('Título')),
  14.             'url' => array('title' => $this->l('URL')),
  15.             'related_product_1' => array('title' => $this->l('Related product #1')),
  16.             'related_product_2' => array('title' => $this->l('Related product #2')),
  17.             'related_product_3' => array('title' => $this->l('Related product #3')),
  18.             'related_product_4' => array('title' => $this->l('Related product #4')),
  19.             'related_product_5' => array('title' => $this->l('Related product #5')),
  20.             'related_product_6' => array('title' => $this->l('Related product #6')),
  21.             'active' => array('title' => $this->l('Activo'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false)
  22.         );
  23.        
  24.         parent::__construct();
  25.     }
  26.  
  27.     public function renderList()
  28.     {
  29.         $this->addRowAction('edit');
  30.         $this->addRowAction('delete');
  31.         $this->addRowAction('details');
  32.  
  33.         $this->displayInformation($this->l('Este interface permite-lhe associar um video do YouTube a 6 produtos').'<br />');
  34.         $this->displayInformation($this->l('Apenas um video poderá estar activo de cada vez'));
  35.         return parent::renderList();
  36.     }
  37.  
  38.     public function renderForm()
  39.     {
  40.         if (!($obj = $this->loadObject(true)))
  41.             return;
  42.  
  43.         $this->fields_form = array(
  44.             'legend' => array(
  45.                 'title' => $this->l('Video da semana'),
  46.                 'image' => '../img/admin/world.gif'
  47.             ),
  48.             'input' => array(
  49.                 array(
  50.                     'type' => 'text',
  51.                     'label' => $this->l('Name'),
  52.                     'name' => 'title',
  53.                     'size' => 33,
  54.                     'required' => true,
  55.                     'desc' => $this->l('Title')
  56.                 ),
  57.                 array(
  58.                       'type' => 'text',
  59.                       'label' => $this->l('URL'),
  60.                       'name' => 'url',
  61.                       'size' => 33,
  62.                       'required' => true,
  63.                       'desc' => $this->l('Video URL')
  64.                 ),
  65.                 array(
  66.                       'type' => 'text',
  67.                       'label' => $this->l('Related product #1'),
  68.                       'name' => 'related_product_1',
  69.                       'desc' => $this->l('Video URL')
  70.                 ),
  71.                 array(
  72.                       'type' => 'text',
  73.                       'label' => $this->l('Related product #2'),
  74.                       'name' => 'related_product_2',
  75.                       'desc' => $this->l('Video URL')
  76.                 ),
  77.                 array(
  78.                       'type' => 'text',
  79.                       'label' => $this->l('Related product #3'),
  80.                       'name' => 'related_product_3',
  81.                       'desc' => $this->l('Video URL')
  82.                 ),
  83.                 array(
  84.                       'type' => 'text',
  85.                       'label' => $this->l('Related product #4'),
  86.                       'name' => 'related_product_4',
  87.                       'desc' => $this->l('Video URL')
  88.                 ),
  89.                 array(
  90.                       'type' => 'text',
  91.                       'label' => $this->l('Related product #5'),
  92.                       'name' => 'related_product_5',
  93.                       'desc' => $this->l('Video URL')
  94.                 ),
  95.                 array(
  96.                       'type' => 'text',
  97.                       'label' => $this->l('Related product #6'),
  98.                       'name' => 'related_product_6',
  99.                       'desc' => $this->l('Video URL')
  100.                 ),
  101.                 array(
  102.                     'type' => 'radio',
  103.                     'label' => $this->l('Active:'),
  104.                     'name' => 'active',
  105.                     'required' => false,
  106.                     'class' => 't',
  107.                     'is_bool' => true,
  108.                     'values' => array(
  109.                         array(
  110.                             'id' => 'active_on',
  111.                             'value' => 1,
  112.                             'label' => $this->l('Enabled')
  113.                         ),
  114.                         array(
  115.                             'id' => 'active_off',
  116.                             'value' => 0,
  117.                             'label' => $this->l('Disabled')
  118.                         )
  119.                     ),
  120.                     'desc' => $this->l('One video at the time')
  121.                 )
  122.             )
  123.         );
  124.  
  125.         if (Shop::isFeatureActive())
  126.         {
  127.             $this->fields_form['input'][] = array(
  128.                 'type' => 'shop',
  129.                 'label' => $this->l('Shop association:'),
  130.                 'name' => 'checkBoxShopAsso',
  131.             );
  132.         }
  133.  
  134.         $this->fields_form['submit'] = array(
  135.             'title' => $this->l('   Save   '),
  136.             'class' => 'button'
  137.         );
  138.  
  139.         if (!($obj = $this->loadObject(true)))
  140.             return;
  141.  
  142.         return parent::renderForm();
  143.     }
  144.  
  145.     public function postProcess(){
  146.         $result = parent::postProcess();
  147.  
  148.         if (Tools::getValue('submitAdd'.$this->table) && $result)
  149.             {
  150.                 $sql = 'call sp_FixDefault(Tools::getValue('url'));';
  151.                 if (!Db::getInstance()->query($sql))
  152.                     die('Error; could not update to the DB.');
  153.             }
  154.         return $result;
  155.     }
  156.   }
  157. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement