本文整理匯總了PHP中Images::getMaxSizeLimit方法的典型用法代碼示例。如果您正苦於以下問題:PHP Images::getMaxSizeLimit方法的具體用法?PHP Images::getMaxSizeLimit怎麽用?PHP Images::getMaxSizeLimit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Images
的用法示例。
在下文中一共展示了Images::getMaxSizeLimit方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionUpload
public function actionUpload($id)
{
$model = $this->checkOwner($id);
Yii::import("ext.EAjaxUpload.qqFileUploader");
$allowedExtensions = param('allowedImgExtensions', array('jpg', 'jpeg', 'gif', 'png'));
//$sizeLimit = param('maxImgFileSize', 8 * 1024 * 1024);
$sizeLimit = Images::getMaxSizeLimit();
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$path = Yii::getPathOfAlias('webroot.uploads.objects.' . $model->id . '.' . Images::ORIGINAL_IMG_DIR);
$pathMod = Yii::getPathOfAlias('webroot.uploads.objects.' . $model->id . '.' . Images::MODIFIED_IMG_DIR);
$oldUMask = umask(0);
if (!is_dir($path)) {
@mkdir($path, 0777, true);
}
if (!is_dir($pathMod)) {
@mkdir($pathMod, 0777, true);
}
umask($oldUMask);
if (is_writable($path) && is_writable($pathMod)) {
touch($path . DIRECTORY_SEPARATOR . 'index.htm');
touch($pathMod . DIRECTORY_SEPARATOR . 'index.htm');
$result = $uploader->handleUpload($path . DIRECTORY_SEPARATOR, false, uniqid());
if (isset($result['success']) && $result['success']) {
$resize = new CImageHandler();
if ($resize->load($path . DIRECTORY_SEPARATOR . $result['filename'])) {
$resize->thumb(param('maxImageWidth', 1024), param('maxImageHeight', 768), Images::KEEP_PHOTO_PROPORTIONAL)->save();
$image = new Images();
$image->id_object = $model->id;
$image->id_owner = $model->owner_id;
$image->file_name = $result['filename'];
$image->save();
} else {
$result['error'] = 'Wrong image type.';
@unlink($path . DIRECTORY_SEPARATOR . $result['filename']);
}
}
} else {
$result['error'] = 'Access denied.';
}
// to pass data through iframe you will need to encode all html tags
$result = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
echo $result;
}
示例2: actionUpload
public function actionUpload($id)
{
$model = $this->checkOwner($id);
$maxImgs = 0;
# unlimited
$currImgCount = 0;
if (issetModule('tariffPlans') && issetModule('paidservices')) {
$sql = 'SELECT COUNT(id) FROM {{images}} WHERE id_object = ' . $model->id;
$currImgCount = Yii::app()->db->createCommand($sql)->queryScalar();
$userTariffInfo = TariffPlans::getTariffInfoByUserId($model->owner_id);
$maxImgs = $userTariffInfo['limitPhotos'];
if (Yii::app()->user->checkAccess("backend_access")) {
# admin or moderator
$maxImgs = 0;
}
}
if ($maxImgs > 0 && $currImgCount >= $maxImgs) {
$result['error'] = Yii::t("module_tariffPlans", "You are trying to download more than {num} pictures ( your tariff limit )", array("{num}" => $maxImgs));
$result = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
echo $result;
Yii::app()->end();
}
Yii::import("ext.EAjaxUpload.qqFileUploader");
$allowedExtensions = param('allowedImgExtensions', array('jpg', 'jpeg', 'gif', 'png'));
//$sizeLimit = param('maxImgFileSize', 8 * 1024 * 1024);
$sizeLimit = Images::getMaxSizeLimit();
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$path = Yii::getPathOfAlias('webroot.uploads.objects.' . $model->id . '.' . Images::ORIGINAL_IMG_DIR);
$pathMod = Yii::getPathOfAlias('webroot.uploads.objects.' . $model->id . '.' . Images::MODIFIED_IMG_DIR);
$oldUMask = umask(0);
if (!is_dir($path)) {
@mkdir($path, 0777, true);
}
if (!is_dir($pathMod)) {
@mkdir($pathMod, 0777, true);
}
umask($oldUMask);
if (is_writable($path) && is_writable($pathMod)) {
touch($path . DIRECTORY_SEPARATOR . 'index.htm');
touch($pathMod . DIRECTORY_SEPARATOR . 'index.htm');
$result = $uploader->handleUpload($path . DIRECTORY_SEPARATOR, false, uniqid());
if (isset($result['success']) && $result['success']) {
$resize = new CImageHandler();
if ($resize->load($path . DIRECTORY_SEPARATOR . $result['filename'])) {
$resize->thumb(param('maxImageWidth', 1024), param('maxImageHeight', 768), Images::KEEP_PHOTO_PROPORTIONAL)->save();
$image = new Images();
$image->id_object = $model->id;
$image->id_owner = $model->owner_id;
$image->file_name = $result['filename'];
if ($image->save() && $model->hasAttribute('count_img')) {
$model->count_img++;
$model->update('count_img');
}
} else {
$result['error'] = 'Wrong image type.';
@unlink($path . DIRECTORY_SEPARATOR . $result['filename']);
}
}
} else {
$result['error'] = 'Access denied.';
}
// to pass data through iframe you will need to encode all html tags
$result = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
echo $result;
}
示例3: tc
<?php
echo tc('Photos for listing');
?>
:<br/>
<?php
echo '<div class="images-area-admin">';
if ($this->images) {
$this->widget('application.modules.images.components.AdminViewImagesWidget', array('objectId' => $this->objectId, 'images' => $this->images, 'withMain' => $this->withMain));
} else {
echo '<strong>' . tc('Photo gallery is empty.') . '</strong>';
}
echo '</div>';
$this->widget('ext.EAjaxUpload.EAjaxUpload', array('id' => 'uploadFile', 'config' => array('action' => Yii::app()->createUrl('/images/main/upload', array('id' => $this->objectId)), 'allowedExtensions' => param('allowedImgExtensions', array('jpg', 'jpeg', 'gif', 'png')), 'sizeLimit' => Images::getMaxSizeLimit(), 'minSizeLimit' => param('minImgFileSize', 5 * 1024), 'multiple' => true, 'onComplete' => "js:function(id, fileName, responseJSON){ reloadImagesArea(); }", 'messages' => array('typeError' => tc("{file} has invalid extension. Only {extensions} are allowed."), 'sizeError' => tc("{file} is too large, maximum file size is {sizeLimit}."), 'minSizeError' => tc("{file} is too small, minimum file size is {minSizeLimit}."), 'emptyError' => tc("{file} is empty, please select files again without it."), 'onLeave' => tc("The files are being uploaded, if you leave now the upload will be cancelled.")))));
$this->widget('ext.charcounter.CharCounter', array('target' => '.image-comment-input > textarea', 'count' => 255, 'config' => array('container' => '<div></div>', 'format' => CJavaScript::quote(tc('Characters left')) . ': %1')));
Yii::app()->clientScript->registerScript('images-reloader', '
function reInitJs(){
$(".images-area-admin .fancy").fancybox();
$(".image-comment-input > textarea").charCounter(255, {
container: "<div></div>",
format: "' . CJavaScript::quote(tc('Characters left')) . ': %1"
});
if($(".images-area").find(".image-item").length == 0){
$(".images-area-admin").html("' . CJavaScript::quote(tc('Photo gallery is empty.')) . '");
}
}
$(".setAsMainLink").live("click", function(){
var id = $(this).closest(".setAsMain").attr("link-id");
$.ajax({
url: "' . Yii::app()->controller->createUrl('/images/main/setMainImage') . '?id="+id,