Current File : /home/pacjaorg/public_html/km/administrator/components/com_djclassifieds/views/item/view.html.php |
<?php
/**
* @package DJ-Classifieds
* @copyright Copyright (C) DJ-Extensions.com, All rights reserved.
* @license http://www.gnu.org/licenses GNU/GPL
* @author url: http://dj-extensions.com
* @author email: contact@dj-extensions.com
*/
defined ('_JEXEC') or die('Restricted access');
class DJClassifiedsViewItem extends JViewLegacy
{
function display($tpl = null)
{
$app = JFactory::getApplication();
$par = JComponentHelper::getParams('com_djclassifieds');
$djmodel = new DJClassifiedsModel();
$this->item = $this->get('Item');
$this->state = $this->get('State');
$this->form = $this->get('Form');
if($this->item->id){
$this->item = $djmodel->getItemById($this->item->id);
}
DJClassifiedsTheme::includeCalendarScripts();
DJClassifiedsTheme::includeDJImageAssets();
DJClassifiedsTheme::includeMapsScript($par);
$app->triggerEvent('onAdminPrepareItemEdit', array(&$this->item, &$par));
$this->item->event = new stdClass();
$this->item->event->onBeforeDJClassifiedsDisplayAdvertMap = trim(implode("\n", $app->triggerEvent('onBeforeDJClassifiedsDisplayAdvertMap', array(&$this->item, &$par, 'item'))));
$this->bs_cl = DJClassifiedsTheme::getBSClasses();
$this->addToolbar();
$this->par = $par;
parent::display($tpl);
}
protected function addToolbar()
{
JFactory::getApplication()->input->set('hidemainmenu', true);
$user = JFactory::getUser();
$isNew = ($this->item->id == 0);
$text = $isNew ? JText::_( 'COM_DJCLASSIFIEDS_NEW' ) : JText::_( 'COM_DJCLASSIFIEDS_EDIT' );
JToolBarHelper::title( JText::_( 'COM_DJCLASSIFIEDS_ITEM' ).': <small><small>[ ' . $text.' ]</small></small>', 'generic.png' );
JToolBarHelper::apply('item.apply', 'JTOOLBAR_APPLY');
JToolBarHelper::save('item.save', 'JTOOLBAR_SAVE');
JToolBarHelper::custom('item.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
JToolBarHelper::custom('item.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false);
if(!$isNew){
$form = JForm::getInstance('sendmessage', JPATH_ROOT.'/administrator/components/com_djclassifieds/models/forms/sendmessage.xml');
$form->setValue('djmsg_item_id', null, $this->item->id);
if($this->item->user_id){
$item_user = JFactory::getUser($this->item->user_id);
$form->setValue('djmsg_email', null, $item_user->email);
}else if($this->item->email){
$form->setValue('djmsg_email', null, $this->item->email);
}
$bar = JToolBar::getInstance('toolbar');
$data = array(
'form' => $form,
'form_action' => 'index.php?option=com_djclassifieds&task=item.sendMessage',
'modal_id' => 'sendMsgModal'
);
$layout = new JLayoutFile('modalsendmessage', JPATH_ROOT .'/administrator/components/com_djclassifieds/layouts');
$dhtml = $layout->render($data);
$bar->appendButton('Custom', $dhtml, 'sendmessage');
}
JToolBarHelper::cancel('item.cancel', 'JTOOLBAR_CANCEL');
}
}