Ejemplo n.º 1
0
 function universalfetchElement($name, $value, &$node)
 {
     $value = (array) $value;
     $html = array();
     $db =& JFactory::getDBO();
     $lng = JFactory::getLanguage();
     $id = $this->generateId($name);
     $pluginNames = array();
     preg_match('/(.*)\\[([a-zA-Z0-9]*)\\]$/', $name, $out);
     $control = $out[1];
     $orig_name = $out[2];
     $db->setQuery('SET @rank=0;');
     $db->query();
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         $control = $name;
         $pluginNames = $value[$orig_name . 'name'];
         if (!isset($data['params']['theme'])) {
             $data['params']['theme'] = array();
         }
         $themeparams = offflat_array($data['params']['theme']);
         $data = offflat_array($data['params']);
         $db->setQuery('UPDATE #__extensions SET ordering = (@rank:=@rank+1) WHERE type = "plugin" AND folder = "search" ORDER BY ordering ASC');
         $db->query();
         $db->setQuery("SELECT extension_id AS id, name FROM #__extensions WHERE type = 'plugin' AND folder = 'search' AND enabled =1 ORDER BY ordering");
     } else {
         $pluginNames = $this->_parent->get($orig_name . 'name');
         $db->setQuery('UPDATE #__plugins SET ordering = (@rank:=@rank+1) WHERE folder = "search" ORDER BY ordering ASC');
         $db->query();
         $db->setQuery("SELECT id, name FROM #__plugins WHERE folder = 'search' AND published=1 ORDER BY ordering");
     }
     $plgs = $db->loadRowList();
     $value == 1 ? $new = true : ($new = false);
     $html[] = '<fieldset class="only">';
     $i = 0;
     $pluginNames = $this->buildPluginNameArray($pluginNames);
     foreach ($plgs as $plg) {
         $lng->load($plg[1]);
         $html_value = '';
         $checked = is_array($value) && in_array($plg[0], $value) ? 'checked="checked"' : '';
         if ($new) {
             $checked = 'checked="checked"';
         }
         $html_value = isset($pluginNames[$plg[0]]) ? $pluginNames[$plg[0]] : JText::_($plg[1]);
         $html[] = '<input type="checkbox" name="' . $name . '[]" value="' . $plg[0] . '" id="' . $name . '_' . $plg[0] . '" ' . $checked . ' />';
         $html[] = ' <label for="' . $id . '_' . $plg[0] . '"  style="clear:none; display:inline-block;min-width: 120px;" >' . JText::_($plg[1]) . '</label>';
         $html[] = ' <input type="hidden" name="' . $control . '[' . $orig_name . 'name][]" value="' . $plg[0] . '" />';
         $html[] = ' <input type="text" name="' . $control . '[' . $orig_name . 'name][]" value="' . $html_value . '" />';
         $html[] = ' <a href="' . JRoute::_('index.php?option=com_plugins&task=plugin.edit&extension_id=' . $plg[0]) . '" target="_blank">Open plugin settings</a> ';
         $html[] = '<div style="clear:both;"></div>';
         $i++;
     }
     $html[] = '</fieldset>';
     return implode($html);
 }
Ejemplo n.º 2
0
 function offflat_array($array)
 {
     $out = array();
     foreach ($array as $k => $v) {
         if (is_array($array[$k]) && offisAssoc($array[$k])) {
             $out += offflat_array($array[$k]);
         } else {
             $out[$k] = $v;
         }
     }
     return $out;
 }
Ejemplo n.º 3
0
 protected function initTheme()
 {
     // Load module
     $db = JFactory::getDBO();
     $db->setQuery("SELECT id, module, params FROM #__modules WHERE published >= 0 AND module LIKE 'mod_improved_ajax_login'");
     $module = $db->loadObject();
     if (!$module) {
         die('mod_improved_ajax_login not found!');
     }
     $modPath = JPATH_SITE . '/modules/mod_improved_ajax_login';
     require_once $modPath . '/params/offlajndashboard/library/flatArray.php';
     $modParams = new JRegistry();
     $modParams->loadString($module->params);
     $modParams->loadArray(offflat_array($modParams->toArray()));
     // get regpage
     list($this->regpage) = explode('|*|', $modParams->get('regpage'));
     // If module not saved then set default param values
     $theme = $modParams->get('theme');
     if (!$theme) {
         $theme = $modParams->set('theme', 'elegant');
         $xml = JFactory::getXML("{$modPath}/themes/{$theme}/theme.xml");
         foreach ($xml->params->param as $p) {
             $modParams->set((string) $p['name'], (string) $p['default']);
         }
     }
     // Build module CSS
     require_once $modPath . '/classes/ImageHelper.php';
     require_once $modPath . '/classes/cache.class.php';
     require_once $modPath . '/helpers/font.php';
     require_once $modPath . '/helpers/parser.php';
     $cache = new OfflajnMenuThemeCache('default', $module, $modParams);
     $cache->addCss($modPath . '/themes/clear.css.php');
     $cache->addCss($modPath . '/themes/' . $theme . '/theme.css.php');
     $cache->assetsAdded();
     // Set up enviroment variables for the cache generation
     $themeurl = JURI::root(true) . "/modules/mod_improved_ajax_login/themes/{$theme}/";
     $cache->addCssEnvVars('themeurl', $themeurl);
     $cache->addCssEnvVars('helper', new OfflajnHelper7($cache->cachePath, $cache->cacheUrl));
     $cacheFiles = $cache->generateCache();
     $this->theme = $theme;
     $this->themeCSS = $cacheFiles[0];
 }
     $_SESSION[$module->module . 'a'] = array();
     $a = $params->toArray();
     $a['params'] = $a;
     $params->loadArray($a);
     $_SESSION[$module->module . "_orig"] = $params->toString();
     $_SESSION[$module->module . 'a'][$module->id] = true;
     $_SESSION[$module->module . "_params"] = $params->toString();
     header('LOCATION: ' . $_SERVER['REQUEST_URI']);
 }
 if (isset($_SESSION[$module->module . "_params"])) {
     $params = new JRegistry();
     $params->loadString($_SESSION[$module->module . "_params"], 'JSON');
 }
 $a = $params->toArray();
 require_once dirname(__FILE__) . DS . 'params' . DS . 'library' . DS . 'flatArray.php';
 $params->loadArray(offflat_array($a['params']));
 // skins
 $themesdir = JPATH_SITE . DS . 'modules' . DS . $module->module . DS . 'themes' . DS;
 $xmlFile = $themesdir . $params->get('theme', 'default') . '/theme.xml';
 //$xml->loadFile( $xmlFile );
 $xml = new SimpleXMLElement(file_get_contents($xmlFile));
 $skins = $xml->params[0]->param[0];
 $sks = array();
 foreach ($skins->children() as $skin) {
     $sks[] = $skin->getName();
 }
 $document->addScriptDeclaration('
   dojo.addOnLoad(function() {
     if (window.Skinchanger) window.skin = new Skinchanger({theme: "' . $params->get('theme', 'default') . '",skins: ' . json_encode($sks) . '});
   });
 ');
Ejemplo n.º 5
0
 function generateThemeSelector($name, $value)
 {
     $themes = JFolder::folders($this->themesdir);
     $this->themeParams = array('default' => '');
     $this->themeScripts = array('default' => '');
     $options = array();
     $options[] = JHTML::_('select.option', '', '- ' . JText::_('Use default') . ' -');
     $data = null;
     $themeparams = null;
     $options = array();
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         foreach ((array) $this->form as $key => $val) {
             if ($val instanceof JRegistry) {
                 $data =& $val;
                 break;
             }
         }
         $data = $data->toArray();
         if (!isset($data['params']['theme'])) {
             $data['params']['theme'] = array();
         }
         $themeparams = offflat_array($data['params']['theme']);
         $data = offflat_array($data['params']);
     } else {
         $data = $this->_parent->_raw;
     }
     preg_match('/(.*)\\[([a-zA-Z0-9]*)\\]$/', $name, $out);
     $control = $out[1];
     $orig_name = $out[2];
     if (is_array($themes)) {
         foreach ($themes as $theme) {
             $GLOBALS['themescripts'] = array();
             $options[] = JHTML::_('select.option', $theme, ucfirst($theme));
             $xml = $this->themesdir . $theme . '/theme.xml';
             if ($theme == 'default') {
                 $theme .= 2;
             }
             $this->params = new SearchOfflajnJParameter('', $xml, 'module');
             $c = $control;
             if (version_compare(JVERSION, '1.6.0', 'ge')) {
                 $this->params->bind($data);
                 $c = $name;
             } else {
                 $this->params->bind($data);
             }
             $this->params->theme = $theme;
             $this->params->addElementPath(JPATH_ROOT . str_replace('/', DS, '/modules/' . $this->_moduleName . '/params'));
             $_xml =& $this->params->getXML();
             for ($x = 0; count(@$_xml['_default']->_children) > $x; $x++) {
                 $node =& $_xml['_default']->_children[$x];
                 if (isset($node->_attributes['directory'])) {
                     $node->_attributes['directory'] = str_replace('/', DS, '/modules/' . $this->_moduleName . '/themes/' . $theme . '/' . $node->_attributes['directory']);
                 }
             }
             $this->themeParams[$theme] = $this->params->render($c);
             $this->themeScripts[$theme] = implode(' ', $GLOBALS['themescripts']);
         }
     }
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         $name .= '[' . $orig_name . ']';
     }
     $themeField = JHTML::_('select.genericlist', $options, $name, 'class="inputbox"', 'value', 'text', $value);
     if ($this->params->get('admindebug', 0) == 1) {
         $themeField .= "<br />";
         $xml = '';
         $skin = 0;
         foreach (version_compare(JVERSION, '1.6.0', 'ge') ? $themeparams : $this->params->toArray() as $key => $value) {
             if ($skin == 0) {
                 if ($key == 'fontskin') {
                     $skin = 1;
                 }
                 continue;
             } else {
                 if ($skin == 1) {
                     if ($key == 'cache') {
                         $skin = 0;
                         continue;
                     }
                 }
             }
             $xml .= "&lt;" . $key . "&gt;" . $value . "&lt;/" . $key . "&gt;\n";
         }
         $themeField .= "<textarea style='width: 100%; min-height: 300px;'>" . $xml . "</textarea>";
     }
     ob_start();
     if (version_compare(JVERSION, '3.0.0', 'ge')) {
         include 'themeselector30.tmpl.php';
     } else {
         if (version_compare(JVERSION, '1.6.0', 'ge')) {
             include 'themeselector16.tmpl.php';
         } else {
             include 'themeselector.tmpl.php';
         }
     }
     $this->themeSelector = ob_get_contents();
     ob_end_clean();
     $document =& JFactory::getDocument();
     $document->addScriptDeclaration('
   dojo.addOnLoad(function(){
     var theme = new ThemeConfigurator({
       selectTheme: "' . $this->generateId($name) . '",
       themeSelector: ' . json_encode($this->themeSelector) . ',
       themeParams: ' . json_encode($this->themeParams) . ',
       themeScripts: ' . json_encode($this->themeScripts) . ',
       joomfish: ' . (int) $this->jf . ',
       control: "' . $control . '",
       isJoomla3 : "' . (int) version_compare(JVERSION, '3.0.0', 'ge') . '"
     });
   });
 ');
 }
Ejemplo n.º 6
0
require_once dirname(__FILE__) . '/helpers/functions.php';
$db = JFactory::getDBO();
$lang = JFactory::getLanguage();
$module->instanceid = $module->module . '-' . $module->id;
$root = JURI::root(true);
if ($root != '/') {
    $root .= '/';
}
// init params
if ($params->get('moduleclass_sfx', '') != @$params->get('advancedTab')->moduleclass_sfx) {
    $params->set('moduleclass_sfx', $params->get('advancedTab')->moduleclass_sfx);
    $db->setQuery('UPDATE #__modules SET params=\'' . addslashes($params->toString()) . '\' WHERE id=' . $module->id);
    $db->query();
}
require_once dirname(__FILE__) . '/params/offlajndashboard/library/flatArray.php';
$params->loadArray(offflat_array($params->toArray()));
// For demo parameter editor
if (defined('DEMO')) {
    $_SESSION['module_id'] = $module->id;
    if (!isset($_SESSION[$module->module . 'a'][$module->id])) {
        $_SESSION[$module->module . 'a'] = array();
        $a = $params->toArray();
        $a['params'] = $a;
        $params->loadArray($a);
        $_SESSION[$module->module . "_orig"] = $params->toString();
        $_SESSION[$module->module . 'a'][$module->id] = true;
        $_SESSION[$module->module . "_params"] = $params->toString();
        header('LOCATION: ' . $_SERVER['REQUEST_URI']);
    }
    if (isset($_SESSION[$module->module . "_params"])) {
        $params = new JRegistry();