17 require_once SQ_INCLUDE_PATH.
'/asset.inc';
18 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
19 require_once SQ_CORE_PACKAGE_PATH.
'/interfaces/bridge/bridge.inc';
44 parent::__construct($assetid);
60 return $this->
attr(
'name');
77 if (!parent::_createAdditional($link))
return FALSE;
92 private function _listFiles($path)
97 $dirs = list_dirs($path, TRUE, Array(
'CVS',
'.svn'));
98 $files = list_files($path, TRUE);
103 $temp = array_merge($dirs, $files);
107 foreach ($temp as $element) {
108 $filename = basename($element);
109 if (strpos($filename,
'.') !== 0) {
127 private function _isValidFile($path)
129 if (file_exists($path) && is_readable($path)) {
156 function getAsset($assetid, $type_code=
'', $mute_errors=FALSE)
159 $id_parts = explode(
':', $assetid);
161 if (isset($id_parts[1])) {
162 $shadowid = $id_parts[1];
168 require_once (SQ_DATA_PATH.
'/private/conf/file_bridge.inc');
169 $location = FILE_BRIDGE_PATH;
170 $location = rtrim($location,
'/');
171 if ($this->_isValidFile($location.
'/'.$shadowid)) {
172 if (is_dir($location.
'/'.$shadowid)) {
173 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'physical_folder');
176 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'physical_file');
206 function getLinks($assetid, $link_types, $type_code=
'', $strict_type_code=TRUE, $side_of_link=
'major', $sort_by=NULL)
209 if (!($link_types & SQ_LINK_TYPE_2)) {
213 if (!is_array($type_code)) {
214 if (empty($type_code)) {
215 $type_code = Array();
217 $type_code = Array($type_code);
221 if (!isset($this->_tmp[
'getLinks'][$assetid][$side_of_link])) {
225 if ($this->
id == $assetid) {
226 if ($side_of_link ==
'minor') {
228 trigger_localised_error(
'CORE0089', E_USER_ERROR);
231 require_once (SQ_DATA_PATH.
'/private/conf/file_bridge.inc');
232 $location = FILE_BRIDGE_PATH;
233 $location = rtrim($location,
'/');
234 $files = $this->_listFiles($location);
236 foreach ($files as $file) {
237 $varid = str_replace($location.
'/',
'', $file);
238 $type_code = (is_dir($file)) ?
'physical_folder' :
'physical_file';
241 'minorid' => $this->
id.
':'.$varid,
242 'minor_type_code' => $type_code,
243 'majorid' => $this->
id,
245 'link_type' => SQ_LINK_TYPE_2,
246 'is_dependant' => FALSE,
247 'is_exclusive' => FALSE,
258 list($bridgeid,$shadowid) = explode(
':', $assetid);
259 require_once (SQ_DATA_PATH.
'/private/conf/file_bridge.inc');
260 $location = FILE_BRIDGE_PATH;
261 $location = rtrim($location,
'/');
264 if (!$this->_isValidFile($location.
'/'.$shadowid)) {
270 if ($side_of_link ==
'minor') {
273 'majorid' => $this->
id,
274 'major_type_code' => $this->
type(),
276 'link_type' => SQ_LINK_TYPE_2,
277 'is_dependant' => TRUE,
278 'is_exclusive' => TRUE,
283 if (is_dir($location.
'/'.$shadowid)) {
284 $files = $this->_listFiles($location.
'/'.$shadowid);
286 foreach ($files as $file) {
287 $varid = str_replace($location.
'/',
'', $file);
288 $type_code = (is_dir($file)) ?
'physical_folder' :
'physical_file';
291 'minorid' => $this->
id.
':'.$varid,
292 'minor_type_code' => $type_code,
293 'majorid' => $this->
id,
295 'link_type' => SQ_LINK_TYPE_2,
296 'is_dependant' => TRUE,
297 'is_exclusive' => TRUE,
310 if (!is_null($sort_by)) {
311 uasort($links, create_function(
'$a,$b',
'return $a["'.$sort_by.
'"] < $b["'.$sort_by.
'"];'));
314 $this->_tmp[
'getLinks'][$assetid][$side_of_link] = $links;
318 return $this->_tmp[
'getLinks'][$assetid][$side_of_link];
344 public function getChildren($assetid, $type_code=
'', $strict_type_code=TRUE, $dependant=NULL, $sort_by=NULL)
349 $links = $this->
getLinks($assetid, SQ_LINK_TYPE_2, $type_code, $strict_type_code,
'major', NULL);
350 if (!empty($links)) {
351 foreach ($links as $link) {
352 $children[$link[
'minorid']][0][
'type_code'] = $link[
'minor_type_code'];
375 function getParents($assetid, $type_code=
'', $strict_type_code=TRUE)
377 $id_parts = explode(
':', $assetid);
378 $parents = $GLOBALS[
'SQ_SYSTEM']->am->getParents($id_parts[0]);
380 $parents[$this->id] = $this->
type();
414 $keywords = parent::getAvailableKeywords();
437 return parent::getKeywordReplacement($keyword);
479 function getPermission($assetid, $permission, $granted=NULL, $and_greater=TRUE, $expand_groups=FALSE, $all_info=FALSE)
482 return $GLOBALS[
'SQ_SYSTEM']->am->getPermission($this->
id, $permission, $granted, $and_greater, $expand_groups, $all_info);
536 function getAssetInfo($assetids, $type_code=Array(), $strict_type_code=TRUE, $field=
'')
539 foreach ($assetids as $assetid) {
542 if (!empty($field)) {
543 if ($field ==
'assetid') {
544 $info[$assetid] = $assetid;
545 }
else if ($field ==
'type_code') {
546 $info[$assetid] = $asset->type();
547 }
else if (in_array($field , Array(
'version',
'name',
'short_name',
'status'))) {
548 $info[$assetid] = $asset->$field;
550 $info[$assetid] = $this->$field;
553 $info[$assetid] = Array(
554 'assetid' => $assetid,
555 'type_code' => $asset->type(),
556 'version' => $asset->version,
557 'name' => $asset->name,
558 'short_name' => $asset->short_name,
559 'status' => $asset->status,
560 'languages' => $asset->languages,
561 'charset' => $asset->charset,
562 'force_secure' => $this->force_secure,
563 'created' => $asset->created,
564 'created_userid' => $asset->created_userid,
565 'updated' => $asset->updated,
566 'updated_userid' => $asset->updated_userid,
567 'published' => $asset->published,
568 'published_userid' => $asset->published_userid,
569 'status_changed' => $asset->status_changed,
570 'status_changed_userid' => $asset->status_changed_userid,
620 function getLink($assetid, $link_type=NULL, $type_code=
'', $strict_type_code=TRUE, $value=NULL, $side_of_link=
'major', $exclusive=NULL)
666 function countLinks($assetid, $side_of_link=
'major', $link_types=0, $type_code=
'', $strict_type_code=TRUE, $ignore_linkid=0)
693 function getLinkByAsset($assetid, $other_assetid, $link_types=NULL, $value=NULL, $side_of_link=
'major', $force_array=FALSE, $dependant=NULL, $exclusive=NULL)
730 function updateLink($linkid, $link_type=NULL, $value=NULL, $sort_order=NULL)
769 function createAssetLink(&$major, &$minor, $link_type, $value=
'', $sort_order=NULL, $dependant=
'0', $exclusive=
'0', $moving=FALSE)