Skip to content

Instantly share code, notes, and snippets.

@dmtrs
dmtrs / gist:447671
Created June 21, 2010 23:03
Cron Tabing for Phergie
//1st approach
public function registerCallback( $callback, int $delay, $arguments=array(), $repeat=false ) {
//...the function that exist
//Add return the key of the callback if registered
return callback key;
}
public functio registerTabCall( $callback , $array( sec, min , hour , dayOfTheWeek ) , $repeate=false) {
$firstdelay = calculate delay from now for the first call;
$key = $this->registerCallback(...., $firstdelay , ... );
public function ownedBy($memId)
{
$this->getDbCriteria()->mergeWith(array(
'condition'=>'t.mem_id='.(int)$memId
));
return $this;
}
public function relations()
{
return array(
@dmtrs
dmtrs / renderMenuItem.php
Created September 2, 2011 11:54
Proper override of renderMenuItem
<?php
protected function renderMenuItem($item)
{
if(isset($item['url']))
{
$label=$this->linkLabelWrapper===null ? $item['label'] : '<'.$this->linkLabelWrapper.'>'.$item['label'].'</'.$this->linkLabelWrapper.'>';
return l($label,
$item['url'],
isset($item['linkOptions']) ? $item['linkOptions'] : array(),
that.onHashChange=function(data) {
//Hash change triggers before yillist is ready.
$(document).ready(function() {
var ajaxUrl = c.updateUrl;
if(typeof(data)!='undefined') {
ajaxUrl = ajaxUrl+'?'+$.param(data);
_general(data);
}
$.fn.yiiListView.update(c.yiiListID, { url: ajaxUrl });
});
<?php
class JsModule extends CWidget
{
...
protected $defaultOptions = array();
...
public function init()
{
$this->options = CMap::mergeArray($this->defaultOptions, $this->options);
//registerscrits etc....
<?php
public function searchStarredMembers( $tag=null, $keyword=null, $myStar = true)
{
$with = array('myMemberStar');
if(isset($tag)) {
if($tag) {
$with = array(
'myMemberStar'=>array(
'with'=> array(
'starToTags'=>array(
<?php
class StreamItem {
//.......
public function relations()
{
return array(
'stream' => array(self::BELONGS_TO, 'Stream', 'stream_id'),
'message' => array(self::BELONGS_TO, 'StreamMessage', 'msg_id'),
);
}
<?php
return arrray(
'components' => array(
'myComponent' => array(
'class' => 'ext.foo.FooComponent',
....
)
)
);
<?php
/**
* @param bool $myProfile If the profile is mine
* @pararm CActiveDataProvider $dataProvider jobs I haved posted
*/
....
?>
<?php
$this->jsPage = $this->createWidget('JsPageTest', array(
'config' => true
));
//If your page is named like JsPage{ControllerID}{ActionID}
//you can also do
$this->jsPage = array('config');