diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index ec1da0b6dc1..a372bc5b865 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -66,7 +66,8 @@ class DolEditor * @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 - * @param array $poscursor Array for initial cursor position array('x'=>x, 'y'=>y) + * @param array $poscursor Array for initial cursor position array('x'=>x, 'y'=>y). + * array('find'=> 'word') can be used to go to line were the word has been found */ public function __construct($htmlname, $content, $width = '', $height = 200, $toolbarname = 'Basic', $toolbarlocation = 'In', $toolbarstartexpanded = false, $uselocalbrowser = 1, $okforextendededitor = true, $rows = 0, $cols = '', $readonly = 0, $poscursor = array()) { @@ -97,6 +98,19 @@ class DolEditor } //if ($conf->dol_use_jmobile) $this->tool = 'textarea'; // ckeditor and ace seems ok with mobile + if ( isset($poscursor['find']) ) { + $posy = 0; + $lines = explode("\n", $content); + $nblines = count($lines); + for ($i = 0 ; $i < $nblines ; $i++) { + if (preg_match('/'.$poscursor['find'].'/', $lines[$i])) { + $posy = $i; + break; + } + } + if ($posy != 0 ) $poscursor['y'] = $posy; + } + // Define some properties if (in_array($this->tool, array('textarea', 'ckeditor', 'ace'))) { if ($this->tool == 'ckeditor' && !dol_textishtml($content)) { // We force content to be into HTML if we are using an advanced editor if content is not HTML. diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 5494b3edc94..31975f8d97c 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -43,7 +43,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/utils.class.php'; // Load translation files required by the page -$langs->loadLangs(array("admin", "modulebuilder", "other", "cron", "errors")); +$langs->loadLangs(array("admin", "modulebuilder", "exports", "other", "cron", "errors")); // GET Parameters $action = GETPOST('action', 'aZ09'); @@ -71,6 +71,7 @@ if (empty($tabdic)) { $tabdic = 'newdicifnodic'; } $file = GETPOST('file', 'alpha'); +$find = GETPOST('find', 'alpha'); $modulename = dol_sanitizeFileName(GETPOST('modulename', 'alpha')); $objectname = dol_sanitizeFileName(GETPOST('objectname', 'alpha')); @@ -3492,7 +3493,7 @@ if ($module == 'initmodule') { print ''; print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; - print ''.img_picto($langs->trans("Edit"), 'edit').''; + print ''.img_picto($langs->trans("Edit"), 'edit').''; print ''; // List of setup pages @@ -3705,7 +3706,8 @@ if ($module == 'initmodule') { print dol_get_fiche_head($head2, $tab, '', -1, '', 0, '', '', 0, 'formodulesuffix'); - $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%', ''); + $posCursor = (empty($find)) ? array() : array('find'=>$find); + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%', 0, $posCursor); print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ? GETPOST('format', 'aZ09') : 'html')); print dol_get_fiche_end(); @@ -4740,7 +4742,7 @@ if ($module == 'initmodule') { print '
'; print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; if (is_array($dicts) && !empty($dicts)) { print ' '.$langs->trans("LanguageFile").' : '; @@ -5047,7 +5049,8 @@ if ($module == 'initmodule') { print ''; print ''; - $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + $posCursor = (empty($find)) ? array() : array('find'=>$find); + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%', 0, $posCursor); print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ? GETPOST('format', 'aZ09') : 'html')); print '
'; print '
'; @@ -5107,7 +5110,7 @@ if ($module == 'initmodule') { print '
'; print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print '
'; @@ -5481,7 +5484,8 @@ if ($module == 'initmodule') { print ''; print ''; - $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + $posCursor = (empty($find)) ? array() : array('find'=>$find); + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%', 0, $posCursor); print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ? GETPOST('format', 'aZ09') : 'html')); print '
'; print '
'; @@ -5541,7 +5545,7 @@ if ($module == 'initmodule') { print '
'; print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print '
'; @@ -5731,7 +5735,8 @@ if ($module == 'initmodule') { print ''; print ''; - $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + $posCursor = (empty($find)) ? array() : array('find'=>$find); + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%', 0, $posCursor); print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ? GETPOST('format', 'aZ09') : 'html')); print '
'; print '
'; @@ -5756,7 +5761,7 @@ if ($module == 'initmodule') { print ''; print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; print ''; - print ''.img_picto($langs->trans("Edit"), 'edit').''; + print ''.img_picto($langs->trans("Edit"), 'edit').''; print ''; print ''; @@ -5786,7 +5791,8 @@ if ($module == 'initmodule') { print ''; print ''; - $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + $posCursor = (empty($find)) ? array() : array('find'=>$find); + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%', 0, $posCursor); print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ? GETPOST('format', 'aZ09') : 'html')); print '
'; print '
'; @@ -5816,7 +5822,7 @@ if ($module == 'initmodule') { print ''; print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; print ''; - print ''.img_picto($langs->trans("Edit"), 'edit').''; + print ''.img_picto($langs->trans("Edit"), 'edit').''; print ''; if (!empty($triggers)) { @@ -5852,7 +5858,8 @@ if ($module == 'initmodule') { print ''; print ''; - $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + $posCursor = (empty($find)) ? array() : array('find'=>$find); + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%', 0, $posCursor); print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ? GETPOST('format', 'aZ09') : 'html')); print '
'; print '
'; @@ -6072,8 +6079,11 @@ if ($module == 'initmodule') { print ''.$langs->transnoentities('ImportExportProfiles').'
'; print '
'; - print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.$langs->trans("DescriptorFile").' ('.$langs->trans("ExportsArea").') : '.$pathtofile.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + print ' '.$langs->trans("DescriptorFile").' ('.$langs->trans("ImportArea").') : '.$pathtofile.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; } else { $fullpathoffile = dol_buildpath($file, 0); @@ -6088,7 +6098,8 @@ if ($module == 'initmodule') { print ''; print ''; - $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + $posCursor = (empty($find)) ? array() : array('find'=>$find); + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%', 0, $posCursor); print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ? GETPOST('format', 'aZ09') : 'html')); print '
'; print '
'; @@ -6192,7 +6203,7 @@ if ($module == 'initmodule') { print '
'; print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print '
'; @@ -6290,7 +6301,8 @@ if ($module == 'initmodule') { print ''; print ''; - $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + $posCursor = (empty($find)) ? array() : array('find'=>$find); + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%', 0, $posCursor); print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ? GETPOST('format', 'aZ09') : 'html')); print '
'; print '
'; @@ -6497,7 +6509,7 @@ if ($module == 'initmodule') { print '
'; print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print '
'; @@ -6593,7 +6605,8 @@ if ($module == 'initmodule') { print ''; print ''; - $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + $posCursor = (empty($find)) ? array() : array('find'=>$find); + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%', 0, $posCursor); print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ? GETPOST('format', 'aZ09') : 'html')); print '
'; print '
'; diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 5fcf3e4fe46..658f3cc5c44 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -64,6 +64,7 @@ class modMyModule extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleMyModuleName' not found (MyModule is name of module). $this->name = preg_replace('/^mod/i', '', get_class($this)); + // DESCRIPTION_FLAG // Module description, used if translation string 'ModuleMyModuleDesc' not found (MyModule is name of module). $this->description = "MyModuleDescription"; // Used only if file README.md and README-LL.md not found. @@ -117,6 +118,7 @@ class modMyModule extends DolibarrModules // '/mymodule/js/mymodule.js.php', ), // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context to 'all' + /* BEGIN MODULEBUILDER HOOKSCONTEXTS */ 'hooks' => array( // 'data' => array( // 'hookcontext1', @@ -124,6 +126,7 @@ class modMyModule extends DolibarrModules // ), // 'entity' => '0', ), + /* END MODULEBUILDER HOOKSCONTEXTS */ // Set this to 1 if features of module are opened to external users 'moduleforexternal' => 0, // Set this to 1 if the module provides a website template into doctemplates/websites/website_template-mytemplate @@ -180,7 +183,9 @@ class modMyModule extends DolibarrModules } // Array to add new pages in new tabs + /* BEGIN MODULEBUILDER TABS */ $this->tabs = array(); + /* END MODULEBUILDER TABS */ // Example: // To add a new tab identified by code tabname1 // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@mymodule:$user->hasRight('mymodule', 'read'):/mymodule/mynewtab1.php?id=__ID__'); @@ -210,6 +215,7 @@ class modMyModule extends DolibarrModules // 'thirdparty' to add a tab in third party view // 'user' to add a tab in user view + // Dictionaries /* Example: $this->dictionaries=array( @@ -303,12 +309,11 @@ class modMyModule extends DolibarrModules */ /* END MODULEBUILDER PERMISSIONS */ + // Main menu entries to add $this->menu = array(); $r = 0; - // Add here entries to declare new menus - /* BEGIN MODULEBUILDER TOPMENU */ $this->menu[$r++] = array( 'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode