PHP Method Yii::import Code Examples

This page contains top rated real world PHP examples of method Yii::import extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: UploadController.php Project: BGCX067/facecom-svn-to-git
0
 public function run($class_name)
 {
     $path = realpath(Yii::app()->basePath . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'upload' . DIRECTORY_SEPARATOR . $class_name);
     $class_name = ucfirst($class_name);
     if ($path && is_dir($path) && is_writable($path)) {
         $dir = key($_GET);
         $filename = $_GET[$dir];
         $pk = pathinfo($filename, PATHINFO_FILENAME);
         $image = Images::model()->findByPk($pk);
         if ($image != null) {
             $image->resize($dir);
         }
     } elseif (class_exists($class_name)) {
         $dir = key($_GET);
         $filename = $_GET[$dir];
         $size = explode('x', $dir);
         $path = realpath(Yii::app()->basePath . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'upload' . DIRECTORY_SEPARATOR . $class_name);
         if (YII_DEBUG && !file_exists($path . DIRECTORY_SEPARATOR . $dir)) {
             mkdir($path . DIRECTORY_SEPARATOR . $dir, 0777);
         }
         if ($path !== FALSE && file_exists($path . DIRECTORY_SEPARATOR . $dir) && is_file($path . DIRECTORY_SEPARATOR . $filename) && $size[0] > 0 && $size[1] > 0) {
             Yii::import('ext.iwi.Iwi');
             $image = new Iwi($path . DIRECTORY_SEPARATOR . $filename);
             $image->adaptive($size[0], $size[1]);
             $image->save($path . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR . $filename, 0644, TRUE);
             $mime = CFileHelper::getMimeType($path . DIRECTORY_SEPARATOR . $filename);
             header('Content-Type: ' . $mime);
             $image->render();
             exit;
         }
     }
     return parent::run($class_name);
 }
Example #2
Show file File: EExcelView.php Project: MGGROUP/SAMDEPURACION
0
 public function init()
 {
     if (isset($_GET[$this->grid_mode_var])) {
         $this->grid_mode = $_GET[$this->grid_mode_var];
     }
     if (isset($_GET['exportType'])) {
         $this->exportType = $_GET['exportType'];
     }
     $lib = Yii::getPathOfAlias($this->libPath) . '.php';
     if ($this->grid_mode == 'export' and !file_exists($lib)) {
         $this->grid_mode = 'grid';
         Yii::log("PHP Excel lib not found({$lib}). Export disabled !", CLogger::LEVEL_WARNING, 'EExcelview');
     }
     if ($this->grid_mode == 'export') {
         $this->title = $this->title ? $this->title : Yii::app()->getController()->getPageTitle();
         $this->initColumns();
         //parent::init();
         //Autoload fix
         spl_autoload_unregister(array('YiiBase', 'autoload'));
         Yii::import($this->libPath, true);
         $this->objPHPExcel = new PHPExcel();
         spl_autoload_register(array('YiiBase', 'autoload'));
         // Creating a workbook
         $this->objPHPExcel->getProperties()->setCreator($this->creator);
         $this->objPHPExcel->getProperties()->setTitle($this->title);
         $this->objPHPExcel->getProperties()->setSubject($this->subject);
         $this->objPHPExcel->getProperties()->setDescription($this->description);
         $this->objPHPExcel->getProperties()->setCategory($this->category);
     } else {
         parent::init();
     }
 }
Example #3
Show file File: RssController.php Project: jessesiu/GigaDBV3
0
 private function generateFeed($datasets)
 {
     Yii::import('ext.feed.*');
     // specify feed type
     $feed = new EFeed(EFeed::RSS1);
     $feed->title = $this->title;
     $feed->link = $this->rssLink;
     $feed->description = $this->rssDescription;
     $feed->RSS1ChannelAbout = $this->rssAbout;
     foreach ($datasets as $key => $dataset) {
         $title = $this->isDataset($dataset) ? $dataset->title : $dataset->message;
         $link = $this->isDataset($dataset) ? Yii::app()->request->hostInfo . "/dataset/" . $dataset->identifier : Yii::app()->request->hostInfo;
         $desc = $this->isDataset($dataset) ? $dataset->description : $dataset->message;
         // create dataset item
         $item = $feed->createNewItem();
         $item->title = $title;
         $item->link = $link;
         $item->date = $dataset->publication_date;
         $item->description = $desc;
         $item->addTag('dc:subject', $title);
         $feed->addItem($item);
     }
     if (count($datasets) == 0) {
         echo "No Item";
     } else {
         $feed->generateFeed();
     }
 }
