1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381:
<?php
namespace Nethgui\System;
/*
* Copyright (C) 2011 Nethesis S.r.l.
*
* This script is part of NethServer.
*
* NethServer is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NethServer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NethServer. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Interface to the underlying platform
*
* @api
* @author Davide Principi <davide.principi@nethesis.it>
* @since 1.0
*/
interface PlatformInterface
{
/**
* A valid service status is a 'disabled' or 'enabled' string.
* @api
*/
const SERVICESTATUS = 1248968160;
/**
* A valid *nix username token
* @api
*/
const USERNAME = 1248968161;
/**
* A not empty value
* @api
*/
const NOTEMPTY = 1248968162;
/**
* Accepts any value
* @api
*/
const ANYTHING = 1248968163;
/**
* Accept a value that represents a collection of any thing
* @api
*/
const ANYTHING_COLLECTION = 1248968164;
/**
* Accept a value that represents a collection of any Unix usernames
* @api
*/
const USERNAME_COLLECTION = 1248968165;
/**
* Accept positive integer
* @api
*/
const POSITIVE_INTEGER = 1248968166;
/**
* Accept a non-negative integer, an integer greater than or equal to zero
* @api
*/
const NONNEGATIVE_INTEGER = 1366805296;
/**
* Valid generic hostname
*
* @api
* @see #478
*/
const HOSTNAME = 1248968167;
/**
* Valid simple hostname without domain part
*
* @api
* @see #1052
*/
const HOSTNAME_SIMPLE = 1334736972;
/**
* Valid hostname with domain part (FQDN)
*
* @api
* @see #1052
*/
const HOSTNAME_FQDN = 1334741642;
/**
* Valid host name or ip address
*
* @api
* @see #478
*/
const HOSTADDRESS = 1248968168;
/**
* Valid date
*
* @api
* @see #513
*/
const DATE = 1248968169;
/**
* Valid time
*
* @api
* @see #513
*/
const TIME = 1248968170;
/**
* Boolean validator.
*
* @api
* '', '0', FALSE are FALSE boolean values. Other values are TRUE.
*/
const BOOLEAN = 1248968171;
/**
* A valid IPv4 address like '192.168.1.1'
*
* @api
*/
const IPv4 = 1248968172;
/**
* A valid IPv4 address like '192.168.1.1' ore empty
*
* @api
*/
const IPv4_OR_EMPTY = 1248968173;
/**
* A valid netmask address like '255.255.255.0' ore empty
*
* @api
*/
const NETMASK_OR_EMPTY = 1365512893;
/**
* Alias for VALID_IPv4
*
* @api
*/
const IP = 1248968174;
/**
* Alias for VALID_IPv4_OR_EMPTY
*
* @api
*/
const IP_OR_EMPTY = 1248968175;
/**
* Alias for NETMASK_OR_EMPTY
*
* @api
*/
const IPv4_NETMASK_OR_EMPTY = 1365513038;
/**
* A valid TCP/UDP port number 0-65535
*
* @api
*/
const PORTNUMBER = 1248968176;
/**
* A choice between 'yes' and 'no' values
*
* @api
*/
const YES_NO = 1248968177;
/**
* A valid ipv4 netmask address like '255.255.255.0'
*
* @api
*/
const IPv4_NETMASK = 1248968178;
/**
* Alias for VALID_IPv4_NETMASK
*
* @api
*/
const NETMASK = 1248968179;
/**
* A valid mac address like 00:16:3E:78:7A:7B
*
* @api
*/
const MACADDRESS = 1248968180;
/**
* Valid email address
*
* A restricted set of RFC5322 dot-atom form (sect 3.4.1)
*
* @api
*/
const EMAIL = 1340359603;
/**
* An empty string
*
* This is useful to compose _OR_EMPTY rules
*
* @api
*/
const EMPTYSTRING = 1368694834;
/**
* CIDR block validator
*
* Eg 192.144.33.0/24
*
* @api
*/
const CIDR_BLOCK = 1402048238;
/* ---------------------------------------8<-------------------------
!!! TO DEVELOPERS !!!
Define new constant values assigning
the current Unix timestamp (`/bin/date +%s` ouput)
-----8<----------------------------------------------------------- */
/**
* @api
* @var string
* @return \Nethgui\System\DatabaseInterface
*/
public function getDatabase($database);
/**
* Get an adapter for a "key" or "prop".
*
* An Identity Adapter is associated with a database value stored in a key
* or prop value. If a $separator character is specified, the adapter
* is enhanced with an ArrayAccess interface, and the value is stored
* joining its elements with that $separator.
*
* @api
* @see \Nethgui\Adapter\AdapterAggregationInterface
* @see getMapAdapter()
* @param string|ArrayAccess $database Database name or ArrayAccess object
* @param string $key Key connected to the adapter.
* @param string $prop Optional - Set to a prop name to connect a prop instead of a key.
* @param string $separator Optional - Specify a single character string to obtain an ArrayAccess and \Countable interface.
* @return \Nethgui\Adapter\AdapterInterface
*/
public function getIdentityAdapter($database, $key, $prop = NULL, $separator = NULL);
/**
* Get a mapping Adapter.
*
* A Map Adapter maps database values through a "reader" and a "writer"
* converter method. Values are specified through $args parameter.
*
* @api
* @see getIdentityAdapter()
* @see \Nethgui\Adapter\AdapterAggregationInterface
* @param callback $readCallback If $args has N elements $readCallback must accept N parameters and return a value.
* @param callback $writeCallback If $args has N elements $writeCallback must accept a parameter and return an array of N elements.
* @param array $args An array of arrays in the form ($database, $key, $prop). $prop is optional.
*
* @return \Nethgui\Adapter\AdapterInterface
*/
public function getMapAdapter($readCallback, $writeCallback, $args);
/**
* Get a table adapter
*
* A table adapter has an array interface, where each element represents a row, and each row
* is an array itself.
*
* @api
* @param string $database Database name
* @param string $typeOrKey The type of the keys to read from database or the key value where the data is stored
* @param string $filterOrProp The string to filter the table data or set to a prop name to connect a prop instead of a key.
* @param array $separators An array of one or two separator strings. The first is for the rows, the second for the columns. Set to NULL if $typeOrKey is a TYPE!
*
* @return \Nethgui\Adapter\AdapterInterface An adapter with array and countable interfaces.
*/
public function getTableAdapter($database, $typeOrKey, $filterOrProp = NULL, $separators = NULL);
/**
* Run an event handler
*
* The event can be signaled immediately or added to a queue.
*
* An event is represented by a ProcessInterface. If the event specification
* terminates with an ampersand (&) the process is detached.
*
* @api
* @see runEvents()
* @see exec()
* @param string $event Event specification <eventName>[@<queueName>][ &]
* @param array $arguments Optional event arguments
* @return \Nethgui\System\ProcessInterface
*/
public function signalEvent($event, $arguments = array());
/**
* Run events on the give queue
*
* @param string $queueName
* @return void
*/
public function runEvents($queueName);
/**
* PHP exec() wrapper
*
* The arguments are replaced in the command string, searching for placeholders
* in the form ${1} .. ${N}.
*
* NOTE: Only placeholders corresponding to i+1 element in the
* arguments array are replaced.
*
* @api
* @param string $command
* @param array $arguments Arguments for the command. Will be shell-escaped.
* @param boolean $detached If set the command is run detached from the PHP system process and traced
* @return \Nethgui\System\ProcessInterface
*/
public function exec($command, $arguments = array(), $detached = FALSE);
/**
* Create a platform validator object
*
* @api
* @param int ... One of the VALID_* constants
* @return \Nethgui\System\ValidatorInterface
*/
public function createValidator();
/**
* Get the system internal date format
*
* @return string
*/
public function getDateFormat();
/**
*
* @return array An array of \Nethgui\System\ProcessInterface traced objects
* @see \Nethgui\System\ProcessInterface
* @deprecated since version 1.6
*/
public function getDetachedProcesses();
/**
* @api
* @param string $name The identifier of the process
* @return \Nethgui\System\ProcessInterface
* @deprecated since version 1.6
*/
public function getDetachedProcess($identifier);
}