Skip to content

Commit

Permalink
[Kunena#26] Agora: Convert most BBCode tags
Browse files Browse the repository at this point in the history
  • Loading branch information
mahagr committed Aug 28, 2011
1 parent 5e1ef9e commit 0676098
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 18 deletions.
1 change: 1 addition & 0 deletions administrator/components/com_kunenaimporter/CHANGELOG.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
28-August-2011 Matias
# [#26] Agora: Fix avatar gallery import
# [#26] Agora: Fix subscriptions import
# [#26] Agora: Convert most BBCode tags

25-August-2011 Matias
# [#20] Add support for Joomla 1.7: make user creation to work
Expand Down
53 changes: 35 additions & 18 deletions administrator/components/com_kunenaimporter/models/export_agora.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,43 @@ class KunenaimporterModelExport_Agora extends KunenaimporterModelExport {
*/
protected $versionmax = null;

/**
* Get configuration
*/
public function &getConfig() {
if (empty($this->config)) {
$query="SELECT conf_name, conf_value AS value FROM #__agora_config";
$this->config = $this->getExportData($query, 0, 1000, 'conf_name');
}
return $this->config;
}

/**
* Get component version
*/
public function getVersion() {
$query = "SELECT conf_value FROM `#__agora_config` WHERE `conf_name` = 'o_cur_version'";
$this->ext_database->setQuery ( $query );
return $this->ext_database->loadResult ();
$config = $this->getConfig();
return $config['o_cur_version']->value;
}

/**
* Convert BBCode to Kunena BBCode
*
* @param string $s String
*/
protected function parseBBCode(&$s) {
$s = preg_replace ( '/\[s\]/', '[strike]', $s );
$s = preg_replace ( '/\[\/s\]/', '[/strike]', $s );

$s = preg_replace ( '/\[justify\]/', '', $s );
$s = preg_replace ( '/\[\/justify\]/', '', $s );

$s = preg_replace ( '/\[size=[1-9]\]/', '[size=1]', $s );
$s = preg_replace ( '/\[size=(10|11)\]/', '[size=2]', $s );
$s = preg_replace ( '/\[size=(12|13)\]/', '[size=3]', $s );
$s = preg_replace ( '/\[size=(14|15|16|17):(.*?)\]/', '[size=4]', $s );
$s = preg_replace ( '/\[size=(18|19|20|21|22|23)\]/', '[size=5]', $s );
$s = preg_replace ( '/\[size=([2-9][0-9])\]/', '[size=6]', $s );
}

public function countConfig() {
Expand All @@ -62,11 +92,7 @@ public function &exportConfig($start=0, $limit=0) {
$config = array();
if ($start) return $config;

$query="SELECT conf_name, conf_value AS value FROM #__agora_config";
$result = $this->getExportData($query, 0, 1000, 'conf_name');

if (!$result) return $config;

$result = $this->getConfig();
$config['id'] = 1;
// $config['board_title'] = null;
// $config['email'] = null;
Expand Down Expand Up @@ -296,10 +322,6 @@ public function &exportCategories($start=0, $limit=0) {
LEFT JOIN #__agora_categories AS cat ON f.cat_id=cat.id)
ORDER BY id";
$result = $this->getExportData($query, $start, $limit);
foreach ($result as $key=>&$row) {
$row->name = $this->prep($row->name);
$row->description = $this->prep($row->description);
}
return $result;
}

Expand Down Expand Up @@ -333,8 +355,7 @@ public function &exportMessages($start = 0, $limit = 0) {
$result = $this->getExportData ( $query, $start, $limit, 'id' );

foreach ( $result as &$row ) {
$row->subject = $this->prep ( $row->subject );
$row->message = $this->prep ( $row->message );
$this->parseBBCode( $row->message );
}
return $result;
}
Expand Down Expand Up @@ -543,10 +564,6 @@ public function &exportBans($start = 0, $limit = 0) {
return $result;
}

protected function prep($s) {
return $s;
}

/**
* Count total number of avatar galleries to be exported
*/
Expand Down

0 comments on commit 0676098

Please sign in to comment.