ItemDisplay.php

Go to the documentation of this file.
00001 <?php
00003 // {{{ license
00004 
00005 // +----------------------------------------------------------------------+
00006 // | FastFrame Application Framework                                      |
00007 // +----------------------------------------------------------------------+
00008 // | Copyright (c) 2002-2006 The Codejanitor Group                        |
00009 // +----------------------------------------------------------------------+
00010 // | This source file is subject to the GNU Lesser Public License (LGPL), |
00011 // | that is bundled with this package in the file LICENSE, and is        |
00012 // | available at through the world-wide-web at                           |
00013 // | http://www.fsf.org/copyleft/lesser.html                              |
00014 // | If you did not receive a copy of the LGPL and are unable to          |
00015 // | obtain it through the world-wide-web, you can get it by writing the  |
00016 // | Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
00017 // | MA 02111-1307, USA.                                                  |
00018 // +----------------------------------------------------------------------+
00019 // | Authors: Jason Rust <jrust@codejanitor.com>                          |
00020 // | Authors: Greg Gilbert <ggilbert@codejanitor.com>                     |
00021 // +----------------------------------------------------------------------+
00022 
00023 // }}}
00024 // {{{ requires
00025 
00026 require_once FASTFRAME_ROOT . 'lib/FastFrame/Action/Display.php';
00027 
00028 // }}}
00029 // {{{ class FF_Action_Display_Item 
00030 
00041 // }}}
00042 class FF_Action_Display_Item extends FF_Action_Display {
00043     // {{{ renderDisplay()
00044 
00051     function renderDisplay()
00052     {
00053         if ($this->o_model->getIsDeleted()) {
00054             $this->o_output->setMessage(_('Note that this item has been deleted.'), FASTFRAME_WARNING_MESSAGE);
00055         }
00056 
00057         require_once FASTFRAME_ROOT . '/lib/FastFrame/Output/Table.php';
00058         $o_table =& new FF_Output_Table('twoColumn');
00059         $o_table->setTableHeaderText($this->getPageName());
00060         $o_table->setTableHeaders($this->getTableData());
00061         $o_table->setAlternateRowColors(true);
00062         $o_table->render();
00063         $o_tableWidget =& $o_table->getWidgetObject();
00064         $this->o_output->o_tpl->append('content_middle', $o_tableWidget->fetch());
00065         $this->renderAdditionalLinks();
00066     }
00067 
00068     // }}}
00069     // {{{ renderAdditionalLinks()
00070 
00077     function renderAdditionalLinks()
00078     {
00079         if (FF_Request::getParam('isPopup', 'g', false)) {
00080             if ($this->o_perms->hasPerm('can_edit_item')) {
00081                 $this->o_output->o_tpl->append('page_links', 
00082                         $this->o_output->link(FastFrame::selfURL(array(
00083                                     'actionId' => ACTION_EDIT, 'module' => 'Item', 
00084                                     'objectId' => $this->o_model->getId())), _('Edit this Item')));
00085             }
00086 
00087             $this->o_output->o_tpl->append('page_links', 
00088                     $this->o_output->link('#', _('Close Window'), 
00089                         array('onclick' => 'self.close();')));
00090         }
00091         else {
00092             $this->o_output->o_tpl->append('page_links', 
00093                     $this->o_output->link(FastFrame::selfURL(array(
00094                                 'actionId' => FF_Request::getParam('returnActionId', 'gs'),
00095                                 'module' => 'Item')),
00096                         sprintf(_('Return to %s List'), $this->getSingularText())));
00097         }
00098     }
00099 
00100     // }}}
00101     // {{{ getTableData()
00102 
00109     function getTableData()
00110     {
00111         require_once dirname(__FILE__) . '/../Output/Checkout.php';
00112         $o_chkoutOutput =& new FF_Output_Checkout();
00113         $a_headers = array();
00114         $a_headers[] = array(
00115             'title' => _('Name:'),
00116             'data' => $this->o_model->getName(),
00117         );
00118         $a_headers[] = array(
00119             'title' => _('Description:'),
00120             'data' => $this->o_model->getFormattedDescription(),
00121             'dataIsSafe' => true,
00122         );
00123         $o_fileCache =& FF_FileCache::singleton();
00124         $tmp_path = $o_fileCache->exists(array('subdir' => 'item_images', 'name' => $this->o_model->getId()), true) ? 
00125             $o_fileCache->getPath(array('subdir' => 'item_images', 'name' => $this->o_model->getId()), true, FASTFRAME_WEBPATH) :
00126             $this->o_registry->getRootFile('general/no_image.gif', 'graphics', FASTFRAME_WEBPATH);
00127         $a_headers[] = array(
00128             'title' => _('Image:'),
00129             'data' => $this->o_output->imgTag($tmp_path, null, array('style' => 'vertical-align: top;')),
00130             'dataIsSafe' => true,
00131         );
00132         $a_headers[] = array(
00133             'title' => _('Barcode:'),
00134             'data' => $this->o_model->getBarcode(),
00135         );
00136         $a_headers[] = array(
00137             'title' => _('Serial Number:'),
00138             'data' => $this->o_model->getSerialNum(),
00139         );
00140         if ($this->o_perms->hasPerm('can_use_category')) {
00141             $a_headers[] = array(
00142                 'title' => _('Category:'),
00143                 'data' => $this->o_model->getCategoryName(),
00144             );
00145         }
00146 
00147         if ($this->o_perms->hasPerm('can_use_vendor')) {
00148             $a_headers[] = array(
00149                 'title' => _('Vendor:'),
00150                 'data' => $this->o_model->getVendorName(),
00151             );
00152         }
00153 
00154         $a_headers[] = array(
00155             'title' => _('Status:'),
00156             'data' => $this->o_model->getFormattedStatus(),
00157         );
00158         $a_headers[] = array(
00159             'title' => _('Shopper Viewable:'),
00160             'data' => $this->o_model->getShopperViewable() ? _('Yes') : _('No'),
00161         );
00162         $a_stores = $this->o_registry->getConfigParam('shopping/stores'); 
00163         $s_store = $this->o_model->getStoreId();
00164         $a_headers[] = array(
00165             'title' => _('Store:'),
00166             'data' => isset($a_stores[$s_store]) ? $a_stores[$s_store] : _('Invalid Store'),
00167         );
00168 
00169         // create extra attribute fields
00170         foreach ($this->o_registry->getConfigParam('item/attributes') as $s_key => $s_desc) {
00171             $a_headers[] = array(
00172                 'title' => $s_desc . ':',
00173                 'data' => $this->o_model->getAttribute($s_key),
00174             );
00175         }
00176 
00177         if ($this->o_perms->hasPerm('can_view_loan_history')) {
00178             FF_Request::setParam('returnActionId', FF_Request::getParam('returnActionId', 'gs'), 's');
00179             FF_Request::setParam('returnObjectId', $this->o_model->getId(), 's');
00180             FF_Request::setParam('returnModuleId', 'Item', 's');
00181             $a_headers[] = array(
00182                 'title' => _('Item\'s Loan History:'),
00183                 'data' => $this->o_output->link(
00184                     FastFrame::selfURL(array('module' => 'Loan', 'actionId' => ACTION_LIST_ITEM_LOANS,
00185                             'objectDesc' => $this->o_model->getName(), 'objectId' => $this->o_model->getId())),
00186                     _('Click Here To View')),
00187                 'dataIsSafe' => true,
00188             );
00189         }
00190 
00191         $a_headers[] = array(
00192             'title' => _('Associated Files'),
00193             'data' => $o_chkoutOutput->getAttachmentList($this->o_model->getId(), false),
00194             'dataIsSafe' => true);
00195 
00196         // Show comments
00197         require_once dirname(__FILE__) . '/../Model/Comment.php';
00198         $o_commentModel =& new FF_Model_Comment();
00199         foreach ($o_commentModel->getCommentsByTransactionId($this->o_model->getId()) as $a_data) {
00200             $o_commentModel->reset();
00201             $o_commentModel->importFromArray($a_data);
00202             $a_headers[] = array(
00203                 'title' => _('Comment:'),
00204                 'data' => $o_chkoutOutput->getCommentTable(array('o_comment' => &$o_commentModel), false),
00205                 'dataIsSafe' => true,
00206                 );
00207         }
00208         
00209         return $a_headers;
00210     }
00211 
00212     // }}}
00213     // {{{ getSingularText()
00214 
00221     function getSingularText()
00222     {
00223         return _('Item');
00224     }
00225 
00226     // }}}
00227     // {{{ getPluralText()
00228 
00236     function getPluralText()
00237     {
00238         return _('Items');
00239     }
00240 
00241     // }}}
00242 }
00243 ?>

Generated on Fri Jun 23 11:38:16 2006 for FastFrame by  doxygen 1.4.4