示例#1
0
 /** {@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);
 }
    public function showMain()
    {
        $this->flushConfigCache();
        $form = new Curry_Form(array('url' => url('', $_GET), 'method' => 'post', 'elements' => array('job_handler' => array('text', array('label' => 'Job handler', 'value' => Curry_Core::$config->modules->contrib->CurryGearman->jobHandler, 'placeholder' => 'Leave empty to use default')), 'token' => array('text', array('label' => 'Token', 'description' => 'To execute the listener from the browser, a hash is required.', 'value' => Curry_Core::$config->modules->contrib->CurryGearman->token, 'required' => true, 'placeholder' => 'Enter a random string')), 'save' => array('submit', array('label' => 'Save')))));
        if (isPost() && $form->isValid($_POST)) {
            $values = $form->getValues(true);
            $this->saveConfig($values);
            return;
        }
        $webWorkerUrl = url(Curry_Core::$config->curry->baseUrl . 'gearman_listener.php/', array('hash' => Common_Gearman_Listener::getHash()))->getAbsolute();
        $html = <<<HTML
{$form}
<p><a href="{$webWorkerUrl}" target="_blank">Click here to execute Gearman web worker.</a></p>
HTML;
        $this->addMainContent($html);
    }
示例#3
0
 public function showMainFilePerm()
 {
     // the primary key of the row that was clicked is available in the 'item' url parameter.
     $pk = $_GET['item'];
     $mf = ManagedfileQuery::create()->findPk($pk);
     $form = new Curry_Form(array('action' => url('', $_GET), 'method' => 'post', 'elements' => array('oread' => array('checkbox', array('label' => 'Read', 'value' => $mf->getReadPerm('owner'))), 'owrite' => array('checkbox', array('label' => 'Write', 'value' => $mf->getWritePerm('owner'))), 'rread' => array('checkbox', array('label' => 'Read', 'value' => $mf->getReadPerm('role'))), 'rwrite' => array('checkbox', array('label' => 'Write', 'value' => $mf->getWritePerm('role'))), 'wread' => array('checkbox', array('label' => 'Read', 'value' => $mf->getReadPerm('world'))), 'wwrite' => array('checkbox', array('label' => 'Write', 'value' => $mf->getWritePerm('world'))))));
     $form->addDisplayGroup(array('oread', 'owrite'), 'grpOwner', array('legend' => 'Owner permissions'));
     $form->addDisplayGroup(array('rread', 'rwrite'), 'grpRole', array('legend' => 'Role permissions'));
     $form->addDisplayGroup(array('wread', 'wwrite'), 'grpWorld', array('legend' => 'World permissions'));
     $form->addElement('submit', 'save', array('label' => 'Update permisisons'));
     if (isPost() && $form->isValid($_POST)) {
         $values = $form->getValues();
         $operm = array('read' => (bool) $values['oread'], 'write' => (bool) $values['owrite']);
         $rperm = array('read' => (bool) $values['rread'], 'write' => (bool) $values['rwrite']);
         $wperm = array('read' => (bool) $values['wread'], 'write' => (bool) $values['wwrite']);
         $mf->setPermission(Managedfile::getPermissionWord($operm, $rperm, $wperm))->save();
         $this->createModelUpdateEvent('Managedfile', $mf->getPrimaryKey(), 'update');
         return '';
     }
     $this->addMainContent($form);
 }
示例#4
0
 /** {@inheritdoc} */
 public function show(Request $request)
 {
     $this->addMainMenu();
     $configFile = $this->app['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 = $this->app->openConfiguration();
     $defaultConfig = $this->app->getDefaultConfiguration();
     $form = new \Curry_Form(array('action' => url('', array("module", "view")), 'method' => 'post'));
     $themes = array();
     $backendPath = PathHelper::path(true, $this->app['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->backend->theme) ? $config->backend->theme : false;
     if ($activeTheme && !array_key_exists($activeTheme, $themes)) {
         $themes[$activeTheme] = $activeTheme;
     }
     $pages = \PagePeer::getSelect();
     $loggers = $this->getDefaultLoggers($config);
     $enabledLoggers = isset($config->log) ? array_filter($config->log->toArray(), function ($log) {
         return !isset($log['enabled']) || $log['enabled'];
     }) : array();
     // General
     $form->addSubForm(new \Curry_Form_SubForm(array('legend' => 'General', 'elements' => array('name' => array('text', array('label' => 'Name', 'required' => true, 'value' => isset($config->name) ? $config->name : '', 'description' => 'Name of site, shown in backend header and page title by default.', 'placeholder' => $defaultConfig->name)), 'baseUrl' => array('text', array('label' => 'Base URL', 'value' => isset($config->baseUrl) ? $config->baseUrl : '', 'description' => 'The URL to use when creating absolute URLs. This should end with a slash, and may include a path.', 'placeholder' => $defaultConfig->baseUrl)), 'adminEmail' => array('text', array('label' => 'Admin email', 'value' => isset($config->adminEmail) ? $config->adminEmail : '')), 'divertOutMailToAdmin' => array('checkbox', array('label' => 'Divert outgoing email to admin email', 'value' => isset($config->divertOutMailToAdmin) ? $config->divertOutMailToAdmin : '', 'description' => 'All outgoing Curry\\Mail will be diverted to admin email.')), 'developmentMode' => array('checkbox', array('label' => 'Development mode', 'value' => isset($config->developmentMode) ? $config->developmentMode : '')), 'forceDomain' => array('checkbox', array('label' => 'Force domain', 'value' => isset($config->forceDomain) ? $config->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->fallbackLanguage) ? $config->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->backend->theme) ? $config->backend->theme : '', 'description' => 'Theme for the administrative back-end.')), 'logotype' => array('filebrowser', array('label' => 'Backend Logotype', 'value' => isset($config->backend->logotype) ? $config->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->backend->templatePage) ? $config->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->defaultEditor) ? $config->defaultEditor : '', 'description' => 'The default WYSIWYG editor to use with the article module.', 'placeholder' => $defaultConfig->defaultEditor)), 'autoBackup' => array('text', array('label' => 'Automatic database backup', 'value' => isset($config->autoBackup) ? $config->autoBackup : '', 'placeholder' => $defaultConfig->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->revisioning) ? $config->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->autoPublish) ? $config->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->backend->noauth) ? $config->backend->noauth : '', 'description' => 'This will completely disable authorization for the backend.')), 'autoUpdateIndex' => array('checkbox', array('label' => 'Auto Update Search Index', 'value' => isset($config->autoUpdateIndex) ? $config->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->liveEdit) ? $config->liveEdit : $defaultConfig->liveEdit, 'description' => 'Enables editing of content directly in the front-end.')), 'placeholderExclude' => array('textarea', array('label' => 'Excluded placeholders', 'value' => isset($config->backend->placeholderExclude) ? join(PHP_EOL, $config->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->errorPage->notFound) ? $config->errorPage->notFound : '')), 'unauthorized' => array('select', array('label' => 'Unauthorized (401)', 'multiOptions' => array('' => '[ None ]') + $pages, 'value' => isset($config->errorPage->unauthorized) ? $config->errorPage->unauthorized : '')), 'error' => array('select', array('label' => 'Internal server error (500)', 'multiOptions' => array('' => '[ None ]') + $pages, 'value' => isset($config->errorPage->error) ? $config->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->maintenance->enabled) ? $config->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->maintenance->page) ? $config->maintenance->page : '')), 'message' => array('textarea', array('label' => 'Message', 'value' => isset($config->maintenance->message) ? $config->maintenance->message : '', 'rows' => 6, 'cols' => 40))))), 'maintenance');
     // Mail
     $dlgOpts = array('width' => 600, 'minHeight' => 150);
     $form->addSubForm(new \Curry_Form_SubForm(array('legend' => 'Mail', 'class' => 'advanced', 'elements' => array('fromEmail' => array('text', array('label' => 'From email', 'value' => isset($config->mail->from->email) ? $config->mail->from->email : '')), 'fromName' => array('text', array('label' => 'From name', 'value' => isset($config->mail->from->name) ? $config->mail->from->name : '')), 'replytoEmail' => array('text', array('label' => 'ReplyTo email', 'value' => isset($config->mail->replyto->email) ? $config->mail->replyto->email : '')), 'replytoName' => array('text', array('label' => 'ReplyTo name', 'value' => isset($config->mail->replyto->name) ? $config->mail->replyto->name : '')), 'method' => array('select', array('label' => 'Transport', 'multiOptions' => array('' => '[ Default ]', 'smtp' => 'SMTP', 'sendmail' => 'PHP mail() function, ie sendmail.'), 'value' => isset($config->mail->method) ? $config->mail->method : '')), 'host' => array('text', array('label' => 'Host', 'value' => isset($config->mail->host) ? $config->mail->host : '')), 'port' => array('text', array('label' => 'Port', 'value' => isset($config->mail->options->port) ? $config->mail->options->port : '')), 'auth' => array('select', array('label' => 'Auth', 'multiOptions' => array('' => '[ Default ]', 'plain' => 'plain', 'login' => 'login', 'cram-md5' => 'cram-md5'), 'value' => isset($config->mail->options->auth) ? $config->mail->options->auth : '')), 'username' => array('text', array('label' => 'Username', 'value' => isset($config->mail->options->username) ? $config->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->mail->options->ssl) ? $config->mail->options->ssl : '')), 'mailTest' => array('rawHtml', array('value' => '<a href="' . $this->testemail->url() . '" 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->basePath) ? $config->basePath : '', 'placeholder' => $defaultConfig->basePath)), 'projectPath' => array('text', array('label' => 'Project Path', 'value' => isset($config->projectPath) ? $config->projectPath : '', 'placeholder' => $defaultConfig->projectPath)), 'wwwPath' => array('text', array('label' => 'WWW path', 'value' => isset($config->wwwPath) ? $config->wwwPath : '', 'placeholder' => $defaultConfig->wwwPath)), 'vendorPath' => array('text', array('label' => 'Vendor path', 'value' => isset($config->vendorPath) ? $config->vendorPath : '', 'placeholder' => $defaultConfig->vendorPath))))), 'paths');
     // 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->errorNotification) ? $config->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->propel->logging) ? $config->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->propel->debug) ? $config->propel->debug : '', 'description' => 'Enables query counting but doesn\'t log queries.')), 'log' => array('multiselect', array('label' => 'Logging', 'multiOptions' => array_combine(array_keys($loggers), array_keys($loggers)), 'value' => array_keys($enabledLoggers))), 'update_translations' => array('checkbox', array('label' => 'Update Language strings', 'value' => isset($config->updateTranslationStrings) ? $config->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);
     return parent::render();
 }
示例#5
0
 /**
  * Backup database.
  */
 public function showBackup()
 {
     $this->showMainMenu();
     $tables = array();
     $selectedTables = array();
     foreach (Curry_Propel::getModels() as $package => $classes) {
         $selectedTables = array_merge($selectedTables, array_values($classes));
         $tables[$package] = array();
         foreach ($classes as $table) {
             $tables[$package][$table] = $table;
         }
     }
     $form = new Curry_Form(array('action' => url('', array("module", "view", "page_id")), 'method' => 'post', 'elements' => array('tables' => array('multiselect', array('label' => 'Tables', 'multiOptions' => $tables, 'value' => $selectedTables, 'size' => 15)), 'name' => array('text', array('label' => 'Name', 'required' => true, 'value' => 'backup_%Y-%m-%d_%H-%M-%S.txt', 'description' => 'Name of the file, strftime() is used to format the string.')), 'type' => array('radio', array('label' => 'Where do you want to save?', 'multiOptions' => array('online' => 'Save online', 'local' => 'Save to local file'), 'value' => 'online')))));
     $form->addElement('submit', 'Go');
     if (isPost() && ($_POST['tables'] == '*' || $_POST['tables'] == array('*'))) {
         $_POST['tables'] = $selectedTables;
     }
     if (isPost() && $form->isValid($_POST)) {
         $values = $form->getValues();
         if ($values['type'] == 'local') {
             // dump to temp, stream to client
             $fp = fopen("php://temp", 'r+');
             Curry_Backend_DatabaseHelper::dumpDatabase($fp, $values['tables'], $this);
             rewind($fp);
             $name = Curry_String::getRewriteString(Curry_Core::$config->curry->name) . '-db.txt';
             Curry_Application::returnData($fp, 'application/octet-stream', $name);
         } else {
             if ($values['type'] == 'online') {
                 $filename = Curry_Backend_DatabaseHelper::createBackupName($values['name']);
                 $status = Curry_Backend_DatabaseHelper::dumpDatabase($filename, $values['tables'], $this);
                 $this->addMessage('Backup created ' . $filename, $status ? self::MSG_SUCCESS : self::MSG_ERROR);
             }
         }
     }
     $this->addMainContent($form);
 }
示例#6
0
 /**
  * Create new module form.
  *
  * @param PageRevision $pageRevision
  * @param string $moduleClass
  * @return Curry_Form
  */
 public static function getNewModuleForm($pageRevision, $moduleClass, $target)
 {
     $valid = array();
     $modules = array();
     foreach (ModuleQuery::create()->orderByTitle()->find() as $module) {
         $inTargets = in_array($target, $module->getTargets());
         if (!$target || ($module->getTargetsExclude() ? !$inTargets : $inTargets)) {
             $modules[$module->getModuleId()] = $module->getTitle();
             $valid[] = $module->getModuleId();
         }
     }
     $user = User::getUser();
     $modulePermission = $user->hasPagePermission($pageRevision->getPage(), PageAccessPeer::PERM_MODULES);
     if ($modulePermission) {
         $modules = array('Predefined' => $modules);
         foreach (AbstractModule::getModuleList() as $className) {
             $parts = explode("_", str_replace("_Module_", "_", $className));
             $package = array_shift($parts);
             $modules[$package][$className] = join(" / ", $parts);
             $valid[] = $className;
         }
     }
     if (!$moduleClass || !in_array($moduleClass, $valid)) {
         $form = new Curry_Form(array('action' => url('', $_GET), 'method' => 'post', 'class' => isAjax() ? 'dialog-form' : '', 'elements' => array('module_class' => array('select', array('label' => 'Type', 'multiOptions' => $modules, 'required' => true)), 'next' => array('submit', array('label' => 'Next')))));
         return $form;
     } else {
         // Fetch template targets
         $targets = array();
         try {
             $template = $pageRevision->getInheritedProperty('Template');
             if ($template) {
                 $template = \Curry\App::getInstance()->twig->loadTemplate($template);
             }
             while ($template) {
                 $targets = array_merge($targets, $template->getPlaceholders());
                 $template = $template->getParent(array());
             }
         } catch (Exception $e) {
             \Curry\App::getInstance()->logger->warning('Error in template: ' . $e->getMessage());
         }
         if (count($targets)) {
             $targets = array_combine(array_values($targets), array_values($targets));
         }
         // Check for predefined module creation
         if (ctype_digit($moduleClass)) {
             $module = ModuleQuery::create()->findPk($moduleClass);
             $form = new Curry_Form(array('action' => url('', $_GET), 'method' => 'post', 'class' => isAjax() ? 'dialog-form' : '', 'elements' => array('pid_newmodule' => array('hidden', array('value' => 1)), 'module_class' => array('hidden', array('value' => $moduleClass)), 'name' => array('text', array('label' => 'Name', 'required' => true, 'description' => 'A descriptive name of the module.', 'value' => $module->getName())))));
             if (!$target) {
                 // Show only acceptable targets...
                 $form->addElement('select', 'target', array('label' => 'Target', 'description' => 'Specifies what placeholder/variable in the page-template to attach this module to.', 'multiOptions' => $targets));
             } else {
                 $form->addElement('hidden', 'target', array('value' => $target));
                 $form->setCsrfCheck(false);
                 $_POST = $form->getValues();
             }
             $form->addElement('submit', 'add', array('label' => 'Add module'));
             return $form;
         }
         if (!class_exists($moduleClass)) {
             throw new Exception('Class \'' . $moduleClass . '\' could not be loaded, please check the path and classname.');
         }
         $defaultName = substr($moduleClass, strrpos($moduleClass, '_') + 1);
         $targets[''] = '[ Custom ]';
         asort($targets);
         $templates = array('' => "[ None ]", 'new' => "[ Create new ]") + Curry_Backend_Template::getTemplateSelect();
         $defaultTemplateName = 'Modules/' . $defaultName . '.html';
         $defaultTemplate = '';
         if ($moduleClass !== 'Curry_Module_Article' && call_user_func(array($moduleClass, 'hasTemplate'))) {
             $defaultTemplate = array_key_exists($defaultTemplateName, $templates) ? $defaultTemplateName : 'new';
         }
         $predefinedTemplates = call_user_func(array($moduleClass, 'getPredefinedTemplates'));
         $predefinedTemplates = count($predefinedTemplates) ? array_combine(array_keys($predefinedTemplates), array_keys($predefinedTemplates)) : array();
         $predefinedTemplates = array('' => '[ Empty ]') + $predefinedTemplates;
         $form = new Curry_Form(array('action' => url('', $_GET), 'method' => 'post', 'class' => isAjax() ? 'dialog-form' : '', 'elements' => array('pid_newmodule' => array('hidden'), 'module_class' => array('hidden', array('value' => $moduleClass)), 'module_class_display' => array('rawHtml', array('label' => 'Type', 'value' => '<input type="text" value="' . $moduleClass . '" disabled="disabled" />')), 'name' => array('text', array('label' => 'Name', 'required' => true, 'description' => 'A descriptive name of the module.', 'value' => $defaultName)), 'target' => array('select', array('label' => 'Target', 'description' => 'Specifies what placeholder/variable in the page-template to attach this module to.', 'value' => isset($_GET['target']) ? $_GET['target'] : null, 'multiOptions' => $targets, 'class' => 'trigger-change', 'onchange' => "\$('#target_name-label, #target_name-element').toggle(\$(this).val() == '');")), 'target_name' => array('text', array('label' => 'Target Name')), 'template' => array('select', array('class' => 'trigger-change', 'label' => 'Template', 'multiOptions' => $templates, 'value' => $defaultTemplate, 'onchange' => "\$('#template_name-label, #template_name-element, #predefined_template-label, #predefined_template-element').toggle(\$(this).val() == 'new');")), 'template_name' => array('text', array('label' => 'Name', 'value' => $defaultTemplateName)), 'predefined_template' => array('select', array('label' => 'Predefined template', 'multiOptions' => $predefinedTemplates)), 'content_visibility' => array('select', array('label' => 'Content Visibility', 'description' => 'Set the visibility of this module in the Content backend module.', 'multiOptions' => PageModulePeer::$contentVisiblityOptions, 'value' => PageModulePeer::CONTENT_VISIBILITY_ALWAYS, 'required' => true)), 'search_visibility' => array('checkbox', array('label' => 'Search Visibility', 'description' => 'If this module should be rendered when indexing pages.', 'value' => true, 'required' => true)))));
         $form->addDisplayGroup(array('position', 'content_visibility', 'search_visibility'), 'advanced', array('class' => 'advanced', 'legend' => 'Advanced'));
         $form->addElement('submit', 'add', array('label' => 'Add module'));
     }
     return $form;
 }