Example #4
Show file File: UserController.php Project: bfyang5130/zzl
0
 /**
  * This is the action to handle external exceptions.
  */
 public function actionRegister()
 {
     if (!Yii::app()->user->isGuest) {
         $this->redirect('/member/index.html');
     }
     $this->pageTitle = "注册用户 - " . Yii::app()->name;
     if (isset($_POST['username'])) {
         $status = array();
         if (!isset($_POST['username']) || !isset($_POST['password'])) {
             $status = array('status' => 0, "info" => '用户名或者密码错误!');
         } else {
             Yii::import("application.models.form.RegeditForm", true);
             $loginform = new RegeditForm();
             $loginform->setAttributes($_POST);
             if ($loginform->validate() && $loginform->save()) {
                 $status = array('status' => 1, "info" => '已经给你发送了激活邮件,如没有收到,可在会员中心重新发送。');
             } else {
                 $error = $loginform->errors;
                 $status = array('status' => 0, "info" => current(current($error)));
             }
         }
         echo json_encode($status);
         Yii::app()->end();
     }
     $this->render('html5_regedit');
 }
Example #5
Show file File: RegeditForm.php Project: bfyang5130/zzl
0
 /**
  * Logs in the user using the given username and password in the model.
  * @return boolean whether login is successful
  */
 public function save()
 {
     $user = new Users();
     $user->setAttributes($this->attributes);
     $user->setAttribute("password", BaseTool::ENPWD($this->password));
     if ($user->validate() && $user->save()) {
         $accountarray = array('user_id' => Yii::app()->db->getLastInsertID(), 'total' => 0, 'use_money' => 0, 'no_use_money' => 0, 'newworth' => 0);
         $newAccount = new Account();
         $newAccount->setAttributes($accountarray);
         $newAccount->save();
         //发送邮件
         $activecode = BaseTool::getActiveMailCode($this->username);
         $message = MailTemplet::getActiveEmail($this->username, $activecode);
         $mail = Yii::app()->Smtpmail;
         $mail->SetFrom(Yii::app()->params['adminEmail']);
         $mail->Subject = "好帮贷测试邮件";
         $mail->MsgHTML($message);
         $mail->AddAddress($this->email);
         if ($mail->Send()) {
             $user->updateAll(array("regtaken" => $activecode, "regativetime" => time() + 60 * 60), "username=:username", array(":username" => $this->username));
         }
         Yii::import("application.models.form.LoginForm", true);
         $loginform = new LoginForm();
         $loginarray = array('rememberMe' => false, 'username' => $this->username, 'password' => $this->password);
         $loginform->setAttributes($loginarray);
         if ($loginform->validate() && $loginform->login()) {
         }
         return true;
     } else {
         $usererror = $user->errors;
         $this->addError("username", current(current($usererror)));
         return false;
     }
 }
Example #6
Show file File: pdfHelper.php Project: wrenchpilot/LimeSurvey
0
 /**
  * getPdfLanguageSettings
  *
  * Usage: getPdfLanguageSettings($language)
  *
  * @return array ('pdffont','pdffontsize','lg'=>array('a_meta_charset','a_meta_dir','a_meta_language','w_page')
  * @param string $language : language code for the PDF
  */
 public static function getPdfLanguageSettings($language)
 {
     Yii::import('application.libraries.admin.pdf', true);
     Yii::import('application.helpers.surveytranslator_helper', true);
     $pdffont = Yii::app()->getConfig('pdfdefaultfont');
     if ($pdffont == 'auto') {
         $pdffont = PDF_FONT_NAME_DATA;
     }
     $pdfcorefont = array("freesans", "dejavusans", "courier", "helvetica", "freemono", "symbol", "times", "zapfdingbats");
     if (in_array($pdffont, $pdfcorefont)) {
         $alternatepdffontfile = Yii::app()->getConfig('alternatepdffontfile');
         if (array_key_exists($language, $alternatepdffontfile)) {
             $pdffont = $alternatepdffontfile[$language];
             // Actually use only core font
         }
     }
     $pdffontsize = Yii::app()->getConfig('pdffontsize');
     if ($pdffontsize == 'auto') {
         $pdffontsize = PDF_FONT_SIZE_MAIN;
     }
     $lg = array();
     $lg['a_meta_charset'] = 'UTF-8';
     if (getLanguageRTL($language)) {
         $lg['a_meta_dir'] = 'rtl';
     } else {
         $lg['a_meta_dir'] = 'ltr';
     }
     $lg['a_meta_language'] = $language;
     $lg['w_page'] = gT("page");
     return array('pdffont' => $pdffont, 'pdffontsize' => $pdffontsize, 'lg' => $lg);
 }
