Skip to content

Instantly share code, notes, and snippets.

<?php
class ConfigForm extends CFormModel
{
private $_config = array();
/**
* @param array $config
* @param string $scenario
*/
public function __construct($config = array(), $scenario = '')
<?php
class Node
{
public $data;
public $left;
public $right;
public $nextRight;
<?php class PageManager extends CComponent
{
public static function movePage($num,$url){
static $http = array (
100 => "HTTP/1.1 100 Continue",
101 => "HTTP/1.1 101 Switching Protocols",
200 => "HTTP/1.1 200 OK",
201 => "HTTP/1.1 201 Created",
202 => "HTTP/1.1 202 Accepted",
203 => "HTTP/1.1 203 Non-Authoritative Information",
<?php
class AES
{
public static function aes128Encrypt($key, $data) {
if(16 !== strlen($key)) $key = hash('MD5', $key, true);
$padding = 16 - (strlen($data) % 16);
$data .= str_repeat(chr($padding), $padding);
return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC, str_repeat("\0", 16)));
}
<?php
/**
*
* A PHP class that acts as wrapper for Asana API. Lets make things easy! :)
*
* Read Asana API documentation for fully use this class http://developer.asana.com/documentation/
*
* Copyright 2012 Ajimix
* Licensed under the Apache License 2.0
*
<?php
// src/Blogger/BlogBundle/Entity/Comment.php
namespace Blogger\BlogBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="Blogger\BlogBundle\Entity\Repository\CommentRepository")
* @ORM\Table(name="comment")
<?php
/**
* Class ImageHelper
*
* Simple class to manage image load, save and resize
*
* Usage:
*
* $image = new ImageHelper;
<?php
/**
* Class ImageHelper
*
* Simple class to manage image load, save and resize
*
* Usage:
*
* $image = new ImageHelper;
<?php
public static function setSort($book)
{
$model=BooksSort::model()->findByPk($book->id_book);
if ($model===NULL){
$model=new BooksSort;
$max=Yii::app()->db->createCommand("SELECT MAX(sort) FROM {$model->tableName()} WHERE app_id={$book->app_id};")->queryScalar();
$model->sort=$book->sort;
$model->app_id=$book->app_id;
<?php
public function setupOrder($old,$new)
{
$max=Yii::app()->db->createCommand("SELECT MAX(sort) FROM {$this->tableName()} WHERE app_id={$this->app_id};")->queryScalar();
$this->sort=$new;
if ($this->validate()){
if ($new>$max) $new=$max;
} else {
if ($max>=20) $new=20;
else $new=$max;