PageRenderTime 22ms CodeModel.GetById 19ms app.highlight 2ms RepoModel.GetById 0ms app.codeStats 0ms

/administrator/components/com_languages/helpers/multilangstatus.php

https://bitbucket.org/eternaware/joomus
PHP | 132 lines | 99 code | 11 blank | 22 comment | 0 complexity | eb4b5f343e198c499933d04e901fdeb8 MD5 | raw file
Possible License(s): LGPL-2.1
  1<?php
  2/**
  3 * @package     Joomla.Administrator
  4 * @subpackage  com_languages
  5 *
  6 * @copyright   Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
  7 * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8 */
  9
 10defined('_JEXEC') or die;
 11
 12/**
 13 * Multilang status helper.
 14 *
 15 * @package     Joomla.Administrator
 16 * @subpackage  com_languages
 17 * @since       1.7.1
 18 */
 19abstract class multilangstatusHelper
 20{
 21	public static function getHomes()
 22	{
 23		// Check for multiple Home pages
 24		$db		= JFactory::getDBO();
 25		$query	= $db->getQuery(true);
 26		$query->select('COUNT(*)');
 27		$query->from($db->quoteName('#__menu'));
 28		$query->where('home = 1');
 29		$query->where('published = 1');
 30		$query->where('client_id = 0');
 31		$db->setQuery($query);
 32		return $db->loadResult();
 33	}
 34
 35	public static function getLangswitchers()
 36	{
 37		// Check if switcher is published
 38		$db			= JFactory::getDBO();
 39		$query		= $db->getQuery(true);
 40		$query->select('COUNT(*)');
 41		$query->from($db->quoteName('#__modules'));
 42		$query->where('module = ' . $db->quote('mod_languages'));
 43		$query->where('published = 1');
 44		$query->where('client_id = 0');
 45		$db->setQuery($query);
 46		return $db->loadResult();
 47	}
 48
 49	public static function getContentlangs()
 50	{
 51		// Check for published Content Languages
 52		$db		= JFactory::getDBO();
 53		$query	= $db->getQuery(true);
 54		$query->select('a.lang_code AS lang_code');
 55		$query->select('a.published AS published');
 56		$query->from('#__languages AS a');
 57		$db->setQuery($query);
 58		return $db->loadObjectList();
 59	}
 60
 61	public static function getSitelangs()
 62	{
 63		// check for published Site Languages
 64		$db		= JFactory::getDBO();
 65		$query	= $db->getQuery(true);
 66		$query->select('a.element AS element');
 67		$query->from('#__extensions AS a');
 68		$query->where('a.type = '.$db->Quote('language'));
 69		$query->where('a.client_id = 0');
 70		$db->setQuery($query);
 71		return $db->loadObjectList('element');
 72	}
 73
 74	public static function getHomepages()
 75	{
 76		// Check for Home pages languages
 77		$db		= JFactory::getDBO();
 78		$query	= $db->getQuery(true);
 79		$query->select('language');
 80		$query->from($db->quoteName('#__menu'));
 81		$query->where('home = 1');
 82		$query->where('published = 1');
 83		$query->where('client_id = 0');
 84		$db->setQuery($query);
 85		return $db->loadObjectList('language');
 86	}
 87
 88	public static function getStatus()
 89	{
 90		//check for combined status
 91		$db		= JFactory::getDBO();
 92		$query	= $db->getQuery(true);
 93
 94		// Select all fields from the languages table.
 95		$query->select('a.*', 'l.home');
 96		$query->select('a.published AS published');
 97		$query->select('a.lang_code AS lang_code');
 98		$query->from('#__languages AS a');
 99
100		// Select the language home pages
101		$query->select('l.home AS home');
102		$query->select('l.language AS home_language');
103		$query->join('LEFT', '#__menu  AS l  ON  l.language = a.lang_code AND l.home=1  AND l.language <> \'*\'');
104		$query->select('e.enabled AS enabled');
105		$query->select('e.element AS element');
106		$query->join('LEFT', '#__extensions  AS e ON e.element = a.lang_code');
107		$query->where('e.client_id = 0');
108		$query->where('e.enabled = 1');
109		$query->where('e.state = 0');
110
111		$db->setQuery($query);
112		return $db->loadObjectList();
113	}
114
115	public static function getContacts()
116	{
117		$db = JFactory::getDBO();
118		$query = $db->getQuery(true);
119		$query->select('u.name, count(cd.language) as counted, MAX(cd.language='.$db->quote('*').') as all_languages');
120		$query->from('#__users AS u');
121		$query->leftJOIN('#__contact_details AS cd ON cd.user_id=u.id');
122		$query->leftJOIN('#__languages as l on cd.language=l.lang_code');
123		$query->where('EXISTS (SELECT * from #__content as c where  c.created_by=u.id)');
124		$query->where('(l.published=1 or cd.language='.$db->quote('*').')');
125		$query->where('cd.published=1');
126		$query->group('u.id');
127		$query->having('(counted !=' . count(JLanguageHelper::getLanguages()).' OR all_languages=1)');
128		$query->having('(counted !=1 OR all_languages=0)');
129		$db->setQuery($query);
130		return $db->loadObjectList();
131	}
132}