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);
 }
 /**
  * Return a list of allowed mime-types allowed for upload.
  *
  * @return array
  */
 public function getAllowedMimeTypes()
 {
     if ($this->getOption('allowed_mime_types')) {
         return $this->getOption('allowed_mime_types');
     }
     return sfConfig::get('app_rt_asset_allowed_mime_types', rtAssetToolkit::getCommonMimeTypes());
 }
 private static function getCacheDir()
 {
     $dir = sfConfig::get('app_rt_math_cache_dir', '/uploads/_math_cache');
     if (!is_dir(sfConfig::get('sf_web_dir') . $dir)) {
         rtAssetToolkit::makeDir(sfConfig::get('sf_web_dir') . $dir);
     }
     return sfConfig::get('sf_web_dir') . $dir;
 }
 /**
  * Return a string, after replacing Latex math sections with n image equivelant.
  *
  * @param   string  $text
  * @return  string
  */
 public static function transform($text)
 {
     if (trim($text) === '') {
         return $text;
     }
     // relative from the sf_web_root
     $dir = sfConfig::get('app_rt_math_cache_dir', '/uploads/_math_cache');
     $size = sfConfig::get('app_rt_math_mathpublisher_size', 14);
     if (!is_dir(sfConfig::get('sf_web_dir') . $dir)) {
         rtAssetToolkit::makeDir(sfConfig::get('sf_web_dir') . $dir);
     }
     $dir = $dir . '/';
     try {
         $text = mathfilter($text, $size, $dir);
     } catch (Exception $e) {
         // eat the exception
     }
     return $text;
 }
 /**
  * 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);
 }
?>
<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>
Example #7
0
    </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 
}
Example #8
0
    echo '/rtCorePlugin/images/mime-types/' . rtAssetToolkit::translateExtensionToBase($asset->getOriginalFilename()) . '.png';
    ?>
" />
      <?php 
}
?>
    </div>
  </div>
  <div class="rt-core-upload-metadata">
    <?php 
echo truncate_text($asset->getOriginalFilename(), 30);
?>
<br />
    <span>
      <?php 
echo rtAssetToolkit::getFormattedBytes($asset->getFilesize());
?>
 - 
      <a href="#" class="edit-button" onclick="editAsset('<?php 
echo $asset->getId();
?>
', '<?php 
echo $asset->getOriginalFilename();
?>
')">edit</a>
    </span>
  </div>
<?php 
$open = '\\n[';
$close = sprintf('](asset:%s)\\n', $asset->getOriginalFilename());
if ($asset->isImage()) {
 /**
  * Replace occurances of docs tag with list of attached assets.
  *
  * @param array $matches
  * @return string
  */
 protected function _markupDocsInText($matches)
 {
     $string = '';
     $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) {
         $string .= '<div class="rt-docs-holder"><ul class="rt-docs">';
         foreach ($assets as $asset) {
             if ($asset->isImage()) {
                 continue;
             }
             $title = trim($asset->getTitle()) !== '' ? $asset->getTitle() : $asset->getOriginalFilename();
             $description = '';
             if (trim($asset->getDescription()) !== '') {
                 $description = rtMarkdownToolkit::transformBase($asset->getDescription());
             }
             $string .= sprintf('<li class="rt-docs-%s"><span class="rt-docs-title">%s%s</span>%s</li>', $asset->getExtension(), link_to($title, $asset->getWebPath()), sprintf(' <span class="rt-docs-fiesize">(%s)</span>', rtAssetToolkit::getFormattedBytes($asset->getFilesize())), $description);
         }
         $string .= "\n</ul>\n</div>\n";
     }
     return $string;
 }
 /**
  * Retrieve the files content.
  *
  * @param strinf $string
  */
 public function setFileContent($content)
 {
     rtAssetToolkit::putContents($this->getSystemPath(), $content);
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $env = 'cdn';
     $ini = sfConfig::get('sf_config_dir') . '/properties.ini';
     if (!file_exists($ini)) {
         throw new sfCommandException('You must create a config/properties.ini file');
     }
     $properties = parse_ini_file($ini, true);
     if (!isset($properties[$env])) {
         throw new sfCommandException(sprintf('You must define the configuration for server "%s" in config/properties.ini', $env));
     }
     $properties = $properties[$env];
     if (!isset($properties['host'])) {
         throw new sfCommandException('You must define a "host" entry.');
     }
     if (!isset($properties['dir'])) {
         throw new sfCommandException('You must define a "dir" entry.');
     }
     $host = $properties['host'];
     $dir = $properties['dir'];
     $user = isset($properties['user']) ? $properties['user'] . '@' : '';
     if (substr($dir, -1) != '/') {
         $dir .= '/';
     }
     $ssh = 'ssh';
     if (isset($properties['port'])) {
         $port = $properties['port'];
         $ssh = '"ssh -p' . $port . '"';
     }
     if (isset($properties['parameters'])) {
         $parameters = $properties['parameters'];
     } else {
         $parameters = $options['rsync-options'];
         if (file_exists($options['rsync-dir'] . '/rsync_exclude.txt')) {
             $parameters .= sprintf(' --exclude-from=%s/rsync_exclude.txt', $options['rsync-dir']);
         }
         if (file_exists($options['rsync-dir'] . '/rsync_include.txt')) {
             $parameters .= sprintf(' --include-from=%s/rsync_include.txt', $options['rsync-dir']);
         }
         if (file_exists($options['rsync-dir'] . '/rsync.txt')) {
             $parameters .= sprintf(' --files-from=%s/rsync.txt', $options['rsync-dir']);
         }
     }
     $dryRun = $options['go'] ? '' : '--dry-run';
     $web_dir = sfConfig::get('sf_web_dir') . '/';
     $command = "rsync {$dryRun} {$parameters} -e {$ssh} {$web_dir} {$user}{$host}:{$dir}";
     $this->getFilesystem()->execute($command, $options['trace'] ? array($this, 'logOutput') : null, array($this, 'logErrors'));
     $this->clearBuffers();
     $tag = rtAssetToolkit::getCdnTagFilename();
     if (is_file($tag)) {
         unlink($tag);
     }
     file_put_contents($tag, time());
     chmod($tag, 0775);
     chown($tag, fileowner(sfConfig::get('sf_data_dir')));
     chgrp($tag, filegroup(sfConfig::get('sf_data_dir')));
 }
Example #12
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 {
}
 public function executeClearCache(sfWebRequest $request)
 {
     $sf_root_cache_dir = sfConfig::get('sf_cache_dir');
     rtAssetToolkit::recursiveDelete($sf_root_cache_dir . DIRECTORY_SEPARATOR . 'frontend');
     $this->redirect($request->getReferer());
 }
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);
}
Example #17
0
 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>
 /**
  * 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;
 }