00001 <?php
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 require_once FASTFRAME_ROOT . 'lib/FastFrame/Output.php';
00026
00027
00028
00029
00040
00041 class FF_Output_Mayday {
00042
00043
00048 var $o_output;
00049
00050
00051
00052
00059 function FF_Output_Mayday()
00060 {
00061 $this->o_output =& FF_Output::factory();
00062 }
00063
00064
00065
00066
00076 function getFormattedHistory($in_ticketId, $in_isEmail = false)
00077 {
00078 require_once dirname(__FILE__) . '/../Model/TicketHistory.php';
00079 $o_history =& new FF_Model_TicketHistory();
00080 $s_history = "\n";
00081
00082 foreach ($o_history->getHistory($in_ticketId) as $s_entry)
00083 {
00084 if ($in_isEmail) {
00085 $s_history .= $s_entry . "\n";
00086 }
00087 else {
00088 $s_history .= $s_entry . '<br />';
00089 }
00090 }
00091
00092 if (!$in_isEmail) {
00093 $o_widget =& new FF_Smarty('twoRowInfoTable');
00094 $o_widget->assign(array('T_table_header_left' => _('Ticket History'),
00095 'T_table_style' => 'margin-bottom: 3px;',
00096 'T_table_content_cell' => $s_history,
00097 'B_collapsible' => true,
00098 'B_collapsed' => true));
00099 $s_history = $o_widget->fetch();
00100 }
00101
00102 return $s_history;
00103 }
00104
00105
00106
00107
00118 function getFormattedDescription(&$in_ticket, $in_isEmail = false, $in_showEdit = true)
00119 {
00120 if ($in_isEmail) {
00121 return "\n" . $this->formatCommentText($in_ticket->getDescription(), 70);
00122 }
00123
00124 if ($in_showEdit) {
00125 $s_edit = $this->o_output->link('#', $this->o_output->imgTag('edit.gif', 'mini'),
00126 array('title' => _('Edit Description'),
00127 'onclick' => 'FF_EditComment.setup(\'description\'); return false;', 'class' => 'img'));
00128 }
00129 else {
00130 $s_edit = '';
00131 }
00132
00133 $o_widget =& new FF_Smarty('twoRowInfoTable');
00134 $o_widget->assign(array('T_table_header_left' => $this->getReporterDesc($in_ticket, true, true),
00135 'T_table_header_right' => $in_ticket->getFormattedCreateDate() . ' ' . $s_edit,
00136 'T_table_content_cell' => nl2br($this->o_output->processCellData($in_ticket->getDescription())),
00137 'B_collapsible' => true,
00138 'B_collapsed' => $in_ticket->getCreateDate() < $in_ticket->getLastViewTime(),
00139 'B_enable_snippet' => true,
00140 'T_class_suffix' => 2,
00141 'T_extra_attrib' => 'id="description"'));
00142 return $o_widget->fetch();
00143 }
00144
00145
00146
00147
00162 function getFormattedComments(&$in_model, $in_showPrivate, $in_showRemove, $in_showEdit, $in_isEmail = false, $in_mostRecent = false, $in_showAdd = false)
00163 {
00164 require_once dirname(__FILE__) . '/../Model/TicketComment.php';
00165 $o_comment =& new FF_Model_TicketComment();
00166 $o_perms =& FF_Perms::factory();
00167 $a_comments = array();
00168
00169 $in_showPrivate = $in_isEmail ? false : $in_showPrivate;
00170 $tmp_comments = $o_comment->getCommentsByTicketId($in_model->getId(), $in_mostRecent);
00171 $s_numComments = count($tmp_comments);
00172 $i = 0;
00173 foreach ($tmp_comments as $a_data) {
00174 $i++;
00175 $o_comment->reset();
00176 $o_comment->importFromArray($a_data);
00177 if (!$in_showPrivate && $o_comment->getIsPrivate()) {
00178 continue;
00179 }
00180
00181 if ($in_isEmail) {
00182 $s_text = sprintf(_('%s on %s'), $o_comment->getUserFullName(), date('m/d/Y h:ia', $o_comment->getCreateDate()));
00183 }
00184 else {
00185 $s_text = $this->o_output->popupLink('profileWin', $o_comment->getUserFullName(),
00186 array('actionId' => ACTION_DISPLAY, 'isPopup' => 1,
00187 'objectId' => $o_comment->getCreatorId(), 'module' => 'Profile', 'app' => 'profile'),
00188 array('title' => $o_comment->getUserFullName()));
00189 }
00190
00191 if ($in_isEmail) {
00192 $s_comment = substr($this->formatCommentText($s_text, 70), 0 , -71);
00193 $s_comment .= $this->formatCommentText($o_comment->getComment(), 70);
00194 $s_comment = preg_replace('|(https?:
00195 $a_comments[] = $s_comment;
00196 }
00197 else {
00198 $s_commentId = 'comment_' . $o_comment->getId();
00199 $s_edit = $s_remove = $s_private = '';
00200
00201 if ($in_showEdit && !($o_comment->getIsPrivate() && !$o_perms->hasPerm('can_add_private_comment'))) {
00202 $s_edit = $this->o_output->link('#', $this->o_output->imgTag('edit.gif', 'mini'),
00203 array('title' => _('Edit Comment'),
00204 'onclick' => 'FF_EditComment.setup(\'' . $s_commentId . '\'); return false;', 'class' => 'img'));
00205 }
00206
00207 if ($in_showRemove) {
00208 $s_remove = $this->o_output->link(
00209 FastFrame::selfURL(array(
00210 'actionId' => ACTION_DELETE_COMMENT, 'objectId' => $in_model->getId(), 'commentId' => $o_comment->getId())),
00211 $this->o_output->imgTag('delete.gif', 'mini'),
00212 array('title' => _('Delete Comment'), 'class' => 'img delete'));
00213 }
00214
00215 $s_visible = $o_comment->getIsPrivate() ? 'visible' : 'hidden';
00216 $s_private = $this->o_output->imgTag('lock.gif', 'mini',
00217 array('id' => 'commentLock_' . $o_comment->getId(), 'title' => _('Private Comment'),
00218 'height' => 10, 'width' => 11, 'style' => "visibility: $s_visible;"));
00219
00220 $s_comment = nl2br($this->o_output->processCellData($o_comment->getComment()));
00221 $s_comment = preg_replace('|(https?:
00222 $o_widget =& new FF_Smarty('twoRowInfoTable');
00223 $o_widget->assign(array('T_table_header_left' => $s_text,
00224 'T_table_header_right' => $o_comment->getFormattedCreateDate() . ' ' . $s_private . ' ' . $s_edit . ' ' . $s_remove,
00225 'T_table_content_cell' => $s_comment,
00226 'B_collapsible' => true,
00227
00228 'B_collapsed' => ($o_comment->getCreateDate() > $in_model->getLastViewTime() ||
00229 $i == $s_numComments) ? false : true,
00230 'B_enable_snippet' => true,
00231 'T_extra_attrib' => 'id="' . $s_commentId . '"'));
00232 $a_comments[] = $o_widget->fetch();
00233 }
00234 }
00235
00236 if (!count($a_comments)) {
00237 $s_html = _('There are no comments for this Mayday.');
00238 $s_html = $in_isEmail ? $s_html : '<div id="commentsContainer" style="position: relative; width: 100%;"><div id="no_comments" style="font-style: italic;">' . $s_html . '</div>';
00239 }
00240 else {
00241 if ($in_isEmail) {
00242 $s_html = end($a_comments);
00243 }
00244 else {
00245 $s_html = implode('', $a_comments);
00246 $s_visible = count($a_comments) == 1 ? 'hidden' : 'visible';
00247 if (!$in_mostRecent) {
00248 $s_html = '<div id="commentsContainer" style="position: relative; width: 100%;">
00249 <div style="position: absolute; right: -6.5em; height: 1.4em; visibility: ' . $s_visible . ';" onclick="FastFrame.toggleInfoBoxes(this, \'commentsContainer\');">' .
00250 $this->o_output->imgTag('arrow_down.gif', 'mini') .
00251 $this->o_output->link('#', _('Expand All'), array('style' => 'margin-left: 5px;')) .
00252 '</div>' . $s_html;
00253 }
00254 }
00255 }
00256
00257 if (!$in_isEmail && !$in_mostRecent && $in_showAdd) {
00258 $s_html .= '<div id="add_comment"></div>
00259 <div id="add_link" style="position: absolute; right: -8em; bottom: 0; height: 1.4em;" onclick="FF_EditComment.setup(\'add_comment\', ' . (int) $o_perms->hasPerm('can_add_private_comment') . ');">' .
00260 $this->o_output->imgTag('plus.gif', 'mini', array('width' => 10, 'height' => 10)) .
00261 $this->o_output->link('#', _('New Comment'), array('style' => 'margin-left: 4px;')) .
00262 '</div>';
00263 }
00264
00265 if (!$in_isEmail) {
00266 $s_html .= '</div>';
00267 }
00268
00269 return $s_html;
00270 }
00271
00272
00273
00274
00285 function getFormattedWatchlist($in_ticketId, $in_showRemove, $in_extraUsers = array())
00286 {
00287 require_once dirname(__FILE__) . '/../Model/TicketWatchlist.php';
00288 $o_watchlist =& new FF_Model_TicketWatchlist();
00289 $a_users = $in_extraUsers;
00290 $a_users += $o_watchlist->getWatchlistByTicketId($in_ticketId);
00291 if (count($a_users) == 0) {
00292 $s_html = '<div style="font-style: italic; margin-bottom: 5px;">' . _('No users are watching this Mayday.') . '</div>';
00293 }
00294 else {
00295 $s_html = '';
00296 foreach ($a_users as $s_userId => $s_userName) {
00297 $s_userName = "<b>$s_userName</b>";
00298 if (isset($in_extraUsers[$s_userId])) {
00299 $s_userName .= ' [' . _('Update Mayday! to Save Changes') . ']';
00300 }
00301
00302 if ($in_showRemove) {
00303 $s_userName .= ' ';
00304 $s_userName .= $this->o_output->link(
00305 FastFrame::selfURL(array(
00306 'actionId' => ACTION_DELETE_WATCHLIST, 'userId' => $s_userId, 'objectId' => $in_ticketId)),
00307 $this->o_output->imgTag('delete.gif', 'mini'),
00308 array('title', _('Delete Watchlist User'), 'class' => 'img delete'));
00309 }
00310
00311 $s_html .= "<div>$s_userName</div>";
00312 }
00313 }
00314
00315 return $s_html;
00316 }
00317
00318
00319
00320
00333 function getAttachmentList($in_ticketId, $in_numAttach, $in_showRemove, $in_isEmail = false)
00334 {
00335 if ($in_numAttach == 0) {
00336 if ($in_isEmail) {
00337 $s_html = _('No files are attached to this Mayday.');
00338 }
00339 else {
00340 $s_html = '<div style="font-style: italic; margin-bottom: 5px;">' . _('No files are attached to this Mayday.') . '</div>';
00341 }
00342 }
00343 else {
00344 require_once FASTFRAME_ROOT . 'lib/FastFrame/Util.php';
00345 $o_fileCache =& FF_FileCache::singleton();
00346 $a_files = $o_fileCache->getFilesForObject($in_ticketId, 'ticket_files');
00347 $s_html = '';
00348 foreach ($a_files as $s_file) {
00349 $s_fullPath = $o_fileCache->getPath(
00350 array('subdir' => 'ticket_files', 'id' => $in_ticketId, 'name' => $s_file), true);
00351 if ($in_isEmail) {
00352 $s_html .= $this->o_output->link(
00353 FastFrame::selfURL(array(
00354 'actionId' => ACTION_DOWNLOAD, 'path' => 'ticket_files',
00355 'name' => $s_file, 'id' => $in_ticketId,
00356 'useApp' => 1, session_name() => false),
00357 true), $s_file);
00358 $s_html .= ' - ' . FF_Util::bytesToHuman(filesize($s_fullPath)) . ', ';
00359 }
00360 else {
00361 $s_html .= '<div><b>' . $s_file . '</b> ';
00362 $s_html .= sprintf(_('on %s'), date('M jS, g:ia', filemtime($s_fullPath)));
00363 $s_html .= ' - ' . FF_Util::bytesToHuman(filesize($s_fullPath));
00364 if ($o_fileCache->isWebPlayable($s_file)) {
00365 $s_url = FastFrame::selfURL(array('actionId' => ACTION_DOWNLOAD, 'displayFile' => 1,
00366 'path' => 'ticket_files', 'id' => $in_ticketId, 'name' => $s_file, 'useApp' => 1));
00367 $s_html .= ' [';
00368 $s_html .= $this->o_output->link('#', _('Play'), array('onclick' => 'if (!this.parentNode.nextSibling || this.parentNode.nextSibling.tagName.toLowerCase() != "embed") { new Insertion.After(this.parentNode, \'<embed src="' . $s_url . '" type="' . $o_fileCache->getContentType($s_file) . '" autostart="true" loop="false" width="200" height="42" controller="true"></embed>\'); } return false;'));
00369 $s_html .= ']';
00370 }
00371 elseif ($o_fileCache->isWebViewable($s_file)) {
00372 $s_html .= ' [';
00373 $s_html .= $this->o_output->popupLink('docWin', _('View'),
00374 array('actionId' => ACTION_DOWNLOAD, 'displayFile' => 1,
00375 'path' => 'ticket_files', 'id' => $in_ticketId, 'name' => $s_file, 'useApp' => 1),
00376 array('title' => _('Display File'), 'menubar' => true));
00377 $s_html .= ']';
00378 }
00379
00380 $s_html .= ' [';
00381 $s_html .= $this->o_output->link(
00382 FastFrame::selfURL(array(
00383 'actionId' => ACTION_DOWNLOAD, 'path' => 'ticket_files', 'id' => $in_ticketId,
00384 'name' => $s_file, 'useApp' => 1)),
00385 _('Download'));
00386 $s_html .= '] ';
00387 if ($in_showRemove) {
00388 $s_html .= $this->o_output->link(
00389 FastFrame::selfURL(array(
00390 'actionId' => ACTION_DELETE_ATTACHMENT, 'name' => $s_file, 'objectId' => $in_ticketId)),
00391 $this->o_output->imgTag('delete.gif', 'mini'),
00392 array('title', _('Delete Attachment'), 'class' => 'delete img'));
00393 }
00394
00395 $s_html .= '</div>';
00396 }
00397 }
00398
00399 if ($in_isEmail) {
00400 $s_html = substr($s_html, 0, -2);
00401 }
00402 }
00403
00404 return $s_html;
00405 }
00406
00407
00408
00409
00419 function getPriorityIcon($in_points)
00420 {
00421 static $b_correctBoxModel, $a_priorities, $a_icons;
00422 if (!isset($b_correctBoxModel)) {
00423 require_once 'Net/UserAgent/Detect.php';
00424 $b_correctBoxModel = !Net_UserAgent_Detect::isIE();
00425 $o_dao =& FF_DataAccess::factory('Priority');
00426 $a_priorities = $o_dao->getPriorityOptions();
00427 $a_icons = array();
00428 $this->o_output->o_tpl->append('css', 'div.points {
00429 background-image: url(' . $this->o_output->imgTag('gradient.png', 'general', array('app' => 'mayday', 'onlyUrl' => true)) . ');
00430 background-repeat: repeat-x; width: 8px; position: relative; }
00431 div.pointsBorder { border: 1px solid #999; width: 8px; height: 18px; position: absolute; top: 0; right: 0; }');
00432 }
00433
00434 if (!isset($a_icons[$in_points])) {
00435
00436 $tmp_height = $in_points * .18;
00437 $tmp_pos = $tmp_pos2 = 18 - $tmp_height;
00438
00439 if (!$b_correctBoxModel && $tmp_height != 18 && $tmp_height != 9) {
00440 $tmp_pos2 += 1;
00441 }
00442
00443 $tmp_title = isset($a_priorities[$in_points]) ? $a_priorities[$in_points] : sprintf(_('%s Points'), $in_points);
00444 $a_icons[$in_points] = '<div class="pointsBorder" title="' . $tmp_title . '"><div class="points" style="height: ' . $tmp_height . 'px; background-position: 0 -' . $tmp_pos . 'px; top: ' . $tmp_pos2 . 'px;"><!--
00445 }
00446
00447 return $a_icons[$in_points];
00448 }
00449
00450
00451
00452
00463 function getPriorityWithQuickpoints(&$in_model, $in_returnId)
00464 {
00465 static $b_css;
00466 if (!isset($b_css)) {
00467 $b_css = true;
00468 $this->o_output->o_tpl->append('css', 'div.pointsWrapper { width: 21px; height: 18px; position: relative; }
00469 div.pointsControl { position: absolute; top: 0; left: 0; }');
00470 }
00471
00472 $o_perms =& FF_Perms::factory();
00473 $s_html = '<div class="pointsWrapper">';
00474 if ($o_perms->hasPerm('can_edit_ticket_priority') &&
00475 $o_perms->hasObjectPerm($in_model->getCategoryId(), PERMS_EDIT, 'Category', $in_model->getReporterId()) &&
00476 !$in_model->isTicketResolved()) {
00477 $s_html .= '<div class="pointsControl">';
00478 $s_html .= $this->o_output->link(
00479 FastFrame::selfURL(array(
00480 'actionId' => ACTION_INCREASE_POINTS, 'objectId' => $in_model->getId(),
00481 'returnActionId' => $in_returnId)),
00482 $this->o_output->imgTag('plus.png', 'general', array('app' => 'mayday', 'width' => 10, 'height' => 10, 'style' => 'display: block;')),
00483 array('title' => _('Increase Priority'), 'class' => 'priority'));
00484 $s_html .= $this->o_output->link(
00485 FastFrame::selfURL(array(
00486 'actionId' => ACTION_DECREASE_POINTS, 'objectId' => $in_model->getId(),
00487 'returnActionId' => $in_returnId)),
00488 $this->o_output->imgTag('minus.png', 'general', array('app' => 'mayday', 'width' => 10, 'height' => 10, 'style' => 'display: block;')),
00489 array('title' => _('Decrease Priority'), 'class' => 'priority'));
00490 $s_html .= '</div>';
00491 }
00492
00493 $s_html .= $this->getPriorityIcon($in_model->getPoints());
00494 $s_html .= '</div>';
00495 return $s_html;
00496 }
00497
00498
00499
00500
00511 function getTicketListOptions(&$in_model, &$in_perms, $in_actionId)
00512 {
00513 static $b_hasAssignBox;
00514 $tmp_text = '';
00515 if (($b_canEdit = $in_perms->hasObjectPerm($in_model->getCategoryId(), PERMS_EDIT, 'Category', $in_model->getReporterId()))) {
00516 if ($in_model->isTicketResolved()) {
00517 $tmp_text .= $this->o_output->link(
00518 FastFrame::selfURL(array(
00519 'actionId' => ACTION_REOPEN, 'objectId' => $in_model->getId())),
00520 $this->o_output->imgTag('undelete.gif', 'actions'),
00521 array('title' => _('Re-open Mayday')));
00522 }
00523 else {
00524 $tmp_text .= $this->o_output->link(
00525 FastFrame::selfURL(array(
00526 'actionId' => ACTION_EDIT, 'objectId' => $in_model->getId())),
00527 $this->o_output->imgTag('edit.gif', 'actions'),
00528 array('title' => _('Update Mayday')));
00529 }
00530 }
00531
00532 if (!$in_model->isTicketResolved() &&
00533 $in_perms->hasObjectPerm($in_model->getCategoryId(), PERMS_DELETE, 'Category', $in_model->getReporterId())) {
00534 $tmp_text .= ' ';
00535 $tmp_text .= $this->o_output->link(
00536 FastFrame::selfURL(array(
00537 'actionId' => ACTION_RESOLVE, 'objectId' => $in_model->getId())),
00538 $this->o_output->imgTag('delete.gif', 'actions'),
00539 array('title' => _('Resolve Mayday')));
00540 }
00541
00542 $b_isMine = $in_model->getHandlerId() == FF_Auth::getCredential('userId');
00543 if ($b_canEdit && $in_perms->hasPerm('can_edit_ticket_handler') &&
00544 !$in_model->isTicketResolved()) {
00545
00546 if (!isset($b_hasAssignBox)) {
00547 $b_hasAssignBox = true;
00548 $this->o_output->o_tpl->append('extra_html', '<div id="assignBox" style="z-index: 10; display: none; width: 200px; position: absolute;">
00549 <div class="tt_caption" style="height: 15px;"><div style="float: left;">' . _('Assign Ticket') . '</div><a style="display: block; float: right; margin-left: 15px;" href="#" onclick="Element.hide(\'assignBox\'); return false;">' . _('Cancel') . '</a></div>
00550 <div class="tt_text">' . _('Assign To:') . '<br /><select id="assignOptions"></select></div></div>');
00551 }
00552
00553 $tmp_text .= ' ';
00554 if ($b_isMine) {
00555 $s_title = _('Owned by Me');
00556 $s_img = 'user.gif';
00557 }
00558 elseif ($in_model->getHandlerId() == 0) {
00559 $s_title = _('Unassigned');
00560 $s_img = 'user_dimmed.gif';
00561 }
00562 else {
00563 $s_title = sprintf(_('Owned by %s'), $in_model->getHandlerName());
00564 $s_img = 'user2.gif';
00565 }
00566
00567 $s_id = 'assign-' . $in_model->getCategoryId() . '|' . $in_model->getHandlerId();
00568 $tmp_text .= ' ';
00569 $tmp_text .= $this->o_output->imgTag($s_img, 'actions', array('title' => $s_title, 'id' => $s_id, 'class' => 'assign'));
00570 }
00571
00572 return $tmp_text;
00573 }
00574
00575
00576
00577
00589 function getReporterDesc(&$in_model, $in_linkName = true, $in_nameOnly = false)
00590 {
00591 $s_id = $in_model->getReporterId();
00592 $o_perms =& FF_Perms::factory();
00593 if ($in_linkName && !empty($s_id) && $o_perms->hasPerm('can_list', 'profile')) {
00594 $s_name = $this->o_output->popupLink('userWin', $in_model->getReporterName(),
00595 array('actionId' => ACTION_DISPLAY, 'isPopup' => 1,
00596 'objectId' => $s_id, 'module' => 'Profile', 'app' => 'profile'),
00597 array('title' => _('View User Information')));
00598 }
00599 else {
00600 $s_name = $in_model->getReporterName();
00601 }
00602
00603 if ($in_nameOnly) {
00604 return $s_name;
00605 }
00606
00607
00608 if ($in_linkName) {
00609 $s_name = $s_name . ' - ' . FF_Util::formatRelativeDate($in_model->getCreateDate(), true);
00610 $s_info = '';
00611 foreach (array('getReporterDepartment', 'getReporterPhone') as $s_method) {
00612 if (!FastFrame::isEmpty($in_model->$s_method())) {
00613 $s_info .= $in_model->$s_method() . '<br />';
00614 }
00615 }
00616
00617 return $s_name . '<div style="padding-top: 3px;">' . $s_info . '</div>';
00618 }
00619 else {
00620 return $s_name . ' ' . _('on') . ' ' . date('m/d/Y h:ia', $in_model->getCreateDate());
00621 }
00622 }
00623
00624
00625
00626
00637 function getCustomFields($in_ticketId, $in_catId, $in_formFields)
00638 {
00639 require_once dirname(__FILE__) . '/../Model/CustomField.php';
00640 $o_model =& new FF_Model_CustomField();
00641 $a_fields = $o_model->getFieldsByCategory($in_catId, $in_ticketId);
00642 $a_headers = array();
00643 if (count($a_fields)) {
00644 foreach ($a_fields as $a_field) {
00645 $o_model->importFromArray($a_field);
00646 if ($in_formFields) {
00647 switch($o_model->getType()) {
00648 case TYPE_CHECKBOX:
00649 $o_element =& HTML_QuickForm::createElement('checkbox', 'custom[' . $o_model->getId() .']');
00650 break;
00651 case TYPE_TEXTAREA:
00652 $o_element =& HTML_QuickForm::createElement('textarea', 'custom[' . $o_model->getId() . ']', 'data',
00653 array('cols' => 35, 'rows' => 7, 'style' => 'width: 250px;'));
00654 break;
00655 case TYPE_DATE:
00656 case TYPE_DATETIME:
00657 $a_field['data'] = empty($a_field['data']) ? time() : $a_field['data'];
00658 $s_format = $o_model->getType() == TYPE_DATE ? 'M d Y' : 'M d Y H : i';
00659 $o_element =& HTML_QuickForm::createElement('date', 'custom[' . $o_model->getId() . ']', 'data',
00660 array('format' => $s_format,
00661 'minYear' => date('Y') - 1,
00662 'maxYear' => date('Y') + 1,
00663 ));
00664 break;
00665 case TYPE_TEXT:
00666 default:
00667 $o_element =& HTML_QuickForm::createElement('text', 'custom[' . $o_model->getId() . ']', 'data',
00668 array('size' => 40, 'style' => 'width: 250px;'));
00669 break;
00670 }
00671
00672 if (isset($a_field['data'])) {
00673 $o_element->setValue($a_field['data']);
00674 }
00675
00676 $s_data = $o_element->toHtml();
00677 }
00678 else {
00679 switch($o_model->getType()) {
00680 case TYPE_CHECKBOX:
00681 $s_data = $a_field['data'] ? _('Yes') : _('No');
00682 break;
00683 case TYPE_TEXTAREA:
00684 $s_data = nl2br(htmlspecialchars($a_field['data']));
00685 break;
00686 case TYPE_DATE:
00687 $s_data = date('m/d/Y', $a_field['data']);
00688 break;
00689 case TYPE_DATETIME:
00690 $s_data = date('m/d/Y h:ia', $a_field['data']);
00691 break;
00692 case TYPE_TEXT:
00693 default:
00694 $s_data = htmlspecialchars($a_field['data']);
00695 break;
00696 }
00697 }
00698
00699 $a_headers[] = array(
00700 'title' => $o_model->getDescription(),
00701 'data' => $s_data,
00702 'dataIsSafe' => true,
00703 );
00704 }
00705 }
00706
00707 return $a_headers;
00708 }
00709
00710
00711
00712
00722 function getCustomFieldList($in_catId, $in_submitActionId)
00723 {
00724 require_once dirname(__FILE__) . '/../Model/CustomField.php';
00725 $o_model =& new FF_Model_CustomField();
00726 $a_fields = $o_model->getFieldsByCategory($in_catId);
00727 if (count($a_fields)) {
00728 $s_html = '';
00729 foreach ($a_fields as $a_field) {
00730 $o_model->importFromArray($a_field);
00731 $s_html .= '<div style="padding-bottom: 2px;"><b>' . $o_model->getDescription() . '</b> (' .
00732 $o_model->getType(true) . ') ' .
00733 $this->o_output->imgTag('edit.gif', 'actions',
00734 array('title' => _('Edit Field'),
00735 'onclick' => 'this.form.fieldId.value = ' . $o_model->getId(),
00736 'height' => 16, 'width' => 16,
00737 'name' => 'editField', 'type' => 'input')) . ' ' .
00738 $this->o_output->imgTag('delete.gif', 'actions',
00739 array('title' => _('Delete Field'),
00740 'onclick' => 'this.form.fieldId.value = ' . $o_model->getId(),
00741 'height' => 16, 'width' => 16,
00742 'name' => 'deleteField', 'type' => 'input')) .
00743 '</div>';
00744 }
00745 }
00746 else {
00747 $s_html = '<div style="font-style: italic;">' . _('No custom fields are associated with this category.') . '</div>';
00748 }
00749
00750 return $s_html;
00751 }
00752
00753
00754
00755
00765 function formatCommentText($in_text, $in_wrap)
00766 {
00767 $s_text = '+' . str_repeat('-', $in_wrap - 2) . "+\n";
00768 foreach (explode("\n", wordwrap(str_replace(array("\r\n", "\r"), array("\n", "\n"), $in_text), $in_wrap - 2)) as $l) {
00769 $s_text .= '| ' . str_pad($l, $in_wrap - 2, ' ', STR_PAD_RIGHT) . "\n";
00770 }
00771
00772 $s_text .= '+' . str_repeat('-', $in_wrap - 2) . "+\n";
00773 return $s_text;
00774 }
00775
00776
00777 }
00778 ?>