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