RomanL před 8 roky
rodič
revize
b9bd1fc645

+ 30 - 0
modules/boonex/charts/classes/BxChartsConfig.php

@@ -0,0 +1,30 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    Charts Charts
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+bx_import('BxDolModuleConfig');
+
+class BxChartsConfig extends BxBaseModGeneralConfig
+{
+    function __construct($aModule)
+    {
+        parent::__construct($aModule);
+        $this->CNF = array ();
+        $this->_aJsClasses = array(
+           'chart' => 'BxCharts'
+        );
+        $this->_aJsObjects = array(
+            'chart' => 'oCharts'
+        );
+    }
+    
+}
+
+/** @} */

+ 73 - 0
modules/boonex/charts/classes/BxChartsCron.php

@@ -0,0 +1,73 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    Charts Charts
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxChartsCron extends BxDolCron
+{
+    protected $_sModule;
+    protected $_oModule;
+
+    public function __construct()
+    {
+        $this->_sModule = 'bx_charts';
+        $this->_oModule = BxDolModule::getInstance($this->_sModule);
+
+        parent::__construct();
+    }
+
+    function processing()
+    {
+        $this->processingTopByLikes();
+        $this->processingMostActiveProfiles();
+    }
+    
+    function processingTopByLikes()
+    {
+        $aSystems = BxDolVote::getSystems();
+        $aModules = array_keys($this->_oModule->serviceGetTextModules());
+        $sModulesDisabled = explode(',', getParam('bx_charts_chart_top_contents_by_likes_modules_disabled'));
+        $aModules = array_diff($aModules, $sModulesDisabled);
+        $this->_oModule->_oDb->clearTopByLikes();
+        foreach($aModules as $sModule){
+            $oModule = BxDolModule::getInstance($sModule);
+            $sSystem = $oModule->_oConfig->CNF['OBJECT_VOTES'];
+            if(empty($sSystem))
+                continue;
+            $this->_oModule->_oDb->saveTopByLikes($sModule, $aSystems[$sSystem]['table_main']);
+        }
+    }
+    
+    function processingMostActiveProfiles()
+    {
+        $this->_oModule->_oDb->clearMostActiveProfiles();
+        $sContentModule = getParam('bx_charts_chart_most_active_profiles_posts_for_module');
+        $oContentModule = BxDolModule::getInstance($sContentModule);
+        if ($oContentModule){
+            $sContentTable = $oContentModule->_oConfig->CNF['TABLE_ENTRIES'];
+            $sColumnAuthor = $oContentModule->_oConfig->CNF['FIELD_AUTHOR'];
+            if (!empty($sContentTable) && !empty($sColumnAuthor)){
+                $aSystems = BxDolView::getSystems();
+                $aModules = array_keys($this->_oModule->serviceGetProfileModules());
+                $sModulesDisabled = explode(',', getParam('bx_charts_chart_most_active_profiles_modules_disabled'));
+                $aModules = array_diff($aModules, $sModulesDisabled);
+                foreach($aModules as $sModule){
+                    $oModule = BxDolModule::getInstance($sModule);
+                    $sSystem = $oModule->_oConfig->CNF['OBJECT_VIEWS'];
+                    if(empty($sSystem))
+                        continue;
+                    $this->_oModule->_oDb->saveMostActiveProfiles_View($sModule, $aSystems[$sSystem]['table_track']);
+                    $this->_oModule->_oDb->saveMostActiveProfiles_Create($sModule, $sContentTable, $sColumnAuthor);
+                }
+            }
+        }
+    }
+}
+
+/** @} */

+ 69 - 0
modules/boonex/charts/classes/BxChartsDb.php

@@ -0,0 +1,69 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    Charts Charts
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+bx_import('BxDolModuleDb');
+
+class BxChartsDb extends BxBaseModGeneralDb
+{
+    protected $_sTableTopByLikes;
+    protected $_sTableMostActiveProfiles;
+    
+    function __construct(&$oConfig)
+    {
+        parent::__construct($oConfig);
+        $this->_sTableTopByLikes = $this->_sPrefix . 'top_by_likes';
+        $this->_sTableMostActiveProfiles = $this->_sPrefix . 'most_active_profiles';
+    }
+    
+    public function saveTopByLikes($sModuleName, $sTableName)
+    {
+        $sQuery = "INSERT INTO `" . $this->_sTableTopByLikes . "` (`object_id`, `module`, `value`) SELECT `object_id`,'" . $sModuleName . "',`sum` FROM `" . $sTableName . "`";
+        $this->query($sQuery);
+    }
+    
+    public function clearTopByLikes()
+    {
+        $sQuery = "TRUNCATE TABLE `" . $this->_sTableTopByLikes . "`";
+        $this->query($sQuery);
+    }
+    
+    public function getTopByLikes()
+    {
+        return $this->getAll("SELECT * FROM  `" . $this->_sTableTopByLikes . "` ORDER BY `value` DESC LIMIT 0," . intval(getParam('bx_charts_chart_top_contents_by_likes_count')));
+    }
+    
+    public function saveMostActiveProfiles_View($sModuleName, $sTableName)
+    {
+        $sQuery = "INSERT INTO `" . $this->_sTableMostActiveProfiles . "` (`object_id`, `module`, `views_count`) SELECT `object_id`,'" . $sModuleName . "', COUNT(`date`) AS views FROM `" . $sTableName . "` 
+GROUP BY `object_id`";
+        $this->query($sQuery);
+    }
+    
+    public function saveMostActiveProfiles_Create($sModuleName, $sTableName, $sColumnAuthor)
+    {
+        $sQuery = "INSERT INTO `" . $this->_sTableMostActiveProfiles . "` (`object_id`, `module`, `create_count`)  SELECT `sys_profiles`.`content_id`, `sys_profiles`.`type`, COUNT(`" . $sTableName . "`.`id`) FROM `" . $sTableName . "`
+  INNER JOIN `sys_profiles`  ON `sys_profiles`.`id` = `" . $sTableName . "`.`" . $sColumnAuthor . "` WHERE sys_profiles.type='" . $sModuleName . "' GROUP BY `sys_profiles`.`content_id`, `sys_profiles`.`type`";
+        $this->query($sQuery);
+    }
+    
+    public function clearMostActiveProfiles()
+    {
+        $sQuery = "TRUNCATE TABLE `" . $this->_sTableMostActiveProfiles . "`";
+        $this->query($sQuery);
+    }
+    
+    public function getMostActiveProfiles()
+    {
+        return $this->getAll("SELECT SUM(`views_count`) AS views_count, SUM(`create_count`) AS create_count, `object_id`, `module` FROM `bx_charts_most_active_profiles` GROUP BY `object_id`, `module` ORDER BY SUM(`create_count`) DESC, SUM(`views_count`) DESC LIMIT 0," . intval(getParam('bx_charts_chart_most_active_profiles_count')));
+    }
+}
+
+/** @} */

+ 164 - 0
modules/boonex/charts/classes/BxChartsModule.php

@@ -0,0 +1,164 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    Charts Charts
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxChartsModule extends BxDolModule
+{
+    protected $aColors = array('#3366CC','#DC3912','#FF9900','#109618','#990099','#3B3EAC','#0099C6','#DD4477','#66AA00','#B82E2E','#316395','#994499','#22AA99','#AAAA11','#6633CC','#E67300','#8B0707','#329262','#5574A6','#3B3EAC');
+    
+    function __construct(&$aModule)
+    {
+        parent::__construct($aModule);
+    }
+    
+    /**
+     * Service methods
+     */
+    
+    /**
+     * @page service Service Calls
+     * @section bx_charts Charts
+     * @subsection bx_charts-other Other
+     * @subsubsection bx_charts get_profile_modules
+     * 
+     * @code bx_srv('bx_charts', 'get_profile_modules', [...]); @endcode
+     * 
+     * Get list of avaliable prifile modules
+     * 
+     * @return an array with avaliable modules. 
+     * 
+     * @see BxChartsModule::serviceGetProfileModules
+     */
+    /** 
+     * @ref bx_charts-get_profile_modules "get_profile_modules"
+     */
+    public function serviceGetProfileModules()
+    {
+        $aResult = array();
+        $BxDolModuleQuery = BxDolModuleQuery::getInstance();
+        $aModules = $BxDolModuleQuery->getModulesBy(array('type' => 'modules', 'active' => 1));
+        foreach($aModules as $aModule){
+            $oModule = BxDolModule::getInstance($aModule['name']);
+            if($oModule instanceof iBxDolProfileService){
+                $aResult[$aModule['name']] = $aModule['title'];
+            }
+        }
+        return $aResult;
+    }
+    
+    /**
+     * @page service Service Calls
+     * @section bx_charts Charts
+     * @subsection bx_charts-other Other
+     * @subsubsection bx_charts-on-profile get_text_modules
+     * 
+     * @code bx_srv('bx_charts', 'get_text_modules', [...]); @endcode
+     * 
+     * Get list of avaliable text modules
+     * 
+     * @return an array with avaliable modules. 
+     * 
+     * @see BxChartsModule::serviceGetTextModules
+     */
+    /** 
+     * @ref bx_charts-get_text_modules "get_text_modules"
+     */
+    public function serviceGetTextModules()
+    {
+        $aResult = array();
+        $BxDolModuleQuery = BxDolModuleQuery::getInstance();
+        $aModules = $BxDolModuleQuery->getModulesBy(array('type' => 'modules', 'active' => 1));
+        foreach($aModules as $aModule){
+            $oModule = BxDolModule::getInstance($aModule['name']);
+            if($oModule instanceof iBxDolContentInfoService && isset($oModule->_oConfig->CNF['OBJECT_VOTES'])){
+                $aResult[$aModule['name']] = $aModule['title'];
+            }
+        }
+        return $aResult;
+    }
+    
+    /**
+     * @page service Service Calls
+     * @section bx_charts Charts
+     * @subsection bx_charts-other Other
+     * @subsubsection bx_charts-on-profile get_chart_top_contents_by_likes
+     * 
+     * @code bx_srv('bx_charts', 'get_chart_top_contents_by_likes', [...]); @endcode
+     * 
+     * Get Chart Top Contents By Likes
+     * 
+     * @return an html for chart1. 
+     * 
+     * @see BxChartsModule::serviceGetChartTopContentsByLikes
+     */
+    /** 
+     * @ref bx_charts-get_text_modules "get_chart_top_contents_by_likes"
+     */
+    public function serviceGetChartTopContentsByLikes()
+    {
+        return $this->_oTemplate->getChart('TopContentsByLikes');
+    }
+    
+    /**
+     * @page service Service Calls
+     * @section bx_charts Charts
+     * @subsection bx_charts-other Other
+     * @subsubsection bx_charts-on-profile get_chart_most_active_profiles
+     * 
+     * @code bx_srv('bx_charts', 'get_chart_most_active_profiles', [...]); @endcode
+     * 
+     * Get Chart Most Active Profiles
+     * 
+     * @return an html for chart1. 
+     * 
+     * @see BxChartsModule::serviceGetChartMostActiveProfiles
+     */
+    /** 
+     * @ref bx_charts-get_text_modules "get_chart_most_active_profiles"
+     */
+    public function serviceGetChartMostActiveProfiles()
+    {
+        return $this->_oTemplate->getChart('MostActiveProfiles');
+    }
+    
+    public function actionGetChartData($Id = 0)
+    {
+        header('Content-Type: application/json');
+        if ($Id == 'TopContentsByLikes'){
+            $aValues = array('labels' => array(), 'values' => array(), 'colors' => array(), 'links' => array());
+            $aData = $this->_oDb->getTopByLikes();
+            foreach ($aData as $aValue) {
+                $oModule = BxDolModule::getInstance($aValue['module']);
+                array_push($aValues['labels'], $oModule->serviceGetTitle($aValue['object_id']) . ' ' . $oModule->_aModule['title']);
+                array_push($aValues['values'], $aValue['value']);
+                array_push($aValues['links'], $oModule->serviceGetLink($aValue['object_id']));
+              
+            }
+            $aValues['colors'] = array_slice($this->aColors, 0, count($aValues['values']));
+            echo  '{"type": "doughnut", "data":{"labels":' . json_encode($aValues['labels']) . ',"datasets":[{"data":' . json_encode($aValues['values']) . ',"backgroundColor":' . json_encode($aValues['colors']) . '}]}, "links": ' . json_encode($aValues['links']) . '}';
+        }
+        
+        if ($Id == 'MostActiveProfiles'){
+            $aValues = array('labels' => array(), 'values1' => array(), 'values2' => array(), 'links' => array());
+            $aData = $this->_oDb->getMostActiveProfiles();
+            foreach ($aData as $aValue) {
+                $oModule = BxDolModule::getInstance($aValue['module']);
+                array_push($aValues['labels'], $oModule->serviceGetTitle($aValue['object_id']) . ' ' . $oModule->_aModule['title']);
+                array_push($aValues['values1'], $aValue['create_count']);
+                array_push($aValues['values2'], $aValue['views_count']);
+                array_push($aValues['links'], $oModule->serviceGetLink($aValue['object_id']));
+              
+            }
+            echo  '{"type":"bar",  "data": {"labels":' . json_encode($aValues['labels']) . ',"datasets": [{"label": "' . _t('_bx_charts_most_active_profiles_legend_posts') . '","backgroundColor": "' . $this->aColors[0] . '","borderColor": "' . $this->aColors[0] . '","borderWidth": 1,"data": ' . json_encode($aValues['values1']) . '}, {"label": "' . _t('_bx_charts_most_active_profiles_legend_views') . '","backgroundColor": "' . $this->aColors[1] . '","borderColor":"' . $this->aColors[1] . '","borderWidth": 1,"data": ' . json_encode($aValues['values2']) . '}]},"links": ' . json_encode($aValues['links']) . '}';
+        }
+    }
+}
+
+/** @} */

