Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <modification>
- <id>Image Filename for oc 1.5.x</id>
- <version>1.0.3</version>
- <vqmver>1.2.3</vqmver>
- <author>Terrier (Credits to Doug Kulak aka d7a7z7e7d)</author>
- <file name="admin/view/template/catalog/product_form.tpl">
- <operation>
- <search position="before"><![CDATA[function image_upload(field, thumb) {]]></search>
- <add><![CDATA[
- $(document).ready(function() {
- $('#image').keyup(function() {
- $('#image_exists').html('');
- $.ajax({
- url: 'index.php?route=common/filemanager/exists&token=<?php echo $token; ?>',
- type: 'POST',
- data: 'source=' + encodeURIComponent($('#image').attr('value')),
- dataType: 'json',
- success: function(data) {
- if (data.exists == "1") {
- if ($('#image').attr('value')) {
- $.ajax({
- url: 'index.php?route=common/filemanager/image&token=<?php echo $token; ?>',
- type: 'POST',
- data: 'image=' + encodeURIComponent($('#image').attr('value')),
- dataType: 'text',
- success: function(data) {
- $('#thumb').replaceWith('<img src="' + data + '" alt="" id="thumb" class="image" onclick="image_upload(\'image\', \'thumb\');" />');
- }
- });
- }
- $('#image_exists').html('<span style="color: #A5BD71;">Found</span>');
- } else {
- $('#image_exists').html('<span style="color: #FF9999;">Not Found</span>');
- }
- }
- });
- });
- });]]></add>
- </operation>
- <operation>
- <search position="replace" offset="2"><![CDATA[<td><?php echo $entry_image; ?></td>]]></search>
- <add><![CDATA[
- <td><?php echo $entry_image; ?></td>
- <td><img src="<?php echo $thumb; ?>" alt="" id="thumb" class="image" onclick="image_upload('image', 'thumb');" /><br />
- <input size="60" type="text" name="image" value="<?php echo $image; ?>" id="image" /> <span id="image_exists"></span></td>
- ]]></add>
- </operation>
- <operation>
- <search position="replace" offset="4"><![CDATA[<tbody id="image-row<?php echo $image_row; ?>">]]></search>
- <add><![CDATA[
- <tbody id="image-row<?php echo $image_row; ?>">
- <tr>
- <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 />
- <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>
- <td class="left"><a onclick="$('#image-row<?php echo $image_row; ?>').remove();" class="button"><span><?php echo $button_remove; ?></span></a></td>
- ]]></add>
- </operation>
- <operation>
- <search position="replace" offset="4"><![CDATA[html = '<tbody id="image-row' + image_row + '">';]]></search>
- <add><![CDATA[
- html = '<tbody id="image-row' + image_row + '">';
- html += '<tr>';
- 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>';
- html += '<td class="left"><a onclick="$(\'#image-row' + image_row + '\').remove();" class="button"><span><?php echo $button_remove; ?></span></a></td>';
- html += '</tr>';
- ]]></add>
- </operation>
- </file>
- <file name="admin/view/template/catalog/category_form.tpl">
- <operation>
- <search position="before"><![CDATA[function image_upload(field, thumb) {]]></search>
- <add><![CDATA[
- $(document).ready(function() {
- $('#image').keyup(function() {
- $('#image_exists').html('');
- $.ajax({
- url: 'index.php?route=common/filemanager/exists&token=<?php echo $token; ?>',
- type: 'POST',
- data: 'source=' + encodeURIComponent($('#image').attr('value')),
- dataType: 'json',
- success: function(data) {
- if (data.exists == "1") {
- if ($('#image').attr('value')) {
- $.ajax({
- url: 'index.php?route=common/filemanager/image&token=<?php echo $token; ?>',
- type: 'POST',
- data: 'image=' + encodeURIComponent($('#image').attr('value')),
- dataType: 'text',
- success: function(data) {
- $('#thumb').replaceWith('<img src="' + data + '" alt="" id="thumb" class="image" onclick="image_upload(\'image\', \'thumb\');" />');
- }
- });
- }
- $('#image_exists').html('<span style="color: #A5BD71;">Found</span>');
- } else {
- $('#image_exists').html('<span style="color: #FF9999;">Not Found</span>');
- }
- }
- });
- });
- });]]></add>
- </operation>
- <operation>
- <search position="replace" offset="2"><![CDATA[<td><?php echo $entry_image; ?></td>]]></search>
- <add><![CDATA[
- <td><?php echo $entry_image; ?></td>
- <td><img src="<?php echo $thumb; ?>" alt="" id="thumb" class="image" onclick="image_upload('image', 'thumb');" /><br />
- <input size="60" type="text" name="image" value="<?php echo $image; ?>" id="image" /> <span id="image_exists"></span></td>
- ]]></add>
- </operation>
- </file>
- <file name="admin/view/template/catalog/manufacturer_form.tpl">
- <operation>
- <search position="before"><![CDATA[function image_upload(field, thumb) {]]></search>
- <add><![CDATA[
- $(document).ready(function() {
- $('#image').keyup(function() {
- $('#image_exists').html('');
- $.ajax({
- url: 'index.php?route=common/filemanager/exists&token=<?php echo $token; ?>',
- type: 'POST',
- data: 'source=' + encodeURIComponent($('#image').attr('value')),
- dataType: 'json',
- success: function(data) {
- if (data.exists == "1") {
- if ($('#image').attr('value')) {
- $.ajax({
- url: 'index.php?route=common/filemanager/image&token=<?php echo $token; ?>',
- type: 'POST',
- data: 'image=' + encodeURIComponent($('#image').attr('value')),
- dataType: 'text',
- success: function(data) {
- $('#thumb').replaceWith('<img src="' + data + '" alt="" id="thumb" class="image" onclick="image_upload(\'image\', \'thumb\');" />');
- }
- });
- }
- $('#image_exists').html('<span style="color: #A5BD71;">Found</span>');
- } else {
- $('#image_exists').html('<span style="color: #FF9999;">Not Found</span>');
- }
- }
- });
- });
- });]]></add>
- </operation>
- <operation>
- <search position="replace" offset="2"><![CDATA[<td><?php echo $entry_image; ?></td>]]></search>
- <add><![CDATA[
- <td><?php echo $entry_image; ?></td>
- <td><img src="<?php echo $thumb; ?>" alt="" id="thumb" class="image" onclick="image_upload('image', 'thumb');" /><br />
- <input size="60" type="text" name="image" value="<?php echo $image; ?>" id="image" /> <span id="image_exists"></span></td>
- ]]></add>
- </operation>
- </file>
- <file name="admin/controller/common/filemanager.php">
- <operation>
- <search position="before"><![CDATA[public function create() {]]></search>
- <add><![CDATA[
- public function exists() {
- $json = array();
- if (isset($this->request->post['source'])) {
- $source = rtrim(DIR_IMAGE . $this->request->post['source']);
- if (!is_dir($source) && file_exists($source)) {
- $json['exists'] = "1";
- } else {
- $json['exists'] = "0";
- }
- }
- $this->response->setOutput(json_encode($json));
- }]]></add>
- </operation>
- </file>
- </modification>
- <!--
- <modification> - This is the highest point of the file and there can only be one
- <id> - This is the name of the mod. Format: Free form text
- <version> - This is the version of the mod. Format: Number and Decimal (1.0.0)
- <author> - This is the author of the mod. Format: Free form text
- <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
- <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.
- <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.
- <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.
- -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement