本文整理匯總了PHP中MailSo\Base\Utils::Php2js方法的典型用法代碼示例。如果您正苦於以下問題:PHP Utils::Php2js方法的具體用法?PHP Utils::Php2js怎麽用?PHP Utils::Php2js使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MailSo\Base\Utils
的用法示例。
在下文中一共展示了Utils::Php2js方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Handle
/**
* @return void
*/
public function Handle()
{
$sVersion = file_get_contents(PSEVEN_APP_ROOT_PATH . 'VERSION');
define('PSEVEN_APP_VERSION', $sVersion);
if (!class_exists('MailSo\\Version')) {
echo 'MailSo';
return '';
} else {
if (!class_exists('\\CApi') || !\CApi::IsValid()) {
echo 'AfterLogic API';
return '';
}
}
$sPathInfo = \trim(\trim($this->oHttp->GetServer('PATH_INFO', '')), ' /');
if (!empty($sPathInfo)) {
if ('dav' === \substr($sPathInfo, 0, 3)) {
$this->oActions->PathInfoDav();
return '';
}
}
/* @var $oApiIntegrator \CApiIntegratorManager */
$oApiIntegrator = \CApi::Manager('integrator');
// ------ Redirect to HTTPS
$oSettings =& \CApi::GetSettings();
$bRedirectToHttps = $oSettings->GetConf('Common/RedirectToHttps');
$bHttps = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== "off" || isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == "443";
if ($bRedirectToHttps && !$bHttps) {
header("Location: https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
}
// ------
/* @var $oApiCapability \CApiCapabilityManager */
$oApiCapability = \CApi::Manager('capability');
$sResult = '';
$sQuery = \trim(\trim($this->oHttp->GetServer('QUERY_STRING', '')), ' /');
\CApi::Plugin()->RunQueryHandle($sQuery);
$iPos = \strpos($sQuery, '&');
if (0 < $iPos) {
$sQuery = \substr($sQuery, 0, $iPos);
}
$aPaths = explode('/', $sQuery);
if (0 < count($aPaths) && !empty($aPaths[0])) {
$sFirstPart = strtolower($aPaths[0]);
if ('ping' === $sFirstPart) {
@header('Content-Type: text/plain; charset=utf-8');
$sResult = 'Pong';
} else {
if ('pull' === $sFirstPart) {
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
pclose(popen("start /B git pull", "r"));
} else {
exec("git pull > /dev/null 2>&1 &");
}
\CApi::Location('./');
} else {
if ('ajax' === $sFirstPart) {
@ob_start();
$aResponseItem = null;
$sAction = $this->oHttp->GetPost('Action', null);
try {
\CApi::Log('AJAX: Action: ' . $sAction);
if ('SystemGetAppData' !== $sAction && \CApi::GetConf('labs.webmail.csrftoken-protection', true) && !$this->validateToken()) {
throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::InvalidToken);
} else {
if (!empty($sAction)) {
$sMethodName = 'Ajax' . $sAction;
$this->oActions->SetActionParams($this->oHttp->GetPostAsArray());
if (method_exists($this->oActions, $sMethodName) && is_callable(array($this->oActions, $sMethodName))) {
$aResponseItem = call_user_func(array($this->oActions, $sMethodName));
}
if (\CApi::Plugin()->JsonHookExists($sMethodName)) {
$aResponseItem = \CApi::Plugin()->RunJsonHook($this->oActions, $sMethodName, $aResponseItem);
}
}
}
if (!is_array($aResponseItem)) {
throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::UnknownError);
}
} catch (\Exception $oException) {
//if ($oException instanceof \ProjectCore\Exceptions\ClientException &&
// \ProjectCore\Notifications::AuthError === $oException->getCode())
//{
// $oApiIntegrator = /* @var $oApiIntegrator \CApiIntegratorManager */ \CApi::Manager('integrator');
// $oApiIntegrator->setLastErrorCode(\ProjectCore\Notifications::AuthError);
// $oApiIntegrator->logoutAccount();
//}
\CApi::LogException($oException);
$sAction = empty($sAction) ? 'Unknown' : $sAction;
$aAdditionalParams = null;
if ($oException instanceof \ProjectCore\Exceptions\ClientException) {
$aAdditionalParams = $oException->GetObjectParams();
}
$aResponseItem = $this->oActions->ExceptionResponse(null, $sAction, $oException, $aAdditionalParams);
}
@header('Content-Type: application/json; charset=utf-8');
\CApi::Plugin()->RunHook('ajax.response-result', array($sAction, &$aResponseItem));
$sResult = \MailSo\Base\Utils::Php2js($aResponseItem, \CApi::MailSoLogger());
// \CApi::Log('AJAX: Response: '.$sResult);
//.........這裏部分代碼省略.........
示例2: compileTemplates
/**
* @param bool $bAdmin = false
* @param bool $bJsOutput = true
*
* @return string
*/
public function compileTemplates($bAdmin = false, $bJsOutput = true)
{
$aTemplates = array();
\RainLoop\Utils::CompileTemplates($aTemplates, APP_VERSION_ROOT_PATH . 'app/templates/Views/Components', 'Component');
\RainLoop\Utils::CompileTemplates($aTemplates, APP_VERSION_ROOT_PATH . 'app/templates/Views/' . ($bAdmin ? 'Admin' : 'User'));
\RainLoop\Utils::CompileTemplates($aTemplates, APP_VERSION_ROOT_PATH . 'app/templates/Views/Common');
$this->oActions->Plugins()->CompileTemplate($aTemplates, $bAdmin);
$sHtml = '';
foreach ($aTemplates as $sName => $sFile) {
$sName = \preg_replace('/[^a-zA-Z0-9]/', '', $sName);
$sHtml .= '<script id="' . $sName . '" type="text/html" data-cfasync="false">' . $this->oActions->ProcessTemplate($sName, \file_get_contents($sFile)) . '</script>';
}
unset($aTemplates);
return $bJsOutput ? 'window.rainloopTEMPLATES=' . \MailSo\Base\Utils::Php2js(array($sHtml), $this->Logger()) . ';' : $sHtml;
}
示例3: compileTemplates
/**
* @param bool $bAdmin = false
* @param bool $bJsOutput = true
*
* @return string
*/
public function compileTemplates($bAdmin = false, $bJsOutput = true)
{
$sHtml = \RainLoop\Utils::CompileTemplates(APP_VERSION_ROOT_PATH . 'app/templates/Views/Components', $this->oActions, 'Component') . \RainLoop\Utils::CompileTemplates(APP_VERSION_ROOT_PATH . 'app/templates/Views/' . ($bAdmin ? 'Admin' : 'User'), $this->oActions) . \RainLoop\Utils::CompileTemplates(APP_VERSION_ROOT_PATH . 'app/templates/Views/Common', $this->oActions) . $this->oActions->Plugins()->CompileTemplate($bAdmin);
return $bJsOutput ? 'window.rainloopTEMPLATES=' . \MailSo\Base\Utils::Php2js(array($sHtml), $this->Logger()) . ';' : $sHtml;
}
示例4: compileTemplates
/**
* @param bool $bAdmin = false
*
* @return string
*/
private function compileTemplates($bAdmin = false)
{
$sHtml = \RainLoop\Utils::CompileTemplates(APP_VERSION_ROOT_PATH . 'app/templates/Views/' . ($bAdmin ? 'Admin' : 'App'), $this->oActions) . \RainLoop\Utils::CompileTemplates(APP_VERSION_ROOT_PATH . 'app/templates/Views/Common', $this->oActions) . $this->oActions->Plugins()->CompileTemplate($bAdmin);
return 'window.rainloopTEMPLATES=' . \MailSo\Base\Utils::Php2js(array($sHtml), $this->Logger()) . ';';
}
示例5: Php2js
/**
* @param mixed $mInput
*
* @return string
*/
public static function Php2js($mInput)
{
return \json_encode($mInput, defined('JSON_UNESCAPED_UNICODE') ? JSON_UNESCAPED_UNICODE : 0);
if (\is_null($mInput)) {
return 'null';
} else {
if ($mInput === false) {
return 'false';
} else {
if ($mInput === true) {
return 'true';
} else {
if (\is_scalar($mInput)) {
if (\is_float($mInput)) {
$mInput = \str_replace(',', '.', \strval($mInput));
}
return '"' . \MailSo\Base\Utils::InlineRebuildStringToJsString($mInput) . '"';
}
}
}
}
$bIsList = true;
for ($iIndex = 0, \reset($mInput), $iLen = \count($mInput); $iIndex < $iLen; $iIndex++, \next($mInput)) {
if (\key($mInput) !== $iIndex) {
$bIsList = false;
break;
}
}
$aResult = array();
if ($bIsList) {
foreach ($mInput as $mValue) {
$aResult[] = \MailSo\Base\Utils::Php2js($mValue);
}
return '[' . \join(',', $aResult) . ']';
} else {
foreach ($mInput as $sKey => $mValue) {
$aResult[] = \MailSo\Base\Utils::Php2js($sKey) . ':' . \MailSo\Base\Utils::Php2js($mValue);
}
return '{' . \join(',', $aResult) . '}';
}
}
示例6: Handle
/**
* @return void
*/
public function Handle()
{
$sVersion = file_get_contents(PSEVEN_APP_ROOT_PATH . 'VERSION');
define('PSEVEN_APP_VERSION', $sVersion);
if (!class_exists('MailSo\\Version')) {
echo 'MailSo';
return '';
} else {
if (!class_exists('\\CApi') || !\CApi::IsValid()) {
echo 'AfterLogic API';
return '';
}
}
$sPathInfo = \trim(\trim($this->oHttp->GetServer('PATH_INFO', '')), ' /');
if (!empty($sPathInfo)) {
if ('dav' === \substr($sPathInfo, 0, 3)) {
$this->oActions->PathInfoDav();
return '';
}
}
/* @var $oApiIntegrator \CApiIntegratorManager */
$oApiIntegrator = \CApi::Manager('integrator');
/* @var $oApiCapability \CApiCapabilityManager */
$oApiCapability = \CApi::Manager('capability');
$sResult = '';
$sQuery = \trim(\trim($this->oHttp->GetServer('QUERY_STRING', '')), ' /');
$iPos = \strpos($sQuery, '&');
if (0 < $iPos) {
$sQuery = \substr($sQuery, 0, $iPos);
}
$aPaths = explode('/', $sQuery);
if (0 < count($aPaths) && !empty($aPaths[0])) {
$sFirstPart = strtolower($aPaths[0]);
if ('ping' === $sFirstPart) {
@header('Content-Type: text/plain; charset=utf-8');
$sResult = 'Pong';
} else {
if ('ajax' === $sFirstPart) {
@ob_start();
$aResponseItem = null;
$sAction = $this->oHttp->GetPost('Action', null);
try {
\CApi::Log('AJAX: Action: ' . $sAction);
if ('AppData' !== $sAction && \CApi::GetConf('labs.webmail.csrftoken-protection', true) && !$this->validateToken()) {
throw new \ProjectSeven\Exceptions\ClientException(\ProjectSeven\Notifications::InvalidToken);
} else {
if (!empty($sAction)) {
$sMethodName = 'Ajax' . $sAction;
if (method_exists($this->oActions, $sMethodName) && is_callable(array($this->oActions, $sMethodName))) {
$this->oActions->SetActionParams($this->oHttp->GetPostAsArray());
$aResponseItem = call_user_func(array($this->oActions, $sMethodName));
} else {
if (\CApi::Plugin()->JsonHookExists($sMethodName)) {
$this->oActions->SetActionParams($this->oHttp->GetPostAsArray());
$aResponseItem = \CApi::Plugin()->RunJsonHook($this->oActions, $sMethodName);
}
}
}
}
if (!is_array($aResponseItem)) {
throw new \ProjectSeven\Exceptions\ClientException(\ProjectSeven\Notifications::UnknownError);
}
} catch (\Exception $oException) {
// if ($oException instanceof \ProjectSeven\Exceptions\ClientException &&
// \ProjectSeven\Notifications::AuthError === $oException->getCode())
// {
// $oApiIntegrator = /* @var $oApiIntegrator \CApiIntegratorManager */ \CApi::Manager('integrator');
// $oApiIntegrator->SetLastErrorCode(\ProjectSeven\Notifications::AuthError);
// $oApiIntegrator->LogoutAccount();
// }
\CApi::LogException($oException);
$sAction = empty($sAction) ? 'Unknown' : $sAction;
$aResponseItem = $this->oActions->ExceptionResponse(null, $sAction, $oException);
}
@header('Content-Type: application/json; charset=utf-8');
\CApi::Plugin()->RunHook('ajax.response-result', array($sAction, &$aResponseItem));
$sResult = \MailSo\Base\Utils::Php2js($aResponseItem, \CApi::MailSoLogger());
// \CApi::Log('AJAX: Response: '.$sResult);
} else {
if ('upload' === $sFirstPart) {
@ob_start();
$aResponseItem = null;
$sAction = empty($aPaths[1]) ? '' : $aPaths[1];
try {
$sMethodName = 'Upload' . $sAction;
if (method_exists($this->oActions, $sMethodName) && is_callable(array($this->oActions, $sMethodName))) {
$sError = '';
$sInputName = 'jua-uploader';
$iError = UPLOAD_ERR_OK;
$_FILES = isset($_FILES) ? $_FILES : null;
if (isset($_FILES, $_FILES[$sInputName], $_FILES[$sInputName]['name'], $_FILES[$sInputName]['tmp_name'], $_FILES[$sInputName]['size'], $_FILES[$sInputName]['type'])) {
$iError = isset($_FILES[$sInputName]['error']) ? (int) $_FILES[$sInputName]['error'] : UPLOAD_ERR_OK;
if (UPLOAD_ERR_OK === $iError) {
$this->oActions->SetActionParams(array('AccountID' => $this->oHttp->GetPost('AccountID', ''), 'FileData' => $_FILES[$sInputName], 'AdditionalData' => $this->oHttp->GetPost('AdditionalData', null), 'IsExt' => '1' === (string) $this->oHttp->GetPost('IsExt', '0') ? '1' : '0', 'TenantHash' => (string) $this->oHttp->GetPost('TenantHash', ''), 'Token' => $this->oHttp->GetPost('Token', '')));
\CApi::LogObject($this->oActions->GetActionParams());
$aResponseItem = call_user_func(array($this->oActions, $sMethodName));
} else {
//.........這裏部分代碼省略.........
示例7: EntryApi
/**
*
* @return string
* @throws \System\Exceptions\AuroraApiException
*/
public function EntryApi()
{
@ob_start();
$aResponseItem = null;
$sModule = $this->oHttp->GetPost('Module', null);
$sMethod = $this->oHttp->GetPost('Method', null);
$sParameters = $this->oHttp->GetPost('Parameters', null);
$sFormat = $this->oHttp->GetPost('Format', null);
try {
if (isset($sModule, $sMethod)) {
if (strtolower($sModule) === strtolower($this->GetName())) {
\CApi::Log('API:');
\CApi::Log('Module: ' . $sModule);
\CApi::Log('Method: ' . $sMethod);
if (strtolower($sModule) !== 'core' && \CApi::GetConf('labs.webmail.csrftoken-protection', true) && !\CApi::validateAuthToken()) {
throw new \System\Exceptions\AuroraApiException(\System\Notifications::InvalidToken);
} else {
if (!empty($sModule) && !empty($sMethod)) {
$aParameters = isset($sParameters) && is_string($sParameters) ? @json_decode($sParameters, true) : array();
$sTenantName = $this->oHttp->GetPost('TenantName', '');
\CApi::setTenantName($sTenantName);
if (!is_array($aParameters)) {
$aParameters = array($aParameters);
}
$mUploadData = $this->getUploadData();
if (is_array($mUploadData)) {
$aParameters['UploadData'] = $mUploadData;
}
$this->CallMethod($sMethod, $aParameters, true);
$aResponseItem = $this->DefaultResponse($sMethod, \CApi::GetModuleManager()->GetResults());
}
}
if (!is_array($aResponseItem)) {
throw new \System\Exceptions\AuroraApiException(\System\Notifications::UnknownError);
}
if ($sFormat !== 'Raw') {
@header('Content-Type: application/json; charset=utf-8');
}
}
} else {
throw new \System\Exceptions\AuroraApiException(\System\Notifications::InvalidInputParameter);
}
} catch (\Exception $oException) {
\CApi::LogException($oException);
$aAdditionalParams = null;
if ($oException instanceof \System\Exceptions\AuroraApiException) {
$aAdditionalParams = $oException->GetObjectParams();
}
$aResponseItem = $this->ExceptionResponse($sMethod, $oException, $aAdditionalParams);
}
return \MailSo\Base\Utils::Php2js($aResponseItem, \CApi::MailSoLogger());
}