Esempio n. 1
0
 /** {@inheritdoc} */
 public function showMain()
 {
     $this->addMainMenu();
     $form = new Curry_Form(array('action' => url('', array("module", "view")), 'method' => 'post', 'elements' => array('keywords' => array('text', array('label' => 'Keywords', 'required' => true)), 'search' => array('submit', array('label' => 'Search')))));
     // Validate
     if (isPost() && $form->isValid($_POST)) {
         $this->addMainContent($form);
         $index = $this->app->index;
         $hits = $index->find($form->keywords->getValue());
         $html = "";
         foreach ($hits as $hit) {
             $fieldNames = $hit->getDocument()->getFieldNames();
             $title = in_array('title', $fieldNames) ? (string) $hit->title : '<Untitled>';
             $url = in_array('url', $fieldNames) ? (string) $hit->url : null;
             $model = in_array('model', $fieldNames) ? (string) $hit->model : 'Unknown type';
             $item = $url !== null ? Html::tag('a', array('href' => $url), $title) : $title;
             $item .= ' (' . htmlspecialchars($model) . ')<br/>';
             $html .= '<li>' . $item . '<small>Fields: ' . htmlspecialchars(join(', ', $fieldNames)) . '</small></li>';
         }
         $html .= "<li>Hits: " . count($hits) . " / " . $index->numDocs() . "</li>";
         $this->addMainContent("<ul>" . $html . "</ul>");
     } else {
         $this->addMainContent($form);
     }
 }
Esempio n. 2
0
    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);
    }
Esempio n. 3
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);
 }
Esempio n. 4
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);
 }
Esempio n. 5
0
 /**
  * Show remove package.
  */
 public function showRemove()
 {
     $packageName = $_GET['name'];
     // Check dependencies on installed packages
     $depend = array();
     $installedPackages = PackageQuery::create()->filterByName($packageName, Criteria::NOT_EQUAL)->find();
     foreach ($installedPackages as $installedPackage) {
         $dependencies = Curry_PackageManager::getPackageDependencies($installedPackage->getName(), $installedPackage->getVersion());
         foreach ($dependencies as $depName => $depVersion) {
             if ($depName == $packageName) {
                 $depend[] = $installedPackage->getName();
             }
         }
     }
     $form = new Curry_Form(array('action' => url('', $_GET), 'method' => 'post', 'elements' => array('simulate' => array('checkbox', array('label' => 'Simulate', 'description' => 'Run simulation, will not make any modifications to the system.')), 'submit' => array('submit', array('label' => 'Continue')))));
     if (isPost() && $form->isValid($_POST)) {
         $simulate = $form->simulate->isChecked();
         $status = Curry_PackageManager::removePackage($packageName, $simulate);
         if ($status) {
             $this->addMessage($packageName . ' successfully removed!', self::MSG_SUCCESS);
         } else {
             $this->addMessage('There was an error when uninstalling ' . $packageName, self::MSG_ERROR);
         }
     } else {
         $this->addMessage('The following package will be removed: ' . $packageName, self::MSG_WARNING);
         if (count($depend)) {
             $this->addMessage('The following packages depend on ' . $packageName . ': ' . join(', ', $depend), self::MSG_ERROR);
         }
         $this->addMainContent($form);
     }
 }
