public function setValue($value, $record = null) { if (!is_string($value)) { $value = json_encode($value); } return parent::setValue($value, $record); }
function testHasValue() { $varcharField = new Varchar("testfield"); $this->assertTrue($varcharField->getNullifyEmpty()); $varcharField->setValue('abc'); $this->assertTrue($varcharField->hasValue()); $varcharField->setValue(''); $this->assertFalse($varcharField->hasValue()); $varcharField->setValue(null); $this->assertFalse($varcharField->hasValue()); $varcharField = new Varchar("testfield", 50, array('nullifyEmpty' => false)); $this->assertFalse($varcharField->getNullifyEmpty()); $varcharField->setValue('abc'); $this->assertTrue($varcharField->hasValue()); $varcharField->setValue(''); $this->assertTrue($varcharField->hasValue()); $varcharField->setValue(null); $this->assertFalse($varcharField->hasValue()); $textField = new Text("testfield"); $this->assertTrue($textField->getNullifyEmpty()); $textField->setValue('abc'); $this->assertTrue($textField->hasValue()); $textField->setValue(''); $this->assertFalse($textField->hasValue()); $textField->setValue(null); $this->assertFalse($textField->hasValue()); $textField = new Text("testfield", array('nullifyEmpty' => false)); $this->assertFalse($textField->getNullifyEmpty()); $textField->setValue('abc'); $this->assertTrue($textField->hasValue()); $textField->setValue(''); $this->assertTrue($textField->hasValue()); $textField->setValue(null); $this->assertFalse($textField->hasValue()); }
/** * Set the value on the field. * Optionally takes the whole record as an argument, * to pick other values. * * @param mixed $value * @param array $record */ public function setValue($value, $record = null) { FrontendEditing::setValue($this, $value, $record); parent::setValue($value, $record); }
function deleteinstallfiles() { if (!Permission::check("ADMIN")) { return Security::permissionFailure($this); } $title = new Varchar("Title"); $content = new HTMLText("Content"); $tempcontent = ''; $username = Session::get('username'); $password = Session::get('password'); // We can't delete index.php as it might be necessary for URL routing without mod_rewrite. // There's no safe way to detect usage of mod_rewrite across webservers, // so we have to assume the file is required. $installfiles = array('install.php', 'config-form.css', 'config-form.html', 'index.html'); foreach ($installfiles as $installfile) { if (file_exists(BASE_PATH . '/' . $installfile)) { @unlink(BASE_PATH . '/' . $installfile); } if (file_exists(BASE_PATH . '/' . $installfile)) { $unsuccessful[] = $installfile; } } if (isset($unsuccessful)) { $title->setValue("Unable to delete installation files"); $tempcontent = "<p style=\"margin: 1em 0\">Unable to delete installation files. Please delete the files below manually:</p><ul>"; foreach ($unsuccessful as $unsuccessfulFile) { $tempcontent .= "<li>{$unsuccessfulFile}</li>"; } $tempcontent .= "</ul>"; } else { $title->setValue("Deleted installation files"); $tempcontent = <<<HTML <p style="margin: 1em 0">Installation files have been successfully deleted.</p> HTML; } $tempcontent .= <<<HTML \t\t\t<p style="margin: 1em 0">You can start editing your site's content by opening <a href="admin/">the CMS</a>. <br /> \t\t\t\t Email: {$username}<br /> \t\t\t\t Password: {$password}<br /> \t\t\t</p> HTML; $content->setValue($tempcontent); return array("Title" => $title, "Content" => $content); }
public function forTemplate() { $items = array(); if ($this->value) { foreach ($this->value as $key => $item) { $v = new Varchar('Value'); $v->setValue($item); $obj = new ArrayData(array('Value' => $v, 'Key' => $key, 'Title' => $item)); $items[] = $obj; } } return new ArrayList($items); }
function deleteinstallfiles() { $title = new Varchar("Title"); $content = new HTMLText("Content"); $tempcontent = ''; $username = Session::get('username'); $password = Session::get('password'); $installfiles = array( 'index.php', 'install.php', 'rewritetest.php', 'config-form.css', 'config-form.html', 'index.html' ); foreach($installfiles as $installfile) { if(file_exists('../' . $installfile)) { @unlink('../' . $installfile); } if(file_exists('../' . $installfile)) { $unsuccessful[] = $installfile; } } if(isset($unsuccessful)) { $title->setValue("Unable to delete installation files"); $tempcontent = "<p style=\"margin: 1em 0\">Unable to delete installation files. Please delete the files below manually:</p><ul>"; foreach($unsuccessful as $unsuccessfulFile) { $tempcontent .= "<li>$unsuccessfulFile</li>"; } $tempcontent .= "</ul>"; } else { $title->setValue("Deleted installation files"); $tempcontent = <<<HTML <p style="margin: 1em 0">Installation files have been successfully deleted.</p> HTML ; } $tempcontent .= <<<HTML <p style="margin: 1em 0">You can start editing your site's content by opening <a href="admin/">the CMS</a>. <br /> Email: $username<br /> Password: $password<br /> </p> HTML ; $content->setValue($tempcontent); return array( "Title" => $title, "Content" => $content, ); }
/** * Returns the nice, human readable string for CIOnlineLinkage. * * @return string */ public function getCIOnlineLinkageNice() { $value = $this->CIOnlineLinkage; if (isset($value) && $value != '') { if (strpos($value, "://") === false) { $value = "http://" . $value; } } else { $value = MDCodeTypes::$default_for_null_value; } $varchar = new Varchar(1024); $varchar->setValue($value); return htmlentities($varchar->LimitCharacters(70)); }