Publication::getLanguages PHP Method

getLanguages() public method

Return all languages used in the publication as an array of Language objects.
public getLanguages ( integer $p_excludeLanguageId = null, array $p_order = [], $p_published = false ) : array
$p_excludeLanguageId integer If greater than 0, exclude the language with the given identifier from the list.
$p_order array The array of order directives in the format: array('field'=>field_name, 'dir'=>order_direction) field_name can take one of the following values: bynumber, byname, byenglish_name, bycode order_direction can take one of the following values: asc, desc
return array
    public function getLanguages($p_excludeLanguageId = null, array $p_order = array(), $p_published = false)
    {
        $queryStr = 'SELECT Languages.* FROM Issues LEFT JOIN Languages ' . 'ON Issues.IdLanguage = Languages.Id WHERE ' . 'Issues.IdPublication = ' . $this->getPublicationId();
        if ($p_excludeLanguageId > 0) {
            $queryStr .= ' AND Languages.Id != ' . $p_excludeLanguageId;
        }
        if ($p_published) {
            $queryStr .= " AND Issues.Published = 'Y'";
        }
        $queryStr .= ' GROUP BY Languages.Id';
        $order = Publication::ProcessLanguageListOrder($p_order);
        $sqlOrder = array();
        foreach ($order as $orderDesc) {
            $sqlOrder[] = $orderDesc['field'] . ' ' . $orderDesc['dir'];
        }
        if (count($sqlOrder) > 0) {
            $queryStr .= ' ORDER BY ' . implode(', ', $sqlOrder);
        }
        $languages = DbObjectArray::Create('Language', $queryStr);
        return $languages;
    }

Usage Example

示例#1
0
	exit;
}

$f_user_id = Input::Get('f_user_id', 'int', 0);
$f_publication_id = Input::Get('f_publication_id', 'int', 0);
$f_subscription_id = Input::Get('f_subscription_id', 'int', 0);
$f_section_number = Input::Get('f_section_number', 'array', array());
$f_section_id = Input::Get('f_section_id', 'array', array());
$f_language_set = Input::Get('f_language_set', 'string', 'all');
$f_subscription_start_date = Input::Get('f_subscription_start_date');
$f_subscription_days = Input::Get('f_subscription_days');
$success = true;

$publicationObj = new Publication($f_publication_id);
$languageObj = new Language($publicationObj->getDefaultLanguageId());
$languages = $publicationObj->getLanguages();
$manageUser = new User($f_user_id);
$errorMsgs = array();

$new_sections = array();
if ($f_language_set == 'all') {
	if (is_array($f_section_number)) {
		foreach ($f_section_number as $section_number) {
			$new_sections[$section_number][] = 0;
		}
	}
} else {
	if (is_array($f_section_id)) {
		foreach ($f_section_id as $section_id) {
			$id = explode('_', $section_id);
			$new_sections[$id[0]][] = $id[1];