Example #1
0
 public function getItem($pk = null)
 {
     $storeId = md5(__METHOD__);
     if (!isset($this->cache[$storeId])) {
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select('config_params');
         $query->from('#__judownload_categories');
         $query->where('parent_id = 0');
         $query->where('level = 0');
         $db->setQuery($query);
         $config_params = $db->loadResult();
         $registry = new JRegistry();
         $registry->loadString($config_params);
         $globalConfig = $registry->toObject();
         foreach ($globalConfig as $key => $value) {
             if (is_object($value)) {
                 $registry = new JRegistry();
                 $registry->loadObject($value);
                 $globalConfig->{$key} = $registry->toArray();
             }
         }
         $this->cache[$storeId] = $globalConfig;
     }
     return $this->cache[$storeId];
 }
Example #2
0
 /**
  * getOptions
  *
  * Generates list options
  *
  * @return    array    The field option objects.
  * @since    1.6
  */
 protected function getOptions()
 {
     $obj = $this->form->getValue('params');
     $params = new JRegistry();
     $params->loadObject($obj);
     $apiKey = $params->get('googlewebfontapikey');
     if ($apiKey) {
         $link = 'https://www.googleapis.com/webfonts/v1/webfonts?key=' . $apiKey;
     } else {
         $link = 'https://www.googleapis.com/webfonts/v1/webfonts';
     }
     $json = @file_get_contents($link);
     $data = json_decode($json, TRUE);
     $items = $data['items'];
     $options = array();
     if ($items) {
         $options[] = JHtml::_('select.option', '', '- None Selected -');
         foreach ($items as $item) {
             $options[] = JHtml::_('select.option', str_replace(" ", "+", $item['family']), $item['family']);
         }
     } else {
         $options[] = JHtml::_('select.option', '', 'Google Web Font API Not Available');
     }
     return $options;
 }
Example #3
0
 /**
  * Gets a reference to the cache object, loading it from the disk if
  * needed.
  *
  * @param   boolean  $force  Should I forcibly reload the registry?
  *
  * @return  JRegistry
  */
 private function &getCacheObject($force = false)
 {
     // Check if we have to load the cache file or we are forced to do that
     if (is_null($this->_cache) || $force) {
         // Create a new JRegistry object
         JLoader::import('joomla.registry.registry');
         $this->_cache = new JRegistry();
         // Try to get data from Joomla!'s cache
         $cache = JFactory::getCache('fof', '');
         $data = $cache->get('cache', 'fof');
         // If data is not found, fall back to the legacy (F0F 2.1.rc3 and earlier) method
         if ($data === false) {
             // Find the path to the file
             $cachePath = JPATH_CACHE . '/fof';
             $filename = $cachePath . '/cache.php';
             $filesystem = $this->getIntegrationObject('filesystem');
             // Load the cache file if it exists. JRegistryFormatPHP fails
             // miserably, so I have to work around it.
             if ($filesystem->fileExists($filename)) {
                 @(include_once $filename);
                 $filesystem->fileDelete($filename);
                 $className = 'F0FCacheStorage';
                 if (class_exists($className)) {
                     $object = new $className();
                     $this->_cache->loadObject($object);
                     $options = array('class' => 'F0FCacheStorage');
                     $cache->store($this->_cache, 'cache', 'fof');
                 }
             }
         } else {
             $this->_cache = $data;
         }
     }
     return $this->_cache;
 }
Example #4
0
 /**
  * Load an object or array into the application configuration object.
  *
  * @param   mixed  $data  Either an array or object to be loaded into the configuration object.
  *
  * @return  void
  *
  * @since   11.1
  */
 public function loadConfiguration($data)
 {
     // Load the data into the configuration object.
     if (is_array($data)) {
         $this->config->loadArray($data);
     } elseif (is_object($data)) {
         $this->config->loadObject($data);
     }
 }
Example #5
0
	public static function save($path)
	{
		$result = array();
		
		if(empty($path)){
			return self::error(JText::_('T3_TM_UNKNOWN_THEME'));
		}
		
		$theme = JFactory::getApplication()->input->getCmd('theme');
		$from = JFactory::getApplication()->input->getCmd('from');
		if (!$theme) {
		   return self::error(JText::_('T3_TM_INVALID_DATA_TO_SAVE'));
		}

		$file = $path . '/less/themes/' . $theme . '/variables-custom.less';

		if(!class_exists('JRegistryFormatLESS')){
			T3::import('format/less');
		}
		$variables = new JRegistry();
		$variables->loadObject($_POST);
		
		$data = $variables->toString('LESS');
		$type = 'new';
		if (JFile::exists($file)) {
			$type = 'overwrite';
		} else {

			if(JFolder::exists($path . '/less/themes/' . $from)){
				if(@JFolder::copy($path . '/less/themes/' . $from, $path . '/less/themes/' . $theme) != true){
					return self::error(JText::_('T3_TM_NOT_FOUND'));
				}
			} else if($from == 'base') {
				$dummydata = "";
				@JFile::write($path . '/less/themes/' . $theme . '/template.less', $dummydata);
				@JFile::write($path . '/less/themes/' . $theme . '/variables.less', $dummydata);
				@JFile::write($path . '/less/themes/' . $theme . '/template-responsive.less', $dummydata);
			}
		}
		
		$return = @JFile::write($file, $data);

		if (!$return) {
			return self::error(JText::_('T3_TM_OPERATION_FAILED'));
		} else {
			$result['success'] = JText::sprintf('T3_TM_SAVE_SUCCESSFULLY', $theme);
			$result['theme'] = $theme;
			$result['type'] = $type;
		}

		//LessHelper::compileForTemplate(T3_TEMPLATE_PATH, $theme);
		T3::import ('core/less');
		T3Less::compileAll($theme);
		return self::response($result);
	}
Example #6
0
 public function onAfterDispatch()
 {
     if (JFactory::getApplication()->isAdmin()) {
         return true;
     }
     $input = JFactory::getApplication()->input;
     $extension = $input->get('option', '', 'cmd');
     $view = $input->get('view', '', 'cmd');
     $categories = $input->get('categories', array(), 'array');
     $category_id = count($categories) == 1 ? array_shift($categories) : null;
     if ($extension !== 'com_ksenmart') {
         return true;
     }
     if (JFactory::getDocument()->getType() !== 'html' || $input->get('tmpl', '', 'cmd') === 'ksenmart') {
         return true;
     }
     $doc = JFactory::getDocument();
     $renderer = $doc->loadRenderer('module');
     $modules = $this->params->get('modules', new stdClass());
     foreach ($modules as $position => $mods) {
         $attribs = array('name' => $position);
         $buf = $doc->getBuffer('modules', $position, $attribs);
         foreach (JModuleHelper::getModules($position) as $mod) {
             foreach ($mods as $mod_id => $mod_params) {
                 $registry = new JRegistry();
                 $mod_params = $registry->loadObject($mod_params);
                 $categories = $mod_params->get('categories', array());
                 $pages = $mod_params->get('pages', array());
                 if ($mod->id == $mod_id) {
                     if ($view == 'catalog' && !empty($category_id)) {
                         if (in_array(-1, $categories) || !in_array($category_id, $categories) && !in_array(0, $categories)) {
                             $moduleHtml = $renderer->render($mod, $attribs, null);
                             $buf = str_replace($moduleHtml, '', $buf);
                         }
                     } else {
                         $page_id = 0;
                         foreach ($this->pages as $key => $page) {
                             if ($page == $view) {
                                 $page_id = $key;
                             }
                         }
                         if (in_array(-1, $pages) || !in_array($page_id, $pages) && !in_array(0, $pages)) {
                             $moduleHtml = $renderer->render($mod, $attribs, null);
                             $buf = str_replace($moduleHtml, '', $buf);
                         }
                     }
                 }
             }
         }
         $doc->setBuffer($buf, 'modules', $position);
     }
     return true;
 }
Example #7
0
 public function getInput()
 {
     if (!defined('YJSGRUN')) {
         echo '<h1 style="color:red;">' . JText::_('YJSG_PLUGIN_NOT_FOUND') . '</h1>';
         return;
     }
     $document = YjsgDochead::getDocument();
     $document->addJsInhead("var comp_dis ='" . JText::_('YJSG_COMPONENT_DISABLED') . "';");
     $yjsg = Yjsg::getInstance();
     $YjsgCurrentVersion = $yjsg->version;
     $YjsgHasUpdate = $yjsg->hasupdate;
     $YjsgLatestVersion = $yjsg->getUpdateVersion();
     $template_folder = basename(dirname(dirname(__FILE__)));
     $params_obj = $this->form->getValue('params');
     $params = new JRegistry();
     $params->loadObject($params_obj);
     $comp_dis = '<div id="option-resut">';
     if ($params->get('component_switch')) {
         $comp_dis .= JText::_('YJSG_COMPONENT_DISABLED');
     }
     $comp_dis .= '</div>';
     $yjsgManageLink = 'index.php?option=com_plugins&view=plugins&filter_folder=system&filter_search=Yjsg';
     $yjsgText = '' . JText::_('YJSG_INS_PUB') . " <strong>v" . $YjsgCurrentVersion . "</strong> " . JText::_('YJSG_INS_PUB2') . ' <a href="' . $yjsgManageLink . '">' . JText::_('YJSC_MAN_EXT') . '</a>';
     if ($YjsgHasUpdate == 1) {
         $updateclass = ' updateavailable';
     } else {
         $updateclass = '';
     }
     // yjsg
     $syshtml = '<div class="yj_system_check">';
     $syshtml .= '<div id="yjsgBox" class="systemBox' . $updateclass . '">';
     $syshtml .= '<h2 id="yjmmpTitle" class="systemBoxTitle yjsgtips" data-original-title="' . JText::_('YJSG_CHECK') . '" data-content="' . JText::_('YJSG_CHECK_TIP') . '">' . JText::_('YJSG_CHECK') . '</h2>';
     if ($YjsgHasUpdate == 1) {
         $syshtml .= '<div class="infoText"><span class="showIcon"></span> ';
         $syshtml .= JText::_('UPDATE_AVAILABLE_TEXT') . '<strong>' . $YjsgCurrentVersion . '</strong>';
         $syshtml .= JText::_('UPDATE_AVAILABLE_TEXT2') . '<strong>' . $YjsgLatestVersion . '</strong>';
         $syshtml .= '<a href="index.php?option=com_installer&amp;view=update">' . JText::_('UPDATE_AVAILABLE_TEXT3') . '</a>';
         $syshtml .= '</div>';
     } else {
         $syshtml .= '<div class="infoText"><span class="showIcon"></span>' . $yjsgText . '</div>';
     }
     $syshtml .= '</div>';
     $syshtml .= '<div  id="settmsgBox" class="systemBox hide">';
     $syshtml .= '<h2 id="yjjbpTitle" class="systemBoxTitle yjsgtips" data-original-title="' . JText::_('YJSG_SETT_MSG') . '" data-content="' . JText::_('YJSG_SETT_MSG_TIP') . '">' . JText::_('YJSG_SETT_MSG') . '</h2>';
     $syshtml .= '<div class="infoText"><span class="showIcon"></span>' . $comp_dis . '</div>';
     $syshtml .= '</div>';
     $syshtml .= '</div>';
     // close yj_system_check
     // Output
     echo $syshtml;
 }
 /**
  *
  * Ajax request set/get data
  */
 public function request()
 {
     $data = new JRegistry();
     $dataFromRequest = JRequest::getVar('data', '');
     $data->loadObject(json_decode($dataFromRequest));
     if ($data->get('requestTask', '') == 'brankNewData') {
         JSNFactory::localimport('libraries.joomlashine.mode.rawmode');
         $jsnrawmode = JSNRawmode::getInstance($data->toArray());
         $jsnrawmode->renderComponent();
         echo $jsnrawmode->getHTML('component');
         jexit();
     }
     $params = $data->get('params', array());
     if (is_object($params)) {
         $params = (array) $params;
     }
     if ($data->get('prefix_params', false)) {
         $prefixId = 0;
         $_params = array();
         foreach ($params as $key => $val) {
             $suffixs = explode('_', $key);
             $number = (int) $suffixs[count($suffixs) - 1];
             if (!$prefixId) {
                 $prefixId = $number;
             }
             $_params[str_replace('_' . $number, '', $key)] = $val;
         }
         $params = $_params;
     }
     $jsnConfig = JSNFactory::getConfig();
     // Execute saveParams event if option is supported ext
     JSNPaExtensionsHelper::executeExtMethod(str_ireplace('com_', '', $data->get('option')), 'saveParams', array('data' => $data, 'jsnConfig' => $jsnConfig, 'params' => $params));
     switch ($data->get('requestType', 'only')) {
         case 'only':
             $jsnConfig->menuitem($data->get('Itemid', ''), $params);
             break;
         case 'globally':
             //Set global config
             $jsnConfig->extension($data->get('option', ''), $params);
             foreach ($params as $k => $param) {
                 $params[$k] = '';
             }
             //Set for menu article layout
             $allMenuitems = $this->getModel('menuitem')->getAllItems(array('option' => $data->get('option', $data->get('option')), 'view' => $data->get('view', 'article'), 'layout' => $data->get('layout', '')));
             foreach ($allMenuitems as $item) {
                 $jsnConfig->menuitem($item->id, $params);
             }
             break;
     }
     jexit('success');
 }
Example #9
0
 public function addChannel($channel)
 {
     $channelId = trim($channel);
     $row = JTable::getInstance('Channel', 'Table');
     $row->load($channelId);
     if ($row->published) {
         $options = new JRegistry();
         $options->loadObject($row->attribs);
         $channel = JFBCFactory::provider($row->provider)->channel($row->type, $options);
         // This is a bit hacky as we're temporarily saving the row to use in the addPost. Should be handling this better.
         $this->currentRow = $row;
         $channel->getStream($this);
     }
 }
Example #10
0
 public function addItem()
 {
     $app = JFactory::getApplication();
     $model = $this->getModel('Carts', 'J2StoreModel');
     $result = $model->addCartItem();
     $registry = new JRegistry();
     if (is_object($result)) {
         $registry->loadObject($result);
         $json = $registry->toArray();
     } elseif (is_array($result)) {
         $json = $result;
     } else {
         $json = $result;
     }
     $config = J2Store::config();
     $cart_url = $model->getCartUrl();
     //if javascript submissions is not enabled
     $ajax = $app->input->getInt('ajax', 0);
     if ($ajax) {
         if (isset($json['success'])) {
             if ($config->get('addtocart_action', 3) == 3) {
                 $json['redirect'] = $cart_url;
             }
         }
         $json['product_redirect'] = JRoute::_('index.php?option=com_j2store&view=product&id=' . $this->input->getInt('product_id'));
         echo json_encode($json);
         $app->close();
     } else {
         $return = $app->input->getBase64('return');
         if (!is_null($return)) {
             $return_url = base64_decode($return);
         } else {
             $return_url = $cart_url;
         }
         if ($json['success']) {
             $this->setRedirect($cart_url, JText::_('J2STORE_ITEM_ADDED_TO_CART'), 'success');
         } elseif ($json['error']) {
             $error = J2Store::utilities()->errors_to_string($json['error']);
             $this->setRedirect($return_url, $error, 'error');
         } else {
             $this->setRedirect($return_url);
         }
     }
 }
Example #11
0
 public function ajaxCreatePost()
 {
     if (JFactory::getUser()->authorise('jfbconnect.channels.post', 'com_jfbconnect')) {
         $response = array();
         $input = JFactory::getApplication()->input;
         $message = $input->post->getString('message');
         $link = $input->post->getString('link');
         $cids = $input->post->get('cids', array(), 'array');
         if (empty($cids)) {
             $response[] = JText::_('COM_JFBCONNECT_CHANNELS_SELECT_CHANNEL_LABEL');
         }
         JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_jfbconnect/tables/');
         $row = JTable::getInstance('Channel', 'Table');
         foreach ($cids as $cid) {
             $row->load($cid);
             $options = new JRegistry();
             $options->loadObject($row->attribs);
             $channel = JFBCFactory::provider($row->provider)->channel($row->type, $options);
             $post = new JRegistry();
             $post->set('message', $message);
             $post->set('link', $link);
             try {
                 $return = $channel->post($post);
             } catch (Exception $e) {
                 $return = false;
             }
             if (!$return) {
                 $response[] = JText::sprintf('COM_JFBCONNECT_CHANNELS_POST_FAILED_LABEL', $row->provider, $row->type);
             } else {
                 $response[] = $return;
             }
         }
         echo implode("<br/>", $response);
     }
     exit;
 }
Example #12
0
 static function &getEditorPluginConfig($namspace = 'config')
 {
     static $config;
     if (!isset($config)) {
         $path = CKEDITOR_LIBRARY;
         require_once $path . DS . 'plugins.php';
         require_once $path . DS . 'plugins' . DS . 'toolbarplugins.php';
         $config = new JRegistry();
         $pluginConfig = new JCKToolbarPlugins();
         $config->loadObject($pluginConfig);
         $data = $config->toObject();
         $properties = get_object_vars($data);
         foreach ($properties as $key => $value) {
             if (strpos('p' . $key, '_')) {
                 unset($data->{$key});
             }
         }
         //Forcibly remove the save plugin due to it causing the icon
         //to disappear in editor version 6.0.4+
         unset($data->save);
         return $config;
     }
     return $config;
 }
Example #13
0
File: map.php Project: Lothurm/J3.x
 private function getTheme()
 {
     static $theme;
     if (!isset($theme)) {
         $query = $this->_db->getQuery(true);
         $query->select(' jth.name AS theme ');
         $query->select(' jth.params ');
         $query->from(' #__joaktree_trees   jte ');
         $query->innerJoin(' #__joaktree_themes  jth ' . ' ON (jth.id = jte.theme_id) ');
         $query->where(' jte.id   = ' . (int) $this->params['tree_id'] . ' ');
         // retrieve the name
         $this->_db->setQuery($query);
         $tmp = $this->_db->loadObject();
         $theme = new JRegistry();
         // load parameters into registry object
         $theme->loadString($tmp->params, 'JSON');
         unset($tmp->params);
         // load the rest of the object into registry object
         $theme->loadObject($tmp);
     }
     return $theme;
 }
Example #14
0
 function beforeLoad(&$params)
 {
     //lets create JS object
     $javascript = new JCKJavascript();
     if ($this->_overwrite) {
         $javascript->addScriptDeclaration("editor.on( 'configLoaded', function()\r\n\t\t\t\t{\r\n\t\t\t\t\teditor.config.plugins = 'html5support,' + editor.config.plugins\r\n\t\t\t\t\tif(editor.config.extraPlugins)\r\n\t\t\t\t\t\teditor.config.extraPlugins += ',video,audio,uicolor,imagedragndrop,ie9selectionoverride';\r\n\t\t\t\t\telse \t\r\n\t\t\t\t\t\teditor.config.extraPlugins += 'video,audio,uicolor,imagedragndrop,ie9selectionoverride';\r\n\t\t\t\t\r\n\t\t\t\t\tif(editor.config.toolbar == 'Full')\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar toolbar = editor.config.toolbar_Full[editor.config.toolbar_Full.length-1];\r\n\t\t\t\t\t\tvar extra = ['Video','Audio','UIColor'];\r\n\t\t\t\t\t\teditor.config.toolbar_Full[editor.config.toolbar_Full.length-1] = toolbar.concat(extra);\r\n\t\t\t\t\t}\t\r\n\t\t\t\t});");
     }
     $config = JFactory::getConfig();
     $dbname = $config->get('db');
     $db = JFactory::getDBO();
     $query = "SELECT COUNT(1)\r\n\t\tFROM information_schema.tables \r\n\t\tWHERE table_schema = '" . $dbname . "' \r\n\t\tAND table_name = '" . $db->getPrefix() . "jcktoolbarplugins'";
     $db->setQuery($query);
     if (!$db->loadResult()) {
         return $javascript->toRaw();
     }
     $query = "SELECT COUNT(p.id) AS pcount,COUNT(tp.pluginid) AS tpcount FROM #__jckplugins p\r\n\t\tLEFT JOIN #__jcktoolbarplugins tp on tp.pluginid = p.id\r\n\t\tWHERE `name` IN('html5support','video','audio','uicolor') ";
     $db->setQuery($query);
     $info = $db->loadObject();
     if ($info && $info->tpcount) {
         return;
     }
     if (!$info->pcount) {
         $query = "INSERT INTO #__jckplugins (`title`,`name`,`type`,`row`,`published`,`editable`,`icon`,`iscore`,`params`, `parentid`) VALUES \r\n\t\t\t('','html5support','plugin',0,1,1,'',1,'',NULL)";
         $db->setQuery($query);
         if (!$db->query()) {
             return $javascript->toRaw();
         }
         $parentid = $db->insertid();
         $query = "INSERT INTO #__jckplugins (`title`,`name`,`type`,`row`,`published`,`editable`,`icon`,`iscore`,`params`, `parentid`) VALUES \r\n            ('Video','video','plugin',3,1,1,'images/icon.png',1,''," . $parentid . "),\t\r\n            ('Audio','audio','plugin',3,1,1,'images/icon.png',1,''," . $parentid . "),\t\r\n            ('UIColor','uicolor','plugin',3,1,1,'uicolor.gif',1,'',NULL),\t\r\n            ('','imagedragndrop','plugin',0,1,1,'',1,'',NULL),\r\n\t\t\t('','ie9selectionoverride','plugin',0,1,1,'',1,'',NULL)";
         $db->setQuery($query);
         if (!$db->query()) {
             return $javascript->toRaw();
         }
         $first = $db->insertid();
         $last = $first + 2;
         //get next layout row  details
         $query = "SELECT row as rowid,MAX(`ordering`) +1 AS rowordering FROM #__jcktoolbarplugins WHERE toolbarid = 1 \r\n                        GROUP BY row\r\n                        ORDER BY row DESC LIMIT 1";
         $db->setQuery($query);
         $rowDetail = $db->loadObject();
         $values = array();
         for ($i = $first; $i <= $last; $i++) {
             $values[] = '(1,' . $i . ',' . $rowDetail->rowid . ',' . $rowDetail->rowordering++ . ',1)';
         }
         $query = "INSERT INTO #__jcktoolbarplugins(toolbarid,pluginid,row,ordering,state) VALUES " . implode(",", $values);
         $db->setQuery($query);
         $db->query();
     }
     if ($this->_overwrite) {
         //Get toolbar plugins object
         jckimport('ckeditor.plugins');
         jckimport('ckeditor.plugins.toolbarplugins');
         $plugins = new JCKtoolbarPlugins();
         foreach (get_object_vars($plugins) as $key => $value) {
             if (strpos('p' . $key, '_')) {
                 unset($plugins->{$key});
             }
         }
         $plugins->html5support = 1;
         $plugins->video = 1;
         $plugins->audio = 1;
         $plugins->uicolor = 1;
         $plugins->imagedragndrop = 1;
         $plugins->ie9selectionoverride = 1;
         $config = new JRegistry('config');
         $config->loadObject($plugins);
         $cfgFile = '';
         $is1_6plus = file_exists(JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor');
         if ($is1_6plus) {
             $cfgFile = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor' . DS . 'plugins' . DS . 'toolbarplugins.php';
         } else {
             $cfgFile = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor' . DS . 'plugins' . DS . 'toolbarplugins.php';
         }
         // Get the config registry in PHP class format and write it to file
         if ($is1_6plus) {
             if (!JFile::write($cfgFile, $config->toString('PHP', array('class' => 'JCKToolbarPlugins extends JCKPlugins')))) {
                 return $javascript->toRaw();
             }
             //if fail then bail out
         } else {
             if (!JFile::write($cfgFile, $config->toString('PHP', 'config', array('class' => 'JCKToolbarPlugins extends JCKPlugins')))) {
                 return $javascript->toRaw();
             }
             //if fail then bail out
         }
         jckimport('ckeditor.toolbar');
         jckimport('ckeditor.toolbar.full');
         $toolbar = new JCKFull();
         //fix toolbar values or they will get wiped out
         foreach (get_object_vars($toolbar) as $k => $v) {
             if (is_null($v)) {
                 $toolbar->{$k} = '';
             }
             if ($k[0] == '_') {
                 $toolbar->{$k} = NULL;
             }
         }
         if (isset($toolbar->Video) || isset($toolbar->Audio) || isset($toolbar->UIColor)) {
             return false;
         }
         $toolbar->Video = '';
         $toolbar->Audio = '';
         $toolbar->UIColor = '';
         $toolbarConfig = new JRegistry('toolbar');
         $toolbarConfig->loadObject($toolbar);
         $filename = '';
         if ($is1_6plus) {
             $filename = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor' . DS . 'toolbar' . DS . 'full.php';
         } else {
             $filename = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor' . DS . 'toolbar' . DS . 'full.php';
         }
         // Get the config registry in PHP class format and write it to file
         if ($is1_6plus) {
             JFile::write($filename, $toolbarConfig->toString('PHP', array('class' => 'JCKFull extends JCKToolbar')));
         } else {
             JFile::write($filename, $toolbarConfig->toString('PHP', 'toolbar', array('class' => 'JCKFull extends JCKToolbar')));
         }
     }
     return $javascript->toRaw();
 }
 /**
  * Test the JRegistry::loadObject method.
  *
  * @covers  JRegistry::loadObject
  *
  * @return void
  */
 public function testLoadObject()
 {
     $object = new stdClass();
     $object->foo = 'testloadobject';
     $registry = new JRegistry();
     $result = $registry->loadObject($object);
     // Result is always true, no error checking in method.
     // Test getting a known value.
     $this->assertThat($registry->get('foo'), $this->equalTo('testloadobject'), 'Line: ' . __LINE__ . '.');
     // Test case from Tracker Issue 22444
     $registry = new JRegistry();
     $object = new JObject();
     $object2 = new JObject();
     $object2->set('test', 'testcase');
     $object->set('test', $object2);
     $this->assertTrue($registry->loadObject($object), 'Line: ' . __LINE__ . '. Should load object successfully');
 }
Example #16
0
 function getMenuContent($S5row)
 {
     global $flexmv;
     //return "<li><a href='#'>".$row->name."</a></li>";
     //silviu module code - start
     //$S5_menu_items_params = new JParameter( $S5row->params );
     $S5_menu_items_params = new JRegistry();
     if ($flexmv <= 2.5) {
         $S5_menu_items_params->loadJSON($S5row->params);
     } else {
         $S5_menu_items_params->loadObject($S5row->params);
     }
     $S5_load_mod = $S5_menu_items_params->get($flexmv <= 2.5 ? 's5_load_mod' : 'data.s5_load_mod');
     $S5_subtext = $S5_menu_items_params->get($flexmv <= 2.5 ? 's5_subtext' : 'data.s5_subtext');
     //retrieve the parent params
     //$S5_parent_items_params = new JParameter( $parent_params );
     $s5_group_child = $S5_menu_items_params->get($flexmv <= 2.5 ? 's5_group_child' : 'data.s5_group_child', 0);
     $S5_mod_array_orig = $S5_menu_items_params->get($flexmv <= 2.5 ? 's5_position' : 'data.s5_position');
     if (!is_array($S5_mod_array_orig)) {
         $S5_mod_array = array($S5_mod_array_orig);
     } else {
         $S5_mod_array = $S5_mod_array_orig;
     }
     //recreate the menu content with link on it
     //after that remove the link so the module content won't have link on it
     //$router 	= JSite::getRouter();
     //$S5row->url = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid='.$S5row->id : $S5row->link.'&Itemid='.$S5row->id;
     $S5row->url = $S5row->flink;
     if ($S5row->type == "separator") {
         $S5row->url = $S5row->link . 'javascript:;';
         //$router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid='.$pitem->id : $pitem->link.'javascript:;';
     }
     $tmp = $S5row;
     //$iParams = new JParameter($tmp->params);
     $iParams = new JRegistry();
     if ($flexmv <= 2.5) {
         $iParams->loadJSON($tmp->params);
     } else {
         $iParams->loadObject($tmp->params);
     }
     if ($iParams->get($flexmv <= 2.5 ? 'menu_image' : 'data.menu_image') && $iParams->get($flexmv <= 2.5 ? 'menu_image' : 'data.menu_image') != -1) {
         switch ($iParams->get($flexmv <= 2.5 ? 'menu_images_align' : 'data.menu_images_align', 0)) {
             case 0:
                 $imgalign = 'float:left;';
                 break;
             case 1:
                 $imgalign = 'float:right;';
                 break;
             default:
                 $imgalign = 'float:left;';
                 break;
         }
         switch ($tmp->browserNav) {
             default:
             case 0:
                 // _top
                 $image = '<span class="s5_img_span"><img style="' . $imgalign . 'cursor:pointer" src="' . $iParams->get($flexmv <= 2.5 ? 'menu_image' : 'data.menu_image') . '" onclick="window.document.location.href=\'' . $S5row->url . '\'" alt="' . $S5row->alias . '" /></span>';
                 break;
             case 1:
                 // _blank
                 $image = '<span class="s5_img_span"><img style="' . $imgalign . 'cursor:pointer" src="' . $iParams->get($flexmv <= 2.5 ? 'menu_image' : 'data.menu_image') . '" onclick="window.open(\'' . $S5row->url . '\')" alt="' . $S5row->alias . '" /></span>';
                 break;
             case 2:
                 // window.open
                 $image = '<span class="s5_img_span"><img style="' . $imgalign . 'cursor:pointer" src="' . $iParams->get($flexmv <= 2.5 ? 'menu_image' : 'data.menu_image') . '" onclick="window.open(\'' . $S5row->url . '\')" alt="' . $S5row->alias . '" /></span>';
                 break;
         }
         /*if($tmp->ionly){
           $tmp->name = null;
           }*/
     } else {
         $image = null;
     }
     /* silviu add new funcitonality to 1.7 version
      *  remove the menu title if param is set to 0 and menu image exists
      */
     if ($iParams->get($flexmv <= 2.5 ? 'menu_image' : 'data.menu_image') && $iParams->get($flexmv <= 2.5 ? 'menu_image' : 'data.menu_image') != -1 && $iParams->get($flexmv <= 2.5 ? 'menu_text' : 'data.menu_text') == 0) {
         $S5row->title = "";
     }
     switch ($tmp->browserNav) {
         default:
         case 0:
             // _top
             if (strstr($S5row->url, "#s5")) {
                 if ($S5row->title != "") {
                     $link_format = "<a href='#'    onclick=\"s5_page_scroll('" . $S5row->url . "')\"><span class='s5_sub_a_span'  onclick=\"s5_page_scroll('" . $S5row->url . "')\" >" . $S5row->title . "</span></a>";
                     if ($S5_subtext != "") {
                         $parent_subtext_flex = "<span class='S5_subtext' onclick=\"s5_page_scroll('" . $S5row->url . "')\" >" . $S5_subtext . "</span>";
                     } else {
                         $parent_subtext_flex = "";
                     }
                     break;
                 }
             } else {
                 $link_format = "<a href='{$S5row->url}'><span class='s5_sub_a_span' onclick='window.document.location.href=\"{$S5row->url}\"'>" . $S5row->title . "</span></a>";
                 if ($S5_subtext != "") {
                     $parent_subtext_flex = "<span class='S5_subtext' onclick='window.document.location.href=\"{$S5row->url}\"'>" . $S5_subtext . "</span>";
                 } else {
                     $parent_subtext_flex = "";
                 }
             }
             break;
         case 1:
             // _blank
             $link_format = "<a href='{$S5row->url}' target='_blank' onclick='this.removeAttribute(\"href\")'><span class='s5_sub_a_span' onclick='window.open(\"{$S5row->url}\")'>" . $S5row->title . "</span></a>";
             if ($S5_subtext != "") {
                 $parent_subtext_flex = "<span class='S5_subtext' onclick='window.open(\"{$S5row->url}\")'>" . $S5_subtext . "</span>";
             } else {
                 $parent_subtext_flex = "";
             }
             break;
         case 2:
             // window.open
             $attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes';
             //.$this->_params->get('window_open');
             // hrm...this is a bit dickey
             $link = $S5row->url;
             //str_replace('index.php', 'index2.php', $pitem->url);
             if ($S5_subtext != "") {
                 $parent_subtext_flex = '<span class="S5_subtext" onclick="window.open(\'' . $link . '\',\'targetWindow\',\'' . $attribs . '\');return false;">' . $S5_subtext . '</span>';
             } else {
                 $parent_subtext_flex = "";
             }
             $link_format = '<a href="' . $link . '" onclick="this.removeAttribute(\'href\')"><span class="s5_sub_a_span" onclick="window.open(this.href,\'targetWindow\',\'' . $attribs . '\');return false;">' . $S5row->title . '</span></a>';
             break;
     }
     if (is_array($S5_mod_array) && !empty($S5_mod_array) && $S5_load_mod == '1') {
         if (is_array($S5_mod_array)) {
             //if($group == 1){
             $s5_loaded_modules = array();
             //get the module content first
             foreach ($S5_mod_array as $S5_position_value) {
                 //get all the modules for this position
                 $all_position_modules = S5JModuleHelper::getModules($S5_position_value);
                 if (is_array($all_position_modules) && !empty($all_position_modules)) {
                     foreach ($all_position_modules as $s5_position_module) {
                         $s5_module_content = "";
                         //$module = S5JModuleHelper::getModule( 'mod_login', 'Login Form' );
                         if ($s5_position_module->module == 'mod_custom') {
                             $s5_module_content = S5JModuleHelper::getModule('custom', $s5_position_module->title);
                         } else {
                             $s5_module_content = S5JModuleHelper::getModule(strtolower(substr($s5_position_module->module, 4, strlen($s5_position_module->module))), $s5_position_module->title);
                         }
                         $attribs['style'] = 'xhtml';
                         //$yj_load_mod ='LOAD MODULE OR MODULES HERE';
                         $s5_loaded_modules[] = S5JModuleHelper::renderModule($s5_module_content, $attribs);
                     }
                 }
             }
             //recreate the menu content with link on it
             //after that remove the link so the module content won't have link on it
             $S5row->title = "<span class='S5_submenu_item'>" . $image . $link_format;
             //display the subtext
             if ($S5_subtext != "") {
                 $S5row->title .= $parent_subtext_flex;
                 //"<div class='S5_subtext'>".$S5_subtext."</div>";//<br />
             }
             $S5row->title .= "</span>";
             //<br />
             if (is_array($s5_loaded_modules) && !empty($s5_loaded_modules)) {
                 //display the Joomla menu content
                 $columns_group = $S5_menu_items_params->get($flexmv <= 2.5 ? 's5_columns' : 'data.s5_columns');
                 //display the child items grouped or not
                 if ($s5_group_child == 0) {
                     //not grouped means <ul><li>content</li></ul>
                     $S5row->title .= "<ul style='float:left;'><li>";
                     //  style='width:".$ul_width."%;
                 } else {
                     $S5row->title .= "<div class='S5_menu_module_parent_group'>";
                     //	$S5row->name .= "<div class='S5_menu_module_parent'>";
                     $S5row->title .= "<div class='S5_menu_module_group'>";
                 }
                 $k = 0;
                 $all_loaded_modules = count($s5_loaded_modules);
                 $rows_group = $columns_group > 0 ? ceil($all_loaded_modules / $columns_group) : 0;
                 for ($i = 0; $i < $rows_group; $i++) {
                     //check to see if we still have modules content to display
                     if (!empty($s5_loaded_modules)) {
                         $S5row->title .= "<div style='width:100%;'>";
                         for ($j = 0; $j < $columns_group; $j++) {
                             if (isset($s5_loaded_modules[$k])) {
                                 if ($all_loaded_modules > $columns_group) {
                                     $content_cell_width = 100 / intval($columns_group);
                                 } else {
                                     $content_cell_width = 100 / intval($all_loaded_modules);
                                 }
                                 $S5row->title .= "<div style='float:left; width:" . $content_cell_width . "%;'>" . $s5_loaded_modules[$k] . "</div>";
                                 //remove the displayed module content form the array
                                 unset($s5_loaded_modules[$k]);
                                 $k++;
                             }
                             //end if
                         }
                         //end for
                         $S5row->title .= "</div><div style='clear:both;'></div>";
                     }
                     //end if
                 }
                 //end for
                 //display the child items grouped or not
                 if ($s5_group_child == 0) {
                     //not grouped means <ul><li>content</li></ul>
                     $S5row->title .= "</li></ul>";
                     //  style='width:".$ul_width."%;
                 } else {
                     $S5row->title .= "</div>";
                     $S5row->title .= "</div>";
                 }
                 //}else{
                 //	$S5row->title = "";
             }
             //end if
             //}
             //new row to remove the link on the content if the content have module in it
             $S5row->module_content = 1;
             //$S5row->name = "<div class='S5_submenu_item'>".$S5row->name."</div>";
         } else {
             //display the Joomla menu content
             $columns_group = $S5_menu_items_params->get($flexmv <= 2.5 ? 's5_columns' : 'data.s5_columns');
             //recreate the menu content with link on it
             //after that remove the link so the module content won't have link on it
             $S5row->title = $image . $link_format;
             //display the subtext
             if ($S5_subtext != "") {
                 $S5row->title .= $parent_subtext_flex;
                 //"<div class='S5_subtext'>".$S5_subtext."</div>";//<br />
             }
             $S5row->title .= "<div class='S5_menu_module_parent_group'>";
             //	$S5row->name .= "<div class='S5_menu_module_parent'>";
             $S5_module_to_load = $S5_mod_array;
             $S5_module_to_load2 = S5modMainMenuHelper::getModule($S5_module_to_load);
             $module_menu_content = trim(S5JModuleHelper::renderModule($S5_module_to_load2, array('style' => "xhtml")));
             if (isset($S5_mod_with[0]) && $S5_mod_with[0] > 0) {
                 $S5row->title .= "<div class='S5_menu_module' style='width:" . $S5_mod_with[0] . "px;'>" . $module_menu_content . "</div>";
             } else {
                 $S5row->title .= "<div class='S5_menu_module'>" . $module_menu_content . "</div>";
             }
             $S5row->title .= "</div>";
             //$S5row->name = str_replace(array('<ul>', '</ul>'), '', $S5row->name);
             //$S5row->name = str_replace(array('<li>', '</li>'), '', $S5row->name);
             //$S5row->name = str_replace(array('<p>', '</p>'), '', $S5row->name);
             //$S5row->name = preg_replace("/<ul(.*)>/", "", $S5row->name);
             //$S5row->name = preg_replace("/<li(.*)>/", "", $S5row->name);
             //$S5row->name = preg_replace("/<p(.*)>/", "<br />", $S5row->name);
             //new row to remove the link on the content if the content have module in it
             $S5row->module_content = 1;
             $S5row->title = "<span class='S5_submenu_item'>" . $S5row->title . "</span>";
         }
     } else {
         $temp = "";
         //$row->name = $links[$links_id];
         if ($S5_subtext != "") {
             //display the subtext
             $temp = $image . $link_format . $parent_subtext_flex;
             //<br />
         } else {
             //$temp =  "<div>".$image.$row->name."</div>";
             $temp = $image . $link_format;
         }
         $S5row->title = $temp;
         //$row->name."\n"."<div class=\"subtext\">".$text."</div>";
         //new row to remove the link on the content if the content have module in it
         $S5row->module_content = 0;
         $S5row->title = "<span class='S5_submenu_item'>" . $S5row->title . "</span>";
     }
     //silviu module code - end
     return $S5row->title;
 }
Example #17
0
 public static function copy()
 {
     // Initialize some variables
     $input = JFactory::getApplication()->input;
     $template = $input->getCmd('template');
     $original = $input->getCmd('original');
     $layout = $input->getCmd('layout');
     //safe name
     $layout = JApplication::stringURLSafe($layout);
     if (!$template || !$original || !$layout) {
         return self::error(JText::_('T3_LAYOUT_INVALID_DATA_TO_SAVE'));
     }
     // clone to CUSTOM dir
     $source = T3Path::getPath('tpls/' . $original . '.php');
     $dest = T3Path::getLocalPath('tpls/' . $layout . '.php');
     $confsource = T3Path::getPath('etc/layout/' . $layout . '.ini');
     $confdest = T3Path::getLocalPath('etc/layout/' . $layout . '.ini');
     $params = new JRegistry();
     $params->loadObject($_POST);
     $data = $params->toString('INI');
     if (!is_dir(dirname($confdest))) {
         JFolder::create(dirname($confdest));
     }
     if (!is_dir(dirname($dest))) {
         JFolder::create(dirname($dest));
     }
     if ($data && !@JFile::write($confdest, $data)) {
         return self::error(JText::_('T3_LAYOUT_OPERATION_FAILED'));
     }
     // Check if original file exists
     if (JFile::exists($source)) {
         // Check if the desired file already exists
         if (!JFile::exists($dest)) {
             if (!JFile::copy($source, $dest)) {
                 return self::error(JText::_('T3_LAYOUT_OPERATION_FAILED'));
             }
             //clone configuration file, we only copy if the target file does not exist
             if (!JFile::exists($confdest) && JFile::exists($confsource)) {
                 JFile::copy($confsource, $confdest);
             }
         } else {
             return self::error(JText::_('T3_LAYOUT_EXISTED'));
         }
     } else {
         return self::error(JText::_('T3_LAYOUT_NOT_FOUND'));
     }
     return self::response(array('successful' => JText::_('T3_LAYOUT_SAVE_SUCCESSFULLY'), 'original' => $original, 'layout' => $layout, 'type' => 'clone'));
 }
Example #18
0
 function getPageSpeed($url)
 {
     require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'classes' . DS . 'config.php';
     $url = str_replace("/administrator", "", JFactory::getURI()->base()) . $url;
     $config = SEFConfig::getConfig();
     $ndata = new stdClass();
     if (strlen($config->google_apikey) == 0) {
         return false;
     }
     $google_url = 'https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url=' . urlencode($url) . '&key=' . $config->google_apikey;
     if (function_exists('curl_init')) {
         $c = curl_init($google_url);
         curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($c, CURLOPT_ENCODING, "utf-8");
         $data = curl_exec($c);
         curl_close($c);
     } else {
         // Try to use our own method
         $data = SEFTools::PostRequest($google_url, null, null, 'get');
         if ($data !== false) {
             $data = $data->content;
         }
     }
     if ($data === false) {
         // Could not connect
         return false;
     }
     $data = json_decode($data);
     $ndata = new stdClass();
     if (isset($data->error)) {
         $ndata->message = $data->error->errors[0]->message;
         return $ndata;
     }
     @($ndata->pageStats = $data->pageStats);
     @($ndata->score = $data->score);
     $reg = new JRegistry();
     $reg->loadObject($ndata);
     return $reg->toString("ini");
 }
Example #19
0
 /**
  *
  * Get params of menu item
  *
  * @param Number $id
  */
 public static function getMenuParams($id)
 {
     $menuSite = JMenu::getInstance('site');
     $Item = $menuSite->getItem($id);
     if (isset($Item->params)) {
         if ($Item->params instanceof JRegistry) {
             return $Item->params;
         }
     }
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select("params");
     $query->from("#__menu");
     $query->where("id = " . $db->quote($id));
     $db->setQuery($query);
     $paramsString = $db->loadResult();
     $jParams = new JRegistry();
     $jParams->loadObject(json_decode($paramsString));
     return $jParams;
 }
Example #20
0
 /**
  * A JParameter object holding the parameters for the plugin
  *
  * @var		A JParameter object
  * @access	public
  * @since	1.5
  */
 function onSave($plugin, $pluginToolbarnames)
 {
     if (!$this->canDo->get('core.edit')) {
         $this->app->redirect(JRoute::_('index.php?option=com_jckman&view=list', false), JText::_('COM_JCKMAN_PLUGIN_PERM_NO_SAVE'), 'error');
         return false;
     }
     require_once CKEDITOR_LIBRARY . DS . 'toolbar.php';
     $CKfolder = CKEDITOR_LIBRARY . DS . 'toolbar';
     jckimport('helper');
     $toolbarnames = JCKHelper::getEditorToolbars();
     if (!empty($toolbarnames)) {
         foreach ($toolbarnames as $toolbarname) {
             $tmpfilename = $CKfolder . DS . $toolbarname . '.php';
             require $tmpfilename;
             $classname = 'JCK' . ucfirst($toolbarname);
             $toolbar = new $classname();
             if (!$plugin->title) {
                 //publish or unpblish plugin
                 $this->onPublish(array($plugin->id), $plugin->published);
                 return;
             }
             $pluginTitle = str_replace(' ', '', $plugin->title);
             $pluginTitle = $pluginTitle;
             //fix toolbar values or they will get wiped out
             foreach (get_object_vars($toolbar) as $k => $v) {
                 if (is_null($v)) {
                     $toolbar->{$k} = '';
                 }
                 if ($k[0] == '_') {
                     $toolbar->{$k} = NULL;
                 }
             }
             $toolbar->{$pluginTitle} = NULL;
             if (!empty($pluginToolbarnames) && in_array($toolbarname, $pluginToolbarnames)) {
                 $toolbar->{$pluginTitle} = '';
             }
             $toolbarConfig = new JRegistry('toolbar');
             $toolbarConfig->loadObject($toolbar);
             // Get the config registry in PHP class format and write it to file
             if (!JFile::write($tmpfilename, $toolbarConfig->toString('PHP', array('class' => $classname . ' extends JCKToolbar')))) {
                 JCKHelper::error(JText::sprintf('COM_JCK_PLUGIN_LIST_FAILED_TO_MODIFY_TOOLBAR', $pname, $classname));
             }
         }
         //layout stuff
         $cids = array(0);
         $db = JFactory::getDBO();
         if (!empty($pluginToolbarnames)) {
             $values = array();
             foreach ($pluginToolbarnames as $plugintoolbarname) {
                 $query = 'SELECT id' . ' FROM #__jcktoolbars' . ' WHERE name = "' . $plugintoolbarname . '"';
                 $db->setQuery($query);
                 $toolbarid = $db->loadResult();
                 if ($toolbarid) {
                     $rowDetail = JCKHelper::getNextLayoutRow($toolbarid);
                     $values[] = '(' . $toolbarid . ',' . $plugin->id . ',' . $rowDetail->rowid . ',' . $rowDetail->rowordering . ',1)';
                     $cids[] = $toolbarid;
                 }
             }
         }
         //First remove plugin from every layout that has not been selected
         $query = 'DELETE FROM #__jcktoolbarplugins' . ' WHERE pluginid =' . $plugin->id . ' AND toolbarid NOT IN (' . implode(',', $cids) . ')';
         $db->setQuery($query);
         if (!$db->query()) {
             JCKHelper::error($db->getErrorMsg());
         }
         //Now add plugin to selected layouts
         if (!empty($values)) {
             $query = 'INSERT INTO #__jcktoolbarplugins(toolbarid,pluginid,row,ordering,state) VALUES ' . implode(',', $values) . ' ON DUPLICATE KEY UPDATE toolbarid = VALUES(toolbarid),pluginid = VALUES(pluginid)';
             $db->setQuery($query);
             if (!$db->query()) {
                 JCKHelper::error($db->getErrorMsg());
             }
         }
     }
     //publish or unpblish plugin
     $this->onPublish(array($plugin->id), $plugin->published);
 }
Example #21
0
 /**
  * Create a configuration object
  *
  * @param   string  $file       The path to the configuration file.
  * @param   string  $type       The type of the configuration file.
  * @param   string  $namespace  The namespace of the configuration file.
  *
  * @return  JRegistry
  *
  * @see     JRegistry
  * @since   11.1
  */
 protected static function createConfig($file, $type = 'PHP', $namespace = '')
 {
     if (is_file($file)) {
         include_once $file;
     }
     // Create the registry with a default namespace of config
     $registry = new JRegistry();
     // Sanitize the namespace.
     $namespace = ucfirst((string) preg_replace('/[^A-Z_]/i', '', $namespace));
     // Build the config name.
     $name = 'JConfig' . $namespace;
     // Handle the PHP configuration type.
     if ($type == 'PHP' && class_exists($name)) {
         // Create the JConfig object
         $config = new $name();
         // Load the configuration values into the registry
         $registry->loadObject($config);
     }
     return $registry;
 }
Example #22
0
 function passAll(&$params, $match_method = 'and', $article = 0)
 {
     if (empty($params)) {
         return 1;
     }
     jimport('joomla.filesystem.file');
     $app = JFactory::getApplication();
     $this->_params = $this->getRequestParams();
     // if no id is found, check if menuitem exists to get view and id
     if ($app->isSite() && (!$this->_params->option || !$this->_params->id)) {
         $menu = JSite::getMenu();
         if (empty($this->_params->Itemid)) {
             $menuItem = $menu->getActive();
         } else {
             $menuItem = $menu->getItem($this->_params->Itemid);
         }
         if (!$this->_params->option) {
             $this->_params->option = empty($menuItem->query['option']) ? null : $menuItem->query['option'];
         }
         $this->_params->view = empty($menuItem->query['view']) ? null : $menuItem->query['view'];
         $this->_params->task = empty($menuItem->query['task']) ? null : $menuItem->query['task'];
         if (!$this->_params->id) {
             $this->_params->id = empty($menuItem->query['id']) ? null : $menuItem->query['id'];
         }
         unset($menuItem);
     }
     $aid = $article && isset($article->id) ? '[' . $article->id . ']' : '';
     $registry = new JRegistry();
     $registry->loadArray($params);
     $id = md5($aid . $registry->toString());
     if (isset($this->_passes[$id])) {
         $pass = $this->_passes[$id];
     } else {
         $pass = $match_method == 'and' ? 1 : 0;
         foreach ($this->_types as $type) {
             if (isset($params[$type])) {
                 $this->initParams($params[$type], $type);
                 if ($pass && $match_method == 'and' || !$pass && $match_method == 'or') {
                     $registry = new JRegistry();
                     $registry->loadObject($params[$type]);
                     $tid = md5($type . $aid . ':' . $registry->toString());
                     if (isset($this->_passes[$tid])) {
                         $pass = $this->_passes[$tid];
                     } else {
                         if ($params[$type]->assignment == 'all') {
                             $pass = 1;
                         } else {
                             if ($params[$type]->assignment == 'none') {
                                 $pass = 0;
                             } else {
                                 if (!isset($this->_classes[$this->maintype]) && JFile::exists(dirname(__FILE__) . '/assignments/' . strtolower($this->maintype) . '.php')) {
                                     require_once dirname(__FILE__) . '/assignments/' . strtolower($this->maintype) . '.php';
                                     $class = 'NNFrameworkAssignments' . $this->maintype;
                                     $this->_classes[$this->maintype] = new $class();
                                 }
                                 if (isset($this->_classes[$this->maintype])) {
                                     $func = 'pass' . $type;
                                     $pass = $this->_classes[$this->maintype]->{$func}($this, $params[$type]->params, $params[$type]->selection, $params[$type]->assignment, $article);
                                 }
                             }
                         }
                         $this->_passes[$tid] = $pass;
                     }
                 }
             }
         }
         $this->_passes[$id] = $pass;
     }
     return $pass ? 1 : 0;
 }
Example #23
0
 protected static function _createPJUpdateConfig($file, $namespace)
 {
     jimport('joomla.registry.registry');
     if (is_file($file)) {
         include_once $file;
     }
     // Create the registry with a default namespace of config
     $registry = new JRegistry();
     // Build the config name.
     $name = 'PJConfig' . $namespace;
     // Handle the PHP configuration type.
     if (class_exists($name)) {
         // Create the JConfig object
         $config = new $name();
         // Load the configuration values into the registry
         $registry->loadObject($config);
     }
     return $registry;
 }
Example #24
0
 private function _updateConfig()
 {
     $config = JFactory::getConfig();
     $dbname = $config->get('db');
     $db = JFactory::getDBO();
     $query = "SELECT COUNT(1)\n\t\tFROM information_schema.tables \n\t\tWHERE table_schema = '" . $dbname . "' \n\t\tAND table_name = '" . $db->getPrefix() . "jcktoolbarplugins'";
     $db->setQuery($query);
     if (!$db->loadResult()) {
         return false;
     }
     //bail out
     $query = "SELECT COUNT(p.id) AS pcount,COUNT(tp.pluginid) AS tpcount FROM #__jckplugins p\n\t\tLEFT JOIN #__jcktoolbarplugins tp on tp.pluginid = p.id\n\t\tWHERE `name` IN('html5support','video','audio','uicolor') ";
     $db->setQuery($query);
     $info = $db->loadObject();
     if ($info && $info->tpcount) {
         return true;
     }
     if (!$info->pcount) {
         $query = "INSERT INTO #__jckplugins (`title`,`name`,`type`,`row`,`published`,`editable`,`icon`,`iscore`,`params`, `parentid`) VALUES \n\t\t\t('','html5support','plugin',0,1,1,'',1,'',NULL)";
         $db->setQuery($query);
         if (!$db->query()) {
             return false;
         }
         $parentid = $db->insertid();
         $query = "INSERT INTO #__jckplugins (`title`,`name`,`type`,`row`,`published`,`editable`,`icon`,`iscore`,`params`, `parentid`) VALUES \n\t\t\t('Video','video','plugin',3,1,1,'images/icon.png',1,''," . $parentid . "),\t\n\t\t\t('Audio','audio','plugin',3,1,1,'images/icon.png',1,''," . $parentid . "),\t\n\t\t\t('UIColor','uicolor','plugin',3,1,1,'uicolor.gif',1,'',NULL),\n\t\t\t('','imagedragndrop','plugin',0,1,1,'',1,'',NULL),\n\t\t\t('','ie9selectionoverride','plugin',0,1,1,'',1,'',NULL)";
         $db->setQuery($query);
         if (!$db->query()) {
             return false;
         }
         $first = $db->insertid();
     } else {
         $query = 'SELECT `id` FROM #__jckplugins WHERE name = "video"';
         $db->setQuery($query);
         $first = $db->loadResult();
     }
     //end if
     $last = $first + 2;
     //get next layout row  details
     $query = "SELECT row as rowid,MAX(`ordering`) +1 AS rowordering FROM #__jcktoolbarplugins WHERE toolbarid = 1 \n\t\t\t\t\t GROUP BY row\n\t\t\t\t\t ORDER BY row DESC LIMIT 1";
     $db->setQuery($query);
     $rowDetail = $db->loadObject();
     //Only insert data in to the __jcktoolbarplugins if upgrading from old version.
     if (!$rowDetails) {
         return true;
     }
     //end if
     $values = array();
     for ($i = $first; $i <= $last; $i++) {
         $values[] = '(1,' . $i . ',' . $rowDetail->rowid . ',' . $rowDetail->rowordering++ . ',1)';
     }
     $query = "INSERT INTO #__jcktoolbarplugins(toolbarid,pluginid,row,ordering,state) VALUES " . implode(",", $values);
     $db->setQuery($query);
     $db->query();
     jimport('joomla.filesystem.file');
     if ($this->_overwrite) {
         //Get toolbar plugins object
         if (defined('JLEGACY_CMS')) {
             $path = JPATH_PLUGINS . '/editors/jckeditor/includes/ckeditor';
         } else {
             $path = JPATH_PLUGINS . '/editors/jckeditor/jckeditor/includes/ckeditor';
         }
         require $path . '/plugins.php';
         require $path . '/plugins/toolbarplugins.php';
         $plugins = new JCKtoolbarPlugins();
         foreach (get_object_vars($plugins) as $key => $value) {
             if (strpos('p' . $key, '_')) {
                 unset($plugins->{$key});
             }
         }
         $plugins->html5support = 1;
         $plugins->video = 1;
         $plugins->audio = 1;
         $plugins->uicolor = 1;
         $plugins->imagedragndrop = 1;
         $plugins->ie9selectionoverride = 1;
         $config = new JRegistry('config');
         $config->loadObject($plugins);
         $cfgFile = $path . '/plugins/toolbarplugins.php';
         // Get the config registry in PHP class format and write it to file
         if (!defined('JLEGACY_CMS')) {
             if (!JFile::write($cfgFile, $config->toString('PHP', array('class' => 'JCKToolbarPlugins extends JCKPlugins')))) {
                 return false;
             }
             //if fail then bail out
         } else {
             if (!JFile::write($cfgFile, $config->toString('PHP', 'config', array('class' => 'JCKToolbarPlugins extends JCKPlugins')))) {
                 return false;
             }
             //if fail then bail out
         }
         require $path . '/toolbar.php';
         require $path . '/toolbar/full.php';
         $toolbar = new JCKFull();
         //fix toolbar values or they will get wiped out
         foreach (get_object_vars($toolbar) as $k => $v) {
             if (is_null($v)) {
                 $toolbar->{$k} = '';
             }
             if ($k[0] == '_') {
                 $toolbar->{$k} = NULL;
             }
         }
         $toolbar->Video = '';
         $toolbar->Audio = '';
         $toolbar->UIColor = '';
         $toolbarConfig = new JRegistry('toolbar');
         $toolbarConfig->loadObject($toolbar);
         $filename = $path . '/toolbar/full.php';
         // Get the config registry in PHP class format and write it to file
         if (!defined('JLEGACY_CMS')) {
             if (!JFile::write($filename, $toolbarConfig->toString('PHP', array('class' => 'JCKFull extends JCKToolbar')))) {
                 return false;
             }
         } else {
             if (!JFile::write($filename, $toolbarConfig->toString('PHP', 'toolbar', array('class' => 'JCKFull extends JCKToolbar')))) {
                 return false;
             }
         }
     }
     return true;
 }
 /**
  * Method to delete one or more overrides
  *
  * @param		array		Array of keys to delete
  *
  * @return	int			Number of successfully deleted overrides, boolean false if an error occured
  *
  * @since		2.5
  */
 public function delete($cids)
 {
     // Check permissions first
     if (!JFactory::getUser()->authorise('core.delete', 'com_languages')) {
         $this->setError(JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'));
         return false;
     }
     jimport('joomla.filesystem.file');
     require_once JPATH_COMPONENT . '/helpers/languages.php';
     $app = JFactory::getApplication();
     // Parse the override.ini file in oder to get the keys and strings
     $filename = constant('JPATH_' . strtoupper($this->getState('filter.client'))) . DS . 'language' . DS . 'overrides' . DS . $this->getState('filter.language') . '.override.ini';
     $strings = LanguagesHelper::parseFile($filename);
     // Unset strings that shall be deleted
     foreach ($cids as $key) {
         if (isset($strings[$key])) {
             unset($strings[$key]);
         }
     }
     foreach ($strings as $key => $string) {
         $strings[$key] = str_replace('"', '"_QQ_"', $string);
     }
     // Write override.ini file with the left strings
     $registry = new JRegistry();
     $registry->loadObject($strings);
     $filename = constant('JPATH_' . strtoupper($this->getState('filter.client'))) . DS . 'language' . DS . 'overrides' . DS . $this->getState('filter.language') . '.override.ini';
     if (!JFile::write($filename, $registry->toString('INI'))) {
         return false;
     }
     $this->cleanCache();
     return count($cids);
 }
Example #26
0
 function _createEditorToolbar($id, $name, $oldname)
 {
     require_once CKEDITOR_LIBRARY . DS . 'toolbar.php';
     $CKfolder = CKEDITOR_LIBRARY . DS . 'toolbar';
     $newfilename = $CKfolder . DS . $name . '.php';
     $oldfilename = $CKfolder . DS . $oldname . '.php';
     $classname = 'JCK' . ucfirst($name);
     $toolbar = new stdclass();
     $toolbarConfig = new JRegistry('toolbar');
     $db = JFactory::getDBO();
     $query = 'SELECT tp.pluginid AS id,p.title,tp.row' . ' FROM #__jcktoolbarplugins tp' . ' LEFT JOIN #__jckplugins p ON p.id = tp.pluginid' . ' WHERE tp.state = 1' . ' AND tp.toolbarid = ' . $id . ' ORDER BY tp.row ASC,tp.ordering ASC';
     $db->setQuery($query);
     $toolbarplugins = $db->loadObjectList();
     if ($toolbarplugins) {
         foreach ($toolbarplugins as $plugin) {
             if ($plugin->id < 0) {
                 $property = 'brk_' . $plugin->id * -1;
                 $toolbar->{$property} = $plugin->row;
             } else {
                 $property = $plugin->title;
                 $toolbar->{$property} = $plugin->row;
             }
         }
     }
     $toolbarConfig->loadObject($toolbar);
     // Get the config registry in PHP class format and write it to file
     $buffer = $toolbarConfig->toString('PHP', array('class' => $classname . ' extends JCKToolbar'));
     if (!JFile::write($oldfilename, $buffer)) {
         JCKHelper::error(JText::sprintf('COM_JCKMAN_LAYOUT_MANAGER_FAILED_WRITE_FILE', $classname));
     }
     if ($newfilename != $oldfilename) {
         if (!JFile::move($oldfilename, $newfilename)) {
             JCKHelper::error(JText::sprintf('COM_JCKMAN_LAYOUT_MANAGER_FAILED_WRITE_FILE', $classname));
         }
     }
 }
Example #27
0
 function processModule($id, $chrome = 'none', $ignores = array(), $overrides = array(), $area = 'articles')
 {
     $ignore_access = isset($ignores['ignore_access']) ? $ignores['ignore_access'] : $this->params->ignore_access;
     $ignore_state = isset($ignores['ignore_state']) ? $ignores['ignore_state'] : $this->params->ignore_state;
     $ignore_assignments = isset($ignores['ignore_assignments']) ? $ignores['ignore_assignments'] : $this->params->ignore_assignments;
     $ignore_caching = isset($ignores['ignore_caching']) ? $ignores['ignore_caching'] : $this->params->ignore_caching;
     $db = JFactory::getDBO();
     $query = $db->getQuery(true)->select('m.*')->from('#__modules AS m')->where('m.client_id = 0');
     if (is_numeric($id)) {
         $query->where('m.id = ' . (int) $id);
     } else {
         $query->where('m.title = ' . $db->quote(nnText::html_entity_decoder($id)));
     }
     if (!$ignore_access) {
         $query->where('m.access IN (' . implode(',', $this->aid) . ')');
     }
     if (!$ignore_state) {
         $query->where('m.published = 1')->join('LEFT', '#__extensions AS e ON e.element = m.module AND e.client_id = m.client_id')->where('e.enabled = 1');
     }
     if (!$ignore_assignments) {
         $date = JFactory::getDate();
         $now = $date->toSql();
         $nullDate = $db->getNullDate();
         $query->where('(m.publish_up = ' . $db->quote($nullDate) . ' OR m.publish_up <= ' . $db->quote($now) . ')')->where('(m.publish_down = ' . $db->quote($nullDate) . ' OR m.publish_down >= ' . $db->quote($now) . ')');
     }
     $query->order('m.ordering');
     $db->setQuery($query);
     $module = $db->loadObject();
     if ($module && !$ignore_assignments) {
         $this->applyAssignments($module);
     }
     if (empty($module)) {
         if ($this->params->place_comments) {
             return $this->params->message_start . JText::_('MA_OUTPUT_REMOVED_NOT_PUBLISHED') . $this->params->message_end;
         }
         return '';
     }
     //determine if this is a custom module
     $module->user = substr($module->module, 0, 4) == 'mod_' ? 0 : 1;
     // set style
     $module->style = $chrome;
     if ($area == 'articles' && !$ignore_caching || !empty($overrides)) {
         $json = $module->params && substr(trim($module->params), 0, 1) == '{';
         if ($json) {
             $params = json_decode($module->params);
         } else {
             // Old ini style. Needed for crappy old style modules like swMenuPro
             $params = JRegistryFormat::getInstance('INI')->stringToObject($module->params);
         }
         // override module parameters
         if (!empty($overrides)) {
             foreach ($overrides as $key => $val) {
                 if (isset($module->{$key})) {
                     $module->{$key} = $val;
                 } else {
                     if ($val && $val['0'] == '[' && $val[strlen($val) - 1] == ']') {
                         $val = json_decode('{"val":' . $val . '}');
                         $val = $val->val;
                     } else {
                         if (isset($params->{$key}) && is_array($params->{$key})) {
                             $val = explode(',', $val);
                         }
                     }
                     $params->{$key} = $val;
                 }
             }
             if ($json) {
                 $module->params = json_encode($params);
             } else {
                 $registry = new JRegistry();
                 $registry->loadObject($params);
                 $module->params = $registry->toString('ini');
             }
         }
     }
     if (isset($module->access) && !in_array($module->access, $this->aid)) {
         if ($this->params->place_comments) {
             return $this->params->message_start . JText::_('MA_OUTPUT_REMOVED_ACCESS') . $this->params->message_end;
         }
         return '';
     }
     $document = clone JFactory::getDocument();
     $document->_type = 'html';
     $renderer = $document->loadRenderer('module');
     $html = $renderer->render($module, array('style' => $chrome, 'name' => ''));
     // don't return html on article level when caching is set
     if ($area == 'articles' && !$ignore_caching && (isset($params->cache) && !$params->cache || isset($params->owncache) && !$params->owncache)) {
         return 'MA_IGNORE';
     }
     return $html;
 }
 public static function enablePreviewMode()
 {
     $configs = array('template_positions_display' => 1);
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select("params");
     $query->from("#__extensions");
     $query->where("name = " . $db->quote('com_templates'));
     $db->setQuery($query);
     $paramsString = $db->loadResult();
     if (!empty($paramsString)) {
         $jParams = new JRegistry();
         $jParams->loadObject(json_decode($paramsString));
         $params = $jParams->toArray();
         foreach ($configs as $k => $val) {
             $params[$k] = (string) $val;
         }
     } else {
         $params = array();
         foreach ($configs as $k => $val) {
             $params[$k] = (string) $val;
         }
     }
     $query->clear();
     $query->select("extension_id");
     $query->from("#__extensions");
     $query->where("name = " . $db->quote('com_templates'));
     $db->setQuery($query);
     $extID = $db->loadResult();
     $query->clear();
     $query->update($db->quoteName('#__extensions'));
     $query->set($db->quoteName('params') . ' = ' . $db->quote((string) json_encode($params)));
     $query->where($db->quoteName('name') . ' = ' . $db->quote('com_templates'));
     $query->where($db->quoteName('extension_id') . ' = ' . $db->quote((int) $extID));
     $query->where($db->quoteName('type') . ' = ' . $db->quote('component'));
     $db->setQuery($query);
     $db->execute();
     return true;
 }
Example #29
0
 /**
  * Create a configuration object
  *
  * @access private
  * @param string	The path to the configuration file
  * @param string	The type of the configuration file
  * @return object JRegistry
  * @since 1.5
  */
 private static function &_createConfig($file, $type = 'PHP')
 {
     jimport('joomla.registry.registry');
     require_once $file;
     // Create the registry with a default namespace of config
     $registry = new JRegistry('config');
     // Create the JConfig object
     $config = new JFrameworkConfig();
     // Load the configuration values into the registry
     $registry->loadObject($config);
     return $registry;
 }
Example #30
0
 /**
  * Method to save the form data.
  *
  * @param   	array		$data							The form data.
  * @param   	boolean	$opposite_client	Indicates whether the override should not be created for the current client
  *
  * @return  boolean  True on success, false otherwise.
  *
  * @since		2.5
  */
 public function save($data, $opposite_client = false)
 {
     $app = JFactory::getApplication();
     require_once JPATH_COMPONENT . '/helpers/languages.php';
     jimport('joomla.filesystem.file');
     $client = $app->getUserState('com_languages.overrides.filter.client', 0);
     $language = $app->getUserState('com_languages.overrides.filter.language', 'en-GB');
     // If the override should be created for both
     if ($opposite_client) {
         $client = 1 - $client;
     }
     $client = $client ? 'administrator' : 'site';
     // Parse the override.ini file in oder to get the keys and strings
     $filename = constant('JPATH_' . strtoupper($client)) . '/language/overrides/' . $language . '.override.ini';
     $strings = LanguagesHelper::parseFile($filename);
     if (isset($strings[$data['id']])) {
         // If an existent string was edited check whether
         // the name of the constant is still the same
         if ($data['key'] == $data['id']) {
             // If yes, simply override it
             $strings[$data['key']] = $data['override'];
         } else {
             // If no, delete the old string and prepend the new one
             unset($strings[$data['id']]);
             $strings = array($data['key'] => $data['override']) + $strings;
         }
     } else {
         // If it is a new override simply prepend it
         $strings = array($data['key'] => $data['override']) + $strings;
     }
     foreach ($strings as $key => $string) {
         $strings[$key] = str_replace('"', '"_QQ_"', $string);
     }
     // Write override.ini file with the strings
     $registry = new JRegistry();
     $registry->loadObject($strings);
     $reg = $registry->toString('INI');
     if (!JFile::write($filename, $reg)) {
         return false;
     }
     // If the override should be stored for both clients save
     // it also for the other one and prevent endless recursion
     if (isset($data['both']) && $data['both'] && !$opposite_client) {
         return $this->save($data, true);
     }
     return true;
 }