Example #1
0
 public static function getRemoteServer()
 {
     $sCallType = FlexiController::getInstance()->getRequest("_type", "json");
     $sCallType = empty($sCallType) ? "json" : $sCallType;
     switch ($sCallType) {
         case "json":
             return FlexiRemoteJSONServer::getInstance();
             break;
         default:
             throw new FlexiException("Unknown Remote call-type: " . $sCallType, ERROR_UNKNOWNTYPE);
     }
     return null;
 }
Example #2
0
 public static function getMediaURL($asPath, $sRole = "", $sName = "", $aParam = array())
 {
     if (empty($asPath)) {
         return "";
     }
     if ($asPath[0] != "/" && substr($asPath, 1, 2) != ":\\" && substr($asPath, 1, 2) != ":/") {
         $sTempPath = FlexiConfig::$sRootDir . "/" . $asPath;
     } else {
         $sTempPath = $asPath;
     }
     $sTempPath = str_replace("//", "/", $sTempPath);
     $sPath = realpath($sTempPath);
     if ($sPath === false) {
         throw new Exception("File missing: " . $sTempPath);
     }
     //echo "path: " . $sPath;
     //FlexiLogger::info(__METHOD__, "isadmin: " . (FlexiConfig::$bIsAdminPath? "yes": "no") . ": " . $sPath);
     $oControl = FlexiController::getCurrentController();
     $sQuery = "r=" . $sRole . "&path=" . $sPath . "&name=" . $sName . (count($aParam) < 1 ? "" : "&" . http_build_query($aParam));
     $sFilePath = FlexiCryptUtil::b64URLEncrypt($sQuery);
     $sURL = $oControl->url(array("p" => $sFilePath), "GetFile", "media", true);
     return $sURL;
 }
Example #3
0
<?php

$oFlexi = FlexiController::getInstance();
//based on ?mod=xxxx
$oControl = FlexiController::getCurrentController();
//echo "class: " . get_class($oControl);
//var_dump($oControl->getView()->getVars());
echo $oControl->getView()->getVar("body");
//echo $oControl->renderLayout();
Example #4
0
 public function unsetSession($sName)
 {
     FlexiController::getInstance()->unsetSession($sName);
 }
Example #5
0
<?php

$aCountry = array("2388929" => "Dallas, United States", "2459115" => "New York, United States", "2373280" => "California, United States", "2514815" => "Washington DC, United States", "44418" => "London, Great Britain", "554890" => "Copenhagen, Denmark", "727232" => "Amsterdam, Netherland", "721943" => "Rome, Italy", "615702" => "Paris, Franch", "1225448" => "Bangkok, Thailand", "1118370" => "Tokyo, Japan", "1154781" => "Kuala Lumpur, Malaysia", "2306179" => "Taipei, Taiwan", "2165352" => "Hong Kong, China", "1062617" => "Singapore", "2161838" => "Guangzhou, China", "2151849" => "Shanghai, China", "2151330" => "Beijing, China", "1199477" => "Manila, Philippines", "1047378" => "Jakarta, Indonesia", "1020725" => "Bandar Seri Begawan, Brunei");
$mSelected = FlexiController::getInstance()->getQuery("formWeatherCity", "");
if (empty($mSelected)) {
    $mSelected = FlexiController::getInstance()->getSession("savedWeatherCity", "1154781");
} else {
    FlexiController::getInstance()->setSession("savedWeatherCity", $mSelected);
}
$aSelectWeather = array("onChange" => "switchWeather('formWeatherCity');");
?>
<script type="text/javascript">
	function switchWeather(sSelect)
	{
		//console.log(oSelect.items[oSelect.selectedIndex]);
		//GetWeather
		var cityId = $("#formWeather #" + sSelect).val();
		$.ajax({
			type: "GET",
			data: "cityid=" + cityId,
				url: '<?php 
echo $this->url(null, "getWeather", "yahooweather");
?>
',
				success: function(data) {
				$('#divshowweather').html(data);
				}
		});
	}
	
	$(document).ready(function() {
Example #6
0
<?php

$oFlexi = FlexiController::getInstance();
//based on ?mod=xxxx
$oControl = FlexiController::getCurrentController();
if (FlexiConfig::$sFramework == "modx2") {
    FlexiController::appendOutput($oControl->renderView($viewname));
    return FlexiController::$sOutput;
} else {
    echo $oControl->renderView($viewname);
}
Example #7
0
<?
/* 
 * standalone used by admin / manager
 */

require_once("modx_header.php");
$sModuleName = FlexiController::getInstance()->getRequest("mod");

$oFlexi->run($sModuleName, $oFlexi->getRequest(FlexiConfig::$aModuleURL["method"]), true);
echo FlexiController::$sOutput;
Example #8
0
<?php

global $aFlexiSetting;
require_once $aFlexiSetting["basedir"] . "/lib/Doctrine/Doctrine.php";
if ($aFlexiSetting["doctrine"]) {
    spl_autoload_register(array('Doctrine', 'autoload'));
}
require_once $aFlexiSetting["basedir"] . "/base/Flexi/objectclass/FlexiConfig.php";
FlexiConfig::configure($aFlexiSetting);
//include this file to integrate flexi controller
require_once FlexiConfig::$sBaseDir . "/functions.php";
spl_autoload_register(array("FlexiConfig", "autoLoad"));
require_once FlexiConfig::$sBaseDir . "/base/Flexi/controller.php";
FlexiController::$iLogLevel = FlexiConfig::$iLogLevel;
//setting up DB Module
$oFlexiModelUtil = FlexiModelUtil::getInstance();
$oFlexiModelUtil->setDBSetting(FlexiConfig::$sDBType, FlexiConfig::$sDBHost, FlexiConfig::$iDBPort, FlexiConfig::$sDBUser, FlexiConfig::$sDBPass, FlexiConfig::$sDBName);
FlexiConfig::finalize();
//initialising main controller
$oFlexi = FlexiController::getInstance();
Example #9
0
 function loadForm()
 {
     $aRow = array();
     $rid = $this->getRequest("rid");
     if (!is_null($rid)) {
         $oModel = $this->getDBQuery("ModxWebUsers u")->leftJoin("u.Attributes a")->where('u.id=?', $rid)->fetchOne();
         if ($oModel !== false) {
             $aRow = array_merge($aRow, $oModel->toArray());
             $aRow["fullname"] = $oModel->Attributes->fullname;
         }
     }
     $aForm = FlexiController::getInstance()->getAllRequest();
     if (isset($aForm["txtPassword"]) && !empty($aForm["txtPassword"])) {
         $aForm["txtPassword"] = md5($aForm["txtPassword"]);
     }
     $aRow = array_merge($aRow, $aForm);
     //var_dump($aRow);
     return $this->getFormConfig($aRow);
 }
Example #10
0
 public function run()
 {
     $sJSON = FlexiController::getInstance()->getRawPostContent();
     $oRequest = json_decode($sJSON);
     var_dump($oRequest);
 }
Example #11
0
 /**
  * load the form from "rid",
  * 	into formListValues
  * @return array
  */
 function loadForm()
 {
     $aRow = null;
     $rid = $this->getRequest("rid");
     //var_dump($rid);
     if (!is_null($rid)) {
         $aList = $this->getDBQuery("RepositoryListValuesTable")->where('id=?', $rid)->execute();
         if (count($aList) > 0) {
             $aRow = $aList[0]->toArray();
         }
     }
     //getting values from form
     if (!is_null($aRow)) {
         $aReq = FlexiController::getInstance()->getAllRequest();
         unset($aReq["id"]);
         //avoiding use of id
         $aRow = array_merge($aRow, $aReq);
     } else {
         $aRow = FlexiController::getInstance()->getAllRequest();
         unset($aRow["id"]);
         //avoiding use of id
     }
     return $this->formListValues($aRow);
 }
Example #12
0
<?php

$oFlexi = FlexiController::getInstance();
//based on ?mod=xxxx
$oControl = FlexiController::getCurrentController();
if (FlexiConfig::$sFramework == "modx2") {
    FlexiController::appendOutput($oControl->getView()->getVar($viewname));
} else {
    echo $oControl->getView()->getVar($viewname);
}
Example #13
0
 public static function getInstance()
 {
     if (self::$oInstance == null) {
         self::$oInstance = new FlexiController();
     }
     return self::$oInstance;
 }
Example #14
0
 public function checkPermission($sTitle)
 {
     if (!$this->hasAccessToContent($sTitle)) {
         FlexiLogger::error(__METHOD__, "Permission denied: " . get_class($this) . ":" . $sTitle);
         FlexiController::getInstance()->redirectURL(FlexiConfig::$sBaseURL . "?" . FlexiConfig::getRequestModuleVarName() . "=FlexiLogin&" . FlexiConfig::getRequestMethodVarName() . "=denied");
     }
     FlexiPlatformHandler::getPlatformHandler()->forceDie();
 }
Example #15
0
 public static function mergeFormWithData(&$aForm, $asValues = null)
 {
     //if no value specified or null, will get all get+post+request (custom)
     $aValues = is_null($asValues) ? FlexiController::getInstance()->getAllRequest() : $asValues;
     $aNotice = FlexiConfig::$aFormMessage;
     foreach ($aForm as $sKey => &$mValue) {
         //is a form field, and is not already set value
         if ($sKey[0] != "#" && !isset($mValue["#value"])) {
             //FlexiLogger::info(__METHOD__, $sKey . ", type: " . $mValue["#type"]);
             //form value 1st,
             if (array_key_exists($sKey, $aValues)) {
                 $mValue["#value"] = is_array($aValues[$sKey]) ? implode(",", $aValues[$sKey]) : $aValues[$sKey];
             } else {
                 if (isset($mValue["#dbfield"])) {
                     $sField = $mValue["#dbfield"];
                     if (isset($aValues[$sField])) {
                         $sValue = $aValues[$sField];
                         if ($mValue["#type"] == "date" || $mValue["#type"] == "date.raw") {
                             $sFormat = isset($mValue["#format"]) ? $mValue["#format"] : FlexiConfig::$sInputDateFormat;
                             $sSep = "-";
                             if (strpos($sFormat, "/") !== false) {
                                 $sSep = "/";
                             } else {
                                 if (strpos($sFormat, ".") !== false) {
                                     $sSep = ".";
                                 }
                             }
                             $sFuncName = str_replace("-", "", strtoupper($sFormat));
                             $sFuncName = str_replace("/", "", $sFuncName);
                             $sFuncName = str_replace(".", "", $sFuncName);
                             $sFuncName = "get" . $sFuncName . "FromISODate";
                             //echo "calling : " . $sFuncName;
                             $sValue = FlexiStringUtil::$sFuncName($sValue, $sSep);
                         }
                         $mValue["#value"] = $sValue;
                     }
                 }
             }
         }
         //notice msg
         if (isset($aNotice[$sKey])) {
             $mValue["#notice"] = $aNotice[$sKey];
         }
     }
 }
Example #16
0
 public function init()
 {
     FlexiController::getInstance()->setHeader("Content-type", "text/x-json");
 }