コード例 #1
0
ファイル: JSimpleXMLTest.php プロジェクト: realityking/JAJAX
	/**
	 * Testing testLoadFile().
	 *
	 * @param string Path to xml
	 * @param bool   Result of load
	 * @param string Class of result
	 *
	 * @return void
	 * @dataProvider casesLoadFile
	 */
	public function testLoadFile( $path, $expected, $class )
	{
		$this->assertThat(
			is_null($this->object->document),
			$this->isTrue()
		);
		$this->assertThat(
			$this->object->loadFile($path),
			$this->equalTo($expected)
		);
		if (!is_null($class))
		{
			$this->assertThat(
				$this->object->document,
				$this->isInstanceOf($class)
			);
		}
		else
		{
			$this->assertThat(
				$this->object->document,
				$this->isNull()
			);
		}
	}
コード例 #2
0
ファイル: helper.php プロジェクト: Roma48/abazherka_old
 public function __construct($module, $params)
 {
     // put the module params to the $config variable
     $this->config = $params->toArray();
     // if the user set engine mode to Mootools
     if ($this->config['engine_mode'] == 'mootools') {
         // load the MooTools framework to use with the module
         JHtml::_('behavior.framework', true);
     } else {
         if ($this->config['include_jquery'] == 1) {
             // if the user specify to include the jQuery framework - load newest jQuery 1.7.*
             $doc = JFactory::getDocument();
             $doc->addScript('https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js');
         }
     }
     // set the active tab
     $this->active_tab = 1;
     // initializing the tabs array
     $this->tabs = array("content" => array(), "title" => array(), "type" => array(), "id" => array(), "animation" => array());
     // getting module ID
     $this->config['module_id'] = $this->config['automatic_module_id'] == 1 ? 'gk-tabs-' . $module->id : $params->get('module_id', 'gk-tabs-1');
     // check the data source type
     if ($this->config['module_data_source'] == 'tabsmanager') {
         // parse JSON data if it comes from the tabs manager
         $this->config['tabs_data'] = json_decode($this->config['tabs_data']);
     } else {
         // check the type of the source file
         if ($this->config['external_source'] == -1) {
             // if there is no selected files - set the tabs_data to blank array
             $this->config['tabs_data'] = array();
         } else {
             // if it is a JSON file
             if (stripos($this->config['external_source'], '.json') !== FALSE) {
                 // read the file content
                 $json_content = file_get_contents(JPATH_ROOT . DS . 'modules' . DS . 'mod_tabs_gk5' . DS . 'external_data' . DS . $this->config['external_source']);
                 // and parse it
                 $this->config['tabs_data'] = json_decode($json_content);
             } else {
                 if (stripos($this->config['external_source'], '.xml') !== FALSE) {
                     // Load Simple XML parser
                     jimport('joomla.utilities.simplexml');
                     // create a new instance of the JSimpleXML parser
                     $xml = new JSimpleXML();
                     // loading file
                     $xml->loadFile(JPATH_ROOT . DS . 'modules' . DS . 'mod_tabs_gk5' . DS . 'external_data' . DS . $this->config['external_source']);
                     // creating empty array
                     $this->config['tabs_data'] = array();
                     // parsing tabs
                     foreach ($xml->document->tab as $tab) {
                         array_push($this->config['tabs_data'], new GKTabObject($tab->getElementByPath('name')->data(), $tab->getElementByPath('type')->data(), $tab->getElementByPath('content')->data(), $tab->getElementByPath('published')->data(), $tab->getElementByPath('access')->data(), $tab->getElementByPath('id')->data(), $tab->getElementByPath('animation')->data()));
                     }
                 } else {
                     // if there is file in other format - set the tabs_data to blank array
                     $this->config['tabs_data'] = array();
                 }
             }
         }
     }
 }
コード例 #3
0
ファイル: jea.class.php プロジェクト: omarmm/MangLuoiBDS
 function version()
 {
     if (is_file(JPATH_COMPONENT_ADMINISTRATOR . DS . 'jea.xml')) {
         jimport('joomla.utilities.simplexml');
         $xml = new JSimpleXML();
         $xml->loadFile(JPATH_COMPONENT_ADMINISTRATOR . DS . 'jea.xml');
         return $xml->document->version[0]->data();
     }
     return '';
 }
コード例 #4
0
 function _loadMenu()
 {
     $xmlfile = dirname(__FILE__) . DS . 'menu.xml';
     $xml = new JSimpleXML();
     $xml->loadFile($xmlfile);
     if (!$xml->document) {
         echo "Cannot load menu xml: {$xmlfile}";
         return;
     }
     $this->_menu = $xml->document;
     //include the dynamic menu
     //include (dirname(__FILE__).DS.'dynamic_menu.php');
 }
コード例 #5
0
 function _loadMenu()
 {
     jimport('joomla.utilities.simplexml');
     $xmlfile = dirname(__FILE__) . '/menu.xml';
     $xml = new JSimpleXML();
     $xml->loadFile($xmlfile);
     //$xml = JFactory::getXML($xmlfile);
     //print_r($xml);
     if (!$xml->document) {
         echo "Cannot load menu xml: {$xmlfile}";
         return;
     }
     $this->_menu = $xml->document;
     //include the dynamic menu
     //include (dirname(__FILE__).'/dynamic_menu.php');
 }
コード例 #6
0
ファイル: menu.class.php プロジェクト: jomsocial/JSVoice
 /**
  * Load menu from XML file
  * 
  * @return void
  */
 function _loadMenu()
 {
     if (version_compare(JVERSION, '3.0', '<')) {
         jimport('joomla.utilities.simplexml');
     }
     $xmlfile = dirname(__FILE__) . '/menu.xml';
     $xml = new JSimpleXML();
     $xml->loadFile($xmlfile);
     if (!$xml->document) {
         echo "Cannot load menu xml: {$xmlfile}";
         return;
     }
     $this->_menu = $xml->document;
     //include the dynamic menu
     include dirname(__FILE__) . '/dynamic_menu.php';
 }
コード例 #7
0
ファイル: view.html.php プロジェクト: sangkasi/joomla
 /**
  * Display the view.
  *
  * @param	string	$tpl	The subtemplate to display.
  *
  * @return	void
  */
 function display($tpl = null)
 {
     JToolBarHelper::title(JText::_('jUpgrade'), 'jupgrade');
     JToolBarHelper::custom('cpanel', 'back.png', 'back_f2.png', 'Back', false, false);
     JToolBarHelper::preferences('com_jupgrade', '500');
     JToolBarHelper::spacer();
     JToolBarHelper::custom('help', 'help.png', 'help_f2.png', 'Help', false, false);
     JToolBarHelper::spacer();
     $xmlfile = JPATH_COMPONENT . '/jupgrade.xml';
     $xml = new JSimpleXML();
     $xml->loadFile($xmlfile);
     $attrib = $xml->document->version[0];
     // get params
     $params = JComponentHelper::getParams('com_jupgrade');
     $this->assignRef('version', $attrib->data());
     $this->assignRef('params', $params);
     parent::display($tpl);
 }
