public function setup()
 {
     parent::setup();
     $this->useFields(array('position', 'title', 'image'));
     $this->setWidget('position', new sfWidgetFormInputText(array(), array('style' => 'width:50px')));
     $file_exists = false;
     $path = '';
     if (!$this->isNew()) {
         $this->setWidget('delete', new sfWidgetFormInputCheckbox());
         $this->validatorSchema['delete'] = new sfValidatorBoolean();
         $this->setWidget('image_delete', new sfWidgetFormInputCheckbox());
         $this->validatorSchema['image_delete'] = new sfValidatorBoolean();
         $file_location = sfConfig::get('sf_upload_dir') . '/variations/' . $this->getObject()->image;
         if (is_file($file_location)) {
             $file_exists = true;
             $path = rtAssetToolkit::getThumbnailPath(sfConfig::get('sf_upload_dir') . '/variations/' . $this->getObject()->image, array('maxWidth' => 30, 'maxHeight' => 30));
         }
     }
     $template = '%input%';
     if ($file_exists) {
         $template = '<div style="float:left; margin-right:10px;">%file%</div> %input%<br />%delete% %delete_label%';
     }
     $this->setWidget('image', new sfWidgetFormInputFileEditable(array('file_src' => $path, 'edit_mode' => !$this->isNew(), 'is_image' => true, 'with_delete' => $this->getObject()->image ? true : false, 'template' => $template)));
     $this->setValidator('image', new sfValidatorFile(array('mime_types' => 'web_images', 'required' => false, 'path' => sfConfig::get('sf_upload_dir') . '/variations'), array('mime_types' => 'Wrong type of file... should be a jpg, gif or png.')));
     $this->validatorSchema['position']->setOption('required', false);
     $pattern = '/^[a-zA-Z0-9 (),.:\\"\\/\'&#@\\-\\|!?+=*_]{1,}$/';
     $this->setValidator('title', new sfValidatorRegex(array('pattern' => $pattern, 'required' => false)));
     $this->validatorSchema['title']->setOption('required', false);
 }
 /**
  * Update the response meta values with the data contained within a rtPage object.
  *
  * @param rtPage $rt_page
  * @param sfUser $sf_user
  * @param sfWebResponse $sf_response
  * @return void
  */
 public static function setCommonMetasFromPage(rtPage $rt_page, sfUser $sf_user, sfWebResponse $sf_response)
 {
     $data = array();
     $data['robots'] = $rt_page->getSearchable() ? 'index, follow' : 'NONE';
     $data['keywords'] = implode(', ', $rt_page->getTags());
     $data['title'] = $rt_page->getTitleHead() ? $rt_page->getTitleHead() : $rt_page->getTitle();
     $data['description'] = $rt_page->getDescription();
     $data['og:title'] = $rt_page->getTitle();
     $data['og:type'] = self::getTypeFromObject($rt_page);
     $data['og:url'] = str_replace('frontend_dev.php/', '', rtSiteToolkit::getCurrentDomain(null, true) . rtSiteToolkit::getRequestUri());
     if ($rt_page->getPrimaryImage()) {
         $img_path = rtAssetToolkit::getThumbnailPath($rt_page->getPrimaryImage()->getSystemPath(), array('maxHeight' => 400, 'maxWidth' => 400));
         $data['og:image'] = rtSiteToolkit::getCurrentDomain(null, true) . $img_path;
     }
     if (rtSiteToolkit::getCurrentSite()) {
         $data['og:site_name'] = rtSiteToolkit::getCurrentSite()->getTitle();
     }
     if ($rt_page->getDescription() !== '') {
         $data['og:description'] = $rt_page->getDescription();
     }
     self::setCommonMetas($data, $sf_response);
 }
 requested that we send this e-mail. If you have questions about this item, please visit <?php 
echo link_to($name, url_for($route_name, $object, true));
?>
</p>

<table>
  <tbody>
    <tr>
      <?php 
if ($object->getPrimaryImage()) {
    ?>
        <td><?php 
    $config = sfConfig::get('app_rt_social');
    $img_m_width = isset($config['item_medium']['max_width']) ? $config['item_medium']['max_width'] : 150;
    $img_m_height = isset($config['item_medium']['max_height']) ? $config['item_medium']['max_height'] : 150;
    $img_path = rtAssetToolkit::getThumbnailPath($object->getPrimaryImage()->getWebPath(), array('maxHeight' => $img_m_height, 'maxWidth' => $img_m_width));
    echo link_to(image_tag("http://" . $_SERVER['HTTP_HOST'] . $img_path), url_for($route_name, $object, true));
    ?>
</td>
      <?php 
}
?>
      <td><?php 
