Skip to content
Please note that GitHub no longer supports Internet Explorer.

We recommend upgrading to the latest Microsoft Edge, Google Chrome, or Firefox.

Learn more
Permalink
Fetching contributors…
Cannot retrieve contributors at this time. Cannot retrieve contributors at this time
152 lines (114 sloc) 4.58 KB
<?php
/**
* phpwcms content management system
*
* @author Oliver Georgi <og@phpwcms.org>
* @copyright Copyright (c) 2002-2015, Oliver Georgi
* @license http://opensource.org/licenses/GPL-2.0 GNU GPL-2
* @link http://www.phpwcms.de
*
**/
// Define some general language specifics
/**
* language setting based on site tree
* $phpwcms['allowed_lang'] = array('en', 'de', 'fr', 'es');
* - DE
* - EN
* - FR
* - ES
* ...
*/
$phpwcms['id_lang'] = array(
// ID LANG
1 => 'en',
2 => 'de',
2 => 'fr',
3 => 'es'
);
$phpwcms['lang_id'] = array_flip($phpwcms['id_lang']);
// The default menu entry ID (0 = root)
$phpwcms['nav_entry_id'] = 0;
// Redirect to default language entry based on browser
if(!isset($LEVEL_ID[1])) {
// try to link user to correct language
$phpwcms['DOCTYPE_LANG'] = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? strtolower(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2)) : $phpwcms['default_lang'];
if(!isset($phpwcms['lang_id'][$phpwcms['DOCTYPE_LANG']])) {
$phpwcms['DOCTYPE_LANG'] = $phpwcms['default_lang'];
}
// Get current alias
$pagelink = empty($content['struct'][ $phpwcms['lang_id'][$phpwcms['DOCTYPE_LANG']] ]['acat_alias']) ? 'id='.$phpwcms['lang_id'][$phpwcms['DOCTYPE_LANG']] : $content['struct'][ $phpwcms['lang_id'][$phpwcms['DOCTYPE_LANG']] ]['acat_alias'];
$pagelink = $phpwcms["rewrite_url"] ? $pagelink . PHPWCMS_REWRITE_EXT : 'index.php?' . $pagelink;
// Redirect
headerRedirect(PHPWCMS_URL . $pagelink, 301);
} elseif(isset($phpwcms['id_lang'][ $LEVEL_ID[1] ])) {
$phpwcms['DOCTYPE_LANG'] = $phpwcms['default_lang'] = $phpwcms['id_lang'][ $LEVEL_ID[1] ];
// Take the current LEVEL 1 as nav entry
$phpwcms['nav_entry_id'] = $LEVEL_ID[1];
} else {
$phpwcms['DOCTYPE_LANG'] = $phpwcms['default_lang'];
}
// switch default date setting
if($phpwcms['default_lang'] != 'de') {
$template_default['date']['language'] = strtoupper($phpwcms['default_lang']);
$template_default['date']['short'] = 'y/m/d';
$template_default['date']['article'] = 'Y/m/d';
$template_default['news']['date_language'] = $template_default['date']['language'];
$template_default['news']['date_format'] = $template_default['date']['article'];
}
/**
* Try to get the base alias: "de_alias" => "_alias" or "alias_de" => "alias_"
*/
function match_alias_language() {
global $content;
$lang_match_spacer = PHPWCMS_ALIAS_WSLASH ? '[_\/]' : '_';
// check if the short language code matches left side first
preg_match(
'/^(' . $content['auto_lang']['preg_or'] . ')(' . $lang_match_spacer . '.+)$/i',
$content['auto_lang']['alias'],
$content['auto_lang']['match_left']
);
if(isset($content['auto_lang']['match_left'][1])) {
$content['auto_lang']['is_left'] = true;
return TRUE;
}
// check if the short language code matches right side
preg_match(
'/^(.+' . $lang_match_spacer . ')(' . $content['auto_lang']['preg_or'] . ')$/i',
$content['auto_lang']['alias'],
$content['auto_lang']['match_right']
);
if(isset($content['auto_lang']['match_right'][1])) {
$content['auto_lang']['is_right'] = true;
return TRUE;
}
return false;
}
/**
* Search structe or article for the opposite alias
*/
function search_opposite_alias($alias='') {
$alias = _dbEscape($alias); // escape only once
// test structure against alias first, is more common and
// maybe we will often see parental level fallback
$where = 'acat_trash=0 AND ';
$where .= VISIBLE_MODE != 2 ? '' : 'acat_aktiv=1 AND acat_public=1 AND '; // handle admin/editor mode
$where .= 'acat_alias LIKE '.$alias; // use LIKE because will match also against uper/lower case, even it is a bit slower
$result = _dbGet('phpwcms_articlecat', 'acat_alias', $where, '', '', 1);
if(isset($result[0]['acat_alias'])) {
return $result[0]['acat_alias'];
}
// test against article ID
$where = 'article_deleted=0 AND article_begin < NOW() AND ';
switch(VISIBLE_MODE) {
case 0: $where .= 'article_public=1 AND article_aktiv=1 AND ';
break;
case 1: $where .= 'article_uid='._dbEscape($_SESSION["wcs_user_id"]).' AND ';
break;
}
$where .= 'article_alias LIKE '.$alias; // use LIKE because will match also against uper/lower case, even it is a bit slower
$result = _dbGet('phpwcms_article', 'article_alias', $where, '', '', 1);
if(isset($result[0]['article_alias'])) {
return $result[0]['article_alias'];
}
return '';
}
You can’t perform that action at this time.
phpwcms-extended/lang.render.php at master · slackero/phpwcms-extended · GitHub
Skip to content
Please note that GitHub no longer supports Internet Explorer.

We recommend upgrading to the latest Microsoft Edge, Google Chrome, or Firefox.

Learn more
Permalink
Fetching contributors…
Cannot retrieve contributors at this time. Cannot retrieve contributors at this time
185 lines (143 sloc) 6.72 KB
<?php
/**
* phpwcms content management system
*
* @author Oliver Georgi <og@phpwcms.org>
* @copyright Copyright (c) 2002-2015, Oliver Georgi
* @license http://opensource.org/licenses/GPL-2.0 GNU GPL-2
* @link http://www.phpwcms.de
*
**/
/**
* Set i18n default language
*/
$phpwcms['i18_lang'] = $phpwcms['default_lang'];
/**
* By default we have no language switch,
* because no multiple languages defined
*/
$content_search = array(
// 'nav_main' => '{NAV_MAIN}',
'switch_lang' => '{SWITCH_LANG}',
'current_lang' => '{LANG}'
);
$content_replace = array(
// 'nav_main' => '',
'switch_lang' => '',
'current_lang' => $phpwcms['i18_lang']
);
$content_search_regexp = array();
$content_replace_regexp = array();
/**
* Try to catch current alias and match it against opposite language
*
*/
if(is_array($phpwcms['allowed_lang']) && count($phpwcms['allowed_lang']) > 1) {
$content['auto_lang'] = array(
'current' => $phpwcms['default_lang'],
'topcount' => $content['struct'][ $content['cat_id'] ]['acat_topcount'],
'struct_alias' => $content['struct'][ $content['cat_id'] ]['acat_alias'],
'struct_depth' => $LEVEL_KEY[ $content['cat_id'] ],
'preg_or' => implode('|', $phpwcms['allowed_lang']),
'match_left' => array(),
'match_right' => array(),
'is_left' => false,
'is_right' => false,
'opposite' => array(),
'root_id' => $phpwcms['lang_id'], // array_flip($phpwcms['id_lang']), yet done in init
'lang_native' => array(
'de' => array('DE', 'Deutsch'),
'en' => array('EN', 'English'),
'fr' => array('FR', 'Français'),
'it' => array('IT', 'Italiano'),
'es' => array('ES', 'Español'),
'ru' => array('RU', 'Ру́сский'),
'zh' => array('中文', '中文')
)
);
// regexp against allowed languages and any alias combination
// like "de_alias" or "alias_de" or "de/alias"
// by default, PHPWCMS_ALIAS contains alias of current article if in
// article detailed mode or alias of current structure level
// if current alias seems not to have an opposite language counter part
// we will first test against current structure level and then against
// parental structure level and so on
// generally current alias is defined in constant PHPWCMS_ALIAS
// first check if article detail mode is active
// no article alias defined, use current constant
if(empty($row['article_alias'])) {
$content['auto_lang']['alias'] = PHPWCMS_ALIAS;
// article alias different from current constant but the
// topcount value of structure level is set to display article
// so the current constant alias has preference
} elseif($content['auto_lang']['topcount'] == -1 && $row['article_alias'] != PHPWCMS_ALIAS) {
$content['auto_lang']['alias'] = PHPWCMS_ALIAS;
// OK, fallback, use the article alias
} else {
$content['auto_lang']['alias'] = $row['article_alias'];
}
// loop as long it matches or we arrived the root level
while(!match_alias_language()) {
// root level, has no parent, so break
if($content['auto_lang']['struct_depth'] < 0) {
break;
}
if($content['auto_lang']['alias'] == $content['auto_lang']['struct_alias']) {
$content['auto_lang']['struct_depth']--;
if($content['auto_lang']['struct_depth'] < 0) {
break;
}
}
$content['auto_lang']['alias'] = $content['struct'][ $LEVEL_ID[ $content['auto_lang']['struct_depth'] ] ]['acat_alias'];
$content['auto_lang']['struct_depth']--;
}
// build all possible opposite language related aliases
// hide non-matching language sections
foreach($phpwcms['allowed_lang'] as $lang) {
$lang_active_class = '';
$lang_switch_title = '@@' . $content['auto_lang']['lang_native'][$lang][1] . '@@';
if( $content['auto_lang']['is_left'] ) {
if($content['auto_lang']['match_left'][1] == $lang) {
$lang_alias = $content['auto_lang']['alias'];
$lang_active_class = ' lang-active';
} else {
$lang_alias = search_opposite_alias( $lang . $content['auto_lang']['match_left'][2] );
}
} elseif($content['auto_lang']['is_right']) {
if($content['auto_lang']['match_right'][2] == $lang) {
$lang_alias = $content['auto_lang']['alias'];
$lang_active_class = ' lang-active';
} else {
$lang_alias = search_opposite_alias( $content['auto_lang']['match_right'][1] . $lang );
}
} else {
$lang_alias = '';
}
// make the language link
$content['auto_lang']['opposite'][$lang] = '';
if($lang_alias == '') {
$lang_root_id = $content['auto_lang']['root_id'][$lang];
$content['auto_lang']['opposite'][$lang] .= !empty( $content['struct'][ $lang_root_id ]['acat_alias'] ) ? $content['struct'][ $lang_root_id ]['acat_alias'] : 'id='.$lang_root_id;
} else {
$content['auto_lang']['opposite'][$lang] .= $lang_alias;
}
if(PHPWCMS_REWRITE) {
$content['auto_lang']['opposite'][$lang] = '<a href="'.$content['auto_lang']['opposite'][$lang].PHPWCMS_REWRITE_EXT;
} else {
$content['auto_lang']['opposite'][$lang] = '<a href="index.php?'.$content['auto_lang']['opposite'][$lang];
}
$content['auto_lang']['opposite'][$lang] .= '" class="lang-switch lang-' . $lang . $lang_active_class . '" title="' . $lang_switch_title . '">';
$content['auto_lang']['opposite'][$lang] .= $content['auto_lang']['lang_native'][$lang][0] . '</a>';
$content_search_regexp[$lang] = '/\['.$lang.'\](.*?)\[\/'.$lang.'\]/is';
$content_replace_regexp[$lang] = $lang_active_class ? '$1' : '';
}
// take the language switch menu
$content_replace['switch_lang'] = implode(LF, $content['auto_lang']['opposite']);
// build the main menu (Bootstrap styled)
//$content_replace['nav_main'] = buildCascadingMenu('B,'.$phpwcms['nav_entry_id'].', , active|nav navbar-nav navbar-right, active'); //nav-justified
}
// Search and Replace
$content['pagetitle'] = str_replace($content_search, $content_replace, $content['pagetitle']);
$content["pagetitle"] = strip_tags(preg_replace($content_search_regexp, $content_replace_regexp, $content["pagetitle"]));
$content['all'] = str_replace($content_search, $content_replace, $content['all']);
$content['all'] = preg_replace($content_search_regexp, $content_replace_regexp, $content['all']);
You can’t perform that action at this time.
Klangidee