コード例 #8
0
ファイル: default.php プロジェクト: q0821/esportshop
 $aup_rule_file = 'alphauserpoints_rule.xml';
 jimport('joomla.filesystem.file');
 jimport('joomla.filesystem.folder');
 $pathToScan = array(0 => 'components', 1 => 'modules', 2 => 'plugins');
 foreach ($pathToScan as $scan) {
     $scan_path = JPATH_ROOT . DS . $scan;
     if (!JFolder::exists($scan_path)) {
         continue;
     }
     $scan_folders = JFolder::folders($scan_path, '.', true, true);
     $count = 0;
     foreach ($scan_folders as $folder) {
         $xmlRuleFile = $folder . DS . $aup_rule_file;
         if (JFile::exists($xmlRuleFile)) {
             $parser = new JSimpleXML();
             $parser->loadFile($xmlRuleFile);
             $elementCom = $parser->document->getElementByPath('component');
             $component = empty($elementCom) ? '' : $elementCom->data();
             $elementRoot = $parser->document->getElementByPath('rules');
             if (!empty($elementRoot)) {
                 foreach ($elementRoot->children() as $rule) {
                     $element = $rule->getElementByPath('name');
                     $nameRule = empty($element) ? '' : addslashes($element->data());
                     $element = $rule->getElementByPath('description');
                     $descriptionRule = empty($element) ? '' : addslashes($element->data());
                     $element = $rule->getElementByPath('plugin_function');
                     $pluginRule = empty($element) ? '' : $element->data();
                     $element = $rule->getElementByPath('fixed_points');
                     $fixed_points = empty($element) ? 'true' : $element->data();
                     $fixed_points = trim(strtolower($fixed_points));
                     $fixed_points = $fixed_points === 'true' ? 1 : 0;
コード例 #9
0
 function _getInitialParams()
 {
     jimport('joomla.utilities.simplexml');
     $xml = new JSimpleXML();
     if (substr($this->jversion, 0, 3) == "1.5") {
         $filename = JPATH_SITE . DS . "/plugins/system/plugin_googlemap2.xml";
     } else {
         $filename = JPATH_SITE . DS . "/plugins/system/plugin_googlemap2/plugin_googlemap2.xml";
     }
     if ($xml->loadFile($filename)) {
         if (substr($this->jversion, 0, 3) == "1.5") {
             $root =& $xml->document;
         } else {
             $root = $xml->document->config[0]->fields[0];
         }
         foreach ($root->children() as $params) {
             foreach ($params->children() as $param) {
                 if ($param->attributes('export') == '1') {
                     $name = $param->attributes('name');
                     if ($name == 'lat') {
                         $this->initparams->deflatitude = $this->params->get($name, $param->attributes('default'));
                     } elseif ($name == 'lon') {
                         $this->initparams->deflongitude = $this->params->get($name, $param->attributes('default'));
                     } elseif (substr($name, 0, 3) == 'txt') {
                         $nm = strtolower($name);
                         $this->initparams->{$nm} = $this->params->get($name, '');
                     } else {
                         $nm = strtolower($name);
                         $this->initparams->{$nm} = $this->params->get($name, $param->attributes('default'));
                     }
                 }
             }
         }
     }
     // Clean up generated variables
     unset($filename, $xml, $root, $params, $param, $name, $nm);
 }
コード例 #10
0
        HTML_jupgrader::showError('Missing update file. Please <a href="' . $url . '" target="_blank">download the update definition file</a> and put it into your temporary directory as "jupgrader.xml".<br />Target Path: ' . $target);
        return false;
    }
} else {
    $result = downloadFile($url, $target);
    if (is_object($result)) {
        HTML_jupgrader::showError('Download Failed: ' . $result->message . '(' . $result->number . ')');
        return false;
    }
}
if (!file_exists($target)) {
    HTML_jupgrader::showError('Update file does not exist: ' . $target);
}
// Yay! file downloaded! Processing time :(
$xmlDoc = new JSimpleXML();
if (!$xmlDoc->loadFile($target)) {
    HTML_jupgrader::showError('Parsing XML Document Failed!');
    return false;
}
//$root = &$xmlDoc->documentElement;
$root =& $xmlDoc->document;
if ($root->name() != 'update') {
    HTML_jupgrader::showError('Parsing XML Document Failed: Not an update definition file!');
    return false;
}
$rootattributes = $root->attributes();
$latest = $rootattributes['release'];
if ($latest == $version) {
    echo "<p>No updates were found. <a href='index.php?option=com_jupdateman&task=step2&target=full'>Force full update &gt;&gt;&gt;</a></p><br /><br /><p>Please check again later or watch <a href='http://www.joomla.org' target='_blank'>www.joomla.org</a></p>";
    echo '</div>';
    return true;
コード例 #11
0
 /**
  * Method to import Joomla! com_content datas and structure
  * this is UNUSED in J2.5+, it may be used in the future
  * 
  * @return boolean true on success
  * @since 1.5
  */
 function import()
 {
     jimport('joomla.utilities.simplexml');
     // Deprecated J2.5, removed J3.x
     // Get the site default language
     $lang = flexicontent_html::getSiteDefaultLang();
     if (!FLEXI_J16GE) {
         // Get all Joomla sections
         $query = 'SELECT * FROM #__sections';
         $this->_db->setQuery($query);
         $sections = $this->_db->loadObjectList();
     }
     $logs = new stdClass();
     if (!FLEXI_J16GE) {
         $logs->sec = 0;
     }
     $logs->cat = 0;
     $logs->art = 0;
     //$logs->err = new stdClass();
     // Create the new category for the flexicontent items
     $topcat = JTable::getInstance('flexicontent_categories', '');
     $topcat->parent_id = 1;
     $topcat->level = 0;
     $topcat->extension = "com_content";
     $topcat->title = 'FLEXIcontent';
     $topcat->alias = 'flexicontent';
     $topcat->lft = null;
     $topcat->rgt = null;
     $topcat->level = 0;
     $topcat->published = 1;
     $topcat->access = 1;
     $topcat->language = "*";
     $topcat->setLocation(0, 'last-child');
     $topcat->check();
     $topcat->store();
     $topcat->rebuildPath($topcat->id);
     // Get the category default parameters in a string
     $xml = new JSimpleXML();
     $xml->loadFile(JPATH_COMPONENT . DS . 'models' . DS . 'category.xml');
     $catparams = new JRegistry();
     foreach ($xml->document->params as $paramGroup) {
         foreach ($paramGroup->param as $param) {
             if (!$param->attributes('name')) {
                 continue;
             }
             // FIX for empty name e.g. seperator fields
             $catparams->set($param->attributes('name'), $param->attributes('default'));
         }
     }
     $catparams_str = $catparams->toString();
     // Loop through the top category object and create cat -> subcat -> items -> fields
     $k = 0;
     if ($topcat->id) {
         // Get the sub-categories of the root category that belong to com_content
         $query = "SELECT * FROM #__categories as c WHERE c.extension='com_content' ";
         $this->_db->setQuery($query);
         $categories = $this->_db->loadObjectList();
         /*//get children
         		$children = array();
         		foreach ($categories as $child) {
         			$parent = $child->parent_id;
         			$list = @$children[$parent] ? $children[$parent] : array();
         			array_push($list, $child);
         			$children[$parent] = $list;
         		}
         		$categories = $children;
         		//unset($children);
         		*/
         $map_old_new = array();
         $map_old_new[1] = $topcat->id;
         // Loop throught the categories of the created section
         foreach ($categories as $category) {
             $subcat = JTable::getInstance('flexicontent_categories', '');
             $subcat->load($category->id);
             $subcat->id = 0;
             $subcat->lft = null;
             $subcat->rgt = null;
             $subcat->level = null;
             $subcat->parent_id = isset($map_old_new[$category->parent_id]) ? $map_old_new[$category->parent_id] : $topcat->id;
             $subcat->setLocation($subcat->parent_id, 'last-child');
             $subcat->params = $category->params;
             $k++;
             $subcat->check();
             if ($subcat->store()) {
                 $logs->cat++;
             } else {
                 $logs->err->{$k}->type = JText::_('FLEXI_IMPORT_CATEGORY') . ' id';
                 $logs->err->{$k}->id = $category->id;
                 $logs->err->{$k}->title = $category->title;
             }
             $subcat->rebuildPath($subcat->id);
             $map_old_new[$category->id] = $subcat->id;
             // Get the articles of the created category
             $query = 'SELECT * FROM #__content WHERE catid = ' . $category->id;
             $this->_db->setQuery($query);
             $articles = $this->_db->loadObjectList();
             // Loop throught the articles of the created category
             foreach ($articles as $article) {
                 $item = JTable::getInstance('content');
                 $item->load($article->id);
                 $item->id = 0;
                 $item->catid = $subcat->id;
                 $k++;
                 $item->check();
                 if ($item->store()) {
                     $logs->art++;
                 } else {
                     $logs->err->{$k}->type = JText::_('FLEXI_IMPORT_ARTICLE') . ' id';
                     $logs->err->{$k}->id = $article->id;
                     $logs->err->{$k}->title = $article->title;
                 }
             }
             // end articles loop
         }
         // end categories loop
     }
     // end if
     foreach ($categories as $category) {
         $subcat = JTable::getInstance('flexicontent_categories', '');
         $subcat->load($map_old_new[$category->id]);
         $subcat->lft = null;
         $subcat->rgt = null;
         $subcat->level = null;
         $subcat->parent_id = isset($map_old_new[$category->parent_id]) ? $map_old_new[$category->parent_id] : $topcat->id;
         $subcat->setLocation($subcat->parent_id, 'last-child');
         $subcat->check();
         $subcat->store();
     }
     unset($map_old_new);
     // Save the created top category as the flexi_top_category for the component
     $this->cparams->set('flexi_top_category', $topcat->id);
     $cparams_str = $this->cparams->toString();
     $flexi = JComponentHelper::getComponent('com_flexicontent');
     $query = 'UPDATE ' . (FLEXI_J16GE ? '#__extensions' : '#__components') . ' SET params = ' . $this->_db->Quote($cparams_str) . ' WHERE ' . (FLEXI_J16GE ? 'extension_id' : 'id') . '=' . $flexi->id;
     $this->_db->setQuery($query);
     $this->_db->execute();
     return $logs;
 }
コード例 #12
0
ファイル: plugins.php プロジェクト: q0821/esportshop
 function _loadPluginElements($xmlFile)
 {
     if (substr(strtolower($xmlFile), -4) != ".xml") {
         return;
     }
     $app = JFactory::getApplication();
     $error = "";
     // XML library
     //jimport('joomla.utilities.simplexml');
     // Import file dependencies
     require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'assets' . DS . 'includes' . DS . 'simplexml.php';
     //$xmlDoc =  JFactory::getXMLParser('Simple');
     $xmlDoc = new JSimpleXML();
     $_xmlFile = JPATH_COMPONENT_ADMINISTRATOR . DS . 'assets' . DS . 'plugins' . DS . $xmlFile;
     $pos = strrpos($_xmlFile, DS);
     if ($pos) {
         $_installPath = substr($_xmlFile, 0, $pos);
     }
     if ($xmlDoc->loadFile($_xmlFile)) {
         $root =& $xmlDoc->document;
         if ($root->name() == 'alphauserpoints') {
             $element = $root->rule;
             $nameRule = $element ? $element[0]->data() : '';
             $element = $root->description;
             $descriptionRule = $element ? $element[0]->data() : '';
             $element = $root->component;
             $componentRule = $element ? $element[0]->data() : '';
             $element = $root->plugin_function;
             $pluginRule = $element ? $element[0]->data() : '';
             $element = $root->fixed_points;
             $fixedpointsRule = $element ? $element[0]->data() : '';
             $fixedpointsRule = trim(strtolower($fixedpointsRule));
             $fixedpointsRule = $fixedpointsRule == 'true' ? 1 : 0;
             $element = @$root->category;
             $categoryRule = @$element ? @$element[0]->data() : '';
             $element = @$root->display_message;
             $displayMessage = @$element ? @$element[0]->data() : '';
             $displayMessage = trim(strtolower($displayMessage));
             $displayMessage = $displayMessage == 'true' ? 1 : 0;
             $element = @$root->email_notification;
             $emailNotification = @$element ? @$element[0]->data() : '';
             $emailNotification = trim(strtolower($emailNotification));
             $emailNotification = $emailNotification == 'true' ? 1 : 0;
             // insert in table
             if ($nameRule != '' && $descriptionRule != '' && $componentRule != '' && $pluginRule != '') {
                 $db = JFactory::getDBO();
                 // check if already exist...
                 $query = "SELECT COUNT(*) FROM #__alpha_userpoints_rules WHERE `plugin_function`='{$pluginRule}'";
                 $db->setQuery($query);
                 $resultCount = $db->loadResult();
                 if (!$resultCount) {
                     $query = "INSERT INTO #__alpha_userpoints_rules VALUES ('', '" . $nameRule . "', '" . $descriptionRule . "', '" . $componentRule . "', '" . $pluginRule . "', '1', '" . $componentRule . "', '', '', '0', '0', 0, '0000-00-00 00:00:00', '', '', '', '', '0', '0', '0', '0', '1', '" . $fixedpointsRule . "', '" . $categoryRule . "', '" . $displayMessage . "', '', '0', '" . $emailNotification . "', '', '', '0', '0', '0', '0', '0', '1')";
                     $db->setQuery($query);
                     if ($db->query()) {
                         $msg = JText::_('AUP_NEW_RULE_INSTALLED_SUCCESSFULLY') . ' : <b>' . $nameRule . '</b>';
                         $app->enqueueMessage($msg);
                     } else {
                         $error = JText::_('This rule is not installed properly');
                         JError::raiseNotice(0, $error);
                     }
                 } else {
                     $error = JText::_('AUP_THISRULEALREADYEXIST');
                     JError::raiseNotice(0, $error);
                 }
             } else {
                 $error = JText::_('AUP_XML_FILE_INVALID');
                 JError::raiseWarning(0, $error);
             }
         } elseif ($root->name() == 'extension') {
             // Install standard plugins for Joomla!
             jimport('joomla.installer.installer');
             jimport('joomla.filesystem.folder');
             jimport('joomla.filesystem.file');
             $plugin_installer = new JInstaller();
             $installStandard = $plugin_installer->install($_installPath);
             JFolder::delete($_installPath);
             $redirecturl = "index.php?option=com_plugins";
             JControllerLegacy::setRedirect($redirecturl);
             JControllerLegacy::redirect();
         } else {
             unset($xmlDoc);
             $error = JText::_('AUP_XML_FILE_INVALID');
             JError::raiseWarning(0, $error);
         }
     } else {
         unset($xmlDoc);
         $error = JText::_('AUP_XML_FILE_INVALID');
         JError::raiseWarning(0, $error);
     }
 }
コード例 #13
0
ファイル: footer.php プロジェクト: sangkasi/joomla
<?php

/**
 * @package		SourceCoast Extension Version Tool
 * @copyright (C) 2010-2011 by CMS Market - All rights reserved
 * http://www.sourcecoast.com
 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 */
defined('_JEXEC') or die('Restricted access');
jimport('joomla.utilities.simplexml');
$option = JRequest::getString('option');
$xmlFile = str_replace("com_", "", $option) . '.xml';
$xml = new JSimpleXML();
$xml->loadFile(JPATH_ADMINISTRATOR . DS . 'components' . DS . $option . DS . $xmlFile);
$title = $xml->document->getElementByPath('/name')->data();
$version = $xml->document->getElementByPath('/version')->data();
?>
<table style="margin-bottom: 5px; padding: 3px; width: 100%; border: 2px solid #BBBBBB; background:#F8F8F8">
	<tbody>
		<tr>
			<td style="text-align: left; width: 25%;">
			<a href="http://www.sourcecoast.com" target="_blank"><img src="components/<?php 
echo $option;
?>
/assets/footer/SourceCoast_Logo.png" /></a>
			</td>
			<td style="text-align: center; width: 49%;">
				<?php 
echo $title;
?>
				<br/>Copyright: 2010-2011 &copy; <a href="http://www.sourcecoast.com" target="_blank">SourceCoast Web Development</a>
コード例 #14
0
ファイル: items.php プロジェクト: jakesyl/flexicontent
 /**
  * Method to import Joomla! com_content datas and structure
  * this is UNUSED in J2.5+, it may be used in the future
  * 
  * @return boolean true on success
  * @since 1.5
  */
 function import()
 {
     jimport('joomla.utilities.simplexml');
     // Deprecated J2.5, removed J3.x
     // Get the site default language
     $lang = flexicontent_html::getSiteDefaultLang();
     if (!FLEXI_J16GE) {
         // Get all Joomla sections
         $query = 'SELECT * FROM #__sections';
         $this->_db->setQuery($query);
         $sections = $this->_db->loadObjectList();
     }
     $logs = new stdClass();
     if (!FLEXI_J16GE) {
         $logs->sec = 0;
     }
     $logs->cat = 0;
     $logs->art = 0;
     //$logs->err = new stdClass();
     // Create the new section for flexicontent items
     $flexisection = JTable::getInstance('section');
     $flexisection->title = 'FLEXIcontent';
     $flexisection->alias = 'flexicontent';
     $flexisection->published = 1;
     $flexisection->ordering = $flexisection->getNextOrder();
     $flexisection->access = 0;
     $flexisection->scope = 'content';
     $flexisection->check();
     $flexisection->store();
     // Get the category default parameters in a string
     $xml = new JSimpleXML();
     $xml->loadFile(JPATH_COMPONENT . DS . 'models' . DS . 'category.xml');
     $catparams = FLEXI_J16GE ? new JRegistry() : new JParameter("");
     foreach ($xml->document->params as $paramGroup) {
         foreach ($paramGroup->param as $param) {
             if (!$param->attributes('name')) {
                 continue;
             }
             // FIX for empty name e.g. seperator fields
             $catparams->set($param->attributes('name'), $param->attributes('default'));
         }
     }
     $catparams_str = $catparams->toString();
     // Loop through the section object and create cat -> subcat -> items -> fields
     $k = 0;
     foreach ($sections as $section) {
         // Create a category for every imported section, to contain all categories of the section
         $cat = JTable::getInstance('flexicontent_categories', '');
         $cat->parent_id = 0;
         $cat->title = $section->title;
         $cat->name = $section->name;
         $cat->alias = $section->alias;
         $cat->image = $section->image;
         $cat->section = $flexisection->id;
         $cat->image_position = $section->image_position;
         $cat->description = $section->description;
         $cat->published = $section->published;
         $cat->ordering = $section->ordering;
         $cat->access = $section->access;
         $cat->params = $catparams_str;
         $k++;
         $cat->check();
         if ($cat->store()) {
             $logs->sec++;
         } else {
             $logs->err->{$k}->type = JText::_('FLEXI_IMPORT_SECTION') . ' id';
             $logs->err->{$k}->id = $section->id;
             $logs->err->{$k}->title = $section->title;
         }
         // Get the categories of each imported section
         $query = "SELECT * FROM #__categories WHERE section = " . $section->id;
         $this->_db->setQuery($query);
         $categories = $this->_db->loadObjectList();
         // Loop throught the categories of the created section
         foreach ($categories as $category) {
             $subcat = JTable::getInstance('flexicontent_categories', '');
             $subcat->load($category->id);
             $subcat->id = 0;
             $subcat->parent_id = $cat->id;
             $subcat->section = $flexisection->id;
             $subcat->params = $catparams_str;
             $k++;
             $subcat->check();
             if ($subcat->store()) {
                 $logs->cat++;
             } else {
                 $logs->err->{$k}->type = JText::_('FLEXI_IMPORT_CATEGORY') . ' id';
                 $logs->err->{$k}->id = $category->id;
                 $logs->err->{$k}->title = $category->title;
             }
             // Get the articles of the created category
             $query = 'SELECT * FROM #__content WHERE catid = ' . $category->id;
             $this->_db->setQuery($query);
             $articles = $this->_db->loadObjectList();
             // Loop throught the articles of the created category
             foreach ($articles as $article) {
                 $item = JTable::getInstance('content');
                 $item->load($article->id);
                 $item->id = 0;
                 $item->sectionid = $flexisection->id;
                 $item->catid = $subcat->id;
                 $k++;
                 $item->check();
                 if ($item->store()) {
                     $logs->art++;
                 } else {
                     $logs->err->{$k}->type = JText::_('FLEXI_IMPORT_ARTICLE') . ' id';
                     $logs->err->{$k}->id = $article->id;
                     $logs->err->{$k}->title = $article->title;
                 }
             }
             // end articles loop
         }
         // end categories loop
     }
     // end sections loop
     // Save the created section as flexi_section for the component
     $fparams = JComponentHelper::getParams('com_flexicontent');
     $fparams->set('flexi_section', $flexisection->id);
     $fparams_str = $fparams->toString();
     $flexi = JComponentHelper::getComponent('com_flexicontent');
     $query = 'UPDATE ' . (FLEXI_J16GE ? '#__extensions' : '#__components') . ' SET params = ' . $this->_db->Quote($fparams_str) . ' WHERE ' . (FLEXI_J16GE ? 'extension_id' : 'id') . '=' . $flexi->id;
     $this->_db->setQuery($query);
     $this->_db->query();
     return $logs;
 }
コード例 #15
0
ファイル: sourcecoast.php プロジェクト: sangkasi/joomla
 function getInstalledVersion($extensionName, $extensionType)
 {
     $version = "Not Installed";
     $extensionType = $extensionType . "s";
     $xmlDir = "";
     $xmlFile = "";
     if ($extensionType == "components" || $extensionType == "modules") {
         if (JFolder::exists(JPATH_ADMINISTRATOR . DS . $extensionType . DS . $extensionName)) {
             $xmlDir = JPATH_ADMINISTRATOR . DS . $extensionType . DS . $extensionName;
             $xmlFile = str_replace("com_", "", $extensionName) . ".xml";
         } else {
             if (JFolder::exists(JPATH_SITE . DS . $extensionType . DS . $extensionName)) {
                 $xmlDir = JPATH_SITE . DS . $extensionType . DS . $extensionName;
                 $xmlFile = $extensionName . ".xml";
             }
         }
     } else {
         if ($extensionType == "plugins") {
             $pluginData = explode(".", $extensionName);
             if (JFile::exists(JPATH_SITE . DS . 'plugins' . DS . $pluginData[0] . DS . $pluginData[1] . '.xml')) {
                 $xmlDir = JPATH_SITE . DS . 'plugins' . DS . $pluginData[0];
             }
             $xmlFile = $pluginData[1] . ".xml";
         }
     }
     if ($xmlFile == "" || $xmlDir == "") {
         return $version;
     }
     $xmlParser = new JSimpleXML();
     if (JFile::exists($xmlDir . DS . $xmlFile)) {
         if ($xmlParser->loadFile($xmlDir . DS . $xmlFile)) {
             $versionElement =& $xmlParser->document->version[0];
             if ($versionElement != null) {
                 $version = $versionElement->_data;
             }
         }
     }
     return $version;
 }
コード例 #16
0
ファイル: view.html.php プロジェクト: Rikisha/proj
 /**
  * Displays the view.
  *
  * @param  string $tpl the template name
  *
  * @return void
  * @since  1.0
  */
 public function display($tpl = null)
 {
     $isNew = !JRequest::getInt('newsletter_id', false);
     if ($isNew && !AclHelper::actionIsAllowed('newsletter.add') || !$isNew && !AclHelper::actionIsAllowed('newsletter.edit')) {
         $msg = $isNew ? 'JLIB_APPLICATION_ERROR_CREATE_RECORD_NOT_PERMITTED' : 'JLIB_APPLICATION_ERROR_EDIT_NOT_PERMITTED';
         JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_newsletter&view=newsletters', false), JText::_($msg), 'error');
         return;
     }
     //TODO: Need to move css/js to SetDocument
     JHTML::stylesheet('media/com_newsletter/css/admin.css');
     JHTML::stylesheet('media/com_newsletter/css/newsletter.css');
     JHTML::script('media/com_newsletter/js/migur/js/core.js');
     JHTML::script('media/com_newsletter/js/migur/js/ajax.js');
     JHTML::script('media/com_newsletter/js/migur/js/widgets.js');
     JHTML::script('media/com_newsletter/js/migur/js/moodialog/MooDialog.js');
     JHTML::script('media/com_newsletter/js/migur/js/moodialog/MooDialog.Request.js');
     JHTML::script('media/com_newsletter/js/migur/js/moodialog/MooDialog.IFrame.js');
     JHTML::stylesheet('media/com_newsletter/js/migur/js/moodialog/css/MooDialog.css');
     JHTML::script('media/com_newsletter/js/migur/js/autocompleter/Observer.js');
     JHTML::script('media/com_newsletter/js/migur/js/autocompleter/Autocompleter.js');
     JHTML::script('media/com_newsletter/js/migur/js/autocompleter/Autocompleter.Local.js');
     JHTML::stylesheet('media/com_newsletter/js/migur/js/autocompleter/css/Autocompleter.css');
     JHTML::script('media/com_newsletter/js/migur/js/guide.js');
     JHTML::stylesheet('media/com_newsletter/css/guide.css');
     //TODO: Bulk-code. Need to refactor.
     JavascriptHelper::addObject('comParams', JComponentHelper::getParams('com_newsletter')->toArray());
     $nId = JRequest::getInt('newsletter_id');
     $script = $this->get('Script');
     $this->script = $script;
     // Get main form and data for newsletter
     $this->form = $this->get('Form', 'newsletter');
     $this->newsletter = $this->get('Item');
     $smtpModel = JModel::getInstance('SMtpProfile', 'NewsletterModelEntity');
     // Let's add J! profile
     $smtpp = $smtpModel->loadJoomla();
     JavascriptHelper::addObject('joomlaDe', JComponentHelper::getParams('com_newsletter')->toArray());
     // get the SmtpProfiles data
     $smtpprofilesManager = JModel::getInstance('smtpprofiles', 'NewsletterModel');
     $this->assignRef('smtpprofiles', $smtpprofilesManager->getAllItems('withDefault'));
     // get all the Extensions
     $this->modules = MigurModuleHelper::getSupported(array('withoutInfo' => true));
     $this->plugins = MigurPluginHelper::getSupported(array('withoutInfo' => true), 'com_newsletter.newsletter');
     // get the Extensions used in this newsletter
     $model = JModel::getInstance('newsletterext', 'NewsletterModel');
     $this->usedExts = $model->getExtensionsBy($nId);
     // Get a list of all templates
     $this->setModel(JModel::getInstance('templates', 'NewsletterModel'));
     $model = $this->getModel('templates');
     $templs = $model->getItems();
     $path = JPATH_COMPONENT . '/extensions/templates/';
     $filenames = JFolder::files($path, '^.*\\.xml$');
     if ($filenames === false) {
         JError::raiseError(500, implode("\n", array("Path {$path} not found")));
     }
     $this->templates = (object) array('items' => array(), 'path' => $path);
     $this->htmlTemplateId = null;
     foreach ($templs as $item) {
         $xml = new JSimpleXML();
         $xml->loadFile($path . $item->template);
         $str = trim($xml->document->template[0]->_data);
         $str = preg_replace('/<style.*>.*<\\/style>/s', '', $str);
         $str = str_replace('<position', '<div class="drop container-draggables"', $str);
         $id = strtolower(str_replace('.', '-', $item->template) . '-' . $item->t_style_id);
         $item->id = $id;
         $item->filename = $item->template;
         $item->template = $str;
         $this->templates->items[] = $item;
         if ($this->newsletter->t_style_id == $item->t_style_id) {
             $this->htmlTemplateId = $id;
             $this->t_style_id = $item->t_style_id;
         }
         unset($xml);
     }
     //attachments
     $this->attItems = array();
     $this->dynamicData = array('Name' => '[username]', 'Email' => '[useremail]', 'Site name' => '[sitename]', 'Subscription key' => '[subscription key]', 'Unsubscription link' => '[unsubscription link]', 'Confirmation link' => '[confirmation link]');
     $this->attItemslistDirn = "a.filename";
     $this->attItemslistOrder = "asc";
     // getting of an xml from
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     // We don't need toolbar in the modal window.
     if ($this->getLayout() !== 'modal') {
         $this->addToolbar();
     }
     $this->downloads = (array) DownloadHelper::getByNewsletterId($nId);
     JavascriptHelper::addObject('dataStorage', (object) array('htmlTemplate' => (object) array('template' => (object) array('id' => $this->htmlTemplateId), 'extensions' => (array) $this->usedExts), 'templates' => (array) $this->templates->items, 'modules' => (array) $this->modules, 'plugins' => (array) $this->plugins, 'newsletter' => NewsletterHelper::get($nId)));
     // Set the document
     $this->setDocument();
     parent::display($tpl);
 }
コード例 #17
0
ファイル: items.php プロジェクト: grchis/Site-Auto
 function import()
 {
     $mainframe = JFactory::getApplication();
     jimport('joomla.filesystem.file');
     $db = JFactory::getDBO();
     $query = "SELECT * FROM #__sections";
     $db->setQuery($query);
     $sections = $db->loadObjectList();
     $query = "SELECT COUNT(*) FROM #__k2_items";
     $db->setQuery($query);
     $result = $db->loadResult();
     if ($result) {
         $preserveItemIDs = false;
     } else {
         $preserveItemIDs = true;
     }
     $xml = new JSimpleXML();
     $xml->loadFile(JPATH_COMPONENT . DS . 'models' . DS . 'category.xml');
     $categoryParams = class_exists('JParameter') ? new JParameter('') : new JRegistry('');
     foreach ($xml->document->params as $paramGroup) {
         foreach ($paramGroup->param as $param) {
             if ($param->attributes('type') != 'spacer' && $param->attributes('name')) {
                 $categoryParams->set($param->attributes('name'), $param->attributes('default'));
             }
         }
     }
     $categoryParams = $categoryParams->toString();
     $xml = new JSimpleXML();
     $xml->loadFile(JPATH_COMPONENT . DS . 'models' . DS . 'item.xml');
     $itemParams = class_exists('JParameter') ? new JParameter('') : new JRegistry('');
     foreach ($xml->document->params as $paramGroup) {
         foreach ($paramGroup->param as $param) {
             if ($param->attributes('type') != 'spacer' && $param->attributes('name')) {
                 $itemParams->set($param->attributes('name'), $param->attributes('default'));
             }
         }
     }
     $itemParams = $itemParams->toString();
     $query = "SELECT id, name FROM #__k2_tags";
     $db->setQuery($query);
     $tags = $db->loadObjectList();
     if (is_null($tags)) {
         $tags = array();
     }
     foreach ($sections as $section) {
         $K2Category = JTable::getInstance('K2Category', 'Table');
         $K2Category->name = $section->title;
         $K2Category->alias = $section->title;
         $K2Category->description = $section->description;
         $K2Category->parent = 0;
         $K2Category->published = $section->published;
         $K2Category->access = $section->access;
         $K2Category->ordering = $section->ordering;
         $K2Category->image = $section->image;
         $K2Category->trash = 0;
         $K2Category->params = $categoryParams;
         $K2Category->check();
         $K2Category->store();
         if (JFile::exists(JPATH_SITE . DS . 'images' . DS . 'stories' . DS . $section->image)) {
             JFile::copy(JPATH_SITE . DS . 'images' . DS . 'stories' . DS . $section->image, JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'categories' . DS . $K2Category->image);
         }
         $query = "SELECT * FROM #__categories WHERE section = " . (int) $section->id;
         $db->setQuery($query);
         $categories = $db->loadObjectList();
         foreach ($categories as $category) {
             $K2Subcategory = JTable::getInstance('K2Category', 'Table');
             $K2Subcategory->name = $category->title;
             $K2Subcategory->alias = $category->title;
             $K2Subcategory->description = $category->description;
             $K2Subcategory->parent = $K2Category->id;
             $K2Subcategory->published = $category->published;
             $K2Subcategory->access = $category->access;
             $K2Subcategory->ordering = $category->ordering;
             $K2Subcategory->image = $category->image;
             $K2Subcategory->trash = 0;
             $K2Subcategory->params = $categoryParams;
             $K2Subcategory->check();
             $K2Subcategory->store();
             if (JFile::exists(JPATH_SITE . DS . 'images' . DS . 'stories' . DS . $category->image)) {
                 JFile::copy(JPATH_SITE . DS . 'images' . DS . 'stories' . DS . $category->image, JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'categories' . DS . $K2Subcategory->image);
             }
             $query = "SELECT article.*, xref.content_id\n\t\t\t\tFROM #__content AS article \n\t\t\t\tLEFT JOIN #__content_frontpage AS xref ON article.id = xref.content_id \n\t\t\t\tWHERE catid = " . (int) $category->id;
             $db->setQuery($query);
             $items = $db->loadObjectList();
             foreach ($items as $item) {
                 $K2Item = JTable::getInstance('K2Item', 'Table');
                 $K2Item->title = $item->title;
                 $K2Item->alias = $item->title;
                 $K2Item->catid = $K2Subcategory->id;
                 if ($item->state < 0) {
                     $K2Item->trash = 1;
                 } else {
                     $K2Item->trash = 0;
                     $K2Item->published = $item->state;
                 }
                 $K2Item->featured = $item->content_id ? 1 : 0;
                 $K2Item->introtext = $item->introtext;
                 $K2Item->fulltext = $item->fulltext;
                 $K2Item->created = $item->created;
                 $K2Item->created_by = $item->created_by;
                 $K2Item->created_by_alias = $item->created_by_alias;
                 $K2Item->modified = $item->modified;
                 $K2Item->modified_by = $item->modified_by;
                 $K2Item->publish_up = $item->publish_up;
                 $K2Item->publish_down = $item->publish_down;
                 $K2Item->access = $item->access;
                 $K2Item->ordering = $item->ordering;
                 $K2Item->hits = $item->hits;
                 $K2Item->metadesc = $item->metadesc;
                 $K2Item->metadata = $item->metadata;
                 $K2Item->metakey = $item->metakey;
                 $K2Item->params = $itemParams;
                 $K2Item->check();
                 if ($preserveItemIDs) {
                     $K2Item->id = $item->id;
                     $db->insertObject('#__k2_items', $K2Item);
                 } else {
                     $K2Item->store();
                 }
                 if (!empty($item->metakey)) {
                     $itemTags = explode(',', $item->metakey);
                     foreach ($itemTags as $itemTag) {
                         $itemTag = JString::trim($itemTag);
                         if (in_array($itemTag, JArrayHelper::getColumn($tags, 'name'))) {
                             $query = "SELECT id FROM #__k2_tags WHERE name=" . $db->Quote($itemTag);
                             $db->setQuery($query);
                             $id = $db->loadResult();
                             $query = "INSERT INTO #__k2_tags_xref (`id`, `tagID`, `itemID`) VALUES (NULL, {$id}, {$K2Item->id})";
                             $db->setQuery($query);
                             $db->query();
                         } else {
                             $K2Tag = JTable::getInstance('K2Tag', 'Table');
                             $K2Tag->name = $itemTag;
                             $K2Tag->published = 1;
                             $K2Tag->store();
                             $tags[] = $K2Tag;
                             $query = "INSERT INTO #__k2_tags_xref (`id`, `tagID`, `itemID`) VALUES (NULL, {$K2Tag->id}, {$K2Item->id})";
                             $db->setQuery($query);
                             $db->query();
                         }
                     }
                 }
             }
         }
     }
     // Handle uncategorized articles
     $query = "SELECT * FROM #__content WHERE sectionid = 0";
     $db->setQuery($query);
     $items = $db->loadObjectList();
     if ($items) {
         $K2Uncategorised = JTable::getInstance('K2Category', 'Table');
         $K2Uncategorised->name = 'Uncategorized';
         $K2Uncategorised->alias = 'Uncategorized';
         $K2Uncategorised->parent = 0;
         $K2Uncategorised->published = 1;
         $K2Uncategorised->access = 0;
         $K2Uncategorised->ordering = 0;
         $K2Uncategorised->trash = 0;
         $K2Uncategorised->params = $categoryParams;
         $K2Uncategorised->check();
         $K2Uncategorised->store();
         foreach ($items as $item) {
             $K2Item = JTable::getInstance('K2Item', 'Table');
             $K2Item->title = $item->title;
             $K2Item->alias = $item->title;
             $K2Item->catid = $K2Uncategorised->id;
             if ($item->state < 0) {
                 $K2Item->trash = 1;
             } else {
                 $K2Item->trash = 0;
                 $K2Item->published = $item->state;
             }
             $K2Item->introtext = $item->introtext;
             $K2Item->fulltext = $item->fulltext;
             $K2Item->created = $item->created;
             $K2Item->created_by = $item->created_by;
             $K2Item->created_by_alias = $item->created_by_alias;
             $K2Item->modified = $item->modified;
             $K2Item->modified_by = $item->modified_by;
             $K2Item->publish_up = $item->publish_up;
             $K2Item->publish_down = $item->publish_down;
             $K2Item->access = $item->access;
             $K2Item->ordering = $item->ordering;
             $K2Item->hits = $item->hits;
             $K2Item->metadesc = $item->metadesc;
             $K2Item->metadata = $item->metadata;
             $K2Item->metakey = $item->metakey;
             $K2Item->params = $itemParams;
             $K2Item->check();
             if ($preserveItemIDs) {
                 $K2Item->id = $item->id;
                 $db->insertObject('#__k2_items', $K2Item);
             } else {
                 $K2Item->store();
             }
             if (!empty($item->metakey)) {
                 $itemTags = explode(',', $item->metakey);
                 foreach ($itemTags as $itemTag) {
                     $itemTag = JString::trim($itemTag);
                     if (in_array($itemTag, JArrayHelper::getColumn($tags, 'name'))) {
                         $query = "SELECT id FROM #__k2_tags WHERE name=" . $db->Quote($itemTag);
                         $db->setQuery($query);
                         $id = $db->loadResult();
                         $query = "INSERT INTO #__k2_tags_xref (`id`, `tagID`, `itemID`) VALUES (NULL, {$id}, {$K2Item->id})";
                         $db->setQuery($query);
                         $db->query();
                     } else {
                         $K2Tag = JTable::getInstance('K2Tag', 'Table');
                         $K2Tag->name = $itemTag;
                         $K2Tag->published = 1;
                         $K2Tag->store();
                         $tags[] = $K2Tag;
                         $query = "INSERT INTO #__k2_tags_xref (`id`, `tagID`, `itemID`) VALUES (NULL, {$K2Tag->id}, {$K2Item->id})";
                         $db->setQuery($query);
                         $db->query();
                     }
                 }
             }
         }
     }
     $mainframe->enqueueMessage(JText::_('K2_IMPORT_COMPLETED'));
     $mainframe->redirect('index.php?option=com_k2&view=items');
 }
コード例 #18
0
ファイル: users.php プロジェクト: educakanchay/educa
 function import()
 {
     $mainframe = JFactory::getApplication();
     $db = JFactory::getDBO();
     if (K2_JVERSION != '15') {
         $db->setQuery("SELECT id, title AS name FROM #__usergroups");
         $usergroups = $db->loadObjectList();
         $xml = new JXMLElement(JFile::read(JPATH_COMPONENT . DS . 'models' . DS . 'usergroup.xml'));
         $permissions = class_exists('JParameter') ? new JParameter('') : new JRegistry('');
         foreach ($xml->params as $paramGroup) {
             foreach ($paramGroup->param as $param) {
                 $attribute = K2_JVERSION == '30' ? $param->attributes()->type : $param->getAttribute('type');
                 if ($attribute != 'spacer') {
                     if (K2_JVERSION == '30') {
                         $permissions->set((string) $param->attributes()->name, (string) $param->attributes()->default);
                     } else {
                         $permissions->set($param->getAttribute('name'), $param->getAttribute('default'));
                     }
                 }
             }
         }
     } else {
         $acl = JFactory::getACL();
         $frontEndGroups = $acl->_getBelow('#__core_acl_aro_groups', 'g1.id, g1.name, COUNT(g2.name) AS level', 'g1.name', false, 'Public Frontend', false);
         $backEndGroups = $acl->_getBelow('#__core_acl_aro_groups', 'g1.id, g1.name, COUNT(g2.name) AS level', 'g1.name', false, 'Public Backend', false);
         $usergroups = array_merge($frontEndGroups, $backEndGroups);
         $xml = new JSimpleXML();
         $xml->loadFile(JPATH_COMPONENT . DS . 'models' . DS . 'usergroup.xml');
         $permissions = class_exists('JParameter') ? new JParameter('') : new JRegistry('');
         foreach ($xml->document->params as $paramGroup) {
             foreach ($paramGroup->param as $param) {
                 if ($param->attributes('type') != 'spacer') {
                     $permissions->set($param->attributes('name'), $param->attributes('default'));
                 }
             }
         }
     }
     $permissions->set('inheritance', 0);
     $permissions->set('categories', 'all');
     $permissions = $permissions->toString();
     foreach ($usergroups as $usergroup) {
         $K2UserGroup = JTable::getInstance('K2UserGroup', 'Table');
         $K2UserGroup->name = JString::trim($usergroup->name) . " (Imported from Joomla!)";
         $K2UserGroup->permissions = $permissions;
         $K2UserGroup->store();
         if (K2_JVERSION != '15') {
             $query = "SELECT * FROM #__users AS user JOIN #__user_usergroup_map AS map ON user.id = map.user_id\n\t\t\t\tWHERE map.group_id = " . $usergroup->id;
         } else {
             $query = "SELECT * FROM #__users WHERE gid={$usergroup->id}";
         }
         $db->setQuery($query);
         $users = $db->loadObjectList();
         foreach ($users as $user) {
             $query = "SELECT COUNT(*) FROM #__k2_users WHERE userID={$user->id}";
             $db->setQuery($query);
             $result = $db->loadResult();
             if (!$result) {
                 $K2User = JTable::getInstance('K2User', 'Table');
                 $K2User->userID = $user->id;
                 $K2User->group = $K2UserGroup->id;
                 $K2User->store();
             }
         }
     }
     $mainframe->enqueueMessage(JText::_('K2_IMPORT_COMPLETED'));
     $mainframe->redirect('index.php?option=com_k2&view=users');
 }
コード例 #19
0
ファイル: view.html.php プロジェクト: jomsocial/JSVoice
    function menu()
    {
        global $JVVERSION;
        $latest_version = '';
        $version_link = JAVoiceHelpers::get_Version_Link();
        $layout = JRequest::getVar('layout', 'statistic');
        $cid = JRequest::getVar('cid');
        if (is_array($cid)) {
            JArrayHelper::toInteger($cid);
            $cid = $cid[0];
        }
        $latest_version = $this->get('LatestVersion');
        if ($latest_version) {
            $version_link['latest_version']['info'] = 'http://wiki.joomlart.com/wiki/JA_Voice/Overview';
            $version_link['latest_version']['upgrade'] = 'http://www.joomlart.com/forums/downloads.php?do=cat&id=139';
            $iLatest_version = str_replace('.', '', $latest_version);
            $iLatest_version = trim($iLatest_version);
            $iLatest_version = intval($iLatest_version);
        } else {
            $version_link['latest_version']['info'] = '';
            $version_link['latest_version']['upgrade'] = '';
        }
        //$xml = JFactory::getXMLParser( 'simple' );
        $xml = new JSimpleXML();
        $file = JPATH_COMPONENT . '/javoice.xml';
        $xml->loadFile($file);
        $out = $xml->document;
        if ($out == false) {
            $current_version = $JVVERSION;
        } else {
            $allComments = $out->children();
            foreach ($allComments as $blogpost) {
                if ($blogpost->name() == "version") {
                    $current_version = $blogpost->data();
                    break;
                }
            }
        }
        $iCurrent_version = str_replace('.', '', $current_version);
        $iCurrent_version = trim($iCurrent_version);
        $iCurrent_version = intval($iCurrent_version);
        ?>
		<fieldset class="adminform">
					<div class="submenu-box">
						<div class="submenu-pad">
		<ul id="submenu" class="configuration">
			<li><a href="index.php?option=com_javoice&layout=statistic"
				class="<?php 
        if ($layout == null || $layout == 'statistic') {
            echo 'active';
        }
        ?>
">
										<?php 
        echo JText::_('STATISTICS');
        ?>
									</a></li>
			<li><a href="index.php?option=com_javoice&layout=supportandlicense"
				class="<?php 
        if ($layout == 'supportandlicense' || $layout == 'verify') {
            echo 'active';
        }
        ?>
">
										<?php 
        echo JText::_('DOCUMENTATION_AND_SUPPORT');
        ?>
									</a></li>			
			<li style="float: right;line-height:30px;">
				<?php 
        if (empty($iLatest_version)) {
            echo JText::_('VERSION') . ' <b>' . $current_version . '</b>';
        } elseif (!empty($iLatest_version) && $iLatest_version <= $iCurrent_version) {
            echo JText::_('YOUR_VERSION') . ': <b><a href="' . $version_link['current_version']['info'] . '" target="_blank">' . $current_version . '</a></b>&nbsp;&nbsp;' . JText::_('LATEST_VERSION') . ': <b><a href="' . $version_link['latest_version']['info'] . '" target="_blank">' . $latest_version . '</a></b>&nbsp;&nbsp;<font color="Blue"> <i>(' . JText::_('SYSTEM_RUNNING_THE_LATEST_VERSION') . ')</i></font>';
        } elseif (!empty($iLatest_version) && $iLatest_version > $iCurrent_version) {
            echo JText::_('YOUR_VERSION') . ': <b><a href="' . $version_link['current_version']['info'] . '" target="_blank">' . $current_version . '</a></b>&nbsp;&nbsp;' . JText::_('LATEST_VERSION') . ': <b>';
            echo isset($version_link['latest_version']) ? '<a href="' . $version_link['latest_version']['info'] . '" target="_blank">' . $latest_version . '</a>' : $latest_version;
            echo '</b>&nbsp;&nbsp;<span style="background-color:rgb(255,255,0);color:Red;font-weight:bold;">' . JText::_('NEW_VERSION_AVAILABLE') . '</span>';
            if (isset($version_link['latest_version'])) {
                echo '<a target="_blank" href="' . $version_link['latest_version']['upgrade'] . '" title="' . JText::_('CLICK_HERE_TO_DOWNLOAD_LATEST_VERSION') . '">' . JText::_('UPGRADE_NOW') . '</a>';
            }
        }
        ?>
					
			</li>
		</ul>
		<div class="clr"></div>
						</div>
					</div>
					<div class="clr"></div>
				</fieldset>
<?php 
    }
コード例 #20
0
ファイル: view.html.php プロジェクト: jomsocial/JSVoice
 function _getXML($path, $xpath = 'control')
 {
     // Initialize variables
     $result = null;
     // load the xml metadata
     if (file_exists($path)) {
         //$xml = JFactory::getXMLParser('Simple');
         $xml = new JSimpleXML();
         if ($xml->loadFile($path)) {
             if (isset($xml->document)) {
                 $list = $xml->document->_children;
                 foreach ($list as $k => $row) {
                     $result[$k]['filename'] = $row->attributes('filename') . '.php';
                     $result[$k]['description'] = $row->message[0]->_data;
                 }
             }
         }
     }
     return $result;
 }
コード例 #21
0
 function _getJoomlaInstalledVersion($extensionName)
 {
     $xmlFiles = NULL;
     $version = "Undetermined";
     if (JFolder::exists(JPATH_ADMINISTRATOR . DS . 'components' . DS . $extensionName)) {
         $dir = JPATH_ADMINISTRATOR . DS . 'components' . DS . $extensionName;
     } else {
         if (JFolder::exists(JPATH_SITE . DS . 'components' . DS . $extensionName)) {
             $dir = JPATH_SITE . DS . 'components' . DS . $extensionName;
         } else {
             if (JFolder::exists(JPATH_SITE . DS . 'modules' . DS . $extensionName)) {
                 $dir = JPATH_SITE . DS . 'modules' . DS . $extensionName;
             } else {
                 if (JFolder::exists(JPATH_ADMINISTRATOR . DS . 'modules' . DS . $extensionName)) {
                     $dir = JPATH_ADMINISTRATOR . DS . 'modules' . DS . $extensionName;
                 } else {
                     if (JFolder::exists(JPATH_SITE . DS . 'templates' . DS . $extensionName)) {
                         $dir = JPATH_SITE . DS . 'templates' . DS . $extensionName;
                     } else {
                         if (JFolder::exists(JPATH_ADMINISTRATOR . DS . 'templates' . DS . $extensionName)) {
                             $dir = JPATH_ADMINISTRATOR . DS . 'templates' . DS . $extensionName;
                         } else {
                             if (JFolder::exists(JPATH_ADMINISTRATOR . DS . 'templates' . DS . $extensionName)) {
                                 $dir = JPATH_ADMINISTRATOR . DS . 'templates' . DS . $extensionName;
                             } else {
                                 if (count($xmlFiles = JFolder::files(JPATH_SITE . DS . 'plugins', '^' . $extensionName . '.xml$', true, true)) > 0) {
                                     $dir = JPATH_SITE . DS . 'plugins';
                                 } else {
                                     return $version;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if (!$xmlFiles) {
         $xmlFiles = JFolder::files($dir, '.xml$', false, true);
     }
     if (count($xmlFiles) > 0) {
         foreach ($xmlFiles as $xmlFile) {
             $xmlParser = new JSimpleXML();
             if ($xmlParser->loadFile($xmlFile)) {
                 if (is_object($xmlParser->document)) {
                     if ($xmlParser->document->name() == 'install') {
                         $versionElement =& $xmlParser->document->version[0];
                         if ($versionElement != null) {
                             $version = $versionElement->_data;
                         }
                     }
                 }
             }
         }
     }
     return $version;
 }
コード例 #22
0
ファイル: template.php プロジェクト: Rikisha/proj
 /**
  * Method to get the template by it's id.
  * Can fetch both types standard and custom.
  * For standard type use the filename of template
  *
  * @param String - template id or filename
  *
  * @return JObject
  * @since  1.0
  * @deprecated
  */
 public function getTemplateBy($id, $preserve = false)
 {
     //TODO: Check. If this method is not used anywhere then remove it.
     jimport('joomla.utilities.simplexml');
     if (empty($id)) {
         return false;
     }
     $isCustom = false;
     // Make sure that result will be the same type in both cases
     if (strval(intval($id)) == strval($id)) {
         $isCustom = true;
         $item = $this->getItem($id);
         if (empty($item)) {
             return false;
         }
         $filename = $item->template;
     } else {
         $item = new JObject($this->getTable()->getProperties(1));
         if (empty($item)) {
             return false;
         }
         $filename = $id;
     }
     $fullfile = JPATH_COMPONENT_ADMINISTRATOR . DS . 'extensions' . DS . 'templates' . DS . $filename;
     if (JFile::exists($fullfile) === false) {
         $this->setError("File {$fullfile} not found");
         return false;
     }
     try {
         $xml = new JSimpleXML();
         $xml->loadFile($fullfile);
         $str = trim($xml->document->template[0]->_data);
         if (!$preserve) {
             $str = str_replace('<position', '<div class="drop container-draggables"', $str);
         }
         $item->filename = $filename;
         $item->content = $str;
         $item->information = array('name' => $xml->document->information[0]->name[0]->_data, 'author' => $xml->document->information[0]->author[0]->_data, 'creationDate' => $xml->document->information[0]->creationDate[0]->_data, 'copyright' => $xml->document->information[0]->copyright[0]->_data, 'license' => $xml->document->information[0]->license[0]->_data, 'authorEmail' => $xml->document->information[0]->authorEmail[0]->_data, 'authorUrl' => $xml->document->information[0]->authorUrl[0]->_data, 'version' => $xml->document->information[0]->version[0]->_data, 'description' => $xml->document->information[0]->description[0]->_data);
         unset($xml);
     } catch (Exception $e) {
         $this->setError($e->__toString());
         return false;
     }
     return $item;
 }
コード例 #23
0
ファイル: account.php プロジェクト: ErickLopez76/offiria
 public function getUpdate()
 {
     // This can also be overwritten using config file
     $serverXML = 'http://www.offiria.com/releases.xml';
     $app = JFactory::getApplication();
     $defaultFile = JPATH_ROOT . DS . 'offiria.xml';
     $objXml = new JSimpleXML();
     $objXml->loadFile($defaultFile);
     $children = $objXml->document->children();
     $localversion = $children[0]->attributes('number');
     $curl = curl_init();
     curl_setopt($curl, CURLOPT_URL, $serverXML);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     $result = curl_exec($curl);
     curl_close($curl);
     $objXml2 = new JSimpleXML();
     $objXml2->loadString($result);
     $renderData = new stdClass();
     $renderData->data = array();
     $renderData->current_version = $localversion;
     if (isset($objXml2->document) && isset($objXml2->document->releases)) {
         $releases = $objXml2->document->releases[0];
         try {
             // Always assume the first child is the latest
             $latestversion = $releases->version[0]->attributes('number');
             if (trim($localversion) == trim($latestversion)) {
                 $renderData->msg = 'No new updates available.';
             } else {
                 $renderData->msg = 'New updates available.';
                 $notMet = true;
                 foreach ($releases->version as $version) {
                     if (trim($localversion) == trim($version->attributes('number'))) {
                         // found
                         break;
                     } else {
                         $index = count($renderData->data);
                         $renderData->data[$index] = new stdClass();
                         $renderData->data[$index]->version = $version->attributes('number');
                         $renderData->data[$index]->package_url = $version->package[0]->attributes('url');
                         $renderData->data[$index]->change_log = $version->changelog[0]->data();
                     }
                 }
             }
         } catch (Exception $ex) {
             $renderData->msg = 'Unable to retrieve update logs.';
         }
     } else {
         $renderData->msg = 'Unable to retrieve update logs.';
     }
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_account' . DS . 'views' . DS . 'update' . DS . 'view.html.php';
     $view = new AccountViewUpdate($renderData);
     $view->display($renderData);
 }
コード例 #24
0
ファイル: parameter.php プロジェクト: knigherrant/decopatio
 /**
  * Loads an XML setup file and parses it.
  *
  * @param   string  $path  A path to the XML setup file.
  *
  * @return  object
  *
  * @deprecated  12.1
  * @since   11.1
  */
 public function loadSetupFile($path)
 {
     $result = false;
     if ($path) {
         $xml = new JSimpleXML();
         if ($xml->loadFile($path)) {
             if ($params = $xml->document->params) {
                 foreach ($params as $param) {
                     $this->setXML($param);
                     $result = true;
                 }
             }
         }
     } else {
         $result = true;
     }
     return $result;
 }
コード例 #25
0
ファイル: common.php プロジェクト: ashanrupasinghe/slbcv2
 /**
  * Get and parse file content to xml element
  *
  * @param string $xmlfile   Xml file path
  * @param bool   $array     Convert to array or not
  *
  * @return mixed NULL if load or parse file fail, Array if array is true, otherwise JSimpleXML
  */
 public static function getXML($xmlfile, $array = true)
 {
     /*
             $xml = JFactory::getXMLParser('Simple');
             if ($xml->loadFile($xmlfile)) {
                 if ($array)
                     return T3Common::xmltoarray($xml->document);
                 return $xml->document;
             }
             return null;
     */
     //$xml = JFactory::getXML ($xmlfile);
     if (!class_exists('JSimpleXML')) {
         t3import('core.joomla.simplexml');
     }
     $xml = new JSimpleXML();
     if ($xml->loadFile($xmlfile)) {
         if ($array) {
             return T3Common::xmltoarray($xml->document);
         }
         return $xml->document;
     }
     return null;
 }
コード例 #26
0
ファイル: ilink.php プロジェクト: jomsocial/JSVoice
 function _getXML($path, $xpath = 'control')
 {
     // Initialize variables
     $result = null;
     // load the xml metadata
     if (file_exists($path)) {
         //$xml = JFactory::getXMLParser('Simple');
         $xml = new JSimpleXML();
         if ($xml->loadFile($path)) {
             if (isset($xml->document)) {
                 $result = $xml->document->getElementByPath($xpath);
             }
         }
         return $result;
     }
     return $result;
 }
コード例 #27
0
ファイル: users.php プロジェクト: rlee1962/diylegalcenter
 function import()
 {
     $mainframe =& JFactory::getApplication();
     $db =& JFactory::getDBO();
     $acl =& JFactory::getACL();
     $frontEndGroups = $acl->_getBelow('#__core_acl_aro_groups', 'g1.id, g1.name, COUNT(g2.name) AS level', 'g1.name', false, 'Public Frontend', false);
     $backEndGroups = $acl->_getBelow('#__core_acl_aro_groups', 'g1.id, g1.name, COUNT(g2.name) AS level', 'g1.name', false, 'Public Backend', false);
     $usergroups = array_merge($frontEndGroups, $backEndGroups);
     $xml = new JSimpleXML();
     $xml->loadFile(JPATH_COMPONENT . DS . 'models' . DS . 'userGroup.xml');
     $permissions = new JParameter('');
     foreach ($xml->document->params as $paramGroup) {
         foreach ($paramGroup->param as $param) {
             if ($param->attributes('type') != 'spacer') {
                 $permissions->set($param->attributes('name'), $param->attributes('default'));
             }
         }
     }
     $permissions->set('inheritance', 0);
     $permissions->set('categories', 'all');
     $permissions = $permissions->toString();
     foreach ($usergroups as $usergroup) {
         $K2UserGroup =& JTable::getInstance('K2UserGroup', 'Table');
         $K2UserGroup->name = JString::trim($usergroup->name) . " (Imported from Joomla!)";
         $K2UserGroup->permissions = $permissions;
         $K2UserGroup->store();
         $query = "SELECT * FROM #__users WHERE gid={$usergroup->id}";
         $db->setQuery($query);
         $users = $db->loadObjectList();
         foreach ($users as $user) {
             $query = "SELECT COUNT(*) FROM #__k2_users WHERE userID={$user->id}";
             $db->setQuery($query);
             $result = $db->loadResult();
             if (!$result) {
                 $K2User =& JTable::getInstance('K2User', 'Table');
                 $K2User->userID = $user->id;
                 $K2User->group = $K2UserGroup->id;
                 $K2User->store();
             }
         }
     }
     $mainframe->redirect('index.php?option=com_k2&view=users', JText::_('Import Completed'));
 }
コード例 #28
0
 function _parseRequest()
 {
     $folder = $this->getFolder();
     $type = JRequest::getVar('type', false, 'post');
     if ($type) {
         $query = JRequest::getVar('query', false, 'post', 'BASE64');
         $start = JRequest::getInt('start', 0);
         $num = count(JFolder::files($folder, '.xml$', 1, false));
         switch ($type) {
             case 'clear':
                 $this->_db->setQuery("TRUNCATE TABLE `#__rsseo_pages`");
                 $this->_db->query();
                 $this->_db->setQuery("TRUNCATE TABLE `#__rsseo_redirects`");
                 $this->_db->query();
                 break;
             case 'backup':
                 $buffer = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
                 $buffer .= '<query>' . "\n";
                 $query = $this->decode($query);
                 if (preg_match('# (\\#__.*?) #is', $query['query'], $matches)) {
                     $table = trim($matches[1]);
                 }
                 $buffer .= $this->addTag('table', $table);
                 $this->_db->setQuery($query['query']);
                 $results = $this->_db->loadObjectList();
                 $buffer .= '<rows>' . "\n";
                 foreach ($results as $result) {
                     $buffer .= '<row>' . "\n";
                     foreach ($result as $key => $value) {
                         if (isset($query['primary']) && $key == $query['primary']) {
                             continue;
                         }
                         $buffer .= $this->addTag('column', $value, $key);
                     }
                     $buffer .= '</row>' . "\n";
                 }
                 $buffer .= '</rows>';
                 $buffer .= '</query>';
                 JFile::write($folder . DS . 'package' . $num . '.xml', $buffer);
                 break;
             case 'restore':
                 jimport('joomla.utilities.simplexml');
                 $file = urldecode(JRequest::getVar('file', false, 'post', ''));
                 $xml = new JSimpleXML();
                 $xml->loadFile($file);
                 $root = $xml->document;
                 $table = $root->getElementByPath('table')->data();
                 $rows = $root->getElementByPath('rows')->children();
                 $table_fields = $name = $data = array();
                 $fields = $this->_db->getTableFields($table);
                 foreach ($fields[$table] as $field => $type) {
                     $table_fields[] = $this->_db->NameQuote($field);
                 }
                 foreach ($rows as $row) {
                     $sql = array();
                     $columns = $row->children();
                     foreach ($columns as $column) {
                         $properties = $column->children();
                         foreach ($properties as $prop) {
                             if ($prop->name() == 'name') {
                                 $name[] = $this->_db->NameQuote($prop->data());
                             }
                             if ($prop->name() == 'value') {
                                 $data[] = $this->_db->Quote($prop->data());
                             }
                         }
                     }
                     foreach ($name as $i => $val) {
                         if (!in_array($val, $table_fields)) {
                             unset($name[$i]);
                             unset($data[$i]);
                         }
                     }
                     if (!empty($name) && !empty($data)) {
                         $this->_db->setQuery("INSERT INTO `" . $table . "` (" . implode(',', $name) . ") VALUES (" . implode(',', $data) . "); ");
                         $this->_db->query();
                         unset($name);
                         unset($data);
                     }
                 }
                 break;
         }
     }
     $pack = JRequest::getInt('pack', 0, 'post');
     if ($pack) {
         if (rsseoHelper::is16()) {
             $adapter = JArchive::getAdapter('zip');
             $archivefiles = array();
             $xmlfiles = JFolder::files($folder, '.xml$', 1, true);
             foreach ($xmlfiles as $xmlfile) {
                 $data = JFile::read($xmlfile);
                 $archivefiles[] = array('name' => JFile::getName($xmlfile), 'data' => $data);
             }
             $adapter->create($folder . DS . 'package.zip', $archivefiles);
         } else {
             JArchive::create($folder . DS . 'package.tar', JFolder::files($folder, '.xml$', 1, true), 'gz', '', $folder, true, true);
         }
     }
     die;
 }
コード例 #29
0
ファイル: items.php プロジェクト: navinpai/GEC-Tandav
 function import()
 {
     $mainframe =& JFactory::getApplication();
     jimport('joomla.filesystem.file');
     $db =& JFactory::getDBO();
     $query = "SELECT * FROM #__sections";
     $db->setQuery($query);
     $sections = $db->loadObjectList();
     $xml = new JSimpleXML();
     $xml->loadFile(JPATH_COMPONENT . DS . 'models' . DS . 'category.xml');
     $categoryParams = new JParameter('');
     foreach ($xml->document->params as $paramGroup) {
         foreach ($paramGroup->param as $param) {
             if ($param->attributes('type') != 'spacer') {
                 $categoryParams->set($param->attributes('name'), $param->attributes('default'));
             }
         }
     }
     $categoryParams = $categoryParams->toString();
     $xml = new JSimpleXML();
     $xml->loadFile(JPATH_COMPONENT . DS . 'models' . DS . 'item.xml');
     $itemParams = new JParameter('');
     foreach ($xml->document->params as $paramGroup) {
         foreach ($paramGroup->param as $param) {
             if ($param->attributes('type') != 'spacer') {
                 $itemParams->set($param->attributes('name'), $param->attributes('default'));
             }
         }
     }
     $itemParams = $itemParams->toString();
     $query = "SELECT id, name FROM #__k2_tags";
     $db->setQuery($query);
     $tags = $db->loadObjectList();
     if (is_null($tags)) {
         $tags = array();
     }
     foreach ($sections as $section) {
         $K2Category =& JTable::getInstance('K2Category', 'Table');
         $K2Category->name = $section->title;
         $K2Category->alias = $section->title;
         $K2Category->description = $section->description;
         $K2Category->parent = 0;
         $K2Category->published = $section->published;
         $K2Category->access = $section->access;
         $K2Category->ordering = $section->ordering;
         $K2Category->image = $section->image;
         $K2Category->trash = 0;
         $K2Category->params = $categoryParams;
         $K2Category->check();
         $K2Category->store();
         if (JFile::exists(JPATH_SITE . DS . 'images' . DS . 'stories' . DS . $section->image)) {
             JFile::copy(JPATH_SITE . DS . 'images' . DS . 'stories' . DS . $section->image, JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'categories' . DS . $K2Category->image);
         }
         $query = "SELECT * FROM #__categories WHERE section = {$section->id}";
         $db->setQuery($query);
         $categories = $db->loadObjectList();
         foreach ($categories as $category) {
             $K2Subcategory =& JTable::getInstance('K2Category', 'Table');
             $K2Subcategory->name = $category->title;
             $K2Subcategory->alias = $category->title;
             $K2Subcategory->description = $category->description;
             $K2Subcategory->parent = $K2Category->id;
             $K2Subcategory->published = $category->published;
             $K2Subcategory->access = $category->access;
             $K2Subcategory->ordering = $category->ordering;
             $K2Subcategory->image = $category->image;
             $K2Subcategory->trash = 0;
             $K2Subcategory->params = $categoryParams;
             $K2Subcategory->check();
             $K2Subcategory->store();
             if (JFile::exists(JPATH_SITE . DS . 'images' . DS . 'stories' . DS . $category->image)) {
                 JFile::copy(JPATH_SITE . DS . 'images' . DS . 'stories' . DS . $category->image, JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'categories' . DS . $K2Subcategory->image);
             }
             $query = "SELECT * FROM #__content WHERE catid = {$category->id}";
             $db->setQuery($query);
             $items = $db->loadObjectList();
             foreach ($items as $item) {
                 $K2Item =& JTable::getInstance('K2Item', 'Table');
                 $K2Item->title = $item->title;
                 $K2Item->alias = $item->title;
                 $K2Item->catid = $K2Subcategory->id;
                 if ($item->state == -1) {
                     $K2Item->trash = 1;
                 } else {
                     $K2Item->trash = 0;
                     $K2Item->published = $item->state;
                 }
                 $K2Item->introtext = $item->introtext;
                 $K2Item->fulltext = $item->fulltext;
                 $K2Item->created = $item->created;
                 $K2Item->created_by = $item->created_by;
                 $K2Item->created_by_alias = $item->created_by_alias;
                 $K2Item->modified = $item->modified;
                 $K2Item->modified_by = $item->modified_by;
                 $K2Item->publish_up = $item->publish_up;
                 $K2Item->publish_down = $item->publish_down;
                 $K2Item->access = $item->access;
                 $K2Item->ordering = $item->ordering;
                 $K2Item->hits = $item->hits;
                 $K2Item->metadesc = $item->metadesc;
                 $K2Item->metadata = $item->metadata;
                 $K2Item->metakey = $item->metakey;
                 $K2Item->params = $itemParams;
                 $K2Item->check();
                 $K2Item->store();
                 if (!empty($item->metakey)) {
                     $itemTags = explode(',', $item->metakey);
                     foreach ($itemTags as $itemTag) {
                         $itemTag = JString::trim($itemTag);
                         if (in_array($itemTag, JArrayHelper::getColumn($tags, 'name'))) {
                             $query = "SELECT id FROM #__k2_tags WHERE name=" . $db->Quote($itemTag);
                             $db->setQuery($query);
                             $id = $db->loadResult();
                             $query = "INSERT INTO #__k2_tags_xref (`id`, `tagID`, `itemID`) VALUES (NULL, {$id}, {$K2Item->id})";
                             $db->setQuery($query);
                             $db->query();
                         } else {
                             $K2Tag =& JTable::getInstance('K2Tag', 'Table');
                             $K2Tag->name = $itemTag;
                             $K2Tag->published = 1;
                             $K2Tag->store();
                             $tags[] = $K2Tag;
                             $query = "INSERT INTO #__k2_tags_xref (`id`, `tagID`, `itemID`) VALUES (NULL, {$K2Tag->id}, {$K2Item->id})";
                             $db->setQuery($query);
                             $db->query();
                         }
                     }
                 }
             }
         }
     }
     $mainframe->redirect('index.php?option=com_k2&view=items', JText::_('Import Completed'));
 }
コード例 #30
0
ファイル: xconfig.php プロジェクト: ErickLopez76/offiria
 private function _getPlanSettings()
 {
     // plan-keyword, user-limit, storage, price, duration-to-expire, display-label
     $hardcodedPlan = array(array('professional', 120, '40', '149', '365', 'Venti'), array('plus', 60, '20', '89', '365', 'Grande'), array('starter', 30, '10', '48', '365', 'Tall'));
     $defaultFile = JPATH_ROOT . DS . 'components' . DS . 'com_account' . DS . 'models' . DS . 'accplan.xml';
     $customFile = JPATH_ROOT . DS . 'components' . DS . 'com_account' . DS . 'models' . DS . 'custom-accplan.xml';
     // If acc xml file is not found
     if (!JFile::exists($customFile) && !JFile::exists($defaultFile)) {
         $this->_plans = $hardcodedPlan;
         return false;
     }
     // Use custom file if exists; for white labeling
     if (JFile::exists($customFile)) {
         $defaultFile = $customFile;
     }
     $objXml = new JSimpleXML();
     $objXml->loadFile($defaultFile);
     if ($objXml->document->attributes('default')) {
         $this->_default_plan = $objXml->document->attributes('default');
     }
     // if no plan info is found in the XML file
     if (isset($objXml->document->plan) && count($objXml->document->plan) > 0) {
         $availablePlans = $objXml->document->plan;
         $plans = array();
         //do this
         for ($i = 0; $i < count($availablePlans); $i++) {
             $plans[] = array($availablePlans[$i]->attributes('name'), $availablePlans[$i]->userlimit[0]->data(), $availablePlans[$i]->storage[0]->data(), $availablePlans[$i]->price[0]->data(), $availablePlans[$i]->duration[0]->data(), $availablePlans[$i]->attributes('description'));
         }
         $this->_plans = $plans;
     } else {
         $this->_plans = $hardcodedPlan;
     }
     return true;
 }