+ 38 - 0
modules/boonex/charts/classes/BxChartsTemplate.php

@@ -0,0 +1,38 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    Charts Charts
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+bx_import ('BxDolModuleTemplate');
+
+class BxChartsTemplate extends BxBaseModGeneralTemplate
+{
+    function __construct(&$oConfig, &$oDb)
+    {
+        parent::__construct($oConfig, $oDb);
+    }
+    
+    function getChart($chartName)
+    {
+        $this->addJs(array('chart.min.js', 'chart.js'));
+        $this->addCss(array('chart.css'));
+        return $this->getJsCode('chart', array('chartName' => $chartName)) . $this->parseHtmlByName('chart.html', array('chart_name' => $chartName));
+    }
+    
+    public function getJsCode($sType, $aParams = array(), $bWrap = true)
+    {
+        $aParams = array_merge(array(
+            'sChartName' => $aParams['chartName'],
+        ), $aParams);
+        
+        return parent::getJsCode($sType, $aParams, $bWrap);
+    }
+}
+
+/** @} */

+ 77 - 0
modules/boonex/charts/install/config.php

@@ -0,0 +1,77 @@
+<?php
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    Charts Charts
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+$aConfig = array(
+
+    /**
+     * Main Section.
+     */
+    'type' => BX_DOL_MODULE_TYPE_MODULE,
+    'name' => 'bx_charts',
+    'title' => 'Charts',
+    'note' => 'Charts module.',
+    'version' => '9.0.0.DEV',
+    'vendor' => 'BoonEx',
+    'help_url' => 'http://feed.una.io/?section={module_name}',
+
+    'compatible_with' => array(
+        '9.0.x'
+    ),
+
+    /**
+     * 'home_dir' and 'home_uri' - should be unique. Don't use spaces in 'home_uri' and the other special chars.
+     */
+    'home_dir' => 'boonex/charts/',
+    'home_uri' => 'charts',
+
+    'db_prefix' => 'bx_charts_',
+    'class_prefix' => 'BxCharts',
+
+    /**
+     * Category for language keys.
+     */
+    'language_category' => 'Charts',
+
+    /**
+     * Installation/Uninstallation Section.
+     */
+    'install' => array(
+        'execute_sql' => 1,
+        'update_languages' => 1,
+        'clear_db_cache' => 1,
+    ),
+    'uninstall' => array (
+        'execute_sql' => 1,
+        'update_languages' => 1,
+        'clear_db_cache' => 1,
+    ),
+    'enable' => array(
+        'execute_sql' => 1,
+        'clear_db_cache' => 1,
+    ),
+    'enable_success' => array(
+        'clear_db_cache' => 1,
+    ),
+    'disable' => array (
+        'execute_sql' => 1,
+        'clear_db_cache' => 1,
+    ),
+    'disable_failed' => array (
+        'clear_db_cache' => 1,
+    ),
+
+    /**
+     * Dependencies Section
+     */
+    'dependencies' => array(),
+);
+
+/** @} */

+ 20 - 0
modules/boonex/charts/install/installer.php

@@ -0,0 +1,20 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    Charts Charts
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxChartsInstaller extends BxBaseModTextInstaller
+{
+    function __construct($aConfig)
+    {
+        parent::__construct($aConfig);
+    }
+}
+
+/** @} */

+ 20 - 0
modules/boonex/charts/install/langs/en.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources name="en" flag="gb" title="English">
+  
+  <string name="_bx_charts"><![CDATA[Charts]]></string>
+  <string name="_bx_charts_adm_stg_cpt_type"><![CDATA[Charts]]></string>
+	<string name="_bx_charts_adm_stg_cpt_category_chart_top_contents_by_likes"><![CDATA[Top contents by likes]]></string>
+	<string name="_bx_charts_adm_stg_cpt_category_chart_most_active_profiles"><![CDATA[Most active profiles]]></string>
+  <string name="_bx_charts_adm_stg_cpt_chart_top_contents_by_likes_modules_enabled"><![CDATA[Enabled for modules]]></string>
+  <string name="_bx_charts_adm_stg_cpt_chart_top_contents_by_likes_count"><![CDATA[Count]]></string>
+  <string name="_bx_charts_adm_stg_cpt_chart_most_active_profiles_modules_enabled"><![CDATA[Enabled for modules]]></string>
+  <string name="_bx_charts_adm_stg_cpt_chart_most_active_profiles_count"><![CDATA[Count]]></string>
+  <string name="_bx_charts_adm_stg_cpt_chart_most_active_profiles_posts_for_module"><![CDATA[For module]]></string>
+  <string name="_bx_charts_page_block_title_system_chart_top_contents_by_likes"><![CDATA[Top contents by likes]]></string>
+  <string name="_bx_charts_page_block_title_chart_top_contents_by_likes"><![CDATA[Top contents by likes]]></string>
+  <string name="_bx_charts_page_block_title_system_chart_most_active_profiles"><![CDATA[Most active profiles]]></string>
+  <string name="_bx_charts_page_block_title_chart_most_active_profiles"><![CDATA[Most active profiles]]></string>
+  <string name="_bx_charts_most_active_profiles_legend_posts"><![CDATA[Posted items]]></string>
+  <string name="_bx_charts_most_active_profiles_legend_views"><![CDATA[Profile views]]></string>
+  
+</resources>

+ 13 - 0
modules/boonex/charts/install/sql/disable.sql

@@ -0,0 +1,13 @@
+SET @sName = 'bx_charts';
+
+-- SETTINGS
+SET @iTypeId = (SELECT `ID` FROM `sys_options_types` WHERE `name` = @sName LIMIT 1);
+DELETE FROM `sys_options` WHERE `category_id` IN (SELECT `ID` FROM `sys_options_categories` WHERE `type_id` = @iTypeId);
+DELETE FROM `sys_options_categories` WHERE `type_id` = @iTypeId;
+DELETE FROM `sys_options_types` WHERE `id` = @iTypeId;
+
+-- PAGES
+DELETE FROM `sys_pages_blocks` WHERE `module` = @sName;
+
+-- CRON
+DELETE FROM `sys_cron_jobs` WHERE `name` LIKE 'bx_charts%';

+ 36 - 0
modules/boonex/charts/install/sql/enable.sql

@@ -0,0 +1,36 @@
+SET @sName = 'bx_charts';
+
+-- SETTINGS
+SET @iTypeOrder = (SELECT IFNULL(MAX(`order`), 0) + 1 FROM `sys_options_types` WHERE `group` = 'modules');
+
+INSERT INTO `sys_options_types` (`group`, `name`, `caption`, `icon`, `order`) 
+VALUES('modules', @sName, '_bx_charts_adm_stg_cpt_type', 'bx_charts@modules/boonex/charts/|std-icon.svg', IF(ISNULL(@iTypeOrder), 1, @iTypeOrder + 1));
+
+SET @iTypeId = LAST_INSERT_ID();
+
+INSERT INTO `sys_options_categories` (`type_id`, `name`, `caption`, `hidden`, `order`) VALUES(@iTypeId,  'bx_charts_chart1', '_bx_charts_adm_stg_cpt_category_chart_top_contents_by_likes', 0, 1);
+SET @iCategoryId = LAST_INSERT_ID();
+
+INSERT INTO `sys_options` (`category_id`, `name`, `caption`, `value`, `type`, `extra`, `check`, `check_params`, `check_error`, `order`) VALUES
+(@iCategoryId, 'bx_charts_chart_top_contents_by_likes_modules_disabled', '_bx_charts_adm_stg_cpt_chart_top_contents_by_likes_modules_enabled', '', 'rlist', 'a:2:{s:6:"module";s:9:"bx_charts";s:6:"method";s:16:"get_text_modules";}', '', '', '', 1),
+(@iCategoryId, 'bx_charts_chart_top_contents_by_likes_count', '_bx_charts_adm_stg_cpt_chart_top_contents_by_likes_count', '5', 'digit', '', '', '', '', 2);
+
+INSERT INTO `sys_options_categories` (`type_id`, `name`, `caption`, `hidden`, `order`) VALUES(@iTypeId,  'bx_charts_chart_most_active_profiles', '_bx_charts_adm_stg_cpt_category_chart_most_active_profiles', 0, 2);
+SET @iCategoryId = LAST_INSERT_ID();
+
+INSERT INTO `sys_options` (`category_id`, `name`, `caption`, `value`, `type`, `extra`, `check`, `check_params`, `check_error`, `order`) VALUES
+(@iCategoryId, 'bx_charts_chart_most_active_profiles_modules_disabled', '_bx_charts_adm_stg_cpt_chart_most_active_profiles_modules_enabled', '', 'rlist', 'a:2:{s:6:"module";s:9:"bx_charts";s:6:"method";s:19:"get_profile_modules";}', '', '', '', 1),
+(@iCategoryId, 'bx_charts_chart_most_active_profiles_posts_for_module', '_bx_charts_adm_stg_cpt_chart_most_active_profiles_posts_for_module', 'bx_posts', 'select', 'a:2:{s:6:"module";s:9:"bx_charts";s:6:"method";s:16:"get_text_modules";}', '', '', '', 2),
+(@iCategoryId, 'bx_charts_chart_most_active_profiles_count', '_bx_charts_adm_stg_cpt_chart_most_active_profiles_count', '5', 'digit', '', '', '', '', 3);
+
+-- PAGES: add page block on dashboard
+SET @iPBCellDashboard = 2;
+SET @iPBOrderDashboard = (SELECT IFNULL(MAX(`order`), 0) FROM `sys_pages_blocks` WHERE `object` = 'sys_dashboard' AND `cell_id` = @iPBCellDashboard LIMIT 1);
+INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES
+('sys_dashboard', @iPBCellDashboard,  @sName, '_bx_charts_page_block_title_system_chart_top_contents_by_likes', '_bx_charts_page_block_title_chart_top_contents_by_likes', 11, 192, 'service', 'a:2:{s:6:"module";s:9:"bx_charts";s:6:"method";s:31:"get_chart_top_contents_by_likes";}', 0, 1, 1, @iPBOrderDashboard),
+('sys_dashboard', @iPBCellDashboard,  @sName, '_bx_charts_page_block_title_system_chart_most_active_profiles', '_bx_charts_page_block_title_chart_most_active_profiles', 11, 192, 'service', 'a:2:{s:6:"module";s:9:"bx_charts";s:6:"method";s:30:"get_chart_most_active_profiles";}', 0, 1, 1, @iPBOrderDashboard + 1);
+
+
+-- CRON
+INSERT INTO `sys_cron_jobs` (`name`, `time`, `class`, `file`, `service_call`) VALUES
+('bx_charts_cron', '0 * * * *', 'BxChartsCron', 'modules/boonex/charts/classes/BxChartsCron.php', '');

+ 32 - 0
modules/boonex/charts/install/sql/install.sql

