Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
folder.inc
1 <?php
18 require_once SQ_INCLUDE_PATH.'/asset.inc';
19 
31 class Folder extends Asset
32 {
33 
34 
41  function Folder($assetid=0)
42  {
43  parent::__construct($assetid);
44 
45  }//end constructor
46 
47 
58  protected function _preCreateCheck(Array &$link)
59  {
60  if (!parent::_preCreateCheck($link)) return FALSE;
61 
62  $name = trim($this->attr('name'));
63  if ($name == '') {
64  trigger_localised_error('CORE0083', E_USER_WARNING, $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($this->type(), 'name'));
65  return FALSE;
66  }
67 
68  return TRUE;
69 
70  }//end _preCreateCheck()
71 
72 
83  protected function _createAdditional(Array &$link)
84  {
85  if (!parent::_createAdditional($link)) return FALSE;
86 
87  // NOTE: the main time we wont want to do this is if we are creating
88  // the root folder as it is not linked anywhere
89  if (empty($link)) return TRUE;
90 
91  return $this->makeAndSaveInitialWebPath(strtolower($this->attr('name')), $link);
92 
93  }//end _createAdditional()
94 
95 
106  protected function _getName($short_name=FALSE, $contextid=NULL)
107  {
108  // No context specified, using the current context
109  if ($contextid === NULL) {
110  $contextid = $GLOBALS['SQ_SYSTEM']->getContextId();
111  }//end if
112 
113  // Obtain the attribute value for Name from the specified Context
114  $values = $GLOBALS['SQ_SYSTEM']->am->getAttributeValuesByName('name', $this->type(), Array($this->id), $contextid);
115  if (empty($values) === TRUE) {
116  return parent::_getName($short_name, $contextid);
117  } else {
118  return $values[$this->id];
119  }
120 
121  }//end _getName()
122 
123 
131  public function _getAllowedLinks()
132  {
133 
134  return Array(
135  SQ_LINK_TYPE_1 => Array(
136  'asset' => Array(
137  'card' => 'M',
138  'exclusive' => FALSE,
139  ),
140  ),
141  SQ_LINK_TYPE_2 => Array(
142  'asset' => Array(
143  'card' => 'M',
144  'exclusive' => FALSE,
145  ),
146  ),
147  SQ_LINK_TYPE_3 => Array(
148  'asset' => Array(
149  'card' => 'M',
150  'exclusive' => FALSE,
151  ),
152  ),
153  SQ_LINK_NOTICE => Array(
154  'asset' => Array(
155  'card' => 'M',
156  'exclusive' => FALSE,
157  ),
158  ),
159  );
160 
161  }//end _getAllowedLinks()
162 
163 
164 }//end class
165 ?>