Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
initial application frame
yiiext extensions migrate command and smarty
  • Loading branch information
cebe committed Oct 12, 2011
0 parents commit c7e2d5f
Show file tree
Hide file tree
Showing 56 changed files with 2,365 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .gitignore
@@ -0,0 +1,14 @@
# yii
yii

# assets
web/assets/*

# runtime data
application/runtime/*

# sqlite db
application/data/*

# vendor symlinks
application/vendors/Smarty
6 changes: 6 additions & 0 deletions .gitmodules
@@ -0,0 +1,6 @@
[submodule "application/extensions/yiiext/renderers/smarty"]
path = application/extensions/yiiext/renderers/smarty
url = https://github.com/yiiext/smarty-renderer.git
[submodule "application/extensions/yiiext/commands/migrate"]
path = application/extensions/yiiext/commands/migrate
url = https://github.com/yiiext/migrate-command.git
1 change: 1 addition & 0 deletions application/commands/shell/README
@@ -0,0 +1 @@
add yiic shell commands here
23 changes: 23 additions & 0 deletions application/components/Controller.php
@@ -0,0 +1,23 @@
<?php
/**
* Controller is the customized base controller class.
* All controller classes for this application should extend from this base class.
*/
class Controller extends CController
{
/**
* @var string the default layout for the controller view. Defaults to '//layouts/column1',
* meaning using a single column layout. See 'protected/views/layouts/column1.php'.
*/
public $layout='//layouts/column1';
/**
* @var array context menu items. This property will be assigned to {@link CMenu::items}.
*/
public $menu=array();
/**
* @var array the breadcrumbs of the current page. The value of this property will
* be assigned to {@link CBreadcrumbs::links}. Please refer to {@link CBreadcrumbs::links}
* for more details on how to specify this property.
*/
public $breadcrumbs=array();
}
33 changes: 33 additions & 0 deletions application/components/UserIdentity.php
@@ -0,0 +1,33 @@
<?php

/**
* UserIdentity represents the data needed to identity a user.
* It contains the authentication method that checks if the provided
* data can identity the user.
*/
class UserIdentity extends CUserIdentity
{
/**
* 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=array(
// username => password
'demo'=>'demo',
'admin'=>'admin',
);
if(!isset($users[$this->username]))
$this->errorCode=self::ERROR_USERNAME_INVALID;
else if($users[$this->username]!==$this->password)
$this->errorCode=self::ERROR_PASSWORD_INVALID;
else
$this->errorCode=self::ERROR_NONE;
return !$this->errorCode;
}
}
55 changes: 55 additions & 0 deletions application/config/console.php
@@ -0,0 +1,55 @@
<?php

// This is the configuration for yiic console application.
// Any writable CConsoleApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Console Application',
// application components
'components'=>array(
//*
'db'=>array(
'connectionString' => 'sqlite:'.dirname(dirname(__FILE__)).'/data/testdrive.db',
'initSQLs' => array("PRAGMA foreign_keys = ON;"),
),
// */
// uncomment the following to use a MySQL database
/*
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=code-dashboard',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
),
// */
),

'commandMap' => array(
'migrate' => array(
// alias of the path where you extracted the zip file
'class' => 'application.extensions.yiiext.commands.migrate.EMigrateCommand',
// this is the path where you want your core application migrations to be created
'migrationPath' => 'application.migrations',
// the name of the table created in your database to save versioning information
'migrationTable' => 'migrations',
// the application migrations are in a pseudo-module called "core" by default
'applicationModuleName' => 'core',
// define all available modules
'modulePaths' => array(
/* 'admin' => 'application.modules.admin.db.migrations',
'user' => 'application.modules.user.db.migrations',
'yourModule' => 'application.any.other.path.possible',
// ...*/
),
// here you can configrue which modules should be active, you can disable a module by adding its name to this array
/* 'disabledModules' => array(
'admin', 'anOtherModule', // ...
),*/
// the name of the application component that should be used to connect to the database
'connectionID'=>'db',
// alias of the template file used to create new migrations
//'templateFile'=>'application.db.migration_template',
),
),
);
102 changes: 102 additions & 0 deletions application/config/main.php
@@ -0,0 +1,102 @@
<?php

// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
$return = array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'Web Management',

// preloading 'log' component
'preload'=>array('log'),

// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
),

'modules'=>array(
// uncomment the following to enable the Gii tool
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'LetMeIn1337',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
),
),

// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
),
// uncomment the following to enable URLs in path-format
/*
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
*/
'db'=>array(
'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
),
// uncomment the following to use a MySQL database
/*
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=testdrive',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
),
*/
'errorHandler'=>array(
// use 'site/error' action to display errors
'errorAction'=>'site/error',
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
// uncomment the following to show log messages on web pages
/*
array(
'class'=>'CWebLogRoute',
),
*/
),
),
'viewRenderer'=>array(
'class'=>'application.extensions.yiiext.renderers.smarty.ESmartyViewRenderer',
'fileExtension' => '.tpl',
'pluginsDir' => 'application.extensions.smartyPlugins',
'configDir' => 'application.config.smarty',
),
),

// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
// this is used in contact page
'adminEmail'=>'webmaster@example.com',
),
);

$siteConfigFile = dirname(dirname(__FILE__)) . '/sites/_this_/main.php';
if (file_exists($siteConfigFile)) {
$return = CMap::mergeArray($return, include($siteConfigFile));
}

return $return;

17 changes: 17 additions & 0 deletions application/config/test.php
@@ -0,0 +1,17 @@
<?php

return CMap::mergeArray(
require(dirname(__FILE__).'/main.php'),
array(
'components'=>array(
'fixture'=>array(
'class'=>'system.test.CDbFixtureManager',
),
/* uncomment the following to provide test database connection
'db'=>array(
'connectionString'=>'DSN for test database',
),
*/
),
)
);
103 changes: 103 additions & 0 deletions application/controllers/SiteController.php
@@ -0,0 +1,103 @@
<?php

class SiteController extends Controller
{
/**
* Declares class-based actions.
*/
public function actions()
{
return array(
// captcha action renders the CAPTCHA image displayed on the contact page
'captcha'=>array(
'class'=>'CCaptchaAction',
'backColor'=>0xFFFFFF,
),
// page action renders "static" pages stored under 'protected/views/site/pages'
// They can be accessed via: index.php?r=site/page&view=FileName
'page'=>array(
'class'=>'CViewAction',
),
);
}

/**
* This is the default 'index' action that is invoked
* when an action is not explicitly requested by users.
*/
public function actionIndex()
{
// renders the view file 'protected/views/site/index.php'
// using the default layout 'protected/views/layouts/main.php'
$this->render('index');
}

/**
* This is the action to handle external exceptions.
*/
public function actionError()
{
if($error=Yii::app()->errorHandler->error)
{
if(Yii::app()->request->isAjaxRequest)
echo $error['message'];
else
$this->render('error', $error);
}
}

/**
* Displays the contact page
*/
public function actionContact()
{
$model=new ContactForm;
if(isset($_POST['ContactForm']))
{
$model->attributes=$_POST['ContactForm'];
if($model->validate())
{
$headers="From: {$model->email}\r\nReply-To: {$model->email}";
mail(Yii::app()->params['adminEmail'],$model->subject,$model->body,$headers);
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));
}

/**
* Displays the login page
*/
public function actionLogin()
{
$model=new LoginForm;

// if it is ajax validation request
if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}

// collect user input data
if(isset($_POST['LoginForm']))
{
$model->attributes=$_POST['LoginForm'];
// validate user input and redirect to the previous page if valid
if($model->validate() && $model->login())
$this->redirect(Yii::app()->user->returnUrl);
}
// display the login form
$this->render('login',array('model'=>$model));
}

/**
* Logs out the current user and redirect to homepage.
*/
public function actionLogout()
{
Yii::app()->user->logout();
$this->redirect(Yii::app()->homeUrl);
}
}
7 changes: 7 additions & 0 deletions application/extensions/EXTENSION_INFO
@@ -0,0 +1,7 @@
information on installed extensions


smarty-view-renderer 0.9.8

http://www.yiiframework.com/extension/smarty-view-renderer

1 change: 1 addition & 0 deletions application/extensions/smartyPlugins/README
@@ -0,0 +1 @@
add your smarty plugins here
1 change: 1 addition & 0 deletions application/extensions/yiiext/commands/migrate
Submodule migrate added at f81b5c
1 change: 1 addition & 0 deletions application/extensions/yiiext/renderers/smarty
Submodule smarty added at 019391

0 comments on commit c7e2d5f

Please sign in to comment.