Esempio n. 1
0
 <?php 
   // Cart item row START
   ?>
 <?php 
   $item_price = $stock['price_promotion'] != 0 ? $stock['price_promotion'] : $stock['price_retail'];
   $product = Doctrine::getTable('rtShopProduct')->find($stock['product_id']);
   $match = null;
   $variations = '';
   if (count($stock['rtShopVariations']) > 0) {
       $comma = '';
       $or = '';
       foreach ($stock['rtShopVariations'] as $variation) {
           // build the variation list to display
           $variations .= $comma . $variation['title'];
           $comma = ', ';
           $cleaned_title = rtAssetToolkit::cleanFilename($variation['title'], true);
           if (!is_numeric($cleaned_title)) {
               // avoid simple numbers when building the $match regex.
               $match .= $or . $cleaned_title . '|' . str_replace(array('-', '_'), '', $cleaned_title);
               $or = '|';
           }
       }
       $match = '/(' . $match . ')/i';
       $image = $product->getPrimaryImage($match) ? image_tag(rtAssetToolkit::getThumbnailPath($product->getPrimaryImage($match)->getSystemPath(), array('maxHeight' => 500, 'maxWidth' => 150))) : 'xx';
   } else {
       $image = $product->getPrimaryImage() ? image_tag(rtAssetToolkit::getThumbnailPath($product->getPrimaryImage()->getSystemPath(), array('maxHeight' => 500, 'maxWidth' => 150))) : 'xx';
   }
   ?>
 <tr class="<?php 
   echo isset($stock_exceeded[$stock['id']]) ? 'error' : '';
   ?>
 /**
  * Execute a file upload, communicating the success or failure via an ajax response.
  *
  * Note: This response is set as plain/text since application/json responses were causing
  * issues. When calling this action, please use:
  *
  * <code>
  * url_for('@rt_asset_upload?sf_format=json')
  * </code>
  *
  * @param sfWebRequest $request
  */
 public function executeUpload(sfWebRequest $request)
 {
     $form = $this->getForm();
     $request_params = $request->getParameter($form->getName());
     $form->bind($request_params, $request->getFiles($form->getName()));
     $this->setLayout(false);
     sfConfig::set('sf_web_debug', false);
     $error = '';
     if ($form->isValid()) {
         try {
             $file = $request->getFiles('rt_asset');
             $form->getObject()->setOriginalFilename(rtAssetToolkit::cleanFilename($file['filename']['name']));
             $form->getObject()->setFilesize($file['filename']['size']);
             $form->getObject()->setMimeType($file['filename']['type']);
             $assets = Doctrine::getTable('rtAsset')->getAssetsForModelAndId($request_params['model'], $request_params['model_id']);
             $position = 1;
             if ($assets->count() > 0) {
                 $position = $assets->getLast()->getPosition() + 1;
             }
             $form->getObject()->setPosition($position);
             $form->save();
             $this->asset = $form->getObject();
             return sfView::SUCCESS;
         } catch (Exception $e) {
             $error = $e->getMessage();
             $this->logMessage($e->getMessage(), 'err');
         }
     } else {
         $error = $form['filename']->getError()->getMessage();
     }
     $this->error = $error;
     return sfView::ERROR;
 }