Ver código fonte

#2304 Wiki functionality: various fixes

Alex Trofimov 6 anos atrás
pai
commit
b4693540c8

+ 2 - 0
inc/classes/BxDolWiki.php

@@ -337,6 +337,8 @@ class BxDolWiki extends BxDolFactory implements iBxDolFactoryObject
             $aWikiVer = array('block_id' => $iBlockId);
             if ($bTranslate)
                 $aWikiVer['lang'] = $sLangForTranslate;
+            else
+                $aWikiVer['lang'] = bx_lang_name();
         }
 
         // init form object

+ 5 - 3
inc/classes/BxDolWikiQuery.php

@@ -92,10 +92,12 @@ class BxDolWikiQuery extends BxDolDb
         return $i;
     }
 
-    public function deleteAllRevisions ($iBlockId)
+    public static function deleteAllRevisions ($mixedBlockIds)
     {
-        $aBind = array('block' => $iBlockId);
-        return $this->query("DELETE FROM `sys_pages_wiki_blocks` WHERE `block_id` = :block", $aBind);
+        $oDb = BxDolDb::getInstance();
+        if (!is_array($mixedBlockIds))
+            $mixedBlockId = array($mixedBlockIds);
+        return $oDb->query("DELETE FROM `sys_pages_wiki_blocks` WHERE `block_id` IN(" . $oDb->implode_escape($mixedBlockIds) . ")");
     }
 }
 

+ 2 - 1
inc/js/classes/BxDolWiki.js

@@ -60,7 +60,8 @@ BxDolWiki.prototype.onChangeLangSelector = function (e) {
     var sLangNew = $(e).val();
 
     // save current translation
-    this._oTranslations[this._sCurrentLang] = eContent.val();
+    if (null !== this._sCurrentLang)
+        this._oTranslations[this._sCurrentLang] = eContent.val();
 
     if ('undefined' === typeof(this._oTranslations[sLangNew])) {
         // no saved translation was found - get from server

+ 1 - 1
modules/boonex/wiki/install/sql/install.sql

@@ -2,7 +2,7 @@
 -- Wiki home page
 
 INSERT INTO `sys_objects_page` (`object`, `uri`, `title_system`, `title`, `module`, `cover`, `cover_image`, `type_id`, `layout_id`, `submenu`, `visible_for_levels`, `visible_for_levels_editable`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES
-('bx_wiki_home', 'wiki-home', '', '_bx_wiki_page_home', 'bx_wiki', 0, 0, 1, 5, '', 2147483647, 1, 'r.php?_q=wiki/home', '', '', '', 0, 1, 0, 'BxTemplPageWiki', '');
+('bx_wiki_home', 'wiki-home', '', '_bx_wiki_page_home', 'bx_wiki', 0, 0, 1, 5, '', 2147483647, 1, 'r.php?_q=wiki/wiki-home', '', '', '', 0, 1, 0, 'BxTemplPageWiki', '');
 
 INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `hidden_on`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES
 ('bx_wiki_home', 1, 'bx_wiki', '', '_bx_wiki_block_home', 0, 2147483647, '0', 'wiki', '', 0, 1, 1, 1);

+ 7 - 2
studio/classes/BxDolStudioBuilderPageQuery.php

@@ -396,7 +396,7 @@ class BxDolStudioBuilderPageQuery extends BxDolStudioPageQuery
     {
     	$aBindings = array();
         $sWhereClause = "";
-
+        $aBlockIds = array();
         switch($aParams['type']) {
             case 'by_id':
             	$aBindings = array(
@@ -404,6 +404,7 @@ class BxDolStudioBuilderPageQuery extends BxDolStudioPageQuery
                 );
 
                 $sWhereClause = "AND `tpb`.`id`=:id ";
+                $aBlockIds[] = $aParams['value'];
                 break;
 
             case 'by_object':
@@ -412,6 +413,7 @@ class BxDolStudioBuilderPageQuery extends BxDolStudioPageQuery
                 );
 
                 $sWhereClause = "AND `tpb`.`object`=:object ";
+                $aBlockIds = $this->getColumn("SELECT `id` FROM `sys_pages_blocks` AS `tpb` WHERE 1 " . $sWhereClause, $aBindings);
                 break;
 
             default:
@@ -419,7 +421,10 @@ class BxDolStudioBuilderPageQuery extends BxDolStudioPageQuery
         }
 
         $sSql = "DELETE FROM `tpb` USING `sys_pages_blocks` AS `tpb` WHERE 1 " . $sWhereClause;
-        return (int)$this->query($sSql, $aBindings) > 0;
+        $b = ((int)$this->query($sSql, $aBindings) > 0);
+        if ($b && $aBlockIds)
+            BxDolWikiQuery::deleteAllRevisions($aBlockIds);
+        return $b;
     }
 
     function resetBlocksByPage($sObject, $iCellId)

+ 1 - 1
template/scripts/BxBaseServiceWiki.php

@@ -146,7 +146,7 @@ class BxBaseServiceWiki extends BxDol
             'info' => $sInfo,
             'options' => json_encode(array(
                 'block_id' => $sBlockId,
-                'lang' => $aWikiVer['lang'],
+                'lang' => isset($aWikiVer['lang']) ? $aWikiVer['lang'] : bx_lang_name(),
                 'wiki_action_uri' => $oWikiObject->getWikiUri(),
                 't_confirm_block_deletion' => _t('_sys_wiki_confirm_block_deletion'),
             )),