Changeset 27781


Ignore:
Timestamp:
Mar 16, 2014, 7:16:27 PM (10 years ago)
Author:
Miklfe
Message:
 
Location:
extensions/MyPiwiShop
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • extensions/MyPiwiShop/admin/MyPiwiShopBatch.php

    r27743 r27781  
    44global $template;
    55
    6   $query='SELECT * FROM '.MPS_PRODUCT_TABLE.' ORDER BY `order`;';
     6//set batch manager
     7  $query='
     8  SELECT `id`, `product`, `noteAdmin`, `price`
     9  FROM '.MPS_PRODUCT_TABLE.'
     10  ORDER BY `order`
     11  ;';
    712  $result = pwg_query($query);
    8   $product = array();
    913 
    10   while($row = pwg_db_fetch_assoc($result)){
    11   $product[]= $row;
     14  while($row = pwg_db_fetch_assoc($result)) {
     15   $product[]= $row;
    1216  }
    1317 
    14   $query='SELECT * FROM '.MPS_CONF_TABLE.';';
     18  $query='
     19  SELECT *
     20  FROM '.MPS_CONF_TABLE.'
     21  ;';
    1522  $result       = pwg_query($query);
    16   while($row = pwg_db_fetch_assoc($result)){
     23 
     24  while($row = pwg_db_fetch_assoc($result)) {
    1725   $config = $row ;
    1826  }
    1927
    20  $template->assign(array(
    21   'mps_product' => $product,
    22   'mps_conf'    => $config
     28//tempate assign
     29  $template->assign(array(
     30   'mps_product' => $product,
     31   'mps_conf'    => $config
    2332  )); 
    2433
  • extensions/MyPiwiShop/admin/MyPiwiShopBatchUnit.php

    r27743 r27781  
    11<?php
    22defined('MPS_PATH') or die('Hacking attempt!');
    3 /*      *
    4 *** submit change
    5 **/     
     3
     4//change product check 
     5  if(isset($_POST['imgid'])) {
     6   $imgid = $_POST['imgid'];
     7   $imgen = array($imgid);
     8   
     9        if (!isset($_POST['productcheck'])) {
     10         delet_Allproduct_Thisimage($imgid);
     11        } else {
     12         $product_id = $_POST['productcheck'];
     13         add_product_Thisimage($product_id, $imgen);
     14    }
     15  }     
    616       
    7 if(isset($_POST['imgid']))
    8         {
    9         $imgid = $_POST['imgid'];
    10         $imgen = array($imgid);
    11         if (!isset($_POST['productcheck'])) {
    12                 deletThis_image_Allproduct($imgid);
    13         }
    14         else{   
    15 
    16         $product_id = $_POST['productcheck'];
    17         add_product_Thisimage($product_id, $imgen);
    18   }
    19 }       
    20        
    21 
    22 global $template, $element_ids;
     17//set batch manager unit
     18  global $template, $element_ids;
    2319 
    24  $query='SELECT * FROM '.MPS_PRODUCT_TABLE.' ORDER BY `order`;';
     20  $query='
     21  SELECT `id`, `product`, `noteAdmin`, `price`
     22  FROM '.MPS_PRODUCT_TABLE.'
     23  ORDER BY `order`
     24  ;';
    2525  $result = pwg_query($query);
    26   $products = array();
    2726 
    2827  while($row = pwg_db_fetch_assoc($result)){
    29   $products[]= $row;
     28   $products[]= $row;
    3029  }
    3130
    32   $query='SELECT * FROM '.MPS_CONF_TABLE.';';
    33     $result     = pwg_query($query);
     31  $query='
     32  SELECT *
     33  FROM '.MPS_CONF_TABLE.';';
     34  $result       = pwg_query($query);
     35 
    3436  while($row = pwg_db_fetch_assoc($result)){
    3537    $config = $row ;
    3638  }
    3739
    38  $query='
     40  $query='
    3941  SELECT i.id, pi.image_id, pi.product_id
    4042  FROM '.IMAGES_TABLE.' AS i
     
    4345  ;';
    4446  $result = pwg_query($query);
    45   $productcheck = array();
    4647 
    4748  while($row = pwg_db_fetch_assoc($result)){
    48         $productcheck[] = $row;
     49   $productcheck[] = $row;
    4950  }
    5051               
    51  
    52         $template->assign(array(
    53         'mps_products'     => $products,
    54         'mps_conf'                 => $config,
    55         'mps_productcheck' => $productcheck,
    56         ));
     52//template assign
     53  $template->assign(array(
     54   'mps_products'         => $products,
     55   'mps_conf'             => $config,
     56   'mps_productcheck' => $productcheck,
     57));
    5758
    5859
  • extensions/MyPiwiShop/admin/config.php

    r27743 r27781  
    22defined('MPS_PATH') or die('Hacking attempt!');
    33
     4  $select_options_currency = array(
     5   'AUD'=>'Australian Dollar(AUD)',
     6   'BRL'=>'Brazilian Real(BRL)',
     7   'CAD'=>'Canadian Dollar(CAD)',
     8   'CZK'=>'Czech Koruna(CZK)',
     9   'DKK'=>'Danish Krone(DKK)',
     10   'EUR'=>'Euro(EUR)',
     11   'HKD'=>'Hong Kong Dollar(HKD)',
     12   'HUF'=>'Hungarian Forint(HUF)',
     13   'ILS'=>'Israeli New Sheqel(ILS)',
     14   'JPY'=>'Japanese Yen(JPY)',
     15   'MYR'=>'Malaysian Ringgit(MYR)',
     16   'MXN'=>'Mexican Peso(MXN)',
     17   'NOK'=>'Norwegian Krone(NOK)',
     18   'NZD'=>'New Zealand Dollar(NZD)',
     19   'PHP'=>'Philippine Peso(PHP)',
     20   'PLN'=>'Polish Zloty(PLN)',
     21   'GBP'=>'Pound Sterling(GBP)',
     22   'SGD'=>'Singapore Dollar(SGD)',
     23   'SEK'=>'Swedish Krona(SEK)',
     24   'CHF'=>'Swiss Franc(CHF)',
     25   'TWD'=>'Taiwan New Dollar(TWD)',
     26   'THB'=>'Thai Baht(THB)',
     27   'USD'=>'U.S. Dollar(USD)'
     28  );
    429
    5   $select_options_currency=array(
    6   'AUD'=>'Australian Dollar(AUD)',
    7   'BRL'=>'Brazilian Real(BRL)',
    8   'CAD'=>'Canadian Dollar(CAD)',
    9   'CZK'=>'Czech Koruna(CZK)',
    10   'DKK'=>'Danish Krone(DKK)',
    11   'EUR'=>'Euro(EUR)',
    12   'HKD'=>'Hong Kong Dollar(HKD)',
    13   'HUF'=>'Hungarian Forint(HUF)',
    14   'ILS'=>'Israeli New Sheqel(ILS)',
    15   'JPY'=>'Japanese Yen(JPY)',
    16   'MYR'=>'Malaysian Ringgit(MYR)',
    17   'MXN'=>'Mexican Peso(MXN)',
    18   'NOK'=>'Norwegian Krone(NOK)',
    19   'NZD'=>'New Zealand Dollar(NZD)',
    20   'PHP'=>'Philippine Peso(PHP)',
    21   'PLN'=>'Polish Zloty(PLN)',
    22   'GBP'=>'Pound Sterling(GBP)',
    23   'SGD'=>'Singapore Dollar(SGD)',
    24   'SEK'=>'Swedish Krona(SEK)',
    25   'CHF'=>'Swiss Franc(CHF)',
    26   'TWD'=>'Taiwan New Dollar(TWD)',
    27   'THB'=>'Thai Baht(THB)',
    28   'USD'=>'U.S. Dollar(USD)'
    29   );
    30  
    31 if (isset($_POST['save_config']))
    32 {
    33         $PPid           = $_POST['PPid'];
    34     $currency   = $_POST['currency'];
    35     $ship               = $_POST['ship'];
    36         $comm           = $_POST['comm'];
    37         $tprmulti       = $_POST['tprmulti'];
    38         $tpruniq        = $_POST['tpruniq'];
     30// update config 
     31  if (isset($_POST['save_config'])) {
     32 
     33   $PPid                = $_POST['PPid'];
     34   $currency    = $_POST['currency'];
     35   $ship                = $_POST['ship'];
     36   $comm                = $_POST['comm'];
     37   $tprmulti    = $_POST['tprmulti'];
     38   $tpruniq     = $_POST['tpruniq'];
    3939       
    40         $query='UPDATE '.MPS_CONF_TABLE.'
    41         SET PPid = \''.$PPid.'\',currency = \''.$currency.'\',ship = \''.$ship.'\',comm = \''.$comm.'\' ,tprmulti = \''.$tprmulti.'\',tpruniq = \''.$tpruniq.'\'
    42         WHERE id=1;';
    43         $result=pwg_query($query);
    44    if($result==1)
     40   pwg_query('
     41   UPDATE '.MPS_CONF_TABLE.'
     42   SET PPid = \''.$PPid.'\',currency = \''.$currency.'\',ship = \''.$ship.'\',comm = \''.$comm.'\' ,tprmulti = \''.$tprmulti.'\',tpruniq = \''.$tpruniq.'\'
     43   WHERE id = 1
     44   ;');
     45       
    4546    $page['infos']=l10n('Your configuration settings are saved');
    46    else
    47     $page['errors']=l10n('Error');
     47  }
    4848
    49 }
     49//set config
     50  $query='
     51  SELECT *
     52  FROM '.MPS_CONF_TABLE.'
     53  ;';
     54  $result       = pwg_query($query);
     55 
     56  while($row = pwg_db_fetch_assoc($result)) {
     57   $config = $row ;
     58  }
    5059
    51  $query='SELECT * FROM '.MPS_CONF_TABLE.';';
    52     $result     = pwg_query($query);
    53      while($row = pwg_db_fetch_assoc($result)){
    54     $config = $row ;
    55    }
    56 
    57 
    58 
    59 $template->assign(array(
    60   'mps_currency'        => $select_options_currency,
    61   'mps_conf'            => $config
     60//template assign
     61  $template->assign(array(
     62   'mps_currency'       => $select_options_currency,
     63   'mps_conf'           => $config
    6264  ));
    6365
    64 $template->set_filename('mps_content', realpath(MPS_PATH . 'admin/template/config.tpl'));
     66  $template->set_filename('mps_content', realpath(MPS_PATH . 'admin/template/config.tpl'));
  • extensions/MyPiwiShop/admin/home.php

    r27743 r27781  
    22defined('MPS_PATH') or die('Hacking attempt!');
    33
     4// set home
     5  $query='
     6  SELECT *
     7  FROM '.MPS_CONF_TABLE.'
     8  ;';
     9  $result = pwg_query($query);
     10 
     11  while($row = pwg_db_fetch_assoc($result)) {
     12   $config = $row ;
     13  }
    414
    5 
    6  $query='SELECT * FROM '.MPS_CONF_TABLE.';';
    7     $result     = pwg_query($query);
    8      while($row = pwg_db_fetch_assoc($result)){
    9     $config = $row ;
    10    }
    11 
    12 
    13 $template->assign(array(
    14   'mps_conf'                    => $config,
    15   'INTRO_CONTENT'               => load_language('intro.html', MPS_PATH, array('return'=>true)),
     15//template assign
     16  $template->assign(array(
     17   'mps_conf'      => $config,
     18   'INTRO_CONTENT' => load_language('intro.html', MPS_PATH, array('return'=>true)),
    1619  ));
    1720
    18 $template->set_filename('mps_content', realpath(MPS_PATH . 'admin/template/home.tpl'));
     21  $template->set_filename('mps_content', realpath(MPS_PATH . 'admin/template/home.tpl'));
  • extensions/MyPiwiShop/admin/options.php

    r27743 r27781  
    22defined('MPS_PATH') or die('Hacking attempt!');
    33
    4 
     4// define type option
    55  $select_type_opt=array(
    66  'select'   =>'select',
     
    1010  'checkbox' =>'checkbox',
    1111  );
     12 
     13// delete option
     14  if(isset($_POST['check'])) {
    1215 
    13   if(isset($_POST['check'])){
    1416   foreach($_POST['check'] AS $delete_id){
    1517   
    16    $query='DELETE FROM '.MPS_OPTION_TABLE.'
    17    WHERE id = '.$delete_id.';';
    18    pwg_query($query);
     18   pwg_query('
     19   DELETE FROM '.MPS_OPTION_TABLE.'
     20   WHERE `id` = '.$delete_id.';
     21   ');
    1922   
    20     $query='DELETE FROM '.MPS_PROD_OPT_TABLE.'
    21    WHERE opt_id = '.$delete_id.';';
    22    pwg_query($query);
     23   pwg_query('
     24   DELETE FROM '.MPS_PROD_OPT_TABLE.'
     25   WHERE `opt_id` = '.$delete_id.';
     26   ');
    2327 
    24    $query='DELETE FROM '.MPS_OPT_VAL_TABLE.'
    25    WHERE select_id = '.$delete_id.';';
    26    pwg_query($query);
     28   pwg_query('
     29   DELETE FROM '.MPS_OPT_VAL_TABLE.'
     30   WHERE `select_id` = '.$delete_id.';
     31   ');
     32   
    2733   $page['infos']=l10n('deleted');
    2834   }
    29    }   
     35   
     36  }   
    3037
    31 if (isset($_POST['option_add']))
    32 {
    33 if(empty($_POST['id']))
    34         {
     38// add/edit option
     39  if (isset($_POST['option_add'])) {
     40
     41  //add option
     42        if(empty($_POST['id'])) {
     43         $order = array();
     44         
     45         $query ='SELECT *
     46         FROM '.MPS_OPTION_TABLE.';';
     47         $result = pwg_query($query);
     48         
     49         while($row = pwg_db_fetch_assoc($result)) {
     50       $order[] = $row['order'];
     51         }
     52         
     53         if (count($order) == 0) {
     54          $order = 1;
     55         } else {
     56          $order = max($order)+1;
     57         }
    3558       
    36         $order = array();
    37         $query ='SELECT * FROM '.MPS_OPTION_TABLE.';';
    38         $result = pwg_query($query);
    39         while($row = pwg_db_fetch_assoc($result)){
    40         $order[] = $row['order'];
    41         }
    42         if (count($order) == 0) {
    43         $order = 1;
    44         }else{
    45         $order = max($order)+1;
     59         $name          = $_POST['name'];
     60     $type              = $_POST['type'];
     61     $title             = $_POST['title'];
     62         
     63         if(isset($_POST['requi'])) {
     64          $requi = $_POST['requi'];
     65         } else {
     66          $requi = 0;
     67         }
     68       
     69         pwg_query('
     70         INSERT into '.MPS_OPTION_TABLE.' (`name`,`type`,`titre`,`requi`,`order`)
     71         VALUE (\''.$name.'\',\''.$type.'\',\''.$title.'\',\''.$requi.'\',\''.$order.'\')
     72         ;');
     73   
     74         $select_id = pwg_db_insert_id();                       
     75                       
     76         if(isset($_POST['val'])) {
     77         $val           = $_POST['val'];
     78         
     79      foreach($val as $val_ele) {
     80           pwg_query('
     81           INSERT into '.MPS_OPT_VAL_TABLE.' (`val` , `select_id`)
     82           VALUE (\''.$val_ele.'\',\''.$select_id.'\')
     83           ;');
     84      }
     85         
     86         }
     87         $page['infos']=l10n('Option registered');
    4688        }
    4789       
    48         $name           = $_POST['name'];
    49     $type               = $_POST['type'];
    50     $title              = $_POST['title'];
     90  //edit option
     91    if(!empty($_POST['id'])) {
     92
     93         $name  = $_POST['name'];
     94     $type      = $_POST['type'];
     95     $title     = $_POST['title'];
     96         $id    = $_POST['id'];
    5197       
    52         if(isset($_POST['requi'])){
    53          $requi = $_POST['requi'];
    54          }else{
    55          $requi = 0;
     98         if(isset($_POST['requi'])) {
     99           $requi = $_POST['requi'];
     100          } else {
     101           $requi = 0;
     102          }
     103
     104         pwg_query('   
     105         UPDATE '.MPS_OPTION_TABLE.'
     106         SET `name` = \''.$name.'\', `type` = \''.$type.'\', `titre` = \''.$title.'\', `requi` = \''.$requi.'\'
     107         WHERE `id` = '.$id.'
     108         ;');
     109       
     110         pwg_query('
     111         DELETE FROM '.MPS_OPT_VAL_TABLE.'
     112         WHERE `select_id` =  '.$id.'
     113         ;');
     114   
     115         if(isset($_POST['val'])){
     116         $val           = $_POST['val'];
     117         
     118      foreach($val as $val_ele)
     119      {
     120           pwg_query('
     121           INSERT into '.MPS_OPT_VAL_TABLE.' (`val` , `select_id`)
     122           VALUE (\''.$val_ele.'\',\''.$id.'\')
     123           ;');
     124      }
     125         
    56126         }
     127         
     128    $page['infos']=l10n('Option registered');
     129        }
     130  }
     131
     132// change option order
     133  if(isset($_POST['newOrder'])) {
     134 
     135   $newOrder = explode(",", $_POST['newOrder']);
     136   $ex           = array_pop($newOrder);
     137   
     138        foreach( $newOrder as $order => $id ) {
    57139       
     140         $order = $order +1;
     141     pwg_query('
     142         UPDATE '.MPS_OPTION_TABLE.'
     143         SET `order` = \''.$order.'\'
     144         WHERE `id` = '.$id.'
     145         ;');
     146     } 
     147         
     148        $page['infos']=l10n('the order is changed');
     149  }
     150
     151// set option
     152  $query='
     153  SELECT o.id, o.titre, o.name, o.type, o.requi, o.order, ov.val
     154  FROM '.MPS_OPTION_TABLE.' AS o
     155  LEFT JOIN '.MPS_OPT_VAL_TABLE.' AS ov ON ov.select_id = o.id
     156  ORDER BY o.order
     157  ;';
     158 
     159  $result = pwg_query($query);
     160   while($row = pwg_db_fetch_assoc($result)) {
     161   
     162        if (!isset($option[ $row['id']])) {
     163     $option[$row['id']] = array(
     164          'id'    => $row['id'],
     165          'title' => $row['titre'],
     166          'name'  => $row['name'],
     167          'type'  => $row['type'],
     168          'requi' => $row['requi'],
     169         );
     170        }
     171        $option[$row['id']]['val'][]=$row['val'];
    58172       
    59         $query='INSERT into '.MPS_OPTION_TABLE.' (`name`,`type`,`titre`,`requi`,`order`)
    60                         values (\''.$name.'\',\''.$type.'\',\''.$title.'\',\''.$requi.'\',\''.$order.'\');';
    61    
    62         pwg_query($query);             
    63         $select_id = pwg_db_insert_id();                       
    64                        
    65         if(isset($_POST['val'])){
    66         $val            = $_POST['val'];
    67 
    68 
    69     foreach($val as $val_ele)
    70     {
    71          $query='INSERT into '.MPS_OPT_VAL_TABLE.' (val,select_id)
    72                         values (\''.$val_ele.'\',\''.$select_id.'\');';
    73          $result = pwg_query($query);
    74     }
    75         if($result==1)
    76         $page['infos']=l10n('Option registered');
    77         else
    78         $page['errors']=l10n('Error');
    79         }
    80         }
    81 
    82 if(!empty($_POST['id']))
    83         {
    84 
    85         $name           = $_POST['name'];
    86     $type               = $_POST['type'];
    87     $title              = $_POST['title'];
    88         $id                     = $_POST['id'];
    89        
    90         if(isset($_POST['requi'])){
    91          $requi = $_POST['requi'];
    92          }else{
    93          $requi = 0;
    94          }
    95 
    96         $query='UPDATE '.MPS_OPTION_TABLE.'
    97         SET name = \''.$name.'\', type = \''.$type.'\', titre = \''.$title.'\', requi = \''.$requi.'\'
    98         WHERE id = '.$id.'
    99         ;';
    100     pwg_query($query);
    101        
    102         $query='DELETE FROM '.MPS_OPT_VAL_TABLE.'
    103         WHERE select_id =  '.$id.'
    104         ;';
    105         pwg_query($query);
    106    
    107         if(isset($_POST['val'])){
    108         $val            = $_POST['val'];
    109 
    110     foreach($val as $val_ele)
    111     {
    112        
    113          $query='INSERT into '.MPS_OPT_VAL_TABLE.' (val,select_id)
    114                         values (\''.$val_ele.'\',\''.$id.'\');';
    115          $result = pwg_query($query);
    116     }
    117         }
    118    $page['infos']=l10n('Option registered');
    119 
    120         }
    121 
    122 }
    123 
    124 if(isset($_POST['newOrder']))
    125         {
    126         $newOrder = explode(",", $_POST['newOrder']);
    127         $ex = array_pop($newOrder);
    128        
    129         foreach( $newOrder as $order => $id )
    130         {
    131         $order = $order +1;
    132 
    133       $query='UPDATE '.MPS_OPTION_TABLE.' SET `order` = \''.$order.'\' WHERE id = '.$id.';';
    134         $result = pwg_query($query);
    135    
    136     $page['infos']=l10n('the order is changed');
    137 
    138     }
    139 }
    140 
    141   $query='
    142   SELECT *  FROM '.MPS_OPTION_TABLE.' ORDER BY `order` ;';
    143 
    144   $option = array();
    145   $result = pwg_query($query);
    146   while($row = pwg_db_fetch_assoc($result)){
    147          $query='
    148          SELECT *
    149          FROM '.MPS_OPT_VAL_TABLE.'
    150      WHERE select_id = '.$row['id'].'
    151          ;';
    152         $val = array();
    153         $res = pwg_query($query);
    154          while($row1 = pwg_db_fetch_assoc($res)){
    155          $val[]= $row1['val'];
    156          }
    157         $opt = array("id"        =>$row['id'],
    158                                  "title" =>$row['titre'],
    159                                  "name"  =>$row['name'],
    160                                  "type"  =>$row['type'],
    161                                  "requi" =>$row['requi'],
    162                                  "val"   =>$val
    163                                         );
    164         $option[$row['id']] = $opt;
    165        
    166  }             
    167 
    168 
    169    $template->assign(array(
     173   }
     174 
     175//template assign
     176  $template->assign(array(
    170177         'mps_option'   => $option,
    171178         'mps_type_opt' => $select_type_opt
    172179         ));
    173180
    174 
    175 $template->set_filename('mps_content', realpath(MPS_PATH . 'admin/template/options.tpl'));
     181  $template->set_filename('mps_content', realpath(MPS_PATH . 'admin/template/options.tpl'));
     182 
  • extensions/MyPiwiShop/admin/product.php

    r27743 r27781  
    22defined('MPS_PATH') or die('Hacking attempt!');
    33
    4 
    5   if(isset($_POST['check'])){
    6    foreach($_POST['check'] AS $delete_id){
    7    
    8    $query='DELETE FROM '.MPS_PRODUCT_TABLE.'
    9    WHERE id = '.$delete_id.';';
    10    pwg_query($query);
     4// delete option
     5  if(isset($_POST['check'])) {
     6 
     7   foreach($_POST['check'] AS $delete_id) {
     8   
     9    pwg_query('
     10    DELETE FROM '.MPS_PRODUCT_TABLE.'
     11    WHERE id = '.$delete_id.'
     12    ;');
     13   
     14    pwg_query('
     15    DELETE FROM '.MPS_PROD_OPT_TABLE.'
     16    WHERE product_id = '.$delete_id.'
     17    ;');
     18   }   
     19   
    1120   $page['infos']=l10n('deleted');
    12    
    13    $query='DELETE FROM '.MPS_PROD_OPT_TABLE.'
    14    WHERE product_id = '.$delete_id.';';
    15    pwg_query($query);
    16    
    17 
     21  }   
     22
     23//Add/Edit product
     24  if(isset($_POST['product_add'])) {
     25 
     26  //Add product
     27    if (empty($_POST['id'])) {
     28       
     29         $order = array();
     30         $query ='
     31         SELECT `order`
     32         FROM '.MPS_PRODUCT_TABLE.'
     33         ;';
     34         
     35         $result = pwg_query($query);
     36         while($row = pwg_db_fetch_assoc($result)) {
     37      $order[] = $row['order'];
     38         }
     39         if (count($order) == 0) {
     40          $order = 1;
     41         } else {
     42          $order = max($order)+1;
     43         }
     44       
     45         $product       = $_POST['product'];
     46         $noteAdmin     = $_POST['noteAdmin'];
     47         $price         = $_POST['price'];
     48
     49       
     50     pwg_query('
     51         INSERT into '.MPS_PRODUCT_TABLE.' (`order`,`product`,`noteAdmin`,`price`)
     52         VALUE (\''.$order.'\',\''.$product.'\',\''.$noteAdmin.'\',\''.$price.'\');
     53         ');
     54         $prod = pwg_db_insert_id();
     55   
     56     if(isset($_POST['opt'])) {
     57          $opt = $_POST['opt'];
     58      $inserts = array();
     59         
     60      foreach ($opt as $opt_id) {
     61       $inserts[] = array(
     62        'opt_id' => $opt_id,
     63        'product_id' => $prod,
     64       );
     65      }
     66         
     67      mass_inserts(
     68      MPS_PROD_OPT_TABLE,
     69      array_keys($inserts[0]),
     70      $inserts
     71      );
     72     }
     73         
     74         $page['infos']=l10n('Product registered');
     75    }
     76       
     77  //Edit product       
     78    if(!empty($_POST['id'])) {
     79       
     80         $id            = $_POST['id'];
     81         $product       = $_POST['product'];
     82         $noteAdmin     = $_POST['noteAdmin'];
     83         $price         = $_POST['price'];
     84
     85         pwg_query('
     86         UPDATE '.MPS_PRODUCT_TABLE.'
     87         SET product = \''.$product.'\',noteAdmin = \''.$noteAdmin.'\',price=\''.$price.'\'
     88         WHERE id = '.$id.'
     89         ;');
     90   
     91     pwg_query('
     92         DELETE FROM '.MPS_PROD_OPT_TABLE.'
     93         WHERE `product_id` IN ('.$id.')
     94         ;');
     95       
     96         if(isset($_POST['opt'])) {
     97          $opt          = $_POST['opt'];
     98      $inserts  = array();
     99         
     100      foreach ($opt as $opt_id) {
     101       $inserts[] = array(
     102        'opt_id'         => $opt_id,
     103        'product_id' => $id,
     104       );
     105      }
     106         
     107     mass_inserts(
     108     MPS_PROD_OPT_TABLE,
     109     array_keys($inserts[0]),
     110     $inserts
     111     );
     112     }
     113
     114    $page['infos']=l10n('Edit');
     115    }
     116
     117  }
     118 
     119// Change order
     120  if(isset($_POST['newOrder'])) {
     121   $newOrder = explode(",", $_POST['newOrder']);
     122   $ex           = array_pop($newOrder);
     123       
     124        foreach( $newOrder as $order => $id ) {
     125         $order = $order +1;
     126
     127     pwg_query('
     128         UPDATE '.MPS_PRODUCT_TABLE.'
     129         SET `order` = \''.$order.'\'
     130         WHERE id = '.$id.'
     131        ;');
     132    }
     133       
     134    $page['infos']=l10n('the order is changed');
     135  }
     136
     137if (isset($_POST['option_add'])) {
     138         $order = array();
     139         
     140         $query ='SELECT *
     141         FROM '.MPS_OPTION_TABLE.';';
     142         $result = pwg_query($query);
     143         
     144         while($row = pwg_db_fetch_assoc($result)) {
     145       $order[] = $row['order'];
     146         }
     147         
     148         if (count($order) == 0) {
     149          $order = 1;
     150         } else {
     151          $order = max($order)+1;
     152         }
     153       
     154         $name          = $_POST['name'];
     155     $type              = $_POST['type'];
     156     $title             = $_POST['title'];
     157         
     158         if(isset($_POST['requi'])) {
     159          $requi = $_POST['requi'];
     160         } else {
     161          $requi = 0;
     162         }
     163       
     164         pwg_query('
     165         INSERT into '.MPS_OPTION_TABLE.' (`name`,`type`,`titre`,`requi`,`order`)
     166         VALUE (\''.$name.'\',\''.$type.'\',\''.$title.'\',\''.$requi.'\',\''.$order.'\')
     167         ;');
     168   
     169         $select_id = pwg_db_insert_id();                       
     170                       
     171         if(isset($_POST['val'])) {
     172         $val           = $_POST['val'];
     173         
     174      foreach($val as $val_ele) {
     175           pwg_query('
     176           INSERT into '.MPS_OPT_VAL_TABLE.' (`val` , `select_id`)
     177           VALUE (\''.$val_ele.'\',\''.$select_id.'\')
     178           ;');
     179      }
     180         
     181         }
     182       
     183        echo('<div><div id="idlastopt" data-idlo="'.$select_id.'"></div></div>');
     184  }
     185
     186// set product   
     187  $query='
     188  SELECT p.id, p.order, p.product, p.noteAdmin, p.price, o.name
     189  FROM '.MPS_PRODUCT_TABLE.' AS p
     190  LEFT JOIN '.MPS_PROD_OPT_TABLE.' AS op ON op.product_id = p.id
     191  LEFT JOIN '.MPS_OPTION_TABLE.' AS o ON o.id = op.opt_id
     192  ORDER BY p.order
     193  ;';
     194  $result = pwg_query($query);
     195 
     196  while($row = pwg_db_fetch_assoc($result)) {
     197 
     198   if (!isset($products[ $row['id']])) {
     199        $products[$row['id']] = array(
     200         'id'        => $row['id'],
     201     'product'   => $row['product'],
     202     'noteAdmin' => $row['noteAdmin'],
     203     'price'     => $row['price'],
     204          );
    18205   }
    19    }   
    20 
    21 if(isset($_POST['product_add']))
    22 {
    23 if(!empty($_POST['id']))
    24         {
    25         $id             = $_POST['id'];
    26         $product        = $_POST['product'];
    27         $noteAdmin      = $_POST['noteAdmin'];
    28         $price          = $_POST['price'];
    29 
    30         $query='UPDATE '.MPS_PRODUCT_TABLE.'
    31         SET product = \''.$product.'\',noteAdmin = \''.$noteAdmin.'\',price=\''.$price.'\'
    32         WHERE id = '.$id.';';
    33    pwg_query($query);
    34    
    35     $query = 'DELETE FROM '.MPS_PROD_OPT_TABLE.' WHERE product_id IN ('.$id.');';
    36         pwg_query($query);
    37        
    38         if(isset($_POST['opt']))
    39     {
    40         $opt            = $_POST['opt'];
    41     $inserts    = array();
    42     foreach ($opt as $opt_id)
    43     {
    44       $inserts[] = array(
    45           'opt_id'         => $opt_id,
    46           'product_id' => $id,
    47         );
    48     }
    49     mass_inserts(
    50     MPS_PROD_OPT_TABLE,
    51     array_keys($inserts[0]),
    52     $inserts
    53     );
    54    }
    55 
    56    $page['infos']=l10n('Edit');
    57   }
    58  
    59 
    60 if (empty($_POST['id'])and isset($_POST['product'])and isset($_POST['price'])and is_numeric($_POST['price']))
    61         {
    62         $order = array();
    63         $query ='SELECT * FROM '.MPS_PRODUCT_TABLE.';';
    64         $result = pwg_query($query);
    65         while($row = pwg_db_fetch_assoc($result)){
    66         $order[] = $row['order'];
    67         }
    68         if (count($order) == 0) {
    69         $order = 1;
    70         }else{
    71         $order = max($order)+1;
    72         }
    73        
    74         $product        = $_POST['product'];
    75         $noteAdmin      = $_POST['noteAdmin'];
    76         $price          = $_POST['price'];
    77 
    78        
    79    $query='INSERT into '.MPS_PRODUCT_TABLE.' (`order`,`product`,`noteAdmin`,`price`)
    80                         values (\''.$order.'\',\''.$product.'\',\''.$noteAdmin.'\',\''.$price.'\');';
    81    $result=pwg_query($query);
    82         $prod = pwg_db_insert_id();
    83    
    84    if(isset($_POST['opt']))
    85    {
    86         $opt = $_POST['opt'];
    87     $inserts = array();
    88     foreach ($opt as $opt_id)
    89     {
    90       $inserts[] = array(
    91           'opt_id' => $opt_id,
    92           'product_id' => $prod,
    93         );
    94     }
    95     mass_inserts(
    96     MPS_PROD_OPT_TABLE,
    97     array_keys($inserts[0]),
    98     $inserts
    99     );
    100    }
    101         $page['infos']=l10n('Product registered');
    102   }
    103 }
    104 
    105 if(isset($_POST['newOrder']))
    106         {
    107         $newOrder = explode(",", $_POST['newOrder']);
    108         $ex = array_pop($newOrder);
    109        
    110         foreach( $newOrder as $order => $id )
    111         {
    112         $order = $order +1;
    113 
    114       $query='UPDATE '.MPS_PRODUCT_TABLE.' SET `order` = \''.$order.'\' WHERE id = '.$id.';';
    115         $result = pwg_query($query);
    116    
    117     $page['infos']=l10n('the order is changed');
    118 
    119     }
    120 }
    121 
    122   $select_type_opt=array(
    123   'select'   =>'select',
    124   'radio'    =>'radio',
    125   'text'     =>'text',
    126   'textarea' =>'textarea',
    127   'checkbox' =>'checkbox',
    128   );
    129  
    130 if (isset($_POST['option_add']))
    131 {
    132         $order = array();
    133         $query ='SELECT * FROM '.MPS_OPTION_TABLE.';';
    134         $result = pwg_query($query);
    135         while($row = pwg_db_fetch_assoc($result)){
    136         $order[] = $row['order'];
    137         }
    138        
    139         if (count($order) == 0) {
    140         $order = 1;
    141         }else{
    142         $order = max($order)+1;
    143         }
    144 
    145         $name           = $_POST['name'];
    146     $type               = $_POST['type'];
    147     $title              = $_POST['title'];
    148        
    149         if(isset($_POST['requi'])){
    150          $requi = $_POST['requi'];
    151          }else{
    152          $requi = 0;
    153          }
    154        
    155        
    156         $query='INSERT into '.MPS_OPTION_TABLE.' (`name`,`type`,`titre`,`requi`,`order`)
    157                         values (\''.$name.'\',\''.$type.'\',\''.$title.'\',\''.$requi.'\',\''.$order.'\');';
    158    
    159         pwg_query($query);             
    160         $select_id = pwg_db_insert_id();                       
    161                        
    162         if(isset($_POST['val'])){
    163         $val = $_POST['val'];
    164      foreach($val as $val_ele)
    165       {
    166           $query='INSERT into '.MPS_OPT_VAL_TABLE.' (val,select_id)
    167                         values (\''.$val_ele.'\',\''.$select_id.'\');';
    168           pwg_query($query);
    169      }
    170         }
    171        
    172          echo('<div><div id="idlastopt" data-idlo="'.$select_id.'"></div></div>');
    173        
    174 }
    175  
    176  $query='SELECT * FROM '.MPS_PRODUCT_TABLE.' ORDER BY `order`;';
    177   $result = pwg_query($query);
    178   $products = array();
    179   while($row = pwg_db_fetch_assoc($result)){
    180         $query='
    181         SELECT *
    182         FROM '.MPS_PROD_OPT_TABLE.' AS op
    183         JOIN '.MPS_OPTION_TABLE.' AS p ON p.id = op.opt_id
    184         WHERE product_id = '.$row['id'].'
    185         ;';
    186         $res = pwg_query($query);
    187         $opt = array();
    188         while($row1 = pwg_db_fetch_assoc($res)){
    189     $opt[] = $row1['name'];
    190         }
    191         $row['option'] = $opt ;
    192         $products[$row['id']]=$row;
    193   }
    194  
    195 
    196   $query='SELECT * FROM '.MPS_OPTION_TABLE.' ;';
     206   
     207   $products[$row['id']]['option'][]=$row['name'];
     208  }
     209
     210  $query='
     211  SELECT `id`, `name`
     212  FROM '.MPS_OPTION_TABLE.'
     213  ;';
    197214  $result = pwg_query($query);
    198215  $option = array();
    199   while($row = pwg_db_fetch_assoc($result)){
     216 
     217  while($row = pwg_db_fetch_assoc($result)) {
    200218   $option[$row['id']] = $row['name'];
    201219  }
    202 
    203 $template->assign(array(
    204   'mps_product' => $products,
    205   'mps_option'  => $option,
    206   'mps_type_opt'                => $select_type_opt,
     220 
     221  $select_type_opt=array(
     222   'select'   =>'select',
     223   'radio'    =>'radio',
     224   'text'     =>'text',
     225   'textarea' =>'textarea',
     226   'checkbox' =>'checkbox',
     227  );
     228 
     229//template assign
     230  $template->assign(array(
     231   'mps_product'         => $products, 
     232   'mps_option'          => $option,
     233   'mps_type_opt' => $select_type_opt,
    207234  ));
    208 $template->set_filename('mps_content', realpath(MPS_PATH . 'admin/template/product.tpl'));
     235 
     236  $template->set_filename('mps_content', realpath(MPS_PATH . 'admin/template/product.tpl'));
  • extensions/MyPiwiShop/admin/template/product.tpl

    r27743 r27781  
    442442                        <td><span>{$product.product}</span> <a title="{'edit'|translate|escape:'javascript'}" class="prodEdit icon-pencil tabact">{'edit'|translate}</a> <a title="{'duplicate'|translate|escape:'javascript'}" class="prodDupli icon-pencil tabact">{'duplicate'|translate}</a></td>
    443443                        <td>{$product.noteAdmin} </td>
    444                         <td>{foreach from=$product.option item=option name=option}{$option}/{/foreach}</td>
     444                        <td>{foreach from=$product.option item=option name=option}{if !empty($option)}{$option}/{/if}{/foreach}</td>
    445445                        <td>{$product.price} {$mps_conf.currency}</td>
    446446                </tr>
  • extensions/MyPiwiShop/include/admin_events.inc.php

    r27568 r27781  
    22defined('MPS_PATH') or die('Hacking attempt!');
    33
    4 /**
    5  * admin plugins menu link
    6  */
     4
     5// admin plugins menu link
    76function mps_admin_plugin_menu_links($menu)
    87{
     
    1514}
    1615
    17 
    18 /**
    19  * add an action to the Batch Manager unit
    20 */
    21 
     16//add an action to the Batch Manager unit
    2217function mps_loc_end_element_set_unit()
    2318{
     
    2520 
    2621  global $template;
    27         $template->set_filename('mps_batch_unit', realpath(MPS_PATH.'admin/template/MyPiwiShopBatchUnit.tpl'));
    28         $template->assign_var_from_handle('MPS_BATCH_UNIT', 'mps_batch_unit');
    29 
    30         $template->set_prefilter('batch_manager_unit', 'batch_unit_form');
     22  $template->set_filename('mps_batch_unit', realpath(MPS_PATH.'admin/template/MyPiwiShopBatchUnit.tpl'));
     23  $template->assign_var_from_handle('MPS_BATCH_UNIT', 'mps_batch_unit');
     24  $template->set_prefilter('batch_manager_unit', 'batch_unit_form');
    3125}
    3226
    3327function batch_unit_form($content)
    3428{
    35 
    36         $search = '#</table>(\s*)</fieldset>#s';
    37         $replace ='</table>$1<div class="MyPiwiShopBatchUnit" style="text-align:left">{combine_script id="batchmanagerunit" load="footer" path="'.MPS_PATH.'/admin/template/js/batchmanagerunit.js"}
    38         {include file="'.realpath(MPS_PATH).'/admin/template/MyPiwiShopBatchUnit.tpl" imgid=$element.id}</div>$1</fieldset>';
     29  $search = '#</table>(\s*)</fieldset>#s';
     30  $replace ='</table>$1<div class="MyPiwiShopBatchUnit" style="text-align:left">{combine_script id="batchmanagerunit" load="footer" path="'.MPS_PATH.'/admin/template/js/batchmanagerunit.js"}
     31  {include file="'.realpath(MPS_PATH).'/admin/template/MyPiwiShopBatchUnit.tpl" imgid=$element.id}</div>$1</fieldset>';
    3932
    4033  return preg_replace($search, $replace, $content);
    4134}
    4235
    43 /**
    44  * add an action to the Batch Manager
    45  */
    46 
     36//add an action to the Batch Manager
    4737function mps_loc_end_element_set_global()
    4838{
    49         include_once(MPS_PATH.'admin/MyPiwiShopBatch.php');
     39  include_once(MPS_PATH.'admin/MyPiwiShopBatch.php');
    5040
    51         global $template;
    52        
    53         $template->set_filename('mps_batch_global', (MPS_PATH.'admin/template/MyPiwiShopBatch.tpl'));
    54  
    55         $template->append('element_set_global_plugins_actions', array(
    56     'ID' => 'mps',
    57     'NAME' => l10n('MyPiwiShop'),
    58     'CONTENT' => $template->parse('mps_batch_global', true)
    59     ));
     41  global $template;
     42  $template->set_filename('mps_batch_global', (MPS_PATH.'admin/template/MyPiwiShopBatch.tpl'));
     43  $template->append('element_set_global_plugins_actions', array(
     44   'ID' => 'mps',
     45   'NAME' => l10n('MyPiwiShop'),
     46   'CONTENT' => $template->parse('mps_batch_global', true)
     47  ));
    6048}
    6149
    62 /**
    63  * perform added action
    64 */
     50// perform added action
    6551function mps_element_set_global_action($action, $collection)
    6652{
    67         if ($action == 'mps')
    68         {
    69         global $page;
     53  if ($action == 'mps') {
     54   global $page;
    7055       
    71                 if (empty($_POST['productcheck']))
    72                 {
    73                 $page['errors'][] = l10n('Select at least one product');
    74                 }
    75                 else if ($_POST['thisprod']=='del')
    76                 {
    77                 $product_id = $_POST['productcheck'];
    78                 deletAll_product_image($product_id, $collection);
    79                 $page['infos'][] = l10n('Products have been removed for these pictures');       
    80                 }
    81                 else
    82                 {
    83                 $product_id = $_POST['productcheck'];
    84                 add_product_image($product_id, $collection);
    85                 $page['infos'][] = l10n('products have been added to these images');   
    86                 }
     56   if (empty($_POST['productcheck'])) {
     57        $page['errors'][] = l10n('Select at least one product');
     58   } else if ($_POST['thisprod']=='del') {
     59        $product_id = $_POST['productcheck'];
     60        deletAll_product_image($product_id, $collection);
     61        $page['infos'][] = l10n('Products have been removed for these pictures');       
     62   } else {
     63    $product_id = $_POST['productcheck'];
     64    add_product_image($product_id, $collection);
     65        $page['infos'][] = l10n('products have been added to these images');   
     66   }
     67   
    8768  }
    88  
    8969}
    9070
  • extensions/MyPiwiShop/include/functions.inc.php

    r27743 r27781  
    22defined('MPS_PATH') or die('Hacking attempt!');
    33
    4 /**
    5 *product/image
    6 **/
     4//add a product to all selected image
    75function add_product_image($product, $images)
    86{
     
    1210  }
    1311
    14   $query = '
    15         DELETE
    16         FROM '.MPS_PROD_IMG_TABLE.'
    17         WHERE image_id IN ('.implode(',', $images).')
    18         AND product_id IN ('.implode(',', $product).')
     12  pwg_query('
     13  DELETE
     14  FROM '.MPS_PROD_IMG_TABLE.'
     15  WHERE image_id IN ('.implode(',', $images).')
     16  AND product_id IN ('.implode(',', $product).')
     17  ;');
    1918
    20         ;';
    21   pwg_query($query);
    22 
    23   $inserts = array();
    24   foreach ($images as $image_id)
    25   {
    26     foreach ( array_unique($product) as $product_id)
    27     {
    28       $inserts[] = array(
    29           'image_id' => $image_id,
    30           'product_id' => $product_id,
    31         );
    32     }
     19  foreach ($images as $image_id) {
     20 
     21   foreach ( array_unique($product) as $product_id) {
     22    $inserts[] = array(
     23     'image_id' => $image_id,
     24     'product_id' => $product_id,
     25    );
     26   }
    3327  }
    34     mass_inserts(
    35     MPS_PROD_IMG_TABLE,
    36     array_keys($inserts[0]),
    37     $inserts
    38     );
     28 
     29  mass_inserts(
     30   MPS_PROD_IMG_TABLE,
     31   array_keys($inserts[0]),
     32   $inserts
     33  );
    3934}
    4035
    41 /**
    42 *product/image
    43 **/
     36//delet all product for all selected image
    4437function deletAll_product_image($product, $images)
    4538{
    46   $query = '
    47         DELETE
    48         FROM '.MPS_PROD_IMG_TABLE.'
    49         WHERE image_id IN ('.implode(',', $images).')
    50         AND product_id IN ('.implode(',', $product).')
    51 
    52         ;';
    53   pwg_query($query);
    54 
     39  pwg_query('
     40  DELETE
     41  FROM '.MPS_PROD_IMG_TABLE.'
     42  WHERE image_id IN ('.implode(',', $images).')
     43  AND product_id IN ('.implode(',', $product).')
     44  ;');
    5545}
    5646
    57 function deletThis_image_Allproduct($images)
     47//delet all product to specific image
     48function delet_Allproduct_Thisimage($images)
    5849{
    5950  $query = '
     
    6758}
    6859
     60//add a product to specific image
    6961function add_product_Thisimage($product, $images)
    7062{
  • extensions/MyPiwiShop/include/public_events.inc.php

    r27743 r27781  
    22defined('MPS_PATH') or die('Hacking attempt!');
    33
    4 /*
    5  * button on album and photos pages
    6  */
     4//button on album and photos pages
    75function mps_add_button()
    86{
    97  global $template, $conf;
    108 
    11  $query='SELECT * FROM '.MPS_CONF_TABLE.';';
    12     $result     = pwg_query($query);
    13     while($row = pwg_db_fetch_assoc($result)){
    14     $config = $row ;
    15    }
     9  $query='
     10  SELECT *
     11  FROM '.MPS_CONF_TABLE.'
     12  ;';
     13  $result       = pwg_query($query);
     14 
     15  while($row = pwg_db_fetch_assoc($result)){
     16   $config = $row ;
     17  }
    1618
    17         $template->assign(array(
    18     'mps_conf'  => $config,
    19         'MPS_PATH'      => MPS_PATH,
    20     ));   
    21 //  $template->assign('MPS_PATH', MPS_PATH);
     19  $template->assign(array(
     20   'mps_conf'   => $config,
     21   'MPS_PATH'   => MPS_PATH,
     22  ));   
     23
    2224  $template->set_filename('mps_button', realpath(MPS_PATH.'template/button_basket.tpl'));
    23 //  $template->assign('mps_conf' , $config);
    24 
    2525  $button = $template->parse('mps_button', true);
    2626 
    27   if (script_basename()=='index')
    28   {
     27  if (script_basename()=='index') {
    2928    $template->add_index_button($button, EVENT_HANDLER_PRIORITY_NEUTRAL);
    30   }
    31   else
    32   {
     29  } else {
    3330    $template->add_picture_button($button, EVENT_HANDLER_PRIORITY_NEUTRAL);
    3431  }
    3532}
    3633
    37 /**
    38  * add a forms on photo page
    39  */
    40 function mps_loc_end_picture()
     34// add a forms on photo page
     35function mps_init_form_picture()
    4136{
    4237  global $template;
    43         $template->set_filename('MyPiwiShop', realpath(MPS_PATH.'template/MyPiwiShop.tpl'));
    44         $template->assign_var_from_handle('MPS_CONTENT', 'MyPiwiShop');
     38 
     39  $template->set_filename('MyPiwiShop', realpath(MPS_PATH.'template/MyPiwiShop.tpl'));
     40  $template->assign_var_from_handle('MPS_CONTENT', 'MyPiwiShop');
    4541}
    4642
     43// place on picture page (default theme)
    4744function mps_picture_form($content)
    4845{
    49         $search = '#</div>(\s*)</div>(\s*){if isset\(\$COMMENT_COUNT\)}#s';
    50         $replace =  '</div>$1</div>$2<div id="MyPiwiShop">{$MPS_CONTENT}</div>{if isset(\$COMMENT_COUNT)}';
     46  $search = '#</div>(\s*)</div>(\s*){if isset\(\$COMMENT_COUNT\)}#s';
     47  $replace =  '</div>$1</div>$2<div id="MyPiwiShop">{$MPS_CONTENT}</div>{if isset(\$COMMENT_COUNT)}';
    5148
    52         return preg_replace($search, $replace, $content);
     49  return preg_replace($search, $replace, $content);
    5350}
    5451
     52// place on picture page (piwitheme theme)
    5553function mps_picture_form_piwitheme($content)
    5654{
    57         $search = '#{/foreach}(\s*){/foreach}(\s*)</table>(\s*){/if}(\s*)</div>#s';
    58         $replace =  '{/foreach}$1{/foreach}$1</table>$1{/if}</div><div class="panelPP"><div id="MyPiwiShop">{$MPS_CONTENT}</div></div>';
     55  $search = '#{/foreach}(\s*){/foreach}(\s*)</table>(\s*){/if}(\s*)</div>#s';
     56  $replace =  '{/foreach}$1{/foreach}$1</table>$1{/if}</div><div class="panelPP"><div id="MyPiwiShop">{$MPS_CONTENT}</div></div>';
    5957
    60         $newcont = preg_replace($search, $replace, $content);
     58  $newcont = preg_replace($search, $replace, $content);
    6159
    62         $search = '#<a class="trigger" href="\#">(\s*)infos(\s*)</a>(\s*)#s';
    63         $replace =  '<a class="trigger" href="#">infos</a>$1<a class="triggerPP" href="#" >{\'Shop\'|@translate}</a>{footer_script}{literal}$(document).ready(function(){$(".triggerPP").click(function(){$(".panelPP").toggle("fast");$(this).toggleClass("active");return false;});});{/literal}{/footer_script}';
     60  $search = '#<a class="trigger" href="\#">(\s*)infos(\s*)</a>(\s*)#s';
     61  $replace =  '<a class="trigger" href="#">infos</a>$1<a class="triggerPP" href="#" >{\'Shop\'|@translate}</a>{footer_script}{literal}$(document).ready(function(){$(".triggerPP").click(function(){$(".panelPP").toggle("fast");$(this).toggleClass("active");return false;});});{/literal}{/footer_script}';
    6462
    65         return preg_replace($search, $replace, $newcont);
     63  return preg_replace($search, $replace, $newcont);
    6664}
    6765
     66// place on picture page (stripped theme)
    6867function mps_picture_form_stripped($content)
    6968{
    70         $search = '#<div style="clear: both;"></div>(\s*)</div>(\s*)</div>(\s*)</div>(\s*){/if}(\s*)</div>#s';
    71         $replace =  '<div style="clear: both;"></div></div>$1</div></div>$2{/if}<div id="Tmps" class="tabBlock"><div id="MyPiwiShop">{$MPS_CONTENT}</div></div></div>';
     69  $search = '#<div style="clear: both;"></div>(\s*)</div>(\s*)</div>(\s*)</div>(\s*){/if}(\s*)</div>#s';
     70  $replace =  '<div style="clear: both;"></div></div>$1</div></div>$2{/if}<div id="Tmps" class="tabBlock"><div id="MyPiwiShop">{$MPS_CONTENT}</div></div></div>';
    7271
    73         $newcont = preg_replace($search, $replace, $content);
     72  $newcont = preg_replace($search, $replace, $content);
    7473
    75         $search = '#{/if}(\s*)</ul>(\s*)#s';
    76         $replace =  '{/if}$2<li id="tabTmps" class="tabTitle" title="{\'Shop\'|@translate}" name="shop">{\'Shop\'|@translate}</li></ul>';
     74  $search = '#{/if}(\s*)</ul>(\s*)#s';
     75  $replace =  '{/if}$2<li id="tabTmps" class="tabTitle" title="{\'Shop\'|@translate}" name="shop">{\'Shop\'|@translate}</li></ul>';
    7776
    78         return preg_replace($search, $replace, $newcont);
     77  return preg_replace($search, $replace, $newcont);
    7978}
    8079
     
    8281{
    8382  global $conf, $template, $picture, $user;
    84         $image_id = $picture['current']['id'];
     83 
     84  $image_id = $picture['current']['id'];
    8585       
    86    $query='SELECT * FROM '.MPS_CONF_TABLE.';';
    87       $result   = pwg_query($query);
    88       while($row = pwg_db_fetch_assoc($result)){
    89       $config = $row ;
    90      }
     86  $query='
     87  SELECT *
     88  FROM '.MPS_CONF_TABLE.'
     89  ;';
     90  $result = pwg_query($query);
     91 
     92  while($row = pwg_db_fetch_assoc($result)) {
     93   $config = $row ;
     94  }
    9195
    92    $query = '
    93         SELECT *
    94     FROM '.MPS_PROD_IMG_TABLE.' AS pi
    95     INNER JOIN '.MPS_PRODUCT_TABLE.' AS p ON pi.product_id = p.id
    96     WHERE image_id = '.$image_id .'
    97         ORDER BY `order`
     96  $query = '
     97  SELECT *
     98  FROM '.MPS_PROD_IMG_TABLE.' AS pi
     99  INNER JOIN '.MPS_PRODUCT_TABLE.' AS p ON pi.product_id = p.id
     100  WHERE image_id = '.$image_id .'
     101  ORDER BY `order`
    98102    ;';
    99         $result = pwg_query($query);
    100         $num_rows = pwg_db_num_rows($result);
    101      if ($num_rows != 0){
    102       while($row = pwg_db_fetch_assoc($result)){
    103           $product[$row['product']] = $row['product'].' '. $row['price'].' '. $config['currency'];
    104       $price[] = $row['price'];
    105      }
     103  $result = pwg_query($query);
     104  $num_rows = pwg_db_num_rows($result);
     105 
     106  if ($num_rows != 0) {
     107   while($row = pwg_db_fetch_assoc($result)) {
     108    $product[$row['product']] = $row['product'].' '. $row['price'].' '. $config['currency'];
     109    $price[] = $row['price'];
     110   }
    106111
    107112 
    108   $query='SELECT pi.product_id, po.product_id, p.price, p.product, o.name, o.type, o.requi, o.order, po.opt_id, ov.val 
     113   $query='SELECT pi.product_id, po.product_id, p.price, p.product, o.name, o.type, o.requi, o.order, po.opt_id, ov.val 
    109114   FROM '.MPS_PROD_IMG_TABLE.' AS pi
    110     LEFT JOIN '.MPS_PRODUCT_TABLE.' AS p ON p.id = pi.product_id
    111         LEFT JOIN '.MPS_PROD_OPT_TABLE.' AS po ON po.product_id = p.id
    112         LEFT JOIN '.MPS_OPTION_TABLE.' AS o ON o.id = po.opt_id
    113         LEFT JOIN '.MPS_OPT_VAL_TABLE.' AS ov ON ov.select_id = o.id
    114         WHERE image_id = '.$image_id .'
    115         AND po.opt_id IS NOT NULL
    116          ;';
    117 
    118          $result = pwg_query($query);
    119         while($row = pwg_db_fetch_assoc($result)){
    120         {
    121                 if (!isset($products[ $row['product']]['options'][ $row['order'] ]))
    122                 {
    123                         $products[ $row['product'] ]['options'][ $row['order'] ] = array(
    124                         'name'   => $row['name'],
    125                         'type'   => $row['type'],
    126                         'requi'  => $row['requi'],
    127                         'values' => array(),
    128                         );
    129                 }
     115   LEFT JOIN '.MPS_PRODUCT_TABLE.' AS p ON p.id = pi.product_id
     116   LEFT JOIN '.MPS_PROD_OPT_TABLE.' AS po ON po.product_id = p.id
     117   LEFT JOIN '.MPS_OPTION_TABLE.' AS o ON o.id = po.opt_id
     118   LEFT JOIN '.MPS_OPT_VAL_TABLE.' AS ov ON ov.select_id = o.id
     119   WHERE image_id = '.$image_id .'
     120   AND po.opt_id IS NOT NULL
     121   ;';
     122   $result = pwg_query($query);
     123         
     124   while($row = pwg_db_fetch_assoc($result)) {
     125    {
     126         if (!isset($products[ $row['product']]['options'][ $row['order'] ])) {
     127          $products[ $row['product'] ]['options'][ $row['order'] ] = array(
     128           'name'   => $row['name'],
     129           'type'   => $row['type'],
     130           'requi'  => $row['requi'],
     131           'values' => array(),
     132          );
     133         }
     134         $products[ $row['product'] ]['options'][ $row['order'] ]['values'][] = $row['val'];
     135   
     136    }
     137   }
    130138 
    131         $products[ $row['product'] ]['options'][ $row['order'] ]['values'][] = $row['val'];
    132         }
    133     }
    134         if(isset($products)){
    135      $template->assign(array(
    136          'mps_options'                  => $products,
    137          ));
    138         }
    139  
    140         $template->assign(array(
    141         'mps_conf'                      => $config,
    142         'mps_price'                     => $price,
    143         'mps_product'           => $product,
    144         ));
     139   if(isset($products)) {
     140    $template->assign(array(
     141     'mps_options'  => $products,
     142    ));
     143   }
     144   
     145   $template->assign(array(
     146    'mps_conf'          => $config,
     147    'mps_price'   => $price,
     148    'mps_product' => $product,
     149   ));
    145150       
    146 
    147        
    148        
    149         $theme = $user['theme'];
    150        
    151  switch ($theme) {
     151   $theme = $user['theme'];
     152   
     153   switch ($theme) {
    152154    case 'stripped':
    153         $template->set_prefilter('picture', 'mps_picture_form_stripped');
    154         break;
     155     $template->set_prefilter('picture', 'mps_picture_form_stripped');
     156     break;
    155157        case 'PwgCarbon_dft':
    156158        case 'PwgCarbon':
     
    159161        case 'Slimi':
    160162        case 'Slim':
    161         $template->set_prefilter('picture', 'mps_picture_form_piwitheme');
    162                 $template->assign(array('bypiwitheme'=> 'bypiwitheme'));
    163         break;
     163     $template->set_prefilter('picture', 'mps_picture_form_piwitheme');
     164         $template->assign(array('bypiwitheme'=> 'bypiwitheme'));
     165     break;
    164166    default:
    165         $template->set_prefilter('picture', 'mps_picture_form');
    166         break;
    167 }
    168 
    169 
     167     $template->set_prefilter('picture', 'mps_picture_form');
     168     break;
    170169   }
     170  }
    171171}
    172172
  • extensions/MyPiwiShop/main.inc.php

    r27743 r27781  
    3535add_event_handler('init', 'mps_init');
    3636
    37 if (defined('IN_ADMIN'))
    38 {
     37if (defined('IN_ADMIN')) {
    3938  include_once(MPS_PATH . 'include/admin_events.inc.php');
    4039 
     
    4746  add_event_handler('element_set_global_action', 'mps_element_set_global_action', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
    4847  add_event_handler('loc_end_element_set_unit', 'mps_loc_end_element_set_unit');
    49 
    50 }
    51 else
    52 {
     48} else {
    5349  // file containing all public handlers functions
    5450  include_once(MPS_PATH . 'include/public_events.inc.php');
     
    6056  // form on photo page
    6157  add_event_handler('loc_end_picture', 'mps_prepar_tpl');
    62   add_event_handler('loc_end_picture', 'mps_loc_end_picture');
     58  add_event_handler('loc_end_picture', 'mps_init_form_picture');
    6359}
    6460
     
    6662include_once(MPS_PATH . 'include/functions.inc.php');
    6763
    68  function mps_init()
    69 {
     64 function mps_init() {
    7065  global $prefixeTable;
    7166 
     
    7570  $maintain->autoUpdate(MPS_VERSION, 'install');
    7671 
    77         $query='SELECT * FROM '.MPS_CONF_TABLE.';';
    78         if(pwg_db_num_rows(pwg_query($query))==0){
    79       single_insert(
    80        $prefixeTable."mps_conf",
    81        array(
    82         'currency' => 'EUR',
    83         )
    84       );
    85         }
     72  $query='
     73  SELECT *
     74  FROM '.MPS_CONF_TABLE.'
     75  ;';
     76       
     77  if(pwg_db_num_rows(pwg_query($query))==0) {
     78   single_insert(
     79    $prefixeTable."mps_conf",
     80    array(
     81     'currency' => 'EUR',
     82    )
     83   );
     84  }
    8685 
    8786  // load plugin language file
    8887  load_language('plugin.lang', MPS_PATH);
    89  
    9088}
    9189
  • extensions/MyPiwiShop/maintain.inc.php

    r27743 r27781  
    7474        ;');
    7575       
    76             $this->installed = true;
    77 
     76        $this->installed = true;
    7877  } 
    7978       
    80 
    81   /**
    82    * plugin activation
    83    */
    84    function activate($plugin_version, &$errors=array())
     79  function activate($plugin_version, &$errors=array())
    8580  {
    86 
    87    if (!$this->installed)
    88     {
    89       $this->install($plugin_version, $errors);
    90     }
     81   if (!$this->installed) {
     82    $this->install($plugin_version, $errors);
     83   }
    9184  }
    9285 
     
    9588  }
    9689
    97 
    98   /**
    99    * plugin uninstallation
    100    */
    10190  function uninstall()
    10291  {
     
    10998    pwg_query('DROP TABLE `'. $prefixeTable .'mps_opt_val`;');
    11099    pwg_query('DROP TABLE `'. $prefixeTable .'mps_prod_opt`;');
    111  }
     100  }
    112101}
    113102
Note: See TracChangeset for help on using the changeset viewer.