当前位置: 首页>>代码示例>>PHP>>正文


PHP Json::encode方法代码示例

本文整理汇总了PHP中Bitrix\Main\Web\Json::encode方法的典型用法代码示例。如果您正苦于以下问题:PHP Json::encode方法的具体用法?PHP Json::encode怎么用?PHP Json::encode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bitrix\Main\Web\Json的用法示例。


在下文中一共展示了Json::encode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: renderMenu

function renderMenu($id, $items)
{
    ?>
	<script>
		BX('<?php 
    echo $id;
    ?>
').onclick = function()
		{
			this.blur();

			BX.adminShowMenu(this,
				<?php 
    $json = array();
    foreach ($items as $name => $params) {
        $json[] = array('TEXT' => $name, 'ONCLICK' => "window.location.href = '?" . http_build_query($params) . "'");
    }
    echo Json::encode($json);
    ?>
				, {active_class: 'adm-btn-save-active'});

			return false;
		};
	</script>
	<?php 
}
开发者ID:Satariall,项目名称:izurit,代码行数:26,代码来源:scale.php

示例2: doPostAction

 protected function doPostAction($isEdit, $action)
 {
     /** @global CMain $APPLICATION */
     global $APPLICATION;
     if ($isEdit) {
         $APPLICATION->RestartBuffer();
         header('Content-Type: application/json', true);
         echo Json::encode($this->arResult);
         die;
     } else {
         switch ($action) {
             case 'download':
                 $APPLICATION->restartBuffer();
                 header('Content-Type: text/plain', true);
                 header('Content-Disposition: attachment; filename="recovery_codes.txt"');
                 header('Content-Transfer-Encoding: binary');
                 header(sprintf('Content-Length: %d', CUtil::BinStrlen($this->arResult['PLAIN_RESPONSE'])));
                 echo $this->arResult['PLAIN_RESPONSE'];
                 exit;
                 break;
             case 'print':
                 $APPLICATION->restartBuffer();
                 $this->includeComponentTemplate(static::PRINT_PAGE);
                 exit;
                 break;
             case 'view':
             default:
                 $this->includeComponentTemplate(static::VIEW_PAGE);
                 break;
         }
     }
 }
开发者ID:akniyev,项目名称:itprom_dobrohost,代码行数:32,代码来源:class.php

示例3: onBeforeHTMLEditorScriptRuns

 public static function onBeforeHTMLEditorScriptRuns()
 {
     $asset = Asset::getInstance();
     $asset->addJs('/bitrix/js/newkaliningrad.typografru/typograf.js');
     $messages = Loc::loadLanguageFile(Path::normalize(__FILE__));
     $asset->addString(sprintf('<script>BX.message(%s)</script>', Json::encode($messages, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE)));
 }
开发者ID:askew-,项目名称:bitrix-typograf,代码行数:7,代码来源:typograf.php

示例4: sendJsonResponse

 protected function sendJsonResponse($response)
 {
     global $APPLICATION;
     $APPLICATION->restartBuffer();
     header('Content-Type:application/json; charset=UTF-8');
     echo Json::encode($response);
     $this->end();
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:8,代码来源:basecomponent.php

示例5: sendJsonResponse

 protected function sendJsonResponse($response)
 {
     $this->getApplication()->restartBuffer();
     while (ob_end_clean()) {
     }
     header('Content-Type:application/json; charset=UTF-8');
     echo Json::encode($response);
     $this->end();
 }
开发者ID:Satariall,项目名称:izurit,代码行数:9,代码来源:class.php

示例6: encode

 public static function encode($data)
 {
     // php 5.4.0+
     if (defined('JSON_UNESCAPED_UNICODE')) {
         return parent::encode($data, JSON_UNESCAPED_UNICODE);
     } else {
         return static::_encode(static::convertData($data));
     }
 }
开发者ID:webgksupport,项目名称:alpina,代码行数:9,代码来源:yandexjson.php

示例7: sendJsonResponse

 protected function sendJsonResponse($response)
 {
     if (!defined('PUBLIC_AJAX_MODE')) {
         define('PUBLIC_AJAX_MODE', true);
     }
     global $APPLICATION;
     $APPLICATION->restartBuffer();
     while (ob_end_clean()) {
     }
     header('Content-Type:application/json; charset=UTF-8');
     echo Json::encode($response);
     $this->end();
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:13,代码来源:ajax.php

示例8: sendJsonResponse

 protected function sendJsonResponse($response, $params = null)
 {
     if (!defined('PUBLIC_AJAX_MODE')) {
         // define('PUBLIC_AJAX_MODE', true);
     }
     global $APPLICATION;
     $APPLICATION->restartBuffer();
     if (!empty($params['http_status']) && $params['http_status'] == 403) {
         header('HTTP/1.0 403 Forbidden', true, 403);
     }
     if (!empty($params['http_status']) && $params['http_status'] == 500) {
         header('HTTP/1.0 500 Internal Server Error', true, 500);
     }
     header('Content-Type:application/json; charset=UTF-8');
     echo Json::encode($response);
     $this->end();
 }
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:17,代码来源:controller.php

示例9: executeComponent

 public function executeComponent()
 {
     /** @global CMain $APPLICATION */
     global $APPLICATION;
     if ($this->request->isPost() && $this->request['action']) {
         // try to connect
         $result = $this->toEdit();
         $result = Json::encode($result);
         $APPLICATION->RestartBuffer();
         header('Content-Type: application/json', true);
         echo $result;
         die;
     } else {
         $APPLICATION->SetTitle(Loc::getMessage("SECURITY_OTP_TITLE"));
         // get data for new OTP connection
         $this->arResult = $this->toView();
         $this->IncludeComponentTemplate();
     }
 }
开发者ID:akniyev,项目名称:itprom_dobrohost,代码行数:19,代码来源:class.php

示例10: array

$availableTypesDescription = \Bitrix\Security\Mfa\Otp::getTypesDescription();
$currentPage = $APPLICATION->GetCurPageParam(sprintf('%s_active_tab=%s', $tabControl->name, $tabControl->tabs[$tabControl->tabIndex]['DIV']), array(sprintf('%s_active_tab', $tabControl->name)));
$deactivateDays = array();
$deactivateDays[] = GetMessage("SEC_OTP_NO_DAYS");
for ($i = 1; $i <= 10; $i++) {
    $deactivateDays[$i] = FormatDate("ddiff", time() - 60 * 60 * 24 * $i);
}
$jsMessages = array('SEC_OTP_ERROR_TITLE' => GetMessage('SEC_OTP_ERROR_TITLE'), 'SEC_OTP_UNKNOWN_ERROR' => GetMessage('SEC_OTP_UNKNOWN_ERROR'));
$jsSettings = array('userId' => (int) $ID, 'successfulUrl' => $currentPage, 'deactivateDays' => $deactivateDays, 'availableTypes' => $availableTypesDescription);
?>
<script id="otp-user-edit-messages" type="application/json"><?php 
echo \Bitrix\Main\Web\Json::encode($jsMessages);
?>
</script>
<script id="otp-user-edit-settings" type="application/json"><?php 
echo \Bitrix\Main\Web\Json::encode($jsSettings);
?>
</script>
<!--Popup starts-->
<tr style="display: none;">
	<td colspan="2">
<div id="otp-mobile-popup" class="otp-popup otp-mobile" data-title="<?php 
echo GetMessage('SEC_OTP_CONNECT_MOBILE_TITLE');
?>
">
	<div class="otp-description">
		<ol>
			<li><?php 
echo GetMessage('SEC_OTP_CONNECT_MOBILE_STEP_1');
?>
</li>
开发者ID:akniyev,项目名称:itprom_dobrohost,代码行数:31,代码来源:options_user_settings_1.php

示例11: toJsObject

        if ($code != '') {
            $orm = ApplicationPasswordTable::getList(array('select' => array('ID'), 'filter' => array('USER_ID' => $USER->GetID(), 'CODE' => $code)));
            if ($row = $orm->fetch()) {
                ApplicationPasswordTable::delete($row['ID']);
            }
        }
        $password = ApplicationPasswordTable::generatePassword();
        $res = ApplicationPasswordTable::add(array('USER_ID' => $USER->GetID(), 'APPLICATION_ID' => 'desktop', 'PASSWORD' => $password, 'DATE_CREATE' => new Main\Type\DateTime(), 'CODE' => $code, 'COMMENT' => GetMessage('DESKTOP_APP_GENERATOR'), 'SYSCOMMENT' => GetMessage('DESKTOP_APP_TITE')));
        if ($res->isSuccess()) {
            $answer["appPassword"] = $password;
        }
    }
}
if (isset($_REQUEST['json']) && $_REQUEST['json'] == 'y') {
    header('Content-Type: application/json');
    echo Main\Web\Json::encode($answer);
} else {
    echo toJsObject($answer);
}
function toJsObject(array $answer)
{
    $answerParts = array();
    foreach ($answer as $attr => $value) {
        switch (gettype($value)) {
            case 'string':
                $value = "'" . CUtil::JSEscape($value) . "'";
                break;
            case 'boolean':
                $value = $value === true ? 'true' : 'false';
                break;
            case 'array':
开发者ID:Levan1209,项目名称:u136016,代码行数:31,代码来源:index.php

示例12: response

function response($result)
{
    echo Json::encode($result);
    die;
}
开发者ID:webgksupport,项目名称:alpina,代码行数:5,代码来源:ajax.php

示例13: substr

        $newNumber = substr($_POST["BLACKLIST_NEW_NUMBER"], 0, 20);
        $newNumber = CVoxImplantPhone::Normalize($newNumber);
        if ($newNumber) {
            $dbBlacklist = Bitrix\Voximplant\BlacklistTable::getList(array("filter" => array("PHONE_NUMBER" => $newNumber)));
            if (!$dbBlacklist->Fetch()) {
                Bitrix\Voximplant\BlacklistTable::add(array("PHONE_NUMBER" => $newNumber));
            }
            LocalRedirect(POST_FORM_ACTION_URI);
        } else {
            $arResult["ERROR"] = GetMessage("VI_BLACKLIST_NUMBER_ERROR");
        }
    }
    if (isset($_POST["action"]) && $_POST["action"] == "delete_number") {
        $dbBlacklist = Bitrix\Voximplant\BlacklistTable::getList(array("filter" => array("PHONE_NUMBER" => $_POST["number"])));
        if ($arBlacklist = $dbBlacklist->Fetch()) {
            Bitrix\Voximplant\BlacklistTable::delete($arBlacklist["ID"]);
        }
        $APPLICATION->RestartBuffer();
        echo \Bitrix\Main\Web\Json::encode(array("success" => "Y"));
        die;
    }
}
$arResult["ITEMS"] = array();
$dbBlacklist = Bitrix\Voximplant\BlacklistTable::getList();
while ($arBlacklist = $dbBlacklist->Fetch()) {
    $arResult["ITEMS"][] = $arBlacklist;
}
$arResult["BLACKLIST_AUTO"] = Bitrix\Main\Config\Option::get("voximplant", "blacklist_auto", "N");
$arResult["BLACKLIST_TIME"] = intval(Bitrix\Main\Config\Option::get("voximplant", "blacklist_time", 5));
$arResult["BLACKLIST_COUNT"] = intval(Bitrix\Main\Config\Option::get("voximplant", "blacklist_count", 5));
$this->IncludeComponentTemplate();
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:component.php

示例14: array

                case 'original_texts':
                    $res = $engine->getOriginalTexts($arDomain['DOMAIN'], $arDomain['SITE_DIR']);
                    break;
                case 'crawling':
                    $res = array('excluded' => $engine->getExcluded($arDomain['DOMAIN'], $arDomain['SITE_DIR']), 'indexed' => $engine->getIndexed($arDomain['DOMAIN'], $arDomain['SITE_DIR']));
                    break;
                default:
                    $res = array('error' => 'unknown action');
                    break;
            }
        } catch (Engine\YandexException $e) {
            $res = array('error' => array('message' => $e->getMessage(), 'status' => $e->getStatus(), 'code' => $e->getCode()));
        }
    }
    Header('Content-type: application/json; charset=' . LANG_CHARSET);
    echo \Bitrix\Main\Web\Json::encode($res);
} elseif (isset($_REQUEST['get'])) {
    switch ($_REQUEST['get']) {
        case 'original_text_form':
            $arSettings = $engine->getSettings();
            $arDomains = \CSeoUtils::getDomainsList();
            foreach ($arDomains as $key => $domain) {
                if (!isset($arSettings['SITES'][$domain['DOMAIN']])) {
                    unset($arDomains[$key]);
                }
            }
            if (count($arDomains) <= 0) {
                $msg = new CAdminMessage(array('MESSAGE' => Loc::getMessage('SEO_YANDEX_ERROR'), 'HTML' => 'Y'));
                echo $msg->Show();
            } else {
                ?>
开发者ID:webgksupport,项目名称:alpina,代码行数:31,代码来源:seo_yandex.php

示例15:

    ?>
">
				<span class="bx-disk-interface-bread-crumbs-item-current"><?php 
    echo $crumb['NAME'];
    ?>
</span>
			</a>
			<span class="clb"></span>
		</span>
		<?php 
}
?>
</div>

<script type="application/javascript">
	BX.ready(function () {
		new BX.Disk.BreadcrumbsClass({
			containerId: '<?php 
echo $arResult['BREADCRUMBS_ID'];
?>
',
			collapsedCrumbs: <?php 
echo \Bitrix\Main\Web\Json::encode($preparedToJs);
?>
,
			showOnlyDeleted: <?php 
echo (int) $arResult['SHOW_ONLY_DELETED'];
?>
		});
	});
</script>
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:template.php


注:本文中的Bitrix\Main\Web\Json::encode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。