Author Topic: Manufacturer Logo - Finally Finished  (Read 100051 times)

DeeCee

  • Jr. Member
  • **
  • Posts: 177
Manufacturer Logo - Finally Finished
« on: September 16, 2008, 15:42:04 pm »
For brand awareness, I have been working on the upload and display of a manufacturer logo.

I actually just noticed that in the dev.wiki, this is being worked on, but I can't wait for VM 1.1.3 to be released, so I thought I'd work on it myself.

I have added a tab to the Manufacturer form under VM admin and have the images (thumb and full) uploading and storing to the directory successfully.

My current situation is that I can't seem to get the manufacturer image to the flypage.

I have tried various methods of altering clsses/ps_product.php, html/product.product_display.php etc etc but still can't seem to get this to work.

Following the example of category image thumbnails and the developer wiki ( https://dev.virtuemart.net/cb/wiki/1367 ), I have tried to hack/copy the following examples to produce the same results but in the flypage:

classes/ps_product_category.php -> function get_child_list
classes/ps_product.php -> function get_mf_name

Do I have to put the images in an array as a variable and then import the variable as a template? I just don't know!

I've tried following the above functions as examples, but keep getting 500 errors (man i should have paid more attention in database classes...) and I ned some serious guidence to understand how to get stored manufacturer images to the product flypage.

Can anyone help out so that everyone can benefit?

Thanks
Dave
                  
PS - had to seperate the php code out to other posts. I somehow went over the 20000 character limit ;)


Here is the SQL, manufacturer form code, ps_manufacturer code

SQL:
Code: [Select]
ALTER TABLE `jos_vm_manufacturer` ADD `mf_thumb_image` VARCHAR( 255 ) NULL DEFAULT NULL AFTER `mf_desc` ,
ADD `mf_full_image` VARCHAR( 255 ) NULL DEFAULT NULL AFTER `mf_thumb_image` ;
I take no responsibility for any lost work. It is your responsibility to back up files before attempting anything I suggest as I may be:
a) intoxicated
b) high on sugar
c) can't concentrate due to lack of sleep

If you like my hacks, feel free to buy me a coffee, muffin or both :)

paypal: deecee23 at gmail dot com

Hacks in progress: Manufacturer Logo Hack - 100% done

DeeCee

  • Jr. Member
  • **
  • Posts: 177
Re: Manufacturer Logo - need help with arrays / $tpl
« Reply #1 on: September 16, 2008, 15:42:54 pm »
administrator/components/com_virtuemart/html/manufacturer.manufacturer_form.php

