本文整理匯總了PHP中Images::getMainImageData方法的典型用法代碼示例。如果您正苦於以下問題:PHP Images::getMainImageData方法的具體用法?PHP Images::getMainImageData怎麽用?PHP Images::getMainImageData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Images
的用法示例。
在下文中一共展示了Images::getMainImageData方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: genImgForSlider
public static function genImgForSlider($apartmentId)
{
$mainImage = Images::getMainImageData(null, $apartmentId);
if ($mainImage) {
$imgName = $mainImage['file_name'];
Yii::import('application.extensions.image.Image');
$pathImg = DIRECTORY_SEPARATOR . Images::UPLOAD_DIR . DIRECTORY_SEPARATOR . Images::OBJECTS_DIR . DIRECTORY_SEPARATOR . $apartmentId . DIRECTORY_SEPARATOR . Images::ORIGINAL_IMG_DIR . DIRECTORY_SEPARATOR . $imgName;
$sliderDir = DIRECTORY_SEPARATOR . Images::UPLOAD_DIR . DIRECTORY_SEPARATOR . Images::OBJECTS_DIR . DIRECTORY_SEPARATOR . $apartmentId . DIRECTORY_SEPARATOR . Images::MODIFIED_IMG_DIR . DIRECTORY_SEPARATOR;
if ($mainImage['file_name_modified']) {
$name = $mainImage['file_name_modified'];
} else {
$name = Images::updateModifiedName($mainImage);
}
$sliderImgName = 'thumb_' . param('slider_img_width', 500) . 'x' . param('slider_img_height', 280) . '_' . $name;
$pathImgSlider = $sliderDir . DIRECTORY_SEPARATOR . $sliderImgName;
if (!is_dir(ROOT_PATH . $sliderDir)) {
@mkdir(ROOT_PATH . $sliderDir);
}
@unlink(ROOT_PATH . $pathImgSlider);
if (!file_exists(ROOT_PATH . $pathImgSlider)) {
$image = new Image(ROOT_PATH . $pathImg);
$image->resizeWithEffect(param('slider_img_width', 500), param('slider_img_height', 280));
$image->save(ROOT_PATH . $pathImgSlider);
return true;
} else {
return true;
}
}
return false;
}
示例2: actionIndex
//.........這裏部分代碼省略.........
}
if ($user->balance < $paidOption->price) {
Yii::app()->user->setFlash('error', tc('Please refill the balance'));
$error = 2;
}
}
}
}
$paysystem->createPayModel();
if ($paysystem->payModel === null) {
throw404();
}
if ($error == 0) {
// Создаем платеж и ставим ему статус "Ожидает оплаты"
$payment = new Payments();
$payment->user_id = Yii::app()->user->id;
$payment->paid_id = $paid_id;
if ($paid_id != PaidServices::ID_ADD_FUNDS) {
$payment->paid_option_id = $paidOption->id;
}
$payment->apartment_id = $ad_id;
$payment->tariff_id = $tariffId;
if ($tariffId && issetModule('tariffPlans')) {
$payment->amount = $tariffPlanInfo['price'];
} else {
$payment->amount = $paid_id == PaidServices::ID_ADD_FUNDS ? $amount : $paidOption->price;
}
$payment->currency_charcode = Currency::getDefaultCurrencyModel()->char_code;
$payment->status = Payments::STATUS_WAITPAYMENT;
$payment->paysystem_id = $paysystem->id;
$payment->save();
/*echo '<pre>';
print_r($payment->getErrors());
echo '</pre>';
exit;*/
// Передаем платеж на обработку в модель платежки.
// Приложение либо звершается (происходит редирект по нужному адресу),
// либо выдает сообщение, которое будет отображено пользователю
$return = $paysystem->payModel->processPayment($payment);
switch ($return['status']) {
case Paysystem::RESULT_OK:
Yii::app()->user->setFlash('success', $return['message']);
$this->redirect(array('/usercpanel/main/payments'));
break;
case Paysystem::RESULT_NOTICE:
Yii::app()->user->setFlash('notice', $return['message']);
$this->redirect(array('/userads/main/update', 'id' => $payment->apartment_id));
break;
case Paysystem::RESULT_ERROR:
Yii::app()->user->setFlash('error', $return['message']);
$this->redirect(array('/userads/main/update', 'id' => $payment->apartment_id));
break;
default:
$this->render('result', array('payment' => $payment, 'paysystem' => $paysystem, 'message' => $return['message']));
}
echo 'Loading ... ';
exit;
}
}
if ($paid_id != PaidServices::ID_ADD_FUNDS) {
$apartment = Apartment::model()->findByPk($ad_id);
if ($apartment->active != Apartment::STATUS_ACTIVE || $apartment->owner_active != 1) {
echo '<h2>' . tt('To apply a paid service for the listing, it should be active.', 'paidservices') . '</h2>';
exit;
}
}
$paidService = PaidServices::model()->findByPk($paid_id);
if (!$paidService || !$paidService->active) {
throw404();
}
if ($paid_id == PaidServices::ID_ADD_IN_SLIDER) {
$img = Images::getMainImageData(null, $apartment->id);
if (!$img) {
Yii::app()->user->setFlash('error', tt('Error! You must upload the image for the ad.', 'paidservices'));
if (!$isFancy) {
$this->redirect(array('/userads/main/update', 'id' => $ad_id));
} else {
echo tt('Error! You must upload the image for the ad.', 'paidservices');
}
Yii::app()->end();
}
}
if (!isset($user)) {
$user = User::model()->findByPk(Yii::app()->user->id);
}
if ($isFancy || Yii::app()->request->isAjaxRequest) {
$this->excludeJs();
if ($tariffId && issetModule('tariffPlans')) {
$this->redirect(array('/tariffPlans/main/index'));
} else {
$this->renderPartial('paidform', array('paidService' => $paidService, 'user' => $user, 'ad_id' => $ad_id, 'isFancy' => true), false, true);
}
} else {
if ($tariffId && issetModule('tariffPlans')) {
$this->redirect(array('/tariffPlans/main/index'));
} else {
$this->render('paidform', array('paidService' => $paidService, 'user' => $user, 'ad_id' => $ad_id, 'isFancy' => false));
}
}
}