Returns the tag cloud for specified parameters using eZ Find

@param array $params

@return array
559654
private function solrTagCloud( $params )
    {
        $offset = 0;
        if( isset( $params['offset'] ) && is_numeric( $params['offset'] ) )
            $offset = (int) $params['offset'];

        // It seems that Solr doesn't like PHP_INT_MAX constant on 64bit operating systems
        $limit = 1000000;
        if( isset( $params['limit'] ) && is_numeric( $params['limit'] ) )
            $limit = (int) $params['limit'];

        $searchFilter = array();

        if ( isset( $params['class_identifier'] ) )
        {
            if ( !is_array( $params['class_identifier'] ) )
                $params['class_identifier'] = array( $params['class_identifier'] );

            if ( !empty( $params['class_identifier'] ) )
                $searchFilter['meta_class_identifier_ms'] = '(' . implode( ' OR ', $params['class_identifier'] ) . ')';
        }

        if ( isset( $params['parent_node_id'] ) )
            $searchFilter['meta_path_si'] = (int) $params['parent_node_id'];

        $solrSearch = new eZSolr();
        $solrParams = array(
            'SearchOffset'   => 0,
            // It seems that Solr doesn't like PHP_INT_MAX constant on 64bit operating systems
            'SearchLimit'    => 1000000,
            'Facet'          => array(
                // We don't want to limit max facet result number since we limit it later anyways
                array( 'field' => 'ezf_df_tag_ids', 'limit' => 1000000 )
            ),
            'Filter'         => $searchFilter,
            'QueryHandler'   => 'ezpublish',
            'AsObjects'      => false
        );

        $searchResult = $solrSearch->search( '*:*', $solrParams );
        if ( !isset( $searchResult['SearchExtras'] ) || !$searchResult['SearchExtras'] instanceof ezfSearchResultInfo )
            return array();

        $facetResult = $searchResult['SearchExtras']->attribute( 'facet_fields' );
        if ( !is_array( $facetResult ) || empty( $facetResult[0]['countList'] ) )
            return array();

        $tagsCountList = $facetResult[0]['countList'];

        /** @var eZTagsObject[] $tags */
        $tags = eZTagsObject::fetchList( array( 'id' => array( array_keys( $tagsCountList ) ) ) );
        if ( !is_array( $tags ) || empty( $tags ) )
            return array();

        $tagSortArray = array();
        $tagKeywords = array();
        $tagCounts = array();
        foreach ( $tags as $tag )
        {
            $tagKeyword = $tag->attribute( 'keyword' );
            $tagCount = $tagsCountList[(int) $tag->attribute( 'id' )];

            $tagSortArray[] = array(
                'keyword'   => $tagKeyword,
                'count'     => $tagCount,
                'tag'       => $tag
            );

            $tagKeywords[] = $tagKeyword;
            $tagCounts[] = $tagCount;
        }

        // calling call_user_func_array requires all arguments to be references
        // this is the reason for $sortFlags array and $sortArgs[] = &....
        $sortArgs = array();
        $sortFlags = array( SORT_ASC, SORT_DESC, SORT_LOCALE_STRING, SORT_NUMERIC );
        if ( isset( $params['sort_by'] ) && is_array( $params['sort_by'] ) && !empty( $params['sort_by'] ) )
        {
            $params['sort_by'] = is_string( $params['sort_by'][0] ) ? array( $params['sort_by'] ) : $params['sort_by'];
            foreach ( $params['sort_by'] as $sortItem )
            {
                if ( is_array( $sortItem ) && !empty( $sortItem ) )
                {
                    switch ( $sortItem[0] )
                    {
                        case 'keyword':
                            $sortArgs[] = &$tagKeywords;
                            if ( isset( $sortItem[1] ) && $sortItem[1] )
                                $sortArgs[] = &$sortFlags[0];
                            else
                                $sortArgs[] = &$sortFlags[1];
                            $sortArgs[] = &$sortFlags[2];
                            break;
                        case 'count':
                            $sortArgs[] = &$tagCounts;
                            if ( isset( $sortItem[1] ) && $sortItem[1] )
                                $sortArgs[] = &$sortFlags[0];
                            else
                                $sortArgs[] = &$sortFlags[1];
                            $sortArgs[] = &$sortFlags[3];
                            break;
                    }
                }
            }
        }

        if ( empty( $sortArgs ) )
        {
            $sortArgs[] = &$tagKeywords;
            $sortArgs[] = &$sortFlags[0];
        }

        $sortArgs[] = &$tagSortArray;

        call_user_func_array( 'array_multisort', $sortArgs );

        $tagSortArray = array_slice( $tagSortArray, $offset, $limit );
        if ( empty( $tagSortArray ) )
            return array();

        $tagKeywords = array_slice( $tagKeywords, $offset, $limit );
        $tagCounts = array_slice( $tagCounts, $offset, $limit );

        if ( isset( $params['post_sort_by'] ) )
        {
            if ( $params['post_sort_by'] === 'keyword' )
                array_multisort( $tagKeywords, SORT_ASC, SORT_LOCALE_STRING, $tagSortArray );
            else if ( $params['post_sort_by'] === 'keyword_reverse' )
                array_multisort( $tagKeywords, SORT_DESC, SORT_LOCALE_STRING, $tagSortArray );
            else if ( $params['post_sort_by'] === 'count' )
                array_multisort( $tagCounts, SORT_ASC, SORT_NUMERIC, $tagSortArray );
            else if ( $params['post_sort_by'] === 'count_reverse' )
                array_multisort( $tagCounts, SORT_DESC, SORT_NUMERIC, $tagSortArray );
        }

        $this->normalizeTagCounts( $tagSortArray, $tagCounts );

        return $tagSortArray;
    }