Code: [Select]
<?php 
if( !defined'_VALID_MOS' ) && !defined'_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' ); 
/**
*
* @version $Id: manufacturer.manufacturer_form.php 1095 2007-12-19 20:19:16Z soeren_nb $
* @package VirtueMart
* @subpackage html
* @copyright Copyright (C) 2004-2007 soeren - All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/
mm_showMyFileName__FILE__ );

global 
$ps_manufacturer_category$manufacturer;

$manufacturer_id vmGet$_REQUEST'manufacturer_id');
$option = empty($option)?vmGet$_REQUEST'option''com_virtuemart'):$option;

if (!empty(
$manufacturer_id)) {
  
$q "SELECT * FROM #__{vm}_manufacturer WHERE manufacturer_id='$manufacturer_id'"
  
$db->query($q);  
  
$db->next_record();
}
//First create the object and let it print a form heading
$formObj = &new formFactory$VM_LANG->_('PHPSHOP_MANUFACTURER_FORM_LBL') );
//Then Start the form
$formObj->startForm('adminForm''enctype="multipart/form-data"');

$tabs = new vmTabPanel(01"manufacturerform");
$tabs->startPane("content-pane");
$tabs->startTab"<img src='"IMAGEURL ."ps_image/edit.png' align='absmiddle' width='16' height='16' border='0' /> ".$VM_LANG->_('PHPSHOP_MANUFACTURER_FORM_LBL'), "info-page");
?>

  <table class="adminform">
    <tr>
      <td align="right"><?php echo $VM_LANG->_('PHPSHOP_MANUFACTURER_LIST_MANUFACTURER_NAME'?></td>
      <td>
        <input type="text" class="inputbox" name="mf_name" value="<?php $db->sp("mf_name"?>" size="16" />
      </td>
    </tr>
    <tr>
      <td width="22%" align="right" ><?php echo $VM_LANG->_('PHPSHOP_PRODUCT_FORM_URL'?>:</td>
      <td width="78%" >
        <input type="text" class="inputbox" name="mf_url" value="<?php $db->sp("mf_url"?>" size="32" />
      </td>
    </tr>
    <tr>
      <td align="right"><?php echo $VM_LANG->_('PHPSHOP_MANUFACTURER_FORM_CATEGORY'?>:</td>
      <td ><?php $ps_manufacturer_category->list_category($db->f("mf_category_id"));     ?></td>
    </tr>
    <tr>
      <td align="right">&nbsp;</td>
      <td >&nbsp;</td>
    </tr>
    <tr>
      <td align="right" ><?php echo $VM_LANG->_('PHPSHOP_MANUFACTURER_FORM_EMAIL'?>:</td>
      <td>
        <input type="text" class="inputbox" name="mf_email" value="<?php $db->sp("mf_email"?>" size="18" />
      </td>
    </tr>
    <tr>
      <td align="right" >&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td width="22%" align="right"  valign="top"><?php echo $VM_LANG->_('PHPSHOP_MANUFACTURER_FORM_DESCRIPTION'?>:</td>
      <td width="78%" ><?php
editorArea'editor1'$db->f("mf_desc"), 'mf_desc''300''150''70''25' )
?>

      </td>
    <tr align="center">
      <td colspan="2" >&nbsp;</td>
    </tr>
</table>
<?php
$tabs
->endTab();
$tabs->startTab"<img src='"IMAGEURL ."ps_image/image.png' width='16' height='16' align='absmiddle' border='0' /> ".$VM_LANG->_('E_IMAGES'), "images-page");

if( !
stristr$db->f("mf_thumb_image"), "http") )
  echo 
"<input type=\"hidden\" name=\"mf_thumb_image_curr\" value=\""$db->f("mf_thumb_image") ."\" />";

if( !
stristr$db->f("mf_full_image"), "http") )
  echo 
"<input type=\"hidden\" name=\"mf_full_image_curr\" value=\""$db->f("mf_full_image") ."\" />";
 
  
$ps_html->writableIndicator( array( IMAGEPATH."manufacturer") );
?>

  <table class="adminform" >
    <tr>
      <td valign="top" width="50%" style="border-right: 1px solid black;">
        <h2><?php echo $VM_LANG->_('PHPSHOP_PRODUCT_FORM_FULL_IMAGE'?></h2>
        <table class="adminform">
          <tr class="row0">
            <td colspan="2" ><?php 
            
if ($manufacturer_id) {
                echo 
$VM_LANG->_('PHPSHOP_PRODUCT_FORM_IMAGE_UPDATE_LBL') . "<br />"; } ?>

              <input type="file" class="inputbox" name="mf_full_image" size="50" maxlength="255" />
              </td>
          </tr>
          <tr class="row1">
            <td colspan="2" ><div style="font-weight:bold;"><?php echo $VM_LANG->_('PHPSHOP_IMAGE_ACTION'?>:</div><br/>
              <input type="radio" class="inputbox" name="mf_full_image_action" id="mf_full_image_action0" checked="checked" value="none" onchange="toggleDisable( document.adminForm.image_action[1], document.adminForm.mf_full_image, true );toggleDisable( document.adminForm.image_action[1], document.adminForm.mf_full_image_url, true );"/>
              <label for="mf_full_image_action0"><?php echo $VM_LANG->_('PHPSHOP_NONE'); ?></label><br/>
              <?php
              
// Check if GD library is available - creates image
              
if( function_exists('imagecreatefromjpeg')) { ?>

              <input type="radio" class="inputbox" name="mf_full_image_action" id="mf_full_image_action1" value="auto_resize" onchange="toggleDisable( document.adminForm.mf_full_image_action[1], document.adminForm.mf_thumb_image, true );toggleDisable( document.adminForm.mf_full_image_action[1], document.adminForm.mf_thumb_image_url, true );"/>
              <label for="mf_full_image_action1"><?php echo $VM_LANG->_('PHPSHOP_FILES_FORM_AUTO_THUMBNAIL') . "</label><br />"
              }
              if (
$manufacturer_id and $db->f("mf_full_image")) { ?>

                <input type="radio" class="inputbox" name="mf_full_image_action" id="mf_full_image_action2" value="delete" onchange="toggleDisable( document.adminForm.mf_full_image_action[1], document.adminForm.mf_thumb_image, true );toggleDisable( document.adminForm.mf_full_image_action[1], document.adminForm.mf_thumb_image_url, true );"/>
                <label for="mf_full_image_action2"><?php echo $VM_LANG->_('PHPSHOP_PRODUCT_FORM_IMAGE_DELETE_LBL') . "</label><br />"
              } 
?>

            </td>
          </tr>
          <tr class="row0"><td colspan="2">&nbsp;</td></tr>
          <tr class="row0">
            <td width="21%" ><?php echo $VM_LANG->_('URL')." (".$VM_LANG->_('CMN_OPTIONAL')."!)&nbsp;"?></td>
            <td width="79%" >
              <?php 
              
if( stristr($db->f("mf_full_image"), "http") )
              
$mf_full_image_url $db->f("mf_full_image");
              else if(!empty(
$_REQUEST['mf_full_image_url']))
              
$mf_full_image_url vmGet($_REQUEST'mf_full_image_url');
              else
              
$mf_full_image_url "";
              
?>

              <input type="text" class="inputbox" size="50" name="mf_full_image_url" value="<?php echo $mf_full_image_url ?>" onchange="if( this.value.length>0) document.adminForm.mf_full_image_action[1].checked=false; else document.adminForm.mf_full_image_action[1].checked=true; toggleDisable( document.adminForm.product_full_image_action[1], document.adminForm.mf_thumb_image_url, true );toggleDisable( document.adminForm.mf_full_image_action[1], document.adminForm.mf_thumb_image, true );" />
            </td>
          </tr>
          <tr class="row1"><td colspan="2">&nbsp;</td></tr>
          <tr class="row1">
            <td colspan="2" >
              <div style="overflow:auto;">
                <?php 
                 echo 
$ps_product->image_tag($db->f("mf_full_image"), ""0"manufacturer");
                
?>

              </div>
            </td>
          </tr>
        </table>
      </td>

      <td valign="top" width="50%">
        <h2><?php echo $VM_LANG->_('PHPSHOP_PRODUCT_FORM_THUMB_IMAGE'?></h2>
        <table class="adminform">
          <tr class="row0">
            <td colspan="2" ><?php if ($manufacturer_id) {
                echo 
$VM_LANG->_('PHPSHOP_PRODUCT_FORM_IMAGE_UPDATE_LBL') . "<br />"; } ?>

              <input type="file" class="inputbox" name="mf_thumb_image" size="50" maxlength="255" onchange="if(document.adminForm.mf_thumb_image.value!='') document.adminForm.mf_thumb_image_url.value='';" />
            </td>
          </tr>
          <tr class="row1">
            <td colspan="2" ><div style="font-weight:bold;"><?php echo $VM_LANG->_('PHPSHOP_IMAGE_ACTION'?>:</div><br/>
              <input type="radio" class="inputbox" id="mf_thumb_image_action0" name="mf_thumb_image_action" checked="checked" value="none" onchange="toggleDisable( document.adminForm.image_action[1], document.adminForm.mf_thumb_image, true );toggleDisable( document.adminForm.image_action[1], document.adminForm.mf_thumb_image_url, true );"/>
              <label for="mf_thumb_image_action0"><?php echo $VM_LANG->_('PHPSHOP_NONE'?></label><br/>
              <?php 
              
if ($manufacturer_id and $db->f("mf_thumb_image")) { ?>

                <input type="radio" class="inputbox" id="mf_thumb_image_action1" name="mf_thumb_image_action" value="delete" onchange="toggleDisable( document.adminForm.image_action[1], document.adminForm.mf_thumb_image, true );toggleDisable( document.adminForm.image_action[1], document.adminForm.mf_thumb_image_url, true );"/>
                <label for="mf_thumb_image_action1"><?php echo $VM_LANG->_('PHPSHOP_PRODUCT_FORM_IMAGE_DELETE_LBL') . "</label><br />"
              } 
?>

            </td>
          </tr>
          <tr class="row0"><td colspan="2">&nbsp;</td></tr>
          <tr class="row0">
            <td width="21%" ><?php echo $VM_LANG->_('URL')." (".$VM_LANG->_('CMN_OPTIONAL').")&nbsp;"?></td>
            <td width="79%" >
              <?php 
              
if( stristr($db->f("mf_thumb_image"), "http") )
              
$mf_thumb_image_url $db->f("mf_thumb_image");
              else if(!empty(
$_REQUEST['mf_thumb_image_url']))
              
$mf_thumb_image_url vmGet($_REQUEST'mf_thumb_image_url');
              else
              
$mf_thumb_image_url "";
              
?>

              <input type="text" class="inputbox" size="50" name="mf_thumb_image_url" value="<?php echo $mf_thumb_image_url ?>" />
            </td>
          </tr>
          <tr class="row1"><td colspan="2">&nbsp;</td></tr>
          <tr class="row1">
            <td colspan="2" >
              <div style="overflow:auto;">
                <?php 
                 echo 
$ps_product->image_tag($db->f("mf_thumb_image"), ""0"manufacturer");
                
?>

              </div>
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
<?php
$tabs
->endPane();

// Add necessary hidden fields
$formObj->hiddenField'manufacturer_id'$manufacturer_id );
  
$funcname = !empty($manufacturer_id) ? "manufacturerupdate" "manufactureradd";
// Write your form with mixed tags and text fields
// and finally close the form:
$formObj->finishForm$funcname$modulename.'.manufacturer_list'$option );
?>

<script type="text/javascript">//<!--
function toggleDisable( elementOnChecked, elementDisable, disableOnChecked ) {
  if( !disableOnChecked ) {
    if(elementOnChecked.checked==true) {
      elementDisable.disabled=false;
    }
    else {
      elementDisable.disabled=true;
    }
  }
  else {
    if(elementOnChecked.checked==true) {
      elementDisable.disabled=true;
    }
    else {
      elementDisable.disabled=false;
    }
  }
}

toggleDisable( document.adminForm.mf_full_image_action[1], document.adminForm.mf_thumb_image, true );
//-->
</script>

I take no responsibility for any lost work. It is your responsibility to back up files before attempting anything I suggest as I may be:
a) intoxicated
b) high on sugar
c) can't concentrate due to lack of sleep

If you like my hacks, feel free to buy me a coffee, muffin or both :)

paypal: deecee23 at gmail dot com

Hacks in progress: Manufacturer Logo Hack - 100% done

DeeCee

  • Jr. Member
  • **
  • Posts: 177
Re: Manufacturer Logo - need help with arrays / $tpl
« Reply #2 on: September 16, 2008, 15:43:03 pm »
administrator/components/com_virtuemart/classes/ps_manufacturer.php

Code: [Select]
<?php
if( !defined'_VALID_MOS' ) && !defined'_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
/**
*
* @version $Id: ps_manufacturer.php 1406 2008-05-26 06:58:04Z joomlacorner $
* @package VirtueMart
* @subpackage classes
* @copyright Copyright (C) 2004-2008 soeren - All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/

/**
 * The class is is used to manage the manufacturers in your store.
 *
 */
class ps_manufacturer extends vmAbstractObject {

/**
 * Validates the Input Parameters and uploaded image files 
 * onBeforeManufacturerAdd
 *
 * @param array $d
 * @return boolean
 */
function validate_add(&$d) {
global $vmLogger$VM_LANG;
require_once(CLASSPATH 'imageTools.class.php' );
$valid true;
$db = new ps_DB;

if (empty($d["mf_name"])) {
$GLOBALS['vmLogger']->err$VM_LANG->_('VM_MANUF_ERR_NAME') );
return false;
}
else {
$q "SELECT count(*) as rowcnt from #__{vm}_manufacturer where";
$q .= " mf_name='" .  $db->getEscaped($d["mf_name"]) . "'";
$db->query($q);
$db->next_record();
if ($db->f("rowcnt") > 0) {
$GLOBALS['vmLogger']->err$VM_LANG->_('VM_MANUF_ERR_EXISTS') );
return false;
}
}
/** Image Upload Validation **/

