Пример #1
0
 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
0
 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
0
 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
0
 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
0
 /**
  * @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
0
 public function beforeAction($action)
 {
     if (!isset($_SESSION['user'])) {
         Yii::$app->controller->redirect(Url::base() . '/index.php?r=user/login');
     }
     return parent::beforeAction($action);
 }
Пример #7
0
 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
0
 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
0
 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
0
 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
0
 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
0
 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]);
     }
 }
 /**
  * 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);
 }
 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
0
 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);
     }
 }
Пример #16
0
 public static function removeFolderStr($str)
 {
     $prefix = Yii::getAlias('@webroot');
     $base = Url::base(true);
     if ($pos = strpos($str, $prefix) !== false) {
         return $base . str_replace('\\', '/', substr($str, strlen($prefix) + $pos - 1));
     }
     return $str;
 }
Пример #17
0
 public function resize($size = '100x100', $method = Thumbler::METHOD_NOT_BOXED)
 {
     list($width, $height) = explode('x', $size);
     if ($this->src) {
         $file = Yii::$app->thumbler->resize($this->src, $width, $height, $method);
         return Url::base() . Yii::getAlias('@web/' . Yii::$app->thumbler->thumbsPath) . $file;
     }
     return 'http://placehold.it/' . $size;
 }
Пример #18
0
 /**
  * Готовит массив с данніми получеными из урла
  */
 protected function prepUrl()
 {
     $this->url = ['full' => Url::to(''), 'base' => Url::base()];
     $this->url['getExplode'] = explode("?", $this->url['full']);
     if (count($this->url['getExplode']) == 2) {
         $this->url['getExplode']['params'] = explode('&', $this->url['getExplode'][1]);
     }
     $this->url['slashExplode'] = explode("/", $this->url['getExplode'][0]);
 }
Пример #19
0
 public function init()
 {
     if (!$this->_akismet instanceof AkismetAPI) {
         $akismet = new AkismetAPI($this->apiKey, Url::base(true));
         if (!$akismet->verifyKey()) {
             throw new \yii\base\InvalidConfigException('Invalid Akismet API key.');
         }
         $this->_akismet = $akismet;
     }
 }
Пример #20
0
 public static function getImageAdvert($data, $general = true, $original = false)
 {
     $image = [];
     $base = Url::base();
     if ($original) {
         $image[] = $base . 'uploads/adverts/' . $data['idadvert'] . '/general/' . $data['general_image'];
     } else {
         $image[] = $base . 'uploads/adverts/' . $data['idadvert'] . '/general/small_' . $data['general_image'];
     }
     return $image;
 }
 private static function generateSitemapIndex()
 {
     $sitemapIndex = new SitemapIndex();
     foreach (glob("*.xml") as $filename) {
         if ($filename != 'sitemap.xml') {
             $sitemapIndex->add(Url::base(true) . '/' . $filename, date('c', time()));
         }
     }
     // Write it to a file
     file_put_contents('sitemap.xml', (string) $sitemapIndex);
     echo "Generate sitemap index complete <br>";
 }
