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

	global $module;
	global $module_path;

	$operation = $request['operation'];

	$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>";

	switch ($operation){
	default:
	case 'listmod':
		$content .= "<li $active><a href=\"".basename($PHP_SELF)."?f=extra&operation=listmod\" $current>"._CP_EXTRA_MODULES_."</a></li>";
		if (permission_of("modinst"))
			$content .= "<li><a href=\"".basename($PHP_SELF)."?f=extra&operation=install\">"._CP_EM_INSTALL_REMOVE_."</a></li>";
	break;
	case 'install':
	case 'remove':
		$content .= "<li><a href=\"".basename($PHP_SELF)."?f=extra&operation=listmod\">"._CP_EXTRA_MODULES_."</a></li>";
		if (permission_of("modinst"))
			$content .= "<li $active><a href=\"".basename($PHP_SELF)."?f=extra&operation=install\" $current>"._CP_EM_INSTALL_REMOVE_."</a></li>";
	break;
	}

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

	return $content;
};

//*****************************************************************************
function Install_Modules($request){
	$content = null;

	$sf = $request['sf'];

	$dir = "./extra/";
	if ($sf==""){
		$content .= _CP_EM_SELECT_EXTRA_MODULE_;

		if (is_dir($dir)){
			//Extra Modules start here
			if(!($dp = opendir($dir))) die("Cannot open $dir.");
			while($file = readdir($dp)) {
				if(is_file($file)) {
					continue;
				}
				else
					if($file != '.' && $file != '..' && $file != 'CVS'){
						$content .= "<br><br>";
						$content .= "
						<a class=\"inline-button orange\" href=\"".basename($PHP_SELF)."?f=extra&sf=".strtolower($file)."&operation=install\"><em>".ucfirst(strtolower($file))."</em><span>INSTALL</span></a>
						<a class=\"inline-button orange\" href=\"".basename($PHP_SELF)."?f=extra&sf=".strtolower($file)."&operation=remove\"><em>".ucfirst(strtolower($file))."</em><span>REMOVE</span></a>
						";
					}
				}
			closedir($dp);
			}
		}
		else{
			if (is_dir($dir))
				if(is_file("./extra/".strtolower($sf)."/admin/index.php"))
					require("./extra/".strtolower($sf)."/admin/index.php");
				else
			$content .= _CP_EM_NO_ADMIN_PAGE_FOUND_;
		}


	return $content;
};


//*****************************************************************************
function Run_Modules($request){
	$content = null;

	$sf = $request['sf'];
	$operation = $request['operation'];

	$dir = "./extra/";
	if ($sf==""){
		$content .= _CP_EM_SELECT_EXTRA_MODULE_;
	}
	else{
		if (is_dir($dir))
			if(is_file("./extra/".strtolower($sf)."/admin/index.php"))
				require("./extra/".strtolower($sf)."/admin/index.php");
			else
				$content .= _CP_EM_NO_ADMIN_PAGE_FOUND_;
	}

	return $content;
};

//*****************************************************************************
function List_Modules($request){
	$content = null;

	$sf = $request['sf'];

	//Module Administration Permission
	$dir = "./extra/";
	if (is_dir($dir)){

		//Extra Modules start here
		if(!($dp = opendir($dir))) die("Cannot open $dir.");
		while($file = readdir($dp)) {
			if(is_file($file)) {
				continue;
			}
			else
				if($file != '.' && $file != '..' && $file != 'CVS'){
					if (permission_of(strtolower($file))){
						$content .= "
						<br>
						<a class=\"inline-button orange\" href=\"".basename($PHP_SELF)."?f=extra&sf=".strtolower($file)."&operation=run\"><em>".ucfirst(strtolower($file))."</em><span>".ucfirst(strtolower($file))."</span></a><br>";
					}
			}
		}
		closedir($dp);
	}

	return $content;
};

//*****************************************************************************
function Extra_Operation($request){
	$content = null;

	$sf = $request['sf'];
	$operation = $request['operation'];

	$content = Create_Tab_Menu($request);

	if (($sf=="") and ($operation==""))
		$operation = "listmod";

	switch ($operation){
	default:
	case 'run':
		$content .= Run_Modules($request);
	break;
	case 'listmod':
		$content .= List_Modules($request);
	break;
	case 'install':
		$content .= Install_Modules($request);
	break;
//	case 'remove':
//		$content .= Remove_Modules($request);
//	break;
	}

	return $content;
}

?>
Return current item: ChiCoMaS - Chilek CMS