Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
calendar_event_single.inc
1 <?php
17 require_once dirname(__FILE__).'/../../calendar_event/calendar_event.inc';
18 
33 {
34  var $parent_links = Array();
35 
36 
43  function Calendar_Event_Single($assetid=0)
44  {
45  $this->Calendar_Event($assetid);
46 
47  }//end constructor
48 
49 
58  function load($assetid)
59  {
60  parent::load($assetid);
61 
62  $this->parent_links = $GLOBALS['SQ_SYSTEM']->am->getLinks($assetid, SQ_SC_LINK_ALL, 'calendar_event_multi_date', FALSE, 'minor');
63 
64  }//end load()
65 
66 
77  function _preCreateCheck(&$link)
78  {
79  if ($link['asset'] instanceof Calendar_Event_Cancellation) {
80  $replacee_link = $GLOBALS['SQ_SYSTEM']->am->getLink($link['asset']->id, NULL, '', TRUE, NULL, 'minor');
81  $replacee = $GLOBALS['SQ_SYSTEM']->am->getAsset($replacee_link['majorid']);
82  if (substr($this->attr('start_date'), 0, 10) == substr($link['asset']->attr('start_date'), 0, 10)) {
83  $this->setAttrValue('name', 'Modified: '.$replacee->name);
84  } else {
85  $this->setAttrValue('name', 'Rescheduled from '.date('jS M Y', iso8601_ts($link['asset']->attr('start_date'))).': '.$replacee->name);
86  }
87  }
88 
89  return parent::_preCreateCheck($link);
90 
91  }//end _preCreateCheck()
92 
93 
100  function printBody2()
101  {
102  require_once SQ_FUDGE_PATH.'/general/datetime.inc';
103  ?>
104  <table border="0" cellspacing="2" cellpadding="2">
105  <tr>
106  <td><b><?php echo translate('name'); ?></b></td>
107  <td><?php echo $this->attr('name'); ?></td>
108  </tr>
109  <?php
110  if ($recurring_events = $GLOBALS['SQ_SYSTEM']->am->getParents($this->id, 'calendar_event_recurring', FALSE)) {
111  $root_url = array_values($GLOBALS['SQ_SYSTEM']->am->getRootURL());
112  if (is_array($root_url)) $root_url = $root_url[0];
113  ?>
114  <tr>
115  <td><b><?php echo translate('cal_event_replaces_cancellation') ?></b></td>
116  <td><?php
117  // get the parent recurring event asset
118  $recurring_events = array_keys($recurring_events);
119  $recurring_event = $GLOBALS['SQ_SYSTEM']->am->getAsset($recurring_events[0]);
120  if (isset($_REQUEST['SQ_CALENDAR_EVENT_ID'])) {
121  $cancellation_href = htmlspecialchars(replace_query_string_vars(Array('SQ_CALENDAR_EVENT_ID' => $recurring_events[0], 'SQ_CALENDAR_EVENT_ACTION' => NULL)));
122  } else {
123  $cancellation_href = $root_url.'?a='.$recurring_events[0];
124  }
125  echo '<a href="'.$cancellation_href.'">'.$recurring_event->attr('name').'</a>';
126  ?></td>
127  </tr>
128  <?php
129  }
130  ?>
131  <tr>
132  <td><b><?php echo translate('start_date') ?></b></td>
133  <td><?php echo $this->getFriendlyStart(); ?></td>
134  </tr>
135  <tr>
136  <td><b><?php echo translate('end_date') ?></b></td>
137  <td><?php echo $this->getFriendlyEnd(); ?></td>
138  </tr>
139  <tr>
140  <td><b><?php echo translate('duration') ?></b></td>
141  <td><?php
142  // give useful info if no duration - easy_time_total returns empty string
143  $total_time = easy_time_total($this->getDuration(), TRUE);
144  echo (empty($total_time) ? 'N/A' : $total_time);
145  ?></td>
146  </tr>
147  <tr>
148  <td><b><?php echo translate('description') ?></b></td>
149  <td><?php echo $this->getKeywordReplacement('asset_attribute_description'); ?></td>
150  </tr>
151  </table>
152  <?php
153 
154  }//end printBody2()
155 
156 
171  function getKeywordReplacement($keyword)
172  {
173  $replacement = parent::getKeywordReplacement($keyword);
174  $empty_replacement = (((string)$replacement) == '%'.$keyword.'%');
175 
176  // If we have not found an appropriate replacement, ask the parent, if it is a Calendar Multi Date Event asset
177  if ($empty_replacement && (count($this->parent_links) > 0)) {
178  // Only expecting one relevant link
179  $parent_link = reset($this->parent_links);
180 
181  $parent_asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($parent_link['majorid']);
182  $replacement = $parent_asset->getKeywordReplacement($keyword);
183  $GLOBALS['SQ_SYSTEM']->am->forgetAsset($parent_asset);
184  }
185 
186  return $replacement;
187 
188  }//end getKeywordReplacement()
189 
190 
191 }//end class
192 
193 ?>