// do we have an image URL or an image File Upload?
if (!empty( $d['mf_thumb_image_url'] )) {
// Image URL
if (substr$d['mf_thumb_image_url'], 04) != "http") {
$vmLogger->err$VM_LANG->_('VM_PRODUCT_IMAGEURL_MUSTBEGIN') );
$valid =  false;
}

$d["mf_thumb_image"] = $d['mf_thumb_image_url'];
}
else {
// File Upload
if (!vmImageTools::validate_image($d,"mf_thumb_image","manufacturer")) {
$valid false;
}
}

if (!empty( $d['mf_full_image_url'] )) {
// Image URL
if (substr$d['mf_full_image_url'], 04) != "http") {
$vmLogger->err$VM_LANG->_('VM_PRODUCT_IMAGEURL_MUSTBEGIN') );
return false;
}
$d["mf_full_image"] = $d['mf_full_image_url'];
}
else {
// File Upload
if (!vmImageTools::validate_image($d,"mf_full_image","manufacturer")) {
$valid false;
}
}
return true;
}
/**
 * Validates the Input Parameters onBeforeManufacturerUpdate
 *
 * @param array $d
 * @return boolean
 */
function validate_update(&$d) {
global $vmLogger$VM_LANG;
$valid true;
require_once(CLASSPATH 'imageTools.class.php' );
if (empty($d["mf_name"])) {
$GLOBALS['vmLogger']->err$VM_LANG->_('VM_MANUF_ERR_NAME') );
return False;
}

/** Image Upload Validation **/

// do we have an image URL or an image File Upload?
if (!empty( $d['mf_thumb_image_url'] )) {
// Image URL
if (substr$d['mf_thumb_image_url'], 04) != "http") {
$vmLogger->err$VM_LANG->_('VM_PRODUCT_IMAGEURL_MUSTBEGIN') );
$valid =  false;
}

// if we have an uploaded image file, prepare this one for deleting.
if( $db->f("mf_thumb_image") && substr$db->f("mf_thumb_image"), 04) != "http") {
$_REQUEST["mf_thumb_image_curr"] = $db->f("product_thumb_image");
$d["mf_thumb_image_action"] = "delete";
if (!vmImageTools::validate_image$d"product_thumb_image""manufacturer")) {
return false;
}
}
$d["mf_thumb_image"] = $d['mf_thumb_image_url'];
}
else {
// File Upload
if (!vmImageTools::validate_image$d"mf_thumb_image""manufacturer")) {
$valid false;
}
}

if (!empty( $d['mf_full_image_url'] )) {
// Image URL
if (substr$d['mf_full_image_url'], 04) != "http") {
$vmLogger->err$VM_LANG->_('VM_PRODUCT_IMAGEURL_MUSTBEGIN') );
return false;
}
// if we have an uploaded image file, prepare this one for deleting.
if( $db->f("mf_full_image") && substr$db->f("mf_thumb_image"), 04) != "http") {
$_REQUEST["mf_full_image_curr"] = $db->f("mf_full_image");
$d["mf_full_image_action"] = "delete";
if (!vmImageTools::validate_image$d"mf_full_image""manufacturer")) {
return false;
}
}
$d["mf_full_image"] = $d['mf_full_image_url'];
}
else {
// File Upload
if (!vmImageTools::validate_image$d"mf_full_image""manufacturer")) {
$valid false;
}
}

return true;
}
/**
 * Validates the Input Parameters onBeforeManufacturerDelete
 *
 * @param array $d
 * @return boolean
 */
function validate_delete($mf_id, &$d) {
global $vmLogger$VM_LANG;
$db = new ps_DB;
require_once(CLASSPATH 'imageTools.class.php' );

if (empty( $mf_id )) {
$GLOBALS['vmLogger']->err$VM_LANG->_('VM_MANUF_ERR_DELETE_SELECT') );
return False;
}
$db->query"SELECT `#__{vm}_product`.product_id, manufacturer_id   FROM `#__{vm}_product`, `#__{vm}_product_mf_xref` WHERE manufacturer_id =".intval($mf_id)." AND `#__{vm}_product`.product_id = `#__{vm}_product_mf_xref`.product_id" );
if( $db->num_rows() > ) {
$GLOBALS['vmLogger']->err$VM_LANG->_('VM_MANUF_ERR_DELETE_STILLPRODUCTS') );
return false;
}

/* Prepare mf_thumb_image for Deleting */
if( !stristr$db->f("mf_thumb_image"), "http") ) {
$_REQUEST["mf_thumb_image_curr"] = $db->f("mf_thumb_image");
$d["mf_thumb_image_action"] = "delete";
if (!vmImageTools::validate_image($d,"mf_thumb_image","manufacturer")) {
$vmLogger->err$VM_LANG->_('VM_MANUF_ERR_DELETE_IMAGES') );
return false;
}
}
/* Prepare mf_full_image for Deleting */
if( !stristr$db->f("mf_full_image"), "http") ) {
$_REQUEST["mf_full_image_curr"] = $db->f("mf_full_image");
$d["mf_full_image_action"] = "delete";
if (!vmImageTools::validate_image($d,"mf_full_image","manufacturer")) {
return false;
}
}
return True;

}

/**
 * creates a new manufacturer record
 *
 * @param array $d
 * @return boolean
 */
function add(&$d) {
global $vmLogger$VM_LANG;

$db = new ps_DB;

if (!$this->validate_add($d)) {
return false;
}
if (!vmImageTools::process_images($d)) {
return false;
}
$fields = array( 'mf_name' => vmGet$d'mf_name' ),
'mf_email' => vmGet$d'mf_email' ),
'mf_desc' => vmGet$d'mf_desc'''VMREQUEST_ALLOWHTML ),
'mf_category_id' => vmRequest::getInt('mf_category_id'),
'mf_url' => vmGet$d'mf_url'),
'mf_thumb_image' => vmGet$d'mf_thumb_image'),
'mf_full_image' => vmGet$d'mf_full_image')
);
$db->buildQuery('INSERT''#__{vm}_manufacturer'$fields );
if( $db->query() !== false ) {
$GLOBALS['vmLogger']->info$VM_LANG->_('VM_MANUF_ADDED') );
$_REQUEST['manufacturer_id'] = $db->last_insert_id();
return true;
}
return false;

}

/**
 * updates manufacturer information
 *
 * @param array $d
 * @return boolean
 */
function update(&$d) {
global $VM_LANG;

$db = new ps_DB;

if (!$this->validate_update($d)) {
return False;
}

if (!vmImageTools::process_images($d)) {
return false;
}

$fields = array( 'mf_name' => vmGet$d'mf_name' ),
'mf_email' => vmGet$d'mf_email' ),
'mf_desc' => vmGet$d'mf_desc'''VMREQUEST_ALLOWHTML ),
'mf_category_id' => vmRequest::getInt('mf_category_id'),
'mf_url' => vmGet$d'mf_url'),
'mf_thumb_image' => vmGet$d'mf_thumb_image'),
'mf_full_image' => vmGet$d'mf_full_image')
);
$db->buildQuery('UPDATE''#__{vm}_manufacturer'$fields'WHERE manufacturer_id='.(int)$d["manufacturer_id"] );
if( $db->query() ) {
$GLOBALS['vmLogger']->info$VM_LANG->_('VM_MANUF_UPDATED') );
return true;
}
return false;
}

/**
* Controller for Deleting Records.
*/
function delete(&$d) {
global $vmLogger$VM_LANG;

$record_id $d["manufacturer_id"];

if (!$this->validate_delete($record_id$d)) {
return False;
}

if( is_array$record_id)) {
foreach( $record_id as $record) {
if( !$this->delete_record$record$d ))
return false;
}
return true;
}
else {
return $this->delete_record$record_id$d );
}

