Changeset 27781 for extensions/MyPiwiShop/include/public_events.inc.php
- Timestamp:
- Mar 16, 2014, 7:16:27 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/MyPiwiShop/include/public_events.inc.php
r27743 r27781 2 2 defined('MPS_PATH') or die('Hacking attempt!'); 3 3 4 /* 5 * button on album and photos pages 6 */ 4 //button on album and photos pages 7 5 function mps_add_button() 8 6 { 9 7 global $template, $conf; 10 8 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 } 16 18 17 18 19 20 21 // $template->assign('MPS_PATH', MPS_PATH); 19 $template->assign(array( 20 'mps_conf' => $config, 21 'MPS_PATH' => MPS_PATH, 22 )); 23 22 24 $template->set_filename('mps_button', realpath(MPS_PATH.'template/button_basket.tpl')); 23 // $template->assign('mps_conf' , $config);24 25 25 $button = $template->parse('mps_button', true); 26 26 27 if (script_basename()=='index') 28 { 27 if (script_basename()=='index') { 29 28 $template->add_index_button($button, EVENT_HANDLER_PRIORITY_NEUTRAL); 30 } 31 else 32 { 29 } else { 33 30 $template->add_picture_button($button, EVENT_HANDLER_PRIORITY_NEUTRAL); 34 31 } 35 32 } 36 33 37 /** 38 * add a forms on photo page 39 */ 40 function mps_loc_end_picture() 34 // add a forms on photo page 35 function mps_init_form_picture() 41 36 { 42 37 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'); 45 41 } 46 42 43 // place on picture page (default theme) 47 44 function mps_picture_form($content) 48 45 { 49 50 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)}'; 51 48 52 49 return preg_replace($search, $replace, $content); 53 50 } 54 51 52 // place on picture page (piwitheme theme) 55 53 function mps_picture_form_piwitheme($content) 56 54 { 57 58 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>'; 59 57 60 58 $newcont = preg_replace($search, $replace, $content); 61 59 62 63 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}'; 64 62 65 63 return preg_replace($search, $replace, $newcont); 66 64 } 67 65 66 // place on picture page (stripped theme) 68 67 function mps_picture_form_stripped($content) 69 68 { 70 71 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>'; 72 71 73 72 $newcont = preg_replace($search, $replace, $content); 74 73 75 76 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>'; 77 76 78 77 return preg_replace($search, $replace, $newcont); 79 78 } 80 79 … … 82 81 { 83 82 global $conf, $template, $picture, $user; 84 $image_id = $picture['current']['id']; 83 84 $image_id = $picture['current']['id']; 85 85 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 } 91 95 92 93 94 95 96 97 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` 98 102 ;'; 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 } 106 111 107 112 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.val113 $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 109 114 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 } 130 138 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 )); 145 150 146 147 148 149 $theme = $user['theme']; 150 151 switch ($theme) { 151 $theme = $user['theme']; 152 153 switch ($theme) { 152 154 case 'stripped': 153 154 155 $template->set_prefilter('picture', 'mps_picture_form_stripped'); 156 break; 155 157 case 'PwgCarbon_dft': 156 158 case 'PwgCarbon': … … 159 161 case 'Slimi': 160 162 case 'Slim': 161 162 163 163 $template->set_prefilter('picture', 'mps_picture_form_piwitheme'); 164 $template->assign(array('bypiwitheme'=> 'bypiwitheme')); 165 break; 164 166 default: 165 $template->set_prefilter('picture', 'mps_picture_form'); 166 break; 167 } 168 169 167 $template->set_prefilter('picture', 'mps_picture_form'); 168 break; 170 169 } 170 } 171 171 } 172 172
Note: See TracChangeset
for help on using the changeset viewer.