Просмотр исходного кода

#2304 Wiki functionality: wiki module settings

Alex Trofimov 6 лет назад
Родитель
Сommit
976b39c3c1

+ 2 - 1
inc/classes/BxDolWiki.php

@@ -290,13 +290,14 @@ class BxDolWiki extends BxDolFactory implements iBxDolFactoryObject
         if ($this->_aObject['module'] != $oPage->getModule())
             return array('code' => 5, 'actions' => array('ShowMsg'), 'msg' => _t('_sys_txt_access_denied'));
 
+        $iDesignBox = getParam($this->_aObject['module'] . '_design_box');
         $aBlock = array(
             'object' => $sPage,
             'cell_id' => $iCellId,
             'module' => $this->_aObject['module'],
             'title_system' => '',
             'title' => '',
-            'designbox_id' => 0, // TODO: add to params
+            'designbox_id' => false === $iDesignBox ? 0 : $iDesignBox,
             'visible_for_levels' => 2147483647, 
             'type' => 'wiki',
             'deletable' => 1,

+ 1 - 0
modules/boonex/wiki/install/langs/en.xml

@@ -6,4 +6,5 @@
     <string name="_bx_wiki_page_home"><![CDATA[Wiki Home]]></string>
     <string name="_bx_wiki_block_home"><![CDATA[Wiki Home]]></string>
     <string name="_bx_wiki_menu_item_title_system_home"><![CDATA[Wiki]]></string>
+    <string name="_bx_wiki_option_design_box"><![CDATA[Default design box for new block]]></string>
 </resources>

+ 4 - 0
modules/boonex/wiki/install/sql/disable.sql

@@ -1,4 +1,8 @@
 
+-- Settings
+
+DELETE FROM `top`, `toc`, `to` USING `sys_options_types` AS `top` LEFT JOIN `sys_options_categories` AS `toc` ON `top`.`id`=`toc`.`type_id` LEFT JOIN `sys_options` AS `to` ON `toc`.`id`=`to`.`category_id` WHERE `top`.`name` = 'bx_wiki';
+
 -- Wiki object
 
 DELETE FROM `sys_objects_wiki` WHERE `object` = 'bx_wiki';

+ 14 - 0
modules/boonex/wiki/install/sql/enable.sql

@@ -1,4 +1,18 @@
 
+-- Settings
+
+SET @iTypeOrder = (SELECT MAX(`order`) FROM `sys_options_types` WHERE `group` = 'modules');
+INSERT INTO `sys_options_types`(`group`, `name`, `caption`, `icon`, `order`) VALUES 
+('modules', 'bx_wiki', '_bx_wiki', 'bx_wiki@modules/boonex/wiki/|std-icon.svg', IF(ISNULL(@iTypeOrder), 1, @iTypeOrder + 1));
+SET @iTypeId = LAST_INSERT_ID();
+
+INSERT INTO `sys_options_categories` (`type_id`, `name`, `caption`, `order`)
+VALUES (@iTypeId, 'bx_wiki', '_bx_wiki', 1);
+SET @iCategId = LAST_INSERT_ID();
+
+INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `check`, `check_params`, `check_error`, `extra`, `order`) VALUES
+('bx_wiki_design_box', '0', @iCategId, '_bx_wiki_option_design_box', 'select', '', '', '', 'a:3:{s:6:"module";s:6:"system";s:6:"method";s:16:"get_design_boxes";s:5:"class";s:16:"TemplServiceWiki";}', 10);
+
 -- Wiki object
 
 INSERT INTO `sys_objects_wiki` (`object`, `uri`, `title`, `module`, `allow_add_for_levels`, `allow_edit_for_levels`, `allow_delete_for_levels`, `allow_translate_for_levels`, `allow_unsafe_for_levels`, `override_class_name`, `override_class_file`) VALUES

+ 25 - 0
template/scripts/BxBaseServiceWiki.php

@@ -177,6 +177,31 @@ class BxBaseServiceWiki extends BxDol
         ));
     }
 
+    /**
+     * @page service Service Calls
+     * @section bx_system_general System Services 
+     * @subsection bx_system_general-wiki Wiki
+     * @subsubsection bx_system_general-get_design_boxes get_design_boxes
+     * 
+     * Get "design boxes" array
+     * 
+     * @see BxBaseServiceWiki::serviceGetDesignBoxes
+     */
+    /** 
+     * @ref bx_system_general-get_design_boxes "get_design_boxes"
+     */
+    public function serviceGetDesignBoxes ()
+    {
+        $o = new BxDolStudioBuilderPageQuery();
+        $aItems = array();
+        if (!$o->getDesignBoxes(array('type' => 'all'), $aItems, false))
+            return array();
+        $a = array();
+        foreach($aItems as $r)
+            $a[$r['id']] = _t($r['title']);
+        return $a;
+    }
+
     protected function _addCssJs ()
     {
         if ($this->_bJsCssAdded)