/** @brief Constructs new cluster helper instance. * * @param $cluster [in] One cluster reply. * @param $meta [in] Reply set meta data. * @param $facet_helper [in] Facet helper (used to retrieve value label). * @param $query [in] AfsQuery object previously initialized. It is used to * generate new query to filter on this cluster reply. * @param $config [in] Helper configuration. */ public function __construct($cluster, AfsMetaHelper $meta, $facet_helper, AfsQuery $query, AfsHelperConfiguration $config) { $formatter = AfsFacetHelperRetriever::get_formatter($meta->get_cluster_id(), $query); $this->id = $formatter->format($cluster->id); $this->initialize_label($facet_helper); $this->total_replies = $cluster->totalItems; $factory = new AfsReplyHelperFactory($config->get_reply_text_visitor()); $this->replies = $factory->create_replies($meta->get_feed(), $cluster); $this->query = $query->auto_set_from()->unset_cluster()->add_filter($meta->get_cluster_id(), $this->id); $this->config = $config; }
protected function initialize_cluster($reply_set, $query, $config) { if (property_exists($reply_set, 'content') && property_exists($reply_set->content, 'cluster')) { $clustering_id = $this->get_meta()->get_cluster_id(); $facet_helper = AfsFacetHelperRetriever::get_helper($clustering_id, $this->facets); $this->update_meta($facet_helper); foreach ($reply_set->content->cluster as $cluster) { $helper = new AfsClusterHelper($cluster, $this->get_meta(), $facet_helper, $query, $config); $this->clusters[$helper->get_id()] = $helper; } } }
/** @brief Creates recursively facet elements. * * @param $facet_id [in] current facet id. This value is used to update * current query for each facet element. * @param $facet_element [in] starting point used to create facet elements. * @param $config [in] helper configuration object. * * @return list of facet elements (see @ AfsFacetValueHelper). */ public function create_elements($facet_id, $facet_element, AfsHelperConfiguration $config, $feed = null) { $formatter = AfsFacetHelperRetriever::get_formatter($facet_id, $this->query); return $this->create_elements_recursively($facet_id, $facet_element, $formatter, $config, $feed); }