Exemple #1
0
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
// no direct access
defined('_JEXEC') or die('Restricted access');
if (!file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'load.php')) {
    JError::raiseError(500, JText::_(''));
}
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'load.php';
$context = JeproshopContext::getContext();
/** initialize the shop **/
$context->shop = JeproshopShopModelShop::initialize();
/** load configuration  */
JeproshopSettingModelSetting::loadSettings();
/** load languages  */
JeproshopLanguageModelLanguage::loadLanguages();
/** set context cookie */
$life_time = time() + max(JeproshopSettingModelSetting::getValue('bo_life_time'), 1) * 3600;
$context->cookie = new JeproshopCookie('jeproshop_site', '', $life_time);
/** @var  employee */
$context->employee = new JeproshopEmployeeModelEmployee(JFactory::getUser()->id);
$context->cookie->employee_id = $context->employee->employee_id;
/** Loading default country */
$context->country = new JeproshopCountryModelCountry(JeproshopSettingModelSetting::getValue('default_country'), JeproshopSettingModelSetting::getValue('default_lang'));
/** if the cookie stored language is not an available language, use default language */
if (isset($context->cookie->lang_id) && $context->cookie->lang_id) {
    $language = new JeproshopLanguageModelLanguage($context->cookie->lang_id);
}
if (!isset($language) || !JeproshopTools::isLoadedObject($language, 'lang_id')) {
    $language = new JeproshopLanguageModelLanguage(JeproshopSettingModelSetting::getValue('default_lang'));
}
Exemple #2
0
 /**
  * Return available languages
  *
  * @param bool $published
  * @param bool $shop_id
  * @return array Languages
  */
 public static function getLanguages($published = true, $shop_id = false)
 {
     if (!self::$_LANGUAGES) {
         JeproshopLanguageModelLanguage::loadLanguages();
     }
     $default_language = JFactory::getLanguage();
     $languages = array();
     foreach (self::$_LANGUAGES as $language) {
         if ($published && !$language->published || $shop_id && !isset($language->shops[(int) $shop_id])) {
             continue;
         }
         if ($default_language->getTag() == $language->language_code) {
             $language->is_default = 1;
         }
         $languages[] = $language;
     }
     return $languages;
 }