本文整理汇总了PHP中Helpers::getYiiParam方法的典型用法代码示例。如果您正苦于以下问题:PHP Helpers::getYiiParam方法的具体用法?PHP Helpers::getYiiParam怎么用?PHP Helpers::getYiiParam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Helpers
的用法示例。
在下文中一共展示了Helpers::getYiiParam方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkUrl
public function checkUrl()
{
if ($this->url == self::URL_EXAMPLE) {
$this->url = '';
}
if (!$this->url && !$this->uploadedfile && !$this->content) {
$this->addError('url', Yii::t('swu', 'If you don\'t upload a file or input some text, you must provide a URL.'));
return;
}
if ($this->url) {
if (Helpers::getYiiParam('checkURL')) {
try {
$array = @get_headers($this->url);
} catch (Exception $e) {
$this->addError('url', Yii::t('swu', 'The URL provided is invalid.'));
return;
}
$string = $array[0];
if (strpos($string, "200") === false) {
$this->addError('url', 'The URL provided does not seem to work.');
return;
}
} else {
$valid_schemes = array('http', 'https', 'ftp');
$scheme = @parse_url($this->url, PHP_URL_SCHEME);
if (!in_array($scheme, $valid_schemes)) {
$this->addError('url', 'The URL provided does not validate. Valid schemes are: ' . implode(', ', $valid_schemes) . '.');
return;
}
}
}
}
示例2: authenticate
/**
* Authenticates a user.
* The example implementation makes sure if the username and password
* are both 'demo'.
* In practical applications, this should be changed to authenticate
* against some persistent user identity storage (e.g. database).
* @return boolean whether authentication succeeds.
*/
public function authenticate()
{
$users = Helpers::getYiiParam('admins');
if (!isset($users[$this->username])) {
$this->errorCode = self::ERROR_USERNAME_INVALID;
} elseif (crypt($this->password, $users[$this->username]) != $users[$this->username]) {
$this->errorCode = self::ERROR_PASSWORD_INVALID;
} else {
$this->errorCode = self::ERROR_NONE;
}
return !$this->errorCode;
}
示例3: sendCodes
public function sendCodes($controller)
{
if (!($student = Student::model()->findByAttributes(array('email' => $this->email)))) {
return false;
}
$exercises = Exercise::model()->with('assignment')->sortByDuedate()->findAllByAttributes(array('student_id' => $student->id));
foreach ($exercises as $exercise) {
$exercise->link = Yii::app()->controller->createAbsoluteSslUrl('exercise/info', array('k' => $exercise->generateAckKey()));
}
$options = array();
if (Helpers::getYiiParam('addOriginatingIP')) {
$options['originating_IP'] = sprintf('[%s]', Yii::app()->request->userHostAddress);
}
return MailTemplate::model()->mailFromTemplate('send_codes', array($student->email => $student->name), array('student' => $student, 'exercises' => $exercises), $options);
}
示例4: actionContact
/**
* Displays the contact page
*/
public function actionContact($name = '', $subject = '', $body = '')
{
$model = new ContactForm();
$model->name = $name;
$model->subject = $subject;
$model->body = $body;
if (isset($_POST['ContactForm'])) {
$model->attributes = $_POST['ContactForm'];
if ($model->validate()) {
MailTemplate::model()->mailFromTemplate('contact_form', Helpers::getYiiParam('adminEmail'), array('subject' => $model->subject, 'name' => $model->name, 'email' => $model->email, 'body' => $model->body), array('replyto' => $model->email));
Yii::app()->user->setFlash('contact', 'Thank you for contacting us. We will respond to you as soon as possible.');
$this->refresh();
}
}
$this->render('contact', array('model' => $model));
}
示例5: preFilter
protected function preFilter($filterChain)
{
if (!Helpers::getYiiParam('sslServerName')) {
return true;
}
if (!isset($_SERVER['HTTP_X_FORWARDED_HOST']) || isset($_SERVER['HTTP_X_FORWARDED_HOST']) && $_SERVER['HTTP_X_FORWARDED_HOST'] != Helpers::getYiiParam('sslServerName')) {
/*
* if ( !Yii::app()->getRequest()->isSecureConnection ) {
* This was the original check -- but it doesn't work with altervista...
*/
# Redirect to the secure version of the page.
$url = 'https://' . Helpers::getYiiParam('sslServerName') . Yii::app()->getRequest()->requestUri;
// die("Not a secure connection, redirecting to: " . $url);
Yii::app()->request->redirect($url);
return false;
}
return true;
}
示例6: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate($id = null)
{
$model = new Assignment();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Assignment'])) {
$model->attributes = $_POST['Assignment'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
if ($id) {
$cloned = $this->loadModel($id);
Helpers::object2object($cloned, $model, array('subject', 'title', 'description', 'checklist', 'url', 'duedate', 'grace', 'language', 'status', 'notification', 'shown_since'));
} else {
$model->grace = Helpers::getYiiParam('defaultGrace');
$model->duedate = date('Y-m-d') . ' 23:59:00';
$model->shown_since = date('Y-m-d H:i:s');
$model->language = Yii::app()->language;
$model->status = Helpers::getYiiParam('defaultAssignmentStatus');
$cloned = null;
}
$this->render('create', array('model' => $model, 'cloned' => $cloned));
}
示例7: findTemplateAndMakeReplacements
public function findTemplateAndMakeReplacements($code, $replacements)
{
$lang = Yii::app()->language;
if (!($this->_template = MailTemplate::findByAttributes(array('code' => $code, 'lang' => $lang)))) {
$lang = 'en';
// as a fallback, we look for a template in English
if (!($this->_template = MailTemplate::findByAttributes(array('code' => $code, 'lang' => $lang)))) {
throw new Exception("Could not find mail template {$code} (language: {$lang})");
}
}
$twig = new Twig();
foreach (array('subject', 'plaintext_body', 'html_body') as $field) {
$this->_template->{$field} = $twig->render($this->_template->{$field}, array_merge(array('site_url' => Helpers::getYiiParam('siteUrl'), 'site_name' => Yii::app()->name, 'lang' => $lang, 'now' => date('Y-m-d H:i:s')), $replacements));
}
}
示例8:
echo Yii::app()->user->getFlash('flash-error');
?>
</div>
<?php
}
?>
<?php
echo $content;
?>
<div class="clear"></div>
<div id="footer">
<?php
echo Helpers::getYiiParam('tagline');
?>
<br />
This website is based on the application <a href="<?php
echo SWU::WEBSITE;
?>
">SWU</a> (release <?php
echo SWU::RELEASE;
?>
), available under <a href="<?php
echo SWU::LICENSE_URL;
?>
">GNU Affero General Public License</a>.<br/>
<?php
echo Yii::powered();
?>
示例9: mail
public static function mail($to, $subject, $plaintext_body, $html_body = '', $options = array())
{
if (!Helpers::getYiiParam('sendEmails')) {
return true;
// we won't send emails if it is not enabled, but we won't fail!
}
$from = Helpers::getOption('from', $options, Helpers::getYiiParam('botEmail'));
if ($from == Helpers::getYiiParam('botEmail')) {
$sender = Yii::app()->name;
} else {
$sender = $from;
}
$replyto = Helpers::getOption('replyto', $options, $from);
$title = $subject;
$subject = self::b64($subject);
if (is_array($to)) {
// we expect an array to be like array('some@example.com'=>'John Doe')
$address = array_pop(array_keys($to));
$name = $to[$address];
} else {
$name = $address = $to;
}
$addressee = self::b64($name) . " <" . $address . ">";
$headers = array('From: ' . self::b64($sender) . " <{$from}>", "Reply-To: {$replyto}", 'MIME-Version: 1.0', "X-SWU-Version: " . SWU::RELEASE);
foreach (array('message_id' => 'Message', 'originating_IP' => 'Originating-IP') as $key => $value) {
if ($info = Helpers::getOption($key, $options, false)) {
$headers[] = 'X-SWU-' . $value . ': ' . $info;
}
}
$ack = Helpers::getOption('ack', $options, false);
$ack_link = $ack ? Yii::app()->getController()->createAbsoluteSslUrl('message/ack', array('k' => Helpers::generateAckKey($ack['message_id']))) : false;
$ack_image = Yii::app()->getController()->createAbsoluteSslUrl('site/image', array('name' => 'swu', 'k' => Helpers::generateAckKey(Helpers::getOption('message_id', $options))));
$htt = new MailTemplate();
$htt->findTemplateAndMakeReplacements('standard_head', array('title' => $subject, 'ack_link' => $ack_link, 'ack_image' => $ack_image));
list($plaintext_head, $html_head) = array($htt->getSubtemplateField('plaintext_body'), $htt->getSubtemplateField('html_body'));
$htt->findTemplateAndMakeReplacements('standard_tail', array('ack_link' => $ack_link, 'ack_image' => $ack_image));
list($plaintext_tail, $html_tail) = array($htt->getSubtemplateField('plaintext_body'), $htt->getSubtemplateField('html_body'));
if ($html_body) {
//create a boundary string. It must be unique
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time()));
//add boundary string and mime type specification
$headers[] = "Content-Type: multipart/mixed; boundary=\"PHP-mixed-{$random_hash}\"";
$html = quoted_printable_encode($html_head . $html_body . $html_tail);
}
$plaintext_body = quoted_printable_encode($plaintext_body);
if ($html_body) {
$body = <<<EOT
--PHP-mixed-{$random_hash}
Content-Type: multipart/alternative; boundary="PHP-alt-{$random_hash}"
--PHP-alt-{$random_hash}
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
{$plaintext_body}
--PHP-alt-{$random_hash}
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
{$html}
EOT;
} else {
$headers[] = "Content-type: text/plain; charset=UTF-8";
$headers[] = "Content-Transfer-Encoding: quoted-printable";
$body = $plaintext_body;
}
Yii::log('sending message to ' . $addressee, 'info', 'components.Mailer');
try {
if (mail($addressee, $subject, $body, implode("\r\n", array_merge($headers, Helpers::getYiiParam('customMailHeaders'))) . "\r\n")) {
return true;
}
} catch (Exception $e) {
Yii::log('failed sending message to ' . $addressee . ' ' . $e->getMessage(), 'error', 'components.Mailer');
return false;
}
return false;
}
示例10: array
<p class="note"><?php
echo Yii::t('swu', 'Here you can upload a file choosing it from your computer.');
?>
<?php
echo Yii::t('swu', 'Please note that the maximum allowed size is %number% KiB.', array('%number%' => Helpers::getYiiParam('uploadMaxSize')));
?>
<?php
echo Yii::t('swu', 'If your file is bigger, you can either zip it or use the URL tab.');
?>
</p>
<div class="row">
<?php
echo $form->labelEx($model, 'uploadedfile');
?>
<?php
echo $form->fileField($model, 'uploadedfile');
?>
<?php
echo $form->error($model, 'uploadedfile');
?>
</div>
示例11: _replaceSchemaAndHost
private function _replaceSchemaAndHost($url)
{
$redirection = Helpers::getYiiParam('redirection_url_replace');
return str_replace($redirection['from'], $redirection['to'], $url);
}
示例12: getHostName
public static function getHostName()
{
if ($name = self::getYiiParam('sslServerName')) {
return $name;
}
return 'http://' . Helpers::getYiiParam('siteUrl');
}
示例13: accessRules
/**
* Specifies the access control rules.
* This method is used by the 'accessControl' filter.
* @return array access control rules
*/
public function accessRules()
{
return array(array('allow', 'actions' => array('ack'), 'users' => array('*')), array('allow', 'actions' => array('index', 'view', 'create', 'update', 'admin', 'delete', 'confirm', 'email', 'send', 'do', 'activation', 'toggle'), 'users' => array_keys(Helpers::getYiiParam('admins'))), array('deny', 'users' => array('*')));
}
示例14: accessRules
/**
* Specifies the access control rules.
* This method is used by the 'accessControl' filter.
* @return array access control rules
*/
public function accessRules()
{
return array(array('allow', 'actions' => array('none'), 'users' => array('*')), array('allow', 'actions' => array('password'), 'users' => array_keys(Helpers::getYiiParam('admins'))), array('deny', 'users' => array('*')));
}
示例15: accessRules
/**
* Specifies the access control rules.
* This method is used by the 'accessControl' filter.
* @return array access control rules
*/
public function accessRules()
{
return array(array('allow', 'actions' => array('info'), 'users' => array('*')), array('allow', 'actions' => array(), 'users' => array('@')), array('allow', 'actions' => array('create', 'update', 'index', 'view', 'admin', 'delete'), 'users' => array_keys(Helpers::getYiiParam('admins'))), array('deny', 'users' => array('*')));
}