本文整理汇总了PHP中yii\helpers\Url::base方法的典型用法代码示例。如果您正苦于以下问题:PHP Url::base方法的具体用法?PHP Url::base怎么用?PHP Url::base使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\Url
的用法示例。
在下文中一共展示了Url::base方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionUpload_product
public function actionUpload_product()
{
if (Yii::$app->request->isAjax) {
$model = new ProductCategory();
$Product = new Product();
$ProductImageRel = new ProductImageRel();
$ProductCategoryRel = new ProductCategoryRel();
$model_cat_title = UploadedFile::getInstance($model, 'cat_title');
$time = time();
$model_cat_title->saveAs('product_uploads/' . $time . $model_cat_title->baseName . '.' . $model_cat_title->extension);
if ($model_cat_title) {
$response = [];
$Product->title = $_POST['title'];
$Product->desc = $_POST['desc'];
$Product->status = 1;
if ($Product->save()) {
$ProductCategoryRel->category_id = $_POST['id'];
$ProductCategoryRel->product_id = $Product->id;
$ProductImageRel->product_id = $Product->id;
$ProductImageRel->image = $time . $model_cat_title->baseName . '.' . $model_cat_title->extension;
if ($ProductCategoryRel->save() && $ProductImageRel->save()) {
$response['files'][] = ['name' => $time . $model_cat_title->name, 'type' => $model_cat_title->type, 'size' => $model_cat_title->size, 'url' => Url::base() . '/product_uploads/' . $time . $model_cat_title->baseName . '.' . $model_cat_title->extension, 'deleteUrl' => Url::to(['delete_uploaded_file', 'file' => $model_cat_title->baseName . '.' . $model_cat_title->extension]), 'deleteType' => 'DELETE'];
$response['base'] = $time . $model_cat_title->baseName;
$response['view'] = $this->renderAjax('uploaded_product', ['url' => Url::base() . '/product_uploads/' . $time . $model_cat_title->baseName . '.' . $model_cat_title->extension, 'basename' => $time . $model_cat_title->baseName, 'id' => $ProductImageRel->id, 'model' => $Product]);
}
} else {
$response['errors'] = $product->getErrors();
}
return json_encode($response);
}
}
}
示例2: afterUpdate
public function afterUpdate()
{
try {
if ($this->seoText->load(Yii::$app->request->post())) {
$this->seoText->setAttributes(['_image' => UploadedFile::getInstance($this->seoText, '_image')]);
// if(!$this->seoText->isEmpty()){
if ($this->seoText->save()) {
if ($this->seoText->_image) {
$old = $this->seoText->ogImage;
$photo = new Photo();
$photo->class = get_class($this->seoText);
$photo->item_id = $this->seoText->seotext_id;
$photo->image = $this->seoText->_image;
if ($photo->image && $photo->validate(['image'])) {
$photo->image = Image::upload($photo->image, 'photos', Photo::PHOTO_MAX_WIDTH);
if ($photo->image) {
if ($photo->save()) {
$old->delete();
} else {
@unlink(Yii::getAlias('@webroot') . str_replace(Url::base(true), '', $photo->image));
}
} else {
}
}
}
}
}
} catch (UnknownMethodException $e) {
}
}
示例3: actionUpdate
public function actionUpdate($id)
{
$model = $this->loadModel($id);
$uploadImg = new UploadForm();
if (Yii::$app->request->isPost) {
$uploadImg->img = UploadedFile::getInstance($uploadImg, 'img');
if ($uploadImg->img && $uploadImg->validate()) {
$uploadImg->img->saveAs('uploads/covers/' . Yii::$app->translater->translit($uploadImg->img->baseName) . '.' . $uploadImg->img->extension);
} else {
print_r($uploadImg->getErrors());
}
}
if ($model->load(Yii::$app->request->post())) {
$model->title = Yii::$app->request->post('Source')['title'];
$model->author_id = Yii::$app->request->post('Source')['author_id'];
$model->status = Yii::$app->request->post('Source')['status'];
$model->cat_id = Yii::$app->request->post('Source')['cat_id'];
if (isset($uploadImg->img)) {
$model->cover = Url::base() . 'uploads/covers/' . Yii::$app->translater->translit($uploadImg->img->baseName) . '.' . $uploadImg->img->extension;
}
$model->save(false);
return $this->redirect(Url::toRoute('source/index'));
} else {
return $this->render('_form', ['model' => $model, 'uploadImg' => $uploadImg]);
}
}
示例4: actionUpdate
public function actionUpdate($id)
{
$model = $this->loadModel($id);
$uploadImg = new UploadForm();
if (Yii::$app->request->isPost) {
$uploadImg->img = UploadedFile::getInstance($uploadImg, 'img');
if ($uploadImg->img && $uploadImg->validate()) {
$uploadImg->img->saveAs('uploads/' . Yii::$app->translater->translit($uploadImg->img->baseName) . '.' . $uploadImg->img->extension);
} else {
print_r($uploadImg->getErrors());
}
}
//var_dump($uploadImg); exit;
if ($model->load(Yii::$app->request->post())) {
$model->name = Yii::$app->request->post('Products')['name'];
$model->cat_id = Yii::$app->request->post('Products')['cat_id'];
$model->price = Yii::$app->request->post('Products')['price'];
$model->description = Yii::$app->request->post('Products')['description'];
if (isset($uploadImg->img)) {
$model->photo = Url::base() . 'uploads/' . Yii::$app->translater->translit($uploadImg->img->baseName) . '.' . $uploadImg->img->extension;
}
$model->save();
return $this->redirect(Url::toRoute('products/index'));
} else {
return $this->render('_form', ['model' => $model, 'uploadImg' => $uploadImg]);
}
}
示例5: sendCalendarInvite
/**
* @param Schedule $schedule
* @return bool
* @throws \yii\web\BadRequestHttpException
*/
public static function sendCalendarInvite($schedule)
{
if ($schedule->className() !== Schedule::className()) {
throw new BadRequestHttpException('Invalid request');
}
//Create Email Headers
$mime_boundary = '----Meeting Booking----' . MD5(TIME());
$headers = "From: " . self::$from_name . " <" . self::$from_address . ">\n";
$headers .= "Reply-To: " . self::$from_name . " <" . self::$from_address . ">\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/alternative; boundary=\"{$mime_boundary}\"\n";
$headers .= "Content-class: urn:content-classes:calendarmessage\n";
//Create Email Body (HTML)
$message = "--{$mime_boundary}\r\n";
$message .= "Content-Type: text/html; charset=UTF-8\n";
$message .= "Content-Transfer-Encoding: 8bit\n\n";
$message .= "<html>\n";
$message .= "<body>\n";
$message .= '<p>' . $schedule->description . '</p>';
$message .= "<h4>Tickets:</h4>\n";
$message .= "<ul>\n";
foreach ($schedule->notes as $note) {
$message .= '<li>' . Html::a($note->ticket->fullName, Url::base(true) . Url::to(['/ticket/view', 'id' => $note->ticket_id])) . "</li>\n";
}
$message .= "</ul>\n";
$message .= '(' . Html::a('view calendar event', Url::to(['/schedule/view', 'id' => $schedule->id], true)) . ")\n";
$message .= "</body>\n";
$message .= "</html>\n";
$message .= "--{$mime_boundary}\r\n";
$message .= 'Content-Type: text/calendar;name="meeting.ics";method=REQUEST' . "\n";
$message .= "Content-Transfer-Encoding: 8bit\n\n";
$message .= 'BEGIN:VCALENDAR' . "\r\n" . 'METHOD:REQUEST' . "\r\n" . 'PRODID:-//Microsoft Corporation//Outlook 10.0 MIMEDIR//EN' . "\r\n" . 'VERSION:2.0' . "\r\n" . 'BEGIN:VTIMEZONE' . "\r\n" . 'TZID:Pacific Standard Time' . "\r\n" . 'BEGIN:STANDARD' . "\r\n" . 'DTSTART:16010101T020000' . "\r\n" . 'TZOFFSETFROM:-0700' . "\r\n" . 'TZOFFSETTO:-0800' . "\r\n" . 'RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11' . "\r\n" . 'END:STANDARD' . "\r\n" . 'BEGIN:DAYLIGHT' . "\r\n" . 'DTSTART:16010101T020000' . "\r\n" . 'TZOFFSETFROM:-0800' . "\r\n" . 'TZOFFSETTO:-0700' . "\r\n" . 'RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3' . "\r\n" . 'END:DAYLIGHT' . "\r\n" . 'END:VTIMEZONE' . "\r\n" . 'BEGIN:VEVENT' . "\r\n" . 'ORGANIZER;CN="' . $schedule->createdBy->name . '":MAILTO:' . self::$from_address . "\r\n" . 'ATTENDEE;CN="' . $schedule->tech->name . '";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:' . $schedule->tech->email . "\r\n" . 'LAST-MODIFIED:' . date("Ymd\\TGis") . "\r\n" . 'UID:' . date("Ymd\\TGis", strtotime($schedule->start_time)) . rand() . "@" . self::$domain . "\r\n" . 'DTSTAMP:' . date("Ymd\\TGis") . "\r\n" . 'DTSTART;TZID="Pacific Standard Time":' . date("Ymd\\THis", strtotime($schedule->start_time)) . "\r\n" . 'DTEND;TZID="Pacific Standard Time":' . date("Ymd\\THis", strtotime($schedule->endTime)) . "\r\n" . 'TRANSP:OPAQUE' . "\r\n" . 'SEQUENCE:1' . "\r\n" . 'SUMMARY:' . $schedule->invoice->location->fullName . "\r\n" . 'LOCATION:' . $schedule->invoice->location->address . "\r\n" . 'CLASS:PUBLIC' . "\r\n" . 'PRIORITY:5' . "\r\n" . 'BEGIN:VALARM' . "\r\n" . 'TRIGGER:-PT60M' . "\r\n" . 'ACTION:DISPLAY' . "\r\n" . 'DESCRIPTION:Reminder' . "\r\n" . 'END:VALARM' . "\r\n" . 'END:VEVENT' . "\r\n" . 'END:VCALENDAR' . "\r\n";
return self::send($schedule->tech->email, $schedule->invoice->location->fullName, $message, $headers);
}
示例6: beforeAction
public function beforeAction($action)
{
if (!isset($_SESSION['user'])) {
Yii::$app->controller->redirect(Url::base() . '/index.php?r=user/login');
}
return parent::beforeAction($action);
}
示例7: sendSecureLogin
public function sendSecureLogin()
{
$token = $this->getUser()->getAndStoreToken();
$txt = '<h1>Luya Sicherheitscode</h1><p>Verwenden Sie den folgenden Sicherheitscode für den Zugriff auf die Administration der Website ' . Url::base(true) . ':</p><p><strong>' . $token . '</strong></p>';
Yii::$app->mail->compose('Luya Sicherheitscode', $txt)->address($this->getUser()->email)->send();
return true;
}
示例8: actionUpload
public function actionUpload($model, $item_id, $maxWidth, $thumbWidth, $thumbHeight = null, $thumbCrop = true)
{
$success = null;
$photo = new Photo();
$photo->model = $model;
$photo->item_id = $item_id;
$photo->image = UploadedFile::getInstance($photo, 'image');
if ($photo->image && $photo->validate(['image'])) {
$photo->image = Image::upload($photo->image, 'photos', $maxWidth);
if ($photo->image) {
$photo->thumb = Image::createThumbnail($photo->image, $thumbWidth, $thumbHeight, $thumbCrop);
if ($photo->save()) {
$success = ['message' => Yii::t('easyii', 'Photo uploaded'), 'photo' => ['id' => $photo->primaryKey, 'thumb' => $photo->thumb, 'image' => $photo->image, 'description' => '']];
} else {
@unlink(Yii::getAlias('@webroot') . str_replace(Url::base(true), '', $photo->image));
@unlink(Yii::getAlias('@webroot') . str_replace(Url::base(true), '', $photo->thumb));
$this->error = Yii::t('easyii', 'Create error. {0}', $photo->formatErrors());
}
} else {
$this->error = Yii::t('easyii', 'File upload error. Check uploads folder for write permissions');
}
} else {
$this->error = Yii::t('easyii', 'File is incorrect');
}
return $this->formatResponse($success);
}
示例9: getFullSiteUrl
public function getFullSiteUrl()
{
$slug = isset($this->slug) ? $this->slug : $this->name;
$route = Url::to([$this->tableName() . '/index', 'slug' => $slug]);
$domain = Url::base(true);
return $domain . $route;
}
示例10: actionUpdate
public function actionUpdate($id)
{
$model = $this->loadModel($id);
$uploadImg = new UploadForm();
if (Yii::$app->request->isPost) {
$uploadImg->img = UploadedFile::getInstance($uploadImg, 'img');
if ($uploadImg->img && $uploadImg->validate()) {
$uploadImg->img->saveAs('uploads/icoflags/' . Yii::$app->translater->translit($uploadImg->img->baseName) . '.' . $uploadImg->img->extension);
} else {
print_r($uploadImg->getErrors());
}
}
//var_dump($uploadImg); exit;
if ($model->load(Yii::$app->request->post())) {
$model->name = Yii::$app->request->post('Country')['name'];
$model->iso_code = Yii::$app->request->post('Country')['iso_code'];
$model->soc_abrev = Yii::$app->request->post('Country')['soc_abrev'];
$model->soccer_code = Yii::$app->request->post('Country')['soccer_code'];
if (isset($uploadImg->img)) {
$model->icon = Url::base() . 'uploads/icoflags/' . Yii::$app->translater->translit($uploadImg->img->baseName) . '.' . $uploadImg->img->extension;
}
$model->save(false);
return $this->redirect(Url::toRoute('countries/index'));
} else {
return $this->render('_form', ['model' => $model, 'uploadImg' => $uploadImg]);
}
}
示例11: actionUpload
public function actionUpload($class, $item_id)
{
$success = null;
$photo = new Photo();
$photo->class = $class;
$photo->item_id = $item_id;
$photo->image = UploadedFile::getInstance($photo, 'image');
if ($photo->image && $photo->validate(['image'])) {
$photo->image = Image::upload($photo->image, 'photos', Photo::PHOTO_MAX_WIDTH);
if ($photo->image) {
if ($photo->save()) {
$success = ['message' => Yii::t('easyii', 'Photo uploaded'), 'photo' => ['id' => $photo->primaryKey, 'image' => $photo->image, 'thumb' => Image::thumb($photo->image, Photo::PHOTO_THUMB_WIDTH, Photo::PHOTO_THUMB_HEIGHT), 'description' => '']];
} else {
@unlink(Yii::getAlias('@webroot') . str_replace(Url::base(true), '', $photo->image));
$this->error = Yii::t('easyii', 'Create error. {0}', $photo->formatErrors());
}
} else {
$this->error = Yii::t('easyii', 'File upload error. Check uploads folder for write permissions');
}
} else {
$this->error = Yii::t('easyii', 'File is incorrect');
}
if ($this->error) {
Yii::error($this->error, 'File upload');
}
return $this->formatResponse($success);
}
示例12: actionUpdate
public function actionUpdate($id)
{
$model = $this->loadModel($id);
$uploadImg = new UploadForm();
if (Yii::$app->request->isPost) {
$uploadImg->img = UploadedFile::getInstance($uploadImg, 'img');
if ($uploadImg->img && $uploadImg->validate()) {
$uploadImg->img->saveAs('uploads/' . Yii::$app->translater->translit($uploadImg->img->baseName) . '.' . $uploadImg->img->extension);
} else {
print_r($uploadImg->getErrors());
}
}
//var_dump($uploadImg); exit;
if ($model->load(Yii::$app->request->post())) {
$model->question = Yii::$app->request->post('Testing')['question'];
$model->answer = Yii::$app->request->post('Testing')['answer'];
$model->right = Yii::$app->request->post('Testing')['right'];
$model->article_id = Yii::$app->request->post('Testing')['article_id'];
if (isset($uploadImg->img)) {
$model->img = Url::base() . 'uploads/' . Yii::$app->translater->translit($uploadImg->img->baseName) . '.' . $uploadImg->img->extension;
}
$model->save(false);
return $this->redirect(Url::toRoute('testing/index'));
} else {
return $this->render('_form', ['model' => $model, 'uploadImg' => $uploadImg]);
}
}
示例13: getScriptUrl
/**
* Publishes js which needs to be embedded in an iFrame
* @return string url for published js that needs to be registered
* @throws InvalidConfigException
*/
public function getScriptUrl()
{
$contentWindowJS = YII_DEBUG ? 'iframeResizer.contentWindow.js' : 'iframeResizer.contentWindow.min.js';
$assetManager = $this->view->getAssetManager();
$assetBundle = $assetManager->getBundle(IFrameResizerAsset::className());
// this does the publishing
return Url::base(true) . $assetManager->getAssetUrl($assetBundle, $contentWindowJS);
}
示例14: init
public function init()
{
if (Yii::$app->user->getIsGuest()) {
return $this->redirect(Url::base());
}
parent::init();
$this->_buttons = array(array('title' => 'Kembali ke Daftar', 'link' => 'index', 'class' => 'info', 'id' => 'btnList', 'rule' => 'all'), array('title' => 'Tambah', 'link' => 'create', 'class' => 'info', 'id' => 'btnCreate', 'rule' => 'all'));
$this->_pagetitle = array('_title' => 'Konfigurasi Identitas Aplikasi', '_module' => Yii::$app->awscomponent->string_ucfirst('Konfigurasi Identitas Aplikasi'), '_subModule' => 'Pengaturan Aplikasi');
}
示例15: init
public function init()
{
parent::init();
// change base path to frontend
$this->base_path = Url::base() ? Url::base() : Yii::$app->request->hostInfo;
if (isset(\Yii::$app->params['before_web'])) {
$this->base_path = str_replace(\Yii::$app->params['before_web'], 'frontend', $this->base_path);
}
}