@@ -0,0 +1,32 @@
+-- TABLES
+CREATE TABLE IF NOT EXISTS `bx_charts_top_by_likes` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `object_id` int(11) NOT NULL default '0',
+  `module` varchar(255) NOT NULL,
+  `value` int(11) NOT NULL default '0',
+  PRIMARY KEY (`id`)
+);
+
+CREATE TABLE IF NOT EXISTS `bx_charts_most_active_profiles` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `object_id` int(11) NOT NULL default '0',
+  `module` varchar(255) NOT NULL,
+  `views_count` int(11) NOT NULL default '0',
+  `create_count` int(11) NOT NULL default '0',
+  PRIMARY KEY (`id`)
+);
+
+-- STUDIO: page & widget
+INSERT INTO `sys_std_pages`(`index`, `name`, `header`, `caption`, `icon`) VALUES
+(3, @sName, '_bx_charts', '_bx_charts', 'bx_charts@modules/boonex/charts/|std-icon.svg');
+
+SET @iPageId = LAST_INSERT_ID();
+
+INSERT INTO `sys_std_widgets` (`page_id`, `module`, `url`, `click`, `icon`, `caption`, `cnt_notices`, `cnt_actions`, `bookmark`) 
+VALUES(@iPageId, @sName, '{url_studio}module.php?name=bx_charts', '', 'bx_charts@modules/boonex/charts/|std-icon.svg', '_bx_charts', '', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:11:"get_actions";s:6:"params";a:0:{}s:5:"class";s:18:"TemplStudioModules";}', 0);
+
+SET @iParentPageId = (SELECT `id` FROM `sys_std_pages` WHERE `name` = 'home');
+SET @iParentPageOrder = (SELECT IFNULL(MAX(`order`), 0) + 1 FROM `sys_std_pages_widgets` WHERE `page_id` = @iParentPageId);
+
+INSERT INTO `sys_std_pages_widgets` (`page_id`, `widget_id`, `order`) VALUES
+(@iParentPageId, LAST_INSERT_ID(), @iParentPageOrder);

+ 10 - 0
modules/boonex/charts/install/sql/uninstall.sql

@@ -0,0 +1,10 @@
+SET @sName = 'bx_charts';;
+
+DROP TABLE IF EXISTS `bx_charts_top_by_likes`, `bx_charts_most_active_profiles`
+
+-- STUDIO WIDGET
+DELETE FROM `tp`, `tw`, `tpw`
+USING `sys_std_pages` AS `tp`, `sys_std_widgets` AS `tw`, `sys_std_pages_widgets` AS `tpw`
+WHERE `tp`.`id` = `tw`.`page_id` AND `tw`.`id` = `tpw`.`widget_id` AND `tp`.`name` = @sName;
+
+

+ 73 - 0
modules/boonex/charts/js/chart.js

@@ -0,0 +1,73 @@
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    Charts Charts
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+function BxCharts(oOptions) {
+    this._sObjName = undefined == oOptions.sObjName ? 'oCharts' : oOptions.sObjName;    // javascript object name, to run current object instance from onTimer
+    this._sChartName = oOptions.sChartName == undefined ? '' : oOptions.sChartName;
+    this._sActionsUri = oOptions.sActionUri;
+    this._sKeyGraph = 'bx_chart_growth_graph_' + this._sChartName;
+    this._oChartOptionsDefault = {};
+    var $this = this;
+    $(document).ready(function () {
+        $this.loadData();
+    });
+}
+
+BxCharts.prototype.loadData = function () {
+    var $this = this;
+    var oGraph = $('.' + this._sKeyGraph);
+    var oGraphWrp = oGraph.parents('div:first');
+    var oGraphErr = oGraphWrp.find('.bx-chart-growth-graph-error').hide();
+
+    bx_loading(oGraphWrp, true);
+
+    $.get(
+    	this._sActionsUri + 'GetChartData/' + $this._sChartName + '/',
+    	{
+    	},
+    	function (oData) {
+    	    bx_loading(oGraphWrp, false);
+
+    	    if (oData.error != undefined) {
+    	        if ($this._oChart)
+    	            $this._oChart.destroy();
+
+    	        oGraphErr.html(oData.error).show();
+    	        return;
+    	    }
+    	    var oDataForChart = oData.data || false;
+    	    var oChartOptions = oData.options || {};
+
+    	    if ($this._oChart)
+    	        $this._oChart.destroy();
+    	   
+    	    $this._oChart = new Chart(oGraph, {
+    	        type: oData.type != undefined ? oData.type : 'line',
+    	        data: oDataForChart,
+    	        options: $.extend({}, $this._oChartOptionsDefault, oChartOptions)
+    	    });
+
+    	    if (oData.links) {
+    	        oGraph.click(function (evt) {
+    	            var activePoint = $this._oChart.getElementAtEvent(evt)[0];
+    	            var data = activePoint._chart.data;
+    	            var datasetIndex = activePoint._datasetIndex;
+    	            var label = data.datasets[datasetIndex].label;
+    	            var value = data.datasets[datasetIndex].data[activePoint._index];
+    	            location.href = oData.links[activePoint._index];
+    	        });
+    	    }
+
+    	},
+    	'json'
+    );
+};
+
+/** @} */