Esempio n. 6
0
 /**
  * Create an archive of the project.
  */
 public function showBundle()
 {
     $this->addMainMenu();
     $this->addMessage('You can install this bundle using <a href="' . url('', array('module', 'view' => 'InstallScript')) . '">this installation script</a>.', self::MSG_NOTICE, false);
     $form = new \Curry_Form(array('action' => url('', array("module", "view")), 'method' => 'post', 'elements' => array('project' => array('checkbox', array('label' => 'Project', 'value' => true)), 'www' => array('checkbox', array('label' => 'WWW folder', 'value' => true)), 'vendor' => array('checkbox', array('label' => 'Vendor', 'value' => true)), 'database' => array('checkbox', array('label' => 'Database', 'value' => true)), 'compression' => array('select', array('label' => 'Compression', 'multiOptions' => array(Archive::COMPRESSION_NONE => 'None', Archive::COMPRESSION_GZ => 'Gzip'))), 'save' => array('submit', array('label' => 'Create bundle')))));
     if (isPost() && $form->isValid($_POST)) {
         // create archive
         @set_time_limit(0);
         $compression = $form->compression->getValue();
         $tar = new Archive('', $compression);
         // set up file list
         $options = array(array('pattern' => '*.svn*', 'pattern_subject' => 'path', 'skip' => true), array('pattern' => '*.git*', 'pattern_subject' => 'path', 'skip' => true), array('pattern' => '.DS_Store', 'skip' => true), array('pattern' => 'Thumbs.db', 'skip' => true), array('pattern' => '._*', 'skip' => true));
         if ($form->project->isChecked()) {
             $tar->add($this->app['projectPath'], 'cms/', array_merge($options, array(array('path' => 'data/', 'pattern' => 'data/*/*', 'pattern_subject' => 'path', 'skip' => true))));
         }
         if ($form->www->isChecked()) {
             $tar->add($this->app['wwwPath'], 'www/', $options);
         }
         if ($form->vendor->isChecked()) {
             $tar->add($this->app['projectPath'] . '/../vendor', 'vendor/', $options);
         }
         if ($form->database->isChecked()) {
             $fiveMBs = 5 * 1024 * 1024;
             $fp = fopen("php://temp/maxmemory:{$fiveMBs}", 'r+');
             if (!\Curry_Backend_DatabaseHelper::dumpDatabase($fp)) {
                 throw new \Exception('Aborting: There was an error when dumping the database.');
             }
             fseek($fp, 0);
             $tar->addString('db.txt', stream_get_contents($fp));
             fclose($fp);
         }
         $filename = str_replace(" ", "_", $this->app['name']) . "-bundle-" . date("Ymd") . ".tar" . ($compression ? ".{$compression}" : '');
         header("Content-type: " . Archive::getCompressionMimeType($compression));
         header("Content-disposition: attachment; filename=" . StringHelper::escapeQuotedString($filename));
         // do not use output buffering
         while (ob_end_clean()) {
         }
         $tar->stream();
         exit;
     }
     $this->addMainContent($form);
     return parent::render();
 }
Esempio n. 7
0
 /** {@inheritdoc} */
 public function showMain()
 {
     $rootPage = PageQuery::create()->findRoot();
     $code = Curry_Backend_PageSyncHelper::getPageCode($rootPage);
     $localChecksum = sha1(serialize($code));
     if (isPost('fetch')) {
         Curry_Application::returnJson($code);
     }
     $form = new Curry_Form(array('csrfCheck' => false, 'action' => (string) url('', $_GET), 'method' => 'post', 'elements' => array('url' => array('text', array('label' => 'URL', 'placeholder' => 'http://example.com/admin.php', 'value' => isset($_COOKIE['curry:remote_url']) ? $_COOKIE['curry:remote_url'] : '')), 'user' => array('text', array('label' => 'User', 'value' => isset($_COOKIE['curry:remote_user']) ? $_COOKIE['curry:remote_user'] : '******')), 'password' => array('password', array('label' => 'Password', 'value' => '')), 'submit' => array('submit', array('class' => 'btn btn-primary', 'label' => 'Fetch')))));
     if (isPost('code')) {
         // we have page-code
         if ($localChecksum !== $_POST['local_checksum']) {
             throw new Exception('Local pages were changed during synchronization process, aborting!');
         }
         $remoteCode = json_decode($_POST['code'], true);
         // Update selected pages
         if (isset($_POST['page'])) {
             $updatedPages = Curry_Backend_PageSyncHelper::restorePages($rootPage, $remoteCode, array_keys($_POST['page']));
             $this->addMessage(count($updatedPages) . ' pages updated!', self::MSG_SUCCESS);
         }
         // Delete selected pages
         if (isset($_POST['delete'])) {
             $pagesToDelete = array_keys($_POST['delete']);
             foreach ($pagesToDelete as $pageId) {
                 $page = PageQuery::create()->findPk($pageId);
                 if (!$page) {
                     throw new Exception('Unable to find page to delete.');
                 }
                 if (!$page->isLeaf()) {
                     $this->addMessage('Unable to delete page "' . $page->getName() . '" because it has subpages.', self::MSG_ERROR);
                     continue;
                 }
                 $dependantPages = $page->getDependantPages();
                 if (count($dependantPages)) {
                     $this->addMessage('Unable to delete page "' . $page->getName() . '" because other pages depend on it.', self::MSG_ERROR);
                     continue;
                 }
                 $page->delete();
                 $this->addMessage('Deleted page "' . $page->getName() . '"', self::MSG_WARNING);
             }
         }
     } else {
         if (isPost() && $form->isValid($_POST)) {
             // have user/password
             try {
                 $context = stream_context_create(array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => http_build_query(array('login_username' => $form->user->getValue(), 'login_password' => $form->password->getValue(), 'fetch' => '1')))));
                 $remote = (string) url($form->url->getValue(), array('module' => 'Curry_Backend_PageSync'));
                 $remoteResponse = file_get_contents($remote, null, $context);
                 if ($remoteResponse === false) {
                     throw new Exception('Invalid response');
                 }
                 $remoteCode = json_decode($remoteResponse, true);
                 if ($remoteCode === null) {
                     throw new Exception('Invalid json: ' . $remoteResponse);
                 }
                 setcookie('curry:remote_url', $form->url->getValue(), time() + 86400 * 365);
                 setcookie('curry:remote_user', $form->user->getValue(), time() + 86400 * 365);
                 $this->addMainContent('<form action="' . url('', $_GET) . '" method="post" class="well">');
                 $this->addMainContent('<input type="hidden" name="code" value="' . htmlspecialchars($remoteResponse) . '" />');
                 $this->addMainContent('<input type="hidden" name="local_checksum" value="' . htmlspecialchars($localChecksum) . '" />');
                 $this->addMainContent('<ul>');
                 $this->comparePageCode($code, $remoteCode);
                 $this->addMainContent('</ul>');
                 $this->addMainContent('<button type="submit" class="btn btn-primary">Sync</button>');
                 $this->addMainContent('</form>');
             } catch (Exception $e) {
                 $this->addMainContent($form);
                 $this->addMessage($e->getMessage(), self::MSG_ERROR);
             }
         } else {
             $this->addMainContent(self::INTRO);
             $this->addMainContent($form);
         }
     }
 }
Esempio n. 8
0
 /**
  * Get language selection form.
  *
  * @param string $langcode
  * @return Curry_Form
  */
 private function getLanguageForm($langcode)
 {
     $form = new Curry_Form(array('method' => 'get', 'action' => url(''), 'id' => 'language-selector', 'elements' => array('langcode' => array('select', array('label' => 'Language', 'multiOptions' => array('' => 'None') + LanguageQuery::create()->find()->toKeyValue('Langcode', 'Name'), 'onchange' => 'this.form.submit();', 'value' => $langcode, 'description' => 'Change this if you want to set language specific content.')))));
     $preserve = array('module', 'view', 'page_module_id', 'page_id');
     foreach ($preserve as $var) {
         if (isset($_GET[$var])) {
             $form->addElement('hidden', $var, array('value' => $_GET[$var]));
         }
     }
     return $form;
 }
Esempio n. 9
0
 /**
  * Language translation form.
  *
  * @param Language $language
  * @return Curry_Form
  */
 protected function getTranslationForm(Language $language)
 {
     $form = new Curry_Form(array('action' => url('', $_GET), 'method' => 'post'));
     $translations = LanguageStringTranslationQuery::create()->filterByLanguage($language)->find()->toKeyValue('StringId', 'Translation');
     foreach (LanguageStringQuery::create()->find()->toKeyValue('Id', 'ElementType') as $id => $elementType) {
         $translation = array_key_exists($id, $translations) ? $translations[$id] : '';
         $options = array('label' => $id, 'value' => $translation);
         try {
             $form->getPluginLoader('element')->load($elementType);
             if ($elementType == 'textarea') {
                 $options['rows'] = 4;
                 //$options['wrap'] = null;
             }
         } catch (Zend_Loader_Exception $e) {
             $elementType = 'text';
         }
         $form->addElement($elementType, sha1($id), $options);
     }
     $form->addElement('submit', 'submit', array('label' => 'Save'));
     return $form;
 }
Esempio n. 10
0
 /**
  * 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;
 }
Esempio n. 11
0
 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;
 }
Esempio n. 12
0
 public function createElement($type, $name, $options = null)
 {
     $columnElement = isset($this->columnElements[$name]) ? $this->columnElements[$name] : null;
     if ($columnElement === false) {
         return null;
     }
     if (is_string($columnElement)) {
         $type = $columnElement;
     } else {
         if (is_array($columnElement)) {
             list($type, $o) = $columnElement;
             $options = array_merge((array) $options, $o);
         }
     }
     return parent::createElement($type, $name, $options);
 }
Esempio n. 13
0
 /**
  * Restore database.
  */
 public function showRestore()
 {
     $this->showMainMenu();
     $tables = array();
     $selectedTables = array();
     $disabledTables = array();
     foreach (Curry_Propel::getModels() as $package => $classes) {
         $tables[$package] = array();
         foreach ($classes as $table) {
             $tables[$package][$table] = $table;
             if (method_exists($table, 'save')) {
                 $selectedTables[] = $table;
             } else {
                 $disabledTables[] = $table;
             }
         }
     }
     $files = array('' => '-- Select file --', 'upload' => '[ Upload from computer ]', 'remote' => '[ From remote server ]');
     $path = Curry_Backend_DatabaseHelper::createBackupName('*.txt');
     foreach (array_reverse(glob($path)) as $file) {
         $files[$file] = basename($file) . ' (' . Curry_Util::humanReadableBytes(filesize($file)) . ')';
     }
     $form = new Curry_Form(array('action' => url('', array("module", "view", "page_id")), 'method' => 'post', 'enctype' => 'multipart/form-data', 'elements' => array('tables' => array('multiselect', array('label' => 'Tables', 'multiOptions' => $tables, 'value' => $selectedTables, 'disable' => $disabledTables, 'size' => 15)), 'file' => array('select', array('label' => 'From file', 'multiOptions' => $files, 'class' => 'trigger-change', 'onchange' => "\$('#uploadfile-label').next().andSelf()[this.value == 'upload'?'show':'hide']();" . "\$('#remote-label').next().andSelf()[this.value == 'remote'?'show':'hide']();")), 'uploadfile' => array('file', array('label' => 'Upload file', 'valueDisabled' => true)), 'remote' => array('text', array('label' => 'Remote')), 'max_execution_time' => array('text', array('label' => 'Max execution time', 'value' => '', 'description' => 'Input time in seconds to allow interruption if the time taken to restore would exceed the maximum execution time.')))));
     $form->addElement('submit', 'Go');
     if (isPost() && $form->isValid($_POST)) {
         if ($form->file->getValue() == 'upload') {
             if (!$form->uploadfile->isUploaded()) {
                 throw new Exception('No file was uploaded.');
             }
             $fileinfo = $form->uploadfile->getFileInfo();
             Curry_Backend_DatabaseHelper::restoreFromFile($fileinfo['uploadfile']['tmp_name'], $form->tables->getValue(), 0, 0, $this);
         } else {
             if ($form->file->getValue() == 'remote') {
                 if (!$form->remote->getValue()) {
                     throw new Exception('No remote URL set');
                 }
                 $url = url($form->remote->getValue());
                 $post = array('login_username' => $url->getUser(), 'login_password' => $url->getPassword(), 'tables' => '*', 'name' => 'db.txt', 'type' => 'local');
                 $url->setUser(null)->setPassword(null)->setPath('/admin.php')->add(array('module' => 'Curry_Backend_Database', 'view' => 'Backup'));
                 $context = stream_context_create(array('http' => array('method' => 'POST', 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'content' => http_build_query($post))));
                 $fp = fopen($url, 'r', false, $context);
                 Curry_Backend_DatabaseHelper::restoreFromFile($fp, $form->tables->getValue(), 0, 0, $this);
                 fclose($fp);
             } else {
                 if ($form->file->getValue()) {
                     Curry_Backend_DatabaseHelper::restoreFromFile($form->file->getValue(), $form->tables->getValue(), (int) $form->max_execution_time->getValue(), 0, $this);
                 }
             }
         }
     }
     $this->addMainContent($form);
 }
Esempio n. 14
0
 /**
  * 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;
 }
Esempio n. 15
0
 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;
 }