Skip to content

Instantly share code, notes, and snippets.

@vikky410
vikky410 / Yii1-database-authenticate.php
Last active August 29, 2015 14:07
Yii1: database authentication : Put in UserIdentity
public function authenticate()
{
// $users=array(
// // username => password
// 'demo'=>'demo',
// 'admin'=>'admin',
// );
// if(!isset($users[$this->username]))
// $this->errorCode=self::ERROR_USERNAME_INVALID;
// elseif($users[$this->username]!==$this->password)
@vikky410
vikky410 / hashPassword
Last active August 29, 2015 14:07
Yii1: hash password before save
public function beforeSave() {
$this->password = $this->hashPassword($this->new_password);
return parent::beforeSave();
}
/**
* Checks if the given password is correct.
* @param string the password to be validated
* @return boolean whether the password is valid
*/
@vikky410
vikky410 / Yii1_theme_initilize
Created October 14, 2014 16:27
Yii1: theme initiliaze
public function init(){
parent::init();
Yii::app()->theme = "theme-name";
}
@vikky410
vikky410 / macros
Last active August 29, 2015 14:07 — forked from mnshankar/macros
<?php
/*********************************************************************************************
* Example usage (In view)
* <div class="welcome">
<?php echo Form::open(array('route'=>'process','class'=>'form-horizontal'))?>
<?php echo Form::textField('first_name')?>
<?php echo Form::textField('last_name')?>
<?php echo Form::emailField('email')?>
<?php echo Form::passwordField('password')?>
<?php echo Form::selectField('select_one', array('1'=>'abc', '2'=>'def'))?>
@vikky410
vikky410 / Yii1-base-url
Created October 13, 2014 18:14
Yii1: base url
<?php echo Yii::app()->request->baseUrl; ?>/
@vikky410
vikky410 / Yii1-css
Created October 13, 2014 18:10
Yii1: register css file
<?php Yii::app()->clientScript->registerCssFile(Yii::app()->request->baseUrl . "/css/admin/bootstrap.min.css") ?>
@vikky410
vikky410 / params
Created October 13, 2014 18:08
Yii1 : params
<?php echo Yii::app()->params['title'];?>
@vikky410
vikky410 / gist:52956e9915d2ddf49838
Created September 20, 2014 07:23
Wordpress Geneses: remove site description
//* Remove the site description
remove_action ( 'genesis_site_description', 'genesis_seo_site_description' );
@vikky410
vikky410 / registerjquery.php
Created September 17, 2014 10:43
Yii: register jquery
<?php
Yii::app()->clientScript->registerCoreScript('jquery');
?>
@vikky410
vikky410 / Yii1 Datepicker.php
Last active August 29, 2015 14:06
Yii1 Datepicker
<?php $this->widget('zii.widgets.jui.CJuiDatePicker',
array(
'name' => 'publication_date',
'attribute' => 'publication_date',
'model'=>$model,
'options'=> array(
'dateFormat' =>'yy-mm-dd',
'altFormat' =>'yy-mm-dd',
'changeMonth' => true,
'changeYear' => true,