mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Work on the edit inline tool.
This commit is contained in:
parent
10a3e773ce
commit
0818571827
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
|
||||
/**
|
||||
* Convert a page content to have correct links (based on DOL_URL_ROOT) into an html content.
|
||||
* Convert a page content to have correct links (based on DOL_URL_ROOT) into an html content. It replaces also dynamic content with '...php...'
|
||||
* Used to ouput the page on the Preview from backoffice.
|
||||
*
|
||||
* @param Website $website Web site object
|
||||
|
|
@ -61,7 +61,7 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0, $c
|
|||
$content = preg_replace('/href="<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
|
||||
|
||||
//$replacewith='<span class="phptag">...php...</span>';
|
||||
$replacewith='<span class="phptag">...php...</span>';
|
||||
$replacewith='...phpx...';
|
||||
if ($removephppart) $replacewith='';
|
||||
//$content = preg_replace('/<\?php((?!\?toremove>).)*\?toremove>\n*/ims', $replacewith, $content);
|
||||
/*if ($content === null) {
|
||||
|
|
@ -127,14 +127,15 @@ function dolStripPhpCode($str, $replacewith = '')
|
|||
$newstr .= $part;
|
||||
continue;
|
||||
}
|
||||
//split on closing tag
|
||||
// The second part is the php code. We split on closing tag
|
||||
$partlings = explode('?>', $part);
|
||||
if (!empty($partlings))
|
||||
{
|
||||
$phppart = $partlings[0];
|
||||
//remove content before closing tag
|
||||
if (count($partlings) > 1) $partlings[0] = '';
|
||||
if (count($partlings) > 1) $partlings[0] = ''; // Todo why a count > 1 and not >= 1 ?
|
||||
//append to out string
|
||||
$newstr .= $replacewith.implode('', $partlings);
|
||||
$newstr .= '<span class="phptag">'.$replacewith.'<!-- '.$phppart.' --></span>'.implode('', $partlings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1441,6 +1441,9 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr
|
|||
print 'var ckeditorFilebrowserImageBrowseUrl = \''.DOL_URL_ROOT.'/core/filemanagerdol/browser/default/browser.php?Type=Image&Connector='.DOL_URL_ROOT.'/core/filemanagerdol/connectors/php/connector.php\';'."\n";
|
||||
print '</script>'."\n";
|
||||
print '<script src="'.$pathckeditor.$jsckeditor.($ext?'?'.$ext:'').'"></script>'."\n";
|
||||
print '<script>';
|
||||
print 'CKEDITOR.disableAutoInline = true;'."\n";
|
||||
print '</script>'."\n";
|
||||
}
|
||||
|
||||
// Browser notifications
|
||||
|
|
|
|||
|
|
@ -2199,7 +2199,53 @@ if (! GETPOST('hide_websitemenu'))
|
|||
print '<!-- button EditInLine and ShowSubcontainers -->'."\n";
|
||||
print '<div class="websiteselectionsection inline-block">';
|
||||
print '<div class="inline-block">';
|
||||
|
||||
print '<span id="switchckeditorinline">';
|
||||
print '<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
var isEditingEnabled = '.($conf->global->WEBSITE_EDITINLINE?'true':'false').';
|
||||
if (isEditingEnabled)
|
||||
{
|
||||
switchEditorOnline(true);
|
||||
}
|
||||
|
||||
$( "#switchckeditorinline" ).click(function() {
|
||||
switchEditorOnline();
|
||||
});
|
||||
|
||||
function switchEditorOnline(forceenable)
|
||||
{
|
||||
if (! isEditingEnabled || forceenable)
|
||||
{
|
||||
console.log("Enable inline edit");
|
||||
jQuery(\'section[contenteditable="true"]\').each(function(idx){
|
||||
var idtouse = $(this).attr(\'id\');
|
||||
console.log("Enable inline edit for "+idtouse);
|
||||
CKEDITOR.inline(idtouse, {
|
||||
// Allow some non-standard markup that we used in the introduction.
|
||||
extraAllowedContent: \'span(*);cite(*);q(*);dl(*);dt(*);dd(*);ul(*);li(*);header(*);button(*);h1(*);h2(*);\',
|
||||
removePlugins: \'stylescombo\',
|
||||
// Show toolbar on startup (optional).
|
||||
// startupFocus: true
|
||||
});
|
||||
})
|
||||
|
||||
isEditingEnabled = true;
|
||||
}
|
||||
else {
|
||||
console.log("Disable inline edit");
|
||||
for(name in CKEDITOR.instances)
|
||||
{
|
||||
CKEDITOR.instances[name].destroy(true);
|
||||
}
|
||||
isEditingEnabled = false;
|
||||
}
|
||||
};
|
||||
});
|
||||
</script>';
|
||||
print $langs->trans("EditInLine");
|
||||
print '</span>';
|
||||
|
||||
if ($websitepage->grabbed_from)
|
||||
{
|
||||
//print '<input type="submit" class="button nobordertransp" disabled="disabled" title="'.dol_escape_htmltag($langs->trans("OnlyEditionOfSourceForGrabbedContent")).'" value="'.dol_escape_htmltag($langs->trans("EditWithEditor")).'" name="editcontent">';
|
||||
|
|
@ -2217,6 +2263,7 @@ if (! GETPOST('hide_websitemenu'))
|
|||
print '<a class="button nobordertransp nohoverborder"'.$disabled.' href="'.$_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$websitepage->id.'&action=unseteditinline">'.img_picto($langs->trans("EditInLineOn"), 'switch_on', '', false, 0, 0, '', 'nomarginleft').'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
print '<div class="inline-block">';
|
||||
print $langs->trans("ShowSubcontainers");
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user