本文整理匯總了PHP中MgInitializeWebTier函數的典型用法代碼示例。如果您正苦於以下問題:PHP MgInitializeWebTier函數的具體用法?PHP MgInitializeWebTier怎麽用?PHP MgInitializeWebTier使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了MgInitializeWebTier函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: InitializeWebTier
function InitializeWebTier()
{
// Initialize web tier with the site configuration file. The config
// file should be two directory levels above this script.
$thisFile = __FILE__;
$pos = strrpos($thisFile, '\\');
if ($pos == false) {
$pos = strrpos($thisFile, '/');
}
$cfgFile = substr($thisFile, 0, $pos + 1) . "../webconfig.ini";
MgInitializeWebTier($cfgFile);
}
示例2: dirname
//this in as well
include dirname(__FILE__) . "/../mapadmin/resizableadmin.php";
//Shim some constants we know haven't been properly exposed in previous versions of MapGuide
if (!class_exists("MgImageFormats")) {
class MgImageFormats
{
const Gif = "GIF";
const Jpeg = "JPG";
const Png = "PNG";
const Png8 = "PNG8";
const Raw = "RAW";
const Tiff = "TIF";
}
}
$webConfigPath = dirname(__FILE__) . "/../webconfig.ini";
MgInitializeWebTier($webConfigPath);
require_once dirname(__FILE__) . "/app/util/localizer.php";
require_once dirname(__FILE__) . "/app/util/utils.php";
$config = (require_once dirname(__FILE__) . "/app/config.php");
$logConfig = (require_once dirname(__FILE__) . "/app/log_config.php");
$config = array_merge($config, $logConfig);
//Pull in the appropriate string bundle
$strings = (require_once dirname(__FILE__) . "/app/res/lang/" . $config["Locale"] . ".php");
$app = new \Slim\Slim($config);
//Override error handler for unhandled exceptions
$app->error(function ($err) use($app) {
$title = $app->localizer->getText("E_UNHANDLED_EXCEPTION");
$mimeType = MgMimeType::Html;
//As part of validating the desired representation, this variable will be set, this will tell us
//what mime type to shape the response
if (isset($app->requestedMimeType)) {
示例3: dirname
* and recreates an MgMap instance from the session if a mapname is passed.
*
* For widgets that are installed outside of the Fusion directory structure,
* the value of $extensionDir can be set before including this script to avoid
* some problems.
*/
//widgets outside Fusion can set the $extensionDir before including Common.php
//TODO: I don't think this is necessary anymore (PS)
if (!isset($extensionDir)) {
$installDir = $defaultInstallDir;
$extensionDir = $defaultExtensionDir;
}
include dirname(__FILE__) . "/Constants.php";
// Initialize
try {
MgInitializeWebTier($extensionDir . "/webconfig.ini");
/* If no session has been established yet, then we use the credentials passed
* to this script to connect to the site server. By default, we use the
* Anonymous user.
*/
if (!isset($_REQUEST['session'])) {
$username = isset($_REQUEST['username']) ? $_REQUEST['username'] : 'Anonymous';
$password = isset($_REQUEST['password']) ? $_REQUEST['password'] : '';
$user = new MgUserInformation($username, $password);
$user->SetClientIp(GetClientIp());
$user->SetClientAgent(GetClientAgent());
$siteConnection = new MgSiteConnection();
$siteConnection->Open($user);
} else {
/* If a session has previously been established, we can connect using the
* credentials that the user logged in with previously ... these are stored
示例4: MgInitializeWebTier
-->
<html>
<head>
<title>Layer Visibility</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta http-equiv="content-script-type" content="text/javascript">
<meta http-equiv="content-style-type" content="text/css">
<link href="../styles/globalStyles.css" rel="stylesheet" type="text/css">
<link href="../styles/otherStyles.css" rel="stylesheet" type="text/css">
</head>
<body class="AppFrame">
<h1 class="AppHeading">Layer Visibility</h1>
<?php
require_once '../common/common.php';
try {
MgInitializeWebTier($webconfigFilePath);
$args = $_SERVER['REQUEST_METHOD'] == "POST" ? $_POST : $_GET;
$sessionId = $args['SESSION'];
$mapName = $args['MAPNAME'];
$userInfo = new MgUserInformation($sessionId);
$siteConnection = new MgSiteConnection();
$siteConnection->Open($userInfo);
$map = new MgMap($siteConnection);
$map->Open($mapName);
$layers = $map->GetLayers();
// Get layer collection
echo "<p>Layers, in draw order:</p>";
echo '<table class="taskPane" cellspacing="0">';
echo '<tr><th class="rowHead">Layer</th><th>GetVisible()</th><th>IsVisible()</th></tr>';
$count = $layers->GetCount();
for ($i = 0; $i < $count; $i++) {
示例5: dirname
<html>
<head>
<title>Load OpenLayers integration Sample Data</title>
<style type="text/css">
.error { color:red; }
</style>
</head>
<body>
<?php
include dirname(__FILE__) . "/../../mapadmin/constants.php";
try {
MgInitializeWebTier(dirname(__FILE__) . "/../../webconfig.ini");
if (array_key_exists("USERNAME", $_POST) && array_key_exists("PASSWORD", $_POST)) {
$siteConn = new MgSiteConnection();
$userInfo = new MgUserInformation($_POST["USERNAME"], $_POST["PASSWORD"]);
$siteConn->Open($userInfo);
$resSvc = $siteConn->CreateService(MgServiceType::ResourceService);
//Commercial sample
$res1 = new MgResourceIdentifier("Library://Samples/Sheboygan/Maps/SheboyganCommercial.MapDefinition");
$bs1 = new MgByteSource(dirname(__FILE__) . "/SheboyganCommercial.MapDefinition.xml");
$br1 = $bs1->GetReader();
$resSvc->SetResource($res1, $br1, null);
//Mixed sample
$res2 = new MgResourceIdentifier("Library://Samples/Sheboygan/Maps/SheboyganMixed.MapDefinition");
$bs2 = new MgByteSource(dirname(__FILE__) . "/SheboyganMixed.MapDefinition.xml");
$br2 = $bs2->GetReader();
$resSvc->SetResource($res2, $br2, null);
?>
<p>Sample resources required for OpenLayers integration samples loaded.</p>
<p><a href="../../samples.php">Return to samples</a></p>
<?php
示例6: Exception
if (empty($adminID)) {
throw new Exception($errAdminIDMissing);
}
if (empty($adminPassword)) {
throw new Exception($errPasswordMissing);
}
// Initialize web tier with the site configuration file. The config
// file should be in the directory above as this script.
$webConfigFile = __FILE__;
$pos = strrpos($webConfigFile, '\\');
if ($pos == false) {
$pos = strrpos($webConfigFile, '/');
}
$relativeLocation = '../' . MgConfigProperties::DefaultConfigurationFilename;
$webConfigFile = substr_replace($webConfigFile, $relativeLocation, $pos + 1);
MgInitializeWebTier($webConfigFile);
// Set up user info
$userInfo = new MgUserInformation();
$userInfo->SetMgUsernamePassword($adminID, $adminPassword);
$userInfo->SetLocale($locale);
$clientAgent = GetClientAgent();
$clientIp = GetClientIp();
$userInfo->SetClientAgent($clientAgent);
$userInfo->SetClientIp($clientIp);
// Create a Site object and open the Site Server.
$site = new MgSite();
$site->Open($userInfo);
// Check that we have Administrator permission.
$servers = $site->EnumerateServers();
// Determine the available site servers
$numSites = $site->GetSiteServerCount();
示例7: MapAgentInit
public static function MapAgentInit($webConfigIniPath)
{
$cfgFile = self::GetPath($webConfigIniPath);
MgInitializeWebTier($cfgFile);
}
示例8: SetupTestData
function SetupTestData()
{
global $adminUser;
global $adminPass;
global $user1User;
global $user1Pass;
global $user2User;
global $user2Pass;
global $userGroup;
$webConfigPath = dirname(__FILE__) . "/../../webconfig.ini";
MgInitializeWebTier($webConfigPath);
$mgp = dirname(__FILE__) . "/data/Sheboygan.mgp";
if (!file_exists($mgp)) {
echo "Please put Sheboygan.mgp into the /data directory before running this test suite";
die;
}
if (!is_dir(dirname(__FILE__) . "/../conf/data/test_anonymous/")) {
mkdir(dirname(__FILE__) . "/../conf/data/test_anonymous/");
}
copy(dirname(__FILE__) . "/data/restcfg_anonymous.json", dirname(__FILE__) . "/../conf/data/test_anonymous/restcfg.json");
if (!is_dir(dirname(__FILE__) . "/../conf/data/test_author/")) {
mkdir(dirname(__FILE__) . "/../conf/data/test_author/");
}
copy(dirname(__FILE__) . "/data/restcfg_author.json", dirname(__FILE__) . "/../conf/data/test_author/restcfg.json");
if (!is_dir(dirname(__FILE__) . "/../conf/data/test_administrator/")) {
mkdir(dirname(__FILE__) . "/../conf/data/test_administrator/");
}
copy(dirname(__FILE__) . "/data/restcfg_administrator.json", dirname(__FILE__) . "/../conf/data/test_administrator/restcfg.json");
if (!is_dir(dirname(__FILE__) . "/../conf/data/test_wfsuser/")) {
mkdir(dirname(__FILE__) . "/../conf/data/test_wfsuser/");
}
copy(dirname(__FILE__) . "/data/restcfg_wfsuser.json", dirname(__FILE__) . "/../conf/data/test_wfsuser/restcfg.json");
if (!is_dir(dirname(__FILE__) . "/../conf/data/test_wmsuser/")) {
mkdir(dirname(__FILE__) . "/../conf/data/test_wmsuser/");
}
copy(dirname(__FILE__) . "/data/restcfg_wmsuser.json", dirname(__FILE__) . "/../conf/data/test_wmsuser/restcfg.json");
if (!is_dir(dirname(__FILE__) . "/../conf/data/test_group/")) {
mkdir(dirname(__FILE__) . "/../conf/data/test_group/");
}
copy(dirname(__FILE__) . "/data/restcfg_group.json", dirname(__FILE__) . "/../conf/data/test_group/restcfg.json");
if (!is_dir(dirname(__FILE__) . "/../conf/data/test_mixed/")) {
mkdir(dirname(__FILE__) . "/../conf/data/test_mixed/");
}
copy(dirname(__FILE__) . "/data/restcfg_mixed.json", dirname(__FILE__) . "/../conf/data/test_mixed/restcfg.json");
$source = new MgByteSource($mgp);
$br = $source->GetReader();
$siteConn = new MgSiteConnection();
$userInfo = new MgUserInformation($adminUser, $adminPass);
$siteConn->Open($userInfo);
$site = new MgSite();
$site->Open($userInfo);
//Set up any required users
try {
$site->AddGroup($userGroup, "Group for mapguide-rest test suite users");
} catch (MgException $ex) {
}
try {
$site->AddUser($user1User, $user1User, $user1Pass, "Test user for mapguide-rest test suite");
} catch (MgException $ex) {
}
try {
$site->AddUser($user2User, $user2User, $user2Pass, "Test user for mapguide-rest test suite");
} catch (MgException $ex) {
}
try {
$groups = new MgStringCollection();
$users = new MgStringCollection();
$groups->Add($userGroup);
$users->Add($user1User);
$users->Add($user2User);
$site->GrantGroupMembershipsToUsers($groups, $users);
} catch (MgException $ex) {
}
$resSvc = $siteConn->CreateService(MgServiceType::ResourceService);
$resSvc->ApplyResourcePackage($br);
$srcId = new MgResourceIdentifier("Library://Samples/Sheboygan/Data/Parcels.FeatureSource");
$dstId = new MgResourceIdentifier("Library://RestUnitTests/Parcels.FeatureSource");
$resSvc->CopyResource($srcId, $dstId, true);
$bsWriteable = new MgByteSource(dirname(__FILE__) . "/data/Parcels_Writeable.FeatureSource.xml");
$brWriteable = $bsWriteable->GetReader();
$resSvc->SetResource($dstId, $brWriteable, null);
$rdsdfsource = new MgByteSource(dirname(__FILE__) . "/data/RedlineLayer.sdf");
$rdsdfrdr = $rdsdfsource->GetReader();
$resId = new MgResourceIdentifier("Library://RestUnitTests/RedlineLayer.FeatureSource");
$rdXml = '<?xml version="1.0"?><FeatureSource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:noNamespaceSchemaLocation="FeatureSource-1.0.0.xsd"><Provider>OSGeo.SDF</Provider><Parameter><Name>File</Name><Value>%MG_DATA_FILE_PATH%RedlineLayer.sdf</Value></Parameter></FeatureSource>';
$rdXmlSource = new MgByteSource($rdXml, strlen($rdXml));
$rdXmlRdr = $rdXmlSource->GetReader();
$resSvc->SetResource($resId, $rdXmlRdr, null);
$resSvc->SetResourceData($resId, "RedlineLayer.sdf", MgResourceDataType::File, $rdsdfrdr);
}
示例9: strrpos
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
// get current path
$curPath = __FILE__;
$pos = strrpos($curPath, '\\');
if ($pos == false) {
$pos = strrpos($curPath, '/');
}
$curPath = substr_replace($curPath, "", $pos + 1);
//Note: current path might already be the script!!
MgInitializeWebTier(WEBCONFIGINI);
$locale = $_GET['LOCALE'];
try {
$site = new MgSiteConnection();
$cred = new MgUserInformation();
$cred->SetMgUsernamePassword("Administrator", "admin");
$cred->SetLocale($locale);
$site->Open($cred);
$svc = $site->CreateService(5);
} catch (MgException $exc) {
header("HTTP/1.1 559" . $exc->GetExceptionMessage());
$hdr = "Status: 559 " . $exc->GetExceptionMessage();
header($hdr);
echo "<html>\n";
echo "<body>\n";
echo $hdr . "\n";
示例10: LoadSessionVars
function LoadSessionVars()
{
global $webConfigFile;
global $adminSession;
global $selectedUser;
global $selectedGroup;
global $selectedRole;
global $selectedServer;
global $selectedService;
global $selectedLog;
global $selectedPackage;
global $selectedMapping;
global $packageLoadErrorMsg;
global $packageMakeErrorMsg;
global $packageLoadConfirmationMsg;
global $packageMakeConfirmationMsg;
global $confirmationMsg;
global $userInfo;
global $clientAgent;
global $clientIp;
global $site;
global $autoRefresh;
global $autoRefreshFrequency;
global $limitRefresh;
global $numRecsToRefresh;
global $popups;
try {
if (!array_key_exists('webConfigFile', $_SESSION)) {
// if the user attempts to access a php page without logging in,
// webConfigFile does not exist on the first load
throw new AuthenticationFailedException("webConfigFile does not exist");
}
// Load the current vals of session vars.
$webConfigFile = $_SESSION['webConfigFile'];
$adminSession = $_SESSION['adminSession'];
$selectedUser = $_SESSION['selectedUser'];
$selectedGroup = $_SESSION['selectedGroup'];
$selectedRole = $_SESSION['selectedRole'];
$selectedServer = $_SESSION['selectedServer'];
$selectedService = $_SESSION['selectedService'];
$selectedLog = $_SESSION['selectedLog'];
$selectedPackage = $_SESSION['selectedPackage'];
$selectedMapping = $_SESSION['selectedMapping'];
$packageLoadErrorMsg = $_SESSION['packageLoadErrorMsg'];
$packageMakeErrorMsg = $_SESSION['packageMakeErrorMsg'];
$packageLoadConfirmationMsg = $_SESSION['packageLoadConfirmationMsg'];
$packageMakeConfirmationMsg = $_SESSION['packageMakeConfirmationMsg'];
$confirmationMsg = $_SESSION['confirmationMsg'];
$clientAgent = $_SESSION['clientAgent'];
$clientIp = $_SESSION['clientIp'];
$autoRefresh = $_SESSION['autoRefresh'];
$autoRefreshFrequency = $_SESSION['autoRefreshFrequency'];
$limitRefresh = $_SESSION['limitRefresh'];
$numRecsToRefresh = $_SESSION['numRecsToRefresh'];
$popups = $_SESSION['popups'];
if (empty($webConfigFile)) {
// if the user attempts to access a php page without logging in,
// webConfigFile is empty (on all loads after the first one)
throw new AuthenticationFailedException("webConfigFile is empty");
}
// Initialize web tier with the site configuration file.
MgInitializeWebTier($webConfigFile);
// Set up user info
$userInfo = new MgUserInformation();
$userInfo->SetMgSessionId($adminSession);
$userInfo->SetClientAgent($clientAgent);
$userInfo->SetClientIp($clientIp);
// Create a Site object and open the Site Server.
$site = new MgSite();
$site->Open($userInfo);
} catch (AuthenticationFailedException $e) {
LogoutWithAuthenticationFailedException();
} catch (Exception $e) {
LogoutWithFatalException();
}
}