예제 #1
0
파일: AStep.php 프로젝트: kirkbauer2/kirkxc
 /**
  * Run export step
  *
  * @return boolean
  */
 public function run()
 {
     $time = microtime(true);
     $row = $this->getItems()->current();
     $this->processModel($row[0]);
     $this->generator->getOptions()->time += round(microtime(true) - $time, 3);
     return true;
 }
예제 #2
0
 /**
  * Correct options list
  *
  * @param array $options Options list (list of images sizes)
  *
  * @return array
  */
 protected function prepareOptions($options)
 {
     $editableSizes = \XLite\Logic\ImageResize\Generator::getEditableImageSizes();
     $allSizes = \XLite\Logic\ImageResize\Generator::getImageSizes();
     if ($editableSizes) {
         $needUpdate = false;
         // Prepare temporary array for checking
         $tmp = array();
         foreach ($editableSizes as $model => $opt) {
             foreach ($opt as $code) {
                 $tmp[sprintf('%s-%s', $model, $code)] = array('model' => $model, 'code' => $code, 'size' => $allSizes[$model][$code]);
             }
         }
         $existingSizes = array();
         // Search for options which must be removed
         foreach ($options as $key => $option) {
             $testKey = sprintf('%s-%s', $option->getModel(), $option->getCode());
             if (!isset($tmp[$testKey])) {
                 // Found size which is not present in the list of editable sizes - prepare to remove this
                 $toDelete[$option->getId()] = $option;
                 $needUpdate = true;
             } else {
                 // Keep option in the list of sizes presented in the database and not scheduled to be removed
                 $existingSizes[$testKey] = $option->getId();
             }
         }
         // Search for image sizes which should be added to the database
         foreach ($tmp as $k => $v) {
             if (!isset($existingSizes[$k])) {
                 // Found an option which is not presented in the database - prepare to add this
                 $entity = new \XLite\Model\ImageSettings();
                 $entity->setModel($v['model']);
                 $entity->setCode($v['code']);
                 $entity->setWidth($v['size'][0]);
                 $entity->setHeight($v['size'][1]);
                 $toInsert[] = $entity;
                 $needUpdate = true;
             }
         }
         if (!empty($toInsert)) {
             // Create new image sizes
             \XLite\Core\Database::getRepo('XLite\\Model\\ImageSettings')->insertInBatch($toInsert);
         }
         if (!empty($toDelete)) {
             // Remove obsolete image sizes
             \XLite\Core\Database::getRepo('XLite\\Model\\ImageSettings')->deleteInBatchById($toDelete);
         }
         if ($needUpdate) {
             \XLite\Core\Database::getEM()->clear();
             $options = \XLite\Core\Database::getRepo('XLite\\Model\\ImageSettings')->findAll();
         }
     } else {
         $options = array();
     }
     return $options;
 }
예제 #3
0
 /**
  * Register image sizes
  *
  * @return void
  */
 public static function registerImageSizes()
 {
     $sizes = static::getImageSizes();
     if ($sizes) {
         \XLite\Logic\ImageResize\Generator::addImageSizes($sizes);
     }
 }
예제 #4
0
 /**
  * Get icon sizes
  *
  * @return array
  */
 public static function getIconSizes()
 {
     $model = \XLite\Logic\ImageResize\Generator::MODEL_PRODUCT;
     return array(static::WIDGET_TYPE_SIDEBAR . '.' . static::DISPLAY_MODE_STHUMB => \XLite\Logic\ImageResize\Generator::getImageSizes($model, 'SBSmallThumbnail'), static::WIDGET_TYPE_SIDEBAR . '.' . static::DISPLAY_MODE_BTHUMB => \XLite\Logic\ImageResize\Generator::getImageSizes($model, 'SBBigThumbnail'), static::WIDGET_TYPE_CENTER . '.' . static::DISPLAY_MODE_GRID => \XLite\Logic\ImageResize\Generator::getImageSizes($model, 'LGThumbnailGrid'), static::WIDGET_TYPE_CENTER . '.' . static::DISPLAY_MODE_LIST => \XLite\Logic\ImageResize\Generator::getImageSizes($model, 'LGThumbnailList'), 'other' => \XLite\Logic\ImageResize\Generator::getImageSizes($model, 'CommonThumbnail'));
 }
예제 #5
0
파일: Image.php 프로젝트: kewaunited/xcart
 /**
  * Resize images
  *
  * @return void
  */
 public function prepareSizes()
 {
     $this->doResizeAll(\XLite\Logic\ImageResize\Generator::getModelImageSizes(get_class($this)));
 }
예제 #6
0
 /**
  * Get default max product image width
  *
  * @param boolean $width If true method will return width else - height
  * @param string  $model Model class name
  * @param string  $code  Image sizes code, see \XLite\Logic\ImageResize\Generator::defineImageSizes()
  *
  * @return integer
  */
 public function getDefaultMaxImageSize($width = true, $model = null, $code = null)
 {
     if (is_null($model)) {
         $model = \XLite\Logic\ImageResize\Generator::MODEL_PRODUCT;
     }
     if (is_null($code)) {
         $code = 'Default';
     }
     $resizeData = \XLite\Logic\ImageResize\Generator::getImageSizes($model, $code);
     $id = intval(!$width);
     // $resizeData[0] - width, $resizeData[1] - height
     return isset($resizeData[$id]) ? $resizeData[$id] : 0;
 }
예제 #7
0
 /**
  * Get export cancel flag name
  *
  * @return string
  */
 protected function getImageResizeCancelFlagVarName()
 {
     return \XLite\Logic\ImageResize\Generator::getResizeCancelFlagVarName();
 }
예제 #8
0
 /**
  * Get default max product image width
  *
  * @param boolean $width If true method will return width else - height
  * @param string  $model Model class name
  * @param string  $code  Image sizes code, see \XLite\Logic\ImageResize\Generator::defineImageSizes()
  *
  * @return integer
  */
 public function getDefaultMaxImageSize($width = true, $model = null, $code = null)
 {
     if (is_null($model)) {
         $model = \XLite\Logic\ImageResize\Generator::MODEL_PRODUCT;
     }
     if (is_null($code)) {
         $code = 'Default';
     }
     $resizeData = \XLite\Logic\ImageResize\Generator::getImageSizes($model, $code);
     return isset($resizeData[0]) ? $resizeData[0] : 0;
 }
예제 #9
0
 /**
  * Get export event name
  *
  * @return string
  */
 protected function getEventName()
 {
     return \XLite\Logic\ImageResize\Generator::getEventName();
 }
예제 #10
0
 /**
  * Define steps
  *
  * @return array
  */
 protected function defineSteps()
 {
     $list = parent::defineSteps();
     $list[] = 'XLite\\Module\\XC\\ProductVariants\\Logic\\ImageResize\\Step\\ProductVariants';
     return $list;
 }