1097419
protected function getSignature(array $params)
    {
        ksort($params);

        $srcStr = 'POSTcdn.api.qcloud.com/v2/index.php?'.urldecode(http_build_query($params));

        return base64_encode(hash_hmac('sha1', $srcStr, $this->getCredentials()['secretKey'], true));
    }
369612
protected function parseRelationshipParams(array $params): array
    {
        if (empty($params)) {
            return [];
        }
        $parsed = [];
        foreach ($params as $key => $value) {
            # loop through
            if (is_int($key)) {
                $parsed[$key] = '';
                continue;
            }
            if ($key !== 'paginate' || ($key === 'paginate' && !Arr::isAssoc($value))) {
                $key = $key === 'paginate' ? 'limit' : $key;
                $parsed[$key] = implode('|', $value);

            } else {
                $limit = $this->findInArray($value, 'limit', 0, 10);
                $offset = $this->findInArray($value, 'offset', 1, 0);
                $parsed['limit'] = $limit . '|' . $offset;
            }
        }
        return $parsed;
    }
663388
public function createAndFilterSqlParts( $params )
    {
        $returnArray = array( 'tables' => '', 'joins'  => '', 'columns' => '' );

        if ( !isset( $params['tag_id'] ) )
            return $returnArray;

        if ( is_array( $params['tag_id'] ) )
        {
            $tagIDsArray = $params['tag_id'];
        }
        else if ( (int) $params['tag_id'] > 0 )
        {
            $tagIDsArray = array( (int) $params['tag_id'] );
        }
        else
        {
            return $returnArray;
        }

        if ( !isset( $params['include_synonyms'] ) || ( isset( $params['include_synonyms'] ) && (bool) $params['include_synonyms'] == true ) )
        {
            /** @var eZTagsObject[] $tags */
            $tags = eZTagsObject::fetchList( array( 'main_tag_id' => array( $tagIDsArray ) ) );
            if ( is_array( $tags ) )
            {
                foreach ( $tags as $tag )
                {
                    $tagIDsArray[] = $tag->attribute( 'id' );
                }
            }
        }

        $returnArray['tables'] = " INNER JOIN eztags_attribute_link i1 ON (i1.object_id = ezcontentobject.id AND i1.objectattribute_version = ezcontentobject.current_version)
                                   INNER JOIN eztags i2 ON (i1.keyword_id = i2.id)
                                   INNER JOIN eztags_keyword i3 ON (i2.id = i3.keyword_id)";

        $dbStrings = array();
        foreach ( $tagIDsArray as $tagID )
        {
            if ( is_numeric( $tagID ) )
            {
                $dbStrings[] = "EXISTS (
                    SELECT 1
                    FROM
                        eztags_attribute_link j1,
                        ezcontentobject j2
                    WHERE j1.keyword_id = " . (int) $tagID .
                    " AND j1.object_id = j2.id
                    AND j2.id = ezcontentobject.id
                    AND j1.objectattribute_version = j2.current_version
                )";
            }
        }

        $dbString = implode( " AND ", $dbStrings );

        if ( isset( $params['language'] ) )
        {
            $language = $params['language'];
            if ( !is_array( $language ) )
                $language = array( $language );

            eZContentLanguage::setPrioritizedLanguages( $language );
        }

        $returnArray['joins'] = " $dbString
                                  AND " . eZContentLanguage::languagesSQLFilter( 'i2' ) . " AND " .
                                  eZContentLanguage::sqlFilter( 'i3', 'i2' ) . " AND ";

        if ( isset( $params['language'] ) )
            eZContentLanguage::clearPrioritizedLanguages();

        return $returnArray;
    }