Example #7
Show file File: CrudCode.php Project: israelCanul/Bonanza_V2
0
 public function validateModel($attribute, $params)
 {
     if ($this->hasErrors('model')) {
         return;
     }
     $class = @Yii::import($this->model, true);
     if (!is_string($class) || !$this->classExists($class)) {
         $this->addError('model', "Class '{$this->model}' does not exist or has syntax error.");
     } else {
         if (!is_subclass_of($class, 'CActiveRecord')) {
             $this->addError('model', "'{$this->model}' must extend from CActiveRecord.");
         } else {
             $table = CActiveRecord::model($class)->tableSchema;
             if ($table->primaryKey === null) {
                 $this->addError('model', "Table '{$table->name}' does not have a primary key.");
             } else {
                 if (is_array($table->primaryKey)) {
                     $this->addError('model', "Table '{$table->name}' has a composite primary key which is not supported by crud generator.");
                 } else {
                     $this->_modelClass = $class;
                     $this->_table = $table;
                 }
             }
         }
     }
 }
Example #8
Show file File: AdminController.php Project: tejrajs/humhub-modules-library
0
 /**
  * Configuration Action for Super Admins
  */
 public function actionIndex()
 {
     Yii::import('library.forms.*');
     $form = new LibraryAdminForm();
     // uncomment the following code to enable ajax-based validation
     //if (isset($_POST['ajax']) && $_POST['ajax'] === 'LibraryAdminForm') {
     //    echo CActiveForm::validate($form);
     //    Yii::app()->end();
     //}
     if (isset($_POST['LibraryAdminForm'])) {
         $_POST['LibraryAdminForm'] = Yii::app()->input->stripClean($_POST['LibraryAdminForm']);
         $form->attributes = $_POST['LibraryAdminForm'];
         if ($form->validate()) {
             $form->globalPublicLibrary = HSetting::Set('globalPublicLibrary', $form->globalPublicLibrary, 'library');
             $form->disclaimerWidget = HSetting::Set('disclaimerWidget', $form->disclaimerWidget, 'library');
             $form->disclaimerTitle = HSetting::Set('disclaimerTitle', $form->disclaimerTitle, 'library');
             $form->disclaimerContent = HSetting::Set('disclaimerContent', $form->disclaimerContent, 'library');
             $this->redirect(Yii::app()->createUrl('library/admin/index'));
         }
     } else {
         $form->globalPublicLibrary = HSetting::Get('globalPublicLibrary', 'library');
         $form->disclaimerWidget = HSetting::Get('disclaimerWidget', 'library');
         $form->disclaimerTitle = HSetting::Get('disclaimerTitle', 'library');
         $form->disclaimerContent = HSetting::Get('disclaimerContent', 'library');
     }
     $this->render('index', array('model' => $form));
 }
Example #9
Show file File: CExistValidator.php Project: alsvader/hackbanero
0
 /**
  * Validates the attribute of the object.
  * If there is any error, the error message is added to the object.
  * @param CModel $object the object being validated
  * @param string $attribute the attribute being validated
  */
 protected function validateAttribute($object, $attribute)
 {
     $value = $object->{$attribute};
     if ($this->allowEmpty && $this->isEmpty($value)) {
         return;
     }
     $className = $this->className === null ? get_class($object) : Yii::import($this->className);
     $attributeName = $this->attributeName === null ? $attribute : $this->attributeName;
     $finder = CActiveRecord::model($className);
     $table = $finder->getTableSchema();
     if (($column = $table->getColumn($attributeName)) === null) {
         throw new CException(Yii::t('yii', 'Table "{table}" does not have a column named "{column}".', array('{column}' => $attributeName, '{table}' => $table->name)));
     }
     $columnName = $column->rawName;
     $criteria = new CDbCriteria();
     if ($this->criteria !== array()) {
         $criteria->mergeWith($this->criteria);
     }
     $tableAlias = empty($criteria->alias) ? $finder->getTableAlias(true) : $criteria->alias;
     $valueParamName = CDbCriteria::PARAM_PREFIX . CDbCriteria::$paramCount++;
     $criteria->addCondition($this->caseSensitive ? "{$tableAlias}.{$columnName}={$valueParamName}" : "LOWER({$tableAlias}.{$columnName})=LOWER({$valueParamName})");
     $criteria->params[$valueParamName] = $value;
     if (!$finder->exists($criteria)) {
         $message = $this->message !== null ? $this->message : Yii::t('yii', '{attribute} "{value}" is invalid.');
         $this->addError($object, $attribute, $message, array('{value}' => CHtml::encode($value)));
     }
 }
Example #10
Show file File: AbstractPicturesBehavior.php Project: hit-shappens/testapp
0
 protected function createImageSet($src_image)
 {
     Yii::import('application.extensions.ImageCropper');
     //Yii::log("Load source img: ".memory_get_usage(true),"info","MemmorySize");
     $cropper = new ImageCropper($src_image);
     $parts = preg_split('/[\\/\\\\]/', $src_image);
     $fileName = array_pop($parts);
     foreach ($this->pictures() as $type => $pic) {
         if (isset($pic['vertical']) || isset($pic['horizontal'])) {
             $Info = getimagesize($src_image);
             $orientation = $Info[0] < $Info[1] ? 'vertical' : 'horizontal';
             if (isset($pic[$orientation])) {
                 $w = $pic[$orientation]['w'];
                 $h = $pic[$orientation]['h'];
             }
         } else {
             $w = $pic['w'];
             $h = $pic['h'];
         }
         $filePath = $_SERVER['DOCUMENT_ROOT'] . $pic['path'] . $fileName;
         if ($w == null && $h == null) {
             if (!copy($src_image, $filePath)) {
                 return false;
             }
         } else {
             //Yii::log("Before resize \"".$type."\": ".memory_get_usage(true),"info","MemmorySize");
             if (!$cropper->resize_and_crop($filePath, $w, $h)) {
                 return false;
             }
             //Yii::log("After resize \"".$type."\"".memory_get_usage(true),"info","MemmorySize");
         }
     }
     $cropper = null;
     return $fileName;
 }
