Plugin Directory

Changeset 637603


Ignore:
Timestamp:
12/12/2012 09:40:47 AM (13 years ago)
Author:
vandai
Message:

Update version 1.1.4

Location:
komper/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • komper/trunk/insert_data.php

    r633328 r637603  
    7979    if(array_key_exists($fieldType,$field_type)){
    8080        switch($fieldType){
     81            case "group":
     82                    $form = "<hr noshade>";
     83                    break;
    8184            case "textarea":
    8285                $form = "<textarea class='field span8' rows=3 name='".$fieldName."' id='".$fieldId."'>".$val."</textarea>";
     
    397400        <div class="alert alert-info">
    398401            <h4>You are using Komper free version</h4>
    399             With free version you can create up to 10 fields, and compare 2 products. <br />
     402            With free version you can create up to 15 fields, and compare 2 products. <br />
    400403            Upgrade to Pro version to get unlimited fields, unlimited products to compare, insert comparation table to your posts or pages, and more.. <br />
    401404            Get it here: <a href="http://www.vnetware.com/" target="_blank">http://www.vnetware.com/</a>
  • komper/trunk/komper_admin.php

    r637452 r637603  
    3333
    3434if($act == "insert"){
    35     //include_once("insert_data.php");
    36     $pid = isset($_GET['pid']) ? $_GET['pid'] : "";
    37     $addsubmit = isset($_POST['addsubmit']) ? $_POST['addsubmit'] : "";
    38     $editsubmit = isset($_POST['editsubmit']) ? $_POST['editsubmit'] : "";
    39 
    40     if($addsubmit != ""){
    41         $product_name = isset($_POST['product_name']) ? $_POST['product_name'] : "";
    42         $product_image = upload_img($_FILES);
    43         $wpdb->insert(KOMPER_TABLE_PRODUCT,
    44                 array('product_name' => $product_name,
    45                     'product_image' => $product_image
    46                 ), array('%s','%s')
    47         );
    48         $pid = $wpdb->insert_id;
    49         unset($_POST['product_name']);
    50         unset($_POST['addsubmit']);
    51         foreach($_POST as $key => $post){
    52             $wpdb->insert(KOMPER_TABLE_VALUE,
    53                 array('product_id' => $pid,
    54                     'field_id' => $key,
    55                     'field_values' => $post
    56                 ), array('%s','%s','%s','%s')
    57             ); 
    58         }
    59         //wp_safe_redirect( '?page='.PAGE.'&act=insert'); exit;
    60         echo '<META HTTP-EQUIV="Refresh" Content="0; URL=?page='.PAGE.'&act=insert">';
    61     }
    62 
    63     if($editsubmit != ""){
    64 
    65         $product_id = isset($_POST['pid']) ? $_POST['pid'] : "";
    66         $product_name = isset($_POST['product_name']) ? $_POST['product_name'] : "";
    67 
    68         $fileName = isset($_FILES['product_img']['name']) ? $_FILES['product_img']['name'] : "" ;
    69         if($fileName != ""){
    70             $product_image = upload_img($_FILES);
    71             $wpdb->update(KOMPER_TABLE_PRODUCT,
    72                     array('product_name' => $product_name,
    73                         'product_image' => $product_image
    74                     ), array( 'id' => $product_id ),
    75                     array('%s','%s'), array('%d')
    76             );
    77         }else{
    78             $wpdb->update(KOMPER_TABLE_PRODUCT,
    79                     array('product_name' => $product_name
    80                     ), array( 'id' => $product_id ),
    81                     array('%s'), array('%d')
    82             );
    83         }
    84         unset($_POST['product_name']);
    85         unset($_POST['editsubmit']);
    86         unset($_POST['pid']);
    87         foreach($_POST as $key => $post){
    88             $ids = explode("|",$key);
    89             $pid = $ids[0];
    90             $fid = $ids[1];
    91 
    92             if($pid != ""){
    93                 $wpdb->update(KOMPER_TABLE_VALUE,
    94                     array('field_values' => $post
    95                     ), array('id' => $pid),
    96                     array('%s'), array('%d')
    97                 ); 
    98             }else{
    99                 $wpdb->insert(KOMPER_TABLE_VALUE,
    100                 array('product_id' => $product_id,
    101                     'field_id' => $fid,
    102                     'field_values' => $post
    103                 ), array('%s','%s','%s')
    104             ); 
    105             }
    106         }
    107         echo '<META HTTP-EQUIV="Refresh" Content="0; URL=?page='.PAGE.'&act=insert">';
    108     }
    109     function generateform($fieldType,$fieldName,$fieldId,$field_type,$val = null){
    110         $form = "";
    111         $val = isset($val) ? $val : "";
    112         if(array_key_exists($fieldType,$field_type)){
    113             switch($fieldType){
    114                 case "group":
    115                     $form = "<hr noshade>";
    116                     break;
    117                 case "textarea":
    118                     $form = "<textarea class='field span8' rows=3 name='".$fieldName."' id='".$fieldId."'>".$val."</textarea>";
    119                     break;
    120                 case "radio";
    121                     if($val == "yes") $yes = "checked";else $yes = "";
    122                     if($val == "no" OR $val == "") $no = "checked";else $no = "";
    123                     $form = "<input type='radio' name='".$fieldName."' id='".$fieldId."_1' value='yes' $yes />Yes &nbsp;
    124                         <input type='radio' name='".$fieldName."' id='".$fieldId."_2' value='no' $no />No";
    125                     break;
    126                 case "date":
    127                     echo '<script>
    128                         jQuery(function() {
    129                             jQuery("#date_'.$fieldId.'").datepicker({
    130                                 changeMonth: true,
    131                                 changeYear: true,
    132                                 yearRange: "-50:+10",
    133                                 dateFormat: "d MM yy"
    134                             });
    135                         });
    136                         </script>';
    137                     $form = "<input type='text' name='".$fieldName."' id='date_".$fieldId."' value='".$val."'>";
    138                 break;
    139             }
    140         }
    141         return $form;
    142     }
    143 
    144     function upload_img($files){
    145 
    146         $uploaddir = str_replace('wp-admin/options-general.php','wp-content/products/',$_SERVER['SCRIPT_FILENAME']);
    147         $product_image = "";
    148         $fileName = isset($files['product_img']['name']) ? $files['product_img']['name'] : "" ;
    149         if($fileName != ""){
    150 
    151             if(!is_dir($uploaddir)){
    152                 mkdir($uploaddir,0755);
    153             }
    154             $fileSize = $_FILES['product_img']['size'];
    155             $fileError = $_FILES['product_img']['error'];
    156             if($fileSize > 0 || $fileError == 0){
    157                 $ext = pathinfo($fileName, PATHINFO_EXTENSION);
    158                 $newfilename = md5($fileName.time()).".".$ext;
    159                 $move = move_uploaded_file($_FILES['product_img']['tmp_name'], $uploaddir.$newfilename);
    160                 if($move){
    161                     $product_image = $newfilename;
    162 
    163                     $thumbdir = $uploaddir."/thumb/";
    164                     if(!is_dir($thumbdir)){
    165                         mkdir($thumbdir,0755);
    166                     }
    167                     $thumb = $thumbdir.$newfilename;
    168                     resize($uploaddir.$newfilename,'180','180',$thumb);
    169                 }
    170             }
    171         }
    172         return $product_image;
    173     }
    174 
    175     //RESIZE IMAGE
    176     function resize($img, $w, $h, $newfilename) {
    177         if (!extension_loaded('gd') && !extension_loaded('gd2')) {
    178             trigger_error("GD is not loaded", E_USER_WARNING);
    179             return false;
    180         }
    181         $imgInfo = getimagesize($img);
    182             switch ($imgInfo[2]) {
    183             case 1: $im = imagecreatefromgif($img); break;
    184             case 2: $im = imagecreatefromjpeg($img);  break;
    185             case 3: $im = imagecreatefrompng($img); break;
    186             default:  trigger_error('Unsupported filetype!', E_USER_WARNING);  break;
    187         }
    188         if ($imgInfo[0] <= $w && $imgInfo[1] <= $h) {
    189             $nHeight = $imgInfo[1];
    190             $nWidth = $imgInfo[0];
    191         }else{
    192             if ($w/$imgInfo[0] > $h/$imgInfo[1]) {
    193                 $nWidth = $w;
    194                 $nHeight = $imgInfo[1]*($w/$imgInfo[0]);
    195                 }else{
    196                 $nWidth = $imgInfo[0]*($h/$imgInfo[1]);
    197                 $nHeight = $h;
    198             }
    199         }
    200         $nWidth = round($nWidth);
    201         $nHeight = round($nHeight);
    202 
    203         $newImg = imagecreatetruecolor($nWidth, $nHeight);
    204         if(($imgInfo[2] == 1) OR ($imgInfo[2]==3)){
    205             imagealphablending($newImg, false);
    206             imagesavealpha($newImg,true);
    207             $transparent = imagecolorallocatealpha($newImg, 255, 255, 255, 127);
    208             imagefilledrectangle($newImg, 0, 0, $nWidth, $nHeight, $transparent);
    209         }
    210         imagecopyresampled($newImg, $im, 0, 0, 0, 0, $nWidth, $nHeight, $imgInfo[0], $imgInfo[1]);
    211         switch ($imgInfo[2]) {
    212             case 1: imagegif($newImg,$newfilename); break;
    213             case 2: imagejpeg($newImg,$newfilename);  break;
    214             case 3: imagepng($newImg,$newfilename); break;
    215             default:  trigger_error('Failed resize image!', E_USER_WARNING);  break;
    216         }
    217 
    218         return $newfilename;
    219     }
    220 
    221     $fields = $wpdb->get_results("select * from ".KOMPER_TABLE_NAME." order by field_order asc");
    222 
    223     wp_register_style( 'jqueryStyle', plugins_url('assets/css/smoothness/jquery-ui-1.9.0.custom.min.css', __FILE__) );
    224     wp_enqueue_style('jqueryStyle');
    225     ?>
    226     <script>
    227     jQuery(document).ready(function($) {
    228         $('#checkall').click(function() {
    229             $(this).closest('table').find(':checkbox').prop('checked', this.checked);
    230         });
    231 
    232         //Delete Field Function
    233         $("#btndelfield").click(function(e) {
    234             var selected = new Array();
    235             $('input[type=checkbox]').each(function () {
    236                 if($(this).is(':checked')){
    237                     selected.push($(this).attr('value'));
    238                 }
    239             });
    240             if(selected != ""){
    241                 if(confirm("Delete this fields?")){
    242                     var pids = selected;
    243                     var d_data = {
    244                             action: 'del_products',
    245                             pids: pids
    246                     };
    247                     $.post(ajaxurl, d_data, function(resp){
    248                         location.href='?page=<?php echo PAGE; ?>&act=insert';
    249                     });
    250                 }
    251             }else{
    252                 alert("Please select at least one field to delete.");
    253             }
    254             return false;
    255         });
    256     });
    257     </script>
    258         <div id="menu-management">
    259             <div class="nav-tabs-wrapper">
    260                 <div class="nav-tabs">
    261                     <a href="?page=<?php echo PAGE; ?>" class="nav-tab hide-if-no-js">Field List</a>
    262                     <a href="?page=<?php echo PAGE; ?>&act=insert" class="nav-tab nav-tab-active">Product List</a>
    263                 </div>
    264             </div>
    265             <div class="menu-edit">
    266                 <div id="nav-menu-header">
    267                         <div id="submitpost" class="submitbox">
    268                             <div class="major-publishing-actions">
    269                                 <div class="publishing-action">
    270                                     <h3><span>Product List</span></h3>
    271                                 </div>
    272                             </div>
    273                         </div>
    274                     </div>
    275                     <div id="post-body">
    276                         <div id="post-body-content">
    277                             <?php if($do == "new"){  ?>
    278                             <div id="menu-instructions" class="post-body-plain" style="padding:10px;">
    279                                 <form name="newproduct" class="form-horizontal" onsubmit="return true;" action="?page=<?php echo PAGE;?>&act=insert" method="POST" accept-charset="utf-8" enctype="multipart/form-data">
    280                                   <div class="control-group">
    281                                     <label class="control-label" for="product_name">Product Name</label>
    282                                     <div class="controls">
    283                                       <input type="text" id="product_name" name="product_name">
    284                                     </div>
    285                                   </div>
    286                                   <div class="control-group">
    287                                     <label class="control-label" for="product_image">Product Image</label>
    288                                     <div class="controls">
    289                                       <input type="file" name="product_img" id="product_img">
    290                                     </div>
    291                                   </div>
    292                                   <?php foreach($fields as $row){ ?>
    293                                   <div class="control-group">
    294                                     <label class="control-label" for="<?php echo $row->id;?>"><?php echo $row->field_name;?></label>
    295                                     <div class="controls">
    296                                       <?php echo generateform($row->field_type,$row->id,$row->id,$field_type); ?>
    297                                     </div>
    298                                   </div>
    299                                   <?php } ?>
    300                                   <div class="control-group">
    301                                     <div class="controls">
    302                                       <input type="submit" name="addsubmit" id="addsubmit" class="button button-primary" value="Submit" />
    303                                       <input type="button" name="btncancel" id="btncancel" class="button button-primary" value="Cancel" onclick="window.location.href = '?page=<?php echo PAGE; ?>&act=insert';" />
    304                                     </div>
    305                                   </div>
    306                                 </form>
    307                             </div>
    308                             <?php } elseif($do == "edit") {
    309                             $fields = $wpdb->get_results("SELECT a.*,b.field_values, b.id as pid FROM ".KOMPER_TABLE_NAME." a left join ".KOMPER_TABLE_VALUE." b on a.id = b.field_id and b.product_id = '".$pid."' order by a.field_order asc");
    310                             $prod = $wpdb->get_row("select * from ".KOMPER_TABLE_PRODUCT." where id = '".$pid."' ");
    311                             ?>
    312                             <div id="menu-instructions" class="post-body-plain" style="padding:10px;">
    313                                 <form name="newproduct" class="form-horizontal" onsubmit="return ture;" action="?page=<?php echo PAGE;?>&act=insert&do=edit&pid=<?php echo $pid;?>" method="POST" accept-charset="utf-8" enctype="multipart/form-data">
    314                                   <input type="hidden" id="pid" name="pid" value="<?php echo $prod->id; ?>" />
    315                                     <div class="control-group">
    316                                     <label class="control-label" for="product_name">Product Name</label>
    317                                     <div class="controls">
    318                                       <input type="text" id="product_name" name="product_name" value="<?php echo $prod->product_name; ?>" />
    319                                     </div>
    320                                   </div>
    321                                   <div class="control-group">
    322                                     <label class="control-label" for="product_img">Product Image</label>
    323                                     <div class="controls">
    324                                       <input type="file" name="product_img" id="product_img">
    325                                     </div>
    326                                   </div>
    327                                   <?php foreach($fields as $row){ ?>
    328                                   <div class="control-group">
    329                                     <label class="control-label" for="<?php echo $row->pid;?>"><?php echo $row->field_name;?></label>
    330                                     <div class="controls">
    331                                       <?php echo generateform($row->field_type,$row->pid."|".$row->id,$row->id,$field_type, $row->field_values); ?>
    332                                     </div>
    333                                   </div>
    334                                   <?php } ?>
    335                                   <div class="control-group">
    336                                     <div class="controls">
    337                                       <input type="submit" name="editsubmit" id="editsubmit" class="button button-primary" value="Submit" />
    338                                       <input type="button" name="btncancel" id="btncancel" class="button button-primary" value="Cancel" onclick="window.location.href = '?page=<?php echo PAGE; ?>&act=insert';" />
    339                                     </div>
    340                                   </div>
    341                                 </form>
    342                             </div>
    343                             <?php } else {
    344                                 $perpage = 20;
    345                                 $page = isset($_GET['p']) ? $_GET['p'] : "1";
    346 
    347                                 $sql = "select * from ".KOMPER_TABLE_PRODUCT." order by id desc";
    348                                 $tot_products = count($wpdb->get_results($sql));   
    349                                 $pages = ceil($tot_products/$perpage);
    350 
    351                                 $offset = ($page - 1) * $perpage;
    352 
    353                                 $sql2 = $sql." limit $offset,$perpage";
    354                                 $products = $wpdb->get_results($sql2);
    355 
    356                             ?>
    357                             <div id="menu-instructions" class="post-body-plain" style="padding:10px;width:550px;">
    358                                 <div class="row-fluid">
    359                                     <div class="span6">
    360                                         <a class="btn btn-warning" name="btndelfield" id="btndelfield">Delete Selected</a>
    361                                     </div>
    362                                     <div class="span6" align="right">
    363                                         <a href="?page=<?php echo PAGE; ?>&act=insert&do=new" class="btn btn-primary">Add New Product</a>
    364                                     </div>
    365                                 </div>
    366 
    367                                 <div>
    368                                 <table class="table table-striped table-bordered">
    369                                   <thead>
    370                                     <tr>
    371                                         <th><input type="checkbox" class="checkbox checkall" id="checkall" name="checkall" /></th>
    372                                         <th>No</th>
    373                                         <th>Product Name</th>
    374                                         <th>Action</th>
    375                                     </tr>
    376                                   </thead>
    377                                   <tbody>
    378                                     <?php $i=0;
    379                                     if(count($products) > 0){
    380                                     foreach($products as $row) { $i++; ?>
    381                                     <tr>
    382                                         <td><input type="checkbox" class="checkbox" name="delcheck" id="delcheck" value="<?php echo $row->id; ?>" /></td>
    383                                         <td width="5%"><?php echo $i; ?></td>
    384                                         <td width="70%">
    385                                             <a href='<?php echo get_site_url()."/komper.php?kpids=".$row->id."&target=noheader"; ?>' data-toggle="modal" data-target="#sampleOutput">
    386                                                 <?php echo $row->product_name;?>
    387                                             </a>
    388                                         </td>
    389                                         <td width="20%">
    390                                             <a href="?page=<?php echo PAGE; ?>&act=insert&do=edit&pid=<?php echo $row->id; ?>" class="btn btn-link" id="editbtn"><i class="icon-edit"></i> Edit</a>
    391                                         </td>
    392                                     </tr>
    393                                     <?php }
    394                                     } else{ ?>
    395                                        <tr>
    396                                            <td colspan="4">No Products</td>
    397                                        </tr>
    398                                     <? }?>
    399                                   </tbody>
    400                                 </table>
    401                                 </div>
    402                                 <div class="pagination pagination-centered">
    403                                     <ul>
    404                                         <?php
    405                                         if($page == 1) { $state = "class=\"disabled\""; $prev = "#";}else {$state = ""; $prev = "?page=".PAGE."&act=insert&p=".($page - 1);}
    406                                         echo "<li ".$state."><a href='".$prev."'>Prev</a></li>";
    407                                         for($i=1; $i<=$pages; $i++){
    408                                             if($page == $i) $state = "class=\"active\""; else $state = "";
    409                                             echo '<li '.$state.'><a href="?page='.PAGE.'&act=insert&p='.$i.'">'.$i.'</a></li>';
    410                                         }
    411                                         if($page == ($i-1)) { $state = "class=\"disabled\""; $next = "#";}else {$state = ""; $next = "?page=".PAGE."&act=insert&p=".($page + 1);}
    412                                         echo "<li ".$state."><a href='".$next."'>Next</a></li>";
    413                                         ?>
    414                                     </ul>
    415                                 </div>
    416                                 <div align="right">
    417                                     <span class="label"><?php echo $tot_products;?> Products</span>
    418                                 </div>
    419                             </div>
    420 
    421                             <?php } ?>
    422                         </div><!-- /#post-body-content -->
    423 
    424                     </div><!-- /#post-body -->
    425                     <div id="nav-menu-footer">
    426                         <div class="major-publishing-actions">
    427                         <div class="publishing-action">
    428                             &nbsp;
    429                         </div>
    430                         </div>
    431                     </div><!-- /#nav-menu-footer -->
    432             </div><!-- /.menu-edit -->
    433             <div class="alert alert-info">
    434                 <h4>You are using Komper free version</h4>
    435                 With free version you can create up to 15 fields, and compare 2 products. <br />
    436                 Upgrade to Pro version to get unlimited fields, unlimited products to compare, insert comparation table to your posts or pages, and more.. <br />
    437                 Get it here: <a href="http://www.vnetware.com/" target="_blank">http://www.vnetware.com/</a>
    438             </div>
    439             <!-- MODAL SAMPLE OUTPUT -->
    440     <div class="modal hide" id="sampleOutput" tabindex="-1" role="dialog" aria-labelledby="outputLabel" aria-hidden="true">
    441       <div class="modal-header">
    442         <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    443         <h3 id="outputLabel">Sample Output</h3>
    444       </div>
    445       <div class="modal-body">
    446         <p>loading..</p>
    447       </div>
    448       <div class="modal-footer">
    449         <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
    450       </div>
    451     </div>
    452         <!-- END MODAL SAMPLE OUTPUT -->   
    453     </div>
    454 <?
     35    include_once("insert_data.php");
    45536}elseif($act == "output"){
    45637    include_once("output.php");
  • komper/trunk/output.php

    r637452 r637603  
    1919    $res = "";
    2020    $ids = array_unique(explode(",",trim($pids)));
    21     $ids = array($ids[0],$ids[1]);
    2221    $p_jml = count($ids);
     22    if($p_jml > 1){
     23        $ids = array($ids[0],$ids[1]);
     24    }
    2325    //reset $PIDS
    2426    $pids = implode(',', array_map('mysql_real_escape_string', $ids));
    25    
    2627    $i = 0;
    2728    while($i < $p_jml){
     
    3536    $fields = $wpdb->get_results("select * from ".KOMPER_TABLE_NAME." order by field_order asc");
    3637    $products = $wpdb->get_results("select * from ".KOMPER_TABLE_PRODUCT." where id in (".$pids.") order by FIND_IN_SET(id, '$pids') ");
    37 
     38   
    3839    $f_jml = count($fields);
    3940    $d_jml = count($data);
  • komper/trunk/readme.txt

    r637453 r637603  
    55Requires at least: 3.0.1
    66Tested up to: 3.5
    7 Stable tag: 1.1.3
     7Stable tag: 1.1.4
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3333
    3434
    35 Please note this is the free version.
     35Please note this is the free version.<br />
    3636In this free version, you can create up to 15 fields and display 2 products to compare.
    3737
     
    4848Try Demo:
    4949[http://demo.vnetware.com/komper](http://demo.vnetware.com/komper/)
     50
     51
     52*Note*<br />
     53You can try public release version here:
     54http://src.vnetware.com/komper/pub/
     55
     56This release include quick fixes, new features, and other workaround.
     57
    5058
    5159== Installation ==
     
    96104
    97105
     106If you still have any question or need assistance, please post on *Support* tab.
     107
     108
    98109== Screenshots ==
    99110
     
    108119
    109120== Changelog ==
     121
     122= 1.1.4 =
     123* FIX: Error on upload product images
     124* FIX: Failed on displaying product images
    110125
    111126= 1.1.3 =
Note: See TracChangeset for help on using the changeset viewer.