Skip to content

Instantly share code, notes, and snippets.

@josegonzalez
josegonzalez / searchable.php
Created March 22, 2010 03:59
One of many iterations on a helper for the Searchable plugin
<?php
class SearchableHelper extends AppHelper {
var $helpers = array('Html', 'Text');
function snippets($data) {
$data = json_decode($data, true);
$term = (isset($this->data['SearchIndex']['term'])) ? trim($this->data['SearchIndex']['term']) : '';
$snippets = '';
while (strlen($snippets) < 255 && $value = next($data)) {
$snippets .= $this->Text->highlight($this->Text->excerpt($value, $term, 20), $term);
@josegonzalez
josegonzalez / Readme.textile
Created November 19, 2009 00:42
CakePHP Shell to calculate CodeBaseHQ time using git commit messages