';
- $label.= '
' . $langs->trans('Ref') . ': ' . $this->ref;
+ $label.= '
';
+ $label.= '
' . $langs->trans('Ref') . ': ' . $this->ref.'
';
+ $label.= '
' . $langs->trans('ID') . ': ' . $this->id.'
';
+ $label.= '
' . $langs->trans('Title') . ': ' . $this->title;
- $linkstart = '
';
+ $url = DOL_URL_ROOT.'/website/index.php?websiteid='.$this->fk_website.'&pageid='.$this->id;
+
+ $linkclose='';
+ if (empty($notooltip))
+ {
+ if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
+ {
+ $label=$langs->trans("ShowMyObject");
+ $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
+ }
+ $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
+ $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
+ }
+ else $linkclose = ($morecss?' class="'.$morecss.'"':'');
+
+ $linkstart = ' ';
$linkend=' ';
- $linkstart = $linkend = '';
+ //$linkstart = $linkend = '';
+
+ $result .= $linkstart;
+ if ($withpicto) $result.=img_picto(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
+ if ($withpicto != 2) $result.= $this->ref;
+ $result .= $linkend;
- if ($withpicto)
- {
- $result.=($linkstart.img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?'':'class="classfortooltip"')).$linkend);
- if ($withpicto != 2) $result.=' ';
- }
- $result.= $linkstart . $this->ref . $linkend;
return $result;
}
@@ -526,36 +545,20 @@ class WebsitePage extends CommonObject
// phpcs:enable
global $langs;
- if ($mode == 0)
+ if (empty($this->labelstatus) || empty($this->labelstatusshort))
{
- if ($status == 1) return $langs->trans('Enabled');
- elseif ($status == 0) return $langs->trans('Disabled');
- }
- elseif ($mode == 1)
- {
- if ($status == 1) return $langs->trans('Enabled');
- elseif ($status == 0) return $langs->trans('Disabled');
- }
- elseif ($mode == 2)
- {
- if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
- elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
- }
- elseif ($mode == 3)
- {
- if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4');
- elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5');
- }
- elseif ($mode == 4)
- {
- if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
- elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
- }
- elseif ($mode == 5)
- {
- if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
- elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
+ global $langs;
+ //$langs->load("mymodule");
+ $this->labelstatus[self::STATUS_DRAFT] = $langs->trans('Disabled');
+ $this->labelstatus[self::STATUS_VALIDATED] = $langs->trans('Enabled');
+ $this->labelstatusshort[self::STATUS_DRAFT] = $langs->trans('Disabled');
+ $this->labelstatusshort[self::STATUS_VALIDATED] = $langs->trans('Enabled');
}
+
+ $statusType = 'status5';
+ if ($status == self::STATUS_VALIDATED) $statusType = 'status4';
+
+ return dolGetStatus($this->labelstatus[$status], $this->labelstatusshort[$status], '', $statusType, $mode);
}
diff --git a/htdocs/website/index.php b/htdocs/website/index.php
index 56b3a0c8cb3..afc85a9c213 100644
--- a/htdocs/website/index.php
+++ b/htdocs/website/index.php
@@ -46,6 +46,7 @@ if (! $user->rights->website->read) accessforbidden();
$conf->dol_hide_leftmenu = 1; // Force hide of left menu.
$error=0;
+$websiteid=GETPOST('websiteid', 'int');
$websitekey=GETPOST('website', 'alpha');
$page=GETPOST('page', 'alpha');
$pageid=GETPOST('pageid', 'int');
@@ -101,7 +102,7 @@ $objectpage=new WebsitePage($db);
$object->fetchAll(); // Init $object->records with list of websites
// If website not defined, we take first found
-if (empty($websitekey))
+if (! ($websiteid > 0) && empty($websitekey))
{
foreach($object->records as $key => $valwebsite)
{
@@ -109,10 +110,12 @@ if (empty($websitekey))
break;
}
}
-if ($websitekey)
+if ($websiteid > 0 || $websitekey)
{
- $res = $object->fetch(0, $websitekey);
+ $res = $object->fetch($websiteid, $websitekey);
+ $websitekey = $object->ref;
}
+
$website = $object;
// Check pageid received as aprameter
@@ -418,7 +421,7 @@ if ($action == 'addcontainer')
$db->begin();
$objectpage->fk_website = $object->id;
- if (GETPOST('fetchexternalurl', 'alpha'))
+ if (GETPOSTISSET('fetchexternalurl'))
{
$urltograb=GETPOST('externalurl', 'alpha');
$grabimages=GETPOST('grabimages', 'alpha');
@@ -426,12 +429,18 @@ if ($action == 'addcontainer')
//var_dump($grabimages);exit;
}
- if ($urltograb)
+ if (GETPOSTISSET('fetchexternalurl'))
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
- //if (! preg_match('/^http/', $urltograb) && ! preg_match('/^file/', $urltograb))
- if (! preg_match('/^http/', $urltograb))
+ if (empty($urltograb))
+ {
+ $error++;
+ $langs->load("errors");
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("URL")), null, 'errors');
+ $action = 'createcontainer';
+ }
+ elseif (! preg_match('/^http/', $urltograb))
{
$error++;
$langs->load("errors");
@@ -1372,6 +1381,8 @@ if ($action == 'updatemeta')
$objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alpha');
$objectpage->lang = GETPOST('WEBSITE_LANG', 'aZ09');
$objectpage->htmlheader = trim(GETPOST('htmlheader', 'none'));
+ $objectpage->fk_page = GETPOST('pageidfortranslation', 'int');
+
$newdatecreation=dol_mktime(GETPOST('datecreationhour', 'int'), GETPOST('datecreationmin', 'int'), GETPOST('datecreationsec', 'int'), GETPOST('datecreationmonth', 'int'), GETPOST('datecreationday', 'int'), GETPOST('datecreationyear', 'int'));
if ($newdatecreation) $objectpage->date_creation = $newdatecreation;
@@ -2006,6 +2017,7 @@ if (! GETPOST('hide_websitemenu'))
if ($object->id > 0)
{
$array=$objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl');
+ $object->lines = $array;
}
if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors);
$atleastonepage=(is_array($array) && count($array) > 0);
@@ -2019,13 +2031,13 @@ if (! GETPOST('hide_websitemenu'))
print '
';
- if (! $atleastonepage)
+ if ($atleastonepage)
{
- print '
';
+ print '
';
}
else
{
- print '
';
+ print '
';
}
//print '
';
@@ -2137,55 +2149,11 @@ if (! GETPOST('hide_websitemenu'))
print '
';
print '';
- print '
';
+ //print '';
if ($action != 'addcontainer')
{
- $out='';
- if ($atleastonepage && $action != 'editsource')
- {
- $out.='';
- }
- else
- {
- $out.='';
- }
- if ($atleastonepage)
- {
- if (empty($pageid) && $action != 'createcontainer') // Page id is not defined, we try to take one
- {
- $firstpageid=0;$homepageid=0;
- foreach($array as $key => $valpage)
- {
- if (empty($firstpageid)) $firstpageid=$valpage->id;
- if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid=$valpage->id;
- }
- $pageid=$homepageid?$homepageid:$firstpageid; // We choose home page and if not defined yet, we take first page
- }
-
- foreach($array as $key => $valpage)
- {
- $out.=' 0 && $pageid == $key) $out.=' selected'; // To preselect a value
- $out.='>';
- $out.='['.$valpage->type_container.' '.sprintf("%03d", $valpage->id).'] ';
- $out.=$valpage->pageurl.' - '.$valpage->title;
- if ($object->fk_default_home && $key == $object->fk_default_home) $out.=' ('.$langs->trans("HomePage").')';
- $out.=' ';
- }
- }
- else $out.=' ';
- $out.=' ';
- if ($atleastonepage && $action != 'editsource')
- {
- $out.=ajax_combobox('pageid');
- }
- else
- {
- $out.=' ';
- $out.=ajax_combobox('pageid');
- }
- print $out;
+ print $formwebsite->selectContainer($website, 'pageid', $pageid, 0, $action);
}
else
{
@@ -2298,7 +2266,7 @@ if (! GETPOST('hide_websitemenu'))
print ''."\n";
print '';
- print '
';
+ print '
';
print '
'."\n";
print ''."\n";
@@ -2351,23 +2319,23 @@ if (! GETPOST('hide_websitemenu'))
if ($websitepage->grabbed_from)
{
//print ' ';
- print ''.img_picto($langs->trans("OnlyEditionOfSourceForGrabbedContent"), 'switch_off', '', false, 0, 0, '', 'nomarginleft').' ';
+ print ''.img_picto($langs->trans("OnlyEditionOfSourceForGrabbedContent"), 'switch_off', '', false, 0, 0, '', 'nomarginleft').' ';
}
else
{
//print ' ';
if (empty($conf->global->WEBSITE_EDITINLINE))
{
- print 'ref.'&pageid='.$websitepage->id.'&action=seteditinline">'.img_picto($langs->trans("EditInLineOnOff", $langs->transnoentitiesnoconv("Off")), 'switch_off', '', false, 0, 0, '', 'nomarginleft').' ';
+ print 'ref.'&pageid='.$websitepage->id.'&action=seteditinline">'.img_picto($langs->trans("EditInLineOnOff", $langs->transnoentitiesnoconv("Off")), 'switch_off', '', false, 0, 0, '', 'nomarginleft').' ';
}
else
{
- print 'ref.'&pageid='.$websitepage->id.'&action=unseteditinline">'.img_picto($langs->trans("EditInLineOnOff", $langs->transnoentitiesnoconv("On")), 'switch_on', '', false, 0, 0, '', 'nomarginleft').' ';
+ print 'ref.'&pageid='.$websitepage->id.'&action=unseteditinline">'.img_picto($langs->trans("EditInLineOnOff", $langs->transnoentitiesnoconv("On")), 'switch_on', '', false, 0, 0, '', 'nomarginleft').' ';
}
}
print ' ';
- print '
';
+ print '
';
print $langs->trans("ShowSubcontainers");
/*if ($websitepage->grabbed_from)
{
@@ -2377,11 +2345,11 @@ if (! GETPOST('hide_websitemenu'))
{*/
if (empty($conf->global->WEBSITE_SUBCONTAINERSINLINE))
{
- print '
ref.'&pageid='.$websitepage->id.'&action=setshowsubcontainers">'.img_picto($langs->trans("ShowSubContainersOnOff", $langs->transnoentitiesnoconv("Off")), 'switch_off', '', false, 0, 0, '', 'nomarginleft').' ';
+ print '
ref.'&pageid='.$websitepage->id.'&action=setshowsubcontainers">'.img_picto($langs->trans("ShowSubContainersOnOff", $langs->transnoentitiesnoconv("Off")), 'switch_off', '', false, 0, 0, '', 'nomarginleft').' ';
}
else
{
- print '
ref.'&pageid='.$websitepage->id.'&action=unsetshowsubcontainers">'.img_picto($langs->trans("ShowSubContainersOnOff", $langs->transnoentitiesnoconv("On")), 'switch_on', '', false, 0, 0, '', 'nomarginleft').' ';
+ print '
ref.'&pageid='.$websitepage->id.'&action=unsetshowsubcontainers">'.img_picto($langs->trans("ShowSubContainersOnOff", $langs->transnoentitiesnoconv("On")), 'switch_on', '', false, 0, 0, '', 'nomarginleft').' ';
}
/*}*/
print '
';
@@ -2405,7 +2373,7 @@ if (! GETPOST('hide_websitemenu'))
}
}
- print ''; // end website selection
+ //print ''; // end website selection
print '
';
@@ -2888,12 +2856,24 @@ if ($action == 'editmeta' || $action == 'createcontainer')
print ''."\n";
//print '';
+ $hiddenfromfetchingafterload = ' hideobject';
+ $hiddenmanuallyafterload = ' hideobject';
+ if (GETPOST('radiocreatefrom') == 'checkboxcreatefromfetching') $hiddenfromfetchingafterload = '';
+ if (GETPOST('radiocreatefrom') == 'checkboxcreatemanually') $hiddenmanuallyafterload = '';
+
+ if ($action == 'editmeta' || empty($conf->use_javascript_ajax)) { // No autohide/show in such case
+ $hiddenfromfetchingafterload='';
+ $hiddenmanuallyafterload='';
+ }
+
if ($action == 'createcontainer')
{
print '
';
- print ' * '.$langs->trans("CreateByFetchingExternalPage").'
';
- print '
';
+ if (! empty($conf->use_javascript_ajax)) print ' ';
+ print ''.$langs->trans("CreateByFetchingExternalPage").' ';
+ print ' ';
+ print '';
print '';
print $langs->trans("URL");
print ' ';
@@ -2911,10 +2891,12 @@ if ($action == 'editmeta' || $action == 'createcontainer')
print ' ';
- print ' * '.$langs->trans("OrEnterPageInfoManually").' ';
+ if (! empty($conf->use_javascript_ajax)) print ' ';
+ print ''.$langs->trans("OrEnterPageInfoManually").' ';
+ print ' ';
}
- print '';
+ print '';
if ($action != 'createcontainer')
{
@@ -2928,16 +2910,9 @@ if ($action == 'editmeta' || $action == 'createcontainer')
print $langs->trans('InternalURLOfPage');
print '';
print '/public/website/index.php?website='.urlencode($websitekey).'&pageid='.urlencode($pageid);
+ //if ($objectpage->grabbed_from) print ' - '.$langs->trans('InitiallyGrabbedFrom').' '.$objectpage->grabbed_from.' ';
print ' ';
- /*
- print '';
- print $langs->trans('InitiallyGrabbedFrom');
- print ' ';
- print $objectpage->grabbed_from;
- print ' ';
- */
-
$type_container=$objectpage->type_container;
$pageurl=$objectpage->pageurl;
$pagealiasalt=$objectpage->aliasalt;
@@ -2972,7 +2947,7 @@ if ($action == 'editmeta' || $action == 'createcontainer')
print '';
print $langs->trans('WEBSITE_TITLE');
print ' ';
- print ' ';
+ print ' ';
print ' ';
// Alias
@@ -3023,26 +2998,28 @@ if ($action == 'editmeta' || $action == 'createcontainer')
print $formadmin->select_language($pagelang?$pagelang:$langs->defaultlang, 'WEBSITE_LANG', 0, null, '1');
print '';
+ // Translation of
+ $translationof=0;
+ print '';
+ print $langs->trans('TranslationLinks');
+ print ' ';
+ if ($action == 'editmeta' || $action == 'createcontainer' || $objectpage->fk_page > 0)
+ {
+ $sourcepage=new WebsitePage($db);
+ $result = $sourcepage->fetch($objectpage->fk_page);
+ if ($result == 0)
+ {
+ // not found, we can reset value to clean database
+ }
+ elseif ($result > 0)
+ {
+ $translationof = $sourcepage->id;
+ print ''.$langs->trans('ThisPageIsTranslationOf').' ';
+ print $formwebsite->selectContainer($website, 'pageidfortranslation', $sourcepage->id, 1, $action);
+ }
+ }
if ($action != 'createcontainer')
{
- // Translation of
- if ($objectpage->fk_page > 0)
- {
- print ' ';
- print $langs->trans('ThisPageIsTranslationOf');
- print ' ';
- $sourcepage=new WebsitePage($db);
- $result = $sourcepage->fetch($objectpage->fk_page);
- if ($result == 0) // not found, we can reset value
- {
- }
- elseif ($result > 0)
- {
- print $sourcepage->getNomUrl(1);
- }
- print ' ';
- }
-
// Has translation pages
$sql='SELECT rowid, lang from '.MAIN_DB_PREFIX.'website_page where fk_page = '.$objectpage->id;
$resql = $db->query($sql);
@@ -3051,9 +3028,8 @@ if ($action == 'editmeta' || $action == 'createcontainer')
$num_rows = $db->num_rows($resql);
if ($num_rows > 0)
{
- print '';
- print $langs->trans('ThisPageHasTranslationPages');
- print ' ';
+ if ($translationof) print ' ';
+ print ''.$langs->trans('ThisPageHasTranslationPages').': ';
$i=0;
while ($obj = $db->fetch_object($resql))
{
@@ -3063,11 +3039,11 @@ if ($action == 'editmeta' || $action == 'createcontainer')
print $tmppage->getNomUrl(1).' ('.$tmppage->lang.')';
$i++;
}
- print ' ';
}
}
else dol_print_error($db);
}
+ print '';
print '';
$htmlhelp=$langs->trans("WEBSITE_ALIASALTDesc");
@@ -3127,7 +3103,7 @@ if ($action == 'editmeta' || $action == 'createcontainer')
print '
';
if ($action == 'createcontainer')
{
- print '