Started working on Navbar
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ContactForm class.
|
||||
* ContactForm is the data structure for keeping
|
||||
* contact form data. It is used by the 'contact' action of 'SiteController'.
|
||||
*/
|
||||
class ContactForm extends CFormModel
|
||||
{
|
||||
public $name;
|
||||
public $email;
|
||||
public $subject;
|
||||
public $body;
|
||||
public $verifyCode;
|
||||
|
||||
/**
|
||||
* Declares 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', 'allowEmpty'=>!CCaptcha::checkRequirements()),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares customized attribute labels.
|
||||
* If not declared here, an attribute would have a label that is
|
||||
* the same as its name with the first letter in upper case.
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return array(
|
||||
'verifyCode'=>'Verification Code',
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* LoginForm class.
|
||||
* LoginForm is the data structure for keeping
|
||||
* user login form data. It is used by the 'login' action of 'SiteController'.
|
||||
*/
|
||||
class LoginForm extends CFormModel
|
||||
{
|
||||
public $username;
|
||||
public $password;
|
||||
public $rememberMe;
|
||||
|
||||
private $_identity;
|
||||
|
||||
/**
|
||||
* Declares the validation rules.
|
||||
* The rules state that username and password are required,
|
||||
* and password needs to be authenticated.
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return array(
|
||||
// username and password are required
|
||||
array('username, password', 'required'),
|
||||
// rememberMe needs to be a boolean
|
||||
array('rememberMe', 'boolean'),
|
||||
// password needs to be authenticated
|
||||
array('password', 'authenticate'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares attribute labels.
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return array(
|
||||
'rememberMe'=>'Remember me next time',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticates the password.
|
||||
* This is the 'authenticate' validator as declared in rules().
|
||||
*/
|
||||
public function authenticate($attribute,$params)
|
||||
{
|
||||
if(!$this->hasErrors())
|
||||
{
|
||||
$this->_identity=new UserIdentity($this->username,$this->password);
|
||||
if(!$this->_identity->authenticate())
|
||||
$this->addError('password','Incorrect username or password.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs in the user using the given username and password in the model.
|
||||
* @return boolean whether login is successful
|
||||
*/
|
||||
public function login()
|
||||
{
|
||||
if($this->_identity===null)
|
||||
{
|
||||
$this->_identity=new UserIdentity($this->username,$this->password);
|
||||
$this->_identity->authenticate();
|
||||
}
|
||||
if($this->_identity->errorCode===UserIdentity::ERROR_NONE)
|
||||
{
|
||||
$duration=$this->rememberMe ? 3600*24*30 : 0; // 30 days
|
||||
Yii::app()->user->login($this->_identity,$duration);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
<?php /* @var $this Controller */ ?>
|
||||
<?php $this->beginContent('//layouts/main'); ?>
|
||||
<div id="content">
|
||||
<?php echo $content; ?>
|
||||
</div><!-- content -->
|
||||
<?php $this->endContent(); ?>
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php /* @var $this Controller */ ?>
|
||||
<?php $this->beginContent('//layouts/main'); ?>
|
||||
<div class="span-19">
|
||||
<div id="content">
|
||||
<?php echo $content; ?>
|
||||
</div><!-- content -->
|
||||
</div>
|
||||
<div class="span-5 last">
|
||||
<div id="sidebar">
|
||||
<?php
|
||||
$this->beginWidget('zii.widgets.CPortlet', array(
|
||||
'title'=>'Operations',
|
||||
));
|
||||
$this->widget('zii.widgets.CMenu', array(
|
||||
'items'=>$this->menu,
|
||||
'htmlOptions'=>array('class'=>'operations'),
|
||||
));
|
||||
$this->endWidget();
|
||||
?>
|
||||
</div><!-- sidebar -->
|
||||
</div>
|
||||
<?php $this->endContent(); ?>
|
||||
@@ -15,75 +15,65 @@
|
||||
<meta name="viewport" content="width=device-width">
|
||||
|
||||
<?php Yii::app()->bootstrap->register(); ?>
|
||||
|
||||
<style>
|
||||
body {
|
||||
padding-top: 41px; /* Because of navbar */
|
||||
padding-bottom: 40px;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
<title><?php echo CHtml::encode($this->pageTitle); ?></title>
|
||||
</head>
|
||||
<body>
|
||||
<!--[if lt IE 7]>
|
||||
<p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade
|
||||
your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to
|
||||
improve your experience.</p>
|
||||
<![endif]-->
|
||||
<!--if lt IE 7]>
|
||||
<p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
|
||||
<!endif]-->
|
||||
|
||||
<!-- This code is taken from http://twitter.github.com/bootstrap/examples/hero.html -->
|
||||
<?php
|
||||
$this->widget('bootstrap.widgets.TbNavbar',
|
||||
[
|
||||
'brandLabel' => Yii::app()->name,
|
||||
'display' => null, // default is static to top
|
||||
'items' =>
|
||||
[
|
||||
[
|
||||
'class' => 'bootstrap.widgets.TbNav',
|
||||
'items' =>
|
||||
[
|
||||
array('label' => 'Home', 'url' => '/', 'active' => true),
|
||||
array('label' => 'Blog', 'url' => '#', 'active' => false),
|
||||
array('label' => 'Programme', 'url' => '#', 'active' => false),
|
||||
array('label' => 'About', 'url' => '#', 'active' => false),
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</a>
|
||||
<a class="brand" href="#"><?php echo CHtml::encode(Yii::app()->name); ?></a>
|
||||
|
||||
<div class="nav-collapse collapse">
|
||||
<ul class="nav">
|
||||
<li class="active"><a href="#">Home</a></li>
|
||||
<li><a href="#about">About</a></li>
|
||||
<li><a href="#contact">Contact</a></li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="#">Action</a></li>
|
||||
<li><a href="#">Another action</a></li>
|
||||
<li><a href="#">Something else here</a></li>
|
||||
<li class="divider"></li>
|
||||
<li class="nav-header">Nav header</li>
|
||||
<li><a href="#">Separated link</a></li>
|
||||
<li><a href="#">One more separated link</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<form class="navbar-form pull-right">
|
||||
<input class="span2" type="text" placeholder="Email">
|
||||
<input class="span2" type="password" placeholder="Password">
|
||||
<button type="submit" class="btn">Sign in</button>
|
||||
</form>
|
||||
</div>
|
||||
<!--/.nav-collapse -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
],
|
||||
],
|
||||
|
||||
<?php
|
||||
TbHtml::navbarSearchForm('search', '',
|
||||
[
|
||||
'class' => 'pull-right',
|
||||
|
||||
'placeholder' => 'Search',
|
||||
|
||||
'inputOptions' =>
|
||||
[
|
||||
'append' => TbHtml::submitButton(TbHtml::icon(TbHtml::ICON_SEARCH)),
|
||||
'addOnOptions' =>
|
||||
[
|
||||
'class' => 'pull-right',
|
||||
],
|
||||
'span' => 2,
|
||||
]
|
||||
]),
|
||||
],
|
||||
]);
|
||||
?>
|
||||
|
||||
<?php
|
||||
if(isset($this->breadcrumbs))
|
||||
{
|
||||
$this->widget('bootstrap.widgets.TbBreadcrumb', array(
|
||||
'links'=>$this->breadcrumbs,
|
||||
));
|
||||
));
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
echo $content;
|
||||
<?php
|
||||
echo $content;
|
||||
?>
|
||||
|
||||
<div id="footer">
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
<?php
|
||||
/* @var $this SiteController */
|
||||
/* @var $model ContactForm */
|
||||
/* @var $form CActiveForm */
|
||||
|
||||
$this->pageTitle=Yii::app()->name . ' - Contact Us';
|
||||
$this->breadcrumbs=array(
|
||||
'Contact',
|
||||
);
|
||||
?>
|
||||
|
||||
<h1>Contact Us</h1>
|
||||
|
||||
<?php if(Yii::app()->user->hasFlash('contact')): ?>
|
||||
|
||||
<div class="flash-success">
|
||||
<?php echo Yii::app()->user->getFlash('contact'); ?>
|
||||
</div>
|
||||
|
||||
<?php else: ?>
|
||||
|
||||
<p>
|
||||
If you have business inquiries or other questions, please fill out the following form to contact us. Thank you.
|
||||
</p>
|
||||
|
||||
<div class="form">
|
||||
|
||||
<?php $form=$this->beginWidget('CActiveForm', array(
|
||||
'id'=>'contact-form',
|
||||
'enableClientValidation'=>true,
|
||||
'clientOptions'=>array(
|
||||
'validateOnSubmit'=>true,
|
||||
),
|
||||
)); ?>
|
||||
|
||||
<p class="note">Fields with <span class="required">*</span> are required.</p>
|
||||
|
||||
<?php echo $form->errorSummary($model); ?>
|
||||
|
||||
<div class="row">
|
||||
<?php echo $form->labelEx($model,'name'); ?>
|
||||
<?php echo $form->textField($model,'name'); ?>
|
||||
<?php echo $form->error($model,'name'); ?>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<?php echo $form->labelEx($model,'email'); ?>
|
||||
<?php echo $form->textField($model,'email'); ?>
|
||||
<?php echo $form->error($model,'email'); ?>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<?php echo $form->labelEx($model,'subject'); ?>
|
||||
<?php echo $form->textField($model,'subject',array('size'=>60,'maxlength'=>128)); ?>
|
||||
<?php echo $form->error($model,'subject'); ?>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<?php echo $form->labelEx($model,'body'); ?>
|
||||
<?php echo $form->textArea($model,'body',array('rows'=>6, 'cols'=>50)); ?>
|
||||
<?php echo $form->error($model,'body'); ?>
|
||||
</div>
|
||||
|
||||
<?php if(CCaptcha::checkRequirements()): ?>
|
||||
<div class="row">
|
||||
<?php echo $form->labelEx($model,'verifyCode'); ?>
|
||||
<div>
|
||||
<?php $this->widget('CCaptcha'); ?>
|
||||
<?php echo $form->textField($model,'verifyCode'); ?>
|
||||
</div>
|
||||
<div class="hint">Please enter the letters as they are shown in the image above.
|
||||
<br/>Letters are not case-sensitive.</div>
|
||||
<?php echo $form->error($model,'verifyCode'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="row buttons">
|
||||
<?php echo CHtml::submitButton('Submit'); ?>
|
||||
</div>
|
||||
|
||||
<?php $this->endWidget(); ?>
|
||||
|
||||
</div><!-- form -->
|
||||
|
||||
<?php endif; ?>
|
||||
@@ -2,14 +2,14 @@
|
||||
/* @var $this SiteController */
|
||||
/* @var $error array */
|
||||
|
||||
$this->pageTitle=Yii::app()->name . ' - Error';
|
||||
$this->breadcrumbs=array(
|
||||
'Error',
|
||||
);
|
||||
$this->pageTitle=Yii::app()->name . ' - Error';
|
||||
|
||||
$this->breadcrumbs=array(
|
||||
'Error',
|
||||
);
|
||||
|
||||
$this->widget('bootstrap.widgets.TbHeroUnit', array(
|
||||
'heading' => 'ERROR ' . $code,
|
||||
'content' => $message,
|
||||
));
|
||||
?>
|
||||
|
||||
<h2>Error <?php echo $code; ?></h2>
|
||||
|
||||
<div class="error">
|
||||
<?php echo CHtml::encode($message); ?>
|
||||
</div>
|
||||
@@ -2,19 +2,83 @@
|
||||
/* @var $this SiteController */
|
||||
|
||||
$this->pageTitle=Yii::app()->name;
|
||||
|
||||
$this->breadcrumbs=
|
||||
[
|
||||
'Index'
|
||||
];
|
||||
?>
|
||||
|
||||
<h1>Welcome to <i><?php echo CHtml::encode(Yii::app()->name); ?></i></h1>
|
||||
<div class="container">
|
||||
|
||||
<p>Congratulations! You have successfully created your Yii application.</p>
|
||||
<!-- Main hero unit for a primary marketing message or call to action -->
|
||||
<div class="hero-unit">
|
||||
<h1>Hello, world!</h1>
|
||||
|
||||
<p>You may change the content of this page by modifying the following two files:</p>
|
||||
<ul>
|
||||
<li>View file: <code><?php echo __FILE__; ?></code></li>
|
||||
<li>Layout file: <code><?php echo $this->getLayoutFile('main'); ?></code></li>
|
||||
</ul>
|
||||
<p>
|
||||
|
||||
<ul>
|
||||
<li>View file: <code><?php echo __FILE__; ?></code></li>
|
||||
<li>Layout file: <code><?php echo $this->getLayoutFile('main'); ?></code></li>
|
||||
</ul>
|
||||
|
||||
</p>
|
||||
|
||||
<p>For more details on how to further develop this application, please read
|
||||
the <a href="http://www.yiiframework.com/doc/">documentation</a>.
|
||||
Feel free to ask in the <a href="http://www.yiiframework.com/forum/">forum</a>,
|
||||
should you have any questions.</p>
|
||||
<p><a class="btn btn-primary btn-large">Learn more »</a></p>
|
||||
</div>
|
||||
|
||||
<!-- Example row of columns -->
|
||||
<div class="row">
|
||||
<div class="span4">
|
||||
<h2>Heading YD: <?php echo YII_DEBUG ?></h2>
|
||||
|
||||
<p>
|
||||
|
||||
<?php
|
||||
$connection = Yii::app()->db;
|
||||
|
||||
$command=$connection->createCommand("SELECT * FROM programme");
|
||||
$command->execute(); // a non-query SQL statement execution
|
||||
// or execute an SQL query and fetch the result set
|
||||
$reader=$command->query();
|
||||
|
||||
// each $row is an array representing a row of data
|
||||
$dbgtxt = "";
|
||||
foreach($reader as $row)
|
||||
{
|
||||
$dbgtxt = $dbgtxt . print_r($row, true);
|
||||
}
|
||||
|
||||
echo TbHtml::textArea('dbgtxt', $dbgtxt, array('rows' => 5));
|
||||
?>
|
||||
|
||||
</p>
|
||||
|
||||
<p><a class="btn" href="#">View details »</a></p>
|
||||
</div>
|
||||
<div class="span4">
|
||||
<h2>Heading</h2>
|
||||
|
||||
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris
|
||||
condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis
|
||||
euismod. Donec sed odio dui. </p>
|
||||
|
||||
<p><a class="btn" href="#">View details »</a></p>
|
||||
</div>
|
||||
<div class="span4">
|
||||
<h2>Heading</h2>
|
||||
|
||||
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula
|
||||
porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut
|
||||
fermentum massa justo sit amet risus.</p>
|
||||
|
||||
<p><a class="btn" href="#">View details »</a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<footer>
|
||||
<p>© Company 2012</p>
|
||||
</footer>
|
||||
</div>
|
||||
@@ -1,53 +0,0 @@
|
||||
<?php
|
||||
/* @var $this SiteController */
|
||||
/* @var $model LoginForm */
|
||||
/* @var $form CActiveForm */
|
||||
|
||||
$this->pageTitle=Yii::app()->name . ' - Login';
|
||||
$this->breadcrumbs=array(
|
||||
'Login',
|
||||
);
|
||||
?>
|
||||
|
||||
<h1>Login</h1>
|
||||
|
||||
<p>Please fill out the following form with your login credentials:</p>
|
||||
|
||||
<div class="form">
|
||||
<?php $form=$this->beginWidget('CActiveForm', array(
|
||||
'id'=>'login-form',
|
||||
'enableClientValidation'=>true,
|
||||
'clientOptions'=>array(
|
||||
'validateOnSubmit'=>true,
|
||||
),
|
||||
)); ?>
|
||||
|
||||
<p class="note">Fields with <span class="required">*</span> are required.</p>
|
||||
|
||||
<div class="row">
|
||||
<?php echo $form->labelEx($model,'username'); ?>
|
||||
<?php echo $form->textField($model,'username'); ?>
|
||||
<?php echo $form->error($model,'username'); ?>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<?php echo $form->labelEx($model,'password'); ?>
|
||||
<?php echo $form->passwordField($model,'password'); ?>
|
||||
<?php echo $form->error($model,'password'); ?>
|
||||
<p class="hint">
|
||||
Hint: You may login with <kbd>demo</kbd>/<kbd>demo</kbd> or <kbd>admin</kbd>/<kbd>admin</kbd>.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="row rememberMe">
|
||||
<?php echo $form->checkBox($model,'rememberMe'); ?>
|
||||
<?php echo $form->label($model,'rememberMe'); ?>
|
||||
<?php echo $form->error($model,'rememberMe'); ?>
|
||||
</div>
|
||||
|
||||
<div class="row buttons">
|
||||
<?php echo CHtml::submitButton('Login'); ?>
|
||||
</div>
|
||||
|
||||
<?php $this->endWidget(); ?>
|
||||
</div><!-- form -->
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
/* @var $this SiteController */
|
||||
|
||||
$this->pageTitle=Yii::app()->name . ' - About';
|
||||
$this->breadcrumbs=array(
|
||||
'About',
|
||||
);
|
||||
?>
|
||||
<h1>About</h1>
|
||||
|
||||
<p>This is a "static" page. You may change the content of this page
|
||||
by updating the file <code><?php echo __FILE__; ?></code>.</p>
|
||||
Reference in New Issue
Block a user