Example #1
0
 public function updateGalleryConfig()
 {
     if (isset($_POST['Cfg']['predefinedTitle'])) {
         $_POST['Cfg']['predefinedTitle'] = operations::purifiedTtext($_POST['Cfg']['predefinedTitle']);
     }
     $type = $_POST['scenario'];
     $model = new Cfg($type);
     $model->attributes = $_POST['Cfg'];
     if ($model->validate()) {
         $record = GalleryConfig::model()->find(array('condition' => "type='{$type}'"));
         $attributes = array("config" => serialize($_POST['Cfg']));
         $record->saveAttributes($attributes);
         Yii::app()->user->setFlash('succes', $this->tr('successUpdate'));
     } else {
         Yii::app()->user->setFlash('error', $this->tr('errorUpdate'));
     }
 }
Example #2
0
 public function thumb()
 {
     Yii::import('fbgallery.drivers.Image');
     $quality = $this->conf->quality;
     $sharpen = $this->conf->sharpen;
     $imgWidth = $this->conf->imgWidth;
     $thWidth = $this->conf->thWidth;
     //create an array with filenames of files uploaded in tmp folder
     $arrFiles = MyFiles::filesFromDir($this->path->tmp);
     //select the type of resizing
     switch ($this->conf->thumbStyle) {
         case 'square':
             self::square($arrFiles, $quality, $sharpen, $imgWidth, $thWidth);
             break;
         case 'landscape':
             self::landscape($arrFiles, $quality, $sharpen, $imgWidth, $thWidth);
             break;
         case 'portrait':
             self::portrait($arrFiles, $quality, $sharpen, $imgWidth, $thWidth);
             break;
     }
     //after successful create thumbnail, we go to add new pictures filename in database
     operations::addImagesToDB($arrFiles);
 }
Example #3
0
<?php

$info = operations::getInfoAlbumOrCollection();
if ($this->album) {
    $type = 'album';
    $function = 'removeAlbum';
} else {
    $type = 'collection';
    $function = 'removeCollection';
}
$message = str_replace('{album}', $info['name'], $this->tr('confirmRemoveAlbumOrCollection'));
$message = str_replace('{type}', $type, $message);
$this->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'dialogRemoveAlbumOrCollection', 'options' => array('title' => $this->tr($function), 'autoOpen' => false, 'width' => 360, 'resizable' => false, 'buttons' => array($this->tr($function) => 'js:function(){
						$.post("' . Yii::app()->request->requestUri . '", "function=' . $function . '", function(res){
							window.location.reload();
						});
					}', $this->tr("cancel") => 'js:function(){
						$(this).dialog("close")
					}')), 'htmlOptions' => array('class' => 'hide'), 'themeUrl' => $this->url->juiThemeUrl, 'theme' => $this->juiTheme));
echo CHtml::tag('div', array("class" => "containerMessage clearfix"), $message);
$this->endWidget('zii.widgets.jui.CJuiDialog');
Example #4
0
		<?php 
foreach ($this->lang->all as $language) {
    ?>
			<div class="newAlbumLangContainer clearfix">
				<div class="row">
					<?php 
    echo operations::flag($language) . ' ' . CHtml::label($this->tr("newAlbumName"), 'newAlbumName', array());
    ?>
					<br />
					<?php 
    echo CHtml::textField('newAlbumName_' . $language, '', array('class' => 'inputNewAlbum'));
    ?>
				</div>
				<div class="row">
					<?php 
    echo operations::flag($language) . ' ' . CHtml::label($this->tr("newAlbumDescription"), 'newAlbumDescription', array());
    ?>
					<br />
					<?php 
    echo CHtml::textArea('newAlbumDescription_' . $language, '', array('class' => 'inputNewAlbum cle'));
    ?>
				</div>
			</div>
		<?php 
}
?>
		</div>
		<div class="tagsNewGallery clearfix">
			<div class="row">
				<?php 
echo CHtml::label($this->tr("tags"), 'newAlbumTags', array());
Example #5
0
<?php

$this->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'dialogCPAdministrator', 'options' => array('title' => $this->tr('cpanel'), 'dialogClass' => 'hidden', 'autoOpen' => false, 'width' => 720, 'resizable' => false), 'htmlOptions' => array('class' => 'fbCPAdminBox'), 'themeUrl' => $this->url->juiThemeUrl, 'theme' => $this->juiTheme));
$this->render('administrator/cpMenu');
echo '<div class="fbCPanelRightColumn clearfix">';
echo '<div class="formCPFB fbSettingDetails clearfix">';
$this->render('administrator/cpGalleryForm', array('model' => operations::cfgModel('gallery')));
$this->render('administrator/cpAlbumForm', array('model' => operations::cfgModel('album')));
$this->render('administrator/cpCollectionForm', array('model' => operations::cfgModel('collection')));
$this->render('administrator/cpFancyBoxForm', array('model' => operations::cfgModel('fancybox')));
$this->render('administrator/cpUploaderForm', array('model' => operations::cfgModel('uploader')));
$this->render('administrator/loadDefaultConfiguration');
echo '</div>';
echo '</div>';
$this->endWidget('zii.widgets.jui.CJuiDialog');
Example #6
0
 public function uploadFiles()
 {
     // HTTP headers for no cache etc
     header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
     header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
     header("Cache-Control: no-store, no-cache, must-revalidate");
     header("Cache-Control: post-check=0, pre-check=0", false);
     header("Pragma: no-cache");
     // $targetDir = $_REQUEST['target'];
     $targetDir = $this->path->tmp;
     $cleanupTargetDir = false;
     // Remove old files
     $maxFileAge = 60 * 60;
     // Temp file age in seconds
     // 5 minutes execution time
     @set_time_limit(5 * 60);
     //create structure of album if doesn't exists
     if (!file_exists($this->path->tmp)) {
         operations::createFoldersStructure();
     }
     // get parameters
     $chunk = isset($_REQUEST["chunk"]) ? $_REQUEST["chunk"] : 0;
     $chunks = isset($_REQUEST["chunks"]) ? $_REQUEST["chunks"] : 0;
     $fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : '';
     // Clean the fileName for security reasons
     $fileName = MyFiles::cleanFileName($fileName);
     // remove old temporary files
     if (is_dir($targetDir) && ($dir = opendir($targetDir))) {
         while (($file = readdir($dir)) !== false) {
             $filePath = $targetDir . DIRECTORY_SEPARATOR . $file;
             // Remove temp files if they are older than the max age
             if (preg_match('/\\.tmp$/', $file) && filemtime($filePath) < time() - $maxFileAge) {
                 @unlink($filePath);
             }
         }
         closedir($dir);
     } else {
         throw new CHttpException(501, Yii::t('app', "Failed to open temp directory."));
     }
     // make sure the fileName is unique but only if chunking is disabled
     if ($chunks < 2 && file_exists($targetDir . DIRECTORY_SEPARATOR . $fileName)) {
         $fileName = MyFiles::uniqueFilename($targetDir, $fileName);
     }
     // look for the content type header
     if (isset($_SERVER["HTTP_CONTENT_TYPE"])) {
         $contentType = $_SERVER["HTTP_CONTENT_TYPE"];
     }
     if (isset($_SERVER["CONTENT_TYPE"])) {
         $contentType = $_SERVER["CONTENT_TYPE"];
     }
     // handle non multipart uploads older WebKit versions didn't support multipart in HTML5
     if (strpos($contentType, "multipart") !== false) {
         if (isset($_FILES['file']['tmp_name']) && is_uploaded_file($_FILES['file']['tmp_name'])) {
             // Open temp file
             $out = fopen($targetDir . DIRECTORY_SEPARATOR . $fileName, $chunk == 0 ? "wb" : "ab");
             if ($out) {
                 // Read binary input stream and append it to temp file
                 $in = fopen($_FILES['file']['tmp_name'], "rb");
                 if ($in) {
                     while ($buff = fread($in, 4096)) {
                         fwrite($out, $buff);
                     }
                 } else {
                     throw new CHttpException(501, Yii::t('app', "Failed to open input stream."));
                 }
                 fclose($in);
                 fclose($out);
                 @unlink($_FILES['file']['tmp_name']);
             } else {
                 throw new CHttpException(502, Yii::t('app', "Failed to open output stream."));
             }
         } else {
             throw new CHttpException(503, Yii::t('app', "Failed to move uploaded file."));
         }
     } else {
         // Open temp file
         $out = fopen($targetDir . DIRECTORY_SEPARATOR . $fileName, $chunk == 0 ? "wb" : "ab");
         if ($out) {
             // Read binary input stream and append it to temp file
             $in = fopen("php://input", "rb");
             if ($in) {
                 while ($buff = fread($in, 4096)) {
                     fwrite($out, $buff);
                 }
             } else {
                 throw new CHttpException(501, Yii::t('app', "Failed to open input stream."));
             }
             fclose($in);
             fclose($out);
         } else {
             throw new CHttpException(502, Yii::t('app', "Failed to open output stream."));
         }
     }
     if (intval($chunk) + 1 >= intval($chunks)) {
         $file_name = $fileName;
         if (isset($_SERVER['HTTP_CONTENT_DISPOSITION'])) {
             $array = array();
             preg_match('@^attachment; filename="([^"]+)"@', $_SERVER['HTTP_CONTENT_DISPOSITION'], $array);
             if (isset($array[1])) {
                 $file_name = $array[1];
             }
         }
         //begin preparing of pictures to be added in album
         self::doGallery();
     }
 }
Example #7
0
echo Chtml::hiddenField("scenario", $model->scenario);
?>
	<div id="setGalleryAspect" class="containerMessage displaySetting" style="display: block;">
		<div class="titleCategoryRow"><?php 
