Browse Source

specified proper namespaces

tags/2.0.0-beta
Alexander Makarov 12 years ago
parent
commit
e8d59fb6cb
  1. 2
      apps/advanced/backstage/config/main.php
  2. 2
      apps/advanced/backstage/controllers/SiteController.php
  3. 63
      apps/advanced/common/models/ContactForm.php
  4. 58
      apps/advanced/common/models/LoginForm.php
  5. 2
      apps/advanced/common/models/User.php
  6. 2
      apps/advanced/console/config/main.php
  7. 2
      apps/advanced/frontend/config/main.php
  8. 2
      apps/advanced/frontend/controllers/SiteController.php
  9. 2
      apps/advanced/frontend/models/ContactForm.php
  10. 2
      apps/advanced/frontend/models/LoginForm.php
  11. 2
      apps/advanced/frontend/models/User.php

2
apps/advanced/backstage/config/main.php

@ -12,7 +12,7 @@ return array(
'id' => 'change-me', 'id' => 'change-me',
'basePath' => dirname(__DIR__), 'basePath' => dirname(__DIR__),
'preload' => array('log'), 'preload' => array('log'),
'controllerNamespace' => 'app\controllers', 'controllerNamespace' => 'backstage\controllers',
'modules' => array( 'modules' => array(
), ),
'components' => array( 'components' => array(

2
apps/advanced/backstage/controllers/SiteController.php

@ -1,6 +1,6 @@
<?php <?php
namespace app\controllers; namespace backstage\controllers;
use Yii; use Yii;
use yii\web\Controller; use yii\web\Controller;

63
apps/advanced/common/models/ContactForm.php

@ -1,63 +0,0 @@
<?php
namespace app\models;
use yii\base\Model;
/**
* ContactForm is the model behind the contact form.
*/
class ContactForm extends Model
{
public $name;
public $email;
public $subject;
public $body;
public $verifyCode;
/**
* @return array the validation rules.
*/
public function rules()
{
return array(
// name, email, subject and body are required
array('name, email, subject, body', 'required'),
// email has to be a valid email address
array('email', 'email'),
// verifyCode needs to be entered correctly
array('verifyCode', 'captcha'),
);
}
/**
* @return array customized attribute labels
*/
public function attributeLabels()
{
return array(
'verifyCode' => 'Verification Code',
);
}
/**
* Sends an email to the specified email address using the information collected by this model.
* @param string $email the target email address
* @return boolean whether the model passes validation
*/
public function contact($email)
{
if ($this->validate()) {
$name = '=?UTF-8?B?' . base64_encode($this->name) . '?=';
$subject = '=?UTF-8?B?' . base64_encode($this->subject) . '?=';
$headers = "From: $name <{$this->email}>\r\n" .
"Reply-To: {$this->email}\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-type: text/plain; charset=UTF-8";
mail($email, $subject, $this->body, $headers);
return true;
} else {
return false;
}
}
}

58
apps/advanced/common/models/LoginForm.php

@ -1,58 +0,0 @@
<?php
namespace app\models;
use Yii;
use yii\base\Model;
/**
* LoginForm is the model behind the login form.
*/
class LoginForm extends Model
{
public $username;
public $password;
public $rememberMe = true;
/**
* @return array the validation rules.
*/
public function rules()
{
return array(
// username and password are both required
array('username, password', 'required'),
// password is validated by validatePassword()
array('password', 'validatePassword'),
// rememberMe must be a boolean value
array('rememberMe', 'boolean'),
);
}
/**
* Validates the password.
* This method serves as the inline validation for password.
*/
public function validatePassword()
{
$user = User::findByUsername($this->username);
if (!$user || !$user->validatePassword($this->password)) {
$this->addError('password', 'Incorrect username or password.');
}
}
/**
* Logs in a user using the provided username and password.
* @return boolean whether the user is logged in successfully
*/
public function login()
{
if ($this->validate()) {
$user = User::findByUsername($this->username);
Yii::$app->user->login($user, $this->rememberMe ? 3600*24*30 : 0);
return true;
} else {
return false;
}
}
}

2
apps/advanced/common/models/User.php

@ -1,6 +1,6 @@
<?php <?php
namespace app\models; namespace common\models;
class User extends \yii\base\Object implements \yii\web\Identity class User extends \yii\base\Object implements \yii\web\Identity
{ {

2
apps/advanced/console/config/main.php

@ -12,7 +12,7 @@ return array(
'id' => 'change-me', 'id' => 'change-me',
'basePath' => dirname(__DIR__), 'basePath' => dirname(__DIR__),
'preload' => array('log'), 'preload' => array('log'),
'controllerNamespace' => 'app\controllers', 'controllerNamespace' => 'console\controllers',
'modules' => array( 'modules' => array(
), ),
'components' => array( 'components' => array(

2
apps/advanced/frontend/config/main.php

@ -12,7 +12,7 @@ return array(
'id' => 'change-me', 'id' => 'change-me',
'basePath' => dirname(__DIR__), 'basePath' => dirname(__DIR__),
'preload' => array('log'), 'preload' => array('log'),
'controllerNamespace' => 'app\controllers', 'controllerNamespace' => 'frontend\controllers',
'modules' => array( 'modules' => array(
), ),
'components' => array( 'components' => array(

2
apps/advanced/frontend/controllers/SiteController.php

@ -1,6 +1,6 @@
<?php <?php
namespace app\controllers; namespace frontend\controllers;
use Yii; use Yii;
use yii\web\Controller; use yii\web\Controller;

2
apps/advanced/frontend/models/ContactForm.php

@ -1,6 +1,6 @@
<?php <?php
namespace app\models; namespace frontend\models;
use yii\base\Model; use yii\base\Model;

2
apps/advanced/frontend/models/LoginForm.php

@ -1,6 +1,6 @@
<?php <?php
namespace app\models; namespace frontend\models;
use Yii; use Yii;
use yii\base\Model; use yii\base\Model;

2
apps/advanced/frontend/models/User.php

@ -1,6 +1,6 @@
<?php <?php
namespace app\models; namespace frontend\models;
class User extends \yii\base\Object implements \yii\web\Identity class User extends \yii\base\Object implements \yii\web\Identity
{ {

Loading…
Cancel
Save