"(string) specifying the html that should separate breadcrumbs"
*
* *NOTE*: the class also recognizes the `breadcrumbs_separator` application config
* setting. If this setting is present within the application config.ini file,
* the value will be used as the separator;
*
*
* Adding a label breadcrumb (no link):
* $bcw->add('Label');
*
* Adding a linked label breadcrumb:
* $bcw->add('Label','link_href');
*
*
*/
class BreadcrumbsWidget
implements Org_Apache_Oodt_Balance_Interfaces_IApplicationWidget {
protected $separator = ' → ';
public function __construct($options = array()) {
// Check if the breadcrumbs_separator config setting has been set
if (isset(App::Get()->settings['breadcrumbs_separator'])) {
$this->separator = App::Get()->settings['breadcrumbs_separator'];
}
// If the 'separator' option has been passed, prefer it
if (isset($options['separator'])) {
$this->separator = $options['separator'];
}
}
public function add( $label = null, $link = null) {
$breadcrumbs = App::Get()->response->data('breadcrumbs');
if ( $label != null && $link != null ) {
// will show up as a linked label
$breadcrumbs[] = array($label,$link);
} elseif ( $label != null ) {
// will show up as just text
$breadcrumbs[] = $label;
} else
return 0;
App::Get()->response->data("breadcrumbs",$breadcrumbs);
}
public function render($bEcho = true) {
$str = '';
$data = App::Get()->response->data('breadcrumbs');
if ( !empty($data) ) {
foreach ($data as $bc) {
if (is_array($bc)) {
$str .= ''.$bc[0]."{$this->separator}";
} else {
$str .= ''.$bc.'';
}
}
}
if($bEcho) {
echo $str;
} else {
return $str;
}
}
}