模块开发: Difference between revisions

Jump to navigation Jump to search
Tag: 2017 source edit
 
(6 intermediate revisions by the same user not shown)
Line 11: Line 11:


[[Category:Core]]
[[Category:Core]]
[[Category:开发]]
{{Template用户手册}}
{{Template用户手册}}
{{Template开发文档}}
{{Template开发文档}}
Line 171: Line 172:


<syntaxhighlight lang="PHP">
<syntaxhighlight lang="PHP">
// Array to add new pages in new tabs or remove existing one
// 用于在新tabs中添加新页面或删除现有页面的数组
$this->tabs = array('objecttype:+tabname1:Title1:mylangfile@mymodule:$user->rights->mymodule->read:/mymodule/mypagetab1.php?id=__ID__'    // To add a new tab identified by code tabname1
$this->tabs = array('objecttype:+tabname1:Title1:mylangfile@mymodule:$user->rights->mymodule->read:/mymodule/mypagetab1.php?id=__ID__'    // 增加一个由code tabname1标识的新tab
                             'objecttype:+tabname2:Title2:mylangfile@mymodule:$user->rights->mymodule->read:/mymodule/mypagetab2.php?id=__ID__',  // To add a new tab identified by code tabname2
                             'objecttype:+tabname2:Title2:mylangfile@mymodule:$user->rights->mymodule->read:/mymodule/mypagetab2.php?id=__ID__',  // 增加一个由code tabname2标识的新tab
                             'objecttype:-tabname');                                                    // To remove an existing tab identified by code tabname
                             'objecttype:-tabname');                                                    // 删除一个由code tabname标识的现有选项卡
</syntaxhighlight>
</syntaxhighlight>


Line 239: Line 240:


<syntaxhighlight lang="PHP">
<syntaxhighlight lang="PHP">
$head        // Array of tabs
$head        // tabs的数组
$head[$h]    // Element to describe one tab.
$head[$h]    // Element to describe one tab.
$head[$h][0] // Url of page to show when you click on tab
$head[$h][0] // Url of page to show when you click on tab
Line 260: Line 261:
<syntaxhighlight lang="PHP">
<syntaxhighlight lang="PHP">
dol_fiche_head($links, $active='0', $title='', $notab=0, $picto='')
dol_fiche_head($links, $active='0', $title='', $notab=0, $picto='')
//$links  // Tableau des onglets, appelé $head plus haut.
//$links  // tabs的数组,上面称为$head
//$active // Onglet actif (mettre le nom de l'onglet défini dans votre fichier de module, ou un nom contenu dans $head[$h][2]). Cet onglet sera mis en surbrillance
//$active // 活动选项卡(输入模块文件中定义的选项卡名称,或$head[$h][2]中包含的名称)。此选项卡将突出显示
//$title  // Title to show (shown into a special tab that you can't click)
//$title  // 要显示的标题(显示在无法单击的特殊选项卡中)
//$notab
//$notab
//$picto  // Name of image to show into title. Possible values are:
//$picto  // 要显示到标题中的图片的名称。可能的值为:
//            product
//            product
//            service
//            service
Line 278: Line 279:


===创建原始PHP屏幕页面===
===创建原始PHP屏幕页面===
随后,您可以使用 '''modulebuilder''' 目录中提供的示例模板('''myobject_page.php''')创建基于表数据的PHP页面(有关命令行脚本的开发,请参阅 [[Script development]] )。同样,如果您使用的是 ModuleBuilder,则在初始化对象时会自动创建页面实例(清单、创建页面、Notes选项卡等)。
随后,您可以使用 '''modulebuilder''' 目录中提供的示例模板('''myobject_page.php''')创建基于表数据的PHP页面(有关命令行脚本的开发,请参阅 [[脚本开发]] )。同样,如果您使用的是 ModuleBuilder,则在初始化对象时会自动创建页面实例(清单、创建页面、Notes选项卡等)。


要创建新的用户屏幕页面,请创建特定于模块的 '''htdocs''' 子目录(如果尚未创建)(如 '''htdocs/mymodule''' ),以便在其中放置要创建的页面。
要创建新的用户屏幕页面,请创建特定于模块的 '''htdocs''' 子目录(如果尚未创建)(如 '''htdocs/mymodule''' ),以便在其中放置要创建的页面。
Line 285: Line 286:


<syntaxhighlight lang="PHP">
<syntaxhighlight lang="PHP">
// Load Dolibarr environment
// 加载Dolibarr环境
$res=0;
$res=0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
// 尝试include在CONTEXT_DOCUMENT_ROOT(不总是定义的)中定义的已知web根目录中的main.inc.php
if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php");
if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php");
// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME
// 尝试include由SCRIPT_FILENAME计算的web根检测到web根的main.inc.php
$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php");
if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php");
if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php");
if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php");
// Try main.inc.php using relative path
// 尝试include使用相对路径的main.inc.php
if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php");
if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php");
if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php");
if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php");
Line 634: Line 635:


请参阅页面 [[Hooks_system|Hooks系统]].
请参阅页面 [[Hooks_system|Hooks系统]].
==添加编号模块(可选)==
==添加编号模块(可选)==
'''何时''':当您想添加默认模块未涵盖的编号规则时。
'''何时''':当您想添加默认模块未涵盖的编号规则时。
715

edits

Navigation menu