221137
public function get(array $params = [])
    {
        $this->getLogger()->info('Getting list of layouts ');
        $entries = [];
        $hydratedRegions = [];
        $hydratedWidgets = [];
        $response = $this->doGet($this->url, $params);
        if (isset($params['embed']))
            $embed = ($params['embed'] != null) ? explode(',', $params['embed']) : [];

        foreach ($response as $item) {
            /** @var XiboLayout $layout */
            $layout = new XiboLayout($this->getEntityProvider());
            $layout->hydrate($item);
            foreach ($layout->regions as $reg) {
                /** @var XiboRegion $region */
                $region = new XiboRegion($this->getEntityProvider());
                $region->hydrate($reg);
                if (in_array('playlists', $embed) === true) {
                    /** @var XiboPlaylist $playlist */
                    $playlist = new XiboPlaylist($this->getEntityProvider());
                    $playlist->hydrate($reg['regionPlaylist']);
                    foreach ($playlist->widgets as $widget) {
                        /** @var XiboWidget $widgetObject */
                        $widgetObject = new XiboWidget($this->getEntityProvider());
                        $widgetObject->hydrate($widget);
                        $hydratedWidgets[] = $widgetObject;
                    }
                    $playlist->widgets = $hydratedWidgets;
                    $region->regionPlaylist = $playlist;
                }
                // Add to parent object
                $hydratedRegions[] = $region;
            }
            $layout->regions = $hydratedRegions;

            $entries[] = clone $layout;
        }

        return $entries;
    }
826399
public function getSignature(array $params)
    {
        ksort($params);
        $signature = md5($this->parameters->getAuth('secret') . json_encode($params));

        return $signature;
    }
668601
public function request($params)
  {
    $query = array_merge($params, [
      'key' => $this->key
    ]);

    try {

      $response = $this->client->get(self::API_ENDPOINT, [
        'query' => $query
      ]);

    } catch (ClientException $exception) {

      return collect([]);

    }

    $results = json_decode($response->getBody(), true);

    $output = [];

    for($i = 0; $i < count($results['itemListElement']); $i++) {
      $output[] = new SearchResult($results['itemListElement'][$i]);
    }

    return collect($output);
  }
140896
public function search($params)
    {
        $dataProvider = parent::search($params);
        if (!$this->validate()) {
            return $dataProvider;
        }
        $dataProvider->query->andWhere(['IS NOT', Seo::tableName() . '.item_id', null])
            ->andFilterWhere([
                Seo::tableName() . '.modelName' => $this->modelName,
                Seo::tableName() . '.item_id' => $this->item_id,
            ]);
        return $dataProvider;
    }
670932
public function getCompiledParams(array $params)
    {
        foreach ($params as $k => $p) {
            if (is_array($p)) {
                $params[$k] = $p[0];
            }
        }

        return $params;
    }
160066
protected function serializeParams(array $params)
    {
        $serialized = array();
        foreach ($params as $param) {
            $serialized[] = $this->serializer->serialize($param);
        }

        return $serialized;
    }
803334
public function getSearchQuery($params)
    {
        $data['query'] = [];
        $data['query']['ands'] = [];

        if (isset($params[self::INPUT_CONCEPTS])) {
            $data['query']['ands'] = $this->getInputConceptsQuery(
                $data['query']['ands'],
                $params[self::INPUT_CONCEPTS]
            );
        }

        if (isset($params[self::OUTPUT_CONCEPTS])) {
            $data['query']['ands'] = $this->getOutputConceptsQuery(
                $data['query']['ands'],
                $params[self::OUTPUT_CONCEPTS]
            );
        }

        if (isset($params[self::METADATA])) {
            $data['query']['ands'] = $this->getMetadataQuery($data['query']['ands'], $params[self::METADATA]);
        }

        if (isset($params[self::IMAGES])) {
            $data['query']['ands'] = $this->getImagesQuery($data['query']['ands'], $params[self::IMAGES]);
        }

        if (isset($params[self::REVERSED_IMAGES])) {
            $data['query']['ands'] = $this->getReverseImagesQuery(
                $data['query']['ands'],
                $params[self::REVERSED_IMAGES]
            );
        }

        return $data;
    }
