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 / AuthFilter.php
Created January 12, 2013 21:48
AuthFilter class from the Auth module for the Yii PHP framework.
<?php
/**
* AuthFilter class file.
* @author Christoffer Niska <ChristofferNiska@gmail.com>
* @copyright Copyright &copy; Christoffer Niska 2012-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @package auth.components
*/
/**
@crisu83
crisu83 / TbApiRegisterEvents.php
Last active December 11, 2015 23:39
A function for registering JavaScript events based on an array ($name => $handler).
<?php
/**
* Registers a specific Bootstrap plugin with the given selector and options.
* @param string $name the plugin name.
* @param string $selector the CSS selector.
* @param array $options plugin JavaScript options.
* @param int $position the position of the JavaScript code.
*/
public function registerPlugin($name, $selector, $options = array(), $position = CClientScript::POS_END)
{
<?php
/**
* Generates a button group.
* @param array $buttons the button configurations.
* @param array $htmlOptions additional HTML options. The following special options are recognized:
* todo: write the options
* @return string the generated button group.
*/
public static function buttonGroup($buttons, $htmlOptions = array())
{
<?php
/**
* TbThumbnails 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 bootstrap.widgets
*/
Yii::import('bootstrap.widgets.TbListView');
@crisu83
crisu83 / ModelGroupForm.php
Last active December 12, 2015 06:38
Yii form model that allows for using multiple models in the same form.
<?php
/**
* Class ModelGroupForm
*
* Note! Attributes must be defined as "modelName.attributeName", e.g. "user.name" in forms.
*/
class ModelGroupForm extends CFormModel {
/**
* @var CModel[] $models the model instances (name=>config).
@crisu83
crisu83 / global.php
Created February 18, 2013 14:46
Global shorthand functions for commonly used Yii methods.
<?php
defined('DS') or define('DS', DIRECTORY_SEPARATOR);
/**
* Returns the application instance.
* @return CWebApplication
*/
function app() {
return Yii::app();
@crisu83
crisu83 / namespaceInputIDIssue.php
Last active December 13, 2015 22:48
Namespaces and input ID selector issue.
<?php
// Attribute id:
frontend\models\UserRegisterForm_profile:availabilityDate
// jQuery selector before escaping:
#frontend\models\UserRegisterForm_profile:availabilityDate
// jQuery selector after escaping using the snippet below:
frontend\\\\models\\\\UserRegisterForm_profile\\:availabilityDate
@crisu83
crisu83 / ConfigBuilder.php
Last active December 13, 2015 23:09
Helper for building Yii application configurations.
<?php
/**
* ConfigBuilder 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 building application configurations.
@crisu83
crisu83 / Hijo.php
Last active December 13, 2015 23:19
Random recursive method.
<?php
public function buildMenuRecursive($parentID = 0) {
$result = array();
$menus = Menus::model()->getMenusUsuarios($parentID);
foreach ($menus as $key => $value) {
$result[$key] = array(
'name' => $value['title'],
'link' => $value['url'] ? Yii::app()->createUrl($value['url']) : '',
'visible' => $value['status'],
@crisu83
crisu83 / Facebook.php
Created February 19, 2013 23:01
Facebook application component for Yii.
<?php
/**
* FacebookConnect class file.
* @author Christoffer Niska <ChristofferNiska@gmail.com>
* @copyright Copyright &copy; Christoffer Niska 2011-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
*/
/**
* Facebook connection application component.