Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

mistahdru

Archived
  • Posts

    10
  • Joined

  • Last visited

Profile Information

  • Real Name
    drew gorton
  • Location
    Minnesota, USA

mistahdru's Achievements

  1. :oops: If it isn't obvious, ignore the post dated "Wed Jul 23, 2003 11:26 am". I hit the submit button too quickly. The second post is the accurate one.
  2. I've yet to have a chance to move to the enable/disable categories mod, but it looks to me like all you'll need to do is update the SQL in all_categories.php. Right now it has the following: // 1.2 Test for presence of status field for compatibility with older versions $status = tep_db_num_rows(tep_db_query('describe categories status')); $query = "select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id"; // 1.3 Can't have 'where' in an if statement! if ($status >0) $query.= " and c.status = '1'"; $query.= " and cd.language_id='" . $languages_id ."' order by sort_order, cd.categories_name"; $categories_query = tep_db_query($query); If you're not interested in supporting old versions of OSC, I think you can just update that with the SQL you posted: $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_status = '1' and c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . $languages_id ."' order by sort_order, cd.categories_name"); That's just my quick take on it based on your posts, but it seems to me that should work. If you do test it, let me know either way... Drew
  3. I've yet to have a chance to move to the enable/disable categories mod, but it looks to me like all you'll need to do is update the SQL in all_categories.php. Right now it has the query: $query = "select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id" I think you just need to update that to read: $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_status = '1' and c.parent_id = '" . $value . "' and c.categories_id = cd.categories_id and cd.language_id='" . $languages_id ."' order by sort_order, cd.categories_name"); That's just my quick take on it based on your posts, but it seems to me that should work. If you do test it, let me know either way... Drew
  4. Here's a quick question - have you changed column_left.php per the following? Default OSC (remove) include(DIR_WS_BOXES . 'categories.php'); This Contrib (add) include(DIR_WS_BOXES . 'all_categories.php'); I'm not sure that's included in the instructions, but it is a necessary part. If you have done that, then the issue is in the SQL -- you'll need to edit lines 115 - 124 per the SQL in the enable / disable categories contrib. And, finally, I noticed that I left part of a hack in that code. :oops: You can delete the following: // Keep out parts category $excluded_parts_category_id = 28; That was my quick hack method of leaving out a particular category I didn't want to show. I think I'll switch to the Enable / Disable contrib for my next realease - thanks for pointing it out! Hope that helps, Drew
  5. Ok - I got frustrated enough with text formatting to get stubborn. I overhauled this with a combination of Ivan's code, the tutorials on FPDF.org and the html2pdf class which I posted on the last page. This code will format the following correctly in PDF format: <b><a><i><br><p><li><ol><ul><h4><h3><h2> It also displays the store name as a logo/image and multiple product images (from Contribution "Additional Images 1b"). There may be bugs - please post back here if you find any. I'm not formally uploading it to the contrib yet as it could use further modifications (reducing DB queries and further OSC-ifying) as well as testing. For now, it's been tailored to my needs and could use some further abstractions. It should be useful out of the box, however, for anyone needing to convert HTML text-formatting in their PDF. In any case, here's the changed pdf_datasheet_functions.php: define('FPDF_FONTPATH','pdf/font/'); require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PDF_DATASHEET); require('pdf/pdf_datasheet_config.php'); require('pdf/fpdf.php'); define('FPDF_FONTPATH','font/'); define('LEFT_MARGIN',5); define('RIGHT_MARGIN',5); define('TOP_MARGIN',80); define('IMAGES_X_FROM_RIGHT',80); define('IMAGES_X_FROM_LEFT',150); define('IMAGES_WIDTH',50); define('IMAGES_VERT_DISTANCE',50); define('PAGE_FORMAT','Letter'); define('HOME_PAGE_URL','http://my.site.com'); define('LOGO','pdf/logo.png'); define('TEXT_SIZE',10); define('INDENT_SIZE',5); define('ALLOWABLE_TAGS','<b><a><i><br><p><li><ol><ul><h4><h3><h2>'); class PDF extends FPDF { var $B; var $I; var $U; var $HREF; var $current_indent = LEFT_MARGIN; function PDF($orientation='P',$unit='mm',$format=PAGE_FORMAT) { //Call parent constructor $this->FPDF($orientation,$unit,$format); //Initialization $this->B=0; $this->I=0; $this->U=0; $this->HREF=''; } function Header() { global $products_id; global $languages_id; // Product Description Info $products_description_query = tep_db_query("SELECT products_name from " . TABLE_PRODUCTS_DESCRIPTION . " WHERE products_id = '" . $products_id . "' AND language_id = '" . $languages_id . "'"); $products_description = tep_db_fetch_array($products_description_query); // Product Info $products_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = " . $products_id); $products = tep_db_fetch_array($products_query); // Product Category Info $cPath = ''; $cat_count_sql = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . $products_id . "'"); $cat_count_data = tep_db_fetch_array($cat_count_sql); if ($cat_count_data['count'] == 1) { $categories = array(); $cat_id_sql = tep_db_query("select categories_name from " . TABLE_PRODUCTS_TO_CATEGORIES . " pc, " . TABLE_CATEGORIES_DESCRIPTION . " cd where pc.products_id = '" . $products_id . "' and cd.categories_id = pc.categories_id"); $cat_id_data = tep_db_fetch_array($cat_id_sql); tep_get_parent_categories($categories, $cat_id_data['categories_id']); $size = sizeof($categories)-1; for ($i = $size; $i >= 0; $i--) { if ($cPath != '') $cPath .= ' > '; $parent_id_sql = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . $categories[$i] . "'"); $parent_id_data = tep_db_fetch_array($parent_id_sql); $cPath .= $parent_id_data['categories_name']; } if ($cPath != '') $cPath .= ' >> '; $cPath .= $cat_id_data['categories_name']; } $path = $cPath; $products_name = $products_description['products_name']; $products_model = $products['products_model']; $home_page = HOME_PAGE_URL; $this->SetLeftMargin(LEFT_MARGIN); $this->SetRightMargin(RIGHT_MARGIN); // Logo $this->Image(LOGO,LEFT_MARGIN,10,75,0,png,$home_page); $this->SetLineWidth(0); //Today's date $this->SetTextColor(0,0,0); $date = strftime(DATE_FORMAT_LONG); $this->SetFont('Arial','',9); $this->Cell(0,8,$date .' ',0,1,'R'); $this->Ln(1); $x=$this->GetX(); $y=$this->GetY(); $this->Line($x,$y,$this->w-$this->rMargin,$y); $this->Ln(0.5); //Keep Y position $this->y0=$this->GetY(); $this->Ln(0); $this->SetFont('arial','I',8); $breadcrumb_color_table=explode(",",BREADCRUMB_COLOR_TABLE); $this->SetFillColor($breadcrumb_color_table[0], $breadcrumb_color_table[1], $breadcrumb_color_table[2]); $breadcrumb_text_color=explode(",",BREADCRUMB_COLOR_TEXT); $this->SetTextColor($breadcrumb_text_color[0], $breadcrumb_text_color[1], $breadcrumb_text_color[2]); $this->Cell(0,5,$path .' >> '. $products_name,0,0,'L',1); $this->Ln(5); $this->SetFont('arial','B',24); $product_name_color_table=explode(",",PRODUCT_NAME_COLOR_TABLE); $this->SetFillColor($product_name_color_table[0], $product_name_color_table[1], $product_name_color_table[2]); $this->MultiCell(0,12,$products_name ,0,'L',1); $this->Ln(1); $this->SetTextColor($title_text_color[0], $title_text_color[1], $title_text_color[2]); $this->SetFont('arial','',TEXT_SIZE); $this->Cell(0,5,"Model: " . $products_model); $this->Ln(9); } function Footer() { $this->SetLeftMargin(LEFT_MARGIN); $this->SetRightMargin(RIGHT_MARGIN); $this->SetY(-20); $footer_color_cell=explode(",",FOOTER_CELL_BG_COLOR); $this->SetFillColor($footer_color_cell[0], $footer_color_cell[1], $footer_color_cell[2]); $this->MultiCell(0,5,"",0,'L',1); $x=$this->GetX(); $y=$this->GetY(); $this->SetLineWidth(1); $this->Line($x,$y,$this->w-$this->rMargin,$y); $this->SetFont('Arial','',9); $this->Cell($w,9,PDF_TITLE .' - '. OWNER_EMAIL_ADDRESS .' - '. STORE_ADDRESS,0,0,'L','','mailto:'. OWNER_EMAIL_ADDRESS); $this->Cell(0,10,'Page '.$this->PageNo(),0,0,'R'); } function ShowImages() { global $products_id; $vert = $this->GetY(); $product_image_query = tep_db_query("SELECT products_image FROM " . TABLE_PRODUCTS . " WHERE products_id = " . $products_id); if ($product_image = tep_db_fetch_array($product_image_query)) { $this->Image(DIR_WS_IMAGES . $product_image['products_image'],IMAGES_X_FROM_LEFT,$vert,IMAGES_WIDTH); $vert += IMAGES_VERT_DISTANCE; } // FROM ADDITIONAL IMAGES 1b CONTRIB $additional_images_array = array(); $additional_images_query = tep_db_query("SELECT medium_images FROM " . TABLE_ADDITIONAL_IMAGES . " WHERE products_id = " . $products_id); if (tep_db_num_rows($additional_images_query)) { while ($additional_images = tep_db_fetch_array($additional_images_query)) { array_push ($additional_images_array, DIR_WS_IMAGES . $additional_images['medium_images']); } } for ($i=0;$i<count($additional_images_array);$i++){ $heightwidth=getimagesize($additional_images_array[$i]); $factor = $heightwidth[0]/$heightwidth[1]; $imagewidth=$heightwidth[0]; $imageheight=$heightwidth[1]; $this->Image($additional_images_array[$i],IMAGES_X_FROM_LEFT,$vert,IMAGES_WIDTH); $vert += IMAGES_VERT_DISTANCE; } // END ADDITIONAL IMAGES 1b CONTRIB } function ShowPrice() { global $products_id; global $currencies; // Product Info $product_info_query = tep_db_query("SELECT products_price, products_tax_class_id from " . TABLE_PRODUCTS . " WHERE products_status = 1 and products_id = " . $products_id ); $product_info = tep_db_fetch_array($product_info_query); if ($new_price = tep_get_products_special_price($products_id)) { $products_price = 'Normal Price: ' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . ' <b>Special Price' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</b>'; } else { $products_price = "Price: ".$currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])); } $this->Ln(5); $this->Write(12,$products_price); } function WriteHTML() { global $products_id; global $languages_id; $product_query = tep_db_query("Select products_description from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = " . $products_id ." and language_id = " . $languages_id); if ($product = tep_db_fetch_array($product_query)){ $html = $product['products_description']; } else { $html="No Description Provided"; } $html = html_entity_decode(strip_tags($html,ALLOWABLE_TAGS)); //HTML parser $html=str_replace("n",' ',$html); $a=preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE); global $current_indent; foreach($a as $i=>$e) { if($i%2==0) { //Text if($this->HREF) $this->PutLink($this->HREF,$e); else { $this->Write(5,$e); } } else { //Tag if($e{0}=='/') $this->CloseTag(strtoupper(substr($e,1))); else { //Extract attributes $a2=explode(' ',$e); $tag=strtoupper(array_shift($a2)); $attr=array(); foreach($a2 as $v) if(ereg('^([^=]*)=["']?([^"']*)["']?$',$v,$a3)) $attr[strtoupper($a3[1])]=$a3[2]; $this->OpenTag($tag,$attr); } } } } function OpenTag($tag,$attr) { global $current_indent; $h1 = 22; $h2 = 18; $h3 = 16; $h4 = 14; $line_break = 5; //Opening tag $this->SetLeftMargin($current_indent + LEFT_MARGIN); if($tag=='B' or $tag=='I' or $tag=='U') $this->SetStyle($tag,true); else if($tag=='H1') { $this->SetStyle('B',true); $this->SetFontSize($h1); $this->Ln($line_break * 2); } else if($tag=='H2') { $this->SetStyle('B',true); $this->SetFontSize($h2); $this->Ln($line_break * 2); } else if($tag=='H3') { $this->SetStyle('B',true); $this->SetFontSize($h3); $this->Ln($line_break * 2); } else if($tag=='H4') { $this->SetStyle('B',true); $this->SetFontSize($h4); $this->Ln($line_break * 2); } else if($tag=='A') $this->HREF=$attr['HREF']; else if($tag=='BR') $this->Ln($line_break); else if($tag=='P') $this->Ln($line_break); else if($tag=='UL' or $tag=='OL') { $this->SetLeftMargin($current_indent + INDENT_SIZE); $current_indent += INDENT_SIZE; } else if($tag=='LI') { $this->Ln($line_break); $this->Write(5, chr(149) . " "); } } function CloseTag($tag) { global $current_indent; $line_break = 5; //Closing tag if($tag=='B' or $tag=='I' or $tag=='U') $this->SetStyle($tag,false); else if($tag=='H1' or $tag=='H2' or $tag=='H3' or $tag=='H4') { $this->SetFontSize(TEXT_SIZE); $this->SetStyle('B',false); $this->Ln($line_break); } else if($tag=='A') $this->HREF=''; else if($tag=='P') $this->Ln($line_break); else if($tag=='UL' or $tag=='OL') { $this->SetLeftMargin($current_indent - INDENT_SIZE); $current_indent -= INDENT_SIZE; } else if($tag=='LI') $this->Ln($line_break); } function SetStyle($tag,$enable) { //Modify style and select corresponding font $this->$tag+=($enable ? 1 : -1); $style=''; foreach(array('B','I','U') as $s) if($this->$s>0) $style.=$s; $this->SetFont('',$style); } function PutLink($URL,$txt) { //Put a hyperlink $this->SetTextColor(0,0,255); $this->SetStyle('U',true); $this->Write(5,$txt,$URL); $this->SetStyle('U',false); $this->SetTextColor(0); } } $pdf=new PDF(); $pdf->Open(); $pdf->SetAutoPageBreak(true, 35); $pdf->AddPage(); $pdf->ShowImages(); $pdf->SetRightMargin(IMAGES_X_FROM_RIGHT); $pdf->WriteHTML(); $pdf->SetLeftMargin(LEFT_MARGIN); $pdf->ShowPrice(); $pdf->Output(); exit; Drew
  6. Ugh. Frames. The correct URL for the forum is: http://www.fpdf.org/phorum/read.php?f=1&i=...492&t=3476#3492 Drew
  7. An interesting highbrid would be a PDF which maintains some formatting options. (Keeping bold text bold, for example). FPDF.org has a class which does just this, but I'm having a rough time trying to integrate the two. Here's that thread: http://www.fpdf.org/read.php?f=1&i=3492&t=3476#3492 And here's the URL for the class: http://www.fpdf.org/download/html2pdf.zip As this is my first foray into PDF generating, though, I'm hoping that this both apeals to others and that someone else knows their stuff well enough to make this a trivial task. Drew
×
×
  • Create New...