Returns a subtree node items for given parent node

Following parameters are supported:
ezjscnode::subtree::parent_node_id::limit::offset::sort::order

@since 1.2
@param mixed $args
@return array
487802
public static function subTree( $args )
    {
        $parentNodeID = isset( $args[0] ) ? $args[0] : null;
        $limit = isset( $args[1] ) ? $args[1] : 25;
        $offset = isset( $args[2] ) ? $args[2] : 0;
        $sort = isset( $args[3] ) ? self::sortMap( $args[3] ) : 'published';
        $order = isset( $args[4] ) ? $args[4] : false;
        $objectNameFilter = isset( $args[5] ) ? $args[5] : '';

        if ( !$parentNodeID )
        {
            throw new ezcBaseFunctionalityNotSupportedException( 'Fetch node list', 'Parent node id is not valid' );
        }

        $node = eZContentObjectTreeNode::fetch( $parentNodeID );
        if ( !$node instanceOf eZContentObjectTreeNode )
        {
            throw new ezcBaseFunctionalityNotSupportedException( 'Fetch node list', "Parent node '$parentNodeID' is not valid" );
        }

        $ezjscoreIni = eZINI::instance( 'ezjscore.ini' );
        $hardLimit = (int)$ezjscoreIni->variable( 'ezjscServer_ezjscnode', 'HardLimit' );

        if ( $hardLimit > 0 && $limit > $hardLimit )
        {
            $limit = $hardLimit;
        }

        $params = array( 'Depth' => 1,
                         'Limit' => $limit,
                         'Offset' => $offset,
                         'SortBy' => array( array( $sort, $order ) ),
                         'DepthOperator' => 'eq',
                         'ObjectNameFilter' => $objectNameFilter,
                         'AsObject' => true );

       // fetch nodes and total node count
        $count = $node->subTreeCount( $params );
        if ( $count )
        {
            $nodeArray = $node->subTree( $params );
        }
        else
        {
            $nodeArray = array();
        }
        unset( $node );// We have on purpose not checked permission on $node itself, so it should not be used

        // generate json response from node list
        if ( $nodeArray )
        {
            $list = ezjscAjaxContent::nodeEncode( $nodeArray, array( 'formatDate' => 'shortdatetime',
                                                                     'fetchThumbPreview' => true,
                                                                     'fetchSection' => true,
                                                                     'fetchCreator' => true,
                                                                     'fetchClassIcon' => true ), 'raw' );
        }
        else
        {
            $list = array();
        }

        return array( 'parent_node_id' => $parentNodeID,
                      'count' => count( $nodeArray ),
                      'total_count' => (int)$count,
                      'list' => $list,
                      'limit' => $limit,
                      'offset' => $offset,
                      'sort' => $sort,
                      'order' => $order );
    }
1128339
public function parents()
    {
        if (!$this->nodes) {
            throw new \InvalidArgumentException('The current node list is empty.');
        }

        $node = $this->getNode(0);
        $nodes = array();

        while ($node = $node->parentNode) {
            if (XML_ELEMENT_NODE === $node->nodeType) {
                $nodes[] = $node;
            }
        }

        return $this->createSubCrawler($nodes);
    }
943698
static public function children( $args )
    {
        $ezTagsINI = eZINI::instance( 'eztags.ini' );
        $params = array();

        // Missing: a limit parameter; generateOutput would need to pass it to eZTagsObject::fetchList
        return self::generateOutput(
            $params,
            $args[0],
            $args[1],
            $args[2]
        );
    }
592651
public function getChildren(...$args)
    {
        if (!$this->filter) {
            $this->filter = new \Amiss\Filter($this->mapper);
        }
        return $this->filter->getChildren(...$args);
    }