+ 18 - 0
modules/boonex/charts/request.php

@@ -0,0 +1,18 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+* Copyright (c) UNA, Inc - https://una.io
+* MIT License - https://opensource.org/licenses/MIT
+*
+* @defgroup    Charts Charts
+* @ingroup     UnaModules
+*
+* @{
+*/
+
+require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
+
+check_logged();
+
+BxBaseModTextRequest::processAsAction($GLOBALS['aModule'], $GLOBALS['aRequest']);
+
+/** @} */

+ 5 - 0
modules/boonex/charts/template/chart.html

@@ -0,0 +1,5 @@
+<div class="bx-chart-growth">
+    <div class="bx-chart-growth-graph bx-def-border">
+        <canvas class="bx_chart_growth_graph bx_chart_growth_graph___chart_name__" width="100%"></canvas>
+    </div>
+</div>

+ 41 - 0
modules/boonex/charts/template/css/main.css

@@ -0,0 +1,41 @@
+.bx-pwropa-button-container {
+    width: 100%;
+    text-align: center;
+}
+.bx-pwropa-item-container {
+    text-align: center;
+}
+.bx-pwropa-button-container .bx-pwropa-button {
+    float:none;
+    width:100px;
+    margin:0px auto;
+}
+
+.bx_chart-legend {
+  width:100%;
+  bottom:10%;
+}
+
+.bx_chart-legend ul{
+ list-style: none;
+  margin:0;
+  padding:0;
+ text-align:center;
+}
+
+.bx_chart-legend li {
+  cursor:pointer;
+  margin: 10px 4px;
+  display: inline-table;
+}
+.bx_chart-legend li span {
+  position:relative;
+  padding: 6px 20px;
+  border-radius:13px;
+  color:white;
+  z-index:2;
+  margin-right:1rem;
+}
+.bx_chart-legend li:hover {
+    cursor:pointer;
+}

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 10 - 0
modules/boonex/charts/template/images/icons/std-icon.svg


+ 18 - 0
modules/boonex/russian/data/langs/bx_charts/ru.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources name="ru" flag="ru" title="Russian">
+	<string name="_bx_charts"><![CDATA[Графики]]></string>
+	<string name="_bx_charts_adm_stg_cpt_type"><![CDATA[Графики]]></string>
+	<string name="_bx_charts_adm_stg_cpt_category_chart_top_contents_by_likes"><![CDATA[Популярный контент по лайкам]]></string>
+	<string name="_bx_charts_adm_stg_cpt_category_chart_most_active_profiles"><![CDATA[Наиболее активные профили]]></string>
+	<string name="_bx_charts_adm_stg_cpt_chart_top_contents_by_likes_modules_enabled"><![CDATA[Доступно для модулей]]></string>
+	<string name="_bx_charts_adm_stg_cpt_chart_top_contents_by_likes_count"><![CDATA[Количество]]></string>
+	<string name="_bx_charts_adm_stg_cpt_chart_most_active_profiles_modules_enabled"><![CDATA[Доступно для модулей]]></string>
+	<string name="_bx_charts_adm_stg_cpt_chart_most_active_profiles_count"><![CDATA[Количество]]></string>
+	<string name="_bx_charts_adm_stg_cpt_chart_most_active_profiles_posts_for_module"><![CDATA[Для модуля]]></string>
+	<string name="_bx_charts_page_block_title_system_chart_top_contents_by_likes"><![CDATA[Популярный контент по лайкам]]></string>
+	<string name="_bx_charts_page_block_title_chart_top_contents_by_likes"><![CDATA[Популярный контент по лайкам]]></string>
+	<string name="_bx_charts_page_block_title_system_chart_most_active_profiles"><![CDATA[Наиболее активные профили]]></string>
+	<string name="_bx_charts_page_block_title_chart_most_active_profiles"><![CDATA[Наиболее активные профили]]></string>
+	<string name="_bx_charts_most_active_profiles_legend_posts"><![CDATA[Опубликовано]]></string>
+	<string name="_bx_charts_most_active_profiles_legend_views"><![CDATA[Просмотров]]></string>
+</resources>

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů