tomk79 / px2-px2dthelper
Requires
- php: >=7.3.0
- broccoli-html-editor/broccoli-html-editor: ~0.4
- michelf/php-markdown: ~1.6
- pickles2/lib-px2-contents-editor: ~2.0
- pickles2/lib-px2-module-editor: ~0.2
- pickles2/lib-px2-theme-editor: ~0.0
- tomk79/php-excel2html: ^0.0.8||~0.1
Requires (Dev)
This package is not auto-updated.
Last update: 2022-02-01 12:45:06 UTC
README
| Linux | Windows | |
|---|---|---|
| master |
|
|
| develop |
|
|
这是用于 Pickles 2 的插件。提供与 Pickles 2 桌面工具协同工作的 API。
安装 - Install
请按照以下步骤进行安装。
加载 Composer 包
$ composer require pickles2/px2-px2dthelper
将 Pickles2 的配置中追加
<?php return call_user_func( function(){ /* 中略 */ // funcs: Before content $conf->funcs->before_content = array( // PX=px2dthelper 'tomk79\pickles2\px2dthelper\main::register' ); /* 中略 */ // processor $conf->funcs->processor->html = array( // broccoli-receive-message スクリプトを挿入 // (Optional) 'tomk79\pickles2\px2dthelper\broccoli_receive_message::apply('.json_encode( array( // 許可する接続元を指定 'enabled_origin'=>array( 'http://127.0.0.1:8080', 'http://127.0.0.1:8081', 'http://127.0.0.1:8082', ) ) ).')' ); /* 中略 */ return $conf; } );
API
构建模块的 CSS
/* CSSファイルに下記を記述 */ <?php // CSSのソースコードが返されます。 // このコードには、画像などのリソースもdataスキーマ化した状態で含められます。 print (new \tomk79\pickles2\px2dthelper\main($px))->document_modules()->build_css(); ?>
构建模块的 JavaScript
// JavaScriptファイルに下記を記述 <?php // JavaScriptのソースコードが返されます。 // スクリプト内から画像などのリソースを呼び出している場合、 // このメソッドには、リンクを解決するなどの機能はありません。 // 予め、出力後のパスを起点にパスが解決できるように作成してください。 print (new \tomk79\pickles2\px2dthelper\main($px))->document_modules()->build_js(); ?>
将 CSS 和 JavaScript 加载到 HTML 中
<!DOCTYPE html> <html> <head> <title>Page Title</title> <?php // style要素、および script要素 が出力されます。 print (new \tomk79\pickles2\px2dthelper\main($px))->document_modules()->load(); ?> </head> <body> <h1>Page Title</h1> <!-- コンテンツ --> </body> </html>
PX 命令
PX=px2dthelper.version
获取 px2-px2dthelper 的版本号。
$ php .px_execute.php /?PX=px2dthelper.version
PX=px2dthelper.check_status
获取 px2-px2dthelper 的状态信息。
$ php .px_execute.php /?PX=px2dthelper.check_status
PX=px2dthelper.find_page_content
查找页面内容文件。
$ php .px_execute.php /path/find/content.html?PX=px2dthelper.find_page_content
PX=px2dthelper.get.realpath_data_dir
获取 $conf->plugins->px2dt->guieditor->path_data_dir 的解析后的内部绝对路径。
PX=px2dthelper.get.path_resource_dir
获取 $conf->plugins->px2dt->guieditor->path_resource_dir 的解析后的路径。
PX=px2dthelper.get.custom_fields
获取 $conf->plugins->px2dt->guieditor->custom_fields 的值。
PX=px2dthelper.get.navigation_info
汇总获取生成导航系统所需的信息。
$ php .px_execute.php "/?PX=px2dthelper.get.navigation_info&filter=false"
filter 选项传递给 $site->get_bros() 和 $site->get_children()。
PX=px2dthelper.get.realpath_theme_collection_dir
获取主题集合目录的路径。
$ php .px_execute.php "/?PX=px2dthelper.get.realpath_theme_collection_dir"
PX=px2dthelper.get.all
从 Pickles 2 一次性获取多个信息。
$ php .px_execute.php "/?PX=px2dthelper.get.all&filter=false&path=/index.html"
filter 选项传递给 $site->get_bros() 和 $site->get_children()。
PX=px2dthelper.check_editor_mode
获取内容的编辑模式。
$ php .px_execute.php "/?PX=px2dthelper.check_editor_mode&path=/target/path.html"
PX=px2dthelper.search_sitemap
在网站地图中搜索页面。
limit 选项用于指定搜索结果的最大条数。默认为200条。
$ php .px_execute.php "/?PX=px2dthelper.search_sitemap&keyword=HOME&limit=10"
PX=px2dthelper.sitemap.create
创建新的网站地图文件。在参数 filename 中指定要创建的网站地图文件名(不包括扩展名)。
$ php .px_execute.php "/?PX=px2dthelper.sitemap.create&filename=foobar"
PX=px2dthelper.sitemap.delete
删除网站地图文件。在参数 filename 中指定要删除的网站地图文件名(不包括扩展名)。
$ php .px_execute.php "/?PX=px2dthelper.sitemap.delete&filename=foobar"
PX=px2dthelper.document_modules.build_css
返回CSS源代码。
$ php .px_execute.php /?PX=px2dthelper.document_modules.build_css
此外,如果附加参数 theme_id,则返回由主题定义的CSS代码。
PX=px2dthelper.document_modules.build_js
返回JavaScript源代码。
$ php .px_execute.php /?PX=px2dthelper.document_modules.build_js
此外,如果附加参数 theme_id,则返回由主题定义的JavaScript代码。
PX=px2dthelper.document_modules.load
返回加载CSS和JavaScript的HTML源代码。
$ php .px_execute.php /?PX=px2dthelper.document_modules.load
PX=px2dthelper.convert_table_excel2html
基于CSV或Excel格式的表格生成HTML表格元素并输出。在参数 path 中指定 *.csv、*.xls、*.xlsx。
$ php .px_execute.php "/?PX=px2dthelper.convert_table_excel2html&path=/path/to/sourcedata.xlsx"
PX=px2dthelper.init_content
初始化内容。
$ php .px_execute.php "/path/init/content.html?PX=px2dthelper.init_content&editor_mode=html.gui"
从v2.0.12版本开始,此API在内容已存在的情况下不再覆盖,而是返回错误。如果附加 force 选项,则强制覆盖。
在v2.0.11及以前版本中,默认行为是覆盖现有内容进行初始化。
$ # forceオプションを付加した例 $ php .px_execute.php "/path/init/content.html?PX=px2dthelper.init_content&editor_mode=html.gui&force=1"
PX=px2dthelper.config.parse
解析设置文件(config.php),并返回解析出的值列表。
PX=px2dthelper.config.update
解析设置文件(config.php),并覆盖其中任意值。
$ php .px_execute.php "/path/to/target/page_path.html?PX=px2dthelper.config.update&base64_json=xxxxxxxxxxxx"
要更改的值可以设置为 json(JSON格式的字符串)或 base64_json(转换为Base64的JSON格式的字符串)之一。
$base64_json = base64_encode( json_encode( array( // config の項目で、上書きしたい情報をセットします。 'values' => array( 'name' => 'New Site Name', ), // config の物理構造に合致しない設定項目は、`symbols` の中に分類されます。 'symbols' => array( 'theme_id' => 'new_theme_id', ), ) ) );
PX=px2dthelper.copy_content
复制内容。
$ php .px_execute.php "/path/copy/to.html?PX=px2dthelper.copy_content&from=/path/copy/from.html"
或者:
$ php .px_execute.php "/?PX=px2dthelper.copy_content&from=/path/copy/from.html&to=/path/copy/to.html"
从v2.0.12版本开始,此API在内容已存在的情况下不再覆盖,而是返回错误。如果附加 force 选项,则强制覆盖。
在v2.0.11及以前版本中,默认行为是覆盖现有内容进行初始化。
$ # forceオプションを付加した例 $ php .px_execute.php "/?PX=px2dthelper.copy_content&from=/path/copy/from.html&to=/path/copy/to.html&force=1"
PX=px2dthelper.change_content_editor_mode
更改内容的编辑模式。
$ php .px_execute.php "/path/to/target/page_path.html?PX=px2dthelper.change_content_editor_mode&editor_mode=html.gui"
PX=px2dthelper.plugins.get_plugin_options
获取插件选项。
$ php .px_execute.php "/path/to/target/page_path.html?PX=px2dthelper.plugins.get_plugin_options&func_div=processor.html&plugin_name=namespace\\classname::funcname"
PX=px2dthelper.publish_single_page
单独发布指定的页面。同时也会发布页面特有的资源目录。
$ php .px_execute.php "/path/to/target/page_path.html?PX=px2dthelper.publish_single_page"
PX=px2dthelper.packages.get_path_composer_root_dir
获取放置 composer.json 的目录的路径。
PX=px2dthelper.packages.get_path_npm_root_dir
获取放置 package.json 的目录的路径。
PX=px2dthelper.packages.get_package_list
获取包列表。
$ php .px_execute.php "/path/to/target/page_path.html?PX=px2dthelper.packages.get_package_list"
PX=px2dthelper.px2ce.gpi
PX=px2dthelper.px2me.gpi
PX=px2dthelper.px2te.gpi
分别调用Pickles 2 Contents Editor、Pickles 2 Module Editor、Pickles 2 Theme Editor 的GPI。
可以指定以下选项。
appMode:web(默认)或desktopdata: 传递给GPI的参数。指定base64编码的JSON格式的文本。data_filename: 使用文件代替data传递JSON。将JSON保存到文件中,并指定文件名。文件应放置在px-files/_sys/ram/data/下。
PX=px2dthelper.px2ce.client_resources
PX=px2dthelper.px2me.client_resources
PX=px2dthelper.px2te.client_resources
分别返回Pickles 2 Contents Editor、Pickles 2 Module Editor、Pickles 2 Theme Editor客户端需要加载的资源列表。
默认情况下,返回服务器内部的绝对路径。将服务器内部的目录路径传递给dist参数,可以在指定目录内创建副本,并返回从该副本开始的相对路径。
PX=px2dthelper.custom_console_extensions
PX=px2dthelper.custom_console_extensions.XXXX.client_resources
PX=px2dthelper.custom_console_extensions.XXXX.gpi
PX=px2dthelper.custom_console_extensions_async_run
$conf->plugins->px2dt->customConsoleExtensions 提供访问已注册扩展功能的API。第三个参数的 XXXX 指定 Custom Console Extensions 中注册的ID(索引)。省略时,返回注册的扩展功能列表。
更新日志 - Change log
pickles2/px2-px2dthelper v2.1.0(2022年1月8日)
- 支持的PHP版本更改为
>=7.3.0。 - 适配PHP 8.1。
pickles2/px2-px2dthelper v2.0.22(2022年1月4日)
- 添加
$conf->plugins->px2dt->enable_document_modules_cache。可以设置是否缓存Broccoli相关资源的构建。默认为禁用。 - 修复了Pickles 2 Contents Editor、Pickles 2 Module Editor、Pickles 2 Theme Editor初始化相关的问题。
pickles2/px2-px2dthelper v2.0.21(2021年8月21日)
- 将捆绑的插件设置为更直接的表述。
- 性能方面的改进。
pickles2/px2-px2dthelper v2.0.20(2021年7月10日)
- 修复了在扩展field设置存在多个前端资源时无法处理的问题。
- 其他一些内部代码的微小修正。
pickles2/px2-px2dthelper v2.0.19(2021年4月24日)
- 添加了对
scssphp/scssphp的支持。 - 其他一些内部代码的微小修正。
pickles2/px2-px2dthelper v2.0.18(2021年2月21日)
- 修复了在首页目录和主题集合目录不在预览文档根目录外时无法返回正确路径的问题。
- 修复了API返回路径的Windows路径相关环境依赖问题。
pickles2/px2-px2dthelper v2.0.17(2021年2月21日)
- 更新:Broccoli v0.4.x
PX=px2dthelper.px2te.gpi,PX=px2dthelper.px2te.client_resources已添加。- 添加自定义控制台功能扩展。添加
PX=px2dthelper.custom_console_extensions。 - 将
custom_console_extensions添加到PX=px2dthelper.get.all的返回值中。 - 添加
PX=px2dthelper.get.path_theme_collection_dir。 - 将
path_theme_collection_dir添加到PX=px2dthelper.get.all的返回值中。 - 将
path_homedir添加到PX=px2dthelper.get.all的返回值中。
pickles2/px2-px2dthelper v2.0.16(2020年10月17日)
- 修复了在Firefox中Broccoli编辑器初始化无法完成的问题。
- 其他一些内部代码的微小修正。
pickles2/px2-px2dthelper v2.0.15 (2020年6月21日)
- 更新外部依赖库版本。
pickles2/px2-px2dthelper v2.0.14 (2020年1月2日)
- 兼容PHP 7.4。
pickles2/px2-px2dthelper v2.0.13 (2019年9月4日)
- 禁用停止Broccoli编辑画面的外部脚本。
pickles2/px2-px2dthelper v2.0.12 (2019年6月8日)
- 增加PX命令
PX=px2dthelper.config.parse和PX=px2dthelper.config.update。 - 增加PX命令
PX=px2dthelper.sitemap.create和PX=px2dthelper.sitemap.delete。 PX=px2dthelper.init_content和PX=px2dthelper.copy_content在内容已存在时不再覆盖,而是报错。相反,增加force选项,可以强制覆盖。PX=px2dthelper.get.all的结果中增加了page_originated_csv。(pickles2/px-fw-2.x v2.0.40或更高版本需要)PX=px2dthelper.search_sitemap增加了limit选项。默认上限为200条。- 开始缓存
document_modules的构建结果。
pickles2/px2-px2dthelper v2.0.11 (2018年11月8日)
- 修复了关于资源路径设置(
$conf->path_files,$conf->plugins->px2dt->guieditor->path_resource_dir,$conf->plugins->px2dt->guieditor->path_data_dir)无法使用回调函数的问题。
pickles2/px2-px2dthelper v2.0.10 (2018年10月26日)
- 修复了在Windows环境中,执行
PX=px2dthelper.publish_single_page时,资源目录不被包含在发布目标中的问题。
pickles2/px2-px2dthelper v2.0.9 (2018年9月25日)
- 增加PX命令
PX=px2dthelper.publish_single_page。 - 修复了在Pickles 2内容编辑器以及Pickles 2模块编辑器的API中,有时无法正常调用API的问题。
pickles2/px2-px2dthelper v2.0.8 (2018年8月16日)
- 增加
broccoli-html-editor的API。 - 增加Pickles 2内容编辑器的API。
- 增加Pickles 2模块编辑器的API。
pickles2/px2-px2dthelper v2.0.7 (2018年2月28日)
- 放宽了对依赖库
michelf/php-markdown,leafo/scssphp的版本限制。(pickles2/px-fw-2.x更新时配合使用) - 修复了当
$conf->px2dtconfig以关联数组形式设置时,规范化处理未能正确反映的问题。
pickles2/px2-px2dthelper v2.0.6 (2017年9月14日)
- 增加PX命令
PX=px2dthelper.plugins.get_plugin_options。 - 增加PX命令
PX=px2dthelper.packages.get_package_list。 - 增加PX命令
PX=px2dthelper.packages.get_path_composer_root_dir。 - 增加PX命令
PX=px2dthelper.packages.get_path_npm_root_dir。 - 增加PX命令
PX=px2dthelper.get.realpath_theme_collection_dir。 - 增加PX命令
PX=px2dthelper.get.all和PX=px2dthelper.check_editor_mode的path选项。 - 增加PX命令
PX=px2dthelper.get.all的结果中的path_type,realpath_theme_collection_dir,packages->path_composer_root_dir,packages->path_npm_root_dir,packages->package_list。 - 在PX命令
PX=px2dthelper.get.all中,可以通过指定path选项中的id来获取别名页面的信息。 - 支持
$conf->plugins->px2dt->path_module_templates_dir设置。 - PX命令
PX=px2dthelper.document_modules.build_css和PX=px2dthelper.document_modules.build_js支持主题模块。
pickles2/px2-px2dthelper v2.0.5 (2017年5月30日)
- 增加插入新
processor以插入broccoli-receive-message脚本。 - 增加PX命令
PX=px2dthelper.search_sitemap。 - 修复了在
PX=px2dthelper.copy_content中,当$from和$to指向相同内容时,内容文件会消失的问题。
pickles2/px2-px2dthelper v2.0.4 (2017年4月20日)
- 增加PX命令
PX=px2dthelper.get.navigation_info。 - 增加PX命令
PX=px2dthelper.get.all的filter选项。 PX=px2dthelper.get.all中的path_files和realpath_files有时返回非法值的问题已得到修复。
pickles2/px2-px2dthelper v2.0.3 (2017年2月6日)
- 添加了 PX 命令
PX=px2dthelper.get.all。 - 将
paths_module_template格式化为绝对路径后再返回。 - 在
$site不可用的情况下防止异常终止。
pickles2/px2-px2dthelper v2.0.2 (2017年1月18日)
- 整理了 CSS 和 JS 的构建结果。
pickles2/px2-px2dthelper v2.0.1 (2016年10月17日)
- 添加了 PX 命令
PX=px2dthelper.find_page_content。 - 添加了 PX 命令
PX=px2dthelper.get.realpath_data_dir。 - 添加了 PX 命令
PX=px2dthelper.get.path_resource_dir。 - 添加了 PX 命令
PX=px2dthelper.get.custom_fields。 - 添加了 PX 命令
PX=px2dthelper.check_editor_mode。 - 添加了 PX 命令
PX=px2dthelper.init_content。 - 添加了 PX 命令
PX=px2dthelper.change_content_editor_mode。 - 添加了 PX 命令
PX=px2dthelper.check_status。 - 增加了
PX=px2dthelper.copy_content的复制目标指定方法。现在也可以使用类似/path/copy/to.html?PX=〜〜的方式指定。
pickles2/px2-px2dthelper v2.0.0 (2016年9月15日)
- 首次发布。
针对开发者
测试 - Test
$ ./vendor/phpunit/phpunit/phpunit
文档输出 - phpDocumentor
$ composer run-script documentation
许可证 - License
版权所有 (c)2001-2021 Tomoya Koyanagi,Pickles 2 项目
MIT 许可证 https://open-source.org.cn/licenses/mit-license.php
作者 - Author
- Tomoya Koyanagi tomk79@gmail.com
- 网站: https://www.pxt.jp/
- 推特: @tomk79 https://twitter.com/tomk79/