echo link_to($name, url_for($route_name, $object, true));
?>
<br /><?php 
echo $object->getDescription();
?>
</td>
    </tr>
  </tbody>
?>
<div class="rt-shop-product-mini">
  <!--RTAS
  <div class="rt-admin-tools">
    <?php 
echo link_to(__('Edit Product'), 'rtShopProductAdmin/edit?id=' . $rt_shop_product->getId());
?>
  </div>
  RTAS-->
  <?php 
echo $mode === 'wishlist' ? link_to(__('Remove from wishlist'), 'rt_shop_show_wishlist', array('delete' => $rt_shop_product->getId()), array('class' => 'delete')) : '';
?>
  <div class="image">
    <?php 
$promo_span = $rt_shop_product->isOnPromotion() ? '<span class="promotion">' . __('On Sale Now') . '</span>' : '';
?>
    <?php 
echo link_to($promo_span . image_tag(rtAssetToolkit::getThumbnailPath($rt_shop_product->getPrimaryImage() ? $rt_shop_product->getPrimaryImage()->getSystemPath() : '', array('maxHeight' => $img_s_height, 'maxWidth' => $img_s_width)), array('class' => 'primary-image')), 'rt_shop_product_show', $rt_shop_product);
?>
  </div>
  <div class="details">
    <h3><?php 
echo link_to($title, 'rt_shop_product_show', $rt_shop_product);
?>
</h3>
    <p class="price"><?php 
echo price_for($rt_shop_product);
?>
</p>
  </div>
</div>
    </a>
  <?php 
    $style = 'display:none';
}
?>
</div>
<?php 
if (count($rt_shop_product->getImages()) > 1) {
    ?>
<div class="rt-shop-product-image-thumbs">
  <?php 
    $i = 1;
    foreach ($rt_shop_product->getImages() as $image) {
        ?>
    <div class="rt-list-item-<?php 
        echo $i;
        ?>
">
      <span>
        <?php 
        echo image_tag(rtAssetToolkit::getThumbnailPath($image->getSystemPath(), array('maxHeight' => 69, 'maxWidth' => 49)), array('class' => 'primary-image-holder-' . $image->getId()));
        ?>
      </span>
    </div>
  <?php 
        $i++;
    }
    ?>
</div>
<?php 
}
use_helper('I18N', 'Text');
?>
<li id="rtAttachedAsset<?php 
echo $asset->getId();
?>
" class="rt-core-upload-item <?php 
echo $asset->isImage() ? 'thumbnail' : 'other';
?>
">
  <div class="rt-core-upload-thumb">
    <div>
      <?php 
if ($asset->isImage()) {
    ?>
        <img src="<?php 
    echo rtAssetToolkit::getThumbnailPath($asset->getSystemPath(), array('maxWidth' => 26, 'maxHeight' => 26));
    ?>
" />
      <?php 
} else {
    ?>
        <img src="<?php 
    echo '/rtCorePlugin/images/mime-types/' . rtAssetToolkit::translateExtensionToBase($asset->getOriginalFilename()) . '.png';
    ?>
" />
      <?php 
}
?>
    </div>
  </div>
  <div class="rt-core-upload-metadata">
 /**
  * Replace occurances of gallery tag with list of attached assets.
  *
  * @param array $matches
  * @return string
  */
 protected function _markupGalleriesInText($matches)
 {
     $config = sfConfig::get('app_rt_gallery');
     if (!isset($config['javascripts'])) {
         $config['javascripts'] = array();
     }
     foreach ($config['javascripts'] as $file) {
         use_javascript($file);
     }
     if (!isset($config['stylesheets'])) {
         $config['stylesheets'] = array();
     }
     foreach ($config['stylesheets'] as $file) {
         use_stylesheet($file);
     }
     $string = '';
     $rand = rand();
     $assets = $this->_options['object']->getAssets();
     if (isset($matches[2])) {
         $asset_names = explode(',', $matches[2]);
         $assets = array();
         foreach ($asset_names as $name) {
             $asset = $this->_options['object']->getAssetByName($name);
             if ($asset) {
                 $assets[] = $asset;
             }
         }
     }
     if (count($assets) > 0) {
         $rand = rand();
         $string .= '<ul class="clearing-thumbs large-block-grid-4 small-block-grid-2" data-clearing>' . "\n";
         foreach ($assets as $asset) {
             if ($asset->isImage()) {
                 $img_preview_height = isset($config['markdown_preview']['max_height']) ? $config['markdown_preview']['max_height'] : 150;
                 $img_preview_width = isset($config['markdown_preview']['max_width']) ? $config['markdown_preview']['max_width'] : 400;
                 $img_full_height = isset($config['markdown_full']['max_height']) ? $config['markdown_full']['max_height'] : 600;
                 $img_full_width = isset($config['markdown_full']['max_width']) ? $config['markdown_full']['max_width'] : 1000;
                 $thumb_location_web = rtAssetToolkit::getThumbnailPath($asset->getSystemPath(), array('maxHeight' => $img_preview_height, 'maxWidth' => $img_preview_width));
                 $thumb_location_sys = sfConfig::get('sf_web_dir') . $thumb_location_web;
                 $title = $asset->getTitle() ? $asset->getTitle() : '';
                 $resize_to = array('maxHeight' => $img_full_height, 'maxWidth' => $img_full_width);
                 $info = '';
                 if (trim($asset->getTitle()) != '') {
                     $info = sprintf('<h3>%s</h3>', $asset->getTitle());
                 }
                 if (trim($asset->getDescription()) != '') {
                     $info .= rtMarkdownToolkit::transformBase($asset->getDescription());
                 }
                 $string .= sprintf('<li><a href="%s" data-caption="%s" rel="gallery-group-%s" class="th">%s</a><div>%s</div></li>', rtAssetToolkit::getThumbnailPath($asset->getSystemPath(), $resize_to), $title, $rand, image_tag($thumb_location_web, array('alt' => $title)), $info);
             }
         }
         $string .= "</ul>\n";
     }
     return $string;
 }