13491
public function search($params = array()) {
        $this->checkPermissions('search');
        
        return $this->client->retrieveData($this->resourceName . '/search', $params);
    }
809235
protected function extractQueryParameters(array $params)
    {
        $availableParams = ['extract-archive'];
        $query = [];

        foreach ($params as $key => $value) {
            if (in_array($key, $availableParams)) {
                $query[$key] = $value;
            }
        }

        return $query;
    }
813488
public function findByTag($tag, $params = array(), $options = array())
    {
        $path = sprintf("/tags/%s/tasks", $tag);
        return $this->client->getCollection($path, $params, $options);
    }
984232
protected function _getIndex(array $params) {
        $model = $this->_normalizeModelName($params['datatype']);
        $contentManager = $this->_getContentManager($model);
        $options = $this->_extractOptionsForFetch($params);
        if (instance($model)->isMultilingual()) {
            $options['joinMultilingualModel'] = true;
        }

        $records = $contentManager->fetch($options);
        $amount = count($records);
        $records = array($params['datatype'] => $records);
        if (isset($options['with'])) {
            $records = $this->_combineRecords($params['datatype'], $records, $options['with']);
        }
        return array(
            array(
                'success' => true,
                'result' => $records,
                'amount' => $amount,
                'total' => intval($contentManager->count($options))
            ),
            200
        );
    }
376944
public function singleton($params = [])
    {
        static $instances = [];

        $signature = serialize($params);
        if (!isset($instances[$signature])) {
            $instances[$signature] = idna_convert::getInstance($params);
        }

        return $instances[$signature];
    }
342315
public function search($params)
    {//echo __METHOD__;var_dump($params);
        $this->load($params);//var_dump($this->titleMinLength);var_dump($this->title);var_dump($this->body);

        $modelNewsClassname = $this->module->model('News')->className();
        $query = $this->module->model('NewsQuery', [$modelNewsClassname]);//var_dump($query);exit;

        $query->orderBy(['show_from_time' => SORT_DESC]);

        //$query->alias('main')->leftJoin(['i18n' => NewsI18n::tableName()], "main.id = i18n.news_id AND i18n.lang_code = '{$this->langCodeMain}'");

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        if (!$this->validate()) {
            $query->where('0=1'); // uncomment this line if you do not want to return any records when validation fails
            return $dataProvider;
        }

        // required criterias
        $query->where(['is_visible' => true]);

        $tzShiftSec = intval(date('Z')); // server time zone shift in seconds: west UTC <0, east UTC >0
        if (!empty($tzShiftSec)) {
            $now = new Expression("DATE_SUB(NOW(), INTERVAL {$tzShiftSec} SECOND)"); // UTC time
        }
        $query->andWhere(['<=', 'show_from_time', $now])
              ->andWhere(['or',
                  ['>=', 'show_to_time', $now],
                  ['show_to_time' => null],
                  //new Expression("show_to_time IS NULL"), //?? ['show_to_time' => null],
              ]);
        // no news for current language
/*
        $query->andWhere(['not', ['title' => null]]);
        $query->andWhere(['not', ['body'  => null]]);
        $query->andWhere(['not', ['title' => ''  ]]);
        $query->andWhere(['not', ['body'  => ''  ]]);
*/
        $query->andWhere(['and',
          ['not', ['title' => null]],
          ['not', ['body'  => null]],
          ['not', ['title' => ''  ]],
          ['not', ['body'  => ''  ]],
        ]);
        if (isset($this->titleMinLength)) {
            //$lengthExpr = new Expression("LENGTH(title)"); //! length in bytes, not UTF8-symbols
            $lengthExpr = new Expression("CHAR_LENGTH(title)");
            $query->andFilterWhere(['>=', $lengthExpr, $this->titleMinLength]);
        }
        if (isset($this->bodyMinLength)) {
            //$lengthExpr = new Expression("LENGTH(body)"); //! length in bytes, not UTF8-symbols
            $lengthExpr = new Expression("CHAR_LENGTH(body)");
            $query->andFilterWhere(['>=', $lengthExpr, $this->bodyMinLength]);
        }

        // additional search criterias
        $query->andFilterWhere(['owner_id' => $this->owner_id]);
        $query->andFilterWhere(['like', 'title', $this->title]);
        $query->andFilterWhere(['like', 'body', $this->body]);

        //list($sql, $sqlParams) = Yii::$app->db->getQueryBuilder()->build($query);var_dump($sql);var_dump($sqlParams);
        return $dataProvider;
    }