public function getDirty()
    {
        $dirty = [];

        foreach ($this->properties as $property => $value) {
            if (!array_key_exists($property, $this->original)) {
                $dirty[$property] = $value;
            } elseif ($value !== $this->original[$property] &&
                !$this->originalIsNumericallyEquivalent($property)
            ) {
                $dirty[$property] = $value;
            }
        }

        return $dirty;
    }

public function getDirty ( ) { $ dirty = [ ] ; foreach ( $ this -> properties as $ property => $ value ) { if ( ! array_key_exists ( $ property , $ this -> original ) ) { $ dirty [ $ property ] = $ value ; } elseif ( $ value !== $ this -> original [ $ property ] && ! $ this -> originalIsNumericallyEquivalent ( $ property ) ) { $ dirty [ $ property ] = $ value ; } } return $ dirty ; }

Get the properties that have been changed since last sync.

@return array

Get the properties that have been changed since last sync .


public static function navBarHeader($handle, $brand)
    {
        $navstyle       = '.navbar-'.$handle.'-collapse';
        $nbhc['button'] = new \Ease\Html\ButtonTag([new \Ease\Html\Span(
                _('Switch navigation'), ['class' => 'sr-only']), new \Ease\Html\Span(
                null, ['class' => 'icon-bar']), new \Ease\Html\Span(
                null, ['class' => 'icon-bar']), new \Ease\Html\Span(
                null, ['class' => 'icon-bar'])],
            ['type' => 'button', 'class' => 'navbar-toggle', 'data-toggle' => 'collapse',
            'data-target' => $navstyle,]);
        if (strlen($brand)) {
            $nbhc['brand'] = new \Ease\Html\ATag('./', $brand,
                ['class' => 'navbar-brand']);
        }

        return new \Ease\Html\DivTag($nbhc, ['class' => 'navbar-header']);
    }

public
static
function
navBarHeader
(
$
handle
,
$
brand
)
{
$
navstyle
=
'.navbar-'
.
$
handle
.
'-collapse'
;
$
nbhc
[
'button'
]
=
new
\
Ease
\
Html
\
ButtonTag
(
[
new
\
Ease
\
Html
\
Span
(
_
(
'Switch navigation'
)
,
[
'class'
=>
'sr-only'
]
)
,
new
\
Ease
\
Html
\
Span
(
,
[
'class'
=>
'icon-bar'
]
)
,
new
\
Ease
\
Html
\
Span
(
,
[
'class'
=>
'icon-bar'
]
)
,
new
\
Ease
\
Html
\
Span
(
,
[
'class'
=>
'icon-bar'
]
)
]
,
[
'type'
=>
'button'
,
'class'
=>
'navbar-toggle'
,
'data-toggle'
=>
'collapse'
,
'data-target'
=>
$
navstyle
,
]
)
;
if
(
strlen
(
$
brand
)
)
{
$
nbhc
[
'brand'
]
=
new
\
Ease
\
Html
\
ATag
(
'./'
,
$
brand
,
[
'class'
=>
'navbar-brand'
]
)
;
}
return
new
\
Ease
\
Html
\
DivTag
(
$
nbhc
,
[
'class'
=>
'navbar-header'
]
)
;
}

NavBar header code

@param string $handle classname fragment
@param string $brand  menu brand name

@return \Ease\Html\DivTag


public function &addDropDownSubmenu($name, $items)
    {
        $dropdown = $this->addItem(new \Ease\Html\UlTag(null,
                ['class' => 'dropdown-menu', 'role' => 'menu']));
        if (count($items)) {
            foreach ($items as $item) {
                $this->addMenuItem($item);
            }
        }

        return $dropdown;
    }

public function & addDropDownSubmenu ( $ name , $ items ) { $ dropdown = $ this -> addItem ( new \ Ease \ Html \ UlTag ( null , [ 'class' => 'dropdown-menu' , 'role' => 'menu' ] ) ) ; if ( count ( $ items ) ) { foreach ( $ items as $ item ) { $ this -> addMenuItem ( $ item ) ; } } return $ dropdown ; }

Add Dropdown Submenu.

@param string $name
@param array  $items

@return \Ease\Html\UlTag


public function addButton($content, $type = 'default', $properties = [])
    {
        if (isset($properties['class'])) {
            $properties['class'] = 'btn btn-'.$type.' '.$properties['class'];
        } else {
            $properties['class'] = 'btn btn-'.$type;
        }
        $button = new \Ease\Html\ButtonTag($content, $properties);
        return $this->addItem($button);
    }

public
function
addButton
(
$
content
,
$
type
=
'default'
,
$
properties
=
[
]
)
{
if
(
isset
(
$
properties
[
'class'
]
)
)
{
$
properties
[
'class'
]
=
'btn btn-'
.
$
type
.
' '
.
$
properties
[
'class'
]
;
}
else
{
$
properties
[
'class'
]
=
'btn btn-'
.
$
type
;
}
$
button
=
new
\
Ease
\
Html
\
ButtonTag
(
$
content
,
$
properties
)
;
return
$
this
->
addItem
(
$
button
)
;
}

Add new button into Group

@param mixed  $content    Button content
@param string $type       default|info|success|warning|danger
@param array  $properties adittional properties
@return \Ease\Html\ButtonTag Button inserted


public function flush($caller = null)
    {
        $flushed = 0;
        if (count($this->statusMessages)) {
            foreach ($this->statusMessages as $type => $messages) {
                foreach ($messages as $messageID => $message) {
                    if (!isset($this->flushed[$type][$messageID])) {
                        $this->addToLog($caller, $message, $type);
                        $this->flushed[$type][$messageID] = true;
                        ++$flushed;
                    }
                }
            }
        }

        return $flushed;
    }

public function flush ( $ caller = null ) { $ flushed = 0 ; if ( count ( $ this -> statusMessages ) ) { foreach ( $ this -> statusMessages as $ type => $ messages ) { foreach ( $ messages as $ messageID => $ message ) { if ( ! isset ( $ this -> flushed [ $ type ] [ $ messageID ] ) ) { $ this -> addToLog ( $ caller , $ message , $ type ) ; $ this -> flushed [ $ type ] [ $ messageID ] = true ; ++ $ flushed ; } } } } return $ flushed ; }

Flush Messages.

@param string $caller

@return int how many messages was flushed


public function &addItem($item, $pageItemName = null)
    {
        $added = $this->body->addItem($item, $pageItemName);

        return $added;
    }

public function & addItem ( $ item , $ pageItemName = null ) { $ added = $ this -> body -> addItem ( $ item , $ pageItemName ) ; return $ added ; }

Add item into page body

@param mixed  $item         vkládaná položka
@param string $pageItemName Pod tímto jménem je objekt vkládán do stromu

@return Page poiner to object well included


public function addCSS($css)
    {
        if (is_array($css)) {
            $css = key($css).'{'.current($css).'}';
        }
        $this->easeShared->cascadeStyles[md5($css)] = $css;

        return true;
    }

public function addCSS ( $ css ) { if ( is_array ( $ css ) ) { $ css = key ( $ css ) . '{' . current ( $ css ) . '}' ; } $ this -> easeShared -> cascadeStyles [ md5 ( $ css ) ] = $ css ; return true ; }

Add another CSS definition to stack.

@param string $css definice CSS pravidla

@return bool


public static function getGravatar(
        $email, $size = 80, $default = 'mm', $maxRating = 'g'
    )
    {
        $url = 'http://www.gravatar.com/avatar/';
        $url .= md5(strtolower(trim($email)));
        $url .= "?s=$size&d=$default&r=$maxRating";

        return $url;
    }

public static function getGravatar ( $ email , $ size = 80 , $ default = 'mm' , $ maxRating = 'g' ) { $ url = 'http://www.gravatar.com/avatar/' ; $ url .= md5 ( strtolower ( trim ( $ email ) ) ) ; $ url .= "?s=$size&d=$default&r=$maxRating" ; return $ url ; }

Get either a Gravatar URL or complete image tag for a specified email
address.

@param string $email     The email address
@param integer $size      Size in pixels, defaults to 80px [ 1 - 512 ]
@param string $default   [ 404 | mm | identicon | monsterid | wavatar ]
@param string $maxRating Maximum rating (inclusive) [ g | pg | r | x ]

@return string containing either just a URL or a complete image tag

@source http://gravatar.com/site/implement/images/php/

Get either a Gravatar URL or complete image tag for a specified email address .


public function offsetSet($key, $value)
    {
        if (is_null($key)) {
            $this->content[] = $value;
        } else {
            $this->content[$key] = $value;
        }
    }

public function offsetSet ( $ key , $ value ) { if ( is_null ( $ key ) ) { $ this -> content [ ] = $ value ; } else { $ this -> content [ $ key ] = $ value ; } }

Set the item at the given offset.

@param  mixed $key
@param  mixed $value
@return void


public static function &db($pdo = null)
    {
        $shared = self::instanced();
        if (is_object($pdo)) {
            $shared->dbLink = &$pdo;
        }
        if (!is_object($shared->dbLink)) {
            $shared->dbLink = self::db(SQL\PDO::singleton(is_array($pdo) ? $pdo : [
                ]));
        }

        return $shared->dbLink;
    }

public static function & db ( $ pdo = null ) { $ shared = self :: instanced ( ) ; if ( is_object ( $ pdo ) ) { $ shared -> dbLink = & $ pdo ; } if ( ! is_object ( $ shared -> dbLink ) ) { $ shared -> dbLink = self :: db ( SQL \ PDO :: singleton ( is_array ( $ pdo ) ? $ pdo : [ ] ) ) ; } return $ shared -> dbLink ; }

Returns database object instance.

@return SQL\PDO


public static function &locale($locale = null)
    {
        $shared = self::instanced();
        if (is_object($locale)) {
            $shared->locale = &$locale;
        }
        if (!is_object($shared->locale)) {
            $shared->locale = Locale::singleton();
        }
        return $shared->locale;
    }

public static function & locale ( $ locale = null ) { $ shared = self :: instanced ( ) ; if ( is_object ( $ locale ) ) { $ shared -> locale = & $ locale ; } if ( ! is_object ( $ shared -> locale ) ) { $ shared -> locale = Locale :: singleton ( ) ; } return $ shared -> locale ; }

Locale Class handler

@param Locale $locale overriding object

@return Locale


public static function addUrlParams($url, $addParams, $override = false)
    {
        $urlParts = parse_url($url);
        $urlFinal = '';
        if (array_key_exists('scheme', $urlParts)) {
            $urlFinal .= $urlParts['scheme'].'://'.$urlParts['host'];
        }
        if (array_key_exists('port', $urlParts)) {
            $urlFinal .= ':'.$urlParts['port'];
        }
        if (array_key_exists('path', $urlParts)) {
            $urlFinal .= $urlParts['path'];
        }
        if (array_key_exists('query', $urlParts)) {
            parse_str($urlParts['query'], $queryUrlParams);
            $urlParams = $override ? array_merge($queryUrlParams, $addParams) : array_merge($addParams,
                    $queryUrlParams);
        } else {
            $urlParams = $addParams;
        }

        if (!empty($urlParams)) {
            $urlFinal .= '?';
            if (is_array($urlParams)) {
                $urlFinal .= http_build_query($urlParams);
            } else {
                $urlFinal .= $urlParams;
            }
        }
        return $urlFinal;
    }

public static function addUrlParams ( $ url , $ addParams , $ override = false ) { $ urlParts = parse_url ( $ url ) ; $ urlFinal = '' ; if ( array_key_exists ( 'scheme' , $ urlParts ) ) { $ urlFinal .= $ urlParts [ 'scheme' ] . '://' . $ urlParts [ 'host' ] ; } if ( array_key_exists ( 'port' , $ urlParts ) ) { $ urlFinal .= ':' . $ urlParts [ 'port' ] ; } if ( array_key_exists ( 'path' , $ urlParts ) ) { $ urlFinal .= $ urlParts [ 'path' ] ; } if ( array_key_exists ( 'query' , $ urlParts ) ) { parse_str ( $ urlParts [ 'query' ] , $ queryUrlParams ) ; $ urlParams = $ override ? array_merge ( $ queryUrlParams , $ addParams ) : array_merge ( $ addParams , $ queryUrlParams ) ; } else { $ urlParams = $ addParams ; } if ( ! empty ( $ urlParams ) ) { $ urlFinal .= '?' ; if ( is_array ( $ urlParams ) ) { $ urlFinal .= http_build_query ( $ urlParams ) ; } else { $ urlFinal .= $ urlParams ; } } return $ urlFinal ; }

Add params to url

@param string  $url      originall url
@param array   $addParams   value to add
@param boolean $override replace already existing values ?

@return string url with parameters added


public static function linkify($value, $protocols = array('http', 'mail'),
                                   array $attributes = array())
    {
        // Link attributes
        $attr = '';
        foreach ($attributes as $key => $val) {
            $attr = ' '.$key.'="'.htmlentities($val).'"';
        }

        $links = array();

        // Extract existing links and tags
        $value = preg_replace_callback('~(.*?|<.*?>)~i',
            function ($match) use (&$links) {
            return '<'.array_push($links, $match[1]).'>';
        }, $value);

        // Extract text links for each protocol
        foreach ((array) $protocols as $protocol) {
            switch ($protocol) {
                case 'http':
                case 'https': $value = preg_replace_callback('~(?:(https?)://([^\s<]+)|(www\.[^\s<]+?\.[^\s<]+))(?<![\.,:])~i',
                        function ($match) use ($protocol, &$links, $attr) {
                        if ($match[1]) $protocol = $match[1];
                        $link     = $match[2] ?: $match[3];
                        return '<'.array_push($links,
                                "$link").'>';
                    }, $value);
                    break;
                case 'mail': $value = preg_replace_callback('~([^\s<]+?@[^\s<]+?\.[^\s<]+)(?<![\.,:])~',
                        function ($match) use (&$links, $attr) {
                        return '<'.array_push($links,
                                "{$match[1]}").'>';
                    }, $value);
                    break;
                case 'twitter': $value = preg_replace_callback('~(?<!\w)[@#](\w++)~',
                        function ($match) use (&$links, $attr) {
                        return '<'.array_push($links,
                                "{$match[0]}").'>';
                    }, $value);
                    break;
                default: $value = preg_replace_callback('~'.preg_quote($protocol,
                            '~').'://([^\s<]+?)(?<![\.,:])~i',
                        function ($match) use ($protocol, &$links, $attr) {
                        return '<'.array_push($links,
                                "{$match[1]}").'>';
                    }, $value);
                    break;
            }
        }

        // Insert all link
        return preg_replace_callback('/<(\d+)>/',
            function ($match) use (&$links) {
            return $links[$match[1] - 1];
        }, $value);
    }

Turn all URLs in clickable links.

@author Arnold Daniels <arnold@jasny.net>

@param string $value
@param array  $protocols  http/https, ftp, mail, twitter
@param array  $attributes
@param string $mode       normal or all

@return string


public function &addRowFooterColumns($columns = null, $properties = [])
    {
        $tableRow = $this->tFoot->addItem(new TrTag());
        if (is_array($columns)) {
            foreach ($columns as $column) {
                if (is_object($column) && method_exists($column, 'getTagType') && $column->getTagType()
                    == 'th') {
                    $tableRow->addItem($column);
                } else {
                    $tableRow->addItem(new ThTag($column, $properties));
                }
            }
        }

        return $tableRow;
    }

public function & addRowFooterColumns ( $ columns = null , $ properties = [ ] ) { $ tableRow = $ this -> tFoot -> addItem ( new TrTag ( ) ) ; if ( is_array ( $ columns ) ) { foreach ( $ columns as $ column ) { if ( is_object ( $ column ) && method_exists ( $ column , 'getTagType' ) && $ column -> getTagType ( ) == 'th' ) { $ tableRow -> addItem ( $ column ) ; } else { $ tableRow -> addItem ( new ThTag ( $ column , $ properties ) ) ; } } } return $ tableRow ; }

Insert columns into table foot

@param array $columns    values
@param array $properties options to add

@return TrTag odkaz na řádku tabulky


public function includeCss($cssFile, $fwPrefix = false, $media = 'screen')
    {
        return \Ease\Shared::webPage()->includeCss($cssFile, $fwPrefix, $media);
    }

public function includeCss ( $ cssFile , $ fwPrefix = false , $ media = 'screen' ) { return \ Ease \ Shared :: webPage ( ) -> includeCss ( $ cssFile , $ fwPrefix , $ media ) ; }

Include an CSS file call into page.

@param string $cssFile  cesta k souboru vkládanému do stránky
@param bool   $fwPrefix přidat prefix frameworku (obvykle /Ease/) ?
@param string $media    médium screen|print|braile apod ...

@return int


public static function phpSelf($dropqs = true)
    {
        $url = null;
        if (php_sapi_name() != 'cli') {

            $schema = 'http';
            if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on')) {
                $schema .= 's';
            }
            $url = sprintf('%s://%s%s', $schema, $_SERVER['SERVER_NAME'],
                $_SERVER['REQUEST_URI']);

            $parts = parse_url($url);

            $port   = $_SERVER['SERVER_PORT'];
            $scheme = $parts['scheme'];
            $host   = $parts['host'];
            if (isset($parts['path'])) {
                $path = $parts['path'];
            } else {
                $path = null;
            }
            if (isset($parts['query'])) {
                $qs = $parts['query'];
            } else {
                $qs = null;
            }
            $port || $port = ($scheme == 'https') ? '443' : '80';

            if (($scheme == 'https' && $port != '443') || ($scheme == 'http' && $port
                != '80')
            ) {
                $host = "$host:$port";
            }
            $url = "$scheme://$host$path";
            if (!$dropqs) {
                return "{$url}?{$qs}";
            } else {
                return $url;
            }
        }
    }

public static function phpSelf ( $ dropqs = true ) { $ url = null ; if ( php_sapi_name ( ) != 'cli' ) { $ schema = 'http' ; if ( isset ( $ _SERVER [ 'HTTPS' ] ) && ( $ _SERVER [ 'HTTPS' ] == 'on' ) ) { $ schema .= 's' ; } $ url = sprintf ( '%s://%s%s' , $ schema , $ _SERVER [ 'SERVER_NAME' ] , $ _SERVER [ 'REQUEST_URI' ] ) ; $ parts = parse_url ( $ url ) ; $ port = $ _SERVER [ 'SERVER_PORT' ] ; $ scheme = $ parts [ 'scheme' ] ; $ host = $ parts [ 'host' ] ; if ( isset ( $ parts [ 'path' ] ) ) { $ path = $ parts [ 'path' ] ; } else { $ path = null ; } if ( isset ( $ parts [ 'query' ] ) ) { $ qs = $ parts [ 'query' ] ; } else { $ qs = null ; } $ port || $ port = ( $ scheme == 'https' ) ? '443' : '80' ; if ( ( $ scheme == 'https' && $ port != '443' ) || ( $ scheme == 'http' && $ port != '80' ) ) { $ host = "$host:$port" ; } $ url = "$scheme://$host$path" ; if ( ! $ dropqs ) { return "{$url}?{$qs}" ; } else { return $ url ; } } }

Returns the current URL. This is instead of PHP_SELF which is unsafe.

@param bool $dropqs whether to drop the querystring or not. Default true

@return string the current URL or NULL for php-cli

Returns the current URL . This is instead of PHP_SELF which is unsafe .


public function buildPostData($data)
    {
        $this->data = $data;

        $query = parent::buildPostData($data);

        foreach ($data as $key => $value) {
            if (is_array($value)) $query = preg_replace('/&' . $key . '%5B%5D=/simU', '&' . $key . '=', $query);
        }

        $this->query = $query;

        return $query;
    }

public function buildPostData ( $ data ) { $ this -> data = $ data ; $ query = parent :: buildPostData ( $ data ) ; foreach ( $ data as $ key => $ value ) { if ( is_array ( $ value ) ) $ query = preg_replace ( '/&' . $ key . '%5B%5D=/simU' , '&' . $ key . '=' , $ query ) ; } $ this -> query = $ query ; return $ query ; }

Build Post Data

@access public
@param  $data

@return array|string


public function availble()
    {
        $locales = [];
        $d       = dir(self::$i18n);
        while (false !== ($entry   = $d->read())) {
            if (($entry[0] != '.') && file_exists(self::$i18n.'/'.$entry.'/LC_MESSAGES/'.self::$textDomain.'.mo')) {
                $locales[$entry] = _(self::$alllngs[$entry]);
            }
        }
        $d->close();
        return $locales;
    }

public function availble ( ) { $ locales = [ ] ; $ d = dir ( self :: $ i18n ) ; while ( false !== ( $ entry = $ d -> read ( ) ) ) { if ( ( $ entry [ 0 ] != '.' ) && file_exists ( self :: $ i18n . '/' . $ entry . '/LC_MESSAGES/' . self :: $ textDomain . '.mo' ) ) { $ locales [ $ entry ] = _ ( self :: $ alllngs [ $ entry ] ) ; } } $ d -> close ( ) ; return $ locales ; }

List of availble locales

@return array locales availble


public static function langToLocale($lang)
    {
        $defaultLocale = 'C';
        $langs         = [];
        foreach (self::$alllngs as $langCode => $language) {
            $langs[$langCode] = [strstr($langCode, '_') ? substr($langCode, 0,
                    strpos($langCode, '_')) : $langCode, $language];
        }
        foreach ($langs as $code => $langInfo) {
            if ($lang == $langInfo[0]) {
                $defaultLocale = $code;
                break;
            }
        }
        return $defaultLocale;
    }

public static function langToLocale ( $ lang ) { $ defaultLocale = 'C' ; $ langs = [ ] ; foreach ( self :: $ alllngs as $ langCode => $ language ) { $ langs [ $ langCode ] = [ strstr ( $ langCode , '_' ) ? substr ( $ langCode , 0 , strpos ( $ langCode , '_' ) ) : $ langCode , $ language ] ; } foreach ( $ langs as $ code => $ langInfo ) { if ( $ lang == $ langInfo [ 0 ] ) { $ defaultLocale = $ code ; break ; } } return $ defaultLocale ; }

Find Locale Code for browser language

@param string $lang browser lan en|cs|..

@return string locale code


public static function useLocale($localeCode)
    {
        \setlocale(LC_ALL, $localeCode);
        \bind_textdomain_codeset(self::$textDomain, 'UTF-8');
        \putenv("LC_ALL=$localeCode");
        if (file_exists(self::$i18n)) {
            \bindtextdomain(self::$textDomain, self::$i18n);
        }
        \textdomain(self::$textDomain);
        if (isset($_SESSION)) {
            $_SESSION['locale'] = $localeCode;
        }
        self::$localeUsed = $localeCode;
    }

public static function useLocale ( $ localeCode ) { \ setlocale ( LC_ALL , $ localeCode ) ; \ bind_textdomain_codeset ( self :: $ textDomain , 'UTF-8' ) ; \ putenv ( "LC_ALL=$localeCode" ) ; if ( file_exists ( self :: $ i18n ) ) { \ bindtextdomain ( self :: $ textDomain , self :: $ i18n ) ; } \ textdomain ( self :: $ textDomain ) ; if ( isset ( $ _SESSION ) ) { $ _SESSION [ 'locale' ] = $ localeCode ; } self :: $ localeUsed = $ localeCode ; }

Use Effective locale to requested

@param string $localeCode locale code to use

@return string used locale code


public function setupProperty($options, $name, $constant = null)
    {
        if (isset($options[$name])) {
            $this->$name = $options[$name];
        } else {
            if (is_null($this->$name) && !empty($constant) && defined($constant)) {
                $this->$name = constant($constant);
            }
        }
    }

public function setupProperty ( $ options , $ name , $ constant = null ) { if ( isset ( $ options [ $ name ] ) ) { $ this -> $ name = $ options [ $ name ] ; } else { if ( is_null ( $ this -> $ name ) && ! empty ( $ constant ) && defined ( $ constant ) ) { $ this -> $ name = constant ( $ constant ) ; } } }

Set up one of properties

@param array  $options  array of given properties
@param string $name     name of property to process
@param string $constant load default property value from constant


public function getStatusMessages($clean = false)
    {
        $messages = $this->easeShared->getStatusMessages();
        if ($clean) {
            $this->easeShared->cleanMessages();
        }
        return $messages;
    }

public function getStatusMessages ( $ clean = false ) { $ messages = $ this -> easeShared -> getStatusMessages ( ) ; if ( $ clean ) { $ this -> easeShared -> cleanMessages ( ) ; } return $ messages ; }

Obtain Status Messages

@param bool $clean Remove messages from strack ?

@return array


public static function listCountries(Context $context, $filter = null)
    {
        $queryParams = (!is_null($filter)) ? [Constants::FILTER => $filter] : [];

        $response = NetLicensingService::getInstance()
            ->get($context, Constants::UTILITY_ENDPOINT_PATH . '/' . Constants::UTILITY_ENDPOINT_PATH_COUNTRIES, $queryParams);

        $countries = [];
        $pageNumber = !empty($response->items->pagenumber) ? $response->items->pagenumber : 0;
        $itemsNumber = !empty($response->items->itemsnumber) ? $response->items->itemsnumber : 0;
        $totalPages = !empty($response->items->totalpages) ? $response->items->totalpages : 0;
        $totalItems = !empty($response->items->totalitems) ? $response->items->totalitems : 0;

        if (!empty($response->items->item)) {
            foreach ($response->items->item as $item) {
                $country = ItemToCountryConverter::convert($item);
                $country->exists = true;

                $countries[] = $country;
            }
        }

        return new Page($countries, $pageNumber, $itemsNumber, $totalPages, $totalItems);
    }

public static function listCountries ( Context $ context , $ filter = null ) { $ queryParams = ( ! is_null ( $ filter ) ) ? [ Constants :: FILTER => $ filter ] : [ ] ; $ response = NetLicensingService :: getInstance ( ) -> get ( $ context , Constants :: UTILITY_ENDPOINT_PATH . '/' . Constants :: UTILITY_ENDPOINT_PATH_COUNTRIES , $ queryParams ) ; $ countries = [ ] ; $ pageNumber = ! empty ( $ response -> items -> pagenumber ) ? $ response -> items -> pagenumber : 0 ; $ itemsNumber = ! empty ( $ response -> items -> itemsnumber ) ? $ response -> items -> itemsnumber : 0 ; $ totalPages = ! empty ( $ response -> items -> totalpages ) ? $ response -> items -> totalpages : 0 ; $ totalItems = ! empty ( $ response -> items -> totalitems ) ? $ response -> items -> totalitems : 0 ; if ( ! empty ( $ response -> items -> item ) ) { foreach ( $ response -> items -> item as $ item ) { $ country = ItemToCountryConverter :: convert ( $ item ) ; $ country -> exists = true ; $ countries [ ] = $ country ; } } return new Page ( $ countries , $ pageNumber , $ itemsNumber , $ totalPages , $ totalItems ) ; }

Returns all countries.

determines the vendor on whose behalf the call is performed
@param Context $context

reserved for the future use, must be omitted / set to NULL
@param null $filter

@return Page
@throws RestException
@throws \ErrorException


public function &addItemSmart($pageItem, $properties = [])
    {
        $item = parent::addItemSmart($pageItem, $properties);
        $item->addTagClass('list-group-item');

        return $item;
    }

public function & addItemSmart ( $ pageItem , $ properties = [ ] ) { $ item = parent :: addItemSmart ( $ pageItem , $ properties ) ; $ item -> addTagClass ( 'list-group-item' ) ; return $ item ; }

Every item id added in \Ease\Html\LiTag envelope.

@param mixed  $pageItem   obsah vkládaný jako položka výčtu
@param string $properties Vlastnosti LI tagu

@return mixed

Every item id added in \ Ease \ Html \ LiTag envelope .


public function setObjectName($objectName = null)
    {
        if (is_null($objectName)) {
            $objectName = get_class($this).'@'.$this->getTagProperty('for');
        }

        return parent::setObjectName($objectName);
    }

public function setObjectName ( $ objectName = null ) { if ( is_null ( $ objectName ) ) { $ objectName = get_class ( $ this ) . '@' . $ this -> getTagProperty ( 'for' ) ; } return parent :: setObjectName ( $ objectName ) ; }

Set object name.

@param string $objectName nastavované jméno

@return string New object name


public static function set($str, $color)
    {
        $color_attrs = explode("+", $color);
        $ansi_str    = "";
        foreach ($color_attrs as $attr) {
            $ansi_str .= "\033[".self::$ANSI_CODES[$attr]."m";
        }
        $ansi_str .= $str."\033[".self::$ANSI_CODES["off"]."m";
        return $ansi_str;
    }

public static function set ( $ str , $ color ) { $ color_attrs = explode ( "+" , $ color ) ; $ ansi_str = "" ; foreach ( $ color_attrs as $ attr ) { $ ansi_str .= "\033[" . self :: $ ANSI_CODES [ $ attr ] . "m" ; } $ ansi_str .= $ str . "\033[" . self :: $ ANSI_CODES [ "off" ] . "m" ; return $ ansi_str ; }

Set Ansi Color

@param string $str
@param string $color
@return string


public static function getTypeColor($type)
    {
        switch ($type) {
            case 'mail':                       // Envelope
                $color = 'blue';
                break;
            case 'warning':                    // Vykřičník v trojůhelníku
                $color = 'yellow';
                break;
            case 'error':                      // Lebka
                $color = 'red';
                break;
            case 'debug':                      // Kytička
                $color = 'magenta';
                break;
            case 'success':                    // Kytička
                $color = 'green';
                break;
            default:                           // i v kroužku
                $color = 'white';
                break;
        }
        return $color;
    }

public
static
function
getTypeColor
(
$
type
)
{
switch
(
$
type
)
{
case
'mail'
:
// Envelope
$
color
=
'blue'
;
break
;
case
'warning'
:
// Vykřičník v trojůhelníku
$
color
=
'yellow'
;
break
;
case
'error'
:
// Lebka
$
color
=
'red'
;
break
;
case
'debug'
:
// Kytička
$
color
=
'magenta'
;
break
;
case
'success'
:
// Kytička
$
color
=
'green'
;
break
;
default
:
// i v kroužku
$
color
=
'white'
;
break
;
}
return
$
color
;
}

Get color code for given message

@param string $type


public function get(Context $context, $urlTemplate, array $queryParams = [])
    {
        return $this->request($context, 'get', $urlTemplate, $queryParams);
    }

public function get ( Context $ context , $ urlTemplate , array $ queryParams = [ ] ) { return $ this -> request ( $ context , 'get' , $ urlTemplate , $ queryParams ) ; }

Helper method for performing GET request to NetLicensing API services. Finds and returns first suitable item with
type resultType from the response.

Context for the NetLicensing API call
@param Context $context

the REST URL template
@param $urlTemplate

The REST query parameters values. May be null if there are no parameters.
@param array $queryParams

@return mixed|null
@throws RestException

Helper method for performing GET request to NetLicensing API services . Finds and returns first suitable item with type resultType from the response .


public function post(Context $context, $urlTemplate, array $queryParams = [])
    {
        return $this->request($context, 'post', $urlTemplate, $queryParams);
    }

public function post ( Context $ context , $ urlTemplate , array $ queryParams = [ ] ) { return $ this -> request ( $ context , 'post' , $ urlTemplate , $ queryParams ) ; }

Helper method for performing POST request to NetLicensing API services. Finds and returns first suitable item
with type resultType from the response.

context for the NetLicensing API call
@param Context $context

the REST URL template
@param $urlTemplate

The REST query parameters values. May be null if there are no parameters.
@param array $queryParams

@return mixed|null
@throws RestException

Helper method for performing POST request to NetLicensing API services . Finds and returns first suitable item with type resultType from the response .


public function delete(Context $context, $urlTemplate, array $queryParams = [])
    {
        return $this->request($context, 'delete', $urlTemplate, $queryParams);
    }

public function delete ( Context $ context , $ urlTemplate , array $ queryParams = [ ] ) { return $ this -> request ( $ context , 'delete' , $ urlTemplate , $ queryParams ) ; }

Helper method for performing DELETE request to NetLicensing API services.

context for the NetLicensing API call
@param Context $context

the REST URL template
@param $urlTemplate

The REST query parameters values. May be null if there are no parameters.
@param array $queryParams

@return mixed|null
@throws RestException

Helper method for performing DELETE request to NetLicensing API services .


public function getMyKey($data = null)
    {
        $key = null;
        if (is_null($data)) {
            $data = $this->getData();
        }
        if (isset($data) && isset($data[$this->keyColumn])) {
            $key = $data[$this->keyColumn];
        }

        return $key;
    }

public function getMyKey ( $ data = null ) { $ key = null ; if ( is_null ( $ data ) ) { $ data = $ this -> getData ( ) ; } if ( isset ( $ data ) && isset ( $ data [ $ this -> keyColumn ] ) ) { $ key = $ data [ $ this -> keyColumn ] ; } return $ key ; }

Gives you value of KEY Column

@param array $data data z nichž se vrací hodnota klíče

@return int key column value


public function unsetDataValue($columnName)
    {
        if (array_key_exists($columnName, $this->data)) {
            unset($this->data[$columnName]);

            return true;
        }

        return false;
    }

public function unsetDataValue ( $ columnName ) { if ( array_key_exists ( $ columnName , $ this -> data ) ) { unset ( $ this -> data [ $ columnName ] ) ; return true ; } return false ; }

Odstrani polozku z pole dat pro MySQL.

@param string $columnName název klíče k vymazání

@return bool success


public static function reindexArrayBy($data, $indexBy = null)
    {
        $reindexedData = [];

        foreach ($data as $dataID => $data) {
            if (array_key_exists($indexBy, $data)) {
                $reindexedData[$data[$indexBy]] = $data;
            } else {
                throw new \Exception(sprintf('Data row does not contain column %s for reindexing',
                    $indexBy));
            }
        }

        return $reindexedData;
    }

Reindex Array by given key.

@param array  $data    array to reindex
@param string $indexBy one of columns in array

@return array


public function draw()
    {
        foreach ($this->pageParts as $part) {
            if (is_object($part)) {
                if (method_exists($part, 'drawIfNotDrawn')) {
                    $part->drawIfNotDrawn();
                } else {
                    $part->draw();
                }
            } else {
                echo $part;
            }
        }
        $this->drawStatus = true;
    }

public function draw ( ) { foreach ( $ this -> pageParts as $ part ) { if ( is_object ( $ part ) ) { if ( method_exists ( $ part , 'drawIfNotDrawn' ) ) { $ part -> drawIfNotDrawn ( ) ; } else { $ part -> draw ( ) ; } } else { echo $ part ; } } $ this -> drawStatus = true ; }


public function setUpContext()
    {
        return $this->context = (new \NetLicensing\Context())
            ->setBaseUrl(self::BASE_URL)
            ->setSecurityMode(self::SECURITY_MODE)
            ->setUsername(self::USERNAME)
            ->setPassword(self::PASSWORD);
    }

public function setUpContext ( ) { return $ this -> context = ( new \ NetLicensing \ Context ( ) ) -> setBaseUrl ( self :: BASE_URL ) -> setSecurityMode ( self :: SECURITY_MODE ) -> setUsername ( self :: USERNAME ) -> setPassword ( self :: PASSWORD ) ; }

Determines the vendor on whose behalf the call is performed

@return \NetLicensing\Context


public function getItemsCount($object = null)
    {
        if (is_null($object)) {
            $object = $this->htmlBody;
        }
        return parent::getItemsCount($object);
    }

public function getItemsCount ( $ object = null ) { if ( is_null ( $ object ) ) { $ object = $ this -> htmlBody ; } return parent :: getItemsCount ( $ object ) ; }

Obtain item count

@param Container $object
@return int


public function isEmpty($element = null)
    {
        if (is_null($element)) {
            $element = $this->htmlBody;
        }
        return parent::isEmpty($element);
    }

public function isEmpty ( $ element = null ) { if ( is_null ( $ element ) ) { $ element = $ this -> htmlBody ; } return parent :: isEmpty ( $ element ) ; }

Is object empty ?

@param Container $element

@return boolean


public function addSlashes($text)
    {
        if (isset($this->sqlLink) && method_exists($this->sqlLink,
                'real_escape_string')) {
            $slashed = $this->sqlLink->real_escape_string($text);
        } else {
            $slashed = addslashes($text);
        }

        return $slashed;
    }

public function addSlashes ( $ text ) { if ( isset ( $ this -> sqlLink ) && method_exists ( $ this -> sqlLink , 'real_escape_string' ) ) { $ slashed = $ this -> sqlLink -> real_escape_string ( $ text ) ; } else { $ slashed = addslashes ( $ text ) ; } return $ slashed ; }

Escapes special characters in a string for use in an SQL statement.

@param string $text

@return string

Escapes special characters in a string for use in an SQL statement .


public function connect()
    {
        if (is_null($this->dbType)) {
            $result = null;
        } else {
            switch ($this->dbType) {
                case 'mysql':
                    $this->sqlLink = new \PDO($this->dbType.':dbname='.$this->database.';host='.$this->server.';port='.$this->port.';charset=utf8',
                        $this->username, $this->password,
                        [\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'utf8\'']);
                    break;
                case 'pgsql':
                    $this->sqlLink = new \PDO($this->dbType.':dbname='.$this->database.';host='.$this->server.';port='.$this->port,
                        $this->username, $this->password);
                    if (is_object($this->sqlLink)) {
                        $this->sqlLink->query("SET NAMES 'UTF-8'");
                    }
                    break;

                default:
                    throw new \Ease\Exception(_('Unimplemented Database type').': '.$this->dbType);
                    break;
            }

            if (is_object($this->sqlLink)) {
                $this->errorNumber = $this->sqlLink->errorCode();
                $this->errorText   = $this->sqlLink->errorInfo();
            } else {
                $result = false;
            }
            if ($this->errorNumber != '00000') {
                $this->addStatusMessage('Connect: error #'.$this->errorNumer.' '.$this->errorText,
                    'error');

                $result = false;
            } else {
                $result = parent::connect();
            }
        }

        return $result;
    }

public
function
connect
(
)
{
if
(
is_null
(
$
this
->
dbType
)
)
{
$
result
=
;
}
else
{
switch
(
$
this
->
dbType
)
{
case
'mysql'
:
$
this
->
sqlLink
=
new
\
PDO
(
$
this
->
dbType
.
':dbname='
.
$
this
->
database
.
';host='
.
$
this
->
server
.
';port='
.
$
this
->
port
.
';charset=utf8'
,
$
this
->
username
,
$
this
->
password
,
[
\
PDO
::
MYSQL_ATTR_INIT_COMMAND
=>
'SET NAMES \'utf8\''
]
)
;
break
;
case
'pgsql'
:
$
this
->
sqlLink
=
new
\
PDO
(
$
this
->
dbType
.
':dbname='
.
$
this
->
database
.
';host='
.
$
this
->
server
.
';port='
.
$
this
->
port
,
$
this
->
username
,
$
this
->
password
)
;
if
(
is_object
(
$
this
->
sqlLink
)
)
{
$
this
->
sqlLink
->
query
(
"SET NAMES 'UTF-8'"
)
;
}
break
;
default
:
throw
new
\
Ease
\
Exception
(
_
(
'Unimplemented Database type'
)
.
': '
.
$
this
->
dbType
)
;
break
;
}
if
(
is_object
(
$
this
->
sqlLink
)
)
{
$
this
->
errorNumber
=
$
this
->
sqlLink
->
errorCode
(
)
;
$
this
->
errorText
=
$
this
->
sqlLink
->
errorInfo
(
)
;
}
else
{
$
result
=
false
;
}
if
(
$
this
->
errorNumber
!=
'00000'
)
{
$
this
->
addStatusMessage
(
'Connect: error #'
.
$
this
->
errorNumer
.
' '
.
$
this
->
errorText
,
'error'
)
;
$
result
=
false
;
}
else
{
$
result
=
parent
::
connect
(
)
;
}
}
return
$
result
;
}

Perform connect to database.

@return false|null connecting result true: connected, false: error, null: no SQL configured


public function arrayToInsert($data)
    {
        $cc  = $this->getColumnComma();
        $set = ' ';
        if ($this->dbType == 'mysql') {
            $set = ' SET ';
        }
        return $this->exeQuery('INSERT INTO '.$cc.$this->myTable.$cc.$set.$this->arrayToQuery($data));
    }

public
function
arrayToInsert
(
$
data
)
{
$
cc
=
$
this
->
getColumnComma
(
)
;
$
set
=
' '
;
if
(
$
this
->
dbType
==
'mysql'
)
{
$
set
=
' SET '
;
}
return
$
this
->
exeQuery
(
'INSERT INTO '
.
$
cc
.
$
this
->
myTable
.
$
cc
.
$
set
.
$
this
->
arrayToQuery
(
$
data
)
)
;
}

Insert array values as new database row

@param string $data

@return sqlresult


public function prepSelect($data, $ldiv = 'AND')
    {
        $operator     = null;
        $conditions   = [];
        $conditionsII = [];
        foreach ($data as $column => $value) {
            if (is_integer($column)) {
                $conditionsII[] = $value;
                continue;
            }
            if (($column == $this->keyColumn) && ($this->keyColumn == '')) {
                continue;
            }
            if (is_string($value) && (($value == '!=""') || ($value == "!=''"))) {
                $conditions[] = ' '.$this->getColumnComa().$column.$this->getColumnComma()." !='' ";
                continue;
            }

            if (is_null($value)) {
                $value    = 'null';
                $operator = ' IS ';
            } else {
                if (strlen($value) && ($value[0] == '!')) {
                    $operator = ' != ';
                    $value    = substr($value, 1);
                } else {
                    if (($value === '!null') || (strtoupper($value) === 'IS NOT NULL')) {
                        $value    = 'null';
                        $operator = 'IS NOT';
                    } else {
                        if (is_null($operator)) {
                            $operator = ' = ';
                        }
                    }
                }
                if (is_bool($value)) {
                    if ($value === null) {
                        $value .= ' null,';
                    } elseif ($value) {
                        $value = ' TRUE';
                    } else {
                        $value = ' FALSE';
                    }
                } elseif (!is_string($value)) {
                    $value = " $value";
                } else {
                    if (strtoupper($value) == 'NOW()') {
                        $value = " 'NOW()'";
                    } else {
                        if ($value != 'null') {
                            $value = " '".addslashes($value)."'";
                        }
                    }
                    if ($operator == ' != ') {
                        $operator = ' NOT LIKE ';
                    } else {
                        if (is_null($operator)) {
                            $operator = ' LIKE ';
                        }
                    }
                }
            }

            $conditions[] = ' '.$this->getColumnComma().$column.$this->getColumnComma()."$operator $value ";
        }

        return trim(implode($ldiv, $conditions).' '.implode(' ', $conditionsII));
    }

public
function
prepSelect
(
$
data
,
$
ldiv
=
'AND'
)
{
$
operator
=
;
$
conditions
=
[
]
;
$
conditionsII
=
[
]
;
foreach
(
$
data
as
$
column
=>
$
value
)
{
if
(
is_integer
(
$
column
)
)
{
$
conditionsII
[
]
=
$
value
;
continue
;
}
if
(
(
$
column
==
$
this
->
keyColumn
)
&&
(
$
this
->
keyColumn
==
''
)
)
{
continue
;
}
if
(
is_string
(
$
value
)
&&
(
(
$
value
==
'!=""'
)
||
(
$
value
==
"!=''"
)
)
)
{
$
conditions
[
]
=
' '
.
$
this
->
getColumnComa
(
)
.
$
column
.
$
this
->
getColumnComma
(
)
.
" !='' "
;
continue
;
}
if
(
is_null
(
$
value
)
)
{
$
value
=
'null'
;
$
operator
=
' IS '
;
}
else
{
if
(
strlen
(
$
value
)
&&
(
$
value
[
0
]
==
'!'
)
)
{
$
operator
=
' != '
;
$
value
=
substr
(
$
value
,
1
)
;
}
else
{
if
(
(
$
value
===
'!null'
)
||
(
strtoupper
(
$
value
)
===
'IS NOT NULL'
)
)
{
$
value
=
'null'
;
$
operator
=
'IS NOT'
;
}
else
{
if
(
is_null
(
$
operator
)
)
{
$
operator
=
' = '
;
}
}
}
if
(
is_bool
(
$
value
)
)
{
if
(
$
value
===
)
{
$
value
.=
' null,'
;
}
elseif
(
$
value
)
{
$
value
=
' TRUE'
;
}
else
{
$
value
=
' FALSE'
;
}
}
elseif
(
!
is_string
(
$
value
)
)
{
$
value
=
" $value"
;
}
else
{
if
(
strtoupper
(
$
value
)
==
'NOW()'
)
{
$
value
=
" 'NOW()'"
;
}
else
{
if
(
$
value
!=
'null'
)
{
$
value
=
" '"
.
addslashes
(
$
value
)
.
"'"
;
}
}
if
(
$
operator
==
' != '
)
{
$
operator
=
' NOT LIKE '
;
}
else
{
if
(
is_null
(
$
operator
)
)
{
$
operator
=
' LIKE '
;
}
}
}
}
$
conditions
[
]
=
' '
.
$
this
->
getColumnComma
(
)
.
$
column
.
$
this
->
getColumnComma
(
)
.
"$operator $value "
;
}
return
trim
(
implode
(
$
ldiv
,
$
conditions
)
.
' '
.
implode
(
' '
,
$
conditionsII
)
)
;
}

Generuje fragment MySQL dotazu z pole data.

@param array  $data Pokud hodnota zacina znakem ! Je tento odstranen a generovan je negovany test
@param string $ldiv typ generovane podminky AND/OR

@return string

Generuje fragment MySQL dotazu z pole data .


public function useObject($object)
    {
        $this->setKeyColumn($object->getKeyColumn());
        $this->setTableName($object->getMyTable());
    }

public function useObject ( $ object ) { $ this -> setKeyColumn ( $ object -> getKeyColumn ( ) ) ; $ this -> setTableName ( $ object -> getMyTable ( ) ) ; }

Set Up PDO for curent usage.

@param \Ease\Brick $object or its child


public function addSlide($slide, $capHeading = '', $caption = '',
                             $default = false)
    {
        $item = new \Ease\Html\DivTag($slide, ['class' => 'item']);
        if ($default) {
            $item->addTagClass('active');
        }

        if ($capHeading || $caption) {
            $cpt = $item->addItem(new \Ease\Html\DivTag(null,
                    ['class' => 'carousel-caption']));
            if ($capHeading) {
                $cpt->addItem(new \Ease\Html\H4Tag($capHeading));
            }
            if ($caption) {
                $cpt->addItem(new \Ease\Html\PTag($caption));
            }
        }
        $to        = $this->indicators->getItemsCount();
        $indicator = new \Ease\Html\LiTag(null,
            ['data-target' => '#'.$this->name, 'data-slide-to' => $to]);
        if ($default) {
            $indicator->addTagClass('active');
            $this->active = $to;
        }
        $this->indicators->addItem($indicator);
        $this->inner->addItem($item);
    }

public function addSlide ( $ slide , $ capHeading = '' , $ caption = '' , $ default = false ) { $ item = new \ Ease \ Html \ DivTag ( $ slide , [ 'class' => 'item' ] ) ; if ( $ default ) { $ item -> addTagClass ( 'active' ) ; } if ( $ capHeading || $ caption ) { $ cpt = $ item -> addItem ( new \ Ease \ Html \ DivTag ( null , [ 'class' => 'carousel-caption' ] ) ) ; if ( $ capHeading ) { $ cpt -> addItem ( new \ Ease \ Html \ H4Tag ( $ capHeading ) ) ; } if ( $ caption ) { $ cpt -> addItem ( new \ Ease \ Html \ PTag ( $ caption ) ) ; } } $ to = $ this -> indicators -> getItemsCount ( ) ; $ indicator = new \ Ease \ Html \ LiTag ( null , [ 'data-target' => '#' . $ this -> name , 'data-slide-to' => $ to ] ) ; if ( $ default ) { $ indicator -> addTagClass ( 'active' ) ; $ this -> active = $ to ; } $ this -> indicators -> addItem ( $ indicator ) ; $ this -> inner -> addItem ( $ item ) ; }

