public function setValue($value, $record = null) { if (!is_string($value)) { $value = json_encode($value); } return parent::setValue($value, $record); }
/** * Convert a single URL, assumes $url has been verified to be * a real URL * * @param string $url */ public function convertUrl($url) { $oembed = Oembed::get_oembed_from_url($url, false, $this->oembedOptions); if ($oembed) { return array('Title' => '', 'Content' => $oembed->forTemplate()); } $graph = OpenGraph::fetch($url); if ($graph) { foreach ($graph as $key => $value) { $data[$key] = Varchar::create_field('Varchar', $value); } if (isset($data['url'])) { return array('Title' => $graph->Title, 'Content' => MicroPost::create()->customise($data)->renderWith('OpenGraphPost')); } } // get the post and take its <title> tag at the very least $service = new RestfulService($url); $response = $service->request(); if ($response && $response->getStatusCode() == 200) { if (preg_match('/<title>(.*?)<\\/title>/is', $response->getBody(), $matches)) { $title = Convert::raw2xml(trim($matches[1])); return array('Title' => $title, 'Content' => "<a href='{$url}'>{$title}</a>"); } } }
public function prepValueForDB($value) { $value = parent::prepValueForDB($value); $ciphertext = $this->service->encrypt($value); $this->value = $ciphertext; return $ciphertext; }
/** * Returns the string which will be used in the template * @return string */ public function forTemplate() { $value = parent::forTemplate(); if (FrontendEditing::editingEnabled() && FrontendEditing::isEditable($this)) { $value = '<span class="frontend-editable frontend-editable-varchar" data-feclass="' . FrontendEditing::getClassName($this) . '" data-feid="' . FrontendEditing::getID($this) . '" data-fefield="' . $this->name . '">' . $value . '</span>'; } return $value; }
public function __construct($name, $size = 3, $options = array()) { parent::__construct($name, $size = 3, $options); }
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 __construct($name = null, $size = 7, $options = array()) { $this->size = $size ? $size : 7; parent::__construct($name, $size, $options); }
/** * @param string|null $name * @param array $options */ public function __construct($name = null, $options = array()) { // Size should probably be 40, but to avoid schema change leave for now parent::__construct($name, 255, $options); }
public function __construct($name, $size = 16) { parent::__construct($name, $size); }
public function MemberDetails() { $m = $this->securityContext->getMember(); if ($m) { return Varchar::create_field('Varchar', Convert::raw2json(array('Title' => $m->getTitle(), 'FirstName' => $m->FirstName, 'Surname' => $m->Surname, 'MemberID' => $m->ID))); } }
/** * Return all tags for the deployed commit. * * @return ArrayList */ public function getTags() { $commit = $this->Environment()->getCommit($this->SHA); if (!$commit) { return new ArrayList([]); } $tags = $this->Environment()->getCommitTags($commit); $returnTags = []; if (!empty($tags)) { foreach ($tags as $tag) { $field = Varchar::create('Tag', '255'); $field->setValue($tag->getName()); $returnTags[] = $field; } } return new ArrayList($returnTags); }
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, ); }
/** * Process and render search results */ function getSearchResults($data = null, $form = null) { $query = $this->owner->data()->getQuery(); $term = isset($_GET['Search']) ? Convert::raw2xml($_GET['Search']) : ''; $results = $query ? $query->getDataObjects(true) : ArrayList::create(); $elapsed = '< 0.001'; if ($query) { $resultData = array('TotalResults' => ($total = $query->getTotalResults()) ? $total : 0); $time = $query->getTimeTaken(); if ($time) { $elapsed = $time / 1000; } } else { $resultData = array(); } $data = array('Results' => $results, 'Query' => Varchar::create_field('Varchar', $term), 'Title' => $this->owner->data()->Title, 'ResultData' => ArrayData::create($resultData), 'TimeTaken' => $elapsed); return $data; }
/** * Return all tags for the deployed commit. * * @return ArrayList */ public function getTags() { $returnTags = array(); $repo = $this->getRepository(); if ($repo) { $tags = $repo->getReferences()->resolveTags($this->SHA); if (!empty($tags)) { foreach ($tags as $tag) { $field = Varchar::create('Tag', '255'); $field->setValue($tag->getName()); $returnTags[] = $field; } } } return new ArrayList($returnTags); }
public function hasValue() { return parent::hasValue() && $this->value != '<p></p>'; }
public function exists() { return parent::exists() && $this->value != '<p></p>'; }
public function __construct($name = null, $options = array()) { parent::__construct($name, 6, $options); }
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()); }
/** * 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)); }