Example #11
Show file File: GtcIdentifierProvider.php Project: dbrisinajumi/gii-template-collection
0
 public function suggestIdentifier($model)
 {
     if (!$model instanceof CActiveRecord) {
         $model = CActiveRecord::model(Yii::import($model));
     }
     if (is_callable(array($model, 'getItemLabel'))) {
         return 'itemLabel';
     }
     $nonNumericFound = false;
     $columns = $model->tableSchema->columns;
     foreach ($columns as $column) {
         if ($column->isPrimaryKey) {
             $fallbackName = $column->name;
         }
         // Use the first non-numeric column as a fallback
         if (!$column->isForeignKey && !$column->isPrimaryKey && $column->type != 'BIGINT' && $column->type != 'INT' && $column->type != 'INTEGER' && $column->type != 'BOOLEAN' && !$nonNumericFound) {
             $fallbackName = $column->name;
             $nonNumericFound = true;
         }
         // Return the first title, name, label column, if found
         if (in_array($column->name, array("title", "name", "label"))) {
             $fallbackName = $column->name;
             break;
         }
     }
     return $fallbackName;
 }
Example #12
Show file File: LanguageSelector.php Project: mjrouser/cityapi
0
 public static function setLanguage($cookieDays = 180)
 {
     if (Yii::app()->request->getPost('languageSelector') !== null && in_array($_POST['languageSelector'], self::getLanguagesList(), true)) {
         Yii::app()->setLanguage($_POST['languageSelector']);
         $cookie = new CHttpCookie('language', $_POST['languageSelector']);
         $cookie->expire = time() + 60 * 60 * 24 * $cookieDays;
         Yii::app()->request->cookies['language'] = $cookie;
     } else {
         if (isset(Yii::app()->request->cookies['language']) && in_array(Yii::app()->request->cookies['language']->value, self::getLanguagesList(), true)) {
             Yii::app()->setLanguage(Yii::app()->request->cookies['language']->value);
         } else {
             if (isset(Yii::app()->request->cookies['language'])) {
                 // Invalid language
                 unset(Yii::app()->request->cookies['language']);
             } else {
                 Yii::import('ext.EGeoIP');
                 try {
                     $geoIp = new EGeoIP();
                     $geoIp->locate();
                     $countryCode = strtolower($geoIp->getCountryCode());
                     if (!in_array($countryCode, self::getLanguagesList(), true)) {
                         return;
                     }
                     Yii::app()->setLanguage($countryCode);
                     $cookie = new CHttpCookie('language', $countryCode);
                     $cookie->expire = time() + 60 * 60 * 24 * $cookieDays;
                     Yii::app()->request->cookies['language'] = $cookie;
                 } catch (Exception $exception) {
                     Yii::log($exception->__toString(), 'error', 'app.widgets.languageSelector');
                 }
             }
         }
     }
 }
Example #13
Show file File: ContactController.php Project: phiphi1992/fpthue
0
 public function actionSendMail()
 {
     if (!empty($_POST)) {
         Yii::import('ext.yii-mail.YiiMailMessage');
         $message = new YiiMailMessage();
         $message->setBody($_POST['content']);
         $message->subject = $_POST['subject'];
         $message->from = $_POST['email'];
         $message->to = Yii::app()->params['adminEmail'];
         if (Yii::app()->mail->send($message)) {
             $model = new Comments();
             $model->title = $_POST['subject'];
             $model->content = $_POST['content'];
             $model->email = $_POST['email'];
             $model->name = $_POST['fullName'];
             $model->phone = $_POST['phone'];
             $model->created = time();
             if ($model->save()) {
                 return jsonOut(array('error' => false, 'message' => 'Cảm ơn bạn đã gửi thông tin, chúng tôi sẽ phản hồi cho bạn trong thời gian sớm nhất!'));
             } else {
                 return json_encode(array('error' => true, 'message' => 'Lỗi hệ thống, gửi thông tin không thành công.'));
             }
         } else {
             return json_encode(array('error' => true, 'message' => 'Gửi thông tin không thành công'));
         }
     }
 }
