Skip to content

Instantly share code, notes, and snippets.

View crisu83's full-sized avatar
🎩
Coding

Christoffer Niska crisu83

🎩
Coding
View GitHub Profile
<?php
/**
* @return array the behavior configurations (behavior name=>behavior configuration)
*/
public function behaviors() {
return array(
'audit' => array('class' => 'common.extensions.audit.behaviors.AuditBehavior'),
'image' => array('class' => 'vendor.crisu83.yii-image.behaviors.ImageBehavior'),
);
@crisu83
crisu83 / DateFormatterBehavior.php
Created February 28, 2013 08:24
Active record behavior for automatic formatting of date columns.
<?php
class DateFormatterBehavior extends CActiveRecordBehavior {
const WIDTH_SHORT = 'short';
const WIDTH_MEDIUM = 'medium';
const WIDTH_LONG = 'long';
public $dates = array();
public function afterFind($event) {
@crisu83
crisu83 / AuditBehavior.php
Created February 28, 2013 08:38
Audit active record behavior.
<?php
require(__DIR__ . '/../models/AuditAttribute.php');
require(__DIR__ . '/../models/AuditModel.php');
class AuditBehavior extends CActiveRecordBehavior {
// Audit actions
const ACTION_CREATE = 'create';
const ACTION_DELETE = 'delete';
@crisu83
crisu83 / yiistrap-namespacing.php
Last active December 14, 2015 12:59
Random thoughts about using namespacing for the HTML helper in Yiistrap.
<?php
/* Core implementation */
// Helper
namespace bootstrap\helpers;
class Html extends \CHtml {
public static function someStaticHelperMethod() {
@crisu83
crisu83 / ActiveRecord.php
Created March 13, 2013 21:16
ActiveRecord::getRelatedAttribute method for Yii.
<?php
class ActiveRecord extends CActiveRecord
{
/**
* Returns a model attribute through the given relations.
* @param string|array $through the relation or a list of relations.
* @param string $attribute the attribute name.
* @param string $defaultValue the default value to return if the relation is not found.
* @return string the result.
*/
@crisu83
crisu83 / Debugger.php
Last active December 15, 2015 08:49
Helper for enabling debugging based on the ip address in Yii applications.
<?php
/**
* Debugger class file.
* @author Christoffer Niska <christoffer.niska@gmail.com>
* @copyright Copyright &copy; Christoffer Niska 2013-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
*/
/**
* Helper for enabling debugging based on the ip address.
@crisu83
crisu83 / ExtensionBehavior.php
Last active December 16, 2015 02:29
Tools for building extensions for the Yii PHP framework.
<?php
/**
* C83ExtensionBehavior class file.
* @author Christoffer Niska <christoffer.niska@gmail.com>
* @copyright Copyright &copy; Christoffer Niska 2013-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @package vendor.crisu83.yii-extension.behaviors
*/
/**
@crisu83
crisu83 / FileManager.php
Last active December 16, 2015 17:29
A file manager application component for the Yii PHP framework.
<?php
/**
* FileManager class file.
* @author Christoffer Niska <christoffer.niska@gmail.com>
* @copyright Copyright &copy; Christoffer Niska 2013-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @package crisu83.yii-filemanager.components
*/
Yii::import('vendor.crisu83.yii-extension.behaviors.ComponentBehavior', true/* force include */);
@crisu83
crisu83 / FileManager.php
Created April 26, 2013 21:02
A file manager application component for the Yii PHP framework.
<?php
/**
* FileManager class file.
* @author Christoffer Niska <christoffer.niska@gmail.com>
* @copyright Copyright &copy; Christoffer Niska 2013-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @package crisu83.yii-filemanager.components
*/
Yii::import('vendor.crisu83.yii-extension.behaviors.ComponentBehavior', true/* force include */);
{
"name": "yii-twbs/yiistrap",
"description": "Twitter Bootstrap for the Yii PHP framework.",
"type": "yii-extension",
"keywords": ["bootstrap"],
"license": "BSD-3-Clause",
"authors": [
{
"name": "Christoffer Niska",
"email": "christoffer.niska@gmail.com",