/* Delete Image files */
if (!vmImageTools::process_images($d)) {
return false;
}
$vmLogger->info$VM_LANG->_('VM_MANUF_DELETED').": $record_id." );
return True;
}
/**
* Deletes one Record.
*/
function delete_record$record_id, &$d ) {
global $vmLogger$VM_LANG;
$db = new ps_DB;
if (!$this->validate_delete($record_id$d)) {
return False;
}
$q 'DELETE from #__{vm}_product_mf_xref WHERE manufacturer_id='.(int)$record_id.' LIMIT 1';
$db->query($q);
$q 'DELETE from #__{vm}_manufacturer WHERE manufacturer_id='.(int)$record_id.' LIMIT 1';
$db->query($q);
return True;

/* Delete Image files */
if (!vmImageTools::process_images($d)) {
return false;
}
$vmLogger->info$VM_LANG->_('VM_MANUF_DELETED').": $record_id." );
return True;
}
/**
 * Prints a drop-down list of manufacturer names and their ids.
 *
 * @param int $manufacturer_id
 */
function list_manufacturer($manufacturer_id='0') {

$db = new ps_DB;

$q "SELECT manufacturer_id as id,mf_name as name FROM #__{vm}_manufacturer ORDER BY mf_name";
$db->query($q);
$db->next_record();

// If only one vendor do not show list
if ($db->num_rows() == 1) {

echo '<input type="hidden" name="manufacturer_id" value="'$db->f("id").'" />';
echo $db->f("name");
}
elseif( $db->num_rows() > 1) {
$db->reset();
$array = array();
while ($db->next_record()) {
$array[$db->f("id")] = $db->f("name");
}
$code ps_html::selectList('manufacturer_id'$manufacturer_id$array ). "<br />\n";
echo $code;
}
else  {
echo '<input type="hidden" name="manufacturer_id" value="1" />Please create at least one Manufacturer!!';
}
}
}

?>

I take no responsibility for any lost work. It is your responsibility to back up files before attempting anything I suggest as I may be:
a) intoxicated
b) high on sugar
c) can't concentrate due to lack of sleep

If you like my hacks, feel free to buy me a coffee, muffin or both :)

paypal: deecee23 at gmail dot com

Hacks in progress: Manufacturer Logo Hack - 100% done

DeeCee

  • Jr. Member
  • **
  • Posts: 177
Re: Manufacturer Logo - need help with arrays / $tpl
« Reply #3 on: October 01, 2008, 03:41:20 am »
Does anyone have any input on this?
I take no responsibility for any lost work. It is your responsibility to back up files before attempting anything I suggest as I may be:
a) intoxicated
b) high on sugar
c) can't concentrate due to lack of sleep

If you like my hacks, feel free to buy me a coffee, muffin or both :)

paypal: deecee23 at gmail dot com

Hacks in progress: Manufacturer Logo Hack - 100% done

BernardE

  • Jr. Member
  • **
  • Posts: 52
    • Wooza Shop - Online mall and shops
Re: Manufacturer Logo - need help with arrays / $tpl
« Reply #4 on: October 11, 2008, 14:27:46 pm »
Hi DeeCee

Thanks a lot for this nice mode. I'm having a little trouble getting it running. I have set it up as you showed. However, I get the following error message:

Call to a member function image_tag() on a non-object in...html\manufacturer.manufacturer_form.php on line 144

I check the file, and it seems the $ps_product functions are not be instantiated. I do not understand this, as the works in the product.product_form.php file.

Any ideas?

DeeCee

  • Jr. Member
  • **
  • Posts: 177
Re: Manufacturer Logo - need help with arrays / $tpl
« Reply #5 on: October 16, 2008, 14:17:44 pm »
Hey Bernard,

I haven't looked at this for about a month due to other commitments, so I'll have a look over the next couple of days.

I also have thought about a way to display the images on the product flypage, but yet to test out.

Actually, I just had a look at manufacturer.manufacturer_form on my script and its just a </tr> tag.

If you mean line 140 then, yes, $ps_product is suppose to be there as it calls the the function image tag in class\ps_product - line 1374

Also, I just tested the manufacturer image upload again and it works fine on my computer.
I take no responsibility for any lost work. It is your responsibility to back up files before attempting anything I suggest as I may be:
a) intoxicated
b) high on sugar
c) can't concentrate due to lack of sleep

If you like my hacks, feel free to buy me a coffee, muffin or both :)

paypal: deecee23 at gmail dot com

Hacks in progress: Manufacturer Logo Hack - 100% done

DeeCee

  • Jr. Member
  • **
  • Posts: 177
Re: Manufacturer Logo - Finally Finished
« Reply #6 on: January 28, 2009, 15:12:45 pm »
Okay folks, after many months of not looking at my site and operating without it, I gave myself a deadline (1st of Feb) and have finally figured out how to upload and display manufacturer logos :)

I'll update you all tomorrow as I really need some sleep, but I've tested it out on my current VM installation and will try it on a clean unmodified version tomorrow as well to work some kinks.

Hopefully we'll see this added to VM as it is a sorely missed feature :)

Cheers
Dave
I take no responsibility for any lost work. It is your responsibility to back up files before attempting anything I suggest as I may be:
a) intoxicated
b) high on sugar
c) can't concentrate due to lack of sleep

If you like my hacks, feel free to buy me a coffee, muffin or both :)

paypal: deecee23 at gmail dot com

Hacks in progress: Manufacturer Logo Hack - 100% done

aravot

  • Peter
  • Quality&Testing Team
  • Sr. Member
  • *
  • Posts: 2874
    • VirtueMart Extensions
Re: Manufacturer Logo - Finally Finished
« Reply #7 on: January 29, 2009, 08:19:55 am »
VirtueMart 1.2 has manufacturer logo, please have a look at the code and see if you can make any improvements.

DeeCee

  • Jr. Member
  • **
  • Posts: 177
Re: Manufacturer Logo - Finally Finished
« Reply #8 on: January 29, 2009, 08:21:51 am »
Yep - thats what I plan to do :)
I take no responsibility for any lost work. It is your responsibility to back up files before attempting anything I suggest as I may be:
a) intoxicated
b) high on sugar
c) can't concentrate due to lack of sleep

If you like my hacks, feel free to buy me a coffee, muffin or both :)

paypal: deecee23 at gmail dot com

Hacks in progress: Manufacturer Logo Hack - 100% done

DeeCee

  • Jr. Member
  • **
  • Posts: 177
Re: Manufacturer Logo - Finally Finished
« Reply #9 on: January 29, 2009, 11:21:34 am »
VirtueMart 1.2 has manufacturer logo, please have a look at the code and see if you can make any improvements.
Aravot, I will provide improvements over the next couple of days, on here publicly and to you personally with tagged code and code breakdown document.

GregDev has done pretty much exactly the same as I have done above (great work btw Greg :) ), but not to the next step of displaying the images on the product pages nor within the manufacturer pop up.

Not really useful if you can't use it ;)

I'll update tomorrow hopefully :)
I take no responsibility for any lost work. It is your responsibility to back up files before attempting anything I suggest as I may be:
a) intoxicated
b) high on sugar
c) can't concentrate due to lack of sleep

If you like my hacks, feel free to buy me a coffee, muffin or both :)

paypal: deecee23 at gmail dot com

Hacks in progress: Manufacturer Logo Hack - 100% done

DeeCee

  • Jr. Member
  • **
  • Posts: 177
Re: Manufacturer Logo - Finally Finished
« Reply #10 on: February 03, 2009, 09:25:30 am »
Okay folks here it is:

You need to update the following to get the manufacturers logo working in VM :)

Works with VM 1.1.3 J1.5.9

Code has integrated GregDevs work which will be present in Virtuemart 1.2 :)

Of note, GregDev's work does not include the extra information/coding to show the images on the product flypage nor in the manufacturers pop up. My work provides global variables to call in the flypage allowing the manufacturer logo to be displayed and allow the manu thumb image to be shown in the pop up.

The differences between Greg's work and mine where minor. The only changes were to some code within the manufacturer form and proper coding of the class functions (mainly logger).

I also made the tab look like the product image upload tab. Just a style thing for consistancy.

PLEASE BACK UP ALL WORK BEFORE APPLYING THIS MODIFICATION

Enjoy :)

Cheers
Dave

--------

What this does:
Allows a manufacturer image to be shown in the manufacturer pop up and on the product flypage.

Things to do:

1. Add entries into the database for mf_thumb_image, mf_full_image
2. Add new folder called manufacturer under:
administrator/components/com_virtuemart/shop_image/
3. Turn on "Show Manufacturer Link" under Configuration -> Site -> Layout/Theme Configuration

(same place as product images)

Files to modify:

administrator/components/com_virtuemart/classes/ps_manufacturer.php

administrator/components/com_virtuemart/classes/ps_product.php

administrator/components/com_virtuemart/html/manufacturer.manufacturer_form.php

administrator/components/com_virtuemart/html/shop.product_details.php

administrator/components/com_virtuemart/html/shop.manufacturer_page.php

components/com_virtuemart/themes/default/templates/product_details/flypage.tpl.php (or whatever your flypage is)

components/com_virtuemart/themes/default/templates/pages/shop.maunfacturer.tpl.php

SQL:

Adds mf_full_image and mf_thumb_image to the manufacturer table

Code: [Select]
ALTER TABLE `jos_vm_manufacturer` ADD `mf_thumb_image` VARCHAR( 255 ) NULL DEFAULT NULL AFTER `mf_desc` ,
ADD `mf_full_image` VARCHAR( 255 ) NULL DEFAULT NULL AFTER `mf_thumb_image` ;

Tip:
I am rather pedantic when it comes to images. In this case, I have saved my logos as either .gif or .png with an alpha transperancy. This allows for background colour to show behind the image.

Try a border or a complimentary colour as the back ground for your logos if you don't want to use a transparent background like I have. I tend to like consistancy between pages when I view them so small things like these make your site that much more professional  ;)

File attachment:
All 5 important files to change excl flypage.tpl.php

Images:

Additional Tab:


Inside tab:


Uploaded images (full and thumb):



Full image on flypage link and standard logo:



Thumb image on manufacturer pop up:



[attachment cleanup by admin]
I take no responsibility for any lost work. It is your responsibility to back up files before attempting anything I suggest as I may be:
a) intoxicated
b) high on sugar
c) can't concentrate due to lack of sleep

If you like my hacks, feel free to buy me a coffee, muffin or both :)

paypal: deecee23 at gmail dot com

Hacks in progress: Manufacturer Logo Hack - 100% done

DeeCee

  • Jr. Member
  • **
  • Posts: 177
Re: Manufacturer Logo - Finally Finished
« Reply #11 on: February 03, 2009, 09:37:30 am »
ps_manufacturer

declare the classes to call within ps_manufacturer

Code: [Select]
<?php
if( !defined'_VALID_MOS' ) && !defined'_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
/**
*
* @version $Id: ps_manufacturer.php 1513 2008-08-16 19:02:37Z gregdev $
* @package VirtueMart
* @subpackage classes
* @copyright Copyright (C) 2004-2008 soeren - All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/

/**
 * The class is is used to manage the manufacturers in your store.
 *
 */
class ps_manufacturer {

/**
 * Validates the Input Parameters onBeforeManufacturerAdd
 *
 * @param array $d
 * @return boolean
 */
function validate_add(&$d) {
global $VM_LANG;
require_once(CLASSPATH 'imageTools.class.php' );
$valid true;
$db = new ps_DB;

if (empty($d["mf_name"])) {
$GLOBALS['vmLogger']->err$VM_LANG->_('VM_MANUF_ERR_NAME') );
$valid false;
}
else {
$q "SELECT count(*) as rowcnt from #__{vm}_manufacturer where";
$q .= " mf_name='" .  $db->getEscaped($d["mf_name"]) . "'";
$db->query($q);
$db->next_record();
if ($db->f("rowcnt") > 0) {
$GLOBALS['vmLogger']->err$VM_LANG->_('VM_MANUF_ERR_EXISTS') );
$valid false;
}
}

/** Image Upload Validation **/

// do we have an image URL or an image File Upload?
if (!empty( $d['mf_thumb_image_url'] )) {
// Image URL
if (substr$d['mf_thumb_image_url'], 04) != "http") {
$GLOBALS['vmLogger']->err$VM_LANG->_('VM_PRODUCT_IMAGEURL_MUSTBEGIN') );
$valid =  false;
}

$d["mf_thumb_image"] = $d['mf_thumb_image_url'];
}
else {
// File Upload
if (!vmImageTools::validate_image$d"mf_thumb_image""manufacturer")) {
$valid false;
}
}

if (!empty( $d['mf_full_image_url'] )) {
// Image URL
if (substr$d['mf_full_image_url'], 04) != "http") {
$GLOBALS['vmLogger']->err$VM_LANG->_('VM_PRODUCT_IMAGEURL_MUSTBEGIN') );
return false;
}
$d["mf_full_image"] = $d['mf_full_image_url'];
}
else {
// File Upload
if (!vmImageTools::validate_image$d"mf_full_image""manufacturer")) {
$valid false;
}
}
return $valid;
}
/**
 * Validates the Input Parameters onBeforeManufacturerUpdsate
 *
 * @param array $d
 * @return boolean
 */
function validate_update(&$d) {
global $VM_LANG;
$valid true;
require_once(CLASSPATH 'imageTools.class.php' );

if (empty($d["mf_name"])) {
$GLOBALS['vmLogger']->err$VM_LANG->_('VM_MANUF_ERR_NAME') );
$valid =  false;
}

$db = new ps_DB;
$q 'SELECT mf_thumb_image, mf_full_image FROM #__{vm}_manufacturer WHERE manufacturer_id='. (int) $d["manufacturer_id"];
$db->query$q );
$db->next_record();

/** Image Upload Validation **/

// do we have an image URL or an image File Upload?
if (!empty( $d['mf_thumb_image_url'] )) {
// Image URL
if (substr$d['mf_thumb_image_url'], 04) != "http") {
$GLOBALS['vmLogger']->err$VM_LANG->_('VM_PRODUCT_IMAGEURL_MUSTBEGIN') );
$valid =  false;
}

// if we have an uploaded image file, prepare this one for deleting.
if( $db->f("mf_thumb_image") && substr$db->f("mf_thumb_image"), 04) != "http") {
$_REQUEST["mf_thumb_image_curr"] = $db->f("product_thumb_image");
$d["mf_thumb_image_action"] = "delete";
if (!vmImageTools::validate_image$d"product_thumb_image""manufacturer")) {
return false;
}
}
$d["mf_thumb_image"] = $d['mf_thumb_image_url'];
}
else {
// File Upload
if (!vmImageTools::validate_image$d"mf_thumb_image""manufacturer")) {
$valid false;
}
}

if (!empty( $d['mf_full_image_url'] )) {
// Image URL
if (substr$d['mf_full_image_url'], 04) != "http") {
$GLOBALS['vmLogger']->err$VM_LANG->_('VM_PRODUCT_IMAGEURL_MUSTBEGIN') );
return false;
}
// if we have an uploaded image file, prepare this one for deleting.
if( $db->f("mf_full_image") && substr$db->f("mf_thumb_image"), 04) != "http") {
$_REQUEST["mf_full_image_curr"] = $db->f("mf_full_image");
$d["mf_full_image_action"] = "delete";
if (!vmImageTools::validate_image$d"mf_full_image""manufacturer")) {
return false;
}
}
$d["mf_full_image"] = $d['mf_full_image_url'];
}
else {
// File Upload
if (!vmImageTools::validate_image$d"mf_full_image""manufacturer")) {
$valid false;
}
}

return $valid;
}
/**
 * Validates the Input Parameters onBeforeManufacturerDelete
 *
 * @param array $d
 * @return boolean
 */
function validate_delete($mf_id, &$d) {
global $VM_LANG;
$db = new ps_DB();
require_once(CLASSPATH 'imageTools.class.php' );

$mf_id = (int) $mf_id;

if (empty( $mf_id )) {
$GLOBALS['vmLogger']->err$VM_LANG->_('VM_MANUF_ERR_DELETE_SELECT') );
return False;
}

