Skip to content

Instantly share code, notes, and snippets.

View crisu83's full-sized avatar
🎩
Coding

Christoffer Niska crisu83

🎩
Coding
View GitHub Profile
@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",
@crisu83
crisu83 / composer.json
Created April 29, 2013 09:25
yiistrap-docs composer.json
{
"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",
@crisu83
crisu83 / resolveVersion.php
Last active December 18, 2015 12:59
An interesting db query
<?php
/**
* Returns the version of this node based on the given set of conditions.
* @param array $conditions the condition configurations (name=>value).
* @return CmsNodeVersion the version model.
*/
public function resolveVersion($conditions) {
// If we have conditions we need to do a bit of a trickier query.
if (!empty($conditions)) {
$select = array();
@crisu83
crisu83 / WorkflowBehavior.php
Last active December 18, 2015 22:19
Workflow behavior
<?php
class WorkflowBehavior extends CActiveRecordBehavior
{
/**
* @var string the name of the status attribute.
*/
public $statusAttribute = 'status';
/**
* @var integer the default status.