本文整理汇总了PHP中ContactHelperRoute类的典型用法代码示例。如果您正苦于以下问题:PHP ContactHelperRoute类的具体用法?PHP ContactHelperRoute怎么用?PHP ContactHelperRoute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ContactHelperRoute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getContactRoute
function getContactRoute($id, $catid)
{
$needles = array('category' => (int) $catid, 'categories' => null);
//Find the itemid
$itemid = ContactHelperRoute::_findItem($needles);
$itemid = $itemid ? '&Itemid=' . $itemid : '';
//Create the link
$link = 'index.php?option=com_contact&view=contact&id=' . $id . '&catid=' . $catid . $itemid;
return $link;
}
示例2: display
function display($tpl = null)
{
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$params = $app->getParams();
$feedEmail = $app->getCfg('feed_email', 'author');
$siteEmail = $app->getCfg('mailfrom');
$fromName = $app->getCfg('fromname');
JRequest::setVar('limit', $app->getCfg('feed_limit'));
// Get some data from the models
$category = $this->get('Category');
$rows = $this->get('Items');
$doc->link = JRoute::_(ContactHelperRoute::getCategoryRoute($category->id));
foreach ($rows as $row) {
// strip html from feed item title
$title = $this->escape($row->name);
$title = html_entity_decode($title, ENT_COMPAT, 'UTF-8');
// Compute the contact slug
$row->slug = $row->alias ? $row->id . ':' . $row->alias : $row->id;
// url link to article
$link = JRoute::_(ContactHelperRoute::getContactRoute($row->slug, $row->catid));
$description = $row->address;
$author = $row->created_by_alias ? $row->created_by_alias : $row->author;
@($date = $row->created ? date('r', strtotime($row->created)) : '');
// load individual item creator class
$item = new JFeedItem();
$item->title = $title;
$item->link = $link;
$item->description = $description;
$item->date = $date;
$item->category = $category->title;
$item->author = $author;
// We don't have the author email so we have to use site in both cases.
if ($feedEmail == 'site') {
$item->authorEmail = $siteEmail;
} elseif ($feedEmail == 'author') {
$item->authorEmail = $row->author_email;
}
// loads item info into rss array
$doc->addItem($item);
}
}
示例3: prepareDocument
/**
* Prepares the document
*
* @return void
*/
protected function prepareDocument()
{
parent::prepareDocument();
$menu = $this->menu;
$id = (int) @$menu->query['id'];
if ($menu && ($menu->query['option'] != $this->extension || $menu->query['view'] == $this->viewName || $id != $this->category->id)) {
$path = array(array('title' => $this->category->title, 'link' => ''));
$category = $this->category->getParent();
while (($menu->query['option'] != 'com_contact' || $menu->query['view'] == 'contact' || $id != $category->id) && $category->id > 1) {
$path[] = array('title' => $category->title, 'link' => ContactHelperRoute::getCategoryRoute($category->id));
$category = $category->getParent();
}
$path = array_reverse($path);
foreach ($path as $item) {
$this->pathway->addItem($item['title'], $item['link']);
}
}
parent::addFeed();
}
示例4: getAssociations
/**
* Method to get the associations for a given item
*
* @param integer $id Id of the item
* @param string $view Name of the view
*
* @return array Array of associations for the item
*
* @since 3.0
*/
public static function getAssociations($id = 0, $view = null)
{
$jinput = JFactory::getApplication()->input;
$view = $view === null ? $jinput->get('view') : $view;
$id = empty($id) ? $jinput->getInt('id') : $id;
if ($view === 'contact') {
if ($id) {
$associations = JLanguageAssociations::getAssociations('com_contact', '#__contact_details', 'com_contact.item', $id);
$return = array();
foreach ($associations as $tag => $item) {
$return[$tag] = ContactHelperRoute::getContactRoute($item->id, (int) $item->catid, $item->language);
}
return $return;
}
}
if ($view === 'category' || $view === 'categories') {
return self::getCategoryAssociations($id, 'com_contact');
}
return array();
}
示例5: display
function display()
{
// Get some data from the models
$category = $this->get('Category');
$rows = $this->get('Items');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$params = $app->getParams();
$doc->link = JRoute::_(ContactHelperRoute::getCategoryRoute($category->id));
foreach ($rows as $row) {
// strip html from feed item title
$title = $this->escape($row->name);
$title = html_entity_decode($title, ENT_COMPAT, 'UTF-8');
// Compute the contact slug
$row->slug = $row->alias ? $row->id . ':' . $row->alias : $row->id;
// url link to article
// & used instead of & as this is converted by feed creator
$link = JRoute::_(ContactHelperRoute::getContactRoute($row->slug, $row->catid), false);
// strip html from feed item description text
// TODO: Only pull fulltext if necessary (actually, just get the necessary fields).
$description = $params->get('feed_summary', 0) ? $row->introtext : $row->introtext;
$author = $row->created_by_alias ? $row->created_by_alias : $row->author;
@($date = $row->created ? date('r', strtotime($row->created)) : '');
// load individual item creator class
$item = new JFeedItem();
$item->title = $title;
$item->link = $link;
$item->description = $description;
$item->date = $date;
$item->category = $row->category;
// loads item info into rss array
$doc->addItem($item);
}
}
示例6: getAssociations
/**
* Method to get the associations for a given item
*
* @param integer $id Id of the item
* @param string $view Name of the view
*
* @return array Array of associations for the item
*
* @since 3.0
*/
public static function getAssociations($id = 0, $view = null)
{
jimport('helper.route', JPATH_COMPONENT_SITE);
$app = JFactory::getApplication();
$jinput = $app->input;
$view = is_null($view) ? $jinput->get('view') : $view;
$id = empty($id) ? $jinput->getInt('id') : $id;
if ($view == 'contact') {
if ($id) {
$associations = ContactHelper::getAssociations($id);
$return = array();
foreach ($associations as $tag => $item) {
$return[$tag] = ContactHelperRoute::getContactRoute($item->id, $item->catid, $item->language);
}
return $return;
}
}
if ($view == 'category' || $view == 'categories') {
return self::getCategoryAssociations($id, 'com_contact');
}
return array();
}
示例7: onContentSearch
/**
* Search content (contacts).
*
* The SQL must return the following fields that are used in a common display
* routine: href, title, section, created, text, browsernav.
*
* @param string $text Target search string.
* @param string $phrase Matching option (possible values: exact|any|all). Default is "any".
* @param string $ordering Ordering option (possible values: newest|oldest|popular|alpha|category). Default is "newest".
* @param string $areas An array if the search is to be restricted to areas or null to search all areas.
*
* @return array Search results.
*
* @since 1.6
*/
public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
{
require_once JPATH_SITE . '/components/com_contact/helpers/route.php';
$db = JFactory::getDbo();
$app = JFactory::getApplication();
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
if (is_array($areas)) {
if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) {
return array();
}
}
$sContent = $this->params->get('search_content', 1);
$sArchived = $this->params->get('search_archived', 1);
$limit = $this->params->def('search_limit', 50);
$state = array();
if ($sContent) {
$state[] = 1;
}
if ($sArchived) {
$state[] = 2;
}
if (empty($state)) {
return array();
}
$text = trim($text);
if ($text == '') {
return array();
}
$section = JText::_('PLG_SEARCH_CONTACTS_CONTACTS');
switch ($ordering) {
case 'alpha':
$order = 'a.name ASC';
break;
case 'category':
$order = 'c.title ASC, a.name ASC';
break;
case 'popular':
case 'newest':
case 'oldest':
default:
$order = 'a.name DESC';
}
$text = $db->quote('%' . $db->escape($text, true) . '%', false);
$query = $db->getQuery(true);
// SQLSRV changes.
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias', '!=', '0');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id . ' END as slug';
$case_when1 = ' CASE WHEN ';
$case_when1 .= $query->charLength('c.alias', '!=', '0');
$case_when1 .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when1 .= ' ELSE ';
$case_when1 .= $c_id . ' END as catslug';
$query->select('a.name AS title, \'\' AS created, a.con_position, a.misc, ' . $case_when . ',' . $case_when1 . ', ' . $query->concatenate(array("a.name", "a.con_position", "a.misc"), ",") . ' AS text,' . $query->concatenate(array($db->quote($section), "c.title"), " / ") . ' AS section,' . '\'2\' AS browsernav');
$query->from('#__contact_details AS a')->join('INNER', '#__categories AS c ON c.id = a.catid')->where('(a.name LIKE ' . $text . ' OR a.misc LIKE ' . $text . ' OR a.con_position LIKE ' . $text . ' OR a.address LIKE ' . $text . ' OR a.suburb LIKE ' . $text . ' OR a.state LIKE ' . $text . ' OR a.country LIKE ' . $text . ' OR a.postcode LIKE ' . $text . ' OR a.telephone LIKE ' . $text . ' OR a.fax LIKE ' . $text . ') AND a.published IN (' . implode(',', $state) . ') AND c.published=1 ' . ' AND a.access IN (' . $groups . ') AND c.access IN (' . $groups . ')')->order($order);
// Filter by language.
if ($app->isSite() && JLanguageMultilang::isEnabled()) {
$tag = JFactory::getLanguage()->getTag();
$query->where('a.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')')->where('c.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')');
}
$db->setQuery($query, 0, $limit);
try {
$rows = $db->loadObjectList();
} catch (RuntimeException $e) {
$rows = array();
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
}
if ($rows) {
foreach ($rows as $key => $row) {
$rows[$key]->href = ContactHelperRoute::getContactRoute($row->slug, $row->catslug);
$rows[$key]->text = $row->title;
$rows[$key]->text .= $row->con_position ? ', ' . $row->con_position : '';
$rows[$key]->text .= $row->misc ? ', ' . $row->misc : '';
}
}
return $rows;
}
示例8:
<?php
if ($this->params->get('show_fax_headings') and !empty($item->fax)) {
?>
<?php
echo JTEXT::sprintf('COM_CONTACT_FAX_NUMBER', $item->fax);
?>
<br />
<?php
}
?>
</span>
<p>
<div class="list-title">
<a href="<?php
echo JRoute::_(ContactHelperRoute::getContactRoute($item->slug, $item->catid));
?>
">
<?php
echo $item->name;
?>
</a>
<?php
if ($this->items[$i]->published == 0) {
?>
<span class="label label-warning"><?php
echo JText::_('JUNPUBLISHED');
?>
</span>
<?php
}
示例9: sizeof
if ($params->get('separate_code', '') == "hr") {
$separate_code = "<hr class=\"contact_sep\" />";
} else {
$separate_code = "";
}
}
}
include $sitepath . 'components/com_contact/helpers/route.php';
echo '<div class="custom module doctors">';
echo '<h3 class="page-header"><a href="/specialist"><span>Наши специалисты</span></a></h3>';
echo '<ul>';
$separate_num = sizeof($contacts);
for ($i = 0; $i < sizeof($contacts); $i++) {
echo '<li>';
$slug = $contacts[$i]->id . ":" . $contacts[$i]->alias;
$url = ContactHelperRoute::getContactRoute($slug, $contacts[$i]->catid);
$telephone_array = explode(",", $contacts[$i]->telephone);
if ($params->get('show_image', '') == 1 && $contacts[$i]->name != '') {
if ($params->get('link_image', '') == 1) {
echo "<a href=\"" . $url . "\" class=\"thumb\">" . contactImage($contacts[$i], $params->get('thumb_size', 100)) . "</a>{$newspace}\n";
} else {
echo "<span class=\"info_image\">" . contactImage($contacts[$i], $params->get('thumb_size', 100)) . "</span>{$newspace}\n";
}
}
list($lastname, $firstname, $middlename) = split(' ', $contacts[$i]->name);
if ($params->get('show_name', '') == 1 && $contacts[$i]->name != '') {
if ($params->get('link_to', '') == 1) {
echo "<h4><a href=\"" . $url . "\"><strong>" . $lastname . "</strong><br/>" . $firstname . " " . $middlename . "</a></h4>{$newspace}\n";
} else {
echo "<h4><strong>" . $lastname . "</strong><br/>" . $firstname . " " . $middlename . "</h4>{$newspace}\n";
}
示例10:
if ($this->params->get('show_contact_category') == 'show_no_link') {
?>
<h3>
<span class="contact-category"><?php
echo $this->contact->category_title;
?>
</span>
</h3>
<?php
}
?>
<?php
if ($this->params->get('show_contact_category') == 'show_with_link') {
?>
<?php
$contactLink = ContactHelperRoute::getCategoryRoute($this->contact->catid);
?>
<h3>
<span class="contact-category"><a href="<?php
echo $contactLink;
?>
">
<?php
echo $this->escape($this->contact->category_title);
?>
</a>
</span>
</h3>
<?php
}
?>
示例11: index
/**
* Method to index an item. The item must be a FinderIndexerResult object.
*
* @param FinderIndexerResult $item The item to index as an FinderIndexerResult object.
* @param string $format The item format
*
* @return void
*
* @since 2.5
* @throws Exception on database error.
*/
protected function index(FinderIndexerResult $item, $format = 'html')
{
// Check if the extension is enabled
if (JComponentHelper::isEnabled($this->extension) == false) {
return;
}
$item->setLanguage();
// Initialize the item parameters.
$registry = new Registry();
$registry->loadString($item->params);
$item->params = $registry;
// Build the necessary route and path information.
$item->url = $this->getURL($item->id, $this->extension, $this->layout);
$item->route = ContactHelperRoute::getContactRoute($item->slug, $item->catslug, $item->language);
$item->path = FinderIndexerHelper::getContentPath($item->route);
// Get the menu title if it exists.
$title = $this->getItemMenuTitle($item->url);
// Adjust the title if necessary.
if (!empty($title) && $this->params->get('use_menu_title', true)) {
$item->title = $title;
}
/*
* Add the meta-data processing instructions based on the contact
* configuration parameters.
*/
// Handle the contact position.
if ($item->params->get('show_position', true)) {
$item->addInstruction(FinderIndexer::META_CONTEXT, 'position');
}
// Handle the contact street address.
if ($item->params->get('show_street_address', true)) {
$item->addInstruction(FinderIndexer::META_CONTEXT, 'address');
}
// Handle the contact city.
if ($item->params->get('show_suburb', true)) {
$item->addInstruction(FinderIndexer::META_CONTEXT, 'city');
}
// Handle the contact region.
if ($item->params->get('show_state', true)) {
$item->addInstruction(FinderIndexer::META_CONTEXT, 'region');
}
// Handle the contact country.
if ($item->params->get('show_country', true)) {
$item->addInstruction(FinderIndexer::META_CONTEXT, 'country');
}
// Handle the contact zip code.
if ($item->params->get('show_postcode', true)) {
$item->addInstruction(FinderIndexer::META_CONTEXT, 'zip');
}
// Handle the contact telephone number.
if ($item->params->get('show_telephone', true)) {
$item->addInstruction(FinderIndexer::META_CONTEXT, 'telephone');
}
// Handle the contact fax number.
if ($item->params->get('show_fax', true)) {
$item->addInstruction(FinderIndexer::META_CONTEXT, 'fax');
}
// Handle the contact e-mail address.
if ($item->params->get('show_email', true)) {
$item->addInstruction(FinderIndexer::META_CONTEXT, 'email');
}
// Handle the contact mobile number.
if ($item->params->get('show_mobile', true)) {
$item->addInstruction(FinderIndexer::META_CONTEXT, 'mobile');
}
// Handle the contact webpage.
if ($item->params->get('show_webpage', true)) {
$item->addInstruction(FinderIndexer::META_CONTEXT, 'webpage');
}
// Handle the contact user name.
$item->addInstruction(FinderIndexer::META_CONTEXT, 'user');
// Add the type taxonomy data.
$item->addTaxonomy('Type', 'Contact');
// Add the category taxonomy data.
$item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access);
// Add the language taxonomy data.
$item->addTaxonomy('Language', $item->language);
// Add the region taxonomy data.
if (!empty($item->region) && $this->params->get('tax_add_region', true)) {
$item->addTaxonomy('Region', $item->region);
}
// Add the country taxonomy data.
if (!empty($item->country) && $this->params->get('tax_add_country', true)) {
$item->addTaxonomy('Country', $item->country);
}
// Get content extras.
FinderIndexerHelper::getContentExtras($item);
// Index the item.
$this->indexer->index($item);
//.........这里部分代码省略.........
示例12: _prepareDocument
/**
* Prepares the document
*/
protected function _prepareDocument()
{
$app = JFactory::getApplication();
$menus = $app->getMenu();
$pathway = $app->getPathway();
$title = null;
// Because the application sets a default page title,
// we need to get it from the menu item itself
$menu = $menus->getActive();
if ($menu) {
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
} else {
$this->params->def('page_heading', JText::_('COM_CONTACT_DEFAULT_PAGE_TITLE'));
}
$id = (int) @$menu->query['id'];
if ($menu && ($menu->query['option'] != 'com_contact' || $menu->query['view'] == 'contact' || $id != $this->category->id)) {
$path = array(array('title' => $this->category->title, 'link' => ''));
$category = $this->category->getParent();
while (($menu->query['option'] != 'com_contact' || $menu->query['view'] == 'contact' || $id != $category->id) && $category->id > 1) {
$path[] = array('title' => $category->title, 'link' => ContactHelperRoute::getCategoryRoute($category->id));
$category = $category->getParent();
}
$path = array_reverse($path);
foreach ($path as $item) {
$pathway->addItem($item['title'], $item['link']);
}
}
$title = $this->params->get('page_title', '');
if (empty($title)) {
$title = $app->getCfg('sitename');
} elseif ($app->getCfg('sitename_pagetitles', 0)) {
$title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
}
$this->document->setTitle($title);
if ($this->category->metadesc) {
$this->document->setDescription($this->category->metadesc);
} elseif (!$this->category->metadesc && $this->params->get('menu-meta_description')) {
$this->document->setDescription($this->params->get('menu-meta_description'));
}
if ($this->category->metakey) {
$this->document->setMetadata('keywords', $this->category->metakey);
} elseif (!$this->category->metakey && $this->params->get('menu-meta_keywords')) {
$this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
}
if ($app->getCfg('MetaTitle') == '1') {
$this->document->setMetaData('title', $this->category->getMetadata()->get('page_title'));
}
if ($app->getCfg('MetaAuthor') == '1') {
$this->document->setMetaData('author', $this->category->getMetadata()->get('author'));
}
$mdata = $this->category->getMetadata()->toArray();
foreach ($mdata as $k => $v) {
if ($v) {
$this->document->setMetadata($k, $v);
}
}
// Add alternative feed link
if ($this->params->get('show_feed_link', 1) == 1) {
$link = '&format=feed&limitstart=';
$attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
$this->document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs);
$attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
$this->document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs);
}
}
示例13: defined
<?php
defined('_JEXEC') or die;
?>
<?php if (count($this->items[$this->parent->id]) > 0 && $this->maxLevelcat != 0) : ?>
<ul>
<?php foreach($this->items[$this->parent->id] as $id => $item) : ?>
<?php if ($this->params->get('show_empty_categories_cat') || $item->numitems || count($item->getChildren())) : ?>
<li>
<a href="<?php echo JRoute::_(ContactHelperRoute::getCategoryRoute($item->id));?>"><?php echo $this->escape($item->title); ?></a>
<?php if ($this->params->get('show_cat_items_cat') == 1) : ?>
<small>(<?php echo $item->numitems; ?>)</small>
<?php endif; ?>
<?php if (($this->params->get('show_subcat_desc_cat') == 1) && $item->description) : ?>
<div><?php echo JHtml::_('content.prepare', $item->description, '', 'com_contact.categories'); ?></div>
<?php endif; ?>
<?php
if (count($item->getChildren()) > 0) {
$this->items[$item->id] = $item->getChildren();
$this->parent = $item;
$this->maxLevelcat--;
echo $this->loadTemplate('items');
$this->parent = $item->getParent();
$this->maxLevelcat++;
}
?>
</li>
示例14: rowToDocument
/**
* Convert an row to an elastica document
*/
private function rowToDocument($row)
{
$id = $row->id;
//Create a date object
$date = new DateTime($row->created);
//Get the names of the categories
$category = JCategories::getInstance('Contact')->get($row->catid);
$categories = array();
while ($category && $category->id > 1) {
$categories[] = $category->title;
$category = $category->getParent();
}
// Create a document
$entity = array('id' => $id, 'name' => html_entity_decode(strip_tags($row->name), ENT_COMPAT | ENT_HTML401, 'UTF-8'), 'alias' => $row->alias, 'misc' => html_entity_decode(strip_tags($row->misc), ENT_COMPAT | ENT_HTML401, 'UTF-8'), 'categories' => implode(';', $categories), 'language' => $row->language, 'created_at' => $date->format('Y-m-d\\Th:i:s'), 'href' => ContactHelperRoute::getContactRoute($row->id, implode(';', $categories), $row->language));
$document = new \Elastica\Document($id, $entity);
return $document;
}
示例15:
<?php
if ($this->params->get('show_empty_categories_cat') || $item->numitems || count($item->getChildren())) {
if (!isset($this->items[$this->parent->id][$id + 1])) {
$class = ' class="last"';
}
?>
<li<?php
echo $class;
?>
>
<?php
$class = '';
?>
<h4 class="item-title">
<a href="<?php
echo JRoute::_(ContactHelperRoute::getCategoryRoute($item->id));
?>
">
<?php
echo $this->escape($item->title);
?>
</a>
<?php
if ($this->params->get('show_cat_items_cat') == 1) {
?>
<span class="badge badge-info pull-right" title="<?php
echo JText::_('COM_CONTACT_COUNT');
?>
"><?php
echo $item->numitems;