diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index a7e404383ea..9258e2b145d 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -58,7 +58,7 @@ class DolEditor * 'Out:name' share toolbar into the div called 'name' * @param boolean $toolbarstartexpanded Bar is visible or not at start * @param int $uselocalbrowser Enabled to add links to local object with local browser. If false, only external images can be added in content. - * @param int $okforextendededitor True=Allow usage of extended editor tool (like fckeditor) + * @param int $okforextendededitor True=Allow usage of extended editor tool (like fckeditor). If false, use simple textarea. * @param int $rows Size of rows for textarea tool * @param string $cols Size of cols for textarea tool (textarea number of cols '70' or percent 'x%') * @param int $readonly 0=Read/Edit, 1=Read only @@ -100,7 +100,7 @@ class DolEditor $this->editor->Height = $height; if (! empty($width)) $this->editor->Width = $width; $this->editor->ToolbarSet = $shorttoolbarname; // Profile of this toolbar set is deinfed into theme/mytheme/ckeditor/config.js - $this->editor->Config['AutoDetectLanguage'] = 'true'; + $this->editor->Config['AutoDetectLanguage'] = 'true'; // Language of user (browser) $this->editor->Config['ToolbarLocation'] = $toolbarlocation ? $toolbarlocation : 'In'; $this->editor->Config['ToolbarStartExpanded'] = $toolbarstartexpanded; @@ -196,7 +196,7 @@ class DolEditor htmlEncodeOutput :'.$htmlencode_force.', allowedContent :'.($disallowAnyContent?'false':'true').', extraAllowedContent : \'\', - fullPage : '.($fullpage?'true':'false').', + fullPage : '.($fullpage?'true':'false').', toolbar: \''.$this->toolbarname.'\', toolbarStartupExpanded: '.($this->toolbarstartexpanded ? 'true' : 'false').', width: '.($this->width ? '\''.$this->width.'\'' : '\'\'').', diff --git a/htdocs/core/class/interfaces.class.php b/htdocs/core/class/interfaces.class.php index 625b30e3ac2..8262e315540 100644 --- a/htdocs/core/class/interfaces.class.php +++ b/htdocs/core/class/interfaces.class.php @@ -335,7 +335,7 @@ class Interfaces $triggers[$j]['iscoreorexternal'] = $iscoreorexternal[$key]; $triggers[$j]['version'] = $objMod->getVersion(); $triggers[$j]['status'] = img_picto($langs->trans("Active"),'tick'); - if ($disabledbyname > 0 || $disabledbymodule > 1) $triggers[$j]['status'] = " "; + if ($disabledbyname > 0 || $disabledbymodule > 1) $triggers[$j]['status'] = ''; $text =''.$langs->trans("Description").':
'; $text.=$objMod->getDesc().'
'; diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 9eb910da360..8fab0a7b07f 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -15,7 +15,7 @@ ModuleBuilderDescspecifications=You can enter here a long text to describe the s ModuleBuilderDescobjects=Define here the objects you want to manage with your module. A sql file, a page to list them, to create/edit/view a card and an API will be generated. ModuleBuilderDescmenus=This tab is dedicated to define menu entries provided by your module. ModuleBuilderDescpermissions=This tab is dedicated to define the new permissions you want to provide with your module. -ModuleBuilderDesctriggers=This is the view of triggers provided by your module. To include code executed when a triggered business event is launched, just edit this file with your IDE. +ModuleBuilderDesctriggers=This is the view of triggers provided by your module. To include code executed when a triggered business event is launched, just edit this file. ModuleBuilderDeschooks=This tab is dedicated to hooks. ModuleBuilderDescwidgets=This tab is dedicated to manage/build widgets. ModuleBuilderDescbuildpackage=You can generate here a "ready to distribute" package file (a normalized .zip file) of your module and a "ready to distribute" documentation file. Just click on button to build the package or documentation file. @@ -24,7 +24,7 @@ EnterNameOfObjectToDeleteDesc=You can delete an object. WARNING: All files relat DangerZone=Danger zone BuildPackage=Build package/documentation BuildDocumentation=Build documentation -ModuleIsNotActive=This module was not activated yet (go into Home-Setup-Module to make it live) +ModuleIsNotActive=This module was not activated yet (go into %s to make it live) ModuleIsLive=This module has been activated. Any change on it may break a current active feature. DescriptionLong=Long description EditorName=Name of editor diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 8ea54b78454..4037b727ee4 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1,7 +1,5 @@ - * Copyright (C) 2004-2017 Laurent Destailleur - * Copyright (C) 2005-2010 Regis Houssin +/* Copyright (C) 2004-2017 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,6 +22,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $langs->load("admin"); $langs->load("modulebuilder"); @@ -31,17 +30,20 @@ $langs->load("other"); $action=GETPOST('action','aZ09'); $confirm=GETPOST('confirm','alpha'); + $module=GETPOST('module','alpha'); $tab=GETPOST('tab','aZ09'); $tabobj=GETPOST('tabobj','alpha'); if (empty($module)) $module='initmodule'; if (empty($tab)) $tab='description'; if (empty($tabobj)) $tabobj='newobject'; +$file=GETPOST('file','alpha'); $modulename=dol_sanitizeFileName(GETPOST('modulename','alpha')); $objectname=dol_sanitizeFileName(GETPOST('objectname','alpha')); // Security check +if (empty($conf->modulebuilder->enabled)) accessforbidden('ModuleBuilderNotAllowed'); if (! $user->admin && empty($conf->global->MODULEBUILDER_FOREVERYONE)) accessforbidden('ModuleBuilderNotAllowed'); @@ -373,6 +375,29 @@ if ($dirins && $action == 'generatepackage') } } +if ($action == 'savefile') +{ + $pathoftrigger=dol_buildpath($file, 0); + $pathoftriggerbackup=dol_buildpath($file.'.back', 0); + + dol_move($pathoftrigger, $pathoftriggerbackup, 0, 1, 0, 0); + + $content = GETPOST('triggerfilecontent'); + + // Save file on disk + $newmask = 0; + + file_put_contents($pathoftrigger, $content); + if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK; + if (empty($newmask)) // This should no happen + { + $newmask='0664'; + } + + @chmod($pathoftrigger, octdec($newmask)); +} + + /* * View @@ -568,7 +593,8 @@ elseif (! empty($module)) $modulelowercase=strtolower($module); - $modulestatusinfo=img_info('').' '.$langs->trans("ModuleIsNotActive"); + $urltomodulesetup=''.$langs->trans('Home').'-'.$langs->trans("Setup").'-'.$langs->trans("Modules").''; + $modulestatusinfo=img_info('').' '.$langs->trans("ModuleIsNotActive", $urltomodulesetup); if (! empty($conf->$module->enabled)) { $modulestatusinfo=img_warning().' '.$langs->trans("ModuleIsLive"); @@ -882,33 +908,62 @@ elseif (! empty($module)) $interfaces = new Interfaces($db); $triggers = $interfaces->getTriggersList(array('/'.strtolower($module).'/core/triggers')); - print '
'; - print ' - - - - - - '; - - $var=True; - foreach ($triggers as $trigger) + if ($action != 'editfile' || empty($file)) { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } + print '
'; + print '
'.$langs->trans("File").''.$langs->trans("Active").' 
'.$trigger['picto'].''.$trigger['relpath'].''.$trigger['status'].''; - $text=$trigger['info']; - $text.="
\n".$langs->trans("File").":
\n".$trigger['relpath']; - //$text.="\n".$langs->trans("ExternalModule",$trigger['isocreorexternal']); - print $form->textwithpicto('', $text); - print '
+ + + + + + + '; - print '
'.$langs->trans("File").''.$langs->trans("Active").'  
'; - print '
'; + $var=True; + foreach ($triggers as $trigger) + { + print ''; + print ''.$trigger['picto'].''; + print ''.$trigger['relpath'].''; + print ''.(empty($trigger['status'])?$langs->trans("No"):$trigger['status']).''; + print ''; + $text=$trigger['info']; + $text.="
\n".$langs->trans("File").":
\n".$trigger['relpath']; + //$text.="\n".$langs->trans("ExternalModule",$trigger['isocreorexternal']); + print $form->textwithpicto('', $text); + print ''; + print ''; + print ''.img_picto($langs->trans("Edit"), 'edit').''; + print ''; + print ''; + } + + print ''; + print ''; + } + else + { + $pathoftrigger=dol_buildpath($file, 0); + + $content = file_get_contents($pathoftrigger); + + // New module + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + $doleditor=new DolEditor('triggerfilecontent', $content, '', '600', 'Full', 'In', true, false, false, 0, '90%'); + print $doleditor->Create(1, '', false); + print '
'; + print ''; + print '
'; + + print '
'; + } } if ($tab == 'widgets') diff --git a/htdocs/modulebuilder/template/admin/about.php b/htdocs/modulebuilder/template/admin/about.php index 43194ad23e9..ac21d2810e0 100644 --- a/htdocs/modulebuilder/template/admin/about.php +++ b/htdocs/modulebuilder/template/admin/about.php @@ -1,5 +1,6 @@ + * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 79d761b3297..d32bd0a1723 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -1,5 +1,6 @@ + * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/htdocs/modulebuilder/template/class/MyObject.txt b/htdocs/modulebuilder/template/class/MyObject.txt index e86e7cdf5c6..35eb3529698 100644 --- a/htdocs/modulebuilder/template/class/MyObject.txt +++ b/htdocs/modulebuilder/template/class/MyObject.txt @@ -1,2 +1,2 @@ # DO NOT DELETE THIS FILE MANUALLY -# If this file exists, it means the class and file for object MyOjbect was generated by ModuleBuilder. Use ModuleBuilder if you want to delete object. \ No newline at end of file +# If this file exists, it means the class and file for object MyOjbect was generated by ModuleBuilder. So prefer to use ModuleBuilder if you want to delete object. \ No newline at end of file diff --git a/htdocs/modulebuilder/template/core/boxes/mybox.php b/htdocs/modulebuilder/template/core/boxes/mybox.php index a02d041130d..3b3fedcca08 100644 --- a/htdocs/modulebuilder/template/core/boxes/mybox.php +++ b/htdocs/modulebuilder/template/core/boxes/mybox.php @@ -1,5 +1,6 @@ + * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index a7bad8fb43c..33c52d58bea 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software; you can redistribute it and/or modify diff --git a/htdocs/modulebuilder/template/core/tpl/mytemplate.tpl.php b/htdocs/modulebuilder/template/core/tpl/mytemplate.tpl.php index 206494c50f9..9d399c44e85 100644 --- a/htdocs/modulebuilder/template/core/tpl/mytemplate.tpl.php +++ b/htdocs/modulebuilder/template/core/tpl/mytemplate.tpl.php @@ -1,6 +1,5 @@ - * Copyright (C) +/* Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php index 0140e1cc2b9..2db00687df5 100644 --- a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php +++ b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php @@ -1,6 +1,5 @@ - * Copyright (C) +/* Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 62739e2a0a1..6d0c76248f4 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2007-2017 Laurent Destailleur * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software; you can redistribute it and/or modify diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index a578a683131..2e655578235 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2007-2017 Laurent Destailleur * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software; you can redistribute it and/or modify diff --git a/htdocs/modulebuilder/template/scripts/myobject.php b/htdocs/modulebuilder/template/scripts/myobject.php index af381b0bfae..f83a808a0b9 100644 --- a/htdocs/modulebuilder/template/scripts/myobject.php +++ b/htdocs/modulebuilder/template/scripts/myobject.php @@ -1,6 +1,6 @@ #!/usr/bin/env php +/* Copyright (C) 2007-2017 Laurent Destailleur * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software; you can redistribute it and/or modify diff --git a/htdocs/modulebuilder/template/sql/data.sql b/htdocs/modulebuilder/template/sql/data.sql index 82266dc08b3..1bcc30cb1fd 100644 --- a/htdocs/modulebuilder/template/sql/data.sql +++ b/htdocs/modulebuilder/template/sql/data.sql @@ -1,5 +1,4 @@ --- --- Copyright (C) +-- Copyright (C) ---Put here your own copyright and developer email--- -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by diff --git a/htdocs/modulebuilder/template/test/phpunit/MyModuleFunctionalTest.php b/htdocs/modulebuilder/template/test/phpunit/MyModuleFunctionalTest.php index 41dc9891af7..547b48a32af 100644 --- a/htdocs/modulebuilder/template/test/phpunit/MyModuleFunctionalTest.php +++ b/htdocs/modulebuilder/template/test/phpunit/MyModuleFunctionalTest.php @@ -1,6 +1,6 @@ - * Copyright (C) +/* Copyright (C) 2007-2017 Laurent Destailleur + * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -83,7 +83,7 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase * Helper function to select links by href * * @param string $value Href - * @return mixed Helper string + * @return mixed Helper string */ protected function byHref($value) { diff --git a/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php b/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php index 37a65323fda..f2ea5b9934b 100644 --- a/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php +++ b/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php @@ -1,6 +1,6 @@ - * Copyright (C) +/* Copyright (C) 2007-2017 Laurent Destailleur + * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by