Advertisement
Guest User

Image_Filenamev1.0.3 (modified)

a guest
Sep 17th, 2012
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 9.00 KB | None | 0 0
  1. <modification>
  2.     <id>Image Filename for oc 1.5.x</id>
  3.     <version>1.0.3</version>
  4.     <vqmver>1.2.3</vqmver>
  5.     <author>Terrier (Credits to Doug Kulak aka d7a7z7e7d)</author>
  6.     <file name="admin/view/template/catalog/product_form.tpl">
  7.         <operation>
  8.             <search position="before"><![CDATA[function image_upload(field, thumb) {]]></search>
  9.             <add><![CDATA[
  10.               $(document).ready(function() {
  11.                 $('#image').keyup(function() {
  12.                     $('#image_exists').html('');
  13.                     $.ajax({
  14.                         url: 'index.php?route=common/filemanager/exists&token=<?php echo $token; ?>',
  15.                         type: 'POST',
  16.                         data: 'source=' + encodeURIComponent($('#image').attr('value')),
  17.                         dataType: 'json',
  18.                         success: function(data) {
  19.                             if (data.exists == "1") {
  20.                                 if ($('#image').attr('value')) {
  21.                                     $.ajax({
  22.                                         url: 'index.php?route=common/filemanager/image&token=<?php echo $token; ?>',
  23.                                         type: 'POST',
  24.                                         data: 'image=' + encodeURIComponent($('#image').attr('value')),
  25.                                         dataType: 'text',
  26.                                         success: function(data) {
  27.                                             $('#thumb').replaceWith('<img src="' + data + '" alt="" id="thumb" class="image" onclick="image_upload(\'image\', \'thumb\');" />');
  28.                                         }
  29.                                     });
  30.                                 }
  31.                                 $('#image_exists').html('<span style="color: #A5BD71;">Found</span>');
  32.                             } else {
  33.                                 $('#image_exists').html('<span style="color: #FF9999;">Not Found</span>');
  34.                             }
  35.                         }
  36.                     });
  37.                 });
  38.             });]]></add>
  39.         </operation>
  40.         <operation>
  41.             <search position="replace" offset="2"><![CDATA[<td><?php echo $entry_image; ?></td>]]></search>
  42.             <add><![CDATA[
  43.             <td><?php echo $entry_image; ?></td>
  44.            <td><img src="<?php echo $thumb; ?>" alt="" id="thumb" class="image" onclick="image_upload('image', 'thumb');" /><br />
  45.            <input size="60" type="text" name="image" value="<?php echo $image; ?>" id="image" /> <span id="image_exists"></span></td>
  46.            ]]></add>
  47.         </operation>
  48.         <operation>
  49.             <search position="replace" offset="4"><![CDATA[<tbody id="image-row<?php echo $image_row; ?>">]]></search>
  50.             <add><![CDATA[
  51.             <tbody id="image-row<?php echo $image_row; ?>">
  52.            <tr>
  53.              <td class="left"><img src="<?php echo $product_image['thumb']; ?>" alt="" id="thumb<?php echo $image_row; ?>" class="image" onclick="image_upload('image<?php echo $image_row; ?>', 'thumb<?php echo $image_row; ?>');" /><br />
  54.             <input size="60" type="text" name="product_image[<?php echo $image_row; ?>]" value="<?php echo $product_image['image']; ?>" id="image<?php echo $image_row; ?>"  /> <span id="image_exists<?php echo $image_row; ?>"></span></td>
  55.              <td class="left"><a onclick="$('#image-row<?php echo $image_row; ?>').remove();" class="button"><span><?php echo $button_remove; ?></span></a></td>   
  56.            ]]></add>
  57.         </operation>
  58.         <operation>
  59.             <search position="replace" offset="4"><![CDATA[html  = '<tbody id="image-row' + image_row + '">';]]></search>
  60.             <add><![CDATA[
  61.             html  = '<tbody id="image-row' + image_row + '">';
  62.             html += '<tr>';
  63.             html += '<td class="left"><img src="<?php echo $no_image; ?>" alt="" id="thumb' + image_row + '" class="image" onclick="image_upload(\'image' + image_row + '\', \'thumb' + image_row + '\');" /><br /><input size="60" type="text" name="product_image[' + image_row + ']" value="" id="image' + image_row + '" /> <span id="image_exists' + image_row + '"></span></td>';
  64.             html += '<td class="left"><a onclick="$(\'#image-row' + image_row  + '\').remove();" class="button"><span><?php echo $button_remove; ?></span></a></td>';
  65.             html += '</tr>';
  66.            ]]></add>
  67.         </operation>
  68.     </file>
  69.     <file name="admin/view/template/catalog/category_form.tpl">
  70.         <operation>
  71.             <search position="before"><![CDATA[function image_upload(field, thumb) {]]></search>
  72.             <add><![CDATA[
  73.               $(document).ready(function() {
  74.                 $('#image').keyup(function() {
  75.                     $('#image_exists').html('');
  76.                     $.ajax({
  77.                         url: 'index.php?route=common/filemanager/exists&token=<?php echo $token; ?>',
  78.                         type: 'POST',
  79.                         data: 'source=' + encodeURIComponent($('#image').attr('value')),
  80.                         dataType: 'json',
  81.                         success: function(data) {
  82.                             if (data.exists == "1") {
  83.                                 if ($('#image').attr('value')) {
  84.                                     $.ajax({
  85.                                         url: 'index.php?route=common/filemanager/image&token=<?php echo $token; ?>',
  86.                                         type: 'POST',
  87.                                         data: 'image=' + encodeURIComponent($('#image').attr('value')),
  88.                                         dataType: 'text',
  89.                                         success: function(data) {
  90.                                             $('#thumb').replaceWith('<img src="' + data + '" alt="" id="thumb" class="image" onclick="image_upload(\'image\', \'thumb\');" />');
  91.                                         }
  92.                                     });
  93.                                 }
  94.                                 $('#image_exists').html('<span style="color: #A5BD71;">Found</span>');
  95.                             } else {
  96.                                 $('#image_exists').html('<span style="color: #FF9999;">Not Found</span>');
  97.                             }
  98.                         }
  99.                     });
  100.                 });
  101.             });]]></add>
  102.         </operation>
  103.         <operation>
  104.             <search position="replace" offset="2"><![CDATA[<td><?php echo $entry_image; ?></td>]]></search>
  105.             <add><![CDATA[
  106.             <td><?php echo $entry_image; ?></td>
  107.            <td><img src="<?php echo $thumb; ?>" alt="" id="thumb" class="image" onclick="image_upload('image', 'thumb');" /><br />
  108.            <input size="60" type="text" name="image" value="<?php echo $image; ?>" id="image" /> <span id="image_exists"></span></td>
  109.            ]]></add>
  110.         </operation>
  111.     </file>
  112.     <file name="admin/view/template/catalog/manufacturer_form.tpl">
  113.         <operation>
  114.             <search position="before"><![CDATA[function image_upload(field, thumb) {]]></search>
  115.             <add><![CDATA[
  116.               $(document).ready(function() {
  117.                 $('#image').keyup(function() {
  118.                     $('#image_exists').html('');
  119.                     $.ajax({
  120.                         url: 'index.php?route=common/filemanager/exists&token=<?php echo $token; ?>',
  121.                         type: 'POST',
  122.                         data: 'source=' + encodeURIComponent($('#image').attr('value')),
  123.                         dataType: 'json',
  124.                         success: function(data) {
  125.                             if (data.exists == "1") {
  126.                                 if ($('#image').attr('value')) {
  127.                                     $.ajax({
  128.                                         url: 'index.php?route=common/filemanager/image&token=<?php echo $token; ?>',
  129.                                         type: 'POST',
  130.                                         data: 'image=' + encodeURIComponent($('#image').attr('value')),
  131.                                         dataType: 'text',
  132.                                         success: function(data) {
  133.                                             $('#thumb').replaceWith('<img src="' + data + '" alt="" id="thumb" class="image" onclick="image_upload(\'image\', \'thumb\');" />');
  134.                                         }
  135.                                     });
  136.                                 }
  137.                                 $('#image_exists').html('<span style="color: #A5BD71;">Found</span>');
  138.                             } else {
  139.                                 $('#image_exists').html('<span style="color: #FF9999;">Not Found</span>');
  140.                             }
  141.                         }
  142.                     });
  143.                 });
  144.             });]]></add>
  145.         </operation>
  146.         <operation>
  147.             <search position="replace" offset="2"><![CDATA[<td><?php echo $entry_image; ?></td>]]></search>
  148.             <add><![CDATA[
  149.             <td><?php echo $entry_image; ?></td>
  150.            <td><img src="<?php echo $thumb; ?>" alt="" id="thumb" class="image" onclick="image_upload('image', 'thumb');" /><br />
  151.            <input size="60" type="text" name="image" value="<?php echo $image; ?>" id="image" /> <span id="image_exists"></span></td>
  152.            ]]></add>
  153.         </operation>
  154.     </file>
  155.     <file name="admin/controller/common/filemanager.php">
  156.         <operation>
  157.             <search position="before"><![CDATA[public function create() {]]></search>
  158.             <add><![CDATA[
  159.             public function exists() { 
  160.                 $json = array();
  161.                
  162.                 if (isset($this->request->post['source'])) {
  163.                     $source = rtrim(DIR_IMAGE . $this->request->post['source']);
  164.                     if (!is_dir($source) && file_exists($source)) {
  165.                         $json['exists'] = "1";
  166.                     } else {
  167.                         $json['exists'] = "0";
  168.                     }
  169.                 }
  170.                
  171.                 $this->response->setOutput(json_encode($json));                
  172.                    
  173.             }]]></add>
  174.         </operation>
  175.     </file>
  176. </modification>
  177.  
  178. <!--
  179. <modification>  - This is the highest point of the file and there can only be one
  180. <id>            - This is the name of the mod. Format: Free form text
  181. <version>       - This is the version of the mod. Format: Number and Decimal (1.0.0)
  182. <author>        - This is the author of the mod. Format: Free form text
  183. <file>          - This is the name of the file to modify. Requires attribute "name" as relative filename (catalog/controller/product/product.php). There can be multiple
  184. <operation>     - This is the wrapper of the actual operation occuring. There can be multiple operations to the same file. Uses an optional "error" attribute set to skip|abort (abort is default). skip means all other operations will be applied even if one cannot. abort means to revert to the original source.
  185. <search>        - This is the first required step of the operation. Uses an optional attribute "position" set to before|after|replace. replace is default. One per operation. Use CDATA tags to wrap code.
  186. <add>           - This is the second required step of the operation. Uses an optional attribute "trim" set to true|false. false is default. One per operation. Location of added data depends on the position of the <search> command. Use CDATA tags to wrap code.
  187. -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement