Пример #1
0
 /**
  * Update plugin configuration
  */
 public function updateConfig()
 {
     $this->checkCsrfToken();
     $oldVars = $this->plugin->getVars();
     $thumb_dir = $this->request->getPost()->get('thumb_dir');
     if (!empty($thumb_dir) && $thumb_dir !== $oldVars['thumb_dir']) {
         $result = $this->plugin->setupThumbDir($thumb_dir);
         if ($result) {
             $this->plugin->getManager()->cleanupThumbs(true);
             CacheUtil::removeLocalDir($oldVars['thumb_dir']);
             $this->plugin->setVar('thumb_dir', $thumb_dir);
         } else {
             LogUtil::registerError($this->__('Error! Could not change thumbnails storage directory.'));
         }
     }
     $thumb_auto_cleanup = (bool) $this->request->request->get('thumb_auto_cleanup');
     $this->plugin->setVar('thumb_auto_cleanup', $thumb_auto_cleanup);
     $thumb_auto_cleanup_period = $this->request->request->get('thumb_auto_cleanup_period');
     $this->plugin->setVar('thumb_auto_cleanup_period', $thumb_auto_cleanup_period);
     $presets = $this->request->getPost()->get('presets', array());
     $presetsToSave = array();
     foreach ($presets as $preset) {
         // validate jpeg qual and png_compression
         if (!is_numeric($preset['options']['jpeg_quality']) || $preset['options']['jpeg_quality'] < 0 || $preset['options']['jpeg_quality'] > 100) {
             $preset['options']['jpeg_quality'] = 75;
             // default 75%
         }
         if (!is_numeric($preset['options']['png_compression_level']) || $preset['options']['png_compression_level'] < 0 || $preset['options']['png_compression_level'] > 9) {
             $preset['options']['png_compression_level'] = 7;
             // default 7
         }
         $name = $preset['name'];
         if (!empty($name)) {
             $presetsToSave[$name] = new SystemPlugin_Imagine_Preset($name, $preset);
         }
     }
     $this->plugin->setVar('presets', $presetsToSave);
     $this->registerStatus($this->__('Done! Saved plugin configuration.'));
     $this->redirect(ModUtil::url('ZikulaExtensionsModule', 'adminplugin', 'dispatch', array('_plugin' => 'Imagine', '_action' => 'configure')));
 }
Пример #2
0
    /**
     * Update plugin configuration
     */
    public function updateConfig()
    {
        $this->checkCsrfToken();
        $oldVars = $this->plugin->getVars();

        $thumb_dir = $this->request->getPost()->get('thumb_dir');
        if (!empty($thumb_dir) && $thumb_dir !== $oldVars['thumb_dir']) {
            $result = $this->plugin->setupThumbDir($thumb_dir);
            if ($result) {
                $this->plugin->getManager()->cleanupThumbs(true);
                CacheUtil::removeLocalDir($oldVars['thumb_dir']);
                $this->plugin->setVar('thumb_dir', $thumb_dir);
            } else {
                LogUtil::registerError($this->__('Error! Could not change thumbnails storage directory.'));
            }
        }

        $thumb_auto_cleanup = (bool)$this->request->getPost()->get('thumb_auto_cleanup');
        $this->plugin->setVar('thumb_auto_cleanup', $thumb_auto_cleanup);

        $presets = $this->request->getPost()->get('presets', array());

        $presetsToSave = array();
        foreach ($presets as $preset) {
            $name = $preset['name'];
            if (!empty($name)) {
                $presetsToSave[$name] = new SystemPlugin_Imagine_Preset($name, $preset);
            }
        }

        $this->plugin->setVar('presets', $presetsToSave);

        LogUtil::registerStatus($this->__('Done! Saved plugin configuration.'));

        $this->redirect(ModUtil::url('Extensions', 'adminplugin', 'dispatch', array(
            '_plugin' => 'Imagine',
            '_action' => 'configure'
        )));
    }