Carousel Slide.

@param mixed|ImgTag $slide      body Image or something else
@param string       $capHeading
@param string       $caption
@param bool         $default    show slide by default


public function finalize()
    {
        Part::twBootstrapize();
        if (is_null($this->active) && $this->getItemsCount() ) { //We need one slide active
            $this->indicators->getFirstPart()->setTagClass('active');
            $this->inner->getFirstPart()->addTagClass('active');
        }
        $this->inner->addItem(
            new \Ease\Html\ATag(
                '#'.$this->getTagID(),
                [
                new \Ease\Html\Span(null,
                    ['class' => 'glyphicon glyphicon-chevron-left', 'aria-hidden' => 'true']),
                new \Ease\Html\Span(_('Previous'), ['class' => 'sr-only']),
                ],
                ['class' => 'left carousel-control', 'data-slide' => 'prev', 'role' => 'button']
            )
        );
        $this->inner->addItem(
            new \Ease\Html\ATag(
                '#'.$this->getTagID(),
                [
                new \Ease\Html\Span(null,
                    ['class' => 'glyphicon glyphicon-chevron-right', 'aria-hidden' => 'true']),
                new \Ease\Html\Span(_('Next'), ['class' => 'sr-only']),
                ],
                ['class' => 'right carousel-control', 'data-slide' => 'next', 'role' => 'button']
            )
        );
        if ($this->getTagProperty('data-ride') != 'carousel') {
            $this->addJavaScript('$(\'#'.$this->name.'\').carousel();', null,
                true);
        }
    }

public
function
finalize
(
)
{
Part
::
twBootstrapize
(
)
;
if
(
is_null
(
$
this
->
active
)
&&
$
this
->
getItemsCount
(
)
)
{
//We need one slide active
$
this
->
indicators
->
getFirstPart
(
)
->
setTagClass
(
'active'
)
;
$
this
->
inner
->
getFirstPart
(
)
->
addTagClass
(
'active'
)
;
}
$
this
->
inner
->
addItem
(
new
\
Ease
\
Html
\
ATag
(
'#'
.
$
this
->
getTagID
(
)
,
[
new
\
Ease
\
Html
\
Span
(
,
[
'class'
=>
'glyphicon glyphicon-chevron-left'
,
'aria-hidden'
=>
'true'
]
)
,
new
\
Ease
\
Html
\
Span
(
_
(
'Previous'
)
,
[
'class'
=>
'sr-only'
]
)
,
]
,
[
'class'
=>
'left carousel-control'
,
'data-slide'
=>
'prev'
,
'role'
=>
'button'
]
)
)
;
$
this
->
inner
->
addItem
(
new
\
Ease
\
Html
\
ATag
(
'#'
.
$
this
->
getTagID
(
)
,
[
new
\
Ease
\
Html
\
Span
(
,
[
'class'
=>
'glyphicon glyphicon-chevron-right'
,
'aria-hidden'
=>
'true'
]
)
,
new
\
Ease
\
Html
\
Span
(
_
(
'Next'
)
,
[
'class'
=>
'sr-only'
]
)
,
]
,
[
'class'
=>
'right carousel-control'
,
'data-slide'
=>
'next'
,
'role'
=>
'button'
]
)
)
;
if
(
$
this
->
getTagProperty
(
'data-ride'
)
!=
'carousel'
)
{
$
this
->
addJavaScript
(
'$(\'#'
.
$
this
->
name
.
'\').carousel();'
,
,
true
)
;
}
}


public function addToLog($caller, $message, $type = 'info')
    {
        foreach ($this->loggers as $logger) {
            $logger->addToLog($caller, $message, $type);
        }
    }

public function addToLog ( $ caller , $ message , $ type = 'info' ) { foreach ( $ this -> loggers as $ logger ) { $ logger -> addToLog ( $ caller , $ message , $ type ) ; } }

Add Status Message to all registered loggers

@param string $caller  message provider
@param string $message message to log
@param string $type    info|succes|warning|error|email|...


public function addStatusObject(Message $message, $type = 'info')
    {
        $this->addToLog($message->caller, $message->body, $message->type);
        \Ease\Shared::instanced()->addStatusMessage($message->body,
            $message->type);
        return parent::addStatusMessage($message->body, $message->type);
    }

public function addStatusObject ( Message $ message , $ type = 'info' ) { $ this -> addToLog ( $ message -> caller , $ message -> body , $ message -> type ) ; \ Ease \ Shared :: instanced ( ) -> addStatusMessage ( $ message -> body , $ message -> type ) ; return parent :: addStatusMessage ( $ message -> body , $ message -> type ) ; }

Add Status Object to stack

@param \Ease\Logger\Message $message
@param string $type

@return type


public function getTagName()
    {
        $tagName = null;
        if ($this->setName === true) {
            if (isset($this->tagProperties['name'])) {
                $tagName = $this->tagProperties['name'];
            }
        } else {
            $tagName = $this->tagName;
        }

        return $tagName;
    }

public function getTagName ( ) { $ tagName = null ; if ( $ this -> setName === true ) { if ( isset ( $ this -> tagProperties [ 'name' ] ) ) { $ tagName = $ this -> tagProperties [ 'name' ] ; } } else { $ tagName = $ this -> tagName ; } return $ tagName ; }


public function getTagProperty($propertyName)
    {
        $property = null;
        if (isset($this->tagProperties[$propertyName])) {
            $property = $this->tagProperties[$propertyName];
        }

        return $property;
    }

public function getTagProperty ( $ propertyName ) { $ property = null ; if ( isset ( $ this -> tagProperties [ $ propertyName ] ) ) { $ property = $ this -> tagProperties [ $ propertyName ] ; } return $ property ; }

Returns property tag value.

@param string $propertyName název vlastnosti tagu. např. "src" u obrázku

@return string current tag property value


public function finalize()
    {
        Part::twBootstrapize();
        $modalDialog  = $this->addItem(new \Ease\Html\DivTag(null,
                ['class' => 'modal-dialog', 'role' => 'document']));
        $modalContent = $modalDialog->addItem(new \Ease\Html\DivTag(null,
                ['class' => 'modal-content']));
        $this->header->addItem(new \Ease\Html\H4Tag($this->title,
                ['class' => 'modal-title', 'id' => $this->title.'ID']));
        $modalContent->addItem($this->header);
        $modalContent->addItem($this->body);
        $modalContent->addItem($this->footer);
        if (is_array($this->properties)) {
            \Ease\Shared::webPage()->addJavaScript(
                ' $(function ()
{
    $("#'.$this->name.'").modal( {'.Part::partPropertiesToString($this->properties).'});
});
', null, true
            );
        } else {
            \Ease\Shared::webPage()->addJavaScript(
                ' $(function ()
{
    $("#'.$this->name.'").modal( '.$this->properties.');
});
', null, true
            );
        }
    }


public function cloneEarlyRunner()
    {
        $ret          = clone $this;
        $ret->nextRun = time();
        $this->once   = true;

        //\mdebug('Cloned early runner for process [%d]', $this->currentPid);

        return $ret;
    }

clones an early runner when frequency is reached before current run finishes


