Your IP : 3.15.141.201
<?php
namespace Bitrix\Landing;
class Repo extends \Bitrix\Landing\Internals\BaseTable
{
/**
* Internal class.
* @var string
*/
public static $internalClass = 'RepoTable';
/**
* Create new record and return it new id.
* @param array $fields Fields array.
* @return \Bitrix\Main\Result
*/
public static function add($fields)
{
if (!isset($fields['ACTIVE']) || $fields['ACTIVE'] != 'Y')
{
$fields['ACTIVE'] = 'Y';
}
return parent::add($fields);
}
/**
* Get repository.
* @return array
*/
public static function getRepository()
{
$items = array();
$res = self::getList(array(
'select' => array(
'ID', 'NAME', 'DESCRIPTION', 'SECTIONS', 'PREVIEW'
),
'filter' => array(
'=ACTIVE' => 'Y'
)
));
while ($row = $res->fetch())
{
$items['repo_'. $row['ID']] = array(
'name' => $row['NAME'],
'description' => $row['DESCRIPTION'],
'namespace' => 'bitrix',
'section' => explode(',', $row['SECTIONS']),
'preview' => $row['PREVIEW']
);
}
return $items;
}
/**
* Return full info from rest block.
* @param int $id
* @return array
*/
public static function getBlock($id)
{
static $manifest = array();
if (!isset($manifest[$id]))
{
$manifest[$id] = array();
if (($block = self::getById($id)->fetch()))
{
$manifestLocal = unserialize($block['MANIFEST']);
if (!is_array($manifestLocal))
{
$manifestLocal = array();
}
$manifestLocal['block'] = array(
'name' => $block['NAME'],
'description' => $block['DESCRIPTION'],
'namespace' => 'bitrix',
'section' => explode(',', $block['SECTIONS']),
'preview' => $block['PREVIEW']
);
$manifest[$id] = $manifestLocal;
}
}
return $manifest[$id];
}
/**
* Get row by Id.
* @param int $id Id.
* @return Bitrix\Main\DB\Result
*/
public static function getById($id)
{
return parent::getList(array(
'filter' => array(
'ID' => $id
)
));
}
}