123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849 |
- <?php
- /* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
- *
- * 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
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /**
- * \file htdocs/website/index.php
- * \ingroup website
- * \brief Page to website view/edit
- */
- define('NOSCANPOSTFORINJECTION',1);
- define('NOSTYLECHECK',1);
- /**
- * Show HTML header HTML + BODY + Top menu + left menu + DIV
- *
- * @param string $head Optionnal head lines
- * @param string $title HTML title
- * @param string $help_url Url links to help page
- * Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage
- * For other external page: http://server/url
- * @param string $target Target to use on links
- * @param int $disablejs More content into html header
- * @param int $disablehead More content into html header
- * @param array $arrayofjs Array of complementary js files
- * @param array $arrayofcss Array of complementary css files
- * @param string $morequerystring Query string to add to the link "print" to get same parameters (use only if autodetect fails)
- * @return void
- */
- function llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='')
- {
- global $conf;
- // html header
- top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
- // top menu and left menu area
- if (empty($conf->dol_hide_topmenu))
- {
- top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss, $morequerystring, $help_url);
- }
- if (empty($conf->dol_hide_leftmenu))
- {
- left_menu('', $help_url, '', '', 1, $title, 1);
- }
- // main area
- //main_area($title);
- }
- require '../main.inc.php';
- require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
- require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
- require_once DOL_DOCUMENT_ROOT.'/websites/class/website.class.php';
- require_once DOL_DOCUMENT_ROOT.'/websites/class/websitepage.class.php';
- $langs->load("admin");
- $langs->load("other");
- $langs->load("website");
- if (! $user->admin) accessforbidden();
- $conf->dol_hide_leftmenu = 1;
- $error=0;
- $website=GETPOST('website', 'alpha');
- $page=GETPOST('page', 'alpha');
- $pageid=GETPOST('pageid', 'int');
- $action=GETPOST('action','alpha');
- if (GETPOST('delete')) { $action='delete'; }
- if (GETPOST('preview')) $action='preview';
- if (GETPOST('create')) { $action='create'; }
- if (GETPOST('editmedia')) { $action='editmedia'; }
- if (GETPOST('editcss')) { $action='editcss'; }
- if (GETPOST('editmenu')) { $action='editmenu'; }
- if (GETPOST('setashome')) { $action='setashome'; }
- if (GETPOST('editmeta')) { $action='editmeta'; }
- if (GETPOST('editcontent')) { $action='editcontent'; }
- if (empty($action)) $action='preview';
- $object=new Website($db);
- $objectpage=new WebsitePage($db);
- $object->fetchAll(); // Init $object->records
- // If website not defined, we take first found
- if (empty($website))
- {
- foreach($object->records as $key => $valwebsite)
- {
- $website=$valwebsite->ref;
- break;
- }
- }
- if ($website)
- {
- $res = $object->fetch(0, $website);
- }
- if ($pageid < 0) $pageid = 0;
- if ($pageid > 0 && $action != 'add')
- {
- $res = $objectpage->fetch($pageid);
- }
- global $dolibarr_main_data_root;
- $pathofwebsite=$dolibarr_main_data_root.'/websites/'.$website;
- $filecss=$pathofwebsite.'/styles.css';
- $filetpl=$pathofwebsite.'/page'.$pageid.'.tpl.php';
- // Define $urlwithroot
- $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
- $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
- //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
- /*
- * Actions
- */
- if (GETPOST('refreshsite')) $pageid=0; // If we change the site, we reset the pageid.
- // Add page
- if ($action == 'add')
- {
- $db->begin();
- $objectpage->fk_website = $object->id;
- $objectpage->title = GETPOST('WEBSITE_TITLE');
- $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME');
- $objectpage->description = GETPOST('WEBSITE_DESCRIPTION');
- $objectpage->keywords = GETPOST('WEBSITE_KEYWORD');
- if (empty($objectpage->title))
- {
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_PAGENAME")), null, 'errors');
- $error++;
- }
- if (! $error)
- {
- $res = $objectpage->create($user);
- if ($res <= 0)
- {
- $error++;
- setEventMessages($objectpage->error, $objectpage->errors, 'errors');
- }
- }
- if (! $error)
- {
- $db->commit();
- setEventMessages($langs->trans("PageAdded", $objectpage->pageurl), null, 'mesgs');
- $action='';
- }
- else
- {
- $db->rollback();
- }
- }
- // Update page
- if ($action == 'update')
- {
- $db->begin();
- $res = $object->fetch(0, $website);
- $objectpage->fk_website = $object->id;
- $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME');
- $res = $objectpage->fetch(0, $object->fk_website, $objectpage->pageurl);
- if ($res > 0)
- {
- $objectpage->title = GETPOST('WEBSITE_TITLE');
- $objectpage->description = GETPOST('WEBSITE_DESCRIPTION');
- $objectpage->keyword = GETPOST('WEBSITE_KEYWORD');
- $res = $objectpage->update($user);
- if (! $res > 0)
- {
- $error++;
- setEventMessages($objectpage->error, $objectpage->errors, 'errors');
- }
- if (! $error)
- {
- $db->commit();
- setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
- $action='';
- }
- else
- {
- $db->rollback();
- }
- }
- else
- {
- dol_print_error($db);
- }
- }
- // Update page
- if ($action == 'delete')
- {
- $db->begin();
- $res = $object->fetch(0, $website);
- $res = $objectpage->fetch($pageid, $object->fk_website);
- if ($res > 0)
- {
- $res = $objectpage->delete($user);
- if (! $res > 0)
- {
- $error++;
- setEventMessages($objectpage->error, $objectpage->errors, 'errors');
- }
- if (! $error)
- {
- $db->commit();
- setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $website), null, 'mesgs');
-
- header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website);
- exit;
- }
- else
- {
- $db->rollback();
- }
- }
- else
- {
- dol_print_error($db);
- }
- }
- // Update css
- if ($action == 'updatecss')
- {
- $db->begin();
- $res = $object->fetch(0, $website);
- /*
- $res = $object->update($user);
- if ($res > 0)
- {
- $db->commit();
- setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
- $action='';
- }
- else
- {
- $db->rollback();
- }*/
-
- $csscontent = GETPOST('WEBSITE_CSS_INLINE');
-
- dol_mkdir($pathofwebsite);
- file_put_contents($filecss, $csscontent);
- if (! empty($conf->global->MAIN_UMASK))
- @chmod($filecss, octdec($conf->global->MAIN_UMASK));
-
- $action='preview';
- }
- // Update page
- if ($action == 'setashome')
- {
- $db->begin();
- $object->fetch(0, $website);
- $object->fk_default_home = $pageid;
- $res = $object->update($user);
- if (! $res > 0)
- {
- $error++;
- setEventMessages($objectpage->error, $objectpage->errors, 'errors');
- }
-
- if (! $error)
- {
- $db->commit();
- setEventMessages($langs->trans("Saved"), null, 'mesgs');
- $action='preview';
- }
- else
- {
- $db->rollback();
- }
- }
- // Update page
- if ($action == 'updatemeta')
- {
- $db->begin();
- $object->fetch(0, $website);
- $objectpage->fk_website = $object->id;
- $res = $objectpage->fetch($pageid, $object->fk_website);
- if ($res > 0)
- {
- $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME');
- $objectpage->title = GETPOST('WEBSITE_TITLE');
- $objectpage->description = GETPOST('WEBSITE_DESCRIPTION');
- $objectpage->keywords = GETPOST('WEBSITE_KEYWORDS');
- $res = $objectpage->update($user);
- if (! $res > 0)
- {
- $error++;
- setEventMessages($objectpage->error, $objectpage->errors, 'errors');
- }
- if (! $error)
- {
- $db->commit();
- setEventMessages($langs->trans("Saved"), null, 'mesgs');
- $action='preview';
- }
- else
- {
- $db->rollback();
- }
- }
- else
- {
- dol_print_error($db, 'Page not found');
- }
- }
- // Update page
- if ($action == 'updatecontent')
- {
- $db->begin();
- $object->fetch(0, $website);
- $objectpage->fk_website = $object->id;
- $res = $objectpage->fetch($pageid, $object->fk_website);
- if ($res > 0)
- {
- $objectpage->content = GETPOST('PAGE_CONTENT');
- // Clean data. We remove all the head section.
- $objectpage->content = preg_replace('/<head.*<\/head>/s', '', $objectpage->content);
- /* $objectpage->content = preg_replace('/<base\s+href=[\'"][^\'"]+[\'"]\s/?>/s', '', $objectpage->content); */
-
- $res = $objectpage->update($user);
- if (! $res > 0)
- {
- $error++;
- setEventMessages($objectpage->error, $objectpage->errors, 'errors');
- }
- if (! $error)
- {
- $db->commit();
- setEventMessages($langs->trans("Saved"), null, 'mesgs');
-
- dol_mkdir($pathofwebsite);
- dol_delete_file($filetpl);
- file_put_contents($filetpl, $objectpage->content);
- if (! empty($conf->global->MAIN_UMASK))
- @chmod($filetpl, octdec($conf->global->MAIN_UMASK));
-
- header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid);
- exit;
- }
- else
- {
- $db->rollback();
- }
- }
- else
- {
- dol_print_error($db, 'Page not found');
- }
- }
- /*
- * View
- */
- $form = new Form($db);
- $help_url='';
- llxHeader('', $langs->trans("WebsiteSetup"), $help_url);
- print "\n".'<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
- print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
- if ($action == 'create')
- {
- print '<input type="hidden" name="action" value="add">';
- }
- if ($action == 'editcss')
- {
- print '<input type="hidden" name="action" value="updatecss">';
- }
- if ($action == 'editmenu')
- {
- print '<input type="hidden" name="action" value="updatemenu">';
- }
- if ($action == 'setashome')
- {
- print '<input type="hidden" name="action" value="updateashome">';
- }
- if ($action == 'editmeta')
- {
- print '<input type="hidden" name="action" value="updatemeta">';
- }
- if ($action == 'editcontent')
- {
- print '<input type="hidden" name="action" value="updatecontent">';
- }
- if ($action == 'edit')
- {
- print '<input type="hidden" name="action" value="update">';
- }
- // Add a margin under toolbar ?
- $style='';
- if ($action != 'preview' && $action != 'editcontent') $style=' margin-bottom: 5px;';
- print '<div class="centpercent websitebar">';
- if (count($object->records) > 0)
- {
- // ***** Part for web sites
-
- print '<div class="websiteselection">';
- print $langs->trans("Website").': ';
- print '</div>';
- // List of websites
- print '<div class="websiteselection">';
- $out='';
- $out.='<select name="website">';
- if (empty($object->records)) $out.='<option value="-1"> </option>';
- // Loop on each sites
- $i=0;
- foreach($object->records as $key => $valwebsite)
- {
- if (empty($website)) $website=$valwebsite->ref;
- $out.='<option value="'.$valwebsite->ref.'"';
- if ($website == $valwebsite->ref) $out.=' selected'; // To preselect a value
- $out.='>';
- $out.=$valwebsite->ref;
- $out.='</option>';
- $i++;
- }
- $out.='</select>';
- print $out;
- print '<input type="submit" class="button" name="refreshsite" value="'.$langs->trans("Load").'">';
- if ($website)
- {
- $realurl=$urlwithroot.'/public/websites/index.php?website='.$website;
- $dataroot=DOL_DATA_ROOT.'/websites/'.$website;
- if (! empty($object->virtualhost)) $realurl=$object->virtualhost;
- // TODO If virtual url defined, we use it
-
- /*print ' - '.$langs->trans("RealURL").' ';
- print '<input type="text" name="realurl" value="'.$realurl.'"> ';
- print '<a href="'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website.'" target="tab'.$website.'">'.$langs->trans("ViewSiteInNewTab").'</a>';*/
- print ' ';
- print $langs->trans("ViewWebsiteInProduction").': ';
- print '<input type="text" id="previewsiteurl" class="minwidth200imp" name="previewsite" value="'.$realurl.'">';
- //print '<input type="submit" class="button" name="previewwebsite" target="tab'.$website.'" value="'.$langs->trans("ViewSiteInNewTab").'">';
- $htmltext=$langs->trans("SetHereVirtualHost", $dataroot);
- print $form->textwithpicto('', $htmltext);
- print '<a class="button" id="previewsite" href="'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website.'" target="tab'.$website.'">'.$langs->trans("ViewSiteInNewTab").'</a>';
-
- // Example : Adding jquery code
- if (! empty($conf->use_javascript_ajax))
- {
- print '<script type="text/javascript" language="javascript">
- jQuery(document).ready(function() {
- jQuery("#previewsite").click(function() {
- newurl=jQuery("#previewsiteurl").val();
- console.log("Open url "+newurl);
- /* Save url */
- jQuery.ajax({
- method: "POST",
- url: "'.DOL_URL_ROOT.'/core/ajax/saveinplace.php",
- data: {
- field: \'editval_virtualhost\',
- element: \'websites\',
- table_element: \'website\',
- fk_element: '.$object->id.',
- value: newurl,
- },
- context: document.body
- });
- $(this).attr("href",newurl);
- });
- });
- </script>';
- }
- }
-
- print '</div>';
- // Button for websites
- print '<div class="websitetools">';
- if ($action == 'preview')
- {
- $disabled='';
- if (empty($user->rights->websites->create)) $disabled=' disabled="disabled"';
- //print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("MediaFiles")).'" name="editmedia">';
- print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditCss")).'" name="editcss">';
- print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditMenu")).'" name="editmenu">';
- print '<input type="submit"'.$disabled.' class="button" value="'.dol_escape_htmltag($langs->trans("AddPage")).'" name="create">';
- }
- if (in_array($action, array('editcss','editmenu','create')))
- {
- if ($action != 'preview') print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="preview">';
- if (preg_match('/^create/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
- if (preg_match('/^edit/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
- }
-
- print '</div>';
- // ***** Part for pages
-
- if ($website)
- {
- print '</div>';
- $array=$objectpage->fetchAll($object->id);
- if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors);
- $atleastonepage=(is_array($array) && count($array) > 0);
-
- print '<div class="centpercent websitebar"'.($style?' style="'.$style.'"':'').'">';
- print '<div class="websiteselection">';
- print $langs->trans("Page").': ';
- print '</div>';
- print '<div class="websiteselection">';
- $out='';
- $out.='<select name="pageid">';
- if ($atleastonepage)
- {
- if (empty($pageid) && $action != 'create') // 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.='<option value="'.$key.'"';
- if ($pageid > 0 && $pageid == $key) $out.=' selected'; // To preselect a value
- $out.='>';
- $out.=$valpage->title;
- if ($object->fk_default_home && $key == $object->fk_default_home) $out.=' ('.$langs->trans("HomePage").')';
- $out.='</option>';
- }
- }
- else $out.='<option value="-1"> </option>';
- $out.='</select>';
- print $out;
- print '<input type="submit" class="button" name="refreshpage" value="'.$langs->trans("Load").'"'.($atleastonepage?'':' disabled="disabled"').'>';
- print '<input type="submit" class="buttonDelete" name="delete" value="'.$langs->trans("Delete").'"'.($atleastonepage?'':' disabled="disabled"').'>';
- //print $form->selectarray('page', $array);
-
- if ($website && $pageid > 0)
- {
- print ' - '.$langs->trans("RealURL").' ';
- $realurl=$urlwithroot.'/public/websites/index.php?website='.$website.'&page='.$pageid;
- print '<input type="text" name="realurl" class="minwidth200imp" disabled="disabled" value="'.$realurl.'"> ';
- print '<a href="'.$realurl.'" class="button" target="tab'.$website.'">'.$langs->trans("ViewPageInNewTab").'</a>';
- //print '<input type="submit" class="button" name="previewpage" target="tab'.$website.'"value="'.$langs->trans("ViewPageInNewTab").'">';
- }
-
- print '</div>';
- print '<div class="websiteselection">';
- print '</div>';
- print '<div class="websitetools">';
- if ($action == 'preview')
- {
- $disabled='';
- if (empty($user->rights->websites->create)) $disabled=' disabled="disabled"';
- if ($pageid > 0)
- {
- if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) print '<input type="submit" class="button" disabled="disabled" value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">';
- else print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">';
- print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditPageMeta")).'" name="editmeta">';
- print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditPageContent")).'" name="editcontent">';
- //print '<a href="'.$_SERVER["PHP_SELF"].'?action=editmeta&website='.urlencode($website).'&pageid='.urlencode($pageid).'" class="button">'.dol_escape_htmltag($langs->trans("EditPageMeta")).'</a>';
- //print '<a href="'.$_SERVER["PHP_SELF"].'?action=editcontent&website='.urlencode($website).'&pageid='.urlencode($pageid).'" class="button">'.dol_escape_htmltag($langs->trans("EditPageContent")).'</a>';
- }
- }
-
- if (! in_array($action, array('editcss','editmenu','create')))
- {
- if ($action != 'preview') print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="preview">';
- if (preg_match('/^create/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
- if (preg_match('/^edit/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
- }
- print '</div>';
- }
- }
- else
- {
- print '<div class="websiteselection">';
- $langs->load("errors");
- print $langs->trans("ErrorModuleSetupNotComplete");
- print '<div>';
- $action='';
- }
- print '</div>';
- $head = array();
- /*
- * Edit mode
- */
- if ($action == 'editcss')
- {
- print '<div class="fiche">';
- print '<br>';
- $csscontent = @file_get_contents($filecss);
-
- dol_fiche_head();
- print '<table class="border" width="100%">';
- print '<tr><td>';
- print $langs->trans('WebSite');
- print '</td><td>';
- print $website;
- print '</td></tr>';
- print '<tr><td valign="top">';
- print $langs->trans('WEBSITE_CSS_INLINE');
- print '</td><td>';
- print '<textarea class="flat centpercent" rows="32" name="WEBSITE_CSS_INLINE">';
- print $csscontent;
- print '</textarea>';
- print '</td></tr>';
- /*print '<tr><td>';
- print $langs->trans('WEBSITE_CSS_URL');
- print '</td><td>';
- print '<input type="text" class="flat" size="96" name="WEBSITE_CSS_URL" value="'.dol_escape_htmltag($obj->WEBSITE_CSS_URL).'">';
- print '</td></tr>';*/
- print '</table>';
- dol_fiche_end();
- print '</div>';
- print '<br>';
- }
- if ($action == 'editmeta' || $action == 'create')
- {
- print '<div class="fiche">';
-
- print '<br>';
-
- dol_fiche_head();
-
- print '<table class="border" width="100%">';
-
- if ($action != 'create')
- {
- print '<tr><td>';
- print $langs->trans('WEBSITE_PAGEURL');
- print '</td><td>';
- print '/public/websites/index.php?website='.urlencode($website).'&pageid='.urlencode($pageid);
- print '</td></tr>';
- $pageurl=dol_escape_htmltag($objectpage->pageurl);
- $pagetitle=dol_escape_htmltag($objectpage->title);
- $pagedescription=dol_escape_htmltag($objectpage->description);
- $pagekeywords=dol_escape_htmltag($objectpage->keywords);
- }
- if (GETPOST('WEBSITE_PAGENAME')) $pageurl=GETPOST('WEBSITE_PAGENAME');
- if (GETPOST('WEBSITE_TITLE')) $pagetitle=GETPOST('WEBSITE_TITLE');
- if (GETPOST('WEBSITE_DESCRIPTION')) $pagedescription=GETPOST('WEBSITE_DESCRIPTION');
- if (GETPOST('WEBSITE_KEYWORDS')) $pagekeywords=GETPOST('WEBSITE_KEYWORDS');
- print '<tr><td>';
- print $langs->trans('WEBSITE_PAGENAME');
- print '</td><td>';
- print '<input type="text" class="flat" size="96" name="WEBSITE_PAGENAME" value="'.$pageurl.'">';
- print '</td></tr>';
-
- print '<tr><td>';
- print $langs->trans('WEBSITE_TITLE');
- print '</td><td>';
- print '<input type="text" class="flat" size="96" name="WEBSITE_TITLE" value="'.$pagetitle.'">';
- print '</td></tr>';
- print '<tr><td>';
- print $langs->trans('WEBSITE_DESCRIPTION');
- print '</td><td>';
- print '<input type="text" class="flat" size="96" name="WEBSITE_DESCRIPTION" value="'.$pagedescription.'">';
- print '</td></tr>';
- print '<tr><td>';
- print $langs->trans('WEBSITE_KEYWORDS');
- print '</td><td>';
- print '<input type="text" class="flat" size="128" name="WEBSITE_KEYWORDS" value="'.$pagekeywords.'">';
- print '</td></tr>';
- print '</table>';
- dol_fiche_end();
- print '</div>';
- print '<br>';
- }
- if ($action == 'editmedia')
- {
- print '<div class="center">'.$langs->trans("FeatureNotYetAvailable").'</center>';
- }
- if ($action == 'editmenu')
- {
- print '<div class="center">'.$langs->trans("FeatureNotYetAvailable").'</center>';
- }
- if ($action == 'editcontent')
- {
- /*
- * Editing global variables not related to a specific theme
- */
- require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
- $doleditor=new DolEditor('PAGE_CONTENT',$objectpage->content,'',500,'Full','',true,true,true,5,60);
- $doleditor->Create();
- }
- print '</form>';
- if ($action == 'preview')
- {
- if ($pageid > 0)
- {
- $objectpage->fetch($pageid);
- print "\n".'<!-- Page content '.$filetpl.' c-->'."\n";
-
- $csscontent = @file_get_contents($filecss);
-
- $out='';
-
- $out.='<div id="websitecontent" class="websitecontent">'."\n";
-
- $out.='<style scoped>'."\n"; // "scoped" means "apply to parent element only". Not yet supported by browsers
- $out.=$csscontent;
- $out.='</style>'."\n";
-
- $out.=$objectpage->content."\n";
-
- $out.='</div>';
-
- print $out;
-
- /*file_put_contents($filetpl, $out);
- if (! empty($conf->global->MAIN_UMASK))
- @chmod($filetpl, octdec($conf->global->MAIN_UMASK));
- // Output file on browser
- dol_syslog("index.php include $filetpl $filename content-type=$type");
- $original_file_osencoded=dol_osencode($filetpl); // New file name encoded in OS encoding charset
-
- // This test if file exists should be useless. We keep it to find bug more easily
- if (! file_exists($original_file_osencoded))
- {
- dol_print_error(0,$langs->trans("ErrorFileDoesNotExists",$original_file));
- exit;
- }
-
- //include_once $original_file_osencoded;
- */
-
- /*print '<iframe class="websiteiframenoborder centpercent" src="'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website.'&pageid='.$pageid.'"/>';
- print '</iframe>';*/
- }
- else
- {
- print '<br><br><div class="center">'.$langs->trans("PreviewOfSiteNotYetAvailable", $website).'</center><br><br><br>';
- print '<div class="center"><div class="logo_setup"></div></div>';
- }
- }
- llxFooter();
- $db->close();
|