17 require_once SQ_INCLUDE_PATH.
'/asset.inc';
18 require_once SQ_CORE_PACKAGE_PATH.
'/interfaces/bridge/bridge.inc';
43 $this->_ser_attrs = TRUE;
44 parent::__construct($assetid);
59 protected function _getName($short_name=FALSE, $contextid=NULL)
62 if ($contextid === NULL) {
63 $contextid = $GLOBALS[
'SQ_SYSTEM']->getContextId();
67 $values = $GLOBALS[
'SQ_SYSTEM']->am->getAttributeValuesByName(
'name', $this->
type(), Array($this->
id), $contextid);
68 if (empty($values) === TRUE) {
69 return parent::_getName($short_name, $contextid);
71 return $values[$this->id];
91 function getAsset($shadowid, $type_code=
'', $mute_errors=FALSE)
95 $id_parts = explode(
':', $shadowid);
96 if (isset($id_parts[1])) {
97 $shadowid = $id_parts[1];
102 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($shadowid);
129 function getLinks($assetid, $link_types, $type_code=
'', $strict_type_code=TRUE, $side_of_link=
'major', $sort_by=NULL)
134 $id_parts = explode(
':', $assetid);
135 if (isset($id_parts[1]))
return $links;
137 assert_equals($assetid, $this->
id, translate(
'sch_folder_only_own_links'));
139 if (!isset($this->_tmp[
'getLinks'])) {
141 $settings = $this->
attr(
'settings');
143 $sm = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'search_manager');
144 $search_info = Array();
145 $search_info[
'limit'] = 100;
146 $search_info[
'requester'] = $this->id;
147 $search_info[
'field_logic'] = (isset($settings[
'logic'])) ? strtoupper($settings[
'logic']) :
'AND';
149 if (empty($type_code)) {
150 $search_info[
'asset_types'] = (isset($settings[
'types'])) ? $settings[
'types'] : Array();
152 if (!is_array($type_code)) {
153 $type_code = Array($type_code);
157 $type_code = array_flip($type_code);
158 foreach ($type_code as $this_type_code => $value) {
159 $type_code[$this_type_code] = TRUE;
161 $search_info[
'asset_types'] = $type_code;
164 if (empty($search_info[
'asset_types'])) {
168 $search_info[
'statuses'] = (isset($settings[
'statuses'])) ? $settings[
'statuses'] : Array();
170 if (empty($search_info[
'statuses']))
return Array();
172 $search_info[
'roots'] = Array();
173 if (!empty($settings[
'root'])) {
174 $search_info[
'roots'] = $settings[
'root'];
176 $search_info[
'roots'][] = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAssetid(
'root_folder');
179 if (!isset($settings[
'phrase']) || trim($settings[
'phrase']) ==
'') {
180 $search_results = $sm->processBasicSearch($search_info);
182 $search_info[
'fields'][$settings[
'phrase']][
'words'] = $settings[
'phrase'];
183 $search_info[
'fields'][$settings[
'phrase']][
'word_logic'] = (isset($settings[
'logic'])) ? strtoupper($settings[
'logic']) :
'AND';
184 $search_info[
'fields'][$settings[
'phrase']][
'data_sources'] = Array(Array(
'type' =>
'include_all'));
185 $search_results = $sm->processSearch($search_info);
188 if (empty($search_results))
return $links;
190 $assetids = array_keys($search_results);
191 $asset_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo($assetids);
194 foreach ($asset_info as $assetid => $info) {
197 'minorid' => $assetid,
199 'link_type' => SQ_LINK_TYPE_2,
200 'minor_type_code' => $info[
'type_code'],
201 'sort_order' => $sort_order,
202 'is_dependant' =>
'0',
203 'is_exclusive' =>
'0',
210 $this->_tmp[
'getLinks'] = $links;
214 return $this->_tmp[
'getLinks'];
227 if (!isset($this->_tmp[
'getAssetMapLinks'])) {
230 $settings = $this->
attr(
'settings');
232 $sm = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'search_manager');
233 $search_info = Array();
234 $search_info[
'limit'] = 100;
235 $search_info[
'field_logic'] = (isset($settings[
'logic'])) ? strtoupper($settings[
'logic']) :
'AND';
236 $search_info[
'asset_types'] = (isset($settings[
'types'])) ? $settings[
'types'] : Array();
237 $search_info[
'statuses'] = (isset($settings[
'statuses'])) ? $settings[
'statuses'] : Array();
239 $search_info[
'roots'] = Array();
240 if (!empty($settings[
'root'])) {
241 $search_info[
'roots'] = $settings[
'root'];
244 $search_info[
'requester'] = $this->id;
247 if (empty($search_info[
'asset_types'])) {
251 if (empty($search_info[
'statuses']))
return Array();
253 if (!isset($settings[
'phrase']) || trim($settings[
'phrase']) ==
'') {
254 $search_results = $sm->processBasicSearch($search_info);
256 $search_info[
'fields'][$settings[
'phrase']][
'words'] = $settings[
'phrase'];
257 $search_info[
'fields'][$settings[
'phrase']][
'word_logic'] = (isset($settings[
'logic'])) ? strtoupper($settings[
'logic']) :
'AND';
258 $search_info[
'fields'][$settings[
'phrase']][
'data_sources'] = Array(Array(
'type' =>
'include_all'));
259 $search_results = $sm->processSearch($search_info);
262 if (empty($search_results))
return $links;
264 $assetids = array_keys($search_results);
265 $asset_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo($assetids);
268 foreach ($asset_info as $assetid => $info) {
270 'assetid' => $this->
id.
':'.$assetid,
271 'short_name' => $info[
'short_name'],
272 'name' => $info[
'name'],
274 'type_code' => $info[
'type_code'],
275 'status' => $info[
'status'],
276 'linkid' => $this->
id.
':'.$assetid,
277 'link_type' => SQ_LINK_TYPE_2,
279 'sort_order' => $sort_order,
288 $this->_tmp[
'getAssetMapLinks'] = $links;
292 return $this->_tmp[
'getAssetMapLinks'];
309 $id_parts = explode(
':', $assetid);
310 if (isset($id_parts[1])) {
311 $assetid = $id_parts[1];
316 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
318 if (!is_null($assetid)) {
320 'assetid' => $assetid,
321 'name' => $asset->short_name,
322 'type_code' => $asset->type(),
324 'status' => $asset->status,
325 'url' => $asset->getURL(),
330 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($asset);
332 $attrs[
'assetid'] = urlencode($attrs[
'assetid']);
333 $attrs[
'name'] = urlencode($attrs[
'name']);
334 if (isset($attrs[
'short_name'])) {
335 $attrs[
'short_name'] = urlencode($attrs[
'short_name']);
356 function getParents($assetid, $type_code=
'', $strict_type_code=TRUE)
358 assert_equals($assetid, $this->
id, translate(
'sch_folder_only_own_links'));
384 function getChildren($assetid, $type_code=
'', $strict_type_code=TRUE, $dependant=NULL, $sort_by=NULL)
386 assert_equals($assetid, $this->
id, translate(
'sch_folder_only_own_links'));
428 function countLinks($assetid, $side_of_link=
'major', $link_types=0, $type_code=
'', $strict_type_code=TRUE, $ignore_linkid=0)