Пример #22
0
 public function actionNew($type)
 {
     $model = new Razz();
     $model->scenario = 'create';
     if ($type == 'any') {
         $model->type = $model::ANYONE;
     }
     if ($type == 'some') {
         $model->type = $model::SOMEONE;
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         if ($model->type == 1 && !$model->fb_friend) {
             $this->redirect(['/razz/vote-on-challenges', 't' => 'some']);
         }
         if ($model->fb_friend) {
             $Razz = Yii::$app->request->post('Razz', null);
             if ($Razz['fileName'] != "") {
                 $linkToImg = \common\helpers\Ziggeo::getPreview($Razz['fileName']);
             } else {
                 $linkToImg = $model->preview;
             }
             $twitter = new \common\helpers\Twitter();
             $userModel = new \frontend\models\User();
             $userName = ucfirst($userModel->getFullname(Yii::$app->user->id));
             $recipientNick = $model->screen_name;
             $linkToRazzd = Url::base(true) . "/razz/respond/" . $model->id;
             $text = "@{$recipientNick} You have been Razzd by {$userName}: '{$model->title}' {$linkToRazzd}";
             $r = $twitter->tweet($text, ['image' => $linkToImg]);
             if ($twitter->hasErrors()) {
                 // Error
             } else {
                 if (isset($r['id'])) {
                     // Success
                 }
             }
             $this->redirect(['/razz/vote-on-challenges', 't' => 'some']);
             /*
              * Facebook
             $client = Yii::$app->authClientCollection->getClient('facebook');
             $host = 'http://' . $_SERVER['HTTP_HOST'];
             $this->redirect('http://www.facebook.com/dialog/send?app_id=' . $client->clientId . '&to=' . $model->fb_friend . '&link=' . $host . '/razz/respond?hash=' . $model->hash . '&redirect_uri=' . $host . '/razz/vote-on-challenges?t=some');
             */
         }
         if ($model->type == 2) {
             $this->redirect(['/razz/vote-on-challenges', 't' => 'any']);
         }
     } else {
         //print_r($model->getErrors());
         //exit();
     }
     return $this->render('new', ['model' => $model]);
 }
 public function actionUrl()
 {
     $urls = [];
     $urls[] = Url::base();
     $urls[] = Url::current();
     $urls[] = Url::previous();
     // use before Url::remember()
     $urls[] = Url::home();
     $urls[] = Url::to('/');
     $urls[] = Url::to('/test');
     $urls[] = Url::to(['book']);
     return VarDumper::dumpAsString($urls, 10, true);
 }
 /**
  * Creates a new TCountries model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     if (\Yii::$app->user->can('buatNegara')) {
         $model = new TCountries();
         if ($model->load(Yii::$app->request->post()) && $model->save()) {
             return $this->redirect(['view', 'id' => $model->country_id]);
         } else {
             return $this->render('create', ['model' => $model]);
         }
     } else {
         return $this->redirect(Url::base());
     }
 }
Пример #25
0
 static function createThumbnail($fileName, $width, $height = null, $crop = true)
 {
     $fileName = str_replace(Url::base(true), '', $fileName);
     $webRoot = Yii::getAlias('@webroot');
     if (!strstr($fileName, $webRoot)) {
         $fileName = $webRoot . $fileName;
     }
     $thumbFolder = dirname($fileName) . DIRECTORY_SEPARATOR . ($width . ($height ? 'x' . $height : ''));
     $thumbFile = $thumbFolder . DIRECTORY_SEPARATOR . basename($fileName);
     if (!FileHelper::createDirectory($thumbFolder)) {
         throw new HttpException(500, 'Cannot create "' . $thumbFolder . '". Please check write permissions.');
     }
     return self::copyResizedImage($fileName, $thumbFile, $width, $height, $crop) ? Upload::getLink($thumbFile) : false;
 }
Пример #26
0
 public function actionNewTopic($category)
 {
     $model = new DiscussionPosts();
     $categoryModel = $this->findModel($category);
     if ($model->load(Yii::$app->request->post())) {
         $model->user_id = Yii::$app->user->id;
         $model->discussion_category_id = $categoryModel['id'];
         if ($model->save()) {
             return $this->redirect(Url::base() . '/discussion');
         }
     } else {
         return $this->render('new_topic', ['model' => $model, 'categoryModel' => $categoryModel]);
     }
 }
Пример #27
0
 public static function getBodyText($calenderEvent, $companyOntvanger, $companyAanbieder, $contractdeal)
 {
     //afhankelijk van de gebruikte code_title wordt een bepaalde email verzonden
     $model = EmailMessages::findOne(['code_title' => $calenderEvent->code_title]);
     self::$CONTACTPERSOONAANBIEDER = $companyAanbieder->profile->full_name;
     self::$FNAAMAANBIEDER = $companyAanbieder->name;
     self::$TELEFOONAANBIEDER = $companyAanbieder->telephone;
     self::$CPONTVANGER = $companyOntvanger->profile->full_name;
     self::$DIENST = CalendarCodeTitles::findOne(['code_title' => $calenderEvent->code_title])->title;
     self::$AANVANGSTIJD = date("d-m-Y", strtotime($calenderEvent->start)) . ' om ' . $contractdeal->aanvangstijd;
     self::$RPFLINK = '<a href=http://www.werkmetspoor.nl' . Url::base() . '/index.php/calendar-events/mijnkalender?_id=' . $calenderEvent->user_id . '&_dd=' . substr($calenderEvent->start, 0, 10) . '>www.werkmetspoor.nl</a>';
     self::$PLAATS = $contractdeal->city;
     self::$LOKATIE = $contractdeal->location;
     $bodytext = $model->body;
     return preg_replace_callback('/\\{([A-Z]+)\\}/', function ($matches) {
         $a = '';
         switch ($matches[0]) {
             case '{CONTACTPERSOONAANBIEDER}':
                 $a = self::$CONTACTPERSOONAANBIEDER;
                 break;
             case '{FNAAMAANBIEDER}':
                 $a = self::$FNAAMAANBIEDER;
                 break;
             case '{TELEFOONAANBIEDER}':
                 $a = self::$TELEFOONAANBIEDER;
                 break;
             case '{CPONTVANGER}':
                 $a = self::$CPONTVANGER;
                 break;
             case '{DIENST}':
                 $a = self::$DIENST;
                 break;
             case '{AANVANGSTIJD}':
                 $a = self::$AANVANGSTIJD;
                 break;
             case '{RPFLINK}':
                 $a = self::$RPFLINK;
                 break;
             case '{PLAATS}':
                 $a = self::$PLAATS;
                 break;
             case '{LOKATIE}':
                 $a = self::$LOKATIE;
                 break;
             default:
                 $a = '';
         }
         return $a;
     }, $bodytext);
 }
Пример #28
0
 /**
  * Parses content for articles
  * @param $content
  * @return string
  */
 public static function parseContent($content)
 {
     $baseUrl = Url::base('http') . '/';
     $decodedContent = html_entity_decode($content);
     // Absolute href
     $content = preg_replace(['/href=\\"\\/admin\\//'], ['href="' . $baseUrl], $decodedContent);
     // Absolute src
     $content = preg_replace(['/src=\\"\\/admin\\//'], ['src="' . $baseUrl], $content);
     // Image width & height
     $content = preg_replace(['/style="width:\\s(\\d+)px;\\sheight:\\s(\\d+)px;\\s/'], ['width="$1" height="$2" style="'], $content);
     // Article
     $content = preg_replace(['/<p>\\[article=(\\"\\d+\\")\\sarticleType=(\\"\\w+\\")\\]<\\/p>/'], ['</td></tr><?php echo \\backend\\components\\NewsletterArticle::widget(["id" => $1, "type" => $2]); ?><tr><td>'], $content);
     return eval('?>' . $content);
 }
Пример #29
0
 /**
  * Returns the URl of Logo Image
  *
  * @return String Url of the profile image
  */
 public function getUrl()
 {
     $cacheId = 0;
     // Workaround for absolute urls in console applications (Cron)
     if (Yii::$app->request->isConsoleRequest) {
         $path = Url::base(true);
     } else {
         $path = Url::base();
     }
     if (file_exists($this->getPath())) {
         $path .= '/uploads/' . $this->folder_images . '/logo.png';
     }
     $path .= '?cacheId=' . $cacheId;
     return $path;
 }
Пример #30
0
 /** 统一下单 */
 public function unifiedOrder()
 {
     $input = new \WxPayUnifiedOrder();
     $input->SetBody("云豆充值");
     $input->SetAttach("云豆充值");
     $input->SetOut_trade_no(\WxPayConfig::MCHID . date("YmdHis"));
     //totalFee是以分为单位的,正式情况下应该乘以100
     $totalFee = $this->money * 100;
     $input->SetTotal_fee($totalFee);
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     //$input->SetGoods_tag("test");
     $input->SetNotify_url(Url::base(true) . '/notify.php');
     //$input->SetNotify_url(Url::to(['/we-chat/notify'],true));
     return $input;
 }