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


PHP io::jsonEncode方法代码示例

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


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

示例1: file_get_contents

	// The templates definitions.
	templates :';
//append XML templates
$filename = PATH_CSS_FS . '/editortemplates.xml';
if (file_exists($filename)) {
    $source = file_get_contents($filename);
    $file = new DOMDocument('1.0', APPLICATION_DEFAULT_ENCODING);
    $file->loadXml($source, $options);
    $tplsTags = $file->getElementsByTagName('Template');
    $tpls = array();
    foreach ($tplsTags as $tplTag) {
        $tpl = new stdClass();
        $tpl->title = $tplTag->getAttribute("title");
        $descTags = $tplTag->getElementsByTagName('Description');
        if ($descTags->length) {
            foreach ($descTags as $descTag) {
                $tpl->description = $descTag->nodeValue;
            }
        }
        $htmlTags = $tplTag->getElementsByTagName('Html');
        if ($htmlTags->length) {
            foreach ($htmlTags as $htmlTag) {
                $tpl->html = $htmlTag->nodeValue;
            }
        }
        $tpls[] = $tpl;
    }
    $content .= io::jsonEncode($tpls);
}
$content .= '});';
echo $content;
开发者ID:davidmottet,项目名称:automne,代码行数:31,代码来源:templates.php

示例2: _getHTMLForm

    /**
     * Get the HTML form given the block HTML example data.
     *
     * @param CMS_language &$language The language of the administration frontend
     * @param CMS_page &$page The page which contains the client space
     * @param CMS_clientSpace &$clientSpace The client space which contains the row
     * @param CMS_row &$row The row which contains the block
     * @param integer $blockID The tag ID of the block
     * @param string $data The data to show as example
     * @return string The HTML form which can send to the page that will modify the block
     * @access private
     */
    protected function _getHTMLForm($language, &$page, &$clientSpace, &$row, $blockID, $data)
    {
        global $cms_user;
        //append atm-block class and block-id to all first level tags found in block datas
        $domdocument = new CMS_DOMDocument();
        try {
            $domdocument->loadXML('<block>' . $data . '</block>');
        } catch (DOMException $e) {
            $this->raiseError('Parse error for ' . get_class($this) . ' : Page ' . $page->getID() . ' - Row "' . $row->getTagID() . '" - Block "' . $blockID . '" : ' . $e->getMessage());
            $data = '<div class="atm-error-block atm-block-helper">' . $language->getMessage(self::MESSAGE_BLOCK_CONTENT_ERROR) . '</div>';
            $domdocument = new CMS_DOMDocument();
            $domdocument->loadXML('<block>' . $data . '</block>');
        }
        $blockNodes = $domdocument->getElementsByTagName('block');
        if ($blockNodes->length == 1) {
            $blockXML = $blockNodes->item(0);
        }
        //check for valid tags nodes inside current block tag
        $hasNode = false;
        foreach ($blockXML->childNodes as $blockChildNode) {
            //scripts tags and p tags are not correctly handled by javascript
            if (is_a($blockChildNode, 'DOMElement') && $blockChildNode->tagName != 'script') {
                $hasNode = true;
            }
        }
        foreach ($blockXML->childNodes as $blockChildNode) {
            //scripts tags and p tags are not correctly handled by javascript
            if (is_a($blockChildNode, 'DOMElement') && ($blockChildNode->tagName != 'p' || io::substr($blockChildNode->tagName, 0, 4) != 'atm-')) {
                $hasNode = false;
            }
        }
        if (!$hasNode) {
            //append div with atm-empty-block class around datas
            $domdocument = new CMS_DOMDocument();
            try {
                $domdocument->loadXML('<block><div class="atm-empty-block atm-block-helper">' . $data . '</div></block>');
            } catch (DOMException $e) {
                $this->raiseError('Parse error for block : ' . $e->getMessage() . " :\n" . $data, true);
                return '';
            }
            $blockNodes = $domdocument->getElementsByTagName('block');
            if ($blockNodes->length == 1) {
                $blockXML = $blockNodes->item(0);
            }
        }
        $elements = array();
        $uniqueId = 'block-' . md5(mt_rand() . microtime());
        foreach ($blockXML->childNodes as $blockChildNode) {
            if (is_a($blockChildNode, 'DOMElement') && $blockChildNode->tagName != 'script' && $blockChildNode->tagName != 'p' && io::substr($blockChildNode->tagName, 0, 4) != 'atm-') {
                if ($blockChildNode->hasAttribute('class')) {
                    $blockChildNode->setAttribute('class', $blockChildNode->getAttribute('class') . ' atm-block ' . $uniqueId);
                } else {
                    $blockChildNode->setAttribute('class', 'atm-block ' . $uniqueId);
                }
                $elementId = 'el-' . md5(mt_rand() . microtime());
                $blockChildNode->setAttribute('id', $elementId);
                $elements[] = $elementId;
            }
        }
        $data = CMS_DOMDocument::DOMElementToString($blockXML, true);
        //add block JS specification
        $data = '
		<script type="text/javascript">
			atmBlocksDatas[\'' . $uniqueId . '\'] = {
				page:				\'' . $page->getID() . '\',
				document:			document,
				clientSpaceTagID:	\'' . $clientSpace->getTagID() . '\',
				row:				\'' . $row->getTagID() . '\',
				id:					\'' . $blockID . '\',
				jsBlockClass:		\'' . $this->_jsBlockClass . '\',
				hasContent:			\'' . $this->_hasContent . '\',
				editable:			\'' . $this->_editable . '\',
				administrable:		\'' . $this->_administrable . '\',
				options:			' . io::jsonEncode($this->_options) . ',
				value:				' . (is_array($this->_value) ? sensitiveIO::jsonEncode($this->_value) : '\'' . sensitiveIO::sanitizeJSString($this->_value) . '\'') . ',
				elements:			[' . ($elements ? '\'' . implode('\',\'', $elements) . '\'' : '') . ']
			};
		</script>
		' . $data;
        return $data;
    }
开发者ID:davidmottet,项目名称:automne,代码行数:93,代码来源:block.php

示例3: file_get_contents

}
//append XML styles
$filename = PATH_CSS_FS . '/editorstyles.xml';
if (file_exists($filename)) {
    $source = file_get_contents($filename);
    $file = new DOMDocument('1.0', APPLICATION_DEFAULT_ENCODING);
    $file->loadXml($source, $options);
    $stylesTags = $file->getElementsByTagName('Style');
    $styles = array();
    foreach ($stylesTags as $styleTag) {
        $style = new stdClass();
        $style->name = $styleTag->getAttribute("name");
        $style->element = $styleTag->getAttribute("element");
        $attrTags = $styleTag->getElementsByTagName('Attribute');
        if ($attrTags->length) {
            $style->attributes = new stdClass();
            foreach ($attrTags as $attrTag) {
                $name = $attrTag->getAttribute("name");
                $style->attributes->{$name} = $attrTag->getAttribute("value");
            }
        }
        $styles[] = $style;
    }
    $content .= 'config.stylesSet = ' . io::jsonEncode($styles) . ';' . "\n";
}
$content .= '
	config.templates_files = [\'' . PATH_MAIN_WR . '/ckeditor/templates.php\'];
	config.menu_groups = \'clipboard,tablecell,tablecellproperties,tablerow,tablecolumn,table,anchor,link,automneLinks,editPlugin\';
};
';
echo $content;
开发者ID:davidmottet,项目名称:automne,代码行数:31,代码来源:config.php


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