Skip to content

Instantly share code, notes, and snippets.

@dholmes
dholmes / gist:1201528
Created September 7, 2011 19:46
Gone years without doing this....the flexible array of array / array of object filter
<!-- In some controller, etc somewhere -->
<?php
// Say you find yourself with a big array of data
$messageList = $email->getCompetitionMessages($competition);
// but you want to filter out anything from the admin
$messageList = array_filter($messageList,new Istart_Filter_ValueInObjectArrayFilter('fromEmail','admin@example.com'));
// Or, if < PHP 5.3
@dholmes
dholmes / gist:1165580
Created August 23, 2011 15:56
[dojo] uncheck all the dijit checkBoxes contained within a single form, div, etc
dojo.query('#teamMemberInvitesList input[type=checkbox]').forEach(
function(node){
var checkbox = dijit.getEnclosingWidget(node);
if(checkbox){
checkbox.attr('checked',false);
}
}
);
@dholmes
dholmes / gist:1163356
Created August 22, 2011 19:56
[ZF] passing options to the pagination control
<?php
/* In your controller action */
class search extends Zend_Controller{
public function searchResultsAction()
{
$request = $this->getRequest();
$sort = $request->getParam('sort','date');
$this->view->sort = $sort;
$pageSize = (int) $request->getParam('pagesize',10);
@dholmes
dholmes / gist:1154476
Created August 18, 2011 16:35
[zf] Quick and dirty validating field
<?php
$color = new Zend_Form_Element_Text('color');
$color->AddValidator('Regex',false,array('/^\#[a-f0-9]{6}$/i'));
$color->getValidator('Regex')->setMessages( array(
Zend_Validate_Regex::NOT_MATCH =>
'\'%value%\' is not valid. Use a value in the form of #112233'
));