Commit f694e057 authored by Ad Schellevis's avatar Ad Schellevis

* documentation tag fixures to better support phpDocumentor

* initial model implementation using Phalcon validators and custom binding to config object

Still a lot to dow here, no impact on current install base
parent b3fea6b9
<?php <?php
/* /**
# Copyright (C) 2015 Deciso B.V. * Copyright (C) 2015 Deciso B.V.
# *
# All rights reserved. * All rights reserved.
# *
# Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
# *
# 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
# *
# 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
# *
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*
-------------------------------------------------------------------------------------- */
package : Frontend Controller Base
function: implements core controller for OPNsense framework
*/
namespace OPNsense\Base; namespace OPNsense\Base;
use Phalcon\Mvc\Controller; use Phalcon\Mvc\Controller;
/**
* Class ControllerBase implements core controller for OPNsense framework
* @package OPNsense\Base
*/
class ControllerBase extends Controller class ControllerBase extends Controller
{ {
/** /**
......
<?php <?php
/* /**
# Copyright (C) 2015 Deciso B.V. * Copyright (C) 2015 Deciso B.V.
# *
# All rights reserved. * All rights reserved.
# *
# Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
# *
# 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
# *
# 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
# *
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*
-------------------------------------------------------------------------------------- */
package : Frontend Index Controller
function: implements base index controller, shared functionality
*/
namespace OPNsense\Base; namespace OPNsense\Base;
/**
* Class IndexController
* @package OPNsense\Base
*/
class IndexController extends \OPNsense\Base\ControllerBase class IndexController extends \OPNsense\Base\ControllerBase
{ {
......
<?php <?php
/* /**
# Copyright (C) 2015 Deciso B.V. * Copyright (C) 2015 Deciso B.V.
# *
# All rights reserved. * All rights reserved.
# *
# Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
# *
# 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
# *
# 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
# *
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*
-------------------------------------------------------------------------------------- */
package : Index controller for core package namespace OPNsense\Core;
*/
namespace OPNsense\Core;
/**
* Class IndexController Index controller for core package
* @package OPNsense\Core
*/
class IndexController extends \OPNsense\Base\IndexController class IndexController extends \OPNsense\Base\IndexController
{ {
public function indexAction() public function indexAction()
......
<?php <?php
/* /**
# Copyright (C) 2015 Deciso B.V. * Copyright (C) 2015 Deciso B.V.
# *
# All rights reserved. * All rights reserved.
# *
# Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
# *
# 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
# *
# 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
# *
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*
-------------------------------------------------------------------------------------- */
*/
namespace OPNsense\Sample; namespace OPNsense\Sample;
/**
* Class IndexController
* @package OPNsense\Sample
*/
class IndexController extends \OPNsense\Base\IndexController class IndexController extends \OPNsense\Base\IndexController
{ {
public function indexAction() public function indexAction()
......
<?php <?php
/* /**
# Copyright (C) 2015 Deciso B.V. * Copyright (C) 2015 Deciso B.V.
# *
# All rights reserved. * All rights reserved.
# *
# Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
# *
# 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
# *
# 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
# *
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*
-------------------------------------------------------------------------------------- */
*/
namespace OPNsense\Sample; namespace OPNsense\Sample;
use Phalcon\Mvc\Controller; use Phalcon\Mvc\Controller;
use \OPNsense\Base\ControllerBase; use \OPNsense\Base\ControllerBase;
/**
* Class PageController
* @package OPNsense\Sample
*/
class PageController extends ControllerBase class PageController extends ControllerBase
{ {
public function indexAction() public function indexAction()
......
<?php <?php
/* /**
# Copyright (C) 2015 Deciso B.V. * Copyright (C) 2015 Deciso B.V.
# *
# All rights reserved. * All rights reserved.
# *
# Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
# *
# 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
# *
# 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
# *
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*
-------------------------------------------------------------------------------------- */
package : Frontend Model Base
function:
*/
namespace OPNsense\Base\FieldTypes; namespace OPNsense\Base\FieldTypes;
/**
* Class ArrayField
* @package OPNsense\Base\FieldTypes
*/
class ArrayField extends BaseField class ArrayField extends BaseField
{ {
/** /**
* @var bool is this array empty ( only filled with defaults) * add Childnode (list), ignore the name of this item
*/ * @param string $name property name
private $internalEmptyStatus = false; * @param BaseField $node content (must be of type BaseField)
/**
* add Childnode (list)
* @param $name property name
* @param $node content (must be of type BaseField)
*/ */
public function addChildNode($name, $node) public function addChildNode($name, $node)
{ {
if ($name == null) {
// index item
$this->internalChildnodes[] = $node; $this->internalChildnodes[] = $node;
} else {
$this->internalChildnodes[$name] = $node;
}
}
/**
* @return bool is empty array (only filled for template structure)
*/
public function isEmpty()
{
return $this->internalEmptyStatus;
}
/**
* @param $status|bool set empty (status boolean)
*/
public function setInternalEmptyStatus($status)
{
$this->internalEmptyStatus = $status ;
} }
} }
\ No newline at end of file
<?php <?php
/* /**
# Copyright (C) 2015 Deciso B.V. * Copyright (C) 2015 Deciso B.V.
# *
# All rights reserved. * All rights reserved.
# *
# Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
# *
# 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
# *
# 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
# *
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*
-------------------------------------------------------------------------------------- */
package : Frontend Model Base
function:
*/
namespace OPNsense\Base\FieldTypes; namespace OPNsense\Base\FieldTypes;
/**
* Class BaseField
* @package OPNsense\Base\FieldTypes
*/
abstract class BaseField abstract class BaseField
{ {
/** /**
...@@ -55,11 +56,27 @@ abstract class BaseField ...@@ -55,11 +56,27 @@ abstract class BaseField
*/ */
protected $internalReference = ""; protected $internalReference = "";
/**
* @var string tag name for this object, either the last part of the reference.
*/
protected $internalXMLTagName = "";
/**
* @var bool is this a required attribute?
*/
protected $internalIsRequired = false ;
/** /**
* @var string validation message string * @var string validation message string
*/ */
protected $internalValidationMessage = null; protected $internalValidationMessage = null;
/**
* @var bool node (and subnodes) is virtual
*/
protected $internalIsVirtual = false ;
/** /**
* @return bool returns if this a container type object (no data) * @return bool returns if this a container type object (no data)
*/ */
...@@ -71,15 +88,18 @@ abstract class BaseField ...@@ -71,15 +88,18 @@ abstract class BaseField
/** /**
* default constructor * default constructor
* @param null|string $ref direct reference to this object * @param null|string $ref direct reference to this object
* @param null|string $tagname xml tagname to use
*/ */
public function __construct($ref = null) public function __construct($ref = null, $tagname = null)
{ {
$this->internalReference = $ref; $this->internalReference = $ref;
$this->internalXMLTagName = $tagname;
} }
/** /**
* @param $name property name * Add a childnode to this node.
* @param $node content (must be of type BaseField) * @param string $name property name
* @param BaseField $node content (must be of type BaseField)
*/ */
public function addChildNode($name, $node) public function addChildNode($name, $node)
{ {
...@@ -89,7 +109,7 @@ abstract class BaseField ...@@ -89,7 +109,7 @@ abstract class BaseField
/** /**
* Reflect default getter to internal child nodes. * Reflect default getter to internal child nodes.
* Implements the special attribute __items to return all items and __reference to identify the field in this model. * Implements the special attribute __items to return all items and __reference to identify the field in this model.
* @param $name property name * @param string $name property name
* @return mixed * @return mixed
*/ */
public function __get($name) public function __get($name)
...@@ -97,7 +117,14 @@ abstract class BaseField ...@@ -97,7 +117,14 @@ abstract class BaseField
if (array_key_exists($name, $this->internalChildnodes)) { if (array_key_exists($name, $this->internalChildnodes)) {
return $this->internalChildnodes[$name]; return $this->internalChildnodes[$name];
} elseif ($name == '__items') { } elseif ($name == '__items') {
return $this->internalChildnodes; // return all (no virtual/hidden) items
$result = array();
foreach ($this->internalChildnodes as $key => $value) {
if ($value->internalIsVirtual == false) {
$result[$key] = $value ;
}
}
return $result;
} elseif ($name == '__reference') { } elseif ($name == '__reference') {
return $this->internalReference; return $this->internalReference;
} else { } else {
...@@ -109,8 +136,8 @@ abstract class BaseField ...@@ -109,8 +136,8 @@ abstract class BaseField
/** /**
* reflect default setter to internal child nodes * reflect default setter to internal child nodes
* @param $name|string property name * @param string $name property name
* @param $value|string property value * @param string $value property value
*/ */
public function __set($name, $value) public function __set($name, $value)
{ {
...@@ -119,6 +146,9 @@ abstract class BaseField ...@@ -119,6 +146,9 @@ abstract class BaseField
} }
} }
/**
* @return null|string string interpretation of this field
*/
public function __toString() public function __toString()
{ {
return $this->internalValue; return $this->internalValue;
...@@ -126,7 +156,7 @@ abstract class BaseField ...@@ -126,7 +156,7 @@ abstract class BaseField
/** /**
* default setter * default setter
* @param $value set field value * @param string $value set field value
*/ */
public function setValue($value) public function setValue($value)
{ {
...@@ -142,8 +172,78 @@ abstract class BaseField ...@@ -142,8 +172,78 @@ abstract class BaseField
} }
/** /**
* set Default field value * @return array returns validators for this field type (empty if none)
* @param $value default value */
public function getValidators()
{
return array();
}
/**
* Mark this node as virtual, only used as template for structure behind it.
* Used for array structures.
*/
public function setInternalIsVirtual()
{
$this->internalIsVirtual = true;
}
/**
* getter for internal tag name
* @return null|string xml tagname to use
*/
public function getInternalXMLTagName()
{
return $this->internalXMLTagName;
}
/**
* Recursive method to flatten tree structure for easy validation.
* @return array named array with field type nodes, using the internal reference.
*/
public function getFlatNodes()
{
$result = array ();
if (count($this->internalChildnodes) == 0) {
return array($this);
}
foreach ($this->__items as $node) {
foreach ($node->getFlatNodes() as $childNode) {
$result[$childNode->internalReference] = $childNode ;
}
}
return $result;
}
/**
* Add this node and it's children to the supplied simplexml node pointer.
* @param \SimpleXMLElement $node target node
*/
public function addToXMLNode($node)
{
if ($this->internalReference == "" || get_class($this) == "OPNsense\\Base\\FieldTypes\\ArrayField") {
// ignore tags without internal reference (root) and ArrayTypes
$subnode = $node ;
} else {
if ($this->internalValue != "") {
$subnode = $node->addChild($this->getInternalXMLTagName(), $this->internalValue);
} else {
$subnode = $node->addChild($this->getInternalXMLTagName());
}
}
foreach ($this->__items as $key => $FieldNode) {
$FieldNode->addToXMLNode($subnode);
}
}
/**
* set Default field value ( for usage in model xml )
* @param string $value default value
*/ */
public function setDefault($value) public function setDefault($value)
{ {
...@@ -151,7 +251,8 @@ abstract class BaseField ...@@ -151,7 +251,8 @@ abstract class BaseField
} }
/** /**
* @param $msg validation message (on failure) * set Validation message ( for usage in model xml )
* @param string $msg validation message (on failure)
*/ */
public function setValidationMessage($msg) public function setValidationMessage($msg)
{ {
...@@ -159,11 +260,16 @@ abstract class BaseField ...@@ -159,11 +260,16 @@ abstract class BaseField
} }
/** /**
* @return array returns validators for this field type (empty if none) * Implements required property, the base class only implements the setter.
* The implemented fieldtype should include the correct validation.
* @param string $value set if this node/field is required (Y/N)
*/ */
public function getValidators() public function setRequired($value)
{ {
return array(); if (strtoupper(trim($value)) == "Y") {
$this->internalIsRequired = true;
} else {
$this->internalIsRequired = false;
}
} }
}
}
\ No newline at end of file
<?php <?php
/* /**
# Copyright (C) 2015 Deciso B.V. * Copyright (C) 2015 Deciso B.V.
# *
# All rights reserved. * All rights reserved.
# *
# Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
# *
# 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
# *
# 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
# *
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*
-------------------------------------------------------------------------------------- */
package : Frontend Model Base
function:
*/
namespace OPNsense\Base\FieldTypes; namespace OPNsense\Base\FieldTypes;
/**
* Class ContainerField
* @package OPNsense\Base\FieldTypes
*/
class ContainerField extends BaseField class ContainerField extends BaseField
{ {
} }
\ No newline at end of file
<?php <?php
/* /**
# Copyright (C) 2015 Deciso B.V. * Copyright (C) 2015 Deciso B.V.
# *
# All rights reserved. * All rights reserved.
# *
# Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
# *
# 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
# *
# 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
# *
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*
*/
--------------------------------------------------------------------------------------
package : Frontend Model Base
function: Email field type
*/
namespace OPNsense\Base\FieldTypes; namespace OPNsense\Base\FieldTypes;
use Phalcon\Validation\Validator\Email; use Phalcon\Validation\Validator\Email;
/**
* Class EmailField
* @package OPNsense\Base\FieldTypes
*/
class EmailField extends BaseField class EmailField extends BaseField
{ {
/** /**
...@@ -51,7 +52,12 @@ class EmailField extends BaseField ...@@ -51,7 +52,12 @@ class EmailField extends BaseField
} else { } else {
$msg = $this->internalValidationMessage; $msg = $this->internalValidationMessage;
} }
return array(new Email(array('message' => $msg))); if ($this->internalIsRequired == true || $this->internalValue != null) {
} return array(new Email(array('message' => $msg)));
} else {
// empty field and not required, skip this validation.
return array();
}
} }
\ No newline at end of file }
<?php <?php
/* /**
# Copyright (C) 2015 Deciso B.V. * Copyright (C) 2015 Deciso B.V.
# *
# All rights reserved. * All rights reserved.
# *
# Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
# *
# 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
# *
# 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
# *
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*
-------------------------------------------------------------------------------------- */
package : Frontend Model Base
function:
*/
namespace OPNsense\Base\FieldTypes; namespace OPNsense\Base\FieldTypes;
/**
* Class TextField
* @package OPNsense\Base\FieldTypes
*/
class TextField extends BaseField class TextField extends BaseField
{ {
/** /**
...@@ -46,10 +46,10 @@ class TextField extends BaseField ...@@ -46,10 +46,10 @@ class TextField extends BaseField
/** /**
* set validation mask * set validation mask
* @param $value regexp validation mask * @param string $value regexp validation mask
*/ */
public function setMask($value) public function setMask($value)
{ {
$this->internalMask = $value ; $this->internalMask = $value ;
} }
} }
\ No newline at end of file
<?php <?php
/* /**
# Copyright (C) 2015 Deciso B.V. * Copyright (C) 2015 Deciso B.V.
# *
# All rights reserved. * All rights reserved.
# *
# Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
# *
# 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
# *
# 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
# *
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*
-------------------------------------------------------------------------------------- */
package : Frontend Model Base
function: Basic Exception class for Model initialization
*/
namespace OPNsense\Base; namespace OPNsense\Base;
/** /**
* Class BaseModelException * Class BaseModelException for Model initialization
* @package Base * @package Base
*/ */
class ModelException extends \Exception class ModelException extends \Exception
{ {
} }
\ No newline at end of file
<?php <?php
/* /**
# Copyright (C) 2014 Deciso B.V. * Copyright (C) 2015 Deciso B.V.
# *
# All rights reserved. * All rights reserved.
# *
# Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
# *
# 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
# *
# 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
# *
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*
-------------------------------------------------------------------------------------- */
package : Captive portal
function: provides access to the systems ARP table
*/
namespace OPNsense\CaptivePortal; namespace OPNsense\CaptivePortal;
use \OPNsense\Core; use \OPNsense\Core;
/**
* Class ARP provides access to the systems ARP table
* @package OPNsense\CaptivePortal
*/
class ARP class ARP
{ {
...@@ -53,8 +53,8 @@ class ARP ...@@ -53,8 +53,8 @@ class ARP
/** /**
* set static arp entry * set static arp entry
* @param $ipaddress hosts ipaddress * @param $ipaddress|string hosts ipaddress
* @param $mac hosts physical address * @param $mac|string hosts physical address
*/ */
public function setStatic($ipaddress, $mac) public function setStatic($ipaddress, $mac)
{ {
...@@ -68,7 +68,7 @@ class ARP ...@@ -68,7 +68,7 @@ class ARP
/** /**
* drop static arp entry * drop static arp entry
* @param $ipaddress hosts ipaddress * @param $ipaddress|string hosts ipaddress
*/ */
public function dropStatic($ipaddress) public function dropStatic($ipaddress)
{ {
......
<?php <?php
/* /**
# Copyright (C) 2014 Deciso B.V. * Copyright (C) 2015 Deciso B.V.
# *
# All rights reserved. * All rights reserved.
# *
# Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
# *
# 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
# *
# 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
#— *
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*
-------------------------------------------------------------------------------------- */
package : Captive portal
function: main package for captive portal backend functionality
*/
namespace OPNsense\CaptivePortal; namespace OPNsense\CaptivePortal;
use \Phalcon\Logger\Adapter\Syslog; use \Phalcon\Logger\Adapter\Syslog;
...@@ -39,7 +33,7 @@ use \Phalcon\DI\FactoryDefault; ...@@ -39,7 +33,7 @@ use \Phalcon\DI\FactoryDefault;
use \OPNsense\Core; use \OPNsense\Core;
/** /**
* Class CPClient * Class CPClient main class for captive portal backend functionality
* // TODO: CARP interfaces are probably not handled correctly * // TODO: CARP interfaces are probably not handled correctly
* @package CaptivePortal * @package CaptivePortal
*/ */
...@@ -79,7 +73,7 @@ class CPClient ...@@ -79,7 +73,7 @@ class CPClient
/** /**
* reset traffic counters * reset traffic counters
* *
* @param null $rulenum * @param string|null $rulenum
*/ */
public function zeroCounters($rulenum = null) public function zeroCounters($rulenum = null)
{ {
...@@ -136,7 +130,7 @@ class CPClient ...@@ -136,7 +130,7 @@ class CPClient
/** /**
* update zone(s) with new configuration data * update zone(s) with new configuration data
* @param string $zone * @param string|null $zone
*/ */
public function update($zone = null) public function update($zone = null)
{ {
...@@ -146,7 +140,7 @@ class CPClient ...@@ -146,7 +140,7 @@ class CPClient
/** /**
* refresh allowed ip's for defined zone ( null for all zones ) * refresh allowed ip's for defined zone ( null for all zones )
* @param string $cpzone * @param string|null $cpzone
*/ */
public function refreshAllowedIPs($cpzone = null) public function refreshAllowedIPs($cpzone = null)
{ {
...@@ -256,7 +250,7 @@ class CPClient ...@@ -256,7 +250,7 @@ class CPClient
* To be able to grant access to physical pc's, we need to do some administration. * To be able to grant access to physical pc's, we need to do some administration.
* Our captive portal database keeps a list of every used address and last know mac address * Our captive portal database keeps a list of every used address and last know mac address
* *
* @param string $cpzone zone name or number * @param string|null $cpzone zone name or number
*/ */
public function refreshAllowedMACs($cpzone = null) public function refreshAllowedMACs($cpzone = null)
{ {
...@@ -450,14 +444,14 @@ class CPClient ...@@ -450,14 +444,14 @@ class CPClient
* @param string $clientip * @param string $clientip
* @param string $clientmac * @param string $clientmac
* @param string $username * @param string $username
* @param string $password * @param string|null $password
* @param string $bw_up * @param string|null $bw_up
* @param string $bw_down * @param string|null $bw_down
* @param string $radiusctx * @param string|null $radiusctx
* @param int $session_timeout * @param int|null $session_timeout
* @param int $idle_timeout * @param int|null $idle_timeout
* @param int $session_terminate_time * @param int|null $session_terminate_time
* @param int $interim_interval * @param int|null $interim_interval
* @return bool|string * @return bool|string
*/ */
public function portalAllow( public function portalAllow(
...@@ -601,7 +595,7 @@ class CPClient ...@@ -601,7 +595,7 @@ class CPClient
/** /**
* flush zone (null flushes all zones) * flush zone (null flushes all zones)
* @param string $zone zone name or id * @param string|null $zone zone name or id
*/ */
public function flush($zone = null) public function flush($zone = null)
{ {
...@@ -638,7 +632,7 @@ class CPClient ...@@ -638,7 +632,7 @@ class CPClient
/** /**
* cleanup portal sessions * cleanup portal sessions
* @param $cpzone zone name * @param $cpzone|null zone name
*/ */
public function portalCleanupSessions($cpzone = null) public function portalCleanupSessions($cpzone = null)
{ {
...@@ -711,7 +705,7 @@ class CPClient ...@@ -711,7 +705,7 @@ class CPClient
/** /**
* list (ipfw) accounting information * list (ipfw) accounting information
* @param string $ipaddr ip address * @param string|null $ipaddr ip address
* @return array (key = hosts ip) * @return array (key = hosts ip)
*/ */
public function listAccounting($ipaddr = null) public function listAccounting($ipaddr = null)
...@@ -747,7 +741,7 @@ class CPClient ...@@ -747,7 +741,7 @@ class CPClient
/** /**
* disconnect a session or a list of sessions depending on the parameter * disconnect a session or a list of sessions depending on the parameter
* @param string $cpzonename zone name or id * @param string $cpzonename zone name or id
* @param string $sessionid * @param string $sessionid session id
*/ */
public function disconnect($cpzonename, $sessionid) public function disconnect($cpzonename, $sessionid)
{ {
......
<?php <?php
/* /**
# Copyright (C) 2014 Deciso B.V. * Copyright (C) 2015 Deciso B.V.
# *
# All rights reserved. * All rights reserved.
# *
# Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
# *
# 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
# *
# 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
# *
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*
-------------------------------------------------------------------------------------- */
package : Captive portal
function: provides access to the captiveportal internal administration ( one sqllite db per zone )
*/
namespace OPNsense\CaptivePortal; namespace OPNsense\CaptivePortal;
use \Phalcon\DI\FactoryDefault; use \Phalcon\DI\FactoryDefault;
...@@ -38,7 +33,7 @@ use \Phalcon\Db\Adapter\Pdo\Sqlite; ...@@ -38,7 +33,7 @@ use \Phalcon\Db\Adapter\Pdo\Sqlite;
use \Phalcon\Logger\Adapter\Syslog; use \Phalcon\Logger\Adapter\Syslog;
/** /**
* Class DB, handles captive portal zone's adminstration * Class DB, provides access to the captiveportal internal administration ( one sqllite db per zone )
* @package CaptivePortal * @package CaptivePortal
*/ */
class DB class DB
......
<?php <?php
/* /**
# Copyright (C) 2014 Deciso B.V. * Copyright (C) 2015 Deciso B.V.
# *
# All rights reserved. * All rights reserved.
# *
# Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
# *
# 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
# *
# 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
# *
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*
-------------------------------------------------------------------------------------- */
package : Captive portal
function: provides ipfw handling
*/
namespace OPNsense\CaptivePortal; namespace OPNsense\CaptivePortal;
use OPNsense\Core; use OPNsense\Core;
/** /**
* Class Rules * Class Rules provides ipfw handling
* @package CaptivePortal * @package CaptivePortal
*/ */
class Rules class Rules
......
<?php <?php
/* /**
# Copyright (C) 2014 Deciso B.V. * Copyright (C) 2015 Deciso B.V.
# *
# All rights reserved. * All rights reserved.
# *
# Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
# *
# 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
# *
# 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
# *
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*
-------------------------------------------------------------------------------------- */
package : Core
function: provides access to systems config xml
*/
namespace OPNsense\Core; namespace OPNsense\Core;
use \Phalcon\DI\FactoryDefault; use \Phalcon\DI\FactoryDefault;
/** /**
* Class Config * Class Config provides access to systems config xml
* @package Core * @package Core
*/ */
class Config extends Singleton class Config extends Singleton
...@@ -51,7 +45,7 @@ class Config extends Singleton ...@@ -51,7 +45,7 @@ class Config extends Singleton
/** /**
* XMLDocument type reference to config * XMLDocument type reference to config
* @var XMLDocument * @var \DOMDocument
*/ */
private $configxml = null ; private $configxml = null ;
...@@ -113,13 +107,13 @@ class Config extends Singleton ...@@ -113,13 +107,13 @@ class Config extends Singleton
} }
} }
/*
* parse configuration and dump to std output (test) /**
* @param DOMElement $node * Execute a xpath expression on config.xml
* @param string $nodename * @param $query
* @return \DOMNodeList
* @throws ConfigException * @throws ConfigException
*/ */
public function xpath($query) public function xpath($query)
{ {
$this->checkvalid(); $this->checkvalid();
...@@ -127,24 +121,35 @@ class Config extends Singleton ...@@ -127,24 +121,35 @@ class Config extends Singleton
return $xpath->query($query); return $xpath->query($query);
} }
/*
* init new config object, try to load current configuration
* (executed via Singleton)
*/
/**
* object representation of xml document via simplexml, references the same underlying model
* @return SimpleXML
* @throws ConfigException
*/
public function object() public function object()
{ {
$this->checkvalid(); $this->checkvalid();
return $this->simplexml; return $this->simplexml;
} }
/* /**
* Execute a xpath expression on config.xml * get DOMDocument
* @param $query * @return XMLDocument
* @return \DOMNodeList
* @throws ConfigException * @throws ConfigException
*/ */
public function getDOM()
{
$this->checkvalid();
return $this->configxml;
}
/**
* init new config object, try to load current configuration
* (executed via Singleton)
*/
protected function init() protected function init()
{ {
$this->config_file = FactoryDefault::getDefault()->get('config')->globals->config_path . "config.xml"; $this->config_file = FactoryDefault::getDefault()->get('config')->globals->config_path . "config.xml";
...@@ -156,11 +161,6 @@ class Config extends Singleton ...@@ -156,11 +161,6 @@ class Config extends Singleton
} }
/*
* object representation of xml document via simplexml, references the same underlying model
* @return SimpleXML
* @throws ConfigException
*/
/** /**
* Load config file * Load config file
...@@ -177,10 +177,25 @@ class Config extends Singleton ...@@ -177,10 +177,25 @@ class Config extends Singleton
throw new ConfigException('empty file') ; throw new ConfigException('empty file') ;
} }
$this->configxml = new \DOMDocument; $this->configxml = new \DOMDocument('1.0');
$this->configxml->loadXML($xml); $this->configxml->loadXML($xml);
$this->simplexml = simplexml_import_dom($this->configxml); $this->simplexml = simplexml_import_dom($this->configxml);
$this->isValid = true; $this->isValid = true;
} }
/**
* @return mixed return xml text representation of this config
*/
public function __toString()
{
// reformat XML (pretty print)
$dom = new \DOMDocument;
$dom->formatOutput = true;
$dom->preserveWhiteSpace = false;
$dom->loadXML($this->configxml->saveXML());
return $dom->saveXML();
}
} }
<?php <?php
/** /**
* Created by PhpStorm. * Copyright (C) 2015 Deciso B.V.
* User: ad *
* Date: 04-01-15 * All rights reserved.
* Time: 20:06 *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/ */
namespace OPNsense\Core;
namespace app\models\OPNsense\Core;
/** /**
* Class ConfigException * Class ConfigException
......
<?php <?php
/* /**
# Copyright (C) 2014 Deciso B.V. * Copyright (C) 2015 Deciso B.V.
# *
# All rights reserved. * All rights reserved.
# *
# Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
# *
# 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
# *
# 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
# *
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*
-------------------------------------------------------------------------------------- */
package : Core
function: shell/command handling routines
*/
namespace OPNsense\Core; namespace OPNsense\Core;
use \Phalcon\DI\FactoryDefault; use \Phalcon\DI\FactoryDefault;
/**
* Class Shell shell/command handling routines
* @package OPNsense\Core
*/
class Shell class Shell
{ {
......
<?php <?php
/* /**
# Copyright (C) 2014 Deciso B.V. * Copyright (C) 2015 Deciso B.V.
# *
# All rights reserved. * All rights reserved.
# *
# Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
# *
# 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
# *
# 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
# *
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*
-------------------------------------------------------------------------------------- */
package : Core
function: provides singleton pattern
*/
namespace OPNsense\Core; namespace OPNsense\Core;
/** /**
* Class Singleton * Class Singleton provides singleton pattern, be careful with usage.
* @package Core * @package Core
*/ */
abstract class Singleton abstract class Singleton
......
<?php <?php
/* /**
# Copyright (C) 2015 Deciso B.V. * Copyright (C) 2015 Deciso B.V.
# *
# All rights reserved. * All rights reserved.
# *
# Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
# *
# 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
# *
# 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
# *
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*
-------------------------------------------------------------------------------------- */
*/
namespace OPNsense\Sample; namespace OPNsense\Sample;
use OPNsense\Base\BaseModel; use OPNsense\Base\BaseModel;
class Sample extends BaseModel class Sample extends BaseModel
{ {
// protected function init()
// {
// print("\nxXx\n");
// }
} }
<model> <model>
<mount>//test/sample</mount> <mount>//test/sample</mount>
<description> <description>
Sample model Sample model.
The mountpoint is a reference to the config.xml file and this part (ROOT/test/sample)
should only be used by this model.
By defining full sections per model we should avoid clashes and keep serializing data back.
</description> </description>
<items> <items>
<tag1 type="TextField"> <tag1 type="TextField">
...@@ -21,10 +24,12 @@ ...@@ -21,10 +24,12 @@
<node1 type="TextField"/> <node1 type="TextField"/>
<node2 type="TextField"/> <node2 type="TextField"/>
</section> </section>
</childnodes>
<childnodes1>
<section1 type="ArrayField"> <section1 type="ArrayField">
<nodeX type="TextField"></nodeX> <nodeX type="TextField"></nodeX>
<nodeZ type="TextField"></nodeZ> <nodeZ type="TextField"></nodeZ>
</section1> </section1>
</childnodes> </childnodes1>
</items> </items>
</model> </model>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment