public function generate($subsection_field, $subsection_id, $items = NULL, $recurse = 0, $flags = self::GETEVERYTHING)
{
static $done = array();
if ($done[$subsection_field] >= $recurse + 1) {
return array('options' => array(), 'html' => '', 'preview' => '');
}
$done[$subsection_field] += 1;
// Fetch subsection meta data
$meta = Symphony::Database()->fetch("SELECT filter_tags, caption, droptext, show_preview\n\t\t\t\tFROM tbl_fields_subsectionmanager\n\t\t\t\tWHERE field_id = '" . intval($subsection_field) . "'\n\t\t\t\tLIMIT 1");
// Get display mode
if ($meta[0]['show_preview'] == 1) {
$mode = 'preview';
$flags |= self::GETPREVIEW;
} else {
$mode = 'plain';
}
// Fetch entry data
$subsection = SectionManager::fetch($subsection_id, 'ASC', 'name');
$fields = $subsection->fetchFields();
$entries = $this->__filterEntries($subsection_id, $fields, $meta[0]['filter_tags'], $items, $flags & self::GETALLITEMS);
$droptext = $meta[0]['droptext'];
// Check caption
$caption = $meta[0]['caption'];
if ($caption == '') {
// Fetch name of primary field in subsection
$primary = Symphony::Database()->fetch("SELECT element_name\n\t\t\t\t\tFROM tbl_fields\n\t\t\t\t\tWHERE parent_section = '" . intval($subsection_id) . "'\n\t\t\t\t\tAND sortorder = '0'\n\t\t\t\t\tLIMIT 1");
$caption = '{$' . $primary[0]['element_name'] . '}';
}
// Layout subsection data
$data = $this->__layoutSubsection($entries, $fields, $caption, $droptext, $mode, $flags);
$done[$subsection_field] -= 1;
return $data;
}