PhpRiot
Recent Code Pastes

Listing 1626

Followup to listing-1625.txt, submitted by anonymous user.

Submitted by anonymous user, 10 October 2008
<?php
 
        function html_item()
        {
            // Unset the 'route' to the cart
            unset($_SESSION['itemToCart']);
            
            // Check the item slug is legit 
            $tpl = Items::load()->getItemInfo('ItemText.URLSlug', $_GET['get'][1]);
            if( !$tpl  ) 
            {
                HandleException( __FILE__, __LINE__, 'Missing Category URLSlug.. PreviousPage: '.$_SESSION['previousPage']. ' - Refeer: '.$_SERVER['HTTP_REFERER'] ); 
                header("Location: ".Conf::$PATH_URL."lost");
            }
            
            // Vars
            $this->title = $tpl['MetaTitle'];
            $this->metaDesc = $tpl['Description'];
            $this->setSMLVar( 'SEOH1', "Buy {$tpl['ItemName']} UK" );
            $this->setSMLVar( 'SEOH2', $tpl['ItemName'] . " from ".$tpl['UniqueName'] ); 
            
            // Includes
            $this->setMedia( 'js/mootabs.js' );
            
            // Try to swap the previous item with this one 
            if(!Breadcrumbs::get()->swapLastItem( 'item/'.$tpl['URLSlug'], $tpl['UniqueName'].' '.$tpl['ItemName'], 'item' ))
            {
                // No previous item so just add it
                Breadcrumbs::get()->addCrumb( 'item/'.$tpl['URLSlug'], $tpl['UniqueName'].' '.$tpl['ItemName'], 'item' );
            }
            
            // Item Features
            $tpl['ItemFeatures'] = Items::load()->getItemFeatures($tpl['ItemId']);
            
            // Item Pictures
            $tpl['ItemPictures'] = Items::load()->getItemPictures($tpl['ItemId']);
            
            // Item Options
            $tpl['ItemVariations'] = Items::load()->getItemVariations($tpl['ItemId'], 'Variation');
            
            // Item Accessories
            $tpl['ItemAccessories'] = Items::load()->getItemVariations($tpl['ItemId'], 'Accessory');
            
            // Related Items
            $tpl['RelatedItems'] = Items::load()->getItemVariations($tpl['ItemId'], 'Related');
            
            // Turns the benefits into a list 
            $Benefits = explode("\n", $tpl['Benefits']);
            $tpl['Benefits'] = array();
            foreach ($Benefits as $bk => $bv) if($bv != '') 
                $tpl['Benefits'][] = array('Benefit'=>$bv);
                        
            // Make the Quantity Drop down box 
            if($tpl['Quantity'] > 0)
            {
                $num = 1;
                while ($num <= $tpl['Quantity'] && $num <= 10)
                {
                    $tpl['QuantityLoop'][] = array('Value'=>$num);
                    $num++;
                }
            }
            
            // Add to XML
            $item = $this->xml->append( $this->g['content'], 'Item' );        
            $this->arrayToXMLVal( $item, $tpl );
        }
 
?>
Submit a Follow Up