function rt_thumbnail($object, $width = 250, $height = 1000, $options = array())
{
    try {
        $image = $object->getPrimaryImage();
    } catch (Exception $e) {
        return '';
    }
    if (!$image) {
        return '';
    }
    return image_tag(rtAssetToolkit::getThumbnailPath($image->getSystemPath(), array('maxHeight' => $width, 'maxWidth' => $height)), $options);
}
Exemple #9
0
        $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' : '';
    ?>
">
    <td class="rt-shop-cart-primary-image-thumb">
      <?php 
    echo link_to($image, '@rt_shop_product_show?id=' . $stock['rtShopProduct']['id'] . '&slug=' . $stock['rtShopProduct']['slug']);
    ?>
    </td>
    <td class="rt-shop-cart-details">
      <input type="hidden" name="product_id[]" value="<?php 
    echo $stock['rtShopProduct']['id'];
    ?>
    <span class="rt-shop-option-set">

      <?php 
        // Cycle through each variation
        foreach ($variations as $variation) {
            $ref = array();
            $stock_level = 0;
            foreach (Doctrine::getTable('rtShopStock')->getForProductIdAndVariationId($rt_shop_product->getId(), $variation->getId()) as $rt_shop_stock) {
                $stock_level += $rt_shop_stock->quantity;
                if ($rt_shop_stock->quantity > 0 || $rt_shop_product->getBackorderAllowed()) {
                    $ref[] = 'rt-shop-stock-id-' . $rt_shop_stock->id;
                }
            }
            $available = $stock_level > 0;
            $file_location = sfConfig::get('sf_upload_dir') . '/variations/' . $variation->image;
            $image = $rt_shop_attribute->getDisplayImage() && is_file($file_location) ? ' style="background-image: url(' . rtAssetToolkit::getThumbnailPath($file_location, array('maxWidth' => 30, 'maxHeight' => 30)) . ')"' : '';
            // Skip for out of stock options.
            if (!$rt_shop_product->getBackorderAllowed() && !$available) {
                continue;
            }
            ?>

        <input name="rt-shop-variation-ids[<?php 
            echo $i;
            ?>
]" title="<?php 
            echo htmlentities($variation->getTitle());
            ?>
" id="rt-variation-<?php 
            echo $variation->getId();
            ?>
<?php

use_helper('I18N', 'rtText', 'rtTemplate');
$width = isset($options['width']) ? $options['width'] : 1000;
$height = isset($options['height']) ? $options['height'] : 1000;
$snippets = $sf_data->getRaw('snippets');
/** @var $snippets Doctrine_Collection */
if ($snippets && count($snippets) && $snippets->get(0)->getPrimaryImage()) {
    echo rtAssetToolkit::getThumbnailPath($snippets->get(0)->getPrimaryImage()->getSystemPath(), array('maxHeight' => $width, 'maxWidth' => $height));
} else {
}