Example #14
Show file File: ExtensionBehavior.php Project: crisu83/yii-extension
0
 /**
  * Imports the a class or directory.
  * The path alias is automatically prepended if applicable.
  * @param string $alias path alias to be imported.
  * @param boolean $forceInclude whether to include the class file immediately.
  * @return string the class name or the directory that this alias refers to.
  * @throws \CException if the alias is invalid.
  */
 public function import($alias, $forceInclude = false)
 {
     if (($baseAlias = $this->getAlias()) !== null) {
         $alias = $baseAlias . '.' . $alias;
     }
     return Yii::import($alias, $forceInclude);
 }
Example #15
Show file File: EMailing.php Project: ahdail/humhub
0
 /**
  * Run method for EMailing System
  *
  * @param type $args
  */
 public function run($args)
 {
     $this->printHeader('E-Mail Interface');
     if (!isset($args[0]) || $args[0] != "daily" && $args[0] != 'hourly') {
         print "\n Run with parameter:\n" . "\t daily - for Daily Mailings\n" . "\t hourly - for Hourly Mailings\n";
         print "\n\n";
         exit;
     }
     $this->mode = $args[0];
     Yii::import("application.modules_core.wall.*", true);
     $users = User::model()->with('httpSessions')->findAllByAttributes(array('status' => User::STATUS_ENABLED));
     foreach ($users as $user) {
         print "Processing : " . $user->email . ": ";
         $notificationContent = $this->getNotificationContent($user);
         $activityContent = $this->getActivityContent($user);
         // Something new?
         if ($notificationContent == "" && $activityContent == "") {
             print "Nothing new! \n";
             continue;
         }
         $message = new HMailMessage();
         $message->view = 'application.views.mail.EMailing';
         $message->addFrom(HSetting::Get('systemEmailAddress', 'mailing'), HSetting::Get('systemEmailName', 'mailing'));
         $message->addTo($user->email);
         if ($this->mode == 'hourly') {
             $message->subject = Yii::t('base', "Latest news");
         } else {
             $message->subject = Yii::t('base', "Your daily summary");
         }
         $message->setBody(array('notificationContent' => $notificationContent, 'activityContent' => $activityContent, 'user' => $user), 'text/html');
         Yii::app()->mail->send($message);
         print "Sent! \n";
     }
     print "\nEMailing completed.\n";
 }
Example #16
Show file File: NewsTest.php Project: nizsheanez/documentation
0
 public function testGetContent()
 {
     Yii::app()->getModule('news');
     Yii::import('application.modules.news.models.*');
     $model = new News();
     $model->setAttributes(array('text' => 'comment 1', 'status' => News::STATE_ACTIVE), false);
 }
Example #17
Show file File: MPTranslate.php Project: ntquyen/GXC-CMS
0
 /**
  * method that handles the on missing translation event
  * 
  * @param CMissingTranslationEvent $event
  * @return string the message to translate or the translated message if autoTranslate is set to true
  */
 function missingTranslation($event)
 {
     Yii::import('translate.models.MessageSource');
     $attributes = array('category' => $event->category, 'message' => $event->message);
     if (($model = MessageSource::model()->find('message=:message AND category=:category', $attributes)) === null) {
         $model = new MessageSource();
         $model->attributes = $attributes;
         if (!$model->save()) {
             return Yii::log(TranslateModule::t('Message ' . $event->message . ' could not be added to messageSource table'));
         }
     }
     if ($model->id) {
         if ($this->autoTranslate && substr($event->language, 0, 2) !== substr(Yii::app()->sourceLanguage, 0, 2)) {
             //&& key_exists($event->language,$this->getGoogleAcceptedLanguages($event->language))
             Yii::import('translate.models.Message');
             $translation = $this->googleTranslate($event->message, $event->language, Yii::app()->sourceLanguage);
             $messageModel = new Message();
             $messageModel->attributes = array('id' => $model->id, 'language' => $event->language, 'translation' => $translation);
             if ($messageModel->save()) {
                 $event->message = $translation;
             } else {
                 return Yii::log(TranslateModule::t('Message ' . $event->message . ' could not be translated with auto-translate'));
             }
         } elseif (substr($event->language, 0, 2) !== substr(Yii::app()->sourceLanguage, 0, 2) || Yii::app()->getMessages()->forceTranslation) {
             self::$messages[$model->id] = array('language' => $event->language, 'message' => $event->message, 'category' => $event->category);
         }
     }
     return $event;
 }
