* * 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 . */ /** * \file htdocs/collab/index.php * \ingroup collab * \brief Page to work on a shared document (PAD) */ define('NOSCANPOSTFORINJECTION',1); define('NOSTYLECHECK',1); require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // Load translation files required by the page $langs->loadLangs(array("admin","other","website")); if (! $user->admin) accessforbidden(); if (! ((GETPOST('testmenuhider','int') || ! empty($conf->global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))) { $conf->dol_hide_leftmenu = 1; // Force hide of left menu. } $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'; /* * Actions */ if (GETPOST('refreshsite')) $pageid=0; // If we change the site, we reset the pageid. if (GETPOST('refreshpage')) $action='preview'; // Add a collab page if ($action == 'add') { $db->begin(); $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(); } $action = 'preview'; $id = $objectpage->id; } // 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); } } /* * View */ $form = new Form($db); $help_url=''; llxHeader('', $langs->trans("WebsiteSetup"), $help_url, '', 0, '', '', '', '', '', ''."\n".'
'); print "\n".'
'; print ''; if ($action == 'create') { print ''; } // Add a margin under toolbar ? $style=''; if ($action != 'preview' && $action != 'editcontent') $style=' margin-bottom: 5px;'; //var_dump($objectpage);exit; print '
'; if (count($object->records) > 0) { // ***** Part for web sites print '
'; print $langs->trans("WebSite").': '; print '
'; // List of websites print '
'; $out=''; $out.=''; $out.=ajax_combobox('website'); print $out; print ''; if ($website) { $virtualurl=''; $dataroot=DOL_DATA_ROOT.'/collab/'.$website; if (! empty($object->virtualhost)) $virtualurl=$object->virtualhost; } if ($website && $action == 'preview') { $disabled=''; if (empty($user->rights->websites->write)) $disabled=' disabled="disabled"'; print '   '; //print ''; print ''; print ''; print ''; } print '
'; // Button for websites print '
'; if ($action == 'preview') { print '
'; print ''; //print ''; $htmltext=$langs->trans("SetHereVirtualHost", $dataroot); print $form->textwithpicto('', $htmltext); print '
'; $urlext=$virtualurl; $urlint=$urlwithroot.'/public/collab/index.php?website='.$website; //if (! empty($object->virtualhost)) //{ print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">'; print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); print ''; //} print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint)).'">'; print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot), 1, 'preview'); print ''; } if (in_array($action, array('editcss','editmenu','create'))) { if ($action != 'preview') print ''; if (preg_match('/^create/',$action)) print ''; if (preg_match('/^edit/',$action)) print ''; } print '
'; // ***** Part for pages if ($website) { print '
'; $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 '
'; print '
'; print $langs->trans("Page").': '; print '
'; print '
'; if ($action != 'add') { $out=''; $out.=''; $out.=ajax_combobox('pageid'); print $out; } else { print $langs->trans("New"); } print ''; //print $form->selectarray('page', $array); if ($action == 'preview') { $disabled=''; if (empty($user->rights->websites->write)) $disabled=' disabled="disabled"'; if ($pageid > 0) { print '   '; if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) print ''; else print ''; print ''; print ''; //print ''.dol_escape_htmltag($langs->trans("EditPageMeta")).''; //print ''.dol_escape_htmltag($langs->trans("EditPageContent")).''; print ''; } } print '
'; print '
'; print '
'; print '
'; if ($website && $pageid > 0 && $action == 'preview') { $websitepage = new WebSitePage($db); $websitepage->fetch($pageid); $realpage=$urlwithroot.'/public/collab/index.php?website='.$website.'&page='.$pageid; $pagealias = $websitepage->pageurl; print '
'; print ''; //print ''; $htmltext=$langs->trans("WEBSITE_PAGENAME", $pagealias); print $form->textwithpicto('', $htmltext); print '
'; if (! empty($object->virtualhost)) { $urlext=$virtualurl.'/'.$pagealias.'.php'; print 'transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext)).'">'; print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); print ''; } else { print ''; print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); print ''; } print 'transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage)).'">'; print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot), 1, 'preview'); print ''; // View page in new Tab //print ''; // TODO Add js to save alias like we save virtual host name and use dynamic virtual host for url of id=previewpageext } if (! in_array($action, array('editcss','editmenu','create'))) { if ($action != 'preview') print ''; if (preg_match('/^create/',$action)) print ''; if (preg_match('/^edit/',$action)) print ''; } print '
'; if ($action == 'preview') { // Adding jquery code to change on the fly url of preview ext if (! empty($conf->use_javascript_ajax)) { print ''; } } } } else { print '
'; $langs->load("errors"); print $langs->trans("ErrorModuleSetupNotComplete"); print '
'; $action=''; } print '
'; $head = array(); if ($action == 'editcontent') { /* * Editing global variables not related to a specific theme */ $csscontent = @file_get_contents($filecss); $contentforedit = ''; /*$contentforedit.=''."\n";*/ $contentforedit .= $objectpage->content; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor=new DolEditor('PAGE_CONTENT',$contentforedit,'',500,'Full','',true,true,true,ROWS_5,'90%'); $doleditor->Create(0, '', false); } print "
\n\n"; // End of page llxFooter(); $db->close();