MUSIC FOR YOUR PRODUCTION

PRODUCTIONS

    • 039.jpg

      KI 039- PULSING TENSION - DARK


      Pulsing underscore titles for the whole range of tension topics in reality TV, documentaies or radio features.

      040.jpg

      KI 040- PULSING TENSION - LIGHT


      Pulsing underscore titles for the whole range of tension topics in reality TV, documentaies or radio features.

      038.jpg

      KI 038- ABOVE & BEYOND


      Different titles for spheric szenarios - from wide horizons or urban panoramas up to slow motion in sports.

      037.jpg

      KI 037- SPRINGTIME


      Spring is here! Positive and atmospheric titles for TV and radio coverage about springtime.

      036.jpg

      KI 036- ATMOSPHERIC GUITAR MOODS


      Atmospheric titles featuring the acoustic guitar, interwoven with string melodies and subtly used percussion elements.

      035.jpg

      KI 035- SILENT ROOMS AND SPACES


      Unobtrusive but very atmospheric and intinsive miniatures, with a lot of space for images and text.

      034.jpg

      KI 034- CHANGING PLANET


      Mystic, dark, fascinating, but also dynamic and driving forward titles for media coverage about global changes of environment, nature and society.

      033.jpg

      KI 033- SERIOUS GUITAR MOODS


      Sensitively adjusted guitar titles with a wide variety of emotions Ð from dark tension to ambivalent and pensive tunes.

  • PLAYLISTS