From 5f00e8c87450afe9337463241a0d3670b3ab60bc Mon Sep 17 00:00:00 2001
From: Roman Bakholdin
Date: Wed, 6 Jun 2018 20:35:11 +0700
Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0?=
=?UTF-8?q?=D1=86=D0=B8=D1=8F=20=D1=82=D0=B5=D1=81=D1=82=D0=BE=D0=B2=D0=BE?=
=?UTF-8?q?=D0=B3=D0=BE=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=20?=
=?UTF-8?q?=D0=B2=20=D1=80=D0=B0=D0=BC=D0=BA=D0=B0=D1=85=20Bitrix=20=D0=BF?=
=?UTF-8?q?=D1=80=D0=BE=D0=B5=D0=BA=D1=82=D0=B0=20=D1=81=20=D0=B8=D1=81?=
=?UTF-8?q?=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8?=
=?UTF-8?q?=D0=B5=D0=BC=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D1=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
getLastNews.php | 36 ++++++++++++
iblocktool.php | 18 ++++++
local/modules/br.base/include.php | 1 +
local/modules/br.base/install/index.php | 56 ++++++++++++++++++
local/modules/br.base/install/version.php | 6 ++
local/modules/br.base/lib/debug.php | 55 +++++++++++++++++
local/modules/br.base/lib/iblocktool.php | 72 +++++++++++++++++++++++
7 files changed, 244 insertions(+)
create mode 100644 getLastNews.php
create mode 100644 iblocktool.php
create mode 100644 local/modules/br.base/include.php
create mode 100644 local/modules/br.base/install/index.php
create mode 100644 local/modules/br.base/install/version.php
create mode 100644 local/modules/br.base/lib/debug.php
create mode 100644 local/modules/br.base/lib/iblocktool.php
diff --git a/getLastNews.php b/getLastNews.php
new file mode 100644
index 0000000..73f0a70
--- /dev/null
+++ b/getLastNews.php
@@ -0,0 +1,36 @@
+Get('https://lenta.ru/rss');
+
+if($sRssResult){
+ $objXML = new CDataXML();
+ $objXML->LoadString($sRssResult);
+ $aResult = $objXML->GetArray();
+
+ foreach($aResult['rss']['#']['channel'][0]['#']['item'] as $iKey => $aItem){
+
+ echo "---------------------\n";
+ echo $aItem['#']['title'][0]['#']."\n";
+ echo $aItem['#']['link'][0]['#']."\n";
+ echo $aItem['#']['description'][0]['#']."\n";
+ echo "---------------------\n";
+ echo "\n";
+
+ if($iKey >= 4){
+ break;
+ }
+ }
+
+}
+
diff --git a/iblocktool.php b/iblocktool.php
new file mode 100644
index 0000000..35f1d47
--- /dev/null
+++ b/iblocktool.php
@@ -0,0 +1,18 @@
+
+require $_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_before.php';
+
+use \Bitrix\Main\Loader;
+use \Br\Base\Debug;
+use \Br\Base\IblockTool;
+
+Loader::includeModule("br.base");
+
+
+$oNewsList = new IblockTool(1, ['ID' => 'DESC'], ['%NAME' => 'Форум'], ['NAME', 'ID']);
+$oNewsList->setCacheTtl(1);
+$oNewsList->setPageCount(10);
+$aNewsListResult = $oNewsList->getList();
+
+
+Debug::pr($aNewsListResult);
+
diff --git a/local/modules/br.base/include.php b/local/modules/br.base/include.php
new file mode 100644
index 0000000..b3d9bbc
--- /dev/null
+++ b/local/modules/br.base/include.php
@@ -0,0 +1 @@
+MODULE_VERSION = $arModuleVersion["VERSION"];
+ $this->MODULE_VERSION_DATE = $arModuleVersion["VERSION_DATE"];
+
+ $this->MODULE_NAME = 'Br Base';
+ $this->MODULE_DESCRIPTION = 'Br Base';
+
+ $this->PARTNER_NAME = "Br";
+ $this->PARTNER_URI = "https://vk.com/romani_nsk";
+ }
+
+ /**
+ * Do install module
+ * @return bool
+ */
+ function DoInstall() {
+ if (IsModuleInstalled("br.base")) {
+ return false;
+ }
+
+ if (!check_bitrix_sessid()) {
+ return false;
+ }
+
+ RegisterModule("br.base");
+ LocalRedirect("/bitrix/admin/partner_modules.php");
+ return true;
+ }
+
+ /**
+ * Uninstall module
+ * @return bool
+ */
+ function DoUninstall() {
+ UnRegisterModule("br.base");
+ LocalRedirect("/bitrix/admin/partner_modules.php");
+ return true;
+ }
+}
diff --git a/local/modules/br.base/install/version.php b/local/modules/br.base/install/version.php
new file mode 100644
index 0000000..6bf7fad
--- /dev/null
+++ b/local/modules/br.base/install/version.php
@@ -0,0 +1,6 @@
+
+$arModuleVersion = array(
+ "VERSION" => "0.0.1",
+ "VERSION_DATE" => "2018-06-06 16:00:00"
+);
+?>
\ No newline at end of file
diff --git a/local/modules/br.base/lib/debug.php b/local/modules/br.base/lib/debug.php
new file mode 100644
index 0000000..e5dbace
--- /dev/null
+++ b/local/modules/br.base/lib/debug.php
@@ -0,0 +1,55 @@
+IsAdmin()) {
+
+ if($iToFile > 0){
+
+ if(strlen($sFileName) <= 0){
+ $sFileName = '/printrlog.txt';
+ }
+ $sFilePath = $_SERVER['DOCUMENT_ROOT'].$sFileName;
+ if(!file_exists( $sFilePath )){
+ fclose(fopen($sFilePath, 'w+'));
+ }
+
+ ob_start();
+ if($iMore == 1){
+ debug_print_backtrace();
+ }
+ is_array($mVar) ? print_r($mVar) : var_dump($mVar);
+ $sVarResult = ob_get_clean();
+
+
+ if($iToFile == 2){
+ file_put_contents($sFilePath, $sVarResult, FILE_APPEND);
+ } else {
+ file_put_contents($sFilePath, $sVarResult);
+ }
+
+ } else {
+ echo '
';
+ if($iMore == 1){
+ echo "
########################################################
";
+ debug_print_backtrace();
+ echo "########################################################
";
+ }
+ is_array($mVar) ? print_r($mVar) : var_dump($mVar);
+ echo "-------
";
+ echo '';
+ }
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/local/modules/br.base/lib/iblocktool.php b/local/modules/br.base/lib/iblocktool.php
new file mode 100644
index 0000000..1a8f92d
--- /dev/null
+++ b/local/modules/br.base/lib/iblocktool.php
@@ -0,0 +1,72 @@
+_aOrder = (is_array($aOrderParam)) ? $aOrderParam : ['ID' => 'ASC'];
+ $this->_aFilter = (is_array($aFilterParam)) ? array_merge(['IBLOCK_ID' => $iIbId], $aFilterParam) : ['IBLOCK_ID' => $iIbId];
+ $this->_aSelect = (is_array($aSelectParam)) ? $aSelectParam : [];
+ $this->_iCacheTtl = 86400;
+ $this->_iPageCount = ["nPageSize" => "20"];
+ $this->_mResult = false;
+ }
+
+ public function setCacheTtl($iCacheTtl){
+ if( (int)$iCacheTtl > 0 ){
+ $this->_iCacheTtl = $iCacheTtl;
+ }
+ }
+
+ public function setPageCount($iPageCount){
+ if( (int)$iPageCount > 0 ){
+ $this->_iPageCount = $iPageCount;
+ }
+ }
+
+ public function getList(){
+
+ $oCache = Cache::createInstance();
+ if ($oCache->initCache($this->_iCacheTtl, md5(serialize(array_merge($this->_aOrder, $this->_aFilter, $this->_aSelect))))) {
+ $this->_mResult = $oCache->getVars();
+ }
+ elseif ($oCache->startDataCache()) {
+ Loader::includeModule("iblock");
+
+ $oResult = \CIBlockElement::GetList($this->_aOrder, $this->_aFilter, false, $this->_iPageCount, $this->_aSelect);
+ $aResult = [];
+ while ($aElement = $oResult->GetNext()) {
+ $aResult[] = $aElement;
+ }
+
+ if(count($aResult) > 0){
+ $this->_mResult['RESULT'] = $aResult;
+ $oCache->endDataCache(array('RESULT' => $aResult));
+ }
+
+ }
+
+ return $this->_mResult;
+ }
+
+
+
+}
\ No newline at end of file