class CAdminMobileMenu
{
const DEFAULT_ITEM_SORT = 100;
private static $arItems = array();
public static function addItem($arItem)
{
if (!isset($arItem["sort"]))
$arItem["sort"] = self::DEFAULT_ITEM_SORT;
self::$arItems[] = $arItem;
return count(self::$arItems);
}
public static function buildMenu($arParams)
{
if (!empty(self::$arItems))
return self::$arItems;
if (isset($arParams["MENU_FILE"]))
{
$arMobileMenuItems = array();
require($_SERVER["DOCUMENT_ROOT"] . $arParams["MENU_FILE"]);
if (!empty($arMobileMenuItems))
foreach ($arMobileMenuItems as $arItem)
self::addItem($arItem);
}
if (isset($arParams["EVENT_NAME"]))
{
foreach (GetModuleEvents("mobileapp", $arParams["EVENT_NAME"], true) as $arHandler)
ExecuteModuleEventEx($arHandler);
}
CAdminMobilePush::OnAdminMobileGetPushSettings();
sortByColumn(self::$arItems, "sort");
return self::$arItems;
}
public static function getDefaultUrl($arParams)
{
if (!self::buildMenu($arParams))
return false;
$firstUrl = '';
foreach (self::$arItems as $arSection)
{
if (!isset($arSection["items"]) || !is_array($arSection["items"]))
continue;
foreach ($arSection["items"] as $arItem)
{
if (isset($arItem["default"]) && $arItem["default"] == true && isset($arItem["data-url"]))
return $arItem["data-url"];
if (isset($arItem["data-url"]) && empty($firstUrl))
$firstUrl = $arItem["data-url"];
}
}
if ($firstUrl == '' && isset($arParams["MOBILE_APP_INDEX_PAGE"]))
$firstUrl = $arParams["MOBILE_APP_INDEX_PAGE"];
return $firstUrl;
}
}
class CAdminMobileDetailTmpl
{
private static function getTitleHtml($title)
{
return '
' . $title . '
';
}
private static function getUpperButtonsHtml($arButtons)
{
$retHtml = '' .
$arSection["TITLE"] . '
';
if ($arSection["TYPE"] == "container")
{
$retHtml .= $arSection["HTML"];
}
else
{
$retHtml .= '
';
if(is_array($arSection["ROWS"]))
{
foreach ($arSection["ROWS"] as $row)
{
$retHtml .= '
' . $row["VALUE"] . ' |
';
}
}
$retHtml .= '
';
if (isset($arSection["BOTTOM"]) && isset($arSection["BOTTOM"]["VALUE"]))
{
$retHtml .= '
';
}
$retHtml .= '
';
}
$retHtml .= '
';
return $retHtml;
}
public static function getHtml($arAdminDetail)
{
$retHtml = '';
if (isset($arAdminDetail["TITLE"]))
$retHtml .= self::getTitleHtml($arAdminDetail["TITLE"]);
if (isset($arAdminDetail["UPPER_BUTTONS"]))
$retHtml .= self::getUpperButtonsHtml($arAdminDetail["UPPER_BUTTONS"]);
if (isset($arAdminDetail["SECTIONS"]) && is_array($arAdminDetail["SECTIONS"]))
foreach ($arAdminDetail["SECTIONS"] as $arSection)
$retHtml .= self::getSectionHtml($arSection);
return $retHtml;
}
}
class CAdminMobileDetail
{
private $arDetail;
public function setTitle($strTitle)
{
$this->arDetail["TITLE"] = $strTitle;
}
public function addUpperButton($arButton)
{
$this->arDetail["UPPER_BUTTONS"][] = $arButton;
}
public function addSection($arSection)
{
$this->arDetail["SECTIONS"][] = $arSection;
}
public function getHtml()
{
return CAdminMobileDetailTmpl::getHtml($this->arDetail);
}
public function getItem()
{
return $this->arDetail;
}
}
class CAdminMobileInterface
{
public static function getCheckBoxesHtml($arCB, $strTitle = '', $arChecked = array(), $arParams = array())
{
if (!is_array($arCB) || empty($arCB))
return false;
$arCBParams["ITEMS"] = $arCB;
if ($strTitle <> '')
$arCBParams["TITLE"] = $strTitle;
if (!empty($arChecked))
$arCBParams["CHECKED"] = $arChecked;
if (is_array($arParams))
foreach ($arParams as $key => $param)
$arCBParams[$key] = $param;
ob_start();
$GLOBALS["APPLICATION"]->IncludeComponent(
'bitrix:mobileapp.interface.checkboxes',
'.default',
$arCBParams,
false
);
$resultHtml = ob_get_contents();
ob_end_clean();
return $resultHtml;
}
}
class CMobileLazyLoad
{
public static function getBase64Stub()
{
return "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIW2N88f7jfwAJWAPJBTw90AAAAABJRU5ErkJggg==";
}
}
class CAdminMobileEdit
{
private static function getCustomAttribs($arField)
{
$strResult = '';
if(isset($arField["CUSTOM_ATTRS"]) && is_array($arField["CUSTOM_ATTRS"]))
{
$strResult .= ' ';
foreach ($arField["CUSTOM_ATTRS"] as $attrName => $attrVal)
$strResult .= ' '.$attrName.'="'.$attrVal.'"';
}
return $strResult;
}
private static function getCommonAttribs($arField)
{
$strResult = '';
$arCommonAttrs = array("ID", "NAME", "HIDDEN");
if(is_array($arField))
{
$strResult .= ' ';
foreach ($arCommonAttrs as $attrName)
{
if(isset($arField[$attrName]))
{
$strResult .= ' '.mb_strtolower($attrName).'="'.$arField[$attrName].'"';
}
}
}
return $strResult;
}
public static function getFieldHtml($arField)
{
global $APPLICATION;
$resultHtml = '';
$someAttribs = self::getCommonAttribs($arField);
$someAttribs .= self::getCustomAttribs($arField);
switch ($arField["TYPE"])
{
case 'BLOCK':
$resultHtml =
'