/** {@inheritdoc} */ public function showMain() { if (!is_writable($this->app['configPath'])) { $this->addMessage("Configuration file doesn't seem to be writable.", self::MSG_ERROR); } $config = $this->app->openConfiguration(); $pages = PagePeer::getSelect(); $form = new Curry_Form(array('action' => url('', array("module", "view")), 'method' => 'post', 'elements' => array('enabled' => array('checkbox', array('label' => 'Enable domain mapping', 'value' => $config->domainMapping->enabled)), 'default_base_page' => array('select', array('label' => 'Default base page', 'description' => 'The default base page will only be used if there are no other domains matching and domain mapping is enabled', 'value' => $config->domainMapping->default, 'multiOptions' => array('' => '[ None ]') + $pages))))); $domainForm = new Curry_Form_Dynamic(array('legend' => 'Domain', 'elements' => array('domain' => array('text', array('label' => 'Domain', 'description' => 'You can use default as a wildcard to fetch unmatched domains.', 'required' => true)), 'base_page' => array('select', array('label' => 'Base page', 'multiOptions' => array('' => '[ None ]') + $pages, 'required' => true)), 'include_www' => array('checkbox', array('label' => 'Include www'))))); $form->addSubForm(new Curry_Form_MultiForm(array('legend' => '', 'cloneTarget' => $domainForm, 'defaults' => $config->domainMapping->domains ? $config->domainMapping->domains->toArray() : array())), 'domainMapping'); $form->addElement('submit', 'save', array('label' => 'Save')); if (isPost() && $form->isValid($_POST)) { $values = $form->getValues(); if (!$config->domainMapping) { $config->domainMapping = array(); } $config->domainMapping->enabled = count($values['domainMapping']) ? (bool) $values['enabled'] : false; $config->domainMapping->default = $values['default_base_page']; $config->domainMapping->domains = $values['domainMapping']; try { $this->app->writeConfiguration($config); $this->addMessage("Settings saved.", self::MSG_SUCCESS); } catch (Exception $e) { $this->addMessage($e->getMessage(), self::MSG_ERROR); } } $this->addMainContent($form); }
/** {@inheritdoc} */ public function showMain() { $this->addMainMenu(); $configFile = Curry_Core::$config->curry->configPath; if (!$configFile) { $this->addMessage("Configuration file not set.", self::MSG_ERROR); } else { if (!is_writable($configFile)) { $this->addMessage("Configuration file doesn't seem to be writable.", self::MSG_ERROR); } } $config = new Zend_Config($configFile ? require $configFile : array(), true); $defaultConfig = Curry_Core::getDefaultConfiguration(); $form = new Curry_Form(array('action' => url('', array("module", "view")), 'method' => 'post')); $themes = array(); $backendPath = Curry_Util::path(true, Curry_Core::$config->curry->wwwPath, 'shared', 'backend'); if ($backendPath) { foreach (new DirectoryIterator($backendPath) as $entry) { $name = $entry->getFilename(); if (!$entry->isDot() && $entry->isDir() && $name !== 'common') { $themes[$name] = $name; } } } $activeTheme = isset($config->curry->backend->theme) ? $config->curry->backend->theme : false; if ($activeTheme && !array_key_exists($activeTheme, $themes)) { $themes[$activeTheme] = $activeTheme; } $pages = PagePeer::getSelect(); // General $form->addSubForm(new Curry_Form_SubForm(array('legend' => 'General', 'elements' => array('name' => array('text', array('label' => 'Name', 'required' => true, 'value' => isset($config->curry->name) ? $config->curry->name : '', 'description' => 'Name of site, shown in backend header and page title by default.', 'placeholder' => $defaultConfig->curry->name)), 'baseUrl' => array('text', array('label' => 'Base URL', 'value' => isset($config->curry->baseUrl) ? $config->curry->baseUrl : '', 'description' => 'The URL to use when creating absolute URLs. This should end with a slash, and may include a path.', 'placeholder' => $defaultConfig->curry->baseUrl)), 'adminEmail' => array('text', array('label' => 'Admin email', 'value' => isset($config->curry->adminEmail) ? $config->curry->adminEmail : '')), 'divertOutMailToAdmin' => array('checkbox', array('label' => 'Divert outgoing email to adminEmail', 'value' => isset($config->curry->divertOutMailToAdmin) ? $config->curry->divertOutMailToAdmin : '', 'description' => 'All outgoing Curry_Mail will be diverted to adminEmail.')), 'developmentMode' => array('checkbox', array('label' => 'Development mode', 'value' => isset($config->curry->developmentMode) ? $config->curry->developmentMode : '')), 'forceDomain' => array('checkbox', array('label' => 'Force domain', 'value' => isset($config->curry->forceDomain) ? $config->curry->forceDomain : '', 'description' => 'If the domain of the requested URL doesn\'t match the domain set by Base URL, the user will be redirected to the correct domain.')), 'fallbackLanguage' => array('select', array('label' => 'Fallback Language', 'multiOptions' => array('' => '[ None ]') + LanguageQuery::create()->find()->toKeyValue('PrimaryKey', 'Name'), 'value' => isset($config->curry->fallbackLanguage) ? $config->curry->fallbackLanguage : '', 'description' => 'The language used when no language has been specified for the rendered page. Also the language used in backend context.'))))), 'general'); // Backend $form->addSubForm(new Curry_Form_SubForm(array('legend' => 'Backend', 'class' => 'advanced', 'elements' => array('theme' => array('select', array('label' => 'Theme', 'multiOptions' => array('' => '[ Default ]') + $themes, 'value' => isset($config->curry->backend->theme) ? $config->curry->backend->theme : '', 'description' => 'Theme for the administrative back-end.')), 'logotype' => array('filebrowser', array('label' => 'Backend Logotype', 'value' => isset($config->curry->backend->logotype) ? $config->curry->backend->logotype : '', 'description' => 'Path to the backend logotype. The height of this image should be 100px.')), 'templatePage' => array('select', array('label' => 'Template page', 'multiOptions' => array('' => '[ None ]') + $pages, 'value' => isset($config->curry->backend->templatePage) ? $config->curry->backend->templatePage : '', 'description' => 'The page containing page templates (i.e. pages to be used as base pages). When creating new pages or editing a page using the Content tab, only this page and pages below will be shown as base pages.')), 'defaultEditor' => array('text', array('label' => 'Default HTML editor', 'value' => isset($config->curry->defaultEditor) ? $config->curry->defaultEditor : '', 'description' => 'The default WYSIWYG editor to use with the article module.', 'placeholder' => $defaultConfig->curry->defaultEditor)), 'autoBackup' => array('text', array('label' => 'Automatic database backup', 'value' => isset($config->curry->autoBackup) ? $config->curry->autoBackup : '', 'placeholder' => $defaultConfig->curry->autoBackup, 'description' => 'Specifies the number of seconds since last backup to create automatic database backups when logged in to the backend.')), 'revisioning' => array('checkbox', array('label' => 'Revisioning', 'value' => isset($config->curry->revisioning) ? $config->curry->revisioning : '', 'description' => 'When enabled, a new working revision will automatically be created when you create a page. You will also be warned when editing a published page revision')), 'autoPublish' => array('checkbox', array('label' => 'Auto Publish', 'value' => isset($config->curry->autoPublish) ? $config->curry->autoPublish : '', 'description' => 'When enabled, a check will be made on every request to check if there are any pages that should be published (using publish date).')), 'noauth' => array('checkbox', array('label' => 'Disable Backend Authorization', 'value' => isset($config->curry->backend->noauth) ? $config->curry->backend->noauth : '', 'description' => 'This will completely disable authorization for the backend.')), 'autoUpdateIndex' => array('checkbox', array('label' => 'Auto Update Search Index', 'value' => isset($config->curry->autoUpdateIndex) ? $config->curry->autoUpdateIndex : '', 'description' => 'Automatically update (rebuild) search index when changing page content.'))))), 'backend'); // Live edit $form->addSubForm(new Curry_Form_SubForm(array('legend' => 'Live edit', 'class' => 'advanced', 'elements' => array('liveEdit' => array('checkbox', array('label' => 'Enable Live Edit', 'value' => isset($config->curry->liveEdit) ? $config->curry->liveEdit : $defaultConfig->curry->liveEdit, 'description' => 'Enables editing of content directly in the front-end.')), 'placeholderExclude' => array('textarea', array('label' => 'Excluded placeholders', 'value' => isset($config->curry->backend->placeholderExclude) ? join(PHP_EOL, $config->curry->backend->placeholderExclude->toArray()) : '', 'description' => 'Prevent placeholders from showing up in live edit mode. Use newlines to separate placeholders.', 'rows' => 5))))), 'liveEdit'); // Error pages $form->addSubForm(new Curry_Form_SubForm(array('legend' => 'Error pages', 'class' => 'advanced', 'elements' => array('notFound' => array('select', array('label' => 'Page not found (404)', 'multiOptions' => array('' => '[ None ]') + $pages, 'value' => isset($config->curry->errorPage->notFound) ? $config->curry->errorPage->notFound : '')), 'unauthorized' => array('select', array('label' => 'Unauthorized (401)', 'multiOptions' => array('' => '[ None ]') + $pages, 'value' => isset($config->curry->errorPage->unauthorized) ? $config->curry->errorPage->unauthorized : '')), 'error' => array('select', array('label' => 'Internal server error (500)', 'multiOptions' => array('' => '[ None ]') + $pages, 'value' => isset($config->curry->errorPage->error) ? $config->curry->errorPage->error : ''))))), 'errorPage'); // Maintenance $form->addSubForm(new Curry_Form_SubForm(array('legend' => 'Maintenance', 'class' => 'advanced', 'elements' => array('enabled' => array('checkbox', array('label' => 'Enabled', 'required' => true, 'value' => isset($config->curry->maintenance->enabled) ? $config->curry->maintenance->enabled : '', 'description' => 'When maintenance is enabled, users will not be able to access the pages. Only a page (specified below) will be shown. If no page is specified, the message will be shown.')), 'page' => array('select', array('label' => 'Page to show', 'multiOptions' => array('' => '[ None ]') + $pages, 'value' => isset($config->curry->maintenance->page) ? $config->curry->maintenance->page : '')), 'message' => array('textarea', array('label' => 'Message', 'value' => isset($config->curry->maintenance->message) ? $config->curry->maintenance->message : '', 'rows' => 6, 'cols' => 40))))), 'maintenance'); // Mail $testEmailUrl = url('', array('module', 'view' => 'TestEmail')); $dlgOpts = array('width' => 600, 'minHeight' => 150); $form->addSubForm(new Curry_Form_SubForm(array('legend' => 'Mail', 'class' => 'advanced', 'elements' => array('method' => array('select', array('label' => 'Transport', 'multiOptions' => array('' => '[ Default ]', 'smtp' => 'SMTP', 'sendmail' => 'PHP mail() function, ie sendmail.'), 'value' => isset($config->curry->mail->method) ? $config->curry->mail->method : '')), 'host' => array('text', array('label' => 'Host', 'value' => isset($config->curry->mail->host) ? $config->curry->mail->host : '')), 'port' => array('text', array('label' => 'Port', 'value' => isset($config->curry->mail->options->port) ? $config->curry->mail->options->port : '')), 'auth' => array('select', array('label' => 'Auth', 'multiOptions' => array('' => '[ Default ]', 'plain' => 'plain', 'login' => 'login', 'cram-md5' => 'cram-md5'), 'value' => isset($config->curry->mail->options->auth) ? $config->curry->mail->options->auth : '')), 'username' => array('text', array('label' => 'Username', 'value' => isset($config->curry->mail->options->username) ? $config->curry->mail->options->username : '')), 'password' => array('password', array('label' => 'Password')), 'ssl' => array('select', array('label' => 'SSL', 'multiOptions' => array('' => 'Disabled', 'ssl' => 'SSL', 'tls' => 'TLS'), 'value' => isset($config->curry->mail->options->ssl) ? $config->curry->mail->options->ssl : '')), 'mailTest' => array('rawHtml', array('value' => '<a href="' . $testEmailUrl . '" class="btn dialog" data-dialog="' . htmlspecialchars(json_encode($dlgOpts)) . '">Test email</a>'))))), 'mail'); // Paths $form->addSubForm(new Curry_Form_SubForm(array('legend' => 'Paths', 'class' => 'advanced', 'elements' => array('basePath' => array('text', array('label' => 'Base path', 'value' => isset($config->curry->basePath) ? $config->curry->basePath : '', 'placeholder' => $defaultConfig->curry->basePath)), 'projectPath' => array('text', array('label' => 'Project Path', 'value' => isset($config->curry->projectPath) ? $config->curry->projectPath : '', 'placeholder' => $defaultConfig->curry->projectPath)), 'wwwPath' => array('text', array('label' => 'WWW path', 'value' => isset($config->curry->wwwPath) ? $config->curry->wwwPath : '', 'placeholder' => $defaultConfig->curry->wwwPath)), 'vendorPath' => array('text', array('label' => 'Vendor path', 'value' => isset($config->curry->vendorPath) ? $config->curry->vendorPath : '', 'placeholder' => $defaultConfig->curry->vendorPath))))), 'paths'); // Encoding $form->addSubForm(new Curry_Form_SubForm(array('legend' => 'Encoding', 'class' => 'advanced', 'elements' => array('internal' => array('text', array('label' => 'Internal Encoding', 'value' => isset($config->curry->internalEncoding) ? $config->curry->internalEncoding : '', 'description' => 'The internal encoding for PHP.', 'placeholder' => $defaultConfig->curry->internalEncoding)), 'output' => array('text', array('label' => 'Output Encoding', 'value' => isset($config->curry->outputEncoding) ? $config->curry->outputEncoding : '', 'description' => 'The default output encoding for pages.', 'placeholder' => $defaultConfig->curry->outputEncoding))))), 'encoding'); // Misc $form->addSubForm(new Curry_Form_SubForm(array('legend' => 'Misc', 'class' => 'advanced', 'elements' => array('error_notification' => array('checkbox', array('label' => 'Error notification', 'value' => isset($config->curry->errorNotification) ? $config->curry->errorNotification : '', 'description' => 'If enabled, an attempt to send error-logs to the admin email will be performed when an error occur.')), 'log_propel' => array('checkbox', array('label' => 'Propel Logging', 'value' => isset($config->curry->propel->logging) ? $config->curry->propel->logging : '', 'description' => 'Database queries and other debug information will be logged to the selected logging facility.')), 'debug_propel' => array('checkbox', array('label' => 'Debug Propel', 'value' => isset($config->curry->propel->debug) ? $config->curry->propel->debug : '', 'description' => 'Enables query counting but doesn\'t log queries.')), 'log' => array('select', array('label' => 'Logging', 'multiOptions' => array('' => '[ Other ]', 'none' => 'Disable logging', 'firebug' => 'Firebug'), 'value' => isset($config->curry->log->method) ? $config->curry->log->method : '')), 'update_translations' => array('checkbox', array('label' => 'Update Language strings', 'value' => isset($config->curry->updateTranslationStrings) ? $config->curry->updateTranslationStrings : '', 'description' => 'Add strings as they are used and record last used timestamp'))))), 'misc'); $form->addElement('submit', 'save', array('label' => 'Save', 'disabled' => $configFile ? null : 'disabled')); if (isPost() && $form->isValid($_POST)) { $this->saveSettings($config, $form->getValues()); } $this->addMainContent($form); }
/** * Edit module form. * * @param PageModuleWrapper $wrapper * @return Curry_Form|null */ protected function getModuleForm(PageModuleWrapper $wrapper) { $form = new Curry_Form(array('action' => url('', $_GET), 'method' => 'post', 'elements' => array('pid_editmodule' => array('hidden')))); if ($wrapper->hasData()) { $subform = $wrapper->createObject()->showBack(); if ($subform == null) { return null; } if (!$subform instanceof Curry_Form_SubForm) { throw new Exception($wrapper->getClassName() . '::showBack() did not return an instance of Curry_Form_SubForm.'); } if (!$subform->getLegend()) { $subform->setLegend($wrapper->getName() . ' (' . $wrapper->getClassName() . ')'); } if (!$subform instanceof Curry_Form_MultiForm) { $subform->setDecorators(array('FormElements')); } $form->addSubForm($subform, 'module' . $wrapper->getPageModuleId()); $buttons = array('save'); $form->addElement('submit', 'save', array('label' => 'Save')); if ($wrapper->isDeletable()) { $form->addElement('submit', 'delete', array('label' => 'Remove content')); $buttons[] = 'delete'; } $form->addDisplayGroup($buttons, 'dg1', array('class' => 'horizontal-group')); } else { $form->addElement('submit', 'create', array('label' => $wrapper->isInherited() ? 'Override content' : 'Create content')); } return $form; }
protected function getConfigureForm() { $contentTemplates = array('empty' => 'Empty page'); if (file_exists('db.txt')) { $contentTemplates = array('backup' => '[ Restore from backup ]') + $contentTemplates; } $scriptPath = Curry_URL::getScriptPath(); if (($pos = strrpos($scriptPath, '/')) !== false) { $scriptPath = substr($scriptPath, 0, $pos + 1); } else { $scriptPath = ''; } $form = new Curry_Form(array('csrfCheck' => false, 'elements' => array('name' => array('text', array('label' => 'Project name', 'value' => Curry_Core::$config->curry->name)), 'email' => array('text', array('label' => 'Webmaster email', 'value' => Curry_Core::$config->curry->adminEmail)), 'base_url' => array('text', array('label' => 'Base URL', 'value' => $scriptPath == '/' ? '' : $scriptPath, 'placeholder' => 'auto-detect')), 'template' => array('select', array('label' => 'Content template', 'multiOptions' => $contentTemplates)), 'development_mode' => array('checkbox', array('label' => 'Development mode', 'value' => Curry_Core::$config->curry->developmentMode)), 'save' => array('submit', array('label' => 'Save'))))); $form->addSubForm(new Curry_Form_SubForm(array('legend' => 'Create administrator account', 'elements' => array('username' => array('text', array('label' => 'Username', 'value' => 'admin')), 'password' => array('password', array('label' => 'Password', 'renderPassword' => true)), 'password_confirm' => array('password', array('label' => 'Confirm password', 'renderPassword' => true, 'validators' => array(array('identical', false, array('token' => 'password')))))))), 'admin', 5); $form->addSubForm(new Curry_Form_SubForm(array('legend' => 'Create user account', 'elements' => array('username' => array('text', array('label' => 'Username', 'value' => 'user')), 'password' => array('password', array('label' => 'Password', 'renderPassword' => true)), 'password_confirm' => array('password', array('label' => 'Confirm password', 'renderPassword' => true, 'validators' => array(array('identical', false, array('token' => 'password')))))))), 'user', 6); return $form; }
/** * Module properties form. * * @param PageModuleWrapper $pageModuleWrapper * @return Curry_Form */ public static function getModulePropertiesForm(PageModuleWrapper $pageModuleWrapper) { $form = new Curry_Form(array('action' => url('', $_GET), 'method' => 'post', 'elements' => array('pid_moduleproperties' => array('hidden'), 'name' => array('text', array('label' => 'Name', 'required' => true, 'value' => $pageModuleWrapper->getPageModule()->getName(), 'description' => 'The name of this module. If you have many modules of the same type on the same page this will help you to seperate them from each other.')), 'target' => array('text', array('label' => 'Target', 'description' => 'Specifies what variable in the page-template to attach this module to.', 'required' => true, 'value' => $pageModuleWrapper->getTarget())), 'content_visibility' => array('select', array('label' => 'Content Visibility', 'description' => 'Set the visibility of this module in the Content backend module.', 'multiOptions' => PageModulePeer::$contentVisiblityOptions, 'value' => $pageModuleWrapper->getPageModule()->getContentVisibility(), 'required' => true)), 'search_visibility' => array('checkbox', array('label' => 'Search Visibility', 'description' => 'If this module should be rendered when indexing pages.', 'value' => $pageModuleWrapper->getPageModule()->getSearchVisibility(), 'required' => true))))); $showSelect = array("true" => "Yes", "false" => "No"); $defaultTemplate = $pageModuleWrapper->isInherited() ? "[ Inherit ]" : "[ None ]"; $template = $pageModuleWrapper->getModuleData()->getTemplate(); $templatesSelect = Curry_Backend_Template::getTemplateSelect(); if ($template && !array_key_exists($template, $templatesSelect)) { $templatesSelect[$template] = $template . ' <MISSING!>'; } $form->addSubForm(new Curry_Form_SubForm(array('legend' => $pageModuleWrapper->isInherited() ? 'Override inherited settings' : 'Inherited settings', 'elements' => array('template' => $pageModuleWrapper->hasTemplate() ? array('select', array('label' => 'Template', 'multiOptions' => array(null => $defaultTemplate) + $templatesSelect, 'value' => $template)) : array('select', array('label' => 'Template', 'multiOptions' => array("None"), 'disabled' => 'disabled')), 'show' => array('select', array('label' => 'Show', 'multiOptions' => $pageModuleWrapper->isInherited() ? array('' => "[ Inherit ]") + $showSelect : $showSelect, 'value' => self::bool2str($pageModuleWrapper->getModuleData()->getEnabled())))))), 'local'); $form->addElement('submit', 'save', array('label' => 'Save')); return $form; }
protected function getConfigureForm() { $form = new \Curry_Form(array('csrfCheck' => false, 'elements' => array('name' => array('text', array('label' => 'Project name', 'value' => $this->app['name'])), 'email' => array('text', array('label' => 'Webmaster email', 'value' => $this->app['adminEmail'])), 'base_url' => array('text', array('label' => 'Base URL', 'value' => '', 'placeholder' => 'auto-detect')), 'development_mode' => array('checkbox', array('label' => 'Development mode', 'value' => $this->app['developmentMode'])), 'save' => array('submit', array('label' => 'Save'))))); $form->addSubForm(new \Curry_Form_SubForm(array('legend' => 'Create administrator account', 'elements' => array('username' => array('text', array('label' => 'Username', 'value' => 'admin')), 'password' => array('password', array('label' => 'Password', 'renderPassword' => true)), 'password_confirm' => array('password', array('label' => 'Confirm password', 'renderPassword' => true, 'validators' => array(array('identical', false, array('token' => 'password')))))))), 'admin', 4); return $form; }