$db->query"SELECT `#__{vm}_product`.product_id, manufacturer_id   FROM `#__{vm}_product`, `#__{vm}_product_mf_xref` WHERE manufacturer_id =".intval($mf_id)." AND `#__{vm}_product`.product_id = `#__{vm}_product_mf_xref`.product_id" );
if( $db->num_rows() > ) {
$GLOBALS['vmLogger']->err$VM_LANG->_('VM_MANUF_ERR_DELETE_STILLPRODUCTS') );
return false;
}

$q "SELECT mf_thumb_image,mf_full_image FROM #__{vm}_manufacturer WHERE manufacturer_id='$mf_id'";
$db->query$q );
$db->next_record();

/* Prepare mf_thumb_image for Deleting */
if( !stristr$db->f("mf_thumb_image"), "http") ) {
$_REQUEST["mf_thumb_image_curr"] = $db->f("mf_thumb_image");
$d["mf_thumb_image_action"] = "delete";
if (!vmImageTools::validate_image($d,"mf_thumb_image","category")) {
$GLOBALS['vmLogger']->err$VM_LANG->_('VM_PRODUCT_MANUFACTURER_ERR_DELETE_IMAGES') );
return false;
}
}
/* Prepare product_full_image for Deleting */
if( !stristr$db->f("mf_full_image"), "http") ) {
$_REQUEST["mf_full_image_curr"] = $db->f("mf_full_image");
$d["mf_full_image_action"] = "delete";
if (!vmImageTools::validate_image($d,"mf_full_image","category")) {
return false;
}
}

return True;

}

/**
 * creates a new manufacturer record
 *
 * @param array $d
 * @return boolean
 */
function add(&$d) {
global $VM_LANG;

$db = new ps_DB;

if (!$this->validate_add($d)) {
return false;
}

// Check the images
if (!vmImageTools::process_images($d)) {
return false;
}

$fields = array( 'mf_name' => vmGet$d'mf_name' ),
'mf_email' => vmGet$d'mf_email' ),
'mf_desc' => vmGet$d'mf_desc'''VMREQUEST_ALLOWHTML ),
'mf_category_id' => vmRequest::getInt('mf_category_id'),
'mf_url' => vmGet$d'mf_url'),
'mf_thumb_image' => vmGet$d'mf_thumb_image' ),
'mf_full_image' => vmGet$d'mf_full_image' )
);

$db->buildQuery('INSERT''#__{vm}_manufacturer'$fields );
if( $db->query() !== false ) {
$GLOBALS['vmLogger']->info$VM_LANG->_('VM_MANUF_ADDED') );
$_REQUEST['manufacturer_id'] = $db->last_insert_id();
return true;
}
return false;

}

/**
 * updates manufacturer information
 *
 * @param array $d
 * @return boolean
 */
function update(&$d) {
global $VM_LANG;

$db = new ps_DB;

if (!$this->validate_update($d)) {
return False;
}

// Check the images
if (!vmImageTools::process_images($d)) {
return false;
}

$fields = array( 'mf_name' => vmGet$d'mf_name' ),
'mf_email' => vmGet$d'mf_email' ),
'mf_desc' => vmGet$d'mf_desc'''VMREQUEST_ALLOWHTML ),
'mf_category_id' => vmRequest::getInt('mf_category_id'),
'mf_url' => vmGet$d'mf_url'),
'mf_thumb_image' => vmGet$d'mf_thumb_image' ),
'mf_full_image' => vmGet$d'mf_full_image' )
);
$db->buildQuery('UPDATE''#__{vm}_manufacturer'$fields'WHERE manufacturer_id='.(int)$d["manufacturer_id"] );
if( $db->query() ) {
$GLOBALS['vmLogger']->info$VM_LANG->_('VM_MANUF_UPDATED') );
return true;
}
return false;
}

/**
* Controller for Deleting Records.
*/
function delete(&$d) {

$record_id $d["manufacturer_id"];

if( is_array$record_id)) {
foreach( $record_id as $record) {
if( !$this->delete_record$record$d ))
return false;
}
return true;
}
else {
return $this->delete_record$record_id$d );
}
}
/**
* Deletes one Record.
*/
function delete_record$record_id, &$d ) {
global $db;
if (!$this->validate_delete($record_id$d)) {
return False;
}
$q 'DELETE from #__{vm}_product_mf_xref WHERE manufacturer_id='.(int)$record_id.' LIMIT 1';
$db->query($q);
$q 'DELETE from #__{vm}_manufacturer WHERE manufacturer_id='.(int)$record_id.' LIMIT 1';
$db->query($q);

// Delete the image files
if (!vmImageTools::process_images($d)) {
return false;
}

return True;
}
/**
 * Prints a drop-down list of manufacturer names and their ids.
 *
 * @param int $manufacturer_id
 */
function list_manufacturer($manufacturer_id='0') {

$db = new ps_DB;

$q "SELECT manufacturer_id as id,mf_name as name FROM #__{vm}_manufacturer ORDER BY mf_name";
$db->query($q);
$db->next_record();

// If only one vendor do not show list
if ($db->num_rows() == 1) {

echo '<input type="hidden" name="manufacturer_id" value="'$db->f("id").'" />';
echo $db->f("name");
}
elseif( $db->num_rows() > 1) {
$db->reset();
$array = array();
while ($db->next_record()) {
$array[$db->f("id")] = $db->f("name");
}
$code ps_html::selectList('manufacturer_id'$manufacturer_id$array ). "<br />\n";
echo $code;
}
else  {
echo '<input type="hidden" name="manufacturer_id" value="1" />Please create at least one Manufacturer!!';
}
}
}

?>

I take no responsibility for any lost work. It is your responsibility to back up files before attempting anything I suggest as I may be:
a) intoxicated
b) high on sugar
c) can't concentrate due to lack of sleep

If you like my hacks, feel free to buy me a coffee, muffin or both :)

paypal: deecee23 at gmail dot com

Hacks in progress: Manufacturer Logo Hack - 100% done

DeeCee

  • Jr. Member
  • **
  • Posts: 177
Re: Manufacturer Logo - Finally Finished
« Reply #12 on: February 03, 2009, 09:37:56 am »
ps_product.php

declare the classes to call within ps_product

after function get_mf_name($product_id) (approx line 1257)

Code: [Select]
/**
* Functon to get the image of the manufacturer this product is assigned to
*
* @param int $product_id
* @return string the manufacturer image
* added
*/
function get_mf_full_image($product_id) {

$db = new ps_DB;
$childs = array();

$q = "SELECT mf_full_image,#__{vm}_manufacturer.manufacturer_id FROM #__{vm}_product_mf_xref,#__{vm}_manufacturer ";
$q .= "WHERE product_id='$product_id' ";
$q .= "AND #__{vm}_manufacturer.manufacturer_id=#__{vm}_product_mf_xref.manufacturer_id";

$db->query($q);
$db->next_record();
if ($db->f("mf_full_image")) {
return $db->f("mf_full_image");
}
else {
return "";
}
}
I take no responsibility for any lost work. It is your responsibility to back up files before attempting anything I suggest as I may be:
a) intoxicated
b) high on sugar
c) can't concentrate due to lack of sleep

If you like my hacks, feel free to buy me a coffee, muffin or both :)

paypal: deecee23 at gmail dot com

Hacks in progress: Manufacturer Logo Hack - 100% done

DeeCee

  • Jr. Member
  • **
  • Posts: 177
Re: Manufacturer Logo - Finally Finished
« Reply #13 on: February 03, 2009, 09:38:30 am »
manufacturer.manufacturer_form.php

add the images upload tab to manufacturers

Code: [Select]
<?php 
if( !defined'_VALID_MOS' ) && !defined'_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' ); 
/**
*
* @version $Id: manufacturer.manufacturer_form.php 1095 2007-12-19 20:19:16Z soeren_nb $
* @package VirtueMart
* @subpackage html
* @copyright Copyright (C) 2004-2007 soeren - All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/
mm_showMyFileName__FILE__ );

global 
$ps_manufacturer_category$ps_product;
include_class('product');
$manufacturer_id vmRequest::getInt'manufacturer_id');
$option = empty($option)?vmGet$_REQUEST'option''com_virtuemart'):$option;

if (!empty(
$manufacturer_id)) {
  
$q "SELECT * FROM #__{vm}_manufacturer WHERE manufacturer_id='$manufacturer_id'"
  
$db->query($q);  
  
$db->next_record();
}
//First create the object and let it print a form heading
$formObj = &new formFactory$VM_LANG->_('PHPSHOP_MANUFACTURER_FORM_LBL') );
//Then Start the form
$formObj->startForm('adminForm''enctype="multipart/form-data"');

$tabs = new vmTabPanel(01"manufacturerform");
$tabs->startPane("manufacturer-pane");
$tabs->startTab"<img src='"IMAGEURL ."ps_image/edit.png' align='absmiddle' width='16' height='16' border='0' /> ".$VM_LANG->_('PHPSHOP_MANUFACTURER_FORM_LBL'), "info-page");
?>

<br />
  <table class="adminform">
  <tr>
      <td><strong><?php echo $VM_LANG->_('PHPSHOP_MANUFACTURER_FORM_INFO_LBL'?></strong></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td align="right"><?php echo $VM_LANG->_('PHPSHOP_MANUFACTURER_LIST_MANUFACTURER_NAME'?></td>
      <td>
        <input type="text" class="inputbox" name="mf_name" value="<?php $db->sp("mf_name"?>" size="16" />
      </td>
    </tr>
    <tr>
      <td width="22%" align="right" ><?php echo $VM_LANG->_('PHPSHOP_PRODUCT_FORM_URL'?>:</td>
      <td width="78%" >
        <input type="text" class="inputbox" name="mf_url" value="<?php $db->sp("mf_url"?>" size="32" />
      </td>
    </tr>
    <tr>
      <td align="right"><?php echo $VM_LANG->_('PHPSHOP_MANUFACTURER_FORM_CATEGORY'?>:</td>
      <td ><?php $ps_manufacturer_category->list_category($db->f("mf_category_id"));     ?></td>
    </tr>
    <tr>
      <td align="right">&nbsp;</td>
      <td >&nbsp;</td>
    </tr>
    <tr>
      <td align="right" ><?php echo $VM_LANG->_('PHPSHOP_MANUFACTURER_FORM_EMAIL'?>:</td>
      <td>
        <input type="text" class="inputbox" name="mf_email" value="<?php $db->sp("mf_email"?>" size="18" />
      </td>
    </tr>
    <tr>
      <td align="right" >&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td width="22%" align="right"  valign="top"><?php echo $VM_LANG->_('PHPSHOP_MANUFACTURER_FORM_DESCRIPTION'?>:</td>
      <td width="78%" ><?php
editorArea'editor1'$db->f("mf_desc"), 'mf_desc''300''150''70''25' )
?>

      </td>
    <tr align="center">
      <td colspan="2" >&nbsp;</td>
    </tr>
</table>
<?php
$tabs
->endTab();
$tabs->startTab"<img src='"IMAGEURL ."ps_image/image.png' width='16' height='16' align='absmiddle' border='0' /> ".$VM_LANG->_('E_IMAGES'), "images-page");

if( !
stristr$db->f("mf_thumb_image"), "http") )
  echo 
"<input type=\"hidden\" name=\"mf_thumb_image_curr\" value=\""$db->f("mf_thumb_image") ."\" />";

if( !
stristr$db->f("mf_full_image"), "http") )
  echo 
"<input type=\"hidden\" name=\"mf_full_image_curr\" value=\""$db->f("mf_full_image") ."\" />";
 
  
$ps_html->writableIndicator( array( IMAGEPATH."manufacturer") );
?>

  <table class="adminform" >
    <tr>
      <td valign="top" width="50%" style="border-right: 1px solid black;">
        <h2><?php echo $VM_LANG->_('PHPSHOP_PRODUCT_FORM_FULL_IMAGE'?></h2>
        <table class="adminform">
          <tr class="row0">
            <td colspan="2" ><?php 
            
if ($manufacturer_id) {
                echo 
$VM_LANG->_('PHPSHOP_PRODUCT_FORM_IMAGE_UPDATE_LBL') . "<br />"; } ?>

              <input type="file" class="inputbox" name="mf_full_image" size="50" maxlength="255" />
              </td>
          </tr>
          <tr class="row1">
            <td colspan="2" ><div style="font-weight:bold;"><?php echo $VM_LANG->_('PHPSHOP_IMAGE_ACTION'?>:</div><br/>
              <input type="radio" class="inputbox" name="mf_full_image_action" id="mf_full_image_action0" checked="checked" value="none" onchange="toggleDisable( document.adminForm.mf_full_image_action[1], document.adminForm.mf_thumb_image, true );toggleDisable( document.adminForm.mf_full_image_action[1], document.adminForm.mf_thumb_image_url, true );"/>
              <label for="mf_full_image_action0"><?php echo $VM_LANG->_('PHPSHOP_NONE'?></label><br/>
              <?php
              
// Check if GD library is available - creates image
              
if( function_exists('imagecreatefromjpeg')) { ?>

              <input type="radio" class="inputbox" name="mf_full_image_action" id="mf_full_image_action1" value="auto_resize" onchange="toggleDisable( document.adminForm.mf_full_image_action[1], document.adminForm.mf_thumb_image, true );toggleDisable( document.adminForm.mf_full_image_action[1], document.adminForm.mf_thumb_image_url, true );"/>
              <label for="mf_full_image_action1"><?php echo $VM_LANG->_('PHPSHOP_FILES_FORM_AUTO_THUMBNAIL') . "</label><br />"
              }
              if (
$manufacturer_id and $db->f("mf_full_image")) { ?>

                <input type="radio" class="inputbox" name="mf_full_image_action" id="mf_full_image_action2" value="delete" onchange="toggleDisable( document.adminForm.mf_full_image_action[1], document.adminForm.mf_thumb_image, true );toggleDisable( document.adminForm.mf_full_image_action[1], document.adminForm.mf_thumb_image_url, true );"/>
                <label for="mf_full_image_action2"><?php echo $VM_LANG->_('PHPSHOP_PRODUCT_FORM_IMAGE_DELETE_LBL') . "</label><br />"
              } 
?>

            </td>
          </tr>
          <tr class="row0"><td colspan="2">&nbsp;</td></tr>
          <tr class="row0">
            <td width="21%" ><?php echo $VM_LANG->_('URL')." (".$VM_LANG->_('CMN_OPTIONAL')."!)&nbsp;"?></td>
            <td width="79%" >
              <?php 
              
if( stristr($db->f("mf_full_image"), "http") )
                
$mf_full_image_url $db->f("mf_full_image");
              else if(!empty(
$_REQUEST['mf_full_image_url']))
                
$mf_full_image_url vmGet($_REQUEST'mf_full_image_url');
              else
                
$mf_full_image_url "";
              
?>

              <input type="text" class="inputbox" size="50" name="mf_full_image_url" value="<?php echo $mf_full_image_url ?>" onchange="if( this.value.length>0) document.adminForm.auto_resize.checked=false; else document.adminForm.auto_resize.checked=true; toggleDisable( document.adminForm.auto_resize, document.adminForm.mf_thumb_image_url, true );toggleDisable( document.adminForm.auto_resize, document.adminForm.mf_thumb_image, true );" />
            </td>
          </tr>
          <tr class="row1"><td colspan="2">&nbsp;</td></tr>
          <tr class="row1">
            <td colspan="2" >
              <div style="overflow:auto;">
                <?php echo $ps_product->image_tag($db->f("mf_full_image"), ""0"manufacturer"); ?>
              </div>
            </td>
          </tr>
        </table>
      </td>

      <td valign="top" width="50%">
        <h2><?php echo $VM_LANG->_('PHPSHOP_PRODUCT_FORM_THUMB_IMAGE'?></h2>
        <table class="adminform">
          <tr class="row0">
            <td colspan="2" ><?php if ($manufacturer_id) {
                echo 
$VM_LANG->_('PHPSHOP_PRODUCT_FORM_IMAGE_UPDATE_LBL') . "<br />"; } ?>

              <input type="file" class="inputbox" name="mf_thumb_image" size="50" maxlength="255" onchange="if(document.adminForm.mf_thumb_image.value!='') document.adminForm.mf_thumb_image_url.value='';" />
            </td>
          </tr>
          <tr class="row1">
            <td colspan="2" ><div style="font-weight:bold;"><?php echo $VM_LANG->_('PHPSHOP_IMAGE_ACTION'?>:</div><br/>
              <input type="radio" class="inputbox" id="mf_thumb_image_action0" name="mf_thumb_image_action" checked="checked" value="none" onchange="toggleDisable( document.adminForm.image_action[1], document.adminForm.mf_thumb_image, true );toggleDisable( document.adminForm.image_action[1], document.adminForm.mf_thumb_image_url, true );"/>
              <label for="mf_thumb_image_action0"><?php echo $VM_LANG->_('PHPSHOP_NONE'?></label><br/>
              <?php 
              
if ($manufacturer_id and $db->f("mf_thumb_image")) { ?>

                <input type="radio" class="inputbox" id="mf_thumb_image_action1" name="mf_thumb_image_action" value="delete" onchange="toggleDisable( document.adminForm.image_action[1], document.adminForm.mf_thumb_image, true );toggleDisable( document.adminForm.image_action[1], document.adminForm.mf_thumb_image_url, true );"/>
                <label for="mf_thumb_image_action1"><?php echo $VM_LANG->_('PHPSHOP_PRODUCT_FORM_IMAGE_DELETE_LBL') . "</label><br />";  
              } 
?>

            </td>
          </tr>
          <tr class="row0"><td colspan="2">&nbsp;</td></tr>
          <tr class="row0">
            <td width="21%" ><?php echo $VM_LANG->_('URL')." (".$VM_LANG->_('CMN_OPTIONAL').")&nbsp;"?></td>
            <td width="79%" >
              <?php 
              
if( stristr($db->f("mf_thumb_image"), "http") )
                
$mf_thumb_image_url $db->f("mf_thumb_image");
              else if(!empty(
$_REQUEST['mf_thumb_image_url']))
                
$mf_thumb_image_url vmGet($_REQUEST'mf_thumb_image_url');
              else
                
$mf_thumb_image_url "";
              
?>

              <input type="text" class="inputbox" size="50" name="mf_thumb_image_url" value="<?php echo $mf_thumb_image_url ?>" />
            </td>
          </tr>
          <tr class="row1"><td colspan="2">&nbsp;</td></tr>
          <tr class="row1">
            <td colspan="2" >
              <div style="overflow:auto;">
                <?php 
                 echo 
$ps_product->image_tag($db->f("mf_thumb_image"), ""0"manufacturer");
                
?>

              </div>
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
<?php
$tabs
->endPane();

// Add necessary hidden fields
$formObj->hiddenField'manufacturer_id'$manufacturer_id );
  
$funcname = !empty($manufacturer_id) ? "manufacturerupdate" "manufactureradd";
// Write your form with mixed tags and text fields
// and finally close the form:
$formObj->finishForm$funcname$modulename.'.manufacturer_list'$option );
?>

<script type="text/javascript">//<!--
function toggleDisable( elementOnChecked, elementDisable, disableOnChecked ) {
  if( !disableOnChecked ) {
    if(elementOnChecked.checked==true) {
      elementDisable.disabled=false;
    }
    else {
      elementDisable.disabled=true;
    }
  }
  else {
    if(elementOnChecked.checked==true) {
      elementDisable.disabled=true;
    }
    else {
      elementDisable.disabled=false;
    }
  }
}

toggleDisable( document.adminForm.mf_full_image_action[1], document.adminForm.mf_thumb_image, true );
//-->
</script>
I take no responsibility for any lost work. It is your responsibility to back up files before attempting anything I suggest as I may be:
a) intoxicated
b) high on sugar
c) can't concentrate due to lack of sleep

If you like my hacks, feel free to buy me a coffee, muffin or both :)

paypal: deecee23 at gmail dot com

Hacks in progress: Manufacturer Logo Hack - 100% done

DeeCee

  • Jr. Member
  • **
  • Posts: 177
Re: Manufacturer Logo - Finally Finished
« Reply #14 on: February 03, 2009, 09:38:52 am »
shop.product_details.php

declare the variables to call for the flypage - linked logo and standard logo
(approx line 249)

Code: [Select]
// LINK TO MANUFACTURER POP-UP
$manufacturer_id = $ps_product->get_manufacturer_id($product_id);
$manufacturer_name = $ps_product->get_mf_name($product_id);
$manufacturer_image = $ps_product->get_mf_full_image($product_id); //added
$manufacturer_link = "";
if( $manufacturer_id && !empty($manufacturer_name) ) {
$link = "$mosConfig_live_site/index2.php?page=shop.manufacturer_page&amp;manufacturer_id=$manufacturer_id&amp;output=lite&amp;option=com_virtuemart&amp;Itemid=".$Itemid;
if (!empty($manufacturer_image))
{
$text = '<img src="/components/com_virtuemart/shop_image/manufacturer/'.$manufacturer_image.'" alt="'.$manufacturer_name.'" title="'.$manufacturer_name.'" align="top" border="0" style="margin-bottom:4px;"><br>';
}
else {
$text = '( '.$manufacturer_name.' )';
}
$manufacturer_link .= vmPopupLink( $link, $text );

// Avoid JavaScript on PDF Output
if( @$_REQUEST['output'] == "pdf" )
$manufacturer_link = "<a href=\"$link\" target=\"_blank\" title=\"$manufacturer_name\">$text</a>";
}
// LINK TO MANUFACTURER LOGO
$manufacturer_logo = "";
if( $manufacturer_id && !empty($manufacturer_name) ) {
if (!empty($manufacturer_image))
{
$logo = '<img src="/components/com_virtuemart/shop_image/manufacturer/'.$manufacturer_image.'" alt="'.$manufacturer_name.'" title="'.$manufacturer_name.'" align="top" border="0"><br />';
}
else {
$logo = '( '.$manufacturer_name.' )';
}
$manufacturer_logo .= ( $logo );
}

line 427 - set the variable for the flypage ( dev reference themes and templates http://dev.virtuemart.net/cb/wiki/1367 )

Code: [Select]
$tpl->set( "manufacturer_logo", $manufacturer_logo ); //added
----------

shop.manufacturer_page.php

find image tags in database related to Manu ID and display on manufacturer pop up page

Code: [Select]
mm_showMyFileName( __FILE__ );

$manufacturer_id = intval( vmGet( $_GET, 'manufacturer_id' ));

if( !empty( $manufacturer_id ) ) {
$q  = "SELECT * FROM `#__{vm}_manufacturer` WHERE "; //added
$q .= "`manufacturer_id`=$manufacturer_id";
$db->query($q);
if( !$db->next_record() ) {
return;
}

$mf_name=$db->f("mf_name");
$mf_email=$db->f("mf_email");
$mf_desc=$db->f("mf_desc");
$mf_url = $db->f("mf_url");
$mf_thumb_image = $db->f("mf_thumb_image"); //added
$mf_full_image = $db->f("mf_full_image"); //added

$tpl = vmTemplate::getInstance();
$tpl->set_vars(array('mf_name'=>$db->f("mf_name"),
'mf_email' => $db->f("mf_email"),
'mf_desc' => $db->f("mf_desc"),
'mf_url' => $db->f("mf_url"),
'mf_thumb_image' => $db->f("mf_thumb_image"), //added
'mf_full_image' => $db->f("mf_full_image"), //added
'db' => $db
)
);
echo $tpl->fetch('pages/shop.manufacturer.tpl.php');

}
?>
I take no responsibility for any lost work. It is your responsibility to back up files before attempting anything I suggest as I may be:
a) intoxicated
b) high on sugar
c) can't concentrate due to lack of sleep

If you like my hacks, feel free to buy me a coffee, muffin or both :)

paypal: deecee23 at gmail dot com

Hacks in progress: Manufacturer Logo Hack - 100% done