public function getFilterSections()
{
global $ADMIN_DIR, $g_user;
require_once $GLOBALS['g_campsiteDir'] . '/classes/Publication.php';
require_once $GLOBALS['g_campsiteDir'] . '/classes/Issue.php';
require_once $GLOBALS['g_campsiteDir'] . '/classes/Section.php';
require_once $GLOBALS['g_campsiteDir'] . '/classes/Author.php';
$translator = \Zend_Registry::get('container')->getService('translator');
foreach ($_REQUEST['args'] as $arg) {
$_REQUEST[$arg['name']] = $arg['value'];
}
if ($_REQUEST['publication'] > 0) {
$publication = $_REQUEST['publication'];
} else {
$publication = NULL;
}
$language = NULL;
if ($_REQUEST['issue'] > 0) {
$issueArray = explode("_", $_REQUEST['issue']);
$issue = $issueArray[1];
if (isset($issueArray[2])) {
$language = $issueArray[2];
}
} else {
$issue = NULL;
}
if ($_REQUEST['language'] > 0) {
$language = $_REQUEST['language'];
}
// get sections
$sections = array();
$section_objects = Section::GetSections($publication, $issue, $language);
foreach ($section_objects as $section) {
if (!isset($sections[$section->getSectionNumber()])) {
$sections[$section->getSectionNumber()] = $section;
}
}
$newSections = array();
foreach ($sections as $section) {
$newSections[] = array('val' => $section->getPublicationId() . '_' . $section->getIssueNumber() . '_' . $section->getLanguageId() . '_' . $section->getSectionNumber(), 'name' => $section->getName());
}
$sectionsNo = is_array($newSections) ? sizeof($newSections) : 0;
$menuSectionTitle = $sectionsNo > 0 ? $translator->trans('All Sections', array(), 'library') : $translator->trans('No sections found', array(), 'library');
$returns = array();
$returns['items'] = $newSections;
$returns['itemsNo'] = $sectionsNo;
$returns['menuItemTitle'] = $menuSectionTitle;
return json_encode($returns);
}