-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
201 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
; J2XML Wordpress Importer 3.1.10 | ||
; Copyright (C) 2010-2013 Helios Ciancio. All rights reserved. | ||
; J2XML Wordpress Importer 3.3.21 | ||
; Copyright (C) 2010, 2016 Helios Ciancio. All rights reserved. | ||
; License GNU General Public License version 3 or later; see LICENSE.txt, see LICENSE.php | ||
; Note : All ini files need to be saved as UTF-8 | ||
|
||
PLG_J2XML_WORDPRESS="J2XML Wordpress Importer" | ||
PLG_J2XML_WORDPRESS="Wordpress Importer for J2XML" | ||
PLG_J2XML_WORDPRESS_MSG_REQUIREMENTS_LIB="requires J2XML Library 13.8.220 or above." | ||
PLG_J2XML_WORDPRESS_MSG_REQUIREMENTS_XSL="requires the xsl extension for php in order to work properly. For more Information, please visit the official PHP website at the page <a href='http://php.net/manual/en/book.xsl.php'>XSL - Manual</a>" | ||
PLG_J2XML_WORDPRESS_XML_DESCRIPTION="Allows J2XML to import data from Wordpress. Requires J2XML Library 13.8.220 or above." | ||
|
||
PLG_J2XML_WORDPRESS_READMORE_DESC="Enables the <em>Read more..</em> link into articles replacing the tag &lt;!--more--&gt;." | ||
PLG_J2XML_WORDPRESS_READMORE_LABEL="Read More" | ||
PLG_J2XML_WORDPRESS_READMORE_LABEL="Read More" | ||
PLG_J2XML_WORDPRESS_POSTTYPE_DESC="Use custom post type" | ||
PLG_J2XML_WORDPRESS_POSTTYPE_LABEL="Post type" | ||
PLG_J2XML_WORDPRESS_MSG_POSTTYPE_NOT_SUPPORTED="Post type %s not supported." |
6 changes: 3 additions & 3 deletions
6
administrator/language/en-GB/en-GB.plg_j2xml_wordpress.sys.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
; J2XML Wordpress Importer 3.1.4 | ||
; Copyright (C) 2010-2013 Helios Ciancio. All rights reserved. | ||
; J2XML Wordpress Importer 3.3.21 | ||
; Copyright (C) 2010, 2016 Helios Ciancio. All rights reserved. | ||
; License GNU General Public License version 3 or later; see LICENSE.txt, see LICENSE.php | ||
; Note : All ini files need to be saved as UTF-8 | ||
|
||
PLG_J2XML_WORDPRESS="J2XML Wordpress Importer" | ||
PLG_J2XML_WORDPRESS="Wordpress Importer for J2XML" | ||
PLG_J2XML_WORDPRESS_XML_DESCRIPTION="Allows J2XML to import data from Wordpress. Requires J2XML Library 13.8.220 or above." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
; J2XML Wordpress Importer 3.1.10 | ||
; Copyright (C) 2010-2013 Helios Ciancio. All rights reserved. | ||
; J2XML Wordpress Importer 3.3.21 | ||
; Copyright (C) 2010, 2016 Helios Ciancio. All rights reserved. | ||
; License GNU General Public License version 3 or later; see LICENSE.txt, see LICENSE.php | ||
; Note : All ini files need to be saved as UTF-8 | ||
|
||
PLG_J2XML_WORDPRESS="J2XML Wordpress Importer" | ||
PLG_J2XML_WORDPRESS="Wordpress Importer for J2XML" | ||
PLG_J2XML_WORDPRESS_MSG_REQUIREMENTS_LIB="richiede la libreria J2XML 13.8.220 o superiore." | ||
PLG_J2XML_WORDPRESS_MSG_REQUIREMENTS_XSL="richiede l'estensione xsl per php per funzionare. Per informazioni aggiuntive visita la pagina <a href='http://php.net/manual/en/book.xsl.php'>XSL - Manual</a> sul sito ufficiale del progetto PHP." | ||
PLG_J2XML_WORDPRESS_XML_DESCRIPTION="Abilita J2XML ad importare i dati da Wordpress. Richiesta la libreria J2XML 13.8.220 o superiore." | ||
|
||
PLG_J2XML_WORDPRESS_READMORE_DESC="Abilita il link <em>Leggi tutto...</em> negli articoli sostituendo il tag &lt;!--more--&gt;." | ||
PLG_J2XML_WORDPRESS_READMORE_LABEL="Leggi tutto" | ||
PLG_J2XML_WORDPRESS_READMORE_LABEL="Leggi tutto" | ||
PLG_J2XML_WORDPRESS_POSTTYPE_DESC="Usa tipo post personalizzato" | ||
PLG_J2XML_WORDPRESS_POSTTYPE_LABEL="Post type" | ||
PLG_J2XML_WORDPRESS_MSG_POSTTYPE_NOT_SUPPORTED="Post type %s non supportato." |
6 changes: 3 additions & 3 deletions
6
administrator/language/it-IT/it-IT.plg_j2xml_wordpress.sys.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
; J2XML Wordpress Importer 3.1.4 | ||
; Copyright (C) 2010-2013 Helios Ciancio. All rights reserved. | ||
; J2XML Wordpress Importer 3.3.21 | ||
; Copyright (C) 2010, 2016 Helios Ciancio. All rights reserved. | ||
; License GNU General Public License version 3 or later; see LICENSE.txt, see LICENSE.php | ||
; Note : All ini files need to be saved as UTF-8 | ||
|
||
PLG_J2XML_WORDPRESS="J2XML Wordpress Importer" | ||
PLG_J2XML_WORDPRESS="Wordpress Importer for J2XML" | ||
PLG_J2XML_WORDPRESS_XML_DESCRIPTION="Abilita J2XML ad importare i dati da Wordpress. Richiesta la libreria J2XML 13.8.220 o superiore." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
<!-- | ||
/** | ||
* @version 3.1.9 plugins/j2xml/wordpress/12.xsl | ||
* @version 3.3.20 plugins/j2xml/wordpress/12.xsl | ||
* | ||
* @package J2XML | ||
* @subpackage plg_j2xml_wordpress | ||
* @since 3.1 | ||
* | ||
* @author Helios Ciancio <[email protected]> | ||
* @link http://www.eshiol.it | ||
* @copyright Copyright (C) 2010-2013 Helios Ciancio. All Rights Reserved | ||
* @copyright Copyright (C) 2010-2016 Helios Ciancio. All Rights Reserved | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL v3 | ||
* J2XML is free software. This version may have been modified pursuant | ||
* to the GNU General Public License, and as distributed it includes or | ||
|
@@ -32,7 +32,8 @@ | |
<xsl:key name="categories" match="/rss/channel/item[wp:post_type = 'post']/category[@domain='category']" use="@nicename" /> | ||
|
||
<xsl:template match="/rss"> | ||
<j2xml version="12.5.0"> | ||
<j2xml version="15.9.0"> | ||
<xsl:apply-templates select="/rss/channel/wp:author" mode="wp"/> | ||
<xsl:apply-templates select="/rss/channel/item[wp:post_type = 'post']/category[@domain='category']" mode="wp"> | ||
<xsl:sort order="ascending" select="text()"/> | ||
</xsl:apply-templates> | ||
|
@@ -70,15 +71,18 @@ | |
<content> | ||
<id><xsl:value-of select="wp:post_id"/></id> | ||
<title><xsl:value-of select="title"/></title> | ||
<catid><xsl:value-of select="category[@domain='category']/@nicename"/></catid> | ||
<catid><xsl:choose> | ||
<xsl:when test="category[@domain='category']/@nicename != ''"><xsl:value-of select="category[@domain='category']/@nicename"/></xsl:when> | ||
<xsl:otherwise>uncategorised</xsl:otherwise> | ||
</xsl:choose></catid> | ||
<alias><xsl:choose> | ||
<xsl:when test="wp:post_name != ''"><xsl:value-of select="wp:post_name"/></xsl:when> | ||
<xsl:otherwise><xsl:value-of select="translate(substring-after(link, 'http://'), './?=', '----')"/></xsl:otherwise> | ||
</xsl:choose></alias> | ||
<introtext><xsl:value-of select="content:encoded"/></introtext> | ||
<fulltext></fulltext> | ||
<state><xsl:choose> | ||
<xsl:when test="status = 'publish'">1</xsl:when> | ||
<xsl:when test="wp:status = 'publish'">1</xsl:when> | ||
<xsl:otherwise>0</xsl:otherwise> | ||
</xsl:choose></state> | ||
<created><xsl:value-of select="wp:post_date"/></created> | ||
|
@@ -106,4 +110,26 @@ | |
</content> | ||
</xsl:template> | ||
|
||
<xsl:template match="wp:author" mode="wp"> | ||
<user> | ||
<id><xsl:value-of select="wp:author_id"/></id> | ||
<name><xsl:value-of select="wp:author_display_name"/></name> | ||
<username><xsl:value-of select="wp:author_login"/></username> | ||
<email><xsl:value-of select="wp:author_email"/></email> | ||
<password></password> | ||
<block>1</block> | ||
<sendEmail>0</sendEmail> | ||
<registerDate><![CDATA[0000-00-00 00:00:00]]></registerDate> | ||
<lastvisitDate><![CDATA[0000-00-00 00:00:00]]></lastvisitDate> | ||
<activation/> | ||
<params><![CDATA[{"admin_style":"","admin_language":"","language":"","editor":"","helpsite":"","timezone":""}]]></params> | ||
<lastResetTime><![CDATA[0000-00-00 00:00:00]]></lastResetTime> | ||
<resetCount>0</resetCount> | ||
<otpKey/> | ||
<otep/> | ||
<requireReset>0</requireReset> | ||
<group><![CDATA[["Public","Registered"]]]></group> | ||
</user> | ||
</xsl:template> | ||
|
||
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
/** | ||
* @version 3.3.21 plugins/j2xml/wordpress/enable.php | ||
* | ||
* @package J2XML | ||
* @subpackage plg_j2xml_wordpress | ||
* @since 3.1 | ||
* | ||
* @author Helios Ciancio <[email protected]> | ||
* @link http://www.eshiol.it | ||
* @copyright Copyright (C) 2010-2016 Helios Ciancio. All Rights Reserved | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL v3 | ||
* J2XML is free software. This version may have been modified pursuant | ||
* to the GNU General Public License, and as distributed it includes or | ||
* is derivative of works licensed under the GNU General Public License | ||
* or other free or open source software licenses. | ||
*/ | ||
|
||
// no direct access | ||
defined('_JEXEC') or die('Restricted access.'); | ||
|
||
class PlgJ2xmlWordpressInstallerScript | ||
{ | ||
public function install($parent) | ||
{ | ||
// Enable plugin | ||
$db = JFactory::getDbo(); | ||
$query = $db->getQuery(true); | ||
$query->update('#__extensions'); | ||
$query->set($db->quoteName('enabled') . ' = 1'); | ||
$query->where($db->quoteName('type') . ' = ' . $db->quote('plugin')); | ||
$query->where($db->quoteName('element') . ' = ' . $db->quote('wordpress')); | ||
$query->where($db->quoteName('folder') . ' = ' . $db->quote('j2xml')); | ||
$db->setQuery($query); | ||
$db->execute(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
<?php | ||
/** | ||
* @version 3.2.16 plugins/j2xml/wordpress/wordpress.php | ||
* @version 3.3.21 plugins/j2xml/wordpress/wordpress.php | ||
* | ||
* @package J2XML | ||
* @subpackage plg_j2xml_wordpress | ||
* @since 3.1 | ||
* | ||
* @author Helios Ciancio <[email protected]> | ||
* @link http://www.eshiol.it | ||
* @copyright Copyright (C) 2010-2015 Helios Ciancio. All Rights Reserved | ||
* @copyright Copyright (C) 2010-2016 Helios Ciancio. All Rights Reserved | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL v3 | ||
* J2XML is free software. This version may have been modified pursuant | ||
* to the GNU General Public License, and as distributed it includes or | ||
|
@@ -19,6 +19,8 @@ | |
// no direct access | ||
defined('_JEXEC') or die('Restricted access.'); | ||
|
||
use Joomla\Registry\Registry; | ||
|
||
jimport('joomla.plugin.plugin'); | ||
jimport('joomla.application.component.helper'); | ||
jimport('joomla.filesystem.file'); | ||
|
@@ -30,17 +32,35 @@ class plgJ2XMLWordpress extends JPlugin | |
/** | ||
* CONSTRUCTOR | ||
* @param object $subject The object to observe | ||
* @param object $params The object that holds the plugin parameters | ||
* @param object $config The object that holds the plugin parameters | ||
*/ | ||
function __construct(&$subject, $params) | ||
function __construct(&$subject, $config) | ||
{ | ||
parent::__construct($subject, $params); | ||
parent::__construct($subject, $config); | ||
|
||
// Get the parameters. | ||
// TODO: merge $this->params and $config['params'] | ||
if (isset($config['params'])) | ||
{ | ||
if ($config['params'] instanceof Registry) | ||
{ | ||
$this->_params = $config['params']; | ||
} | ||
else | ||
{ | ||
$this->_params = (version_compare(JPlatform::RELEASE, '12', 'ge') ? new Registry : new JRegistry); | ||
$this->_params->loadString($config['params']); | ||
} | ||
} | ||
|
||
$lang = JFactory::getLanguage(); | ||
$lang->load('plg_j2xml_wordpress', JPATH_SITE, null, false, false) | ||
|| $lang->load('plg_j2xml_wordpress', JPATH_ADMINISTRATOR, null, false, false) | ||
|| $lang->load('plg_j2xml_wordpress', JPATH_SITE, null, true) | ||
|| $lang->load('plg_j2xml_wordpress', JPATH_ADMINISTRATOR, null, true); | ||
|
||
JLog::addLogger(array('text_file' => 'j2xml.php', 'extension' => 'plg_j2xml_wordpress'), JLog::ALL, array('plg_j2xml_wordpress')); | ||
JLog::addLogger(array('logger' => 'messagequeue', 'extension' => 'plg_j2xml_wordpress'), JLOG::ALL & ~JLOG::DEBUG, array('plg_j2xml_wordpress')); | ||
} | ||
|
||
/** | ||
|
@@ -50,29 +70,33 @@ function __construct(&$subject, $params) | |
*/ | ||
public function onBeforeImport($context, &$xml) | ||
{ | ||
JLog::add(new JLogEntry(__METHOD__,JLOG::DEBUG,'plg_j2xml_wordpress')); | ||
JLog::add(new JLogEntry($context,JLOG::DEBUG,'plg_j2xml_wordpress')); | ||
JLog::add(new JLogEntry(print_r($this->_params, true),JLOG::DEBUG,'plg_j2xml_wordpress')); | ||
|
||
if (get_class($xml) != 'SimpleXMLElement') | ||
return false; | ||
|
||
$error = false; | ||
if (!class_exists('XSLTProcessor')) | ||
{ | ||
JError::raiseWarning(1, JText::_('PLG_J2XML_WORDPRESS').' '.JText::_('PLG_J2XML_WORDPRESS_MSG_REQUIREMENTS_XSL')); | ||
JLog::add(new JLogEntry(JText::_('PLG_J2XML_WORDPRESS').' '.JText::_('PLG_J2XML_WORDPRESS_MSG_REQUIREMENTS_XSL')),JLOG::WARNING,'plg_j2xml_wordpress'); | ||
$error = true; | ||
} | ||
|
||
if (version_compare(J2XMLVersion::getShortVersion(), '13.8.3') == -1) | ||
{ | ||
JError::raiseWarning(1, JText::_('PLG_J2XML_WORDPRESS').' '.JText::_('PLG_J2XML_WORDPRESS_MSG_REQUIREMENTS_LIB')); | ||
JLog::add(new JLogEntry(JText::_('PLG_J2XML_WORDPRESS').' '.JText::_('PLG_J2XML_WORDPRESS_MSG_REQUIREMENTS_LIB')),JLOG::WARNING,'plg_j2xml_wordpress'); | ||
$error = true; | ||
} | ||
|
||
if ($error) return false; | ||
|
||
$namespaces = $xml->getNamespaces(true); | ||
if (!isset($namespaces['wp'])) | ||
return true; | ||
if ($generator = $xml->xpath('/rss/channel/generator')) | ||
if (preg_match("/http:\/\/wordpress.(org|com)\//", (string)$generator[0]) == false) | ||
if (preg_match("/http(s):\/\/wordpress.(org|com)\//", (string)$generator[0]) == false) | ||
return true; | ||
|
||
$xml->registerXPathNamespace('wp', $namespaces['wp']); | ||
|
@@ -92,30 +116,57 @@ public function onBeforeImport($context, &$xml) | |
{ | ||
return true; | ||
} | ||
|
||
$xsl = file_get_contents(JPATH_ROOT.'/plugins/j2xml/wordpress/'.$version.'.xsl'); | ||
|
||
if ($this->_params->get('readmore', 1)) | ||
{ | ||
str_replace( | ||
array( | ||
'<introtext><xsl:value-of select="content:encoded"/></introtext>', | ||
'<fulltext></fulltext>' | ||
), | ||
array( | ||
'<introtext><xsl:choose><xsl:when test="contains(content:encoded, \'<!--more-->\')"><xsl:value-of select="substring-before(content:encoded, \'<!--more-->\')"/></xsl:when><xsl:otherwise><xsl:value-of select="content:encoded"/></xsl:otherwise></xsl:choose></introtext>', | ||
'<fulltext><xsl:if test="contains(content:encoded, \'<!--more-->\')"><xsl:value-of select="substring-after(content:encoded, \'<!--more-->\')"/></xsl:if></fulltext>' | ||
), | ||
$xsl | ||
); | ||
} | ||
|
||
if ($post_type != 'post') | ||
{ | ||
$post_query = "wp:post_type = 'post'"; | ||
$unsupported_query = "wp:post_type != 'post'"; | ||
foreach (explode(',', str_replace(' ', '', $this->_params->get('post_type'))) as $type) | ||
{ | ||
$post_query .= " or wp:post_type = '".$type."'"; | ||
$unsupported_query .= " and wp:post_type != '".$type."'"; | ||
} | ||
$xsl = str_replace( | ||
"[wp:post_type = 'post']", | ||
"[".$post_query."]", | ||
$xsl | ||
); | ||
} | ||
$test_unsupported = "[".$unsupported_query."]"; | ||
JLog::add(new JLogEntry($xsl,JLOG::DEBUG,'plg_j2xml_wordpress')); | ||
|
||
$xslt = new XSLTProcessor(); | ||
$xslfile = new DOMDocument(); | ||
if ($this->params->get('readmore', 1)) | ||
$xslfile->loadXML($xsl); | ||
|
||
$post_types = $xml->xpath('/rss/channel/item'.$test_unsupported.'/wp:post_type'); | ||
//foreach(array_unique($post_types) as $unsupported) | ||
foreach(array_unique($post_types) as $unsupported) | ||
{ | ||
$xslfile->loadXML( | ||
str_replace( | ||
array( | ||
'<introtext><xsl:value-of select="content:encoded"/></introtext>', | ||
'<fulltext></fulltext>' | ||
), | ||
array( | ||
'<introtext><xsl:choose><xsl:when test="contains(content:encoded, \'<!--more-->\')"><xsl:value-of select="substring-before(content:encoded, \'<!--more-->\')"/></xsl:when><xsl:otherwise><xsl:value-of select="content:encoded"/></xsl:otherwise></xsl:choose></introtext>', | ||
'<fulltext><xsl:if test="contains(content:encoded, \'<!--more-->\')"><xsl:value-of select="substring-after(content:encoded, \'<!--more-->\')"/></xsl:if></fulltext>' | ||
), | ||
file_get_contents(JPATH_ROOT.'/plugins/j2xml/wordpress/'.$version.'.xsl') | ||
) | ||
); | ||
JLog::add(new JLogEntry(JText::sprintf('PLG_J2XML_WORDPRESS_MSG_POSTTYPE_NOT_SUPPORTED', $unsupported),JLOG::WARNING,'plg_j2xml_wordpress')); | ||
} | ||
else | ||
$xslfile->load(JPATH_ROOT.'/plugins/j2xml/wordpress/'.$version.'.xsl'); | ||
|
||
$xslt->importStylesheet($xslfile); | ||
$xml = $xslt->transformToXML($xml); | ||
$xml = simplexml_load_string($xml); | ||
|
||
return true; | ||
} | ||
} |
Oops, something went wrong.