376296
static public function tagsChildren( $args )
    {
        $http = eZHTTPTool::instance();
        $filter = urldecode( trim( $http->getVariable( 'filter', '' ) ) );

        if ( !isset( $args[0] ) || !is_numeric( $args[0] ) )
            return array( 'count' => 0, 'offset' => false, 'filter' => $filter, 'data' => array() );

        $offset = false;
        $limits = null;

        if ( $http->hasGetVariable( 'offset' ) )
        {
            $offset = (int) $http->getVariable( 'offset' );

            if ( $http->hasGetVariable( 'limit' ) )
                $limit = (int) $http->getVariable( 'limit' );
            else
                $limit = 10;

            $limits = array( 'offset' => $offset, 'limit' => $limit );
        }

        $sorts = null;
        if ( $http->hasGetVariable( 'sortby' ) )
        {
            $sortBy = trim( $http->getVariable( 'sortby' ) );

            $sortDirection = 'asc';
            if ( $http->hasGetVariable( 'sortdirection' ) && trim( $http->getVariable( 'sortdirection' ) ) == 'desc' )
                $sortDirection = 'desc';

            $sorts = array( $sortBy => $sortDirection );
        }

        $fetchParams = array( 'parent_id' => (int) $args[0], 'main_tag_id' => 0 );
        if ( !empty( $filter ) )
            $fetchParams['keyword'] = array( 'like', '%' . $filter . '%' );

        /** @var eZTagsObject[] $children */
        $children = eZTagsObject::fetchList( $fetchParams, $limits, $sorts );
        $childrenCount = eZTagsObject::fetchListCount( $fetchParams );

        if ( !is_array( $children ) || empty( $children ) )
            return array( 'count' => 0, 'offset' => false, 'filter' => $filter, 'data' => array() );

        $dataArray = array();
        foreach ( $children as $child )
        {
            $tagArray = array();
            $tagArray['id'] = $child->attribute( 'id' );
            $tagArray['keyword'] = htmlspecialchars( $child->attribute( 'keyword' ), ENT_QUOTES );
            $tagArray['modified'] = $child->attribute( 'modified' );

            $tagArray['translations'] = array();
            foreach ( $child->getTranslations() as $translation )
            {
                $tagArray['translations'][] = htmlspecialchars( $translation->attribute( 'locale' ), ENT_QUOTES );
            }

            $dataArray[] = $tagArray;
        }

        return array(
            'count'  => $childrenCount,
            'offset' => $offset,
            'filter' => $filter,
            'data'   => $dataArray
        );
    }
96751
public static function getArgs($args)
    {
        $out = [];
        $last_arg = null;

        for ($i = 1, $il = sizeof($args); $i < $il; ++$i) {
            if (preg_match('~^--(.+)~', $args[$i], $match)) {
                $parts = explode('=', $match[1]);
                $key = preg_replace('~[^a-z0-9]+~', '', $parts[0]);

                if (isset($parts[1])) {
                    $out[$key] = $parts[1];
                } else {
                    $out[$key] = true;
                }

                $last_arg = $key;
            } elseif (preg_match('~^-([a-zA-Z0-9]+)~', $args[$i], $match)) {
                $key = null;
                for ($j = 0, $jl = mb_orig_strlen($match[1]); $j < $jl; ++$j) {
                    $key = $match[1]{$j};
                    $out[$key] = true;
                }

                $last_arg = $key;
            } elseif ($last_arg !== null) {
                $out[$last_arg] = $args[$i];
            }
        }

        return $out;
    }
713284
public function query($args = [])
    {
        $defaults = [
            'orderby'       => 'id',
            'order'         => 'DESC',
            'paginate'      => Option::get('default_posts_paginate', 20),
            'cat_in'        => [], //ids
            'cat_not_in'    => [], //ids
            'tag_in'        => [], //ids
            'tag_not_in'    => [], //ids
            'parent_in'     => [], //ids
            'parent_not_in' => [],
            'meta_query'    => [], // Array Of Arrays

        ];

        $args = array_merge($defaults, $args);

        $current_page = Request::get('page', 1);
        $cache_key = 'posts_' . md5(http_build_query($args) . '_' . $current_page);
        if (Cache::tags('posts')->has($cache_key)) {
            $posts = Cache::tags('posts')->get($cache_key);
        } else {
            $posts = $this->postRepository->queryPosts($args);

            if ( ! count($posts) > 0) {
                return new EtherError('No Posts were found');
            }

            Cache::tags('posts')->put($cache_key, $posts, \Option::get('posts_cache_expires', 60));

        }

        return $posts;
    }
316916
public static function sortArgs(array &$args) {
        ksort($args);
        foreach ($args as $key => $val) {
            if (is_array($val)) {
                ksort($val);
                $args [ $key ] = $val;
                self::sortArgs($val);
            }
        }
    }
367439
public static function max(array $args)
    {
        uasort(
            $args,
            function ($a, $b) {
                return count($a) < count($b) ? 1 : -1;
            }
        );
        return count(reset($args));
    }
1070804
public function formatArgs(array $args)
    {
        $result = [];
        foreach ($args as $key => $item) {
            if ('object' === $item[0]) {
                $parts = explode('\\', $item[1]);
                $short = array_pop($parts);
                $formattedValue = sprintf('<em>object</em>(<abbr title="%s">%s</abbr>)', $item[1], $short);
            } elseif ('array' === $item[0]) {
                $formattedValue = sprintf('<em>array</em>(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
            } elseif ('string' === $item[0]) {
                $formattedValue = sprintf("'%s'", htmlspecialchars($item[1], ENT_QUOTES, $this->getCharset()));
            } elseif ('null' === $item[0]) {
                $formattedValue = '<em>null</em>';
            } elseif ('boolean' === $item[0]) {
                $formattedValue = '<em>'.strtolower(var_export($item[1], true)).'</em>';
            } elseif ('resource' === $item[0]) {
                $formattedValue = '<em>resource</em>';
            } else {
                $formattedValue = str_replace("\n", '', var_export(htmlspecialchars((string) $item[1], ENT_QUOTES, $this->getCharset()), true));
            }

            $result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue);
        }

        return implode(', ', $result);
    }
720843
public function getFields(array $args = [])
    {
        if (empty($args)) {
            return $this->fields;
        }

        return \array_filter($this->fields, function (AbstractType $field) use ($args) {
            return $field->filter($args);
        });
    }
1204868
function parseDSN_args($args) {
     	$retn = array();
     	foreach(explode("&",$args) as $arg) {
     	 	list($key,$val) = explode("=",trim($arg));
     	 	$retn[$key] = $val;
     	 	unset($key,$val);
     	}
     	return $retn;
    }
890615
public function getEntities(array $args = [])
    {
        $alias = $this->getTableAlias();

        $q = $this->_em
            ->createQueryBuilder()
            ->select($alias)
            ->from('MauticContactClientBundle:ContactClient', $alias, $alias.'.id');

        if (empty($args['iterator_mode'])) {
            $q->leftJoin($alias.'.category', 'c');
        }

        $args['qb'] = $q;

        return parent::getEntities($args);
    }
1242030
protected function parseArgs(string $arg)
    {
        if ($this->_lastVariadic) {
            return $this->set($this->_lastVariadic, $arg, true);
        }

        if (!$argument = \reset($this->_arguments)) {
            return $this->set(null, $arg);
        }

        $this->setValue($argument, $arg);

        // Otherwise we will always collect same arguments again!
        if (!$argument->variadic()) {
            \array_shift($this->_arguments);
        }
    }
784408
public function findAdminHierarchiesByParentsAndChildren(array $parents, array $children)
    {
        if (count($parents) === 0 || count($children) === 0) {
            throw new \InvalidArgumentException('Array argument cannot be empty');
        }

        $parentIndex = 0;
        $eol = PHP_EOL;
        $parentsTest = '(';

        foreach ($parents as $parent) {
            $parentsTest .= $parentIndex > 0 ? '    OR ' : '    ';
            $parentsTest .= "p.id = {$parent}{$eol}";
            $parentIndex++;
        }
        $parentsTest .= "){$eol}";

        $childrenIndex = 0;
        $childrenTest = '(';

        foreach ($children as $child) {
            $childrenTest .= $childrenIndex > 0 ? '    OR ' : '    ';
            $childrenTest .= "t.id = {$child}{$eol}";
            $childrenIndex++;
        }
        $childrenTest .= "){$eol}";

        $dql = "
            SELECT h
            FROM Claroline\CoreBundle\Entity\Workspace\WorkspaceTagHierarchy h
            JOIN h.parent p
            JOIN h.tag t
            WHERE h.user IS NULL
            AND h.level > 0
            AND {$parentsTest}
            AND {$childrenTest}
        ";
        $query = $this->_em->createQuery($dql);

        return $query->getResult();
    }
820459
public static function getValidItems( $args )
    {
        $http = eZHTTPTool::instance();
        $tpl = eZTemplate::factory();

        $result = array();

        $blockID = $http->postVariable('block_id');
        $offset = $http->postVariable('offset');
        $limit = $http->postVariable('limit');

        $validNodes = eZFlowPool::validNodes( $blockID );
        $counter = 0;
        foreach( $validNodes as $validNode )
        {
            if ( !$validNode->attribute( 'can_read' ) )
                continue;
            $counter++;

            if ( $counter <= $offset )
                continue;

            $tpl->setVariable('node', $validNode);
            $tpl->setVariable('view', 'block_item');
            $tpl->setVariable('image_class', 'blockgallery1');
            $content = $tpl->fetch('design:node/view/view.tpl');

            $result[] = $content;

            if ( $counter === $limit )
                break;
        }

        return $result;
    }
913648
public function getOrderBy($arg)
    {
        // Check if there are phrases in $arg should handle as it is
        $phrase = explode("\"", $arg);
        if (count($phrase) > 2) {
            // Re-init $arg variable 
            // (It will contain the rest of $arg except phrases).
            $arg = '';
            for ($i = 0; $i < count($phrase); $i++) {
                if ($i % 2 == 0 && $phrase[$i] != '') {
                    // Re-build $arg variable after restricting phrases
                    $arg .= $phrase[$i];
                } elseif ($i % 2 == 1 && $phrase[$i] != '') {
                    // Handle phrases using reqular LIKE matching in MySQL
                    $wordOrder[] = $this->getWordLike($phrase[$i]);
                }
            }
        }
        
        // Handle normal $arg using lex's and regular expresion
        $words = explode(' ', $arg);
        foreach ($words as $word) {
            if ($word != '') {
                $wordOrder[] = 'CASE WHEN ' . 
                               $this->getWordRegExp($word) . 
                               ' THEN 1 ELSE 0 END';
            }
        }
        
        $order = '((' . implode(') + (', $wordOrder) . ')) DESC';
        
        return $order;
    }