17 require_once SQ_PACKAGES_PATH.
'/cms/page_templates/page_asset_listing/page_asset_listing.inc';
50 parent::__construct($assetid);
64 $this->
setAttrValue(
'types', Array(
'thesaurus_term' =>
'1'));
65 return parent::create($link);
82 $this->_tmp[
'tag_freq'] = Array();
84 $assets_to_list = Array();
87 $min_depth = $this->
attr(
'min_depth');
88 if ($min_depth ==
'') $min_depth = NULL;
89 $max_depth = $this->
attr(
'max_depth');
90 if ($max_depth ==
'') $max_depth = NULL;
97 foreach ($root_asset_ids as $root_asset_id) {
98 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($root_asset_id);
101 $query_links = $GLOBALS[
'SQ_SYSTEM']->am->generateGetChildrenQuery($asset,
'', FALSE, NULL, NULL, SQ_PERMISSION_READ, TRUE, TRUE, $min_depth, $max_depth, TRUE, NULL);
104 $query_links[
'sql_array'][
'where'] = preg_replace(
'/AND\s*$/',
'', $query_links[
'sql_array'][
'where']);
107 $bind_vars = $query_links[
'bind_vars'];
109 $query_links[
'sql_array'][
'select'] =
'(SELECT DISTINCT l.minorid ';
112 $query_links[
'sql_array'][
'union_select'] =
'';
113 $query_links[
'sql_array'][
'union_from'] =
'';
114 $query_links[
'sql_array'][
'union_where'] =
'';
116 if (isset($bind_vars[
'gc_union_majorid'])) {
117 unset($bind_vars[
'gc_union_majorid']);
120 $query_links = implode(
' ', $query_links[
'sql_array']);
129 $thesaurus_filter_clause =
'';
130 if (!empty($thesaurus_filters)) {
132 $thesaurus_filter_clause =
' AND (te.thesid = :thesaurusid) ';
133 $bind_vars[
'thesaurusid'] = $thesaurus_filters[0];
137 $where_root_node =
'';
139 $where_root_node =
' OR (sl2.majorid = :root_nodeid) ';
140 $bind_vars[
'root_nodeid'] = $root_asset_ids[0];
147 count(sl2.minorid) as score
151 ON (te.thesid || \':\' || te.termid)= sl2.minorid
153 (sl2.majorid IN ('.$query_links.
')
154 '.$where_root_node.
' )
155 '.$thesaurus_filter_clause.
'
164 foreach ($bind_vars as $bind_var => $bind_value) {
168 }
catch (Exception $e) {
169 throw new Exception(
'Unable to get children for asset: '.join(
', ', $root_asset_ids).
' due to database error: '.$e->getMessage());
174 if ($query_limit != -1) {
175 $rows = array_slice($rows, 0, $query_limit);
179 foreach ($rows as $row) {
181 $this->_tmp[
'tag_freq'][$row[
'minorid']] = $row[
'score'];
182 $assets_to_list[$row[
'minorid']] = Array(Array(
'type_code' =>
'thesaurus_term'));
185 return $assets_to_list;
201 if ($this->
attr(
'first_page_only')) {
203 if (empty($si[
'type'])) {
204 $ret = $this->
attr(
'num_per_page');
205 if ($ret == 0) $ret = -1;
224 $links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, SQ_LINK_NOTICE,
'thesaurus', FALSE);
226 foreach ($links as $link) {
227 $ret[] = $link[
'minorid'];
252 $shadow_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
254 foreach ($bc_keywords as $key => $keyword) {
255 if ($keyword ==
'tag_count') {
256 $keywords[$keyword] = array_get_index($this->_tmp[
'tag_freq'], $assetid, 1);
257 }
else if ($keyword ==
'tag_size') {
258 $keywords[$keyword] = ceil(array_get_index($this->_tmp[
'tag_freq'], $assetid, 1) / $this->
_getTagMaxCount() * $this->Attr(
'tag_max_size'));
260 $keywords[$keyword] = $shadow_asset->getKeywordReplacement($keyword);
278 if (count($this->_tmp[
'tag_freq'])) {
279 $ret = array_values($this->_tmp[
'tag_freq']);
299 $ret = parent::_getAdditionalSingleAssetFormatKeywords();
301 $ret[
'tag_count'] = translate(
'page_tag_listing_keyword_tag_count');
302 $ret[
'tag_size'] = translate(
'page_tag_listing_keyword_tag_size');
317 $cache_key = parent::_getCacheKey();
322 $cache_key .=
';MTS='.$this->Attr(
'tag_max_size');
324 $cache_key .=
';FPO='.($this->attr(
'first_page_only') ?
'1' :
'0');