Location: PHPKode > projects > ChiCoMaS - Chilek CMS > chicomas/modules/language/language_operation.php
<?
//*****************************************************************************
function Create_Tab_Menu($request){

	global $module;
	global $module_path;

	$obj_tempdbarray = new CTempDBArray();
	$obj_tempdbengine = new CTempDBEngine();

	$sf = $request['sf'];

	$content = "
	<div id=\"navcontainer\">
	<ul id=\"navlist\">";

	$current = "id=\"current\"";
	$active = "id=\"active\"";


	$content .= "<li><a href=\"".basename($PHP_SELF)."?mode=admin\">"._CONTROL_PANEL_."</a></li>";

	$content .= "<li $active><a href=\"".basename($PHP_SELF)."?f=language&sf=list\" $current>"._CP_LANGUAGE_ADMINISTRATION_."</a></li>";

	$content .= "
	</ul>
	</div>";

	return $content;

};

//*****************************************************************************
function LanguageView($operation, $request){
	global $defaultlanguage;

	$content = null;

	$obj_language = new CLanguage();
	$obj_languagearray = new CLanguageArray();
	$obj_languageengine = new CLanguageEngine();

	if (!isset($f)) $f="language";
	if (!isset($sf)) $sf="list";

	$obj_languagearray = $obj_languageengine->GetLanguages(0);
	$num_count = $obj_languagearray->count();

	$info = _CP_LANGUAGE_ADMINISTRATION_MSG_;

	$content = "
	<i><ul>".$info."</ul></i>
	<center>";
	if ($num_count>1){
		$content .= "
		<form action='".basename($PHP_SELF)."?f=language&sf=list&operation=save' method='post'>
		<div id=\"formular\">
		<table width=\"50%\" cellpadding=\"5\" cellspacing=\"5\" border=\"1\">
		<tbody>
			<th>"._CP_LA_DEFAULT_LANGUAGE_."</th>
			<th>"._CP_LA_ACTIVE_LANGUAGES_."</th>
			<th>"._CP_LA_LANGUAGES_."</th>
		</tbody>";
		while( $obj_language = $obj_languagearray->get() ){
			$languageid = $obj_language->language_id;
			$active = $obj_language->active;
			$language = $obj_language->language;
			$lang = $obj_language->lang;
			if ($active)
				$active = " checked ";
			else
				$active = "";

			if ($defaultlanguage == $lang)
				$default = " checked ";
			else
				$default = "";

			$content .= "
			<tr>
				<td align=\"center\"><input type=\"radio\" name=\"default_lang\" value=\"$lang\"/ $default></td>
				<td align=\"center\"><input type=\"checkbox\" name=\"active_$lang\" $active/></td>
				<td align=\"left\">$language ($lang)</td>
			</tr>";
		}
		$content .= "
		</table>
		</div>
		<br>
		<input type=\"submit\" value=\""._CMN_UPDATE_."\" />
	</form>
	";
	}
	else {
		$content .= Message(89);
		$content .= "<center><img src=\"images/warn.gif\" alt=\"\" width=\"35\" height=\"35\" border=\"0\">";
		$content .= go_back();
		$content .= "</center>";
	}
	$content .= "
	</center>";

	return $content;
}

//*****************************************************************************
function LanguageSave($operation, $request){
	global $defaultlanguage;

	$old_defaultlanguage = $defaultlanguage;

	$content = null;

	$obj_language = new CLanguage();
	$obj_languagearray = new CLanguageArray();
	$obj_languageengine = new CLanguageEngine();

	if (!isset($f)) $f="language";
	if (!isset($sf)) $sf="list";

	$default_lang = $request['default_lang'];
	$active_tr = $request['active_tr'];
	$active_en = $request['active_en'];
	$active_de = $request['active_de'];

	if ($active_tr=="on") $active_tr=1;else $active_tr=0;
	if ($active_en=="on") $active_en=1;else $active_en=0;
	if ($active_de=="on") $active_de=1;else $active_de=0;

	switch (strtolower($default_lang)){
	default:
	case "tr":
		$active_tr = 1;
	break;
	case "en":
		$active_en = 1;
	break;
	case "de":
		$active_de = 1;
	break;
	}

	$obj_languageengine->ResetDefaultLanguage();
	$obj_languageengine->SetDefaultLanguage($default_lang);
	
	if (($active_tr==0) and ($active_en==0) and ($active_de==0))
		$active_tr = 1;

	$obj_languageengine->UpdateLanguage("tr", $active_tr);
	$obj_languageengine->UpdateLanguage("en", $active_en);
	$obj_languageengine->UpdateLanguage("de", $active_de);

	/* Update the config.inc file */
	$conf = new ConfigTool();
	$conf->setConfigFromFile( CONFIGFILE );
	$defaultlanguage = $default_lang;
	$conf->updateKeyValue( "defaultlanguage", "'".$defaultlanguage."'" );
	$conf->setFileName( CONFIGFILE );
	$conf->saveToFile();

	$content .= "
	<div class=note>
		<h3>"._CMN_NOTE_."</h3>
		<p>";
		if (!$failed){
			$content .= _CMN_SAVE_OK_;
			ReDirection(basename($PHP_SELF)."?f=language&sf=list");
		}
		else{
			$content .= _CMN_SAVE_FAILED_."<br><br>";
			$content .= go_back();
		}
		$content .= "
		</p>
	</div>
	";

	return $content;
}

//*****************************************************************************
function Language_Operation($request){
	global $defaultlanguage;

	$content = null;

	$operation = $request['operation'];

	$content = Create_Tab_Menu($request);

	switch ($operation){
	default:
	case 'list':
	case 'view':
		$content .= LanguageView($operation, $request);
	break;
	case 'save':
		$content .= LanguageSave($operation, $request);
	break;
	}

	return $content;
}


?>
Return current item: ChiCoMaS - Chilek CMS