当前位置: 首页>>代码示例>>PHP>>正文


PHP Yii::createComponent方法代码示例

本文整理汇总了PHP中Yii::createComponent方法的典型用法代码示例。如果您正苦于以下问题:PHP Yii::createComponent方法的具体用法?PHP Yii::createComponent怎么用?PHP Yii::createComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Yii的用法示例。


在下文中一共展示了Yii::createComponent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init

 public function init()
 {
     parent::init();
     if ($this->model === null) {
         $model = Yii::createComponent(array('class' => $this->formClass));
         $model->objectId = $this->objectParameter->id_object;
         $model->parameterId = $this->objectParameter->id_parameter;
         if ($this->mainModel->isNewRecord) {
             if (!$this->mainModel->getTmpId()) {
                 $this->mainModel->setTmpId($this->generateTmpId());
             }
             $model->tmpId = $this->mainModel->getTmpId();
         } else {
             $model->instanceId = $this->mainModel->getIdInstance();
         }
         $this->model = $model;
     }
     if ($this->uploadTemplate === null) {
         $this->uploadTemplate = 'template-upload-' . $this->id;
     }
     if ($this->downloadTemplate === null) {
         $this->downloadTemplate = 'template-download-' . $this->id;
     }
     if (!isset($this->htmlOptions['id'])) {
         $this->htmlOptions['id'] = $this->id;
     }
     $this->options = CMap::mergeArray($this->options, array('formData' => $this->model->toRequestParams(), 'uploadTemplateId' => $this->uploadTemplate, 'downloadTemplateId' => $this->downloadTemplate));
     if (!array_key_exists('previewMaxHeight', $this->options) && array_key_exists('height', $this->thumbConfig)) {
         $this->options['previewMaxHeight'] = $this->thumbConfig['height'];
     }
     if (!array_key_exists('previewMaxWidth', $this->options) && array_key_exists('width', $this->thumbConfig)) {
         $this->options['previewMaxWidth'] = $this->thumbConfig['width'];
     }
 }
开发者ID:Cranky4,项目名称:npfs,代码行数:34,代码来源:FileUploadWidget.php

示例2: downloadAs

 /**
  * Download content as text
  */
 public function downloadAs($title, $name, $content, $type = 'text')
 {
     $types = array('text' => 'text/plain', 'pdf' => 'application/pdf', 'word' => 'application/msword');
     $exts = array('text' => 'txt', 'pdf' => 'pdf', 'word' => 'doc');
     // Load anything?
     if ($type == 'pdf') {
         $pdf = Yii::createComponent('application.extensions.tcpdf.ETcPdf', 'P', 'cm', 'A4', true, 'UTF-8');
         $pdf->SetCreator(PDF_CREATOR);
         $pdf->SetAuthor(Yii::app()->name);
         $pdf->SetTitle($title);
         $pdf->SetSubject($title);
         $pdf->setPrintHeader(false);
         $pdf->setPrintFooter(false);
         $pdf->AliasNbPages();
         $pdf->AddPage();
         $pdf->writeHTML($content, true, 0, true, 0);
         $pdf->Output($name . '.' . $exts[$type], "I");
     }
     header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
     header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
     // Date in the past
     header('Pragma: no-cache');
     header("Content-Type: " . $types[$type] . "");
     header("Content-Disposition: attachment; filename=\"" . $name . '.' . $exts[$type] . "\";");
     header("Content-Length: " . mb_strlen($content));
     echo $content;
     exit;
 }
开发者ID:hansenmakangiras,项目名称:yiiframework-cms,代码行数:31,代码来源:Functions.php

示例3: createUrlWithoutBase

 /**
  * This method is Copyright (c) 2008-2014 by Yii Software LLC
  * http://www.yiiframework.com/license/  
  */
 public function createUrlWithoutBase($route, $params = array(), $ampersand = '&')
 {
     unset($params[$this->routeVar]);
     foreach ($params as $i => $param) {
         if ($param === null) {
             $params[$i] = '';
         }
     }
     if (isset($params['#'])) {
         $anchor = '#' . $params['#'];
         unset($params['#']);
     } else {
         $anchor = '';
     }
     $route = trim($route, '/');
     foreach ($this->_rules as $i => $rule) {
         if (is_array($rule)) {
             $this->_rules[$i] = $rule = Yii::createComponent($rule);
         }
         if (($url = $rule->createUrl($this, $route, $params, $ampersand)) !== false) {
             /* x2modstart */
             if ($rule->hasHostInfo) {
                 return $url === '' ? '/' . $anchor : $url . $anchor;
             } else {
                 return '/' . $url . $anchor;
             }
             /* x2modend */
         }
     }
     return $this->createUrlWithoutBaseDefault($route, $params, $ampersand) . $anchor;
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:35,代码来源:X2UrlManager.php

示例4: getTextHighlighter

 /**
  * @static
  * @return CTextHighlighter
  */
 public static function getTextHighlighter()
 {
     if (is_null(self::$_textHighlighter)) {
         self::$_textHighlighter = Yii::createComponent(array('class' => 'CTextHighlighter', 'language' => 'sql', 'showLineNumbers' => false));
     }
     return self::$_textHighlighter;
 }
开发者ID:alexskull,项目名称:Ushi,代码行数:11,代码来源:QtzPanelHelper.php

示例5: init

 /**
  *
  */
 public function init()
 {
     parent::init();
     $this->setHasher(Yii::createComponent($this->hasher));
     $this->setTokenStorage(Yii::createComponent($this->tokenStorage));
     $this->userModule = Yii::app()->getModule('user');
 }
开发者ID:yupe,项目名称:yupe,代码行数:10,代码来源:UserManager.php

示例6: send

 public function send($via, $to, $subject, $message, $params = array())
 {
     if (!is_array($to)) {
         $to = array($to);
     }
     if ($via == 'email') {
         $mailer = Yii::createComponent('application.extensions.mailer.EMailer');
         foreach ($this->email as $k => $v) {
             $mailer->{$k} = mb_convert_encoding($v, 'CP-1251', 'UTF-8');
         }
         foreach ($params as $k => $v) {
             $mailer->{$k} = mb_convert_encoding($v, 'CP-1251', 'UTF-8');
         }
         foreach ($to as $v) {
             $mailer->AddAddress($v);
         }
         $mailer->AddReplyTo($mailer->From);
         $mailer->CharSet = 'WINDOWS-1251';
         $mailer->SetLanguage(Yii::app()->language);
         $mailer->Subject = mb_convert_encoding($subject, 'CP-1251', 'UTF-8');
         $mailer->MsgHTML(mb_convert_encoding($message, 'CP-1251', 'UTF-8'), Yii::getPathOfAlias('webroot'));
         try {
             return $mailer->Send();
         } catch (phpmailerException $e) {
             // TODO: Отправлять в специальную таблицу недоставленных сообщений.
             // Чтобы можно было переотправить по крону или просмотреть на сайте
             //echo $e->getMessage()."\n";
             return false;
         }
     }
 }
开发者ID:rosko,项目名称:Tempo-CMS,代码行数:31,代码来源:Messenger.php

示例7: getToolbarWidget

 protected function getToolbarWidget()
 {
     if (null === $this->_toolbarWidget) {
         $this->_toolbarWidget = Yii::createComponent('YiiDebugToolbar', $this);
     }
     return $this->_toolbarWidget;
 }
开发者ID:vangogogo,项目名称:justsns,代码行数:7,代码来源:YiiDebugToolbarRoute.php

示例8: setUp

 protected function setUp()
 {
     $component = Yii::createComponent(array('class' => 'application.extensions.simpleWorkflow.SWPhpWorkflowSource', 'basePath' => 'application.tests.unit.task.workflows'));
     Yii::app()->setComponent('swSource', $component);
     Task_2_Test::$task2 = null;
     parent::setUp();
 }
开发者ID:honglei619,项目名称:simpleWorkflow,代码行数:7,代码来源:Task_2_Test.php

示例9: init

 /**
  * Генерируется уникальная метка страницы, подключается модуль просмотра,
  * устанавливается обработчик для сбора отладочной информации, регистрируются
  * скрипты для вывода дебаг-панели
  */
 public function init()
 {
     parent::init();
     if (!$this->enabled) {
         return;
     }
     Yii::setPathOfAlias('yii2-debug', dirname(__FILE__));
     Yii::app()->setImport(array('yii2-debug.*', 'yii2-debug.panels.*'));
     if ($this->logPath === null) {
         $this->logPath = Yii::app()->getRuntimePath() . '/debug';
     }
     $panels = array();
     foreach (CMap::mergeArray($this->corePanels(), $this->panels) as $id => $config) {
         if (!isset($config['highlightCode'])) {
             $config['highlightCode'] = $this->highlightCode;
         }
         $panels[$id] = Yii::createComponent($config, $this, $id);
     }
     $this->panels = $panels;
     Yii::app()->setModules(array($this->moduleId => array('class' => 'Yii2DebugModule', 'owner' => $this)));
     if ($this->internalUrls && Yii::app()->getUrlManager()->urlFormat == 'path') {
         $rules = array();
         foreach ($this->coreUrlRules() as $key => $value) {
             $rules[$this->moduleId . '/' . $key] = $this->moduleId . '/' . $value;
         }
         Yii::app()->getUrlManager()->addRules($rules, false);
     }
     Yii::app()->attachEventHandler('onEndRequest', array($this, 'onEndRequest'));
     $this->initToolbar();
 }
开发者ID:Cranky4,项目名称:npfs,代码行数:35,代码来源:Yii2Debug.php

示例10: log

	/**
	 * Sends passed message to all enabled channels matching specified level and category.
	 *
	 * @param mixed $msg if string, is treated as message to be logged, if an array, should contain 'old' and 'new' keys with CModel objects as values
	 * @param string $level level of the message (e.g. 'trace', 'warning', 'error'). It is case-insensitive.
	 * @param string $category category of the message (e.g. 'system.web'). It is case-insensitive.
	 */
	public static function log($msg,$level=CLogger::LEVEL_INFO,$category='application') {
		$cacheDuration=3600;
		$channels = NfyChannels::model()->cache($cacheDuration)->findAll('t.enabled=:enabled', array(':enabled'=>true));
		foreach($channels as $key=>$channel) {
			if ($channel->levels !== null) {
				$levels=preg_split('/[\s,]+/',strtolower($channel->levels),-1,PREG_SPLIT_NO_EMPTY);
				if (!in_array($level, $levels)) continue;
			}
			if ($channel->categories !== null) {
				$categories=preg_split('/[\s,]+/',strtolower($channel->categories),-1,PREG_SPLIT_NO_EMPTY);
				if (!in_array($category, $categories)) continue;
			}

			$route = Yii::createComponent(array(
				'class'=>$channel->route_class,
				'message_template'=>$channel->message_template,
			));
			if (!($route instanceof INfyRoute)) {
				$error = Yii::t('NfyModule.app', 'Route class {route} specified for channel {channel_name} must implement the INfyRoute interface.', array(
					'{route}' => $channel->route_class,
					'{channel_name}' => $channel->name,
				));
				// fail silently so the normal app workflow won't be disrupted by invalid notification configuration
				Yii::log($error, 'error', 'nfy');
				continue;
			}
			$route->process($msg, $channel->id, $channel->subscriptions);
		}
	}
开发者ID:Aplay,项目名称:Fastreview_site,代码行数:36,代码来源:Nfy.php

示例11: getDbConnection

 /**
  * @return CDbConnection
  */
 public function getDbConnection()
 {
     if ($this->dbc === null) {
         $this->dbc = Yii::createComponent(array('class' => 'CDbConnection', 'connectionString' => $this->getConnectionString(), 'username' => $this->user, 'password' => $this->password, 'charset' => 'utf8'));
     }
     return $this->dbc;
 }
开发者ID:Cranky4,项目名称:npfs,代码行数:10,代码来源:DbSettings.php

示例12: actionSendEmail

 public function actionSendEmail($id)
 {
     $mailer = Yii::createComponent('application.extensions.mailer.EMailer');
     $mailer->IsSMTP();
     $mailer->IsHTML(true);
     $mailer->SMTPAuth = true;
     /*
      $mailer->SMTPSecure = "ssl";
     $mailer->Host = "smtp.gmail.com";
     $mailer->Port = 465;
     $mailer->Username = "thony@folindonesia2013.com";
     $mailer->Password = 'thony2013';
     $mailer->From = "thony@folindonesia2013.com";
     */
     /**/
     $mailer->Host = "smtp.mail.yahoo.co.id";
     $mailer->Port = 25;
     $mailer->Username = "festivaloflive2013";
     $mailer->Password = 'jmmindonesia';
     $mailer->From = "festivaloflive2013@yahoo.co.id";
     /**/
     $mailer->CharSet = 'UTF-8';
     $mailer->addAttachment(Yii::app()->basePath . "/reports/BuktiTerima.php");
     //$mailer->addAttachment(Yii::app()->basePath."/reports/bukti_".$id.".pdf");
     $mailer->FromName = "Festival of Live 2013";
     $mailer->AddAddress("thonyronaldo.fol2013@gmail.com", "peterjkambey@gmail.com");
     $mailer->Subject = "FOL Bukti Registrasi";
     $mailer->Body = "FOL Bukti Registrasi";
     $mailer->Send();
     $this->redirect(array('/peserta'));
 }
开发者ID:rusli-nasir,项目名称:ERP_Accounting_Indonesia,代码行数:31,代码来源:SAdminController.php

示例13: _instantiateByConfig

 /**
  * Создает экземпляр класса по свойству данного модуля, которое содержит 
  * конфигурацию компонента Yii. 
  * 
  * Вызов $module->createProfileForm(), вернет компонент, конфигурация которого
  * находится в свойстве profileFormConfig
  * 
  * @param type $name    Имя метода
  * @param type $parameters  Параметры
  * @return type mixed
  */
 protected function _instantiateByConfig($name, $parameters)
 {
     $config = str_replace('create', '', $name, $replacements = 1);
     $config = lcfirst($config) . 'Config';
     $config = $this->{$config};
     return Yii::createComponent($config);
 }
开发者ID:vasiliy-pdk,项目名称:aes,代码行数:18,代码来源:PersonIdentifierModule.php

示例14: getSlave

 /**
  * Construct a slave connection CDbConnection for read operation.
  *
  * @return CDbConnection
  */
 public function getSlave()
 {
     if (!isset($this->_slave)) {
         foreach ($this->slaves as $slaveConfig) {
             if (!isset($slaveConfig['class'])) {
                 $slaveConfig['class'] = 'CDbConnection';
             }
             try {
                 if ($slave = Yii::createComponent($slaveConfig)) {
                     Yii::app()->setComponent('dbslave', $slave);
                     $this->_slave = $slave;
                     break;
                 }
             } catch (Exception $e) {
                 Yii::log('Create slave database connection failed!', 'warn');
                 continue;
             }
         }
         if (!$this->_slave) {
             $this->_slave = clone $this;
             $this->_slave->enableSlave = false;
         }
     }
     return $this->_slave;
 }
开发者ID:niujie123,项目名称:myself,代码行数:30,代码来源:FDbConnection.php

示例15: getFormatter

 public function getFormatter()
 {
     if (!isset($this->_formatter)) {
         $this->_formatter = Yii::createComponent(array('class' => $this->fieldFormatterClass, 'owner' => $this));
     }
     return $this->_formatter;
 }
开发者ID:shuvro35,项目名称:X2CRM,代码行数:7,代码来源:X2ActiveRecord.php


注:本文中的Yii::createComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。