/**
	 * Print Popup
	 *
	 * @param   object     $member   Member info
	 * @param   JRegistry  $params   HTML Params
	 * @param   array      $attribs  Member attribs
	 *
	 * @return string
	 *
	 * @since    1.5
	 */
	public static function print_popup($member, $params, $attribs = [])
	{
		$url = ChurchDirectoryHelperRoute::getMemberRoute($member->slug, $member->catid);
		$url .= '&tmpl=component&print=1&layout=default';

		$status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no';

		// Checks template image directory for image, if non found default are loaded
		if ($params->get('show_icons'))
		{
			$text = JHtml::_('image', 'system/printButton.png', JText::_('JGLOBAL_PRINT'), null, true);
		}
		else
		{
			$text = JText::_('JGLOBAL_ICON_SEP') . ' ' . JText::_('JGLOBAL_PRINT') . ' ' . JText::_('JGLOBAL_ICON_SEP');
		}

		$attribs['title']   = JText::_('JGLOBAL_PRINT');
		$attribs['onclick'] = "window.open(this.href,'win2','" . $status . "'); return false;";
		$attribs['rel']     = 'nofollow';

		return JHtml::_('link', JRoute::_($url), $text, $attribs);
	}
	/**
	 * 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   1.7.0
	 * @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;
		}

		// 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 = ChurchDirectoryHelperRoute::getMemberRoute($item->slug, $item->catslug);
		$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 member
		 * configuration parameters.
		 */
		/* Handle the member position.
		 if ($item->params->get('show_position', true)) {
		    $item->addInstruction(FinderIndexer::META_CONTEXT, 'position');
		 } */
		// Handle the member street address.
		if ($item->params->get('show_street_address', true))
		{
			$item->addInstruction(FinderIndexer::META_CONTEXT, 'address');
		}

		// Handle the member city.
		if ($item->params->get('show_suburb', true))
		{
			$item->addInstruction(FinderIndexer::META_CONTEXT, 'city');
		}

		// Handle the member region.
		if ($item->params->get('show_state', true))
		{
			$item->addInstruction(FinderIndexer::META_CONTEXT, 'region');
		}

		// Handle the member country.
		if ($item->params->get('show_country', true))
		{
			$item->addInstruction(FinderIndexer::META_CONTEXT, 'country');
		}

		// Handle the member zip code.
		if ($item->params->get('show_postcode', true))
		{
			$item->addInstruction(FinderIndexer::META_CONTEXT, 'zip');
		}

		// Handle the member telephone number.
		if ($item->params->get('show_telephone', true))
		{
			$item->addInstruction(FinderIndexer::META_CONTEXT, 'telephone');
		}

		// Handle the member fax number.
		if ($item->params->get('show_fax', true))
		{
			$item->addInstruction(FinderIndexer::META_CONTEXT, 'fax');
		}

		// Handle the member e-mail address.
		if ($item->params->get('show_email', true))
		{
			$item->addInstruction(FinderIndexer::META_CONTEXT, 'email');
		}

		// Handle the member mobile number.
		if ($item->params->get('show_mobile', true))
		{
			$item->addInstruction(FinderIndexer::META_CONTEXT, 'mobile');
		}

		// Handle the member webpage.
		if ($item->params->get('show_webpage', true))
		{
			$item->addInstruction(FinderIndexer::META_CONTEXT, 'webpage');
		}

		// Handle the member webpage.
		if ($item->params->get('show_children', true))
		{
			$item->addInstruction(FinderIndexer::META_CONTEXT, 'children');
		}

		// Handle the member user name.
		$item->addInstruction(FinderIndexer::META_CONTEXT, 'user');

		// Add the type taxonomy data.
		$item->addTaxonomy('Type', 'Church Member');

		// 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);
	}
	/**
	 * Display Function
	 *
	 * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
	 *
	 * @return  mixed  A string if successful, otherwise a Error object.
	 *
	 * @since       1.7.2
	 */
	public function display($tpl = null)
	{
		/** @var JApplicationSite $app */
		$app = JFactory::getApplication();

		// Check for errors.
		if (count($errors = $this->get('Errors')))
		{
			$app->enqueueMessage(implode("\n", $errors), 'error');

			return false;
		}

		$doc       = JFactory::getDocument();
		$params    = $app->getParams();
		$feedEmail = $app->get('feed_email', 'author');
		$siteEmail = $app->get('mailfrom');
		$fromName  = $app->get('fromname');

		$app->input->set('limit', $app->get('feed_limit'));

		// Get some data from the models
		$category = $this->get('Category');
		$rows     = $this->get('Items');

		$doc->link = JRoute::_(ChurchDirectoryHelperRoute::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 churchdirectory slug
			$row->slug = $row->alias ? ($row->id . ':' . $row->alias) : $row->id;

			// Url link to article
			$link = JRoute::_(ChurchDirectoryHelperRoute::getMemberRoute($row->slug, $row->catid));

			$description = $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    = $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);
		}

		return true;
	}
			{
				echo $children . '<br />';
			} ?>
		</p>
	<?php } ?>
	<?php if ($this->params->get('show_contact_category') == 'show_no_link')
	{
		?>
		<h3>
			<span class="contact-category"><?php echo $this->member->category_title; ?></span>
		</h3>
	<?php } ?>
	<?php if ($this->params->get('show_contact_category') == 'show_with_link')
	{
		?>
		<?php $contactLink = ChurchDirectoryHelperRoute::getCategoryRoute($this->member->catid); ?>
		<h3>
			<span class="contact-category"><a href="<?php echo $contactLink; ?>">
					<?php echo $this->escape($this->member->category_title); ?></a>
			</span>
		</h3>
	<?php } ?>
	<?php if ($this->params->get('show_contact_list') && count($this->contacts) > 1)
	{
		?>
		<form action="#" method="get" name="selectForm" id="selectForm">
			<?php echo JText::_('COM_CHURCHDIRECTORY_SELECT_CHURCHDIRECTORY'); ?>
			<?php echo JHtml::_('select.genericlist', $this->contacts, 'id', 'class="inputbox" onchange="document.location.href = this.value"', 'link', 'name', $this->member->link); ?>
		</form>
	<?php } ?>
            </th>
			<?php endif; ?>

        </tr>
        </thead>
		<?php endif; ?>

        <tbody>
			<?php foreach ($this->items as $i => $item) : ?>
        <tr class="<?php echo ($i % 2) ? "odd" : "even"; ?>">
            <td class="item-num">
				<?php echo $i; ?>
            </td>

            <td class="item-title">
                <a href="<?php echo JRoute::_(ChurchDirectoryHelperRoute::getMemberRoute($item->slug, $item->catid)); ?>">
					<?php echo $item->name; ?></a>
            </td>

			<?php if ($this->params->get('show_position_headings')) : ?>
            <td class="item-position">
				<?php echo $renderHelper->getPosition($item->con_position); ?>
            </td>
			<?php endif; ?>

			<?php if ($this->params->get('show_email_headings')) : ?>
            <td class="item-email">
				<?php echo $item->email_to; ?>
            </td>
			<?php endif; ?>
$class = ' class="first"';
if (count($this->children[$this->category->id]) > 0 && $this->maxLevel != 0) :
	?>
<ul class="list-striped list-condensed">
	<?php foreach ($this->children[$this->category->id] as $id => $child) : ?>
	<?php
	if ($this->params->get('show_empty_categories') || $child->numitems || count($child->getChildren())) :
		if (!isset($this->children[$this->category->id][$id + 1]))
		{
			$class = ' class="last"';
		}
		?>
        <li<?php echo $class; ?>>
			<?php $class = ''; ?>
            <h4 class="item-title">
                <a href="<?php echo JRoute::_(ChurchDirectoryHelperRoute::getCategoryRoute($child->id)); ?>">
					<?php echo $this->escape($child->title); ?>
                </a>

				<?php if ($this->params->get('show_cat_items') == 1) : ?>
                <span class="badge badge-info pull-right"
                      title="<?php echo JText::_('COM_CONTACT_CAT_NUM'); ?>"><?php echo $child->numitems; ?></span>
				<?php endif; ?>
            </h4>

			<?php if ($this->params->get('show_subcat_desc') == 1) : ?>
			<?php if ($child->description) : ?>
                <small class="category-desc">
					<?php echo JHtml::_('content.prepare', $child->description, '', 'com_churchdirectoy.category'); ?>
                </small>
				<?php endif; ?>
	/**
	 * Prepares the document
	 *
	 * @return void
	 *
	 * @since       1.7.2
	 */
	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_CHURCHDIRECTORY_DEFAULT_PAGE_TITLE'));
		}

		$title = $this->params->get('page_title', '');

		$id = (int) @$menu->query['id'];

		// If the menu item does not concern this contact
		if ($menu && ($menu->query['option'] != 'com_churchdirectory' || $menu->query['view'] != 'member' || $id != $this->item->id))
		{
			// If this is not a single churchdirectory menu item, set the page title to the contact title
			if ($this->item->name)
			{
				$title = $this->item->name;
			}

			$path     = [['title' => $this->member->name, 'link' => '']];
			$category = JCategories::getInstance('ChurchDirectory')->get($this->member->catid);

			while ($category && ($menu->query['option'] != 'com_churchdirectory'
					|| $menu->query['view'] == 'member'
					|| $id != $category->id) && $category->id > 1)
			{
				$path[]   = ['title' => $category->title, 'link' => ChurchDirectoryHelperRoute::getCategoryRoute($this->member->catid)];
				$category = $category->getParent();
			}

			$path = array_reverse($path);

			foreach ($path as $item)
			{
				$pathway->addItem($item['title'], $item['link']);
			}
		}

		if (empty($title))
		{
			$title = $app->get('sitename');
		}
		elseif ($app->get('sitename_pagetitles', 0) == 1)
		{
			$title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title);
		}
		elseif ($app->get('sitename_pagetitles', 0) == 2)
		{
			$title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename'));
		}

		if (empty($title))
		{
			$title = $this->item->name;
		}

		$this->document->setTitle($title);

		if ($this->item->metadesc)
		{
			$this->document->setDescription($this->item->metadesc);
		}
		elseif (!$this->item->metadesc && $this->params->get('menu-meta_description'))
		{
			$this->document->setDescription($this->params->get('menu-meta_description'));
		}

		if ($this->item->metakey)
		{
			$this->document->setMetadata('keywords', $this->item->metakey);
		}
		elseif (!$this->item->metakey && $this->params->get('menu-meta_keywords'))
		{
			$this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
		}

		if ($this->params->get('robots'))
		{
			$this->document->setMetadata('robots', $this->params->get('robots'));
		}

		$mdata = $this->item->metadata->toArray();

		foreach ($mdata as $k => $v)
		{
			if ($v)
			{
				$this->document->setMetadata($k, $v);
			}
		}
	}