/** * Overload Sprig::update() to save revision change * @param bump whether to bump the version number */ public function update($bump = TRUE) { Kohana::$log->add(Kohana::DEBUG, 'Executing Versioned_Sprig::update'); $updated = FALSE; foreach ($this->_fields as $field => $object) { if ($object instanceof Sprig_Field_Tracked and $this->changed($field)) { $this->comment = UTF8::ucwords($object->label) . ' changed from "' . $this->_original[$field] . '" to "' . $this->_changed[$field] . '".'; } if ($object instanceof Sprig_Field_Versioned and $this->changed($field) and $bump) { $diff = ''; if ($this->version != 0) { $diff = Versioned::diff($this->_original[$field], $this->_changed[$field]); $diff = Versioned::clean_array($diff); $diff = serialize($diff); } $this->version++; $revision = Sprig::factory($this->_model . '_revision'); $revision->values(array('entry' => $this->id, 'version' => $this->version, 'editor' => $this->editor, 'diff' => $diff)); $revision->comments = $this->comments; $revision->create(); $updated = TRUE; $this->comments = array(); } } if (!$updated and count($this->comments) > 0) { $revision = Sprig::factory($this->_model . '_revision'); $revision->entry = $this->id; $revision->version = $this->version; $revision->load(); $revision->comments = array_merge($revision->comments, $this->comments); $revision->update(); } return parent::update(); }
/** * Tests UTF8::ucwords * * @test * @dataProvider provider_ucwords */ public function test_ucwords($input, $expected) { $this->assertSame($expected, UTF8::ucwords($input)); }
/** * Humanize * * Takes multiple words separated by the separator and changes them to spaces * * @param string $str Input string * @param string $separator Input separator * @return string */ function humanize($str, $separator = '_') { return UTF8::ucwords(preg_replace('/[' . preg_quote($separator) . ']+/' . (IS_UTF8_CHARSET && PCRE_UTF8_INSTALLED ? 'u' : ''), ' ', UTF8::trim(UTF8::strtolower($str)))); }
public function label($name, array $attr = NULL) { return Form::label($name, UTF8::ucwords($this->label), $attr); }
public function label($name, array $attr = NULL) { if (is_array($this->label)) { if (isset($this->label[2])) { $attr = $this->label[2]; } if (isset($this->label[1]) and is_bool($this->label[1])) { $autoformat = $this->label[1]; } else { $autoformat = TRUE; } if ($autoformat) { return Form::label($name, html::chars(UTF8::ucwords($this->label[0])), $attr); } else { return Form::label($name, $this->label[0], $attr); } } else { return Form::label($name, UTF8::ucwords($this->label), $attr); } }