echo $this->tr('cPanelGallery') . ' - ' . $this->tr('cpAppearance');
?>
</div>
		<div class="row">
			<?php 
echo FBAdmin::helpTooltip('cssTheme');
?>
			<?php 
echo $form->labelEx($model, 'cssTheme');
?>
			<?php 
echo $form->dropDownList($model, 'cssTheme', operations::existingThemes(), array());
?>
			<?php 
echo FBAdmin::getDefaultValue('gallery', 'cssTheme');
?>
		</div>

		<div class="row">
			<?php 
echo FBAdmin::helpTooltip('thumbStyle');
?>
			<?php 
echo $form->labelEx($model, 'thumbStyle');
?>
			<?php 
echo $form->dropDownList($model, 'thumbStyle', array('landscape' => $this->tr('landscape'), 'portrait' => $this->tr('portrait'), 'square' => $this->tr('square')), array());
Example #8
0
 private function publishForLevel()
 {
     $baseUrl = Yii::app()->assetManager->publish($this->path->assets);
     //to register lang for pluploader
     $lang = $this->conf->pluploadLanguage === 'auto' ? Yii::app()->language : $this->conf->pluploadLanguage;
     $runtimes = $this->conf->runtimes;
     //maxim Mb size of file
     $max_file_size = $this->conf->max_file_size;
     //generate unique name for uploaded files
     $unique_names = $this->conf->unique_names;
     //accepted extensions in file selector from uploader
     $extensions = str_replace('|', ',', $this->conf->accept);
     //if unlimited set to 9999
     $maxUploadable = $this->conf->max != -1 ? $this->conf->max : 9999;
     Yii::app()->request->cookies['maxUploadable'] = new CHttpCookie('maxUploadable', $maxUploadable);
     if (is_dir($this->path->assets)) {
         // ------------------ uploader
         Yii::app()->clientScript->registerCoreScript('cookie');
         Yii::app()->clientScript->registerCssFile($baseUrl . '/plupload/jquery.plupload.queue/css/jquery.plupload.queue.css');
         Yii::app()->clientScript->registerCssFile($baseUrl . '/themes/' . $this->conf->cssTheme . '/cpEditor.css');
         if (strpos($runtimes, 'browserplus')) {
             Yii::app()->clientScript->registerScriptFile($baseUrl . '/plupload/browserplus-min.js', CClientScript::POS_END);
         }
         Yii::app()->clientScript->registerScriptFile($baseUrl . '/plupload/plupload.full.js', CClientScript::POS_END);
         if (file_exists($this->path->assets . '/plupload/i18n/' . $lang . '.js')) {
             Yii::app()->clientScript->registerScriptFile($baseUrl . '/plupload/i18n/' . $lang . '.js', CClientScript::POS_END);
         }
         Yii::app()->clientScript->registerScriptFile($baseUrl . '/plupload/jquery.plupload.queue/jquery.plupload.queue.js', CClientScript::POS_END);
         // ----------------- end uploader
         if ($this->conf->useWysiwyg) {
             Yii::app()->clientScript->registerCssFile($baseUrl . '/cleditor/jquery.cleditor.css');
             Yii::app()->clientScript->registerScriptFile($baseUrl . '/cleditor/jquery.cleditor.min.js', CClientScript::POS_END);
             Yii::app()->clientScript->registerScriptFile($baseUrl . '/cleditor/jquery.cleditor.xhtml.min.js', CClientScript::POS_END);
         }
         Yii::app()->clientScript->registerScriptFile($baseUrl . '/jquery.checkbox.min.js', CClientScript::POS_END);
         Yii::app()->clientScript->registerScriptFile($baseUrl . '/jquery.bteditinplace.min.js', CClientScript::POS_END);
         Yii::app()->clientScript->registerScriptFile($baseUrl . '/fbgallery.min.js', CClientScript::POS_END);
         $activeThemeFolder = $this->url->activeThemeFolder;
         Yii::app()->clientScript->registerScript('startGallery', "startGallery('{$activeThemeFolder}'),putUploader('{$baseUrl}','{$max_file_size}','{$unique_names}','{$extensions}','{$runtimes}')", CClientScript::POS_READY);
     } else {
         throw new Exception($this->tr('errFolder'));
     }
     $lang = $this->conf->isMultilingual ? operations::flag($this->lang->active) : false;
     Yii::app()->clientScript->registerScript('editor', "editThumbnailInfo('{$lang}'); removeImages( '" . $this->tr('removeImage') . "', '" . $this->tr('deleteImage') . "', '" . $this->tr('deleteImages') . "', '" . $this->tr('deleteAllImages') . "', '" . $this->tr('ok') . "', '" . $this->tr('cancel') . "', '" . Yii::app()->request->requestUri . "');");
     if ($this->levelAccess === 2) {
         Yii::app()->clientScript->registerCssFile($baseUrl . '/themes/' . $this->conf->cssTheme . '/cpanel.css');
     }
 }