Ejemplo n.º 1
0
 function load($id = null)
 {
     parent::load($id);
     jimport('joomla.html.parameter');
     $params = new JParameter($this->settings);
     $this->settings = $params->toArray();
 }
Ejemplo n.º 2
0
    public function getList()
    {
        if (!isset($this->_list))
        {
            $rowset = KFactory::get('com://admin/settings.database.rowset.settings');
            
            //Insert the system configuration settings
            $rowset->insert(KFactory::get('com://admin/settings.database.row.system'));
                        
            //Insert the component configuration settings
            $components = KFactory::get('com://admin/extensions.model.components')->enabled(1)->parent(0)->getList();
            
            foreach($components as $component)
            {
                $path   = JPATH_ADMINISTRATOR.'/components/'.$component->option.'/config.xml';
                $params = new JParameter( $component->params);
                    
                $config = array(
                	'name' => strtolower(substr($component->option, 4)),
                    'path' => file_exists($path) ? $path : '',
                    'id'   => $component->id,
                    'data' => $params->toArray(),
                );
                
                $row = KFactory::get('com://admin/settings.database.row.component', $config);
                
                $rowset->insert($row);
            }
             
            $this->_list = $rowset;
        }

        return $this->_list;    
    }
 /**
  * Up
  **/
 public function up()
 {
     $query = "CREATE TABLE IF NOT EXISTS `jos_announcements` (\n\t\t\t\t\t\t`id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t`scope` varchar(100) DEFAULT NULL,\n\t\t\t\t\t\t`scope_id` int(11) DEFAULT NULL,\n\t\t\t\t\t\t`content` text,\n\t\t\t\t\t\t`priority` tinyint(2) NOT NULL DEFAULT '0',\n\t\t\t\t\t\t`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\t\t\t\t`created_by` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t\t\t`state` tinyint(2) NOT NULL DEFAULT '0',\n\t\t\t\t\t\t`publish_up` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\t\t\t\t`publish_down` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\t\t\t\t`sticky` tinyint(2) NOT NULL DEFAULT '0',\n\t\t\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
     $this->db->setQuery($query);
     $this->db->query();
     $params = array('plugin_access' => 'members', 'display_tab' => 1);
     $this->addPluginEntry('groups', 'announcements', 1, $params);
     //get citation params
     if ($this->db->tableExists('#__extensions')) {
         $sql = "SELECT `params` FROM `#__extensions` WHERE `type`='plugin' AND `element`='messages' AND `folder` = 'groups'";
     } else {
         $sql = "SELECT `params` FROM `#__plugins` WHERE `element`='messages' AND `folder`='groups'";
     }
     $this->db->setQuery($sql);
     $p = $this->db->loadResult();
     //load params object
     $params = new \JParameter($p);
     //set param to hide messages tab
     $params->set('display_tab', 0);
     //save new params
     if ($this->db->tableExists('#__extensions')) {
         $query = "UPDATE `#__extensions` SET `params`=" . $this->db->quote(json_encode($params->toArray())) . " WHERE `element`='messages' AND `folder`='groups'";
     } else {
         $query = "UPDATE `#__plugins` SET `params`='" . $params->toString() . "' WHERE `element`='messages' AND `folder`='groups'";
     }
     $this->db->setQuery($query);
     $this->db->query();
 }
Ejemplo n.º 4
0
 /**
  * Initializes the default configuration for the object.
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param KConfig $config An optional KConfig object with configuration options.
  */
 protected function _initialize(KConfig $config)
 {
     $params = '';
     if (is_readable($file = JPATH_THEMES . '/' . $this->getIdentifier()->package . '/params.ini')) {
         $params = file_get_contents($file);
     }
     $params = new JParameter($params);
     $config->append(array('mimetype' => 'text/html', 'params' => $params->toArray(), 'template_filters' => array('shorttag', 'html', 'alias')));
     parent::_initialize($config);
 }
Ejemplo n.º 5
0
 public static function &getExtensions()
 {
     static $list;
     jimport('joomla.html.parameter');
     if ($list != null) {
         return $list;
     }
     $db = JFactory::getDBO();
     $list = array();
     // Get the menu items as a tree.
     $query = $db->getQuery(true);
     $query->select('*');
     $query->from('#__extensions AS n');
     $query->where('n.folder = \'xmap\'');
     $query->where('n.enabled = 1');
     // Get the list of menu items.
     $db->setQuery($query);
     $extensions = $db->loadObjectList('element');
     foreach ($extensions as $element => $extension) {
         require_once JPATH_PLUGINS . DS . $extension->folder . DS . $element . DS . $element . '.php';
         //$xmlPath = JPATH_COMPONENT_ADMINISTRATOR . DS . 'extensions' . DS . $extension->folder . DS . $element . '.xml';
         //$params = new JParameter($extension->params, $xmlPath);
         $params = new JParameter($extension->params);
         $extension->params = $params->toArray();
         $list[$element] = $extension;
     }
     return $list;
 }
Ejemplo n.º 6
0
 public static function preload()
 {
     // Don't preload anything if this is the API
     if (MageBridge::isApiPage() == true) {
         return null;
     }
     // Don't preload anything if the current output contains only the component-area
     if (in_array(JRequest::getCmd('tmpl'), array('component', 'raw'))) {
         return null;
     }
     // Fetch all the current modules
     $modules = MageBridgeModuleHelper::load();
     $register = MageBridgeModelRegister::getInstance();
     // Loop through all the available Joomla! modules
     if (!empty($modules)) {
         foreach ($modules as $module) {
             // Check the name to see if this is a MageBridge-related module
             if (preg_match('/^mod_magebridge_/', $module->module)) {
                 // Initialize variables
                 $type = null;
                 $name = null;
                 jimport('joomla.html.parameter');
                 $params = new JParameter($module->params);
                 $conf = JFactory::getConfig();
                 $user = JFactory::getUser();
                 // Check whether caching returns a valid module-output
                 if ($params->get('cache', 0) && $conf->getValue('config.caching')) {
                     $cache = JFactory::getCache($module->module);
                     $cache->setLifeTime($params->get('cache_time', $conf->getValue('config.cachetime') * 60));
                     $contents = $cache->get(array('JModuleHelper', 'renderModule'), array($module, $params->toArray()), $module->id . $user->get('aid', 0));
                     // If the contents are not empty, there is a cached version so we skip this
                     if (!empty($contents)) {
                         continue;
                     }
                     // If the contents are empty, make sure we have a fresh start
                     // @todo: Why was this needed? This causes under certain circumstances numerous bridge-calls which is bad.
                     //if (empty($contents)) {
                     //    $cache->clean();
                     //}
                 }
                 // If the layout is AJAX-ified, do not fetch the block at all
                 if ($params->get('layout') == 'ajax') {
                     continue;
                 }
                 // Try to include the helper-file
                 if (is_file(JPATH_SITE . '/modules/' . $module->module . '/helper.php')) {
                     $module_file = JPATH_SITE . '/modules/' . $module->module . '/helper.php';
                 } else {
                     if (is_file(JPATH_ADMINISTRATOR . '/modules/' . $module->module . '/helper.php')) {
                         $module_file = JPATH_ADMINISTRATOR . '/modules/' . $module->module . '/helper.php';
                     }
                 }
                 // If there is a module-file, include it
                 if (!empty($module_file) && is_file($module_file)) {
                     require_once $module_file;
                     // Construct and detect the module-class
                     $class = preg_replace('/_([a-z]{1})/', '\\1', $module->module) . 'Helper';
                     if (class_exists($class)) {
                         // Instantiate the class and check for the "register" method
                         $o = new $class();
                         if (method_exists($o, 'register')) {
                             // Fetch the requested tasks
                             $requests = $o->register($params);
                             if (is_array($requests) && count($requests) > 0) {
                                 foreach ($requests as $request) {
                                     // Add each requested task to the MageBridge register
                                     if (!empty($request[2])) {
                                         $register->add($request[0], $request[1], $request[2]);
                                     } else {
                                         if (!empty($request[1])) {
                                             $register->add($request[0], $request[1]);
                                         } else {
                                             $register->add($request[0]);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 7
0
$uri = str_replace(DS, "/", str_replace(JPATH_SITE, JURI::base(), dirname(__FILE__)));
$uri = str_replace("/administrator", "", $uri);
$template = $obj->template;
$name = 'pages_profile';
$profiles = $obj->getProfiles();
$pageids = $obj->getPageIds($name);
$langlist = $obj->getLanguageList();
jimport('joomla.filesystem.file');
$jsonData = $profiles;
$configfile = dirname(__FILE__) . DS . 'config.xml';
if (file_exists($configfile)) {
    /* For General Tab */
    $generalconfig = $obj->getGeneralConfig();
    $configform = JForm::getInstance('general', $configfile, array('control' => 'jform'));
    $params = new JParameter($generalconfig);
    $jsonData['generalconfigdata'] = $params->toArray();
    $jsonData['generalconfigdata'][$name] = str_replace("\n", "\\\\n", $params->get($name, ''));
    $arr_values = array();
    $value = $params->get($name, '');
    $assignedMenus = $obj->getAssignedMenu();
    if ($value) {
        $arr_values_tmp = explode("\n", $value);
        foreach ($arr_values_tmp as $k => $v) {
            if ($v) {
                // Separate data of row
                $row = explode('=', $v);
                // Get pages & language
                $tmp = explode(',', $row[0]);
                $pages = array();
                $language = 'All';
                foreach ($tmp as $t) {
Ejemplo n.º 8
0
 protected function _updateMijosef()
 {
     if (empty($this->_current_version)) {
         return;
     }
     if ($this->_current_version = '1.0.0') {
         $db = JFactory::getDBO();
         jimport('joomla.html.parameter');
         $db->setQuery('SELECT params FROM #__extensions WHERE element = "com_mijosef" AND type = "component"');
         $o_c = $db->loadResult();
         $o_p = new JParameter($o_c);
         $reg = new JRegistry($o_p->toArray());
         $config = $reg->toString();
         $db->setQuery('UPDATE #__extensions SET params = ' . $db->Quote($config) . ' WHERE element = "com_mijosef" AND type = "component"');
         $db->query();
         $db->setQuery('SELECT id, params FROM #__mijosef_extensions');
         $o_exts = $db->loadObjectList();
         if (empty($o_exts)) {
             return;
         }
         foreach ($o_exts as $o_ext) {
             $ext_p = new JParameter($o_ext->params);
             $reg = new JRegistry($ext_p->toArray());
             $params = $reg->toString();
             $db = JFactory::getDBO();
             $db->setQuery('UPDATE #__mijosef_extensions SET params = ' . $db->Quote($params) . ' WHERE id=' . $o_ext->id);
             $db->query();
         }
         $db->setQuery('SELECT id, params FROM #__mijosef_urls');
         $o_urls = $db->loadObjectList();
         if (empty($o_urls)) {
             return;
         }
         foreach ($o_urls as $o_url) {
             $url_p = new JParameter($o_url->params);
             $reg = new JRegistry($url_p->toArray());
             $params = $reg->toString();
             $db = JFactory::getDBO();
             $db->setQuery('UPDATE #__mijosef_urls SET params = ' . $db->Quote($params) . ' WHERE id=' . $o_url->id);
             $db->query();
         }
         return;
     }
 }
 function fetchElement($name, $value, &$node, $control_name)
 {
     if (!defined('japaramhelper2')) {
         $uri = str_replace(DS, "/", str_replace(JPATH_SITE, JURI::base(), dirname(__FILE__)));
         $uri = str_replace("/administrator", "", $uri);
         JHTML::stylesheet('japaramhelper2.css', $uri . "/assets/css/");
         JHTML::script('japaramhelper2.js', $uri . "/assets/js/");
         jimport('joomla.filesystem.folder');
         jimport('joomla.filesystem.file');
         define('japaramhelper2', true);
     }
     $jsonData = array();
     $folder_profiles = array();
     /* Get all profiles name folder from folder profiles */
     $profiles = array();
     $jsonData = array();
     $jsonTempData = array();
     // get in template
     $template = $this->get_active_template();
     $path = JPATH_SITE . DS . 'templates' . DS . $template . DS . 'html' . DS . 'mod_janewspro';
     if (JFolder::exists($path)) {
         $files = JFolder::files($path, '.ini');
         if ($files) {
             foreach ($files as $fname) {
                 $fname = substr($fname, 0, -4);
                 $f = new stdClass();
                 $f->id = $fname;
                 $f->title = $fname;
                 $profiles[$fname] = $f;
                 $params = new JParameter(JFile::read($path . DS . $fname . '.ini'));
                 $jsonData[$fname] = $params->toArray();
                 $jsonTempData[$fname] = $jsonData[$fname];
             }
         }
     }
     // get in module
     $path = JPATH_SITE . DS . 'modules' . DS . 'mod_janewspro' . DS . 'profiles';
     if (!JFolder::exists($path)) {
         return JText::_('Profiles Folder not exist');
     }
     $files = JFolder::files($path, '.ini');
     if ($files) {
         foreach ($files as $fname) {
             $fname = substr($fname, 0, -4);
             $f = new stdClass();
             $f->id = $fname;
             $f->title = $fname;
             $profiles[$fname] = $f;
             $params = new JParameter(JFile::read($path . DS . $fname . '.ini'));
             $jsonData[$fname] = $params->toArray();
         }
     }
     $HTML_Profile = JHTML::_('select.genericlist', $profiles, '' . $control_name . '[' . $name . ']', 'style="width:150px;" onchange="japarams2.changeProfile(this.value)"', 'id', 'title', $value);
     $xml_profile = JPATH_SITE . DS . 'modules' . DS . 'mod_janewspro' . DS . 'admin' . DS . 'config.xml';
     if (file_exists($xml_profile)) {
         /* For General Tab */
         $paramsForm = new JParameter('', $xml_profile, 'template');
     }
     $_body = JResponse::getBody();
     ob_start();
     require_once dirname(__FILE__) . DS . 'tpl.php';
     $content = ob_get_clean();
     JResponse::setBody($_body);
     return $HTML_Profile . $content;
 }
Ejemplo n.º 10
0
    function _discoverJFLanguage()
    {
        static $discovered;
        if (isset($discovered) && $discovered) {
            return;
        }
        $discovered = true;
        $registry = JFactory::getConfig();
        // Find language without loading strings
        $locale = $registry->getValue('config.language');
        // Attention - we need to access the site default values
        // #12943 explains that a user might overwrite the orignial settings based on his own profile
        $langparams = JComponentHelper::getParams('com_languages');
        $defLanguage = $langparams->get("site");
        $registry->setValue("config.defaultlang", isset($defLanguage) && $defLanguage != '' ? $defLanguage : $locale);
        // get params from registry in case function called statically
        $params = $registry->getValue("jfrouter.params");
        $determitLanguage = $params->get('determitLanguage', 1);
        $newVisitorAction = $params->get('newVisitorAction', 'browser');
        $use302redirect = $params->get('use302redirect', 0);
        $enableCookie = $params->get('enableCookie', 1);
        // get instance of JoomFishManager to obtain active language list and config values
        $jfm = JoomFishManager::getInstance();
        $client_lang = '';
        $lang_known = false;
        $jfcookie = JRequest::getVar('jfcookie', null, "COOKIE");
        if (isset($jfcookie["lang"]) && $jfcookie["lang"] != "") {
            $client_lang = $jfcookie["lang"];
            $lang_known = true;
        }
        $uri = JURI::getInstance();
        if ($requestlang = JRequest::getVar('lang', null, "REQUEST")) {
            if ($requestlang != '') {
                $client_lang = $requestlang;
                $lang_known = true;
            }
        }
        // no language choosen - Test plugin e.g. IP lookup tool
        if (!$lang_known) {
            // setup Joomfish pluginds
            $dispatcher = JDispatcher::getInstance();
            $iplang = "";
            JPluginHelper::importPlugin('joomfish');
            $dispatcher->trigger('onDiscoverLanguage', array(&$iplang));
            if ($iplang != "") {
                $client_lang = $iplang;
                $lang_known = true;
            }
        }
        if (!$lang_known && $determitLanguage && key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER) && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
            switch ($newVisitorAction) {
                // usesing the first defined Joom!Fish language
                case 'joomfish':
                    $activeLanguages = $jfm->getActiveLanguages();
                    reset($activeLanguages);
                    $first = key($activeLanguages);
                    $client_lang = $activeLanguages[$first]->getLanguageCode();
                    break;
                case 'site':
                    // We accept that this default locale might be overwritten by user settings!
                    $jfLang = TableJFLanguage::createByJoomla($locale);
                    $client_lang = $jfLang->getLanguageCode();
                    break;
                    // no language chooses - assume from browser configuration
                // no language chooses - assume from browser configuration
                case 'browser':
                default:
                    // language negotiation by Kochin Chang, June 16, 2004
                    // retrieve active languages from database
                    $active_iso = array();
                    $active_isocountry = array();
                    $active_code = array();
                    $activeLanguages = $jfm->getActiveLanguages();
                    if (count($activeLanguages) == 0) {
                        return;
                    }
                    foreach ($activeLanguages as $alang) {
                        $active_iso[] = $alang->iso;
                        if (preg_match('/[_-]/i', $alang->iso)) {
                            $isocountry = preg_split('[_-]', $alang->iso);
                            $active_isocountry[] = $isocountry[0];
                        }
                        $active_code[] = $alang->shortcode;
                    }
                    // figure out which language to use - browser languages are based on ISO codes
                    $browserLang = explode(',', $_SERVER["HTTP_ACCEPT_LANGUAGE"]);
                    foreach ($browserLang as $blang) {
                        if (in_array($blang, $active_iso)) {
                            $client_lang = $blang;
                            break;
                        }
                        $shortLang = substr($blang, 0, 2);
                        if (in_array($shortLang, $active_isocountry)) {
                            $client_lang = $shortLang;
                            break;
                        }
                        // compare with code
                        if (in_array($shortLang, $active_code)) {
                            $client_lang = $shortLang;
                            break;
                        }
                    }
                    break;
            }
        }
        // get the name of the language file for joomla
        $jfLang = TableJFLanguage::createByShortcode($client_lang, false);
        if ($jfLang === null && $client_lang != "") {
            $jfLang = TableJFLanguage::createByISO($client_lang, false);
        } else {
            if ($jfLang === null) {
                $jfLang = TableJFLanguage::createByJoomla($locale);
            }
        }
        if (!$lang_known && $use302redirect) {
            // using a 302 redirect means that we do not change the language on the fly the first time, but with a clean reload of the page
            $href = "index.php";
            $hrefVars = '';
            $queryString = JRequest::getVar('QUERY_STRING', null, "SERVER");
            if (!empty($queryString)) {
                $vars = explode("&", $queryString);
                if (count($vars) > 0 && $queryString) {
                    foreach ($vars as $var) {
                        if (preg_match('/=/i', $var)) {
                            list($key, $value) = explode("=", $var);
                            if ($key != "lang") {
                                if ($hrefVars != "") {
                                    $hrefVars .= "&";
                                }
                                // ignore mosmsg to ensure it is visible in frontend
                                if ($key != 'mosmsg') {
                                    $hrefVars .= "{$key}={$value}";
                                }
                            }
                        }
                    }
                }
            }
            // Add the existing variables
            if ($hrefVars != "") {
                $href .= '?' . $hrefVars;
            }
            if ($jfLang->getLanguageCode() != null) {
                $ulang = 'lang=' . $jfLang->getLanguageCode();
            } else {
                // it's important that we add at least the basic parameter - as of the sef is adding the actual otherwise!
                $ulang = 'lang=';
            }
            // if there are other vars we need to add a & otherwiese ?
            if ($hrefVars == '') {
                $href .= '?' . $ulang;
            } else {
                $href .= '&' . $ulang;
            }
            $registry->setValue("config.multilingual_support", true);
            global $mainframe;
            $mainframe->setUserState('application.lang', $jfLang->code);
            $registry->setValue("config.jflang", $jfLang->code);
            $registry->setValue("config.lang_site", $jfLang->code);
            $registry->setValue("config.language", $jfLang->code);
            $registry->setValue("joomfish.language", $jfLang);
            $href = JRoute::_($href, false);
            header('HTTP/1.1 303 See Other');
            header("Location: " . $href);
            exit;
        }
        if (isset($jfLang) && $jfLang->code != "" && ($jfLang->active || $jfm->getCfg("frontEndPreview"))) {
            $locale = $jfLang->code;
        } else {
            $jfLang = TableJFLanguage::createByJoomla($locale);
            if (!$jfLang->active) {
                ?>
			<div style="background-color: #c00; color: #fff">
				<p style="font-size: 1.5em; font-weight: bold; padding: 10px 0px 10px 0px; text-align: center; font-family: Arial, Helvetica, sans-serif;">
				Joom!Fish config error: Default language is inactive!<br />&nbsp;<br />
				Please check configuration, try to use first active language</p>
			</div>
			<?php 
                $activeLanguages = $jfm->getActiveLanguages();
                if (count($activeLanguages) > 0) {
                    $jfLang = $activeLanguages[0];
                    $locale = $jfLang->code;
                } else {
                    // No active language defined - using system default is only alternative!
                }
            }
            $client_lang = $jfLang->shortcode != '' ? $jfLang->shortcode : $jfLang->iso;
        }
        // TODO set the cookie domain so that it works for all subdomains
        if ($enableCookie) {
            setcookie("lang", "", time() - 1800, "/");
            setcookie("jfcookie", "", time() - 1800, "/");
            setcookie("jfcookie[lang]", $client_lang, time() + 24 * 3600, '/');
        }
        if (defined("_JLEGACY")) {
            $GLOBALS['iso_client_lang'] = $client_lang;
            $GLOBALS['mosConfig_lang'] = $jfLang->code;
        }
        $registry->setValue("config.multilingual_support", true);
        global $mainframe;
        $mainframe->setUserState('application.lang', $jfLang->code);
        $registry->setValue("config.jflang", $jfLang->code);
        $registry->setValue("config.lang_site", $jfLang->code);
        $registry->setValue("config.language", $jfLang->code);
        $registry->setValue("joomfish.language", $jfLang);
        // Force factory static instance to be updated if necessary
        $lang =& JFactory::getLanguage();
        if ($jfLang->code != $lang->getTag()) {
            // Must not assign by reference in order to overwrite the existing reference to the static instance of the language
            $lang = JFactory::_createLanguage();
            $lang->setDefault($jfLang->code);
            $lang->_metadata = array();
            $lang->_metadata['tag'] = $jfLang->code;
            $lang->_metadata['rtl'] = false;
        }
        // no need to set locale for this ISO code its done by JLanguage
        // overwrite with the valued from $jfLang
        $jfparams = JComponentHelper::getParams("com_joomfish");
        $overwriteGlobalConfig = $jfparams->get('overwriteGlobalConfig', 0);
        if ($overwriteGlobalConfig) {
            // We should overwrite additional global variables based on the language parameter configuration
            $params = new JParameter($jfLang->params);
            $paramarray = $params->toArray();
            foreach ($paramarray as $key => $val) {
                if (trim($val) !== '') {
                    $registry->setValue("config." . $key, $val);
                }
                if (defined("_JLEGACY")) {
                    $name = 'mosConfig_' . $key;
                    $GLOBALS[$name] = $val;
                }
            }
        }
    }
Ejemplo n.º 11
0
 function getProfiles()
 {
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     $profiles = array();
     $file_profiles = array();
     $arr_folder = array('core', 'local');
     foreach ($arr_folder as $folder) {
         $path = JPATH_SITE . DS . 'templates' . DS . $this->template . DS . $folder . DS . 'etc' . DS . 'profiles';
         if (!JFolder::exists($path)) {
             JFolder::create($path);
             $content = '';
             JFile::write($path . DS . 'index.html', $content);
         }
         $files = @JFolder::files($path, '\\.ini');
         if ($files) {
             foreach ($files as $f) {
                 $file_profiles[$f] = $path . DS . $f;
             }
         }
     }
     if ($file_profiles) {
         foreach ($file_profiles as $name => $p) {
             $dparams = array();
             if ($name == 'default.ini') {
                 $xmlpath = JPATH_SITE . DS . 'templates' . DS . $this->template . DS . 'templateDetails.xml';
                 $xml =& JFactory::getXMLParser('Simple');
                 if ($xml->loadFile($xmlpath)) {
                     if ($params =& $xml->document->params) {
                         foreach ($params as $param) {
                             foreach ($param->children() as $p) {
                                 if ($p->attributes('name') && isset($p->_attributes['default'])) {
                                     $dparams[$p->attributes('name')] = $p->attributes('default');
                                 }
                             }
                         }
                     }
                 }
             }
             $profile = new stdclass();
             $path = 'etc' . DS . 'profiles' . DS . $name;
             $file = JPATH_SITE . DS . 'templates' . DS . $this->template . DS . 'local' . DS . $path;
             $profile->local = null;
             if (JFile::exists($file)) {
                 $params = new JParameter(JFile::read($file));
                 $profile->local = array_merge($dparams, $params->toArray());
             }
             $file = JPATH_SITE . DS . 'templates' . DS . $this->template . DS . 'core' . DS . $path;
             $profile->core = null;
             if (JFile::exists($file)) {
                 $params = new JParameter(JFile::read($file));
                 $profile->core = array_merge($dparams, $params->toArray());
             }
             $profiles[strtolower(substr($name, 0, -4))] = $profile;
         }
     }
     if (!$profiles) {
         $profile = new stdclass();
         $profile->core = '  ';
         $profile->local = null;
         $profiles['default'] = $profile;
     }
     return $profiles;
 }
Ejemplo n.º 12
0
 function install($theme)
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDBO();
     $package = $this->_getPackageFromUpload();
     if (!$package) {
         JError::raiseWarning(1, JText::_('COM_PHOCAGALLERY_ERROR_FIND_INSTALL_PACKAGE'));
         $this->deleteTempFiles();
         return false;
     }
     if ($package['dir'] && JFolder::exists($package['dir'])) {
         $this->setPath('source', $package['dir']);
     } else {
         JError::raiseWarning(1, JText::_('COM_PHOCAGALLERY_ERROR_INSTALL_PATH_NOT_EXISTS'));
         $this->deleteTempFiles();
         return false;
     }
     // We need to find the installation manifest file
     if (!$this->_findManifest()) {
         JError::raiseWarning(1, JText::_('COM_PHOCAGALLERY_ERROR_FIND_INFO_INSTALL_PACKAGE'));
         $this->deleteTempFiles();
         return false;
     }
     // Files - copy files in manifest
     foreach ($this->_manifest->children() as $child) {
         if (is_a($child, 'JXMLElement') && $child->name() == 'files') {
             if ($this->parseFiles($child) === false) {
                 JError::raiseWarning(1, JText::_('COM_PHOCAGALLERY_ERROR_FIND_INFO_INSTALL_PACKAGE'));
                 $this->deleteTempFiles();
                 return false;
             }
         }
     }
     // File - copy the xml file
     $copyFile = array();
     $path['src'] = $this->getPath('manifest');
     // XML file will be copied too
     $path['dest'] = JPATH_SITE . DS . 'media' . DS . 'com_phocagallery' . DS . 'images' . DS . basename($this->getPath('manifest'));
     $copyFile[] = $path;
     $this->copyFiles($copyFile, array());
     $this->deleteTempFiles();
     // -------------------
     // Themes
     // -------------------
     // Params -  Get new themes params
     $paramsThemes = $this->getParamsThemes();
     // -------------------
     // Component
     // -------------------
     if (isset($theme['component']) && $theme['component'] == 1) {
         $component = 'com_phocagallery';
         $paramsC = JComponentHelper::getParams($component);
         foreach ($paramsThemes as $keyT => $valueT) {
             $paramsC->set($valueT['name'], $valueT['value']);
         }
         $data['params'] = $paramsC->toArray();
         $table = JTable::getInstance('extension');
         $idCom = $table->find(array('element' => $component));
         $table->load($idCom);
         if (!$table->bind($data)) {
             JError::raiseWarning(500, 'Not a valid component');
             return false;
         }
         // pre-save checks
         if (!$table->check()) {
             JError::raiseWarning(500, $table->getError('Check Problem'));
             return false;
         }
         // save the changes
         if (!$table->store()) {
             JError::raiseWarning(500, $table->getError('Store Problem'));
             return false;
         }
     }
     // -------------------
     // Menu Categories
     // -------------------
     if (isset($theme['categories']) && $theme['categories'] == 1) {
         $link = 'index.php?option=com_phocagallery&view=categories';
         $where = array();
         $where[] = 'link = ' . $db->Quote($link);
         $query = 'SELECT id, params FROM #__menu WHERE ' . implode(' AND ', $where);
         $db->setQuery($query);
         $itemsCat = $db->loadObjectList();
         if (!empty($itemsCat)) {
             foreach ($itemsCat as $keyIT => $valueIT) {
                 $query = 'SELECT m.params FROM #__menu AS m WHERE m.id = ' . (int) $valueIT->id;
                 $db->setQuery($query);
                 $paramsCJSON = $db->loadResult();
                 //$paramsCJSON = $valueIT->params;
                 $paramsMc = new JParameter();
                 $paramsMc->loadJSON($paramsCJSON);
                 foreach ($paramsThemes as $keyT => $valueT) {
                     $paramsMc->set($valueT['name'], $valueT['value']);
                 }
                 $dataMc['params'] = $paramsMc->toArray();
                 $table =& JTable::getInstance('menu');
                 if (!$table->load((int) $valueIT->id)) {
                     JError::raiseWarning(500, 'Not a valid table');
                     return false;
                 }
                 if (!$table->bind($dataMc)) {
                     JError::raiseWarning(500, 'Not a valid table');
                     return false;
                 }
                 // pre-save checks
                 if (!$table->check()) {
                     JError::raiseWarning(500, $table->getError('Check Problem'));
                     return false;
                 }
                 // save the changes
                 if (!$table->store()) {
                     JError::raiseWarning(500, $table->getError('Store Problem'));
                     return false;
                 }
             }
         }
     }
     // -------------------
     // Menu Category
     // -------------------
     if (isset($theme['category']) && $theme['category'] == 1) {
         // Select all categories to get possible menu links
         $query = 'SELECT c.id FROM #__phocagallery_categories AS c';
         $db->setQuery($query);
         $categoriesId = $db->loadObjectList();
         // We get id from Phoca Gallery categories and try to find menu links from these categories
         if (!empty($categoriesId)) {
             foreach ($categoriesId as $keyI => $valueI) {
                 $link = 'index.php?option=com_phocagallery&view=category&id=' . (int) $valueI->id;
                 //$link		= 'index.php?option=com_phocagallery&view=category';
                 $where = array();
                 $where[] = 'link = ' . $db->Quote($link);
                 $query = 'SELECT id, params FROM #__menu WHERE ' . implode(' AND ', $where);
                 $db->setQuery($query);
                 $itemsCat = $db->loadObjectList();
                 if (!empty($itemsCat)) {
                     foreach ($itemsCat as $keyIT2 => $valueIT2) {
                         $query = 'SELECT m.params FROM #__menu AS m WHERE m.id = ' . (int) $valueIT2->id;
                         $db->setQuery($query);
                         $paramsCtJSON = $db->loadResult();
                         //$paramsCtJSON = $valueIT2->params;
                         $paramsMct = new JParameter();
                         $paramsMct->loadJSON($paramsCtJSON);
                         foreach ($paramsThemes as $keyT => $valueT) {
                             $paramsMct->set($valueT['name'], $valueT['value']);
                         }
                         $dataMct['params'] = $paramsMct->toArray();
                         $table =& JTable::getInstance('menu');
                         if (!$table->load((int) $valueIT2->id)) {
                             JError::raiseWarning(500, 'Not a valid table');
                             return false;
                         }
                         if (!$table->bind($dataMct)) {
                             JError::raiseWarning(500, 'Not a valid table');
                             return false;
                         }
                         // pre-save checks
                         if (!$table->check()) {
                             JError::raiseWarning(500, $table->getError('Check Problem'));
                             return false;
                         }
                         // save the changes
                         if (!$table->store()) {
                             JError::raiseWarning(500, $table->getError('Store Problem'));
                             return false;
                         }
                     }
                 }
             }
         }
     }
     return true;
 }
Ejemplo n.º 13
0
 /**
  * Get all profiles
  *
  * @return array  An array of profiles
  */
 function getProfiles()
 {
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     $path = JPATH_SITE . DS . 'templates' . DS . $this->template . DS . 'etc' . DS . 'profiles';
     // Check to sure that core & local folders were remove from template.
     // If etc/$type exists, considered as core & local folders were removed
     if (@is_dir($path)) {
         if (!is_file($path . DS . 'index.html')) {
             $content = '<!DOCTYPE html><title></title>';
             JFile::write($path . DS . 'index.html', $content);
         }
         // Read custom parameters
         $dparams = array();
         $xmlpath = JPATH_SITE . DS . 'templates' . DS . $this->template . DS . 'templateDetails.xml';
         $xml =& JFactory::getXMLParser('Simple');
         if ($xml->loadFile($xmlpath)) {
             $params =& $xml->document->params;
             if ($params) {
                 foreach ($params as $param) {
                     foreach ($param->children() as $p) {
                         if ($p->attributes('name') && isset($p->_attributes['default'])) {
                             $dparams[$p->attributes('name')] = $p->attributes('default');
                         }
                     }
                 }
             }
         }
         $filelist = array();
         $profiles = array();
         // Get filename list from profiles folder
         $file_list = JFolder::files($path, '\\.ini');
         // Load profile data
         foreach ($file_list as $file) {
             // Get filename & filepath
             $filename = strtolower(substr($file, 0, -4));
             $filepath = $path . DS . $file;
             if (@file_exists($filepath)) {
                 $profile = new stdclass();
                 $profile->local = null;
                 $params = new JParameter(JFile::read($filepath));
                 // Check if it is default profile or not
                 if ($filename == 'default') {
                     $profile->core = $params->toArray();
                     // Merge custom parameters
                     $profile->local = array_merge($dparams, $params->toArray());
                 } else {
                     $profile->local = $params->toArray();
                 }
                 $profiles[$filename] = $profile;
             }
         }
         // If there isn't any profile in etc/profiles folders, create empty default profile
         if (empty($profiles) || !isset($profiles['default'])) {
             $profile = new stdclass();
             $profile->core = '  ';
             $profile->local = null;
             $profiles['default'] = $profile;
         }
     } else {
         // Maybe template still has older structure folders, so try to read core/local folder.
         $profiles = array();
         $file_profiles = array();
         $arr_folder = array('core', 'local');
         foreach ($arr_folder as $folder) {
             $path = JPATH_SITE . DS . 'templates' . DS . $this->template . DS . $folder . DS . 'etc' . DS . 'profiles';
             if (!JFolder::exists($path)) {
                 if (JFolder::create($path)) {
                     $content = '';
                     JFile::write($path . DS . 'index.html', $content);
                 }
             }
             $files = @JFolder::files($path, '\\.ini');
             if ($files) {
                 foreach ($files as $f) {
                     $file_profiles[$f] = $path . DS . $f;
                 }
             }
         }
         if ($file_profiles) {
             foreach ($file_profiles as $name => $p) {
                 $dparams = array();
                 if ($name == 'default.ini') {
                     // Read custom parameters
                     $xmlpath = JPATH_SITE . DS . 'templates' . DS . $this->template . DS . 'templateDetails.xml';
                     $xml =& JFactory::getXMLParser('Simple');
                     if ($xml->loadFile($xmlpath)) {
                         if ($params =& $xml->document->params) {
                             foreach ($params as $param) {
                                 foreach ($param->children() as $p) {
                                     if ($p->attributes('name') && isset($p->_attributes['default'])) {
                                         $dparams[$p->attributes('name')] = $p->attributes('default');
                                     }
                                 }
                             }
                         }
                     }
                 }
                 $profile = new stdclass();
                 $path = 'etc' . DS . 'profiles' . DS . $name;
                 $file = JPATH_SITE . DS . 'templates' . DS . $this->template . DS . 'local' . DS . $path;
                 $profile->local = null;
                 if (JFile::exists($file)) {
                     $params = new JParameter(JFile::read($file));
                     $profile->local = array_merge($dparams, $params->toArray());
                 }
                 $file = JPATH_SITE . DS . 'templates' . DS . $this->template . DS . 'core' . DS . $path;
                 $profile->core = null;
                 if (JFile::exists($file)) {
                     $params = new JParameter(JFile::read($file));
                     $profile->core = array_merge($dparams, $params->toArray());
                 }
                 $profiles[strtolower(substr($name, 0, -4))] = $profile;
             }
         }
         if (!$profiles) {
             $profile = new stdclass();
             $profile->core = '  ';
             $profile->local = null;
             $profiles['default'] = $profile;
         }
     }
     return $profiles;
 }
Ejemplo n.º 14
0
 public function getUsers($params = array())
 {
     // System variables
     $db = JFactory::getDBO();
     // Construct the query
     $query = 'SELECT * FROM #__users';
     if (isset($params['search'])) {
         $query .= ' WHERE username LIKE ' . $db->Quote($params['search']);
     }
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     foreach ($rows as $index => $row) {
         $params = new JParameter($row->params);
         $row->params = $params->toArray();
         $rows[$index] = $row;
     }
     return $rows;
 }
Ejemplo n.º 15
0
 function determineLanguage($get_lang = null)
 {
     // Set the language for JoomFish
     if (AcesefUtility::JoomFishInstalled()) {
         $registry = JFactory::getConfig();
         // save the default language of the site if needed
         $locale = $registry->get('config.language');
         $GLOBALS['mosConfig_defaultLang'] = $locale;
         $registry->set("config.defaultlang", $locale);
         // Get language from request
         if (!empty($get_lang)) {
             $lang = $get_lang;
         }
         // Try to get language code from JF cookie
         if ($this->AcesefConfig->joomfish_cookie) {
             $jf_cookie = JRequest::getVar('jfcookie', null, 'COOKIE');
             if (isset($jf_cookie['lang'])) {
                 $cookieCode = $jf_cookie['lang'];
             }
         }
         // Try to find language from browser settings
         if ($this->AcesefConfig->joomfish_browser && isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) && class_exists('JoomFishManager')) {
             $active_iso = array();
             $active_isocountry = array();
             $active_code = array();
             $active_languages = JoomFishManager::getInstance()->getActiveLanguages();
             if (count($active_languages) > 0) {
                 foreach ($active_languages as $a_lang) {
                     $active_iso[] = $a_lang->iso;
                     if (preg_match('/[_-]/i', $a_lang->iso)) {
                         $iso = str_replace('_', '-', $a_lang->iso);
                         $isocountry = explode('-', $iso);
                         $active_isocountry[] = $isocountry[0];
                     }
                     $active_code[] = $a_lang->shortcode;
                 }
                 // figure out which language to use - browser languages are based on ISO codes
                 $browser_lang = explode(',', $_SERVER["HTTP_ACCEPT_LANGUAGE"]);
                 foreach ($browser_lang as $b_lang) {
                     if (in_array($b_lang, $active_iso)) {
                         $client_lang = $b_lang;
                         break;
                     }
                     $short_lang = substr($b_lang, 0, 2);
                     if (in_array($short_lang, $active_isocountry)) {
                         $client_lang = $short_lang;
                         break;
                     }
                     // compare with code
                     if (in_array($short_lang, $active_code)) {
                         $client_lang = $short_lang;
                         break;
                     }
                 }
                 if (!empty($client_lang)) {
                     if (strlen($client_lang) == 2) {
                         $browser_code = self::getLangLongCode($client_lang);
                     } else {
                         $browser_code = $client_lang;
                     }
                 }
             }
         }
         // Check if language is selected
         if (empty($lang)) {
             if (empty($code) || !JLanguage::exists($code)) {
                 if ($this->AcesefConfig->joomfish_main_lang != '0') {
                     $code = self::getLangLongCode($this->AcesefConfig->joomfish_main_lang);
                 }
             }
             // Try to get language code from JF cookie
             if (empty($code) || !JLanguage::exists($code)) {
                 if (isset($cookieCode)) {
                     $code = $cookieCode;
                 }
             }
             // Try to get language from browser if needed
             if (empty($code) || !JLanguage::exists($code)) {
                 if (isset($browser_code)) {
                     $code = $browser_code;
                 }
             }
             // Get language from configuration if needed
             if (empty($code) || !JLanguage::exists($code)) {
                 if ($this->AcesefConfig->joomfish_main_lang != '0') {
                     $code = self::getLangLongCode($this->AcesefConfig->joomfish_main_lang);
                 }
             }
             // Get default language if needed
             if (empty($code) || !JLanguage::exists($code)) {
                 $code = $registry->get('config.language');
             }
         }
         // get language long code if needed
         if (empty($code)) {
             if (empty($lang)) {
                 return;
             }
             $code = self::getLangLongCode($lang);
         }
         if (!empty($code)) {
             // set the site language
             $reset_lang = false;
             if ($code != self::getLangLongCode()) {
                 $language = JFactory::getLanguage();
                 $language->setLanguage($code);
                 $language->load();
                 // set the backward compatible language
                 $back_lang = $language->getBackwardLang();
                 $GLOBALS['mosConfig_lang'] = $back_lang;
                 $registry->set("config.lang", $back_lang);
                 $reset_lang = true;
             }
             // set joomfish language if needed
             if ($reset_lang) {
                 $jf_lang = TableJFLanguage::createByJoomla($code);
                 $registry->set("joomfish.language", $jf_lang);
                 // set some more variables
                 $mainframe = JFactory::getApplication();
                 $registry->set("config.multilingual_support", true);
                 $mainframe->setUserState('application.lang', $jf_lang->code);
                 $registry->set("config.jflang", $jf_lang->code);
                 $registry->set("config.lang_site", $jf_lang->code);
                 $registry->set("config.language", $jf_lang->code);
                 $registry->set("joomfish.language", $jf_lang);
                 // overwrite global config with values from $jf_lang if set to in JoomFish
                 $jf_params = JComponentHelper::getParams("com_joomfish");
                 $overwriteGlobalConfig = $jf_params->get('overwriteGlobalConfig', 0);
                 if ($overwriteGlobalConfig) {
                     // We should overwrite additional global variables based on the language parameter configuration
                     $lang_params = new JParameter($jf_lang->params);
                     $param_array = $lang_params->toArray();
                     foreach ($param_array as $key => $val) {
                         $registry->set("config." . $key, $val);
                         if (defined("_JLEGACY")) {
                             $name = 'mosConfig_' . $key;
                             $GLOBALS[$name] = $val;
                         }
                     }
                 }
                 // set the cookie with language
                 if ($this->AcesefConfig->joomfish_cookie) {
                     setcookie("lang", "", time() - 1800, "/");
                     setcookie("jfcookie", "", time() - 1800, "/");
                     setcookie("jfcookie[lang]", $code, time() + 24 * 3600, '/');
                 }
             }
         }
     }
 }
Ejemplo n.º 16
0
 function __construct()
 {
     parent::__construct();
     // init helpers
     $path =& $this->getHelper('path');
     $config =& $this->getHelper('config');
     // init vars
     $jconfig =& JFactory::getConfig();
     $this->application =& JFactory::getApplication();
     $this->document =& JFactory::getDocument();
     $this->language =& JFactory::getLanguage();
     $this->path = JPATH_ROOT;
     $this->url = JURI::root(true);
     $this->cache_path = $this->path . '/cache/template';
     $this->cache_time = max($jconfig->getValue('config.cachetime') * 60, 86400);
     // set cache directory
     if (!file_exists($this->cache_path)) {
         JFolder::create($this->cache_path);
     }
     // set paths
     $path->register($this->path . '/administrator', 'admin');
     $path->register($this->path, 'site');
     $path->register($this->path . '/cache/template', 'cache');
     $path->register($path->path('warp:systems/joomla.1.5/menus'), 'menu');
     // set translations
     $this->language->load('tpl_warp', $path->path('warp:systems/joomla.1.5'), null, true);
     if ($this->application->isSite()) {
         // set config
         $config->set('language', $this->document->language);
         $config->set('direction', $this->document->direction);
         $config->set('actual_date', JHTML::_('date', 'now', JText::_('DATE_FORMAT_LC')));
         // get template params
         if ($file = $path->path('template:params.ini')) {
             $params = new JParameter(file_get_contents($file));
             $config->loadArray($params->toArray());
         }
         // get page class suffix params
         $params = $this->application->getParams();
         $config->parseString($params->get('pageclass_sfx'));
         // dynamic presets ?
         if ($config->get('allow_dynamic_preset')) {
             if ($var = JRequest::getVar($this->warp->preset_var, null, 'default', 'alnum')) {
                 $this->application->setUserState('_current_preset', $var);
             }
             $config->set('_current_preset', $this->application->getUserState('_current_preset'));
         }
     }
     if ($this->application->isAdmin()) {
         // get helper
         $xml =& $this->getHelper('xml');
         $http =& $this->getHelper('http');
         // get xml's
         $tmpl_xml =& $xml->load($path->path('template:templateDetails.xml'), 'xml');
         $warp_xml =& $xml->load($path->path('warp:warp.xml'), 'xml');
         // update check
         if ($url = $warp_xml->document->getElement('updateUrl')) {
             // get template info
             $template = $tmpl_xml->document->getElement('name');
             $version = $tmpl_xml->document->getElement('version');
             $url = sprintf('%s?application=%s&version=%s&format=raw', $url->data(), $template->data() . '_j15', $version->data());
             // check cache
             $file = $this->cache_path . sprintf('/%s.php', $template->data());
             $cache = file_exists($file) ? @unserialize(file_get_contents($file)) : null;
             if (!is_array($cache) || !isset($cache['check']) || !isset($cache['data'])) {
                 $cache = array('check' => null, 'data' => null);
             }
             // only check once a day
             if ($cache['check'] != date('Y-m-d') . ' ' . $version->data()) {
                 if ($request = $http->get($url)) {
                     $cache = array('check' => date('Y-m-d') . ' ' . $version->data(), 'data' => $request['body']);
                     @file_put_contents($file, serialize($cache));
                 }
             }
             // decode response and set message
             if (($response = json_decode($cache['data'])) && isset($response->status, $response->message) && $response->status == 'update-available') {
                 $this->application->enqueueMessage($response->message, 'notice');
             }
         }
     }
 }
Ejemplo n.º 17
0
function shSetJfLanguage($requestlang)
{
    if (empty($requestlang)) {
        return;
    }
    // get instance of JoomFishManager to obtain active language list and config values
    $jfm =& JoomFishManager::getInstance();
    $activeLanguages = $jfm->getActiveLanguages();
    // get the name of the language file for joomla
    $jfLang = TableJFLanguage::createByShortcode($requestlang, true);
    // set Joomfish stuff
    // Get the global configuration object
    global $mainframe;
    $registry =& JFactory::getConfig();
    $params = $registry->getValue("jfrouter.params");
    $enableCookie = empty($params) ? 1 : $params->get('enableCookie', 1);
    if ($enableCookie) {
        setcookie("lang", "", time() - 1800, "/");
        setcookie("jfcookie", "", time() - 1800, "/");
        setcookie("jfcookie[lang]", $jfLang->shortcode, time() + 24 * 3600, '/');
    }
    $GLOBALS['iso_client_lang'] = $jfLang->shortcode;
    $GLOBALS['mosConfig_lang'] = $jfLang->code;
    $mainframe->setUserState('application.lang', $jfLang->code);
    $registry->setValue("config.jflang", $jfLang->code);
    $registry->setValue("config.lang_site", $jfLang->code);
    $registry->setValue("config.language", $jfLang->code);
    $registry->setValue("joomfish.language", $jfLang);
    // Force factory static instance to be updated if necessary
    $lang =& JFactory::getLanguage();
    if ($jfLang->code != $lang->getTag()) {
        $lang = JFactory::_createLanguage();
    }
    $lang16 =& shjlang16Helper::getLanguage();
    if ($jfLang->code != $lang16->getTag()) {
        $lang16 = Jlanguage16::createLanguage();
    }
    // overwrite with the valued from $jfLang
    $params = new JParameter($jfLang->params);
    $paramarray = $params->toArray();
    foreach ($paramarray as $key => $val) {
        $registry->setValue("config." . $key, $val);
        if (defined("_JLEGACY")) {
            $name = 'mosConfig_' . $key;
            $GLOBALS[$name] = $val;
        }
    }
    // set our own data
    $GLOBALS['shMosConfig_lang'] = $lang->get('backwardlang', 'english');
    $GLOBALS['shMosConfig_locale'] = $jfLang->code;
    $GLOBALS['shMosConfig_shortcode'] = $jfLang->shortcode;
}
Ejemplo n.º 18
0
 function run($form, $actiondata)
 {
     $params = new JParameter($actiondata->params);
     $table_name = $params->get('table_name', '');
     $static_where = "";
     if (!empty($table_name) && (trim($params->get('dbfield', '')) || trim($actiondata->content1))) {
         $mainframe =& JFactory::getApplication();
         $database =& JFactory::getDBO();
         $req_param = $form->get_array_value($form->data, explode('.', $params->get('request_param', '')));
         if (is_null($req_param)) {
             $req_param = '';
         } else {
             $static_where = "`" . $params->get('dbfield', '') . "` = '" . $req_param . "'";
             if (is_array($req_param) && !empty($req_param)) {
                 $static_where = "`" . $params->get('dbfield', '') . "` IN ('" . implode("','", $req_param) . "')";
             }
         }
         $where = trim($actiondata->content1) ? $this->_processWhere(trim($actiondata->content1), $form) : $static_where;
         //load the model_id
         $model_id_sub = preg_replace('/(?:^|_)(.?)/e', "strtoupper('\$1')", $table_name);
         $model_id = $params->get('model_id', '');
         if (empty($model_id)) {
             $model_id = $model_id_sub;
         }
         //add a copy of the qury to the debug
         $form->debug['db_record_loader'][] = "SELECT * FROM `" . $table_name . "` AS `" . $model_id . "` WHERE " . $where;
         //run the query
         $database->setQuery("SELECT * FROM `" . $table_name . "` AS `" . $model_id . "` WHERE " . $where);
         $data = $database->loadAssoc();
         if (!is_array($data)) {
             $data = array();
         }
         //check array fields
         if (trim($params->get('array_fields_sets', '')) && trim($params->get('array_separators', ''))) {
             $fields_sets = explode('-', trim($params->get('array_fields_sets', '')));
             $separators = explode('-', trim($params->get('array_separators', '')));
             foreach ($fields_sets as $k1 => $fields_set) {
                 $fields_list = explode(',', $fields_set);
                 foreach ($fields_list as $k2 => $field) {
                     if (isset($data[$field])) {
                         $data[$field] = explode($separators[$k1], $data[$field]);
                     }
                 }
             }
         }
         //process any params fields
         if (strlen(trim($params->get('params_fields', ''))) > 0) {
             $params_fields = explode(",", trim($params->get('params_fields', '')));
             foreach ($params_fields as $params_field) {
                 if (isset($data[$params_field]) && !empty($data[$params_field])) {
                     $local_params = new JParameter($data[$params_field]);
                     $data[$params_field] = $local_params->toArray();
                 }
             }
         }
         if ((int) $params->get('load_under_modelid', 1) == 1) {
             $form->data[$model_id] = $data;
         } else {
             $form->data = array_merge($form->data, $data);
         }
         //check the result
         $request_val = $req_param;
         //JRequest::getVar($params->get('request_param', ''));
         if (!empty($data)) {
             $this->events['found'] = 1;
         } else {
             if (empty($request_val)) {
                 $this->events['nodata'] = 1;
             } else {
                 if (empty($data)) {
                     $this->events['notfound'] = 1;
                 } else {
                 }
             }
         }
         /*else{
         			$this->events['found'] = 1;
         		}*/
         //replace all the curly brackets strings
         /*if(isset($form->form_details->content)){
         			if((int)$params->get('curly_replacer', 1)){
         				$form->form_details->content = $form->curly_replacer($form->form_details->content, $form->data);
         			}
         			//load any form fields if this setting is enabled
         			if((int)$params->get('load_fields', 1)){
         				include_once(JPATH_SITE.DS.'components'.DS.'com_chronoforms'.DS.'libraries'.DS.'includes'.DS.'data_republish.php');
         				$HTMLFormPostDataLoad = new HTMLFormPostDataLoad();
         				$form->form_details->content = $HTMLFormPostDataLoad->load($form->form_details->content, $form->data);
         			}
         		}*/
     }
 }
Ejemplo n.º 19
0
 function _determineLanguage($getLang = null, $redir = false, $useMainLang = false)
 {
     // set the language for JoomFish
     if (SEFTools::JoomFishInstalled()) {
         $sefConfig =& SEFConfig::getConfig();
         $registry =& JFactory::getConfig();
         // Check if the Jfrouter is enabled
         $jfrouterEnabled = JPluginHelper::isEnabled('system', 'jfrouter');
         // save the default language of the site if needed
         if (!$jfrouterEnabled) {
             $locale = $registry->getValue('config.language');
             $GLOBALS['mosConfig_defaultLang'] = $locale;
             $registry->setValue("config.defaultlang", $locale);
         }
         // get instance of JoomFishManager to obtain active language list and config values
         $jfm =& JoomFishManager::getInstance();
         // Get language from request
         if (!empty($getLang)) {
             $lang = $getLang;
         }
         // Try to get language code from JF cookie
         if ($sefConfig->jfLangCookie) {
             $jfCookie = JRequest::getVar('jfcookie', null, 'COOKIE');
             if (isset($jfCookie['lang'])) {
                 $cookieCode = $jfCookie['lang'];
             }
         }
         // Try to find language from browser settings
         if ($sefConfig->jfBrowserLang && isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
             $active_iso = array();
             $active_isocountry = array();
             $active_code = array();
             $activeLanguages = $jfm->getActiveLanguages();
             if (count($activeLanguages) > 0) {
                 foreach ($activeLanguages as $alang) {
                     $active_iso[] = $alang->iso;
                     if (preg_match('/[_-]/i', $alang->iso)) {
                         $iso = str_replace('_', '-', $alang->iso);
                         $isocountry = explode('-', $iso);
                         $active_isocountry[] = $isocountry[0];
                     }
                     $active_code[] = $alang->shortcode;
                 }
                 // figure out which language to use - browser languages are based on ISO codes
                 $browserLang = explode(',', $_SERVER["HTTP_ACCEPT_LANGUAGE"]);
                 foreach ($browserLang as $blang) {
                     if (in_array($blang, $active_iso)) {
                         $client_lang = $blang;
                         break;
                     }
                     $shortLang = substr($blang, 0, 2);
                     if (in_array($shortLang, $active_isocountry)) {
                         $client_lang = $shortLang;
                         break;
                     }
                     // compare with code
                     if (in_array($shortLang, $active_code)) {
                         $client_lang = $shortLang;
                         break;
                     }
                 }
                 if (!empty($client_lang)) {
                     if (strlen($client_lang) == 2) {
                         $browserCode = SEFTools::getLangLongCode($client_lang);
                     } else {
                         $browserCode = $client_lang;
                     }
                 }
             }
         }
         if (!$jfrouterEnabled && $redir && $sefConfig->langPlacement != _COM_SEF_LANG_DOMAIN && (isset($cookieCode) || isset($browserCode)) && $sefConfig->mainLanguage != '0') {
             if (isset($cookieCode)) {
                 $sc = SEFTools::getLangCode($cookieCode);
             } else {
                 $sc = SEFTools::getLangCode($browserCode);
             }
             // Check the referer to see if we should redirect
             $shouldRedir = false;
             if (isset($_SERVER['HTTP_REFERER'])) {
                 $refUri = new JURI($_SERVER['HTTP_REFERER']);
                 $uri = JURI::getInstance();
                 $refHost = $refUri->getHost();
                 $host = $uri->getHost();
                 if ($refHost != $host) {
                     $shouldRedir = true;
                 }
             } else {
                 $shouldRedir = true;
             }
             if ($shouldRedir) {
                 if (!empty($lang) && $sc != $lang || empty($lang) && $sc != $sefConfig->mainLanguage) {
                     // Redirect to correct site
                     $mainframe =& JFactory::getApplication();
                     $href = JRoute::_('index.php?lang=' . $sc, false);
                     $mainframe->redirect($href);
                     exit;
                 }
             }
         }
         // Check if language is selected
         if (empty($lang) && !$jfrouterEnabled) {
             // If route and query string are empty, use the main language
             // note: removed  && $redir  - it was not possible to switch language to main language
             // on other page than homepage (let's see if it causes any other problem)
             // note: added $useMainLang - now it should work for both the VM checkout and using
             // main language with component's own router
             if ($useMainLang && (empty($code) || !JLanguage::exists($code))) {
                 if ($sefConfig->mainLanguage != '0') {
                     $code = SEFTools::GetLangLongCode($sefConfig->mainLanguage);
                 }
             }
             // Try to get language code from JF cookie
             if (empty($code) || !JLanguage::exists($code)) {
                 if (isset($cookieCode)) {
                     $code = $cookieCode;
                 }
             }
             // Try to get language from browser if needed
             if (empty($code) || !JLanguage::exists($code)) {
                 if (isset($browserCode)) {
                     $code = $browserCode;
                 }
             }
             // Get language from configuration if needed
             if (empty($code) || !JLanguage::exists($code)) {
                 if ($sefConfig->mainLanguage != '0') {
                     $code = SEFTools::GetLangLongCode($sefConfig->mainLanguage);
                 }
             }
             // Get default language if needed
             if (empty($code) || !JLanguage::exists($code)) {
                 $code = $registry->getValue('config.language');
             }
         }
         // get language long code if needed
         if (empty($code)) {
             if (empty($lang)) {
                 return;
             }
             $code = SEFTools::getLangLongCode($lang);
         }
         if (!empty($code)) {
             $jfrparams = $registry->getValue('jfrouter.params');
             // set the site language
             $resetLang = false;
             if ($code != SEFTools::getLangLongCode()) {
                 if (!$jfrouterEnabled || $jfrouterEnabled && $jfrparams->get('sefordomain', 'sefprefix') == 'sefprefix') {
                     $language =& JFactory::getLanguage();
                     $language->setLanguage($code);
                     $language->load();
                     // set the backward compatible language
                     $backLang = $language->getBackwardLang();
                     $GLOBALS['mosConfig_lang'] = $backLang;
                     $registry->setValue("config.lang", $backLang);
                     $resetLang = true;
                 }
             }
             // set joomfish language if needed
             if ($resetLang || !$jfrouterEnabled) {
                 $jfLang = TableJFLanguage::createByJoomla($code);
                 $registry->setValue("joomfish.language", $jfLang);
                 // set some more variables
                 $mainframe =& JFactory::getApplication();
                 $registry->setValue("config.multilingual_support", true);
                 $mainframe->setUserState('application.lang', $jfLang->code);
                 $registry->setValue("config.jflang", $jfLang->code);
                 $registry->setValue("config.lang_site", $jfLang->code);
                 $registry->setValue("config.language", $jfLang->code);
                 $registry->setValue("joomfish.language", $jfLang);
                 // overwrite global config with values from $jfLang if set to in JoomFish
                 $jfparams = JComponentHelper::getParams("com_joomfish");
                 $overwriteGlobalConfig = $jfparams->get('overwriteGlobalConfig', 0);
                 if ($overwriteGlobalConfig) {
                     // We should overwrite additional global variables based on the language parameter configuration
                     $langParams = new JParameter($jfLang->params);
                     $paramarray = $langParams->toArray();
                     foreach ($paramarray as $key => $val) {
                         $registry->setValue("config." . $key, $val);
                         if (defined("_JLEGACY")) {
                             $name = 'mosConfig_' . $key;
                             $GLOBALS[$name] = $val;
                         }
                     }
                 }
                 // set the cookie with language
                 if (!$jfrouterEnabled && $sefConfig->jfLangCookie || $jfrouterEnabled && $jfrparams->get('enableCookie', 1)) {
                     setcookie("lang", "", time() - 1800, "/");
                     setcookie("jfcookie", "", time() - 1800, "/");
                     setcookie("jfcookie[lang]", $code, time() + 24 * 3600, '/');
                 }
             }
         }
     }
 }
Ejemplo n.º 20
0
 public function getIntegrationSettings()
 {
     $plugins_list = array('alphauserpoints' => 'Kunena - AlphaUserPoints', 'comprofiler' => 'Kunena - Community Builder', 'gravatar' => 'Kunena - Gravatar', 'community' => 'Kunena - JomSocial', 'joomla' => 'Kunena - Joomla', 'kunena' => 'Kunena - Kunena', 'uddeim' => 'Kunena - UddeIM');
     $plugin_final = array();
     foreach ($plugins_list as $name => $desc) {
         $plugin = JPluginHelper::getPlugin('kunena', $name);
         if ($plugin) {
             if (version_compare(JVERSION, '1.6', '>')) {
                 $pluginParams = new JRegistry($plugin->params);
             } else {
                 $pluginParams = new JParameter($plugin->params);
             }
             $params = $pluginParams->toArray();
             $plugin_final[] = '[b]' . $desc . '[/b] Enabled: ';
             foreach ($params as $name => $value) {
                 $plugin_final[] = "{$name}={$value} ";
             }
             $plugin_final[] = "\n";
         } else {
             $plugin_final[] = "[b]{$desc}[/b] Disabled\n";
         }
     }
     return $plugin_final;
 }
Ejemplo n.º 21
0
t3_import('core/admin/util');
$obj = new JAT3_AdminUtil();
$uri = str_replace(DS, "/", str_replace(JPATH_SITE, JURI::base(), dirname(__FILE__)));
$uri = str_replace("/administrator", "", $uri);
$template = $obj->template;
$name = 'pages_profile';
$profiles = $obj->getProfiles();
$pageids = $obj->getPageIds($name);
jimport('joomla.filesystem.file');
$jsonData = $profiles;
$configfile = dirname(__FILE__) . DS . 'config.xml';
if (file_exists($configfile)) {
    /* For General Tab */
    $generalconfig = $obj->getGeneralConfig();
    $configForm = new JParameter($generalconfig, $configfile, 'template');
    $jsonData['generalconfigdata'] = $configForm->toArray();
    $jsonData['generalconfigdata'][$name] = str_replace("\n", "\\\\n", $configForm->get($name, ''));
    /* Parse data*/
    $arr_values = array();
    if ($value = $configForm->get($name, '')) {
        $arr_values_tmp = explode("\n", $value);
        foreach ($arr_values_tmp as $k => $v) {
            if ($v) {
                $arr_values[$k] = explode('=', $v);
            }
        }
    }
}
$paramsFile = dirname(__FILE__) . DS . 'params.xml';
if (file_exists($paramsFile)) {
    /* For General Tab */
Ejemplo n.º 22
0
function loadActionFile($action_data, $action_index)
{
    //load basic params
    $action_params = array();
    $action_file1 = JPATH_SITE . DS . "administrator" . DS . "components" . DS . "com_chronoforms" . DS . 'form_actions' . DS . $action_data->type . DS . $action_data->type . '.php';
    if (file_exists($action_file1)) {
        require_once $action_file1;
        $actionclassname = preg_replace('/(?:^|_)(.?)/e', "strtoupper('\$1')", 'cfaction_' . $action_data->type);
        if (class_exists($actionclassname)) {
            $actionclass = new $actionclassname();
            $action_params = $actionclass->load(true);
        }
    }
    //load elements files
    $filename = JPATH_SITE . DS . "administrator" . DS . "components" . DS . "com_chronoforms" . DS . 'form_actions' . DS . $action_data->type . DS . $action_data->type . '.ctp';
    if (file_exists($filename)) {
        $handle = fopen($filename, 'rb');
        $element_data = fread($handle, filesize($filename));
        fclose($handle);
        //$pattern_input = '/<div class="element_code"([^>]*?)>(.*?)<\/div>/is';
        $pattern_input = '/<!--start_element_code-->(.*?)<!--end_element_code-->/is';
        preg_match_all($pattern_input, $element_data, $matches);
        //prepare the lement code
        $element_code = $matches[0][0];
        $element_code = str_replace(array('<!--start_element_code-->', '<!--end_element_code-->'), '', $element_code);
        $element_code = str_replace('element_code', 'cfaction_' . $action_data->type . '_element_view wizard_element', $element_code);
        $element_code = preg_replace('/(\'|")' . 'cfaction_' . $action_data->type . '_element(\'|")/', '"' . 'cfaction_' . $action_data->type . '_element_' . $action_index . '"', $element_code);
        $element_code = str_replace('{n}', $action_index, $element_code);
        //prepare element params before the eval
        if (!is_array($action_data->params)) {
            $aparams = new JParameter($action_data->params);
            $params = $aparams->toArray();
            $action_data->params = array();
            foreach ($params as $kp => $param) {
                $action_data->params[$kp] = $param;
            }
        }
        $action_params = array_merge($action_params['action_params'], get_object_vars($action_data), $action_data->params);
        //render element
        ob_start();
        eval('?>' . $element_code);
        $output = ob_get_clean();
        return $output;
    }
}
Ejemplo n.º 23
0
 /**
  *
  * Get Profile of Module
  * @return Ambigous <string, multitype:>|string
  */
 protected function getProfile()
 {
     if (!defined('_JA_PARAM_HELPER')) {
         define('_JA_PARAM_HELPER', 1);
         $uri = str_replace(DS, "/", str_replace(JPATH_SITE, JURI::base(), dirname(__FILE__)));
         if (strpos($uri, JURI::base()) != 0 && strpos($uri, JURI::base()) == false) {
             $uri = JURI::base() . $uri;
         }
         $uri = str_replace("/administrator/", "", $uri);
         //mootools support joomla 1.7 and 2.5
         JHTML::_('behavior.framework', true);
         JHTML::stylesheet($uri . '/assets/css/japaramhelper.css');
         JHTML::script($uri . '/assets/js/japaramhelper.js');
     }
     if (!defined('JAPARAMERTER2')) {
         $uri = str_replace(DS, "/", str_replace(JPATH_SITE, JURI::base(), dirname(__FILE__)));
         if (strpos($uri, JURI::base()) != 0 && strpos($uri, JURI::base()) == false) {
             $uri = JURI::base() . $uri;
         }
         $uri = str_replace("/administrator/", "", $uri);
         JHTML::stylesheet($uri . "/assets/css/japaramhelper2.css");
         JHTML::script($uri . "/assets/js/japaramhelper2.js");
         jimport('joomla.filesystem.folder');
         jimport('joomla.filesystem.file');
         define('JAPARAMERTER2', true);
     }
     $jsonData = array();
     $folder_profiles = array();
     /* Get all profiles name folder from folder profiles */
     $profiles = array();
     $jsonData = array();
     $jsonTempData = array();
     // get in template
     $template = $this->get_active_template();
     $path = JPATH_SITE . DS . 'templates' . DS . $template . DS . 'html' . DS . 'mod_janewspro';
     if (JFolder::exists($path)) {
         $files = JFolder::files($path, '.ini');
         if ($files) {
             foreach ($files as $fname) {
                 $fname = substr($fname, 0, -4);
                 $f = new stdClass();
                 $f->id = $fname;
                 $f->title = $fname;
                 $profiles[$fname] = $f;
                 $params = new JParameter(JFile::read($path . DS . $fname . '.ini'));
                 $jsonData[$fname] = $params->toArray();
                 $jsonTempData[$fname] = $jsonData[$fname];
             }
         }
     }
     // get in module
     $path = JPATH_SITE . DS . 'modules' . DS . 'mod_janewspro' . DS . 'profiles';
     if (!JFolder::exists($path)) {
         return JText::_('PROFILE_FOLDER_NOT_EXIST');
     }
     $files = JFolder::files($path, '.ini');
     if ($files) {
         foreach ($files as $fname) {
             $fname = substr($fname, 0, -4);
             $f = new stdClass();
             $f->id = $fname;
             $f->title = $fname;
             $profiles[$fname] = $f;
             $params = new JParameter(JFile::read($path . DS . $fname . '.ini'));
             $jsonData[$fname] = $params->toArray();
         }
     }
     $xml_profile = JPATH_SITE . DS . 'modules' . DS . 'mod_janewspro' . DS . 'admin' . DS . 'config.xml';
     if (file_exists($xml_profile)) {
         /* For General Form */
         $options = array("control" => "jaform");
         $paramsForm =& JForm::getInstance('jform', $xml_profile, $options);
     }
     $HTML_Profile = JHTML::_('select.genericlist', $profiles, '' . $this->name, 'style="width:150px;" onchange="japarams2.changeProfile(this.value)"', 'id', 'title', $this->value);
     $_body = JResponse::getBody();
     ob_start();
     require_once dirname(__FILE__) . DS . 'tpl.php';
     $content = ob_get_clean();
     JResponse::setBody($_body);
     return $content;
 }
Ejemplo n.º 24
0
 /**
  * Legacy function, use {@link JParameter::toArray() JParameter->toArray()} instead
  *
  * @deprecated As of version 1.5
  */
 function toArray()
 {
     parent::toArray();
 }
Ejemplo n.º 25
0
    protected function formatParams() {

        jimport('joomla.html.parameter');
        $params = new JParameter($this->auction->params);
        $this->auction->params = $params->toArray();

    }