"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/Data.php" between
canopy-3.0.4.tar.gz and canopy-3.0.5.tar.gz

About: Canopy provides a complete web site content management system (successor of "phpwebsite").

Data.php  (canopy-3.0.4):Data.php  (canopy-3.0.5)
<?php <?php
namespace Canopy; namespace Canopy;
/** /**
* Foundation abstract class for any data type object. Note: for overload to wor k * Foundation abstract class for any data type object. Note: for overload to wor k
* all variables in the parent object have to be protected. * all variables in the parent object have to be protected.
* *
* @author Matthew McNaney <mcnaneym@appstate.edu> * @author Matthew McNaney <mcnaneym@appstate.edu>
* @package phpws2 * @package phpws2
* @subpackage Form * @subpackage Form
* @license http://opensource.org/licenses/lgpl-3.0.html * @license http://opensource.org/licenses/lgpl-3.0.html
skipping to change at line 376 skipping to change at line 377
* @param array $vars * @param array $vars
* @throws \Exception * @throws \Exception
*/ */
public function setVars(Array $vars) public function setVars(Array $vars)
{ {
foreach ($vars as $key => $value) { foreach ($vars as $key => $value) {
if (!property_exists($this, $key)) { if (!property_exists($this, $key)) {
throw new \Exception(sprintf('Parameter "%s" does not exist or c annot be set in class %s', throw new \Exception(sprintf('Parameter "%s" does not exist or c annot be set in class %s',
$key, get_class($this))); $key, get_class($this)));
} }
if (!$this->isPrivate($key) && is_a($this->$key, '\phpws2\Variable')
) { if (is_a($this->$key, '\phpws2\Variable')) {
if (!is_null($value)) {
$this->$key->set($value);
}
} elseif (!$this->isPublic($key)) {
$func = self::walkingCase($key, 'set'); $func = self::walkingCase($key, 'set');
if (method_exists($this, $func)) { if (method_exists($this, $func)) {
$this->$func($value); $this->$func($value);
} elseif ($this->isProtected($key)) {
$this->$key = $value;
} else { } else {
throw new \Exception(sprintf('Parameter "%s" does not exist $this->$key->set($value);
or cannot be set in class %s',
$key, get_class($this)));
} }
} else { } elseif (!$this->isPrivate($key)) {
$this->$key = $value; $this->$key = $value;
} else {
throw new \Exception(sprintf('Parameter "%s" does not exist or c
annot be set in class %s',
$key, get_class($this)));
} }
} }
} }
/** /**
* Translate a variable with underlines into a walking case variable. * Translate a variable with underlines into a walking case variable.
* Example: echo walkingCase('foo_bar'); * Example: echo walkingCase('foo_bar');
* // fooBar * // fooBar
* *
* A prefix will be added to the front of the string. * A prefix will be added to the front of the string.
skipping to change at line 454 skipping to change at line 452
/** /**
* Creates a php file containing the current object's values * Creates a php file containing the current object's values
* @param string $file_path * @param string $file_path
* @param boolean $allow_overwrite * @param boolean $allow_overwrite
* @return boolean * @return boolean
*/ */
public function write($file_path, $allow_overwrite = false) public function write($file_path, $allow_overwrite = false)
{ {
if ((!$allow_overwrite && is_file($file_path))) { if ((!$allow_overwrite && is_file($file_path))) {
throw new \Exception(sprintf('Cannot overwrite file at %s', $file_pa throw new \Exception(sprintf('Cannot overwrite file at %s',
th)); $file_path));
} }
if (!is_writable(dirname($file_path))) { if (!is_writable(dirname($file_path))) {
throw new \Exception(sprintf('Cannot write file to directory "%s"', throw new \Exception(sprintf('Cannot write file to directory "%s"',
dirname($file_path) . '/')); dirname($file_path) . '/'));
} }
$vars = $this->getVars(); $vars = $this->getVars();
$content[] = "<?php $content[] = "<?php
skipping to change at line 478 skipping to change at line 477
if ($value instanceof Variable) { if ($value instanceof Variable) {
$content[] = $value->getPHP(); $content[] = $value->getPHP();
} elseif (is_array($value)) { } elseif (is_array($value)) {
$content[] = sprintf('$%s = \'%s\';', $key, print_r($value)); $content[] = sprintf('$%s = \'%s\';', $key, print_r($value));
} else { } else {
$content[] = sprintf('$%s = \'%s\';', $key, $value); $content[] = sprintf('$%s = \'%s\';', $key, $value);
} }
} }
$content[] = "?>"; $content[] = "?>";
if (!file_put_contents($file_path, implode("\n", $content))) { if (!file_put_contents($file_path, implode("\n", $content))) {
throw new \Exception(sprintf('Could not write file to %s', $file_pat throw new \Exception(sprintf('Could not write file to %s',
h)); $file_path));
} }
return true; return true;
} }
/** /**
* Returns the last class from the current object, normally excluding the * Returns the last class from the current object, normally excluding the
* namespace. * namespace.
* @return mixed * @return mixed
*/ */
public function popClass($pop_number = 1) public function popClass($pop_number = 1)
 End of changes. 8 change blocks. 
16 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)