public function toJson($full = false)
{
// @TODO: Support date grouped galleries
$vMode = $this->get('view_mode');
if ($vMode != 'Normal') {
$this->_setModeHelper('Normal');
}
$style = Ansel::getStyleDefinition('ansel_mobile');
$json = new StdClass();
$json->id = $this->id;
$json->n = $this->get('name');
$json->dc = $this->get('date_created');
$json->dm = $this->get('last_modified');
$json->d = $this->get('desc');
$json->ki = Ansel::getImageUrl($this->getKeyImage($style), 'thumb', false, $style)->toString(true);
$json->imgs = array();
// Parent
$parents = $this->getParents();
if (empty($parents)) {
$json->p = null;
$json->pn = null;
} else {
$p = array_pop($parents);
$json->p = $p->id;
$json->pn = $p->get('name');
}
if ($full) {
$json->tiny = $GLOBALS['conf']['image']['tiny'] && ($GLOBALS['conf']['vfs']['src'] == 'direct' || $this->_share->hasPermission('', Horde_Perms::READ));
$json->sg = array();
if ($this->hasSubGalleries()) {
$sgs = $this->getChildren($GLOBALS['registry']->getAuth(), Horde_Perms::READ, false);
//GLOBALS['injector']->getInstance('Ansel_Storage')->listGalleries(array('parent' => $this->id, 'all_levels' => false));
foreach ($sgs as $g) {
$json->sg[] = $g->toJson();
}
}
$images = $this->getImages();
foreach ($images as $img) {
$i = new StdClass();
$i->id = $img->id;
$i->url = Ansel::getImageUrl($img->id, 'thumb', false, $style)->toString(true);
$i->screen = Ansel::getImageUrl($img->id, 'screen', $json->tiny, Ansel::getStyleDefinition('ansel_default'))->toString(true);
$i->fn = $img->filename;
$json->imgs[] = $i;
}
}
if ($vMode != 'Normal') {
$this->_setModeHelper($vMode);
}
return $json;
}