public function &addAjaxTab($tabName, $tabUrl, $active = false)
    {
        $this->tabs[$tabName] = ['ajax' => $tabUrl];
        if ($active) {
            $this->activeTab = $tabName;
        }
        \Ease\Shared::webPage()->addJavaScript('
$(\'#'.$this->getTagID().' a\').click(function (e) {
	e.preventDefault();

	var url = $(this).attr("data-url");
  	var href = this.hash;
  	var pane = $(this);

	// ajax load from data-url
	$(href).load(url,function(result){
	    pane.tab(\'show\');
	});
});

');
        return $this->tabs[$tabName];
    }

Create new Dynamic Tab

@param string $tabName    jméno a titulek tabu
@param string $tabUrl     where to obtain tab content
@param bool   $active     Má být tento tab aktivní ?

@return \Ease\Html\DivTag odkaz na vložený obsah


protected function trace($data)
    {
        if ($this->_debug) {

            //Open the tags and output request specific items
            if ($data->getType() == "request") {
                print '

';
                print "
Request to server
";
                print "
{$data->getMethod()} {$data->getRequestUrl()}
";
            }

            //Output response specific items
            if ($data->getType() == "response") {
                print '
Response from server
';

                if ($data->getHttpCode() >= 400) {
                    print '
' . $data->getHttpCode() . ' ' . $data->getHttpCodeDefinition() . '
';
                } else {
                    print '
' . $data->getHttpCode() . ' ' . $data->getHttpCodeDefinition() . '
';
                }

            }

            //Headers
            print "
";
            foreach ($data->getHeaders() as $header => $value) {
                 print "$header : $value\n";
            }
            print "
";

            //Body
            if ($data->getBody()) {
                $body = json_decode($data->getBody());
                print "
" . json_encode($body, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . "
";
            }

            //Close off the tags
            if ($data->getType() == "request") {
                print '	';
            }

            if ($data->getType() == "response") {
                print '
Time taken: ' . $data->getTimeTaken() * 1000 . ' ms
';
                print "

";
            }
        }
    }

Outputs the debug message.
@param \triagens\ArangoDb\TraceResponse|\triagens\ArangoDb\TraceRequest $data The HTTP request or response trace object.


public function attach($events, IObserver $observer)
    {
        if (is_array($events)) {
            foreach ($events as $event) {
                $this->doAttach($event, $observer);
            }
        } elseif (is_string($events)) {
            $this->doAttach($events, $observer);
        } else {
            throw new ObservableException("Event can only be a string containing the name of the event or an array of event names.");
        }
    }

Attach a listener.
@param  string|array        $events   The event type. This can be an array of event types or just a string for one event.
@param  IObserver           $observer The listener.
@throws ObservableException


protected function doAttach($event, IObserver $observer)
    {
        if (!array_key_exists($event, $this->_observers)) {
            $this->_observers[$event] = array();
        }

        if (in_array($observer, $this->_observers[$event], true)) {
            return;
        }

        array_push($this->_observers[$event], $observer);
    }

protected function doAttach ( $ event , IObserver $ observer ) { if ( ! array_key_exists ( $ event , $ this -> _observers ) ) { $ this -> _observers [ $ event ] = array ( ) ; } if ( in_array ( $ observer , $ this -> _observers [ $ event ] , true ) ) { return ; } array_push ( $ this -> _observers [ $ event ] , $ observer ) ; }

Do the actual work of attaching the listener.
@param string    $event    The event.
@param IObserver $observer The listener.

Do the actual work of attaching the listener .


public function detach($event, IObserver $observer)
    {
        if (!isset($this->_observers[$event])) {
            return;
        }

        foreach ($this->_observers[$event] as $key=> $attachedObserver) {
            if ($attachedObserver === $observer) {
                array_splice($this->_observers[$event], $key, 1);
            }
        }
    }

public function detach ( $ event , IObserver $ observer ) { if ( ! isset ( $ this -> _observers [ $ event ] ) ) { return ; } foreach ( $ this -> _observers [ $ event ] as $ key => $ attachedObserver ) { if ( $ attachedObserver === $ observer ) { array_splice ( $ this -> _observers [ $ event ] , $ key , 1 ) ; } } }

Detatch an observer from an event.
@param string    $event    The event to detach from.
@param IObserver $observer The observer that we want to detach.


public function detachAllEventsForObserver(IObserver $observerToRemove)
    {
        foreach ($this->_observers as $event => $observers) {
            foreach ($observers as $position => $observer) {

                if ($observer === $observerToRemove) {
                    array_splice($this->_observers[$event], $position, 1);
                    break; //Save cycles by breaking here since there is each observer is only attached to each event once.
                }
            }
        }
    }

Remove all events for an observer.
@param IObserver $observerToRemove The observer we wish to detach.


public function validatePod($pod)
    {
        if ($pod instanceof  AModel) {
            $pod = $pod->getPod();
        }

        if ($pod->compareToolbox($this)) {
            return true;
        } else {
            throw new ToolboxException("The pod/model does not belong to this toolbox.");
        }
    }

Checks to see if the pod belongs to this toolbox.
@param AModel|Document $pod The pod to validate.

Checks to see if the pod belongs to this toolbox .


public function getConnection()
    {
        if (!$this->_connection) {

            $options = array(
                    // server endpoint to connect to
                    ConnectionOptions::OPTION_ENDPOINT       => $this->_endpoint,
                    // authorization type to use (currently supported: 'Basic')
                    ConnectionOptions::OPTION_AUTH_TYPE      => 'Basic',
                    // user for basic authorization
                    ConnectionOptions::OPTION_AUTH_USER      => $this->_username,
                    // password for basic authorization
                    ConnectionOptions::OPTION_AUTH_PASSWD    => $this->_password,
                    ConnectionOptions::OPTION_TRACE          => $this->_debug,
                    ConnectionOptions::OPTION_ENHANCED_TRACE => true,
                    ConnectionOptions::OPTION_DATABASE       => $this->_database
            );

            $this->_connection = new Connection($options);
        }

        return $this->_connection;
    }

Get the ArangoDB-PHP connection.
@return \triagens\ArangoDb\Connection


public function getDriver()
    {
        if (!$this->_driver) {

            if ($this->_graph) {
                $this->_driver = $this->getGraphHandler();
            } else {
                $this->_driver = $this->getDocumentHandler();
            }
        }

        return $this->_driver;
    }

public function getDriver ( ) { if ( ! $ this -> _driver ) { if ( $ this -> _graph ) { $ this -> _driver = $ this -> getGraphHandler ( ) ; } else { $ this -> _driver = $ this -> getDocumentHandler ( ) ; } } return $ this -> _driver ; }

Automatically determines which handler we need and return it.
@return \triagens\ArangoDb\DocumentHandler|\triagens\ArangoDb\GraphHandler

Automatically determines which handler we need and return it .


public function generateBindingParameter($parameter, $userParameters)
    {
        $userParameters = array_keys($userParameters);

        while (in_array($parameter, $userParameters)) {

            $characters = '0123456789abcdefghijklmnopqrstuvwxyz';

            for ($i = 0; $i < 7; $i++) {
                $parameter .= $characters[rand(0, strlen($characters) - 1)];
            }
        }

        return $parameter;
    }

public function generateBindingParameter ( $ parameter , $ userParameters ) { $ userParameters = array_keys ( $ userParameters ) ; while ( in_array ( $ parameter , $ userParameters ) ) { $ characters = '0123456789abcdefghijklmnopqrstuvwxyz' ; for ( $ i = 0 ; $ i < 7 ; $ i ++ ) { $ parameter .= $ characters [ rand ( 0 , strlen ( $ characters ) - 1 ) ] ; } } return $ parameter ; }

This generates a binding parameter for filtering so that it does not clash with any user defined parameters.
@param  array  $userParameters An array of binding parameters.
@return string

This generates a binding parameter for filtering so that it does not clash with any user defined parameters .


public function normaliseDriverExceptions(\Exception $exception)
    {
        if ($exception instanceof \triagens\ArangoDb\ServerException) {
            return array('message' => $exception->getServerMessage(), 'code' => $exception->getServerCode());
        } else {
            return array('message' => $exception->getMessage(), 'code' => $exception->getCode());
        }
    }

public function normaliseDriverExceptions ( \ Exception $ exception ) { if ( $ exception instanceof \ triagens \ ArangoDb \ ServerException ) { return array ( 'message' => $ exception -> getServerMessage ( ) , 'code' => $ exception -> getServerCode ( ) ) ; } else { return array ( 'message' => $ exception -> getMessage ( ) , 'code' => $ exception -> getCode ( ) ) ; } }

Normalises the exceptions thrown by ArangoDB-PHP.
@param  \Exception $exception
@return array

Normalises the exceptions thrown by ArangoDB - PHP .


public function createDatabase($name)
    {
        try {
            Database::create($this->getConnection(), $name);

            return true;

        } catch (\Exception $e) {
            $normalised = $this->_toolbox->normaliseDriverExceptions($e);
            throw new DatabaseManagerException($normalised['message'], $normalised['code']);
        }
    }

public function createDatabase ( $ name ) { try { Database :: create ( $ this -> getConnection ( ) , $ name ) ; return true ; } catch ( \ Exception $ e ) { $ normalised = $ this -> _toolbox -> normaliseDriverExceptions ( $ e ) ; throw new DatabaseManagerException ( $ normalised [ 'message' ] , $ normalised [ 'code' ] ) ; } }

Create a database using the current connection's settings and add it as a connection.
@param  string                   $name The name of the database.
@throws DatabaseManagerException
@return boolean

Create a database using the current connection s settings and add it as a connection .


public function deleteDatabase($name)
    {
        try {
            Database::delete($this->getConnection(), $name);

            return true;
        } catch (\Exception $e) {
            $normalised = $this->_toolbox->normaliseDriverExceptions($e);
            throw new DatabaseManagerException($normalised['message'], $normalised['code']);
        }
    }

public function deleteDatabase ( $ name ) { try { Database :: delete ( $ this -> getConnection ( ) , $ name ) ; return true ; } catch ( \ Exception $ e ) { $ normalised = $ this -> _toolbox -> normaliseDriverExceptions ( $ e ) ; throw new DatabaseManagerException ( $ normalised [ 'message' ] , $ normalised [ 'code' ] ) ; } }

Delete a database.
@param  string                   $name The name of the database.
@throws DatabaseManagerException


public function getDatabaseInfo($name)
    {
        try {
            $connection = $this->getConnection($name);

            $info = Database::getInfo($connection);

            $result = array();

            $result['id'] = $info['result']['id'];
            $result['name'] = $info['result']['name'];
            $result['path'] = $info['result']['path'];
            $result['isSystem'] = $info['result']['isSystem'];

            return $result;

        } catch (\Exception $e) {
            $normalised = $this->_toolbox->normaliseDriverExceptions($e);
            throw new DatabaseManagerException($normalised['message'], $normalised['code']);
        }
    }

public function getDatabaseInfo ( $ name ) { try { $ connection = $ this -> getConnection ( $ name ) ; $ info = Database :: getInfo ( $ connection ) ; $ result = array ( ) ; $ result [ 'id' ] = $ info [ 'result' ] [ 'id' ] ; $ result [ 'name' ] = $ info [ 'result' ] [ 'name' ] ; $ result [ 'path' ] = $ info [ 'result' ] [ 'path' ] ; $ result [ 'isSystem' ] = $ info [ 'result' ] [ 'isSystem' ] ; return $ result ; } catch ( \ Exception $ e ) { $ normalised = $ this -> _toolbox -> normaliseDriverExceptions ( $ e ) ; throw new DatabaseManagerException ( $ normalised [ 'message' ] , $ normalised [ 'code' ] ) ; } }

Get information about a database.
@param  string                   $name The name of the database.
@throws DatabaseManagerException
@return array


public function listDatabases()
    {
        try {
            $connection = $this->getConnection();

            $result = Database::listDatabases($connection);

            if (empty($result['result'])) {
                return array();
            } else {
                return $result['result'];
            }

        } catch (\Exception $e) {
            $normalised = $this->_toolbox->normaliseDriverExceptions($e);
            throw new DatabaseManagerException($normalised['message'], $normalised['code']);
        }
    }

public function listDatabases ( ) { try { $ connection = $ this -> getConnection ( ) ; $ result = Database :: listDatabases ( $ connection ) ; if ( empty ( $ result [ 'result' ] ) ) { return array ( ) ; } else { return $ result [ 'result' ] ; } } catch ( \ Exception $ e ) { $ normalised = $ this -> _toolbox -> normaliseDriverExceptions ( $ e ) ; throw new DatabaseManagerException ( $ normalised [ 'message' ] , $ normalised [ 'code' ] ) ; } }

Lists all databases availiable.
@throws DatabaseManagerException
@return array


private function getConnection($database = '_system')
    {
        $connection = clone $this->_toolbox->getConnection();
        $connection->setDatabase($database);

        return $connection;
    }

private function getConnection ( $ database = '_system' ) { $ connection = clone $ this -> _toolbox -> getConnection ( ) ; $ connection -> setDatabase ( $ database ) ; return $ connection ; }

Get a cloned connection with targetting a database.
@param  string                        $database The optional name of the database. Defaults to _system.
@return \triagens\ArangoDb\Connection

Get a cloned connection with targetting a database .


public function useConnection($name)
    {
        if (!array_key_exists($name, $this->_toolboxes)) {
            throw new ClientException("The connection ($name) you are trying to use is not registered with the client.");
        }

        $this->_currentConnection = $name;
    }

Selects the connection as current connection. Any method executed through the client will use this connection.
@param  string          $name The name of the connection to use.
@throws ClientException

Selects the connection as current connection . Any method executed through the client will use this connection .


public function getToolbox($name = 'default')
    {
        if (!array_key_exists($name, $this->_toolboxes)) {
            throw new ClientException("The toolbox for connection ($name) does not exist! Is the connection added to the client?");
        }

        return $this->_toolboxes[$name];
    }

Get a toolbox for a connection.
@param  string          $name The name of the connection.
@throws ClientException
@return Toolbox


public function setModelFormatter(IModelFormatter $formatter)
    {
        $this->_modelFormatter = $formatter;

        foreach ($this->_toolboxes as $toolbox) {
            $toolbox->setModelFormatter($formatter);
        }
    }

public function setModelFormatter ( IModelFormatter $ formatter ) { $ this -> _modelFormatter = $ formatter ; foreach ( $ this -> _toolboxes as $ toolbox ) { $ toolbox -> setModelFormatter ( $ formatter ) ; } }

Adds a model formatter to the client. Once the the model formatter is added, it will be used to determine what models to load in all future operations.
@param IModelFormatter $formatter An instance of the formatter.

Adds a model formatter to the client . Once the the model formatter is added it will be used to determine what models to load in all future operations .


public function load($collection, $id)
    {
        return $this->getToolbox($this->_currentConnection)->getPodManager()->load($collection, $id);
    }

public function load ( $ collection , $ id ) { return $ this -> getToolbox ( $ this -> _currentConnection ) -> getPodManager ( ) -> load ( $ collection , $ id ) ; }

Loads a model from the server using the collection type and the id.
@param  string $collection The collection to load from. For graphs, this can only be "vertex" or "edge".
@param  string $id         The id (key in ArangoDB jargon) of the document, edge or vertex.
@return AModel

Loads a model from the server using the collection type and the id .


public function createGraph($name)
    {
        $toolbox = $this->getToolbox($this->_currentConnection);
        $toolbox->getGraphManager()->createGraph($name);
        $this->addConnection($name, $toolbox->getEndpoint(), array('username' => $toolbox->getUsername(), 'password' => $toolbox->getPassword(), 'graph' => $name, 'database' => $toolbox->getDatabase()));

        return true;
    }

public function createGraph ( $ name ) { $ toolbox = $ this -> getToolbox ( $ this -> _currentConnection ) ; $ toolbox -> getGraphManager ( ) -> createGraph ( $ name ) ; $ this -> addConnection ( $ name , $ toolbox -> getEndpoint ( ) , array ( 'username' => $ toolbox -> getUsername ( ) , 'password' => $ toolbox -> getPassword ( ) , 'graph' => $ name , 'database' => $ toolbox -> getDatabase ( ) ) ) ; return true ; }

Create a graph using the current connection's settings and add it as a connection.
A connection is automatically added to the client using the name of the graph, so you need to be careful that it does not overwrite
another connection with the same name.

You do not need to set the vertex and edge collections. They are automatically named for you.

For example:
$client->createGraph('myGraph');
$client->useConnection('myGraph'); //You can now query the graph
@param  string  $name The name of the graph.
@return boolean

Create a graph using the current connection s settings and add it as a connection . A connection is automatically added to the client using the name of the graph so you need to be careful that it does not overwrite another connection with the same name .


public function renameCollection($collection, $newName)
    {
        return $this->getToolbox($this->_currentConnection)->getCollectionManager()->renameCollection($collection, $newName);
    }

public function renameCollection ( $ collection , $ newName ) { return $ this -> getToolbox ( $ this -> _currentConnection ) -> getCollectionManager ( ) -> renameCollection ( $ collection , $ newName ) ; }

Rename a collection.
@param string $collection The collection we wish to rename.
@param string $newName    The new name of the collection.


public function getIndexInfo($collection, $indexId)
    {
        return $this->getToolbox($this->_currentConnection)->getCollectionManager()->getIndexInfo($collection, $indexId);
    }

public function getIndexInfo ( $ collection , $ indexId ) { return $ this -> getToolbox ( $ this -> _currentConnection ) -> getCollectionManager ( ) -> getIndexInfo ( $ collection , $ indexId ) ; }

Get information about an index.
@param string $collection The name of the collection.
@param string $indexId    The id of the index.


public function load($type, $id)
    {
        $driver = $this->_toolbox->getDriver();

        try {
            if ($this->_toolbox->isGraph()) {

                switch (strtolower($type)) {

                    case "vertex":

                        if ($this->hasTransaction()) {
                            $this->_toolbox->getTransactionManager()->addReadCollection($this->_toolbox->getVertexCollectionName());
                            $this->addTransactionCommand("function () {var temp = graph.getVertex('$id'); return temp ? temp._properties : null}();", "PodManager:load", null, true, array('type' => $type));
                        } else {
                            $vertex = $driver->getVertex($this->_toolbox->getGraph(), $id);

                            return $this->convertDriverDocumentToPod($vertex);
                        }
                        break;

                    case "edge":

                        if ($this->hasTransaction()) {
                            $this->_toolbox->getTransactionManager()->addReadCollection($this->_toolbox->getEdgeCollectionName());
                            $this->addTransactionCommand("graph.getEdge('$id')._properties;", "PodManager:load", null, true, array('type' => $type));
                        } else {
                            $edge = $driver->getEdge($this->_toolbox->getGraph(), $id);

                            return $this->convertDriverDocumentToPod($edge);
                        }
                        break;

                    default:
                        throw new PodManagerException("For graphs, only the types 'vertex' and 'edge' can be loaded.");
                }

            } else {

                if ($this->hasTransaction()) {
                    $this->_toolbox->getTransactionManager()->addReadCollection($type);
                    $this->addTransactionCommand("db.$type.document('$id');", "PodManager:load", null, false, array('type' => $type));
                } else {
                    $document = $driver->getById($type, $id);

                    return $this->convertDriverDocumentToPod($document);
                }

            }
        } catch (\Exception $e) {

            //Rethrow the exception from the try block
            if ($e instanceof PodManagerException) {
                throw $e;

            //Otherwise just return a null if the pod does not exist, or if there is an error.
            } else {
                return null;
            }
        }

    }

Loads a model from the server using the collection type and the id. Returns null if the pod could not be found or loaded.
@param  string $collection The collection to load from. For graphs, this can only be "vertex" or "edge".
@param  string $id         The id (key in ArangoDB jargon) of the document, edge or vertex.
@return AModel

Loads a model from the server using the collection type and the id . Returns null if the pod could not be found or loaded .


public function processStoreResult($pod, $revision, $id = null)
    {
        $pod->setSaved();
        $pod->setRevision($revision);

        if ($id && $pod->getId() === null) {
            $pod->setId($id);
        }

        //Signal here
        $this->notify("after_store", $pod);

        return $pod->getKey();
    }

public
function
processStoreResult
(
$
pod
,
$
revision
,
$
id
=
)
{
$
pod
->
setSaved
(
)
;
$
pod
->
setRevision
(
$
revision
)
;
if
(
$
id
&&
$
pod
->
getId
(
)
===
)
{
$
pod
->
setId
(
$
id
)
;
}
//Signal here
$
this
->
notify
(
"after_store"
,
$
pod
)
;
return
$
pod
->
getKey
(
)
;
}

Process the result after storing a pod.
@param Paraodx\pod\Document|Paradox\pod\Vertex|Paradox\pod\Edge $pod      The pod to process.
@param string                                                   $revision The revision of the pod.
@param string                                                   $id       The id of the pod.

Process the result after storing a pod .


public function convertToPods($type, array $documents)
    {
        $result = array();

        foreach ($documents as $document) {

            if ($document instanceof \triagens\ArangoDb\Document) {
                $model = $this->convertDriverDocumentToPod($document);

                $result[$document->getInternalId()] = $model;

            } else {
                $model = $this->convertArrayToPod($type, $document);

                if (isset($document['_id'])) {
                    $result[$document['_id']] = $model;
                } else {
                    $result[] = $model;
                }
            }
        }

        return $result;
    }

public function convertToPods ( $ type , array $ documents ) { $ result = array ( ) ; foreach ( $ documents as $ document ) { if ( $ document instanceof \ triagens \ ArangoDb \ Document ) { $ model = $ this -> convertDriverDocumentToPod ( $ document ) ; $ result [ $ document -> getInternalId ( ) ] = $ model ; } else { $ model = $ this -> convertArrayToPod ( $ type , $ document ) ; if ( isset ( $ document [ '_id' ] ) ) { $ result [ $ document [ '_id' ] ] = $ model ; } else { $ result [ ] = $ model ; } } } return $ result ; }

Converts an array of documents into pods. The documents in each array can be an ArangoDB-PHP document, edge or vertex or an associative array.
@param  string $type      The type the resulting pods should have.
@param  array  $documents An array of documents or associative arrays.
@return array

Converts an array of documents into pods . The documents in each array can be an ArangoDB - PHP document edge or vertex or an associative array .


public function convertArrayToPod($type, array $data)
    {
        $model = $this->dispense($type);
        $pod = $model->getPod();

        $pod->loadFromArray($data);

        //Signal here
        $this->notify("after_open", $model->getPod());

        return $model;
    }

public
function
convertArrayToPod
(
$
type
,
array
$
data
)
{
$
model
=
$
this
->
dispense
(
$
type
)
;
$
pod
=
$
model
->
getPod
(
)
;
$
pod
->
loadFromArray
(
$
data
)
;
//Signal here
$
this
->
notify
(
"after_open"
,
$
model
->
getPod
(
)
)
;
return
$
model
;
}

Converts an associative array to a pod.
@param  string $type The type of the resulting pod.
@param  array  $data An associative array containing the data for the pod.
@return AModel

Converts an associative array to a pod .


public function convertDriverDocumentToPod(\triagens\ArangoDb\Document $driverDocument)
    {
        switch ($driverDocument) {
            case $driverDocument instanceof \triagens\ArangoDb\Vertex:
                $model = $this->dispense("vertex");
                break;

            case $driverDocument instanceof \triagens\ArangoDb\Edge:
                $model = $this->dispense("edge");
                break;

            default:
                @list($collection,) = explode('/', $driverDocument->getInternalId(), 2);
                $model = $this->dispense($collection);
        }

        $model->getPod()->loadFromDriver($driverDocument);
        $model->getPod()->setSaved();

        //Signal here
        $this->notify("after_open", $model->getPod());

        return $model;
    }

public
function
convertDriverDocumentToPod
(
\
triagens
\
ArangoDb
\
Document
$
driverDocument
)
{
switch
(
$
driverDocument
)
{
case
$
driverDocument
instanceof
\
triagens
\
ArangoDb
\
Vertex
:
$
model
=
$
this
->
dispense
(
"vertex"
)
;
break
;
case
$
driverDocument
instanceof
\
triagens
\
ArangoDb
\
Edge
:
$
model
=
$
this
->
dispense
(
"edge"
)
;
break
;
default
:
@
list
(
$
collection
,
)
=
explode
(
'/'
,
$
driverDocument
->
getInternalId
(
)
,
2
)
;
$
model
=
$
this
->
dispense
(
$
collection
)
;
}
$
model
->
getPod
(
)
->
loadFromDriver
(
$
driverDocument
)
;
$
model
->
getPod
(
)
->
setSaved
(
)
;
//Signal here
$
this
->
notify
(
"after_open"
,
$
model
->
getPod
(
)
)
;
return
$
model
;
}

Converts an ArangoDB-PHP document, edge or vertex into a pod.
@param  \triagens\ArangoDb\Document $driverDocument The ArangoDB-PHP document, edge or vertex.
@return AModel

Converts an ArangoDB - PHP document edge or vertex into a pod .


private function createVertex(array $data = array(), $new = true)
    {
        $vertex = new Vertex($this->_toolbox, $data, $new);
        $this->attachEventsToPod($vertex);

        return $this->setupModel($vertex, $vertex);
    }

private function createVertex ( array $ data = array ( ) , $ new = true ) { $ vertex = new Vertex ( $ this -> _toolbox , $ data , $ new ) ; $ this -> attachEventsToPod ( $ vertex ) ; return $ this -> setupModel ( $ vertex , $ vertex ) ; }

Convinence function to instantiate a vertex, hook up its events and set up its model.
@param array  $data An optional array of data that will be loaded into the vertex.
@param string $new  Whether this pod should be marked as new (never saved to the server).

Convinence function to instantiate a vertex hook up its events and set up its model .


private function createEdge(array $data = array(), $new = true)
    {
        $edge = new Edge($this->_toolbox, $data, $new);
        $this->attachEventsToPod($edge);

        return $this->setupModel($edge, $edge);
    }

private function createEdge ( array $ data = array ( ) , $ new = true ) { $ edge = new Edge ( $ this -> _toolbox , $ data , $ new ) ; $ this -> attachEventsToPod ( $ edge ) ; return $ this -> setupModel ( $ edge , $ edge ) ; }

Convinence function to instantiate an edge, hook up its events and set up its model.
@param array  $data An optional array of data that will be loaded into the edge.
@param string $new  Whether this pod should be marked as new (never saved to the server).

Convinence function to instantiate an edge hook up its events and set up its model .


private function createDocument($type, $data = array(), $new = true)
    {
        $document = new Document($this->_toolbox, $type, $data, $new);
        $this->attachEventsToPod($document);

        return $this->setupModel($document, $document);
    }

private function createDocument ( $ type , $ data = array ( ) , $ new = true ) { $ document = new Document ( $ this -> _toolbox , $ type , $ data , $ new ) ; $ this -> attachEventsToPod ( $ document ) ; return $ this -> setupModel ( $ document , $ document ) ; }

Convinence function to instantiate a document, hook up its events and set up its model.
@param array  $data An optional array of data that will be loaded into the document.
@param string $new  Whether this pod should be marked as new (never saved to the server).

Convinence function to instantiate a document hook up its events and set up its model .


private function setupModel(Document $pod)
    {
        $name = $this->_toolbox->formatModel($pod);

        $model = new $name();

        if (!($model instanceof AModel)) {
            throw new PodManagerException("Custom models must inherit from the Paradox Model class.");
        }

        $model->loadPod($pod);

        $pod->loadModel($model);

        return $model;
    }

Convinence function that sets up the model for a pod and associates the model with it.
@param  Document            $pod The pod we want to set up the model for.
@throws PodManagerException
@return AModel

Convinence function that sets up the model for a pod and associates the model with it .


private function determinePreviouslyStored($model)
    {
        $store = $this->_toolbox->getTransactionManager()->searchCommandsByActionAndObject('PodManager:store', $model);
        $delete = $this->_toolbox->getTransactionManager()->searchCommandsByActionAndObject('PodManager:delete', $model);

        $storePosition = $store ? $store['position'] : -1;
        $deletePosition = $delete ? $delete['position'] : -1;

        if ($deletePosition >= $storePosition) {
            return false;
        } else {
            return $store['id'];
        }
    }

private function determinePreviouslyStored ( $ model ) { $ store = $ this -> _toolbox -> getTransactionManager ( ) -> searchCommandsByActionAndObject ( 'PodManager:store' , $ model ) ; $ delete = $ this -> _toolbox -> getTransactionManager ( ) -> searchCommandsByActionAndObject ( 'PodManager:delete' , $ model ) ; $ storePosition = $ store ? $ store [ 'position' ] : - 1 ; $ deletePosition = $ delete ? $ delete [ 'position' ] : - 1 ; if ( $ deletePosition >= $ storePosition ) { return false ; } else { return $ store [ 'id' ] ; } }

Because transactions are executed in 1 go, this helps us deteremine if the pod has a previous command to store it.
We can then use its id to work with it in the transaction.
@param  AModel         $model The model to determine whether to delete or not.
@return boolean|string

Because transactions are executed in 1 go this helps us deteremine if the pod has a previous command to store it . We can then use its id to work with it in the transaction .


private function addTransactionCommand($command, $action, $object = null, $isGraph = false, $data = array())
    {
        return $this->_toolbox->getTransactionManager()->addCommand($command, $action, $object, $isGraph, $data);
    }

private function addTransactionCommand ( $ command , $ action , $ object = null , $ isGraph = false , $ data = array ( ) ) { return $ this -> _toolbox -> getTransactionManager ( ) -> addCommand ( $ command , $ action , $ object , $ isGraph , $ data ) ; }

Convinence function to add commands to the transaction.
@param unknown $command
@param unknown $action
@param string  $object
@param string  $isGraph

Convinence function to add commands to the transaction .


public function validateType($type)
    {
        if ($this->_toolbox->isGraph()) {

            if (!in_array(strtolower($type), array('edge', 'vertex'))) {
                return false;
            }
        }

        return true;
    }

public function validateType ( $ type ) { if ( $ this -> _toolbox -> isGraph ( ) ) { if ( ! in_array ( strtolower ( $ type ) , array ( 'edge' , 'vertex' ) ) ) { return false ; } } return true ; }

Validates the type to make sure it is valid in the current context. For graphs, a type other than "edge" or "vertex" would be invalid.
@param  string  $type The type to validate.
@return boolean

Validates the type to make sure it is valid in the current context . For graphs a type other than edge or vertex would be invalid .


public static function mapList(callable $callback, array $data): array
    {
        if (!isset($data[0])) {
            $data = [$data];
        }

        return array_map($callback, $data);
    }

public static function mapList ( callable $ callback , array $ data ) : array { if ( ! isset ( $ data [ 0 ] ) ) { $ data = [ $ data ] ; } return array_map ( $ callback , $ data ) ; }

Cleans the api response, so that you always get a list of elements.

@param callable $callback
@param array    $data

@return array

Cleans the api response so that you always get a list of elements .


final protected function crawl(string $url, array $params = []): ?Crawler
    {
        if ($content = $this->connection->getPageBody($url, $params)) {
            return new Crawler($content);
        }

        return null;
    }

final protected function crawl ( string $ url , array $ params = [ ] ) : ? Crawler { if ( $ content = $ this -> connection -> getPageBody ( $ url , $ params ) ) { return new Crawler ( $ content ) ; } return null ; }

Crawles a url.

@param string $url
@param array  $params

@return Crawler|null


final protected function parseUrl(Crawler $node, string $attr = 'href'): ?string
    {
        if (0 === $node->count()) {
            return null;
        }

        if ($url = $node->attr($attr)) {
            return preg_replace('/^\//', static::URL_PREFIX.'/', $url);
        }

        return null;
    }

final protected function parseUrl ( Crawler $ node , string $ attr = 'href' ) : ? string { if ( 0 === $ node -> count ( ) ) { return null ; } if ( $ url = $ node -> attr ( $ attr ) ) { return preg_replace ( '/^\//' , static :: URL_PREFIX . '/' , $ url ) ; } return null ; }

Parses a url node.

@param Crawler $node
@param string  $attr

@return string|null


final protected function parseImage(Crawler $node): ?Image
    {
        $src = $this->parseUrl($node, 'src');

        if (!$src) {
            return null;
        }

        return new Image($src);
    }

final protected function parseImage ( Crawler $ node ) : ? Image { $ src = $ this -> parseUrl ( $ node , 'src' ) ; if ( ! $ src ) { return null ; } return new Image ( $ src ) ; }

Parses an image node.

@param Crawler $node

@return Image|null


final protected function parseString(Crawler $node, bool $multiline = false): ?string
    {
        if (0 === $node->count()) {
            return null;
        }

        $content = $node->attr('content');

        if (null === $content) {
            if ($multiline) {
                $content = $node->html();
                $content = (string) preg_replace('/<p[^>]*?>/', '', $content);
                $content = str_replace('</p>', static::NEWLINE, $content);
                $content = (string) preg_replace('/<br\s?\/?>/i', static::NEWLINE, $content);
            } else {
                $content = $node->text();
            }
        }

        return trim(strip_tags($content));
    }

final protected function parseString ( Crawler $ node , bool $ multiline = false ) : ? string { if ( 0 === $ node -> count ( ) ) { return null ; } $ content = $ node -> attr ( 'content' ) ; if ( null === $ content ) { if ( $ multiline ) { $ content = $ node -> html ( ) ; $ content = ( string ) preg_replace ( '/<p[^>]*?>/' , '' , $ content ) ; $ content = str_replace ( '</p>' , static :: NEWLINE , $ content ) ; $ content = ( string ) preg_replace ( '/<br\s?\/?>/i' , static :: NEWLINE , $ content ) ; } else { $ content = $ node -> text ( ) ; } } return trim ( strip_tags ( $ content ) ) ; }

Parses a string node.

@param Crawler $node
@param bool    $multiline

@return string|null


final protected function parseDate(Crawler $node): ?DateTime
    {
        $content = $this->parseString($node);

        if (null !== $content) {
            return new DateTime($content);
        }

        return null;
    }

final protected function parseDate ( Crawler $ node ) : ? DateTime { $ content = $ this -> parseString ( $ node ) ; if ( null !== $ content ) { return new DateTime ( $ content ) ; } return null ; }

Parses a date note.

@param Crawler $node

@return DateTime|null


public static function load($className)
    {
        $className = str_replace(__NAMESPACE__, '', $className);
        $className = str_replace("\\", DIRECTORY_SEPARATOR, $className);

        if (file_exists(self::$dirRoot . $className . self::EXTENSION)) {
            require_once self::$dirRoot . $className . self::EXTENSION;
        }
    }

public static function load ( $ className ) { $ className = str_replace ( __NAMESPACE__ , '' , $ className ) ; $ className = str_replace ( "\\" , DIRECTORY_SEPARATOR , $ className ) ; if ( file_exists ( self :: $ dirRoot . $ className . self :: EXTENSION ) ) { require_once self :: $ dirRoot . $ className . self :: EXTENSION ; } }

Search for the class's file and require it.
@param string $className The name of the class.

Search for the class s file and require it .


protected function _start()
    {
        if (!$this->_isStart && $this->_coverage) {
            $this->_isStart = true;
            $this->_coverage->start($this->_hash, true);
        }
    }

protected function _start ( ) { if ( ! $ this -> _isStart && $ this -> _coverage ) { $ this -> _isStart = true ; $ this -> _coverage -> start ( $ this -> _hash , true ) ; } }


protected function _initConfig(array $options)
    {
        $options = array_filter($options, function ($option) {
            return null !== $option;
        });

        $this->_config = new Data(array_merge($this->_default, $options));
    }

protected function _initConfig ( array $ options ) { $ options = array_filter ( $ options , function ( $ option ) { return null !== $ option ; } ) ; $ this -> _config = new Data ( array_merge ( $ this -> _default , $ options ) ) ; }

Prepare and init config

@param array $options


public function relateTo(AModel $to, $label = null)
    {
        $edge = $this->_toolbox->getPodManager()->dispense("edge", $label);
        $edge->setTo($to);
        $edge->setFrom($this->getModel());

        return $edge;
    }

public function relateTo ( AModel $ to , $ label = null ) { $ edge = $ this -> _toolbox -> getPodManager ( ) -> dispense ( "edge" , $ label ) ; $ edge -> setTo ( $ to ) ; $ edge -> setFrom ( $ this -> getModel ( ) ) ; return $ edge ; }

Create an edge connecting this vertex to another vertex.
@param  AModel $to    The model we wish to connect to.
@param  string $label An optional label for this edge.
@return Edge

Create an edge connecting this vertex to another vertex .


public function getInboundEdges($label = null, $aql = "", $params = array(), $placeholder = "doc")
    {
        return $this->_toolbox->getGraphManager()->getInboundEdges($this->getId(), $label, $aql, $params, $placeholder);
    }

public function getInboundEdges ( $ label = null , $ aql = "" , $ params = array ( ) , $ placeholder = "doc" ) { return $ this -> _toolbox -> getGraphManager ( ) -> getInboundEdges ( $ this -> getId ( ) , $ label , $ aql , $ params , $ placeholder ) ; }

Get all inbound edges to this vertex. The edges can be filtered by their labels and AQL.
@param  string $label       A string representing one label or an array of labels we want the inbound edges to have.
@param  string $aql         An optional AQL fragment if we want to filter the edges, for example: FILTER doc.someproperty == "somevalue"
@param  array  $params      An optional associative array containing parameters to bind to the query.
@param  string $placeholder Set this to something else if you do not wish to use "doc" to refer to documents in your query.
@return array

Get all inbound edges to this vertex . The edges can be filtered by their labels and AQL .


public function toDriverDocument()
    {
        $vertex = new \triagens\ArangoDb\Vertex;

        foreach ($this->_data as $key => $value) {
            $vertex->set($key, $value);
        }

        if ($this->_id) {
            $vertex->setInternalId($this->_id);
        }

        if ($this->_key) {
            $vertex->setInternalKey($this->_key);
        }

        if ($this->_rev) {
            $vertex->setRevision($this->_rev);
        }

        return $vertex;
    }

public function toDriverDocument ( ) { $ vertex = new \ triagens \ ArangoDb \ Vertex ; foreach ( $ this -> _data as $ key => $ value ) { $ vertex -> set ( $ key , $ value ) ; } if ( $ this -> _id ) { $ vertex -> setInternalId ( $ this -> _id ) ; } if ( $ this -> _key ) { $ vertex -> setInternalKey ( $ this -> _key ) ; } if ( $ this -> _rev ) { $ vertex -> setRevision ( $ this -> _rev ) ; } return $ vertex ; }

Returns an ArangoDB-PHP vertex object representing this vertex.
@return \triagens\ArangoDb\Vertex

Returns an ArangoDB - PHP vertex object representing this vertex .


private function encodeUTF8($object)
    {
        if (\is_array($object)) {
            return array_map([$this, 'encodeUTF8'], $object);
        }

        return mb_convert_encoding((string) $object, 'UTF-8', 'auto');
    }

private function encodeUTF8 ( $ object ) { if ( \ is_array ( $ object ) ) { return array_map ( [ $ this , 'encodeUTF8' ] , $ object ) ; } return mb_convert_encoding ( ( string ) $ object , 'UTF-8' , 'auto' ) ; }

Converts any string or array of strings to UTF8.

@param mixed|mixed[] $object a String or an array

@return mixed|mixed[] UTF8-string or array

Converts any string or array of strings to UTF8 .


public function createCollection($name)
    {
        try {
            return $this->_toolbox->getCollectionHandler()->create($name);
        } catch (\Exception $e) {
            $normalised = $this->_toolbox->normaliseDriverExceptions($e);
            throw new CollectionManagerException($normalised['message'], $normalised['code']);
        }
    }

public function createCollection ( $ name ) { try { return $ this -> _toolbox -> getCollectionHandler ( ) -> create ( $ name ) ; } catch ( \ Exception $ e ) { $ normalised = $ this -> _toolbox -> normaliseDriverExceptions ( $ e ) ; throw new CollectionManagerException ( $ normalised [ 'message' ] , $ normalised [ 'code' ] ) ; } }

Create a collection.
@param  string                     $name The name of the collection.
@throws CollectionManagerException
@return string


public function deleteCollection($name)
    {
        try {
            return $this->_toolbox->getCollectionHandler()->delete($name);
        } catch (\Exception $e) {
            $normalised = $this->_toolbox->normaliseDriverExceptions($e);
            throw new CollectionManagerException($normalised['message'], $normalised['code']);
        }
    }

public function deleteCollection ( $ name ) { try { return $ this -> _toolbox -> getCollectionHandler ( ) -> delete ( $ name ) ; } catch ( \ Exception $ e ) { $ normalised = $ this -> _toolbox -> normaliseDriverExceptions ( $ e ) ; throw new CollectionManagerException ( $ normalised [ 'message' ] , $ normalised [ 'code' ] ) ; } }

Delete a collection.
@param  string                     $name The name of the collection.
@throws CollectionManagerException