QUAL add hook printWebsitePageContent (#39576)
* FIX avoid php warnings (#39556) * Fix help * Doc * FIX: Broken feature 'Generate Child Mo' (#39560) * Fix broken 'Generate Child Mo' * Fix phan * QUAL add hook printWebsitePageContent --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr> Co-authored-by: Francis Appels <francis.appels@yahoo.com>
This commit is contained in:
parent
994d8c5ead
commit
950628b540
4 changed files with 32 additions and 2 deletions
|
|
@ -443,6 +443,18 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage,
|
||||||
$tplcontent .= '$tmp = preg_replace("/__SEO_CANONICAL_LANG__/", (defined("__SEO_PAGE_LANG__") ? preg_replace(\'/\[_-\].*$/\', "", constant("__SEO_PAGE_LANG__")) : (empty($weblangs->shortlang) ? "'.$tmpshortlangcode.'" : $weblangs->shortlang)), $tmp);'."\n";
|
$tplcontent .= '$tmp = preg_replace("/__SEO_CANONICAL_LANG__/", (defined("__SEO_PAGE_LANG__") ? preg_replace(\'/\[_-\].*$/\', "", constant("__SEO_PAGE_LANG__")) : (empty($weblangs->shortlang) ? "'.$tmpshortlangcode.'" : $weblangs->shortlang)), $tmp);'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Let modules rewrite the final page content (e.g. canonical/hreflang links, when a module
|
||||||
|
// implements its own URL rewriting scheme that core has no knowledge of). Runs on every
|
||||||
|
// request (not only at page compile time), so it applies no matter which code path last
|
||||||
|
// recompiled this page (website editor, inline AJAX edit, a module's own template reset...).
|
||||||
|
$tplcontent .= "// Let modules rewrite the final page content (hook)\n";
|
||||||
|
$tplcontent .= 'global $hookmanager;'."\n";
|
||||||
|
$tplcontent .= 'if (is_object($hookmanager)) {'."\n";
|
||||||
|
$tplcontent .= ' $hookmanager->initHooks(array(\'websitepagecontent\'));'."\n";
|
||||||
|
$tplcontent .= ' $parameters = array(\'tmp\' => &$tmp);'."\n";
|
||||||
|
$tplcontent .= ' $hookmanager->executeHooks(\'printWebsitePageContent\', $parameters, $websitepage);'."\n";
|
||||||
|
$tplcontent .= '}'."\n";
|
||||||
|
|
||||||
$tplcontent .= "// Now output the generated page content\n";
|
$tplcontent .= "// Now output the generated page content\n";
|
||||||
$tplcontent .= 'dolWebsiteOutput($tmp, "html", '.((int) $objectpage->id).'); dolWebsiteIncrementCounter('.((int) $object->id).', "'.$objectpage->type_container.'", '.((int) $objectpage->id).');'."\n";
|
$tplcontent .= 'dolWebsiteOutput($tmp, "html", '.((int) $objectpage->id).'); dolWebsiteIncrementCounter('.((int) $object->id).', "'.$objectpage->type_container.'", '.((int) $objectpage->id).');'."\n";
|
||||||
$tplcontent .= "// END PHP ?>\n";
|
$tplcontent .= "// END PHP ?>\n";
|
||||||
|
|
|
||||||
|
|
@ -273,6 +273,14 @@ class Mo extends CommonObject
|
||||||
*/
|
*/
|
||||||
public $tpl = array();
|
public $tpl = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int[] Ids of BOM lines (with a sub-BOM) that must not be flattened into their raw materials
|
||||||
|
* when generating the consume/produce lines, because the user asked to generate a child MO
|
||||||
|
* for them instead (see mo_card.php "Generate Child MO"). A single MoLine anchored on the
|
||||||
|
* sub-assembly product is created for these lines instead of recursing into the sub-BOM.
|
||||||
|
*/
|
||||||
|
public $noFlattenBomLineIds = array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
|
@ -815,7 +823,7 @@ class Mo extends CommonObject
|
||||||
|
|
||||||
$tmpproduct = new Product($this->db);
|
$tmpproduct = new Product($this->db);
|
||||||
$tmpproduct->fetch($line->fk_product);
|
$tmpproduct->fetch($line->fk_product);
|
||||||
if ($line->fk_bom_child > 0) {
|
if ($line->fk_bom_child > 0 && !in_array($line->id, $this->noFlattenBomLineIds)) {
|
||||||
$bom = new BOM($this->db);
|
$bom = new BOM($this->db);
|
||||||
$bom->fetch((int) $line->fk_bom_child);
|
$bom->fetch((int) $line->fk_bom_child);
|
||||||
$error += $this->processBOM($user, $role, $bom, $quantity_line);
|
$error += $this->processBOM($user, $role, $bom, $quantity_line);
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,10 @@ if (empty($reshook)) {
|
||||||
// Create MO with Children
|
// Create MO with Children
|
||||||
if ($action == 'add' && empty($id) && !empty($TBomLineId) && $permissiontoadd) {
|
if ($action == 'add' && empty($id) && !empty($TBomLineId) && $permissiontoadd) {
|
||||||
$noback = 1;
|
$noback = 1;
|
||||||
|
// Sub-BOM lines the user checked "Generate Child MO" for must not be flattened into their
|
||||||
|
// raw materials on the parent MO: keep a single consume line anchored on the sub-assembly
|
||||||
|
// product instead, so it can be found below to create the child MO.
|
||||||
|
$object->noFlattenBomLineIds = array_map('intval', $TBomLineId);
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
|
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
|
||||||
|
|
||||||
$mo_parent = $object;
|
$mo_parent = $object;
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice2.lib.php';
|
||||||
* @var DoliDB $db
|
* @var DoliDB $db
|
||||||
* @var HookManager $hookmanager
|
* @var HookManager $hookmanager
|
||||||
* @var Translate $langs
|
* @var Translate $langs
|
||||||
|
*
|
||||||
|
* @var int $dolibarr_main_db_readonly
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Load main language strings
|
// Load main language strings
|
||||||
|
|
@ -306,7 +308,11 @@ function rebuild_merge_pdf_usage()
|
||||||
print "To exclude deposit invoices, use filter=nodeposit\n";
|
print "To exclude deposit invoices, use filter=nodeposit\n";
|
||||||
print "To exclude some thirdparties, use filter=excludethirdparties id1,id2...\n";
|
print "To exclude some thirdparties, use filter=excludethirdparties id1,id2...\n";
|
||||||
print "To limit to some thirdparties, use filter=onlythirdparties id1,id2...\n";
|
print "To limit to some thirdparties, use filter=onlythirdparties id1,id2...\n";
|
||||||
print "To regenerate existing PDF, use regenerate=templatename or regeneratenomerge=templatename\n";
|
print "\n";
|
||||||
|
print "To regenerate existing PDF before merge, use regenerate=templatename\n";
|
||||||
|
print "To regenerate existing PDF with no merge (regenerate only), use regeneratenomerge=templatename\n";
|
||||||
|
print "To merge by reusing existing PDF (generation only for non already existing PDF), use regenerate=no or nothing\n";
|
||||||
|
print "\n";
|
||||||
print "To generate documents in a given language, use lang=xx_XX\n";
|
print "To generate documents in a given language, use lang=xx_XX\n";
|
||||||
print "To set prefix of generated file name, use prefix=myfileprefix\n";
|
print "To set prefix of generated file name, use prefix=myfileprefix\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue