* @package WB
* @subpackage setup
*/
/**
* make wombat site
*
* @author gERD Schaufelberger
This tool helps setting up a new web site based on the Wombat framework.
Flush session data to start from scratch.
In order to insert media files like photos, videos and PDF-documents
into any CMS-page, those file need to be hosted on the web-server. VFS
manages those files, transcode them to other formats and keeps them in order.
Basic VFS files are installed. Maybe you want to add some cron-jobs etc.
Wombat's XML based CMS uses the multilanguage editor to maintain CMS
articles.
All files to use WXML CMS are installed. Use "Wxml" as
processor in page definitions or simply use patTemplate:wxml-tag in
any template file.
Many features of Wombat require authorized user sessions.
The component User_Login allows to login, register, change password etc.
Use "User_Login" as processor in page definition.
Change event configuration accordingly. Also ment templates and forms and
probably table columns.
Manage your site's uses with the comfortable out-of-the-box
User_Manager component.
Use "User_Manager" as processor in page definition.
Change event configuration accordingly. Also ment templates and forms and
probably table columns.
Many features of Wombat are database driven. Therefore, Wombat requires
access to a MySQL database and a set of tables.
CREATE DATABASE `$dbdb` DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; GRANT USAGE ON *.* TO `$dbuser`@`$dbhost`; SET PASSWORD FOR `$dbuser`@`$dbhost` = password("$dbpassword"); GRANT ALL PRIVILEGES ON `$dbdb`.* TO `$dbuser`@`$dbhost`;EOF; return; } // write database config $config = file_get_contents($this->base . '/etc-default/config.xml'); $db = <<
Create all basic files and folders in BASEDIR to use it as Wombat-based web-site. A proper set up BASEDIR is essential for any Wombat site.
EOF; return; } echo <<Please check ownership and permissions of your files in BASEDIR. It is recommended to set all files to read-only. Still, the web-server needs write access to "var" and subfolders. Hence it's probably a good idea to change owner and permissions:
sudo chown -R USER:GROUP $base chmod -R go-w $base chmod -R go+w $base/varEOF; // etc/wbLoader.php if (file_exists($base . '/etc/wbLoader.php')) { $this->addMsg('Create wbLoader Helper skipped, file exists', self::SEVERITY_WARN); } else { $this->addMsg('Create wbLoader Helper'); $file = array('system . '\';'; $file[] = '?>'; $file[] = ''; $file = implode("\n", $file); file_put_contents($base . '/etc/wbLoader.php', $file); } // etc/config.php if (file_exists($base . '/etc/config.php')) { $this->addMsg('Create optional config.php skipped, file exists', self::SEVERITY_WARN); } else { $this->addMsg('Create optional config.php'); $file = array(''; $file[] = ''; $file = implode("\n", $file); file_put_contents($base . '/etc/config.php', $file); } $this->printMsg(); } private function setBaseDir() { if ('mkbasedir' == $this->post['action']) { //$this->session['basedir'] = ''; $this->mkBaseDir(); } if (!isset($this->session['basedir']) || empty($this->session['basedir'])) { if ('welcome' != $this->post['action']) { $this->post['action'] = 'mkbasedir'; } return; } $this->base = $this->session['basedir']; if (!is_dir($this->base) || !is_writable($this->base)) { $this->addMsg( 'BASEDIR does not exist or is not writable' , self::SEVERITY_ERROR); } } private function mkBaseDir() { $base = realpath( $this->system . '/..'); if (!isset($this->post['basedir']) || empty($this->post['basedir'])) { $this->post['basedir'] = $base; return; } if (rtrim($this->post['basedir'], '/') == $base) { $this->addMsg('BASEDIR must not be the parent folder of Wombat\s SYSTEMDIR', self::SEVERITY_ERROR); return; } if ($this->post['basedir'] == $this->system) { $this->addMsg( 'SYSTEMDIR and BASEDIR must not be the same! The folder that holds the Wombat framework must not be your BASEDIR. That way, you never have to touch anything inside SYSTEMDIR and you may reuse SYSTEMDIR for further web-sites installed in other BASEDIRs.' , self::SEVERITY_ERROR); return; } // create basedir if (!is_dir($this->post['basedir'])) { if (!@mkdir($this->post['basedir'], 0777, true)) { $this->addMsg( 'Could not create BASEDIR. Maybe there is a problem regarding ownership or permissions.' , self::SEVERITY_ERROR); return; } } // writeable if (!is_writable($this->post['basedir'])) { $this->addMsg( 'Folder BASEDIR exists, but is not writeable.' , self::SEVERITY_ERROR); return; } $this->base = realpath($this->post['basedir']); $this->session['basedir'] = $this->base; $folders = array( 'etc', 'etc-default', 'etc-default/event', 'etc-default/site', 'etc-default/site/page', 'etc-default/site/event', 'include', 'include/WB', 'include/patEx', 'template', 'htdoc', 'htdoc/s', 'resource', 'resource/css', 'resource/js', 'template', 'template/Composite', 'template/Static', 'template/Mailer', 'var', 'var/log', 'var/cache', 'var/tmp' ); $this->mkDir($folders); $files = array( 'wbLoader.php', 'etc-default/config.xml', 'etc-default/event.xml', 'etc-default/locale.xml', 'etc-default/log.xml', 'etc-default/locale.xml', 'etc-default/table.xml', 'etc-default/site.xml', 'etc-default/site/content.xml', 'etc-default/site/page/__index.xml', 'etc-default/site/page/sitemap.xml', 'etc-default/site/page/robots.txt.xml', 'etc-default/site/page/blank.xml', 'htdoc/dispatcher.php', 'resource/css/main.css', 'resource/css/form.css', 'resource/css/window.css', 'resource/css/highlight.css', 'resource/css/icon.css', 'resource/css/lightbox.css', 'resource/css/tool.css', 'resource/css/vfs.css', 'template/site.tmpl', 'template/formError.tmpl', 'template/Composite/site.tmpl', 'template/Static/menu.tmpl', 'template/Static/home.tmpl', 'template/Static/blank.tmpl', 'template/Mailer/signature.tmpl', ); $this->copy($files); } private function addMsg($msg, $severity = self::SEVERITY_MSG) { $this->msg[] = array($msg, $severity); } private function printMsg() { echo "
%s
', $msg[1], $msg[0]); } echo "