Example #18
Show file File: EventImage.php Project: bahdall/karbella_event
0
 /**
  * Get url to product image. Enter $size to resize image.
  * @param mixed $size New size of the image. e.g. '150x150'
  * @param mixed $resizeMethod Resize method name to override config. resize/adaptiveResize
  * @param mixed $random Add random number to the end of the string
  * @return string
  */
 public function getUrl($size = false, $resizeMethod = false, $random = false)
 {
     if ($size !== false) {
         $thumbPath = Yii::getPathOfAlias(EventsImagesConfig::get('thumbPath')) . '/' . $size;
         if (!file_exists($thumbPath)) {
             mkdir($thumbPath, 0777, true);
         }
         // Path to source image
         $fullPath = Yii::getPathOfAlias(EventsImagesConfig::get('path')) . '/' . $this->image;
         // Path to thumb
         $thumbPath = $thumbPath . '/' . $this->image;
         if (!file_exists($thumbPath)) {
             // Resize if needed
             Yii::import('ext.phpthumb.PhpThumbFactory');
             $sizes = explode('x', $size);
             $thumb = PhpThumbFactory::create($fullPath);
             if ($resizeMethod === false) {
                 $resizeMethod = EventsImagesConfig::get('resizeThumbMethod');
             }
             $thumb->{$resizeMethod}($sizes[0], $sizes[1])->save($thumbPath);
         }
         return EventsImagesConfig::get('thumbUrl') . $size . '/' . $this->image;
     }
     if ($random === true) {
         return EventsImagesConfig::get('url') . $this->image . '?' . rand(1, 10000);
     }
     return EventsImagesConfig::get('url') . $this->image;
 }
Example #19
Show file File: YumRegistrationController.php Project: kumarsivarajan/yii-user-management
0
 public function actionRegistration()
 {
     // When we override the registrationUrl, this one should not be accessible
     // anymore
     if (Yum::module('registration')->registrationUrl != array('//registration/registration/registration')) {
         throw new CHttpException(403);
     }
     Yii::import('user.profile.models.*');
     $form = new YumRegistrationForm();
     $profile = new YumProfile();
     $this->performAjaxValidation('YumRegistrationForm', $form);
     if (isset($_POST['YumRegistrationForm'])) {
         $form->attributes = $_POST['YumRegistrationForm'];
         $profile->attributes = $_POST['YumProfile'];
         if (Yum::module('registration')->registration_by_email) {
             $form->username = $profile->email;
         }
         $form->validate();
         $profile->validate();
         if (!$form->hasErrors() && !$profile->hasErrors()) {
             $user = new YumUser();
             $user->register($form->username, $form->password, $profile);
             $user->profile = $profile;
             $this->sendRegistrationEmail($user);
             Yum::setFlash('Thank you for your registration. Please check your email.');
             $this->redirect(Yum::module()->loginUrl);
         }
     }
     $this->render(Yum::module('registration')->registrationView, array('form' => $form, 'profile' => $profile));
 }
Example #20
Show file File: YumUsergroup.php Project: Canyian/yii-user-management-facebook
0
 public function getMessageDataProvider()
 {
     Yii::import('application.modules.usergroup.models.*');
     $criteria = new CDbCriteria();
     $criteria->compare('group_id', $this->id);
     return new CActiveDataProvider('YumUsergroupMessage', array('criteria' => $criteria));
 }
Example #21
Show file File: CacheCommand.php Project: niranjan2m/Voyanga
0
 public function actionParseSkyScanner($from, $to)
 {
     $this->from = $from;
     $this->to = $to;
     foreach (Yii::app()->log->routes as $route) {
         $route->enabled = false;
     }
     Yii::import('console.models.*');
     $routesFilename = 'aviastat.txt';
     $routesFolder = 'console.data_files';
     $skyscannerCitiesFile = 'skyscanner_cities.serialized';
     $ourCitiesFile = 'our_cities.serialized';
     $routesPath = Yii::getPathOfAlias($routesFolder) . '/' . $routesFilename;
     $routes = file_get_contents($routesPath);
     $skyscannerCitiesPath = Yii::getPathOfAlias($routesFolder) . '/' . $skyscannerCitiesFile;
     $ourCitiesPath = Yii::getPathOfAlias($routesFolder) . '/' . $ourCitiesFile;
     //1. first - parse incoming file and determine different cities
     $cities = $this->parseRoutes($routes);
     //2. get internal skyscanner's placeIds for each city
     if (is_file($skyscannerCitiesPath)) {
         $skyscannerCities = unserialize(file_get_contents($skyscannerCitiesPath));
     } else {
         $skyscannerCities = $this->getSkyScannerCodes($cities);
         file_put_contents($skyscannerCitiesPath, serialize($skyscannerCities));
     }
     $this->cities = unserialize(file_get_contents($ourCitiesPath));
     echo "Cities loaded\n";
     //3. build urls for parsing skyscanner with routes
     $urls = $this->buildUrls($routes, $skyscannerCities);
     echo "Urls builded. Total urls: " . sizeof($urls) . "\n";
     //4. capture data from skyscanner using urls
     $this->grabSkyScanner($urls);
 }
Example #22
Show file File: DefaultController.php Project: kolbensky/rybolove
0
 /**
  * Import products
  */
 public function actionImport()
 {
     $importer = new CsvImporter();
     $importer->deleteDownloadedImages = Yii::app()->request->getPost('remove_images');
     if (Yii::app()->request->isPostRequest && isset($_FILES['file'])) {
         $importer->file = $_FILES['file']['tmp_name'];
         if ($importer->validate() && !$importer->hasErrors()) {
             // Create db backup
             if (isset($_POST['create_dump']) && $_POST['create_dump']) {
                 Yii::import('application.components.SDatabaseDumper');
                 $dumper = new SDatabaseDumper();
                 $file = Yii::getPathOfAlias('webroot.protected.backups') . DIRECTORY_SEPARATOR . 'dump_' . date('Y-m-d_H_i_s') . '.sql';
                 if (is_writable(Yii::getPathOfAlias('webroot.protected.backups'))) {
                     if (function_exists('gzencode')) {
                         file_put_contents($file . '.gz', gzencode($dumper->getDump()));
                     } else {
                         file_put_contents($file, $dumper->getDump());
                     }
                 } else {
                     throw new CHttpException(503, Yii::t('CsvModule.admin', 'Ошибка. Директория для бэкапов недоступна для записи.'));
                 }
             }
             $importer->import();
         }
     }
     $this->render('import', array('importer' => $importer));
 }
Example #23
Show file File: PortfolioController.php Project: kuzmina-mariya/unizaro-stone
0
 public function actionIndex()
 {
     // Загружаем страницу "Наши работы"
     Yii::import("application.modules.page.models.Page");
     $page = Page::model()->with(array('slides' => array('scopes' => 'published', 'order' => 'slides.sort ASC')))->findByPath("portfolio");
     $this->render('index', array('page' => $page));
 }
Example #24
Show file File: ShopModule.php Project: buildshop/bs-common
0
 public function getAdminSidebarMenu()
 {
     Yii::import('ext.mbmenu.AdminMenu');
     $mod = new AdminMenu();
     $items = $mod->findMenu('shop');
     return $items['items'];
 }
Example #25
Show file File: FormCommand.php Project: romeo14/pow
0
 /**
  * Execute the action.
  * @param array command line parameters specific for this command
  */
 public function run($args)
 {
     if (!isset($args[0], $args[1])) {
         echo "Error: both model class and view name are required.\n";
         echo $this->getHelp();
         return;
     }
     $scenario = isset($args[2]) ? $args[2] : '';
     $modelClass = Yii::import($args[0], true);
     $model = new $modelClass($scenario);
     $attributes = $model->getSafeAttributeNames();
     $templatePath = $this->templatePath === null ? YII_PATH . '/cli/views/shell/form' : $this->templatePath;
     $viewPath = Yii::getPathOfAlias($args[1]);
     $viewName = basename($viewPath);
     $viewPath .= '.php';
     $params = array('modelClass' => $modelClass, 'viewName' => $viewName, 'attributes' => $attributes);
     $list = array(basename($viewPath) => array('source' => $templatePath . '/form.php', 'target' => $viewPath, 'callback' => array($this, 'generateForm'), 'params' => $params));
     $this->copyFiles($list);
     $actionFile = $templatePath . '/action.php';
     if (!is_file($actionFile)) {
         // fall back to default ones
         $actionFile = YII_PATH . '/cli/views/shell/form/action.php';
     }
     echo "The following form view has been successfully created:\n";
     echo "\t{$viewPath}\n\n";
     echo "You may use the following code in your controller action:\n\n";
     echo $this->renderFile($actionFile, $params, true);
     echo "\n";
 }
Example #26
Show file File: YumUserIdentity.php Project: richardh68/yii-user-management
0
	public function authenticateFacebook() {
		$fbconfig = Yum::module()->facebookConfig;
		if (!$fbconfig || $fbconfig && !is_array($fbconfig))
			throw new Exception('actionLogout for Facebook was called, but is not activated in application configuration');

		Yii::import('application.modules.user.vendors.facebook.*');
		require_once('Facebook.php');
		$facebook = new Facebook($fbconfig);

		$fb_uid = $facebook->getUser();
		$profile = YumProfile::model()->findByAttributes(array('facebook_id'=>$fb_uid));
		$user = ($profile) ? YumUser::model()->findByPk($profile->user_id) : null;
		if ($user === null)
			$this->errorCode = self::ERROR_USERNAME_INVALID;
		else if($user->status == YumUser::STATUS_INACTIVE)
			$this->errorCode = self::ERROR_STATUS_INACTIVE;
		else if($user->status == YumUser::STATUS_BANNED)
			$this->errorCode = self::ERROR_STATUS_BANNED;
		else
		{
			$this->id = $user->id;
			$this->username = 'facebook';
			$this->facebook_id = $fb_uid;
			//$this->facebook_user = $facebook->api('/me');
			$this->errorCode = self::ERROR_NONE;
		}
	}
Example #27
Show file File: WsPayment.php Project: uiDeveloper116/webstore
0
 public function init()
 {
     parent::init();
     // import the module-level models and components
     Yii::import('application.extensions.wspayment.' . get_class($this) . '.models.*');
     Yii::import('custom.extensions.payment.' . get_class($this) . '.models.*');
 }
Example #28
Show file File: OpportunitiesBySourceChartView.php Project: RamaKavanan/InitialVersion
0
 public function renderContent()
 {
     $accessContent = $this->resolveContentIfCurrentUserCanAccessChartByModule('OpportunitiesModule', 'OpportunitiesModulePluralLabel');
     if ($accessContent != null) {
         return $accessContent;
     }
     $chartDataProviderType = $this->getChartDataProviderType();
     $chartDataProvider = ChartDataProviderFactory::createByType($chartDataProviderType);
     ControllerSecurityUtil::resolveCanCurrentUserAccessModule($chartDataProvider->getModel()->getModuleClassName(), true);
     $chartData = $chartDataProvider->getChartData();
     Yii::import('ext.amcharts.AmChartMaker');
     $amChart = new AmChartMaker();
     $amChart->data = $chartData;
     $amChart->id = $this->uniqueLayoutId;
     $amChart->type = $this->resolveViewAndMetadataValueByName('type');
     $amChart->addSerialGraph('value', 'column');
     $amChart->xAxisName = $chartDataProvider->getXAxisName();
     $amChart->yAxisName = $chartDataProvider->getYAxisName();
     $amChart->yAxisUnitContent = Yii::app()->locale->getCurrencySymbol(Yii::app()->currencyHelper->getCodeForCurrentUserForDisplay());
     $javascript = $amChart->javascriptChart();
     Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $this->uniqueLayoutId, $javascript);
     $cClipWidget = new CClipWidget();
     $cClipWidget->beginClip("Chart");
     $cClipWidget->widget('application.core.widgets.AmChart', array('id' => $this->uniqueLayoutId));
     $cClipWidget->endClip();
     return $cClipWidget->getController()->clips['Chart'];
 }
Example #29
Show file File: FixtureManager.php Project: DavBfr/BlogMVC
0
 /**
  * {@inheritdoc}
  *
  * @param array $fixtures fixtures to be loaded. The array keys are fixture
  * names, and the array values are either AR class names or table names. If
  * table names, they must begin with a colon character (e.g. 'Post' means
  * an AR class, while ':Post' means a table name).
  *
  * @return void
  * @since 0.1.0
  */
 public function load($fixtures)
 {
     //$schema = $this->getDbConnection()->getSchema();
     //$schema->checkIntegrity(false);
     $this->_rows = array();
     $this->_records = array();
     foreach ($fixtures as $fixtureName => $tableName) {
         if ($tableName[0] === ':') {
             $tableName = substr($tableName, 1);
             unset($modelClass);
         } else {
             $modelClass = \Yii::import($tableName, true);
             $tableName = CActiveRecord::model($modelClass)->tableName();
         }
         if (($prefix = $this->getDbConnection()->tablePrefix) !== null) {
             $tableName = preg_replace('/{{(.*?)}}/', $prefix . '\\1', $tableName);
         }
         $this->resetTable($tableName);
         $rows = $this->loadFixture($tableName);
         if (is_array($rows) && is_string($fixtureName)) {
             $this->_rows[$fixtureName] = $rows;
             if (isset($modelClass)) {
                 foreach (array_keys($rows) as $alias) {
                     $this->_records[$fixtureName][$alias] = $modelClass;
                 }
             }
         }
     }
     //$schema->checkIntegrity(true);
 }
Example #30
Show file File: ProductItemsWidget.php Project: qkongvan/k6-thuc-pham
0
 /**
  * run - Phương thức dùng để render nội dung widget
  */
 public function run()
 {
     Yii::import('application.modules.products.ProductsModule');
     // Đăng ký assets
     $baseScriptUrl = Yii::app()->assetManager->publish(dirname(__FILE__) . '/../assets');
     Yii::app()->getClientScript()->registerCssFile($baseScriptUrl . '/products.css');
     $action = isset($_GET['action']) ? $_GET['action'] : 'list';
     if ($action == 'list') {
         $category = isset($_GET['category']) ? $_GET['category'] : '';
         $data = $this->getListItems($category);
         if (empty($data)) {
             $this->render('no-result');
         } else {
             $this->render('list', array('data' => $data, 'pages' => $this->__pagination, 'category' => $this->__category, 'baseScriptUrl' => $baseScriptUrl));
         }
     } else {
         if ($action == 'detail') {
             $product = isset($_GET['product']) ? $_GET['product'] : '';
             $data = $this->getDetail($product);
             if (empty($data)) {
                 $this->render('no-result');
             } else {
                 $this->render('detail', array('data' => $data, 'baseScriptUrl' => $baseScriptUrl));
             }
         } else {
             $this->render('no-result');
         }
     }
 }