Files
@ a45f0dabc59c
Branch filter:
Location: hot67beta/components/com_contact/views/contact/view.html.php
a45f0dabc59c
7.2 KiB
text/x-php
mneh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | <?php
/**
* @version $Id: view.html.php 11393 2009-01-05 02:11:06Z ian $
* @package Joomla
* @subpackage Contact
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant to the
* GNU General Public License, and as distributed it includes or is derivative
* of works licensed under the GNU General Public License or other free or open
* source software licenses. See COPYRIGHT.php for copyright notices and
* details.
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die( 'Restricted access' );
jimport('joomla.application.component.view');
/**
* @package Joomla
* @subpackage Contacts
*/
class ContactViewContact extends JView
{
function display($tpl = null)
{
global $mainframe;
$user = &JFactory::getUser();
$pathway = &$mainframe->getPathway();
$document = & JFactory::getDocument();
$model = &$this->getModel();
// Get the parameters of the active menu item
$menus = &JSite::getMenu();
$menu = $menus->getActive();
$pparams = &$mainframe->getParams('com_contact');
// Push a model into the view
$model = &$this->getModel();
$modelCat = &$this->getModel( 'Category' );
// Selected Request vars
// ID may come from the contact switcher
if (!($contactId = JRequest::getInt( 'contact_id', 0 ))) {
$contactId = JRequest::getInt( 'id', $contactId );
}
// query options
$options['id'] = $contactId;
$options['aid'] = $user->get('aid', 0);
$contact = $model->getContact( $options );
// check if we have a contact
if (!is_object( $contact )) {
JError::raiseError( 404, 'Contact not found' );
return;
}
// check if access is registered/special
if (($contact->access > $user->get('aid', 0)) || ($contact->category_access > $user->get('aid', 0))) {
$uri = JFactory::getURI();
$return = $uri->toString();
$url = 'index.php?option=com_user&view=login';
$url .= '&return='.base64_encode($return);
$mainframe->redirect($url, JText::_('You must login first') );
}
$options['category_id'] = $contact->catid;
$options['order by'] = 'cd.default_con DESC, cd.ordering ASC';
$contacts = $modelCat->getContacts( $options );
// Set the document page title
// because the application sets a default page title, we need to get it
// right from the menu item itself
if (is_object( $menu ) && isset($menu->query['view']) && $menu->query['view'] == 'contact' && isset($menu->query['id']) && $menu->query['id'] == $contact->id) {
$menu_params = new JParameter( $menu->params );
if (!$menu_params->get( 'page_title')) {
$pparams->set('page_title', $contact->name);
}
} else {
$pparams->set('page_title', $contact->name);
}
$document->setTitle( $pparams->get( 'page_title' ) );
//set breadcrumbs
if (isset( $menu ) && isset($menu->query['view']) && $menu->query['view'] != 'contact'){
$pathway->addItem($contact->name, '');
}
// Adds parameter handling
$contact->params = new JParameter($contact->params);
$pparams->merge($contact->params);
// Handle component/menu overides for some contact parameters if set
/*
$contact->params->def('contact_icons', $pparams->get('contact_icons'));
$contact->params->def('icon_address', $pparams->get('icon_address'));
$contact->params->def('icon_email', $pparams->get('icon_email'));
$contact->params->def('icon_telephone', $pparams->get('icon_telephone'));
$contact->params->def('icon_fax', $pparams->get('icon_fax'));
$contact->params->def('icon_misc', $pparams->get('icon_misc'));
$contact->params->def('show_position', $pparams->get('show_position'));
$contact->params->def('show_email', $pparams->get('show_email'));
$contact->params->def('show_telephone', $pparams->get('show_telephone'));
$contact->params->def('show_mobile', $pparams->get('show_mobile'));
$contact->params->def('show_fax', $pparams->get('show_fax'));
$contact->params->def('allow_vcard', $pparams->get('allow_vcard'));
*/
// Handle email cloaking
if ($contact->email_to && $contact->params->get('show_email')) {
$contact->email_to = JHTML::_('email.cloak', $contact->email_to);
}
if ($contact->params->get('show_street_address') || $contact->params->get('show_suburb') || $contact->params->get('show_state') || $contact->params->get('show_postcode') || $contact->params->get('show_country'))
{
if (!empty ($contact->address) || !empty ($contact->suburb) || !empty ($contact->state) || !empty ($contact->country) || !empty ($contact->postcode)) {
$contact->params->set('address_check', 1);
}
} else {
$contact->params->set('address_check', 0);
}
// Manage the display mode for contact detail groups
switch ($contact->params->get('contact_icons'))
{
case 1 :
// text
$contact->params->set('marker_address', JText::_('Address').": ");
$contact->params->set('marker_email', JText::_('Email').": ");
$contact->params->set('marker_telephone', JText::_('Telephone').": ");
$contact->params->set('marker_fax', JText::_('Fax').": ");
$contact->params->set('marker_mobile', JText::_('Mobile').": ");
$contact->params->set('marker_misc', JText::_('Information').": ");
$contact->params->set('column_width', '100');
break;
case 2 :
// none
$contact->params->set('marker_address', '');
$contact->params->set('marker_email', '');
$contact->params->set('marker_telephone', '');
$contact->params->set('marker_mobile', '');
$contact->params->set('marker_fax', '');
$contact->params->set('marker_misc', '');
$contact->params->set('column_width', '0');
break;
default :
// icons
$image1 = JHTML::_('image.site', 'con_address.png', '/images/M_images/', $contact->params->get('icon_address'), '/images/M_images/', JText::_('Address').": ");
$image2 = JHTML::_('image.site', 'emailButton.png', '/images/M_images/', $contact->params->get('icon_email'), '/images/M_images/', JText::_('Email').": ");
$image3 = JHTML::_('image.site', 'con_tel.png', '/images/M_images/', $contact->params->get('icon_telephone'), '/images/M_images/', JText::_('Telephone').": ");
$image4 = JHTML::_('image.site', 'con_fax.png', '/images/M_images/', $contact->params->get('icon_fax'), '/images/M_images/', JText::_('Fax').": ");
$image5 = JHTML::_('image.site', 'con_info.png', '/images/M_images/', $contact->params->get('icon_misc'), '/images/M_images/', JText::_('Information').": ");
$image6 = JHTML::_('image.site', 'con_mobile.png', '/images/M_images/', $contact->params->get('icon_mobile'), '/images/M_images/', JText::_('Mobile').": ");
$contact->params->set('marker_address', $image1);
$contact->params->set('marker_email', $image2);
$contact->params->set('marker_telephone', $image3);
$contact->params->set('marker_fax', $image4);
$contact->params->set('marker_misc', $image5);
$contact->params->set('marker_mobile', $image6);
$contact->params->set('column_width', '40');
break;
}
JHTML::_('behavior.formvalidation');
$this->assignRef('contact', $contact);
$this->assignRef('contacts', $contacts);
$this->assignRef('params', $pparams);
parent::display($tpl);
}
}
|