Example #1
0
function __MPLParseRecordsHTML(&$response, &$arParams, &$arResult)
{
    $JSResult = array();
    $FHParser = new MPLSimpleHTMLParser($response);
    $SHParser = new MPLSimpleHTMLParser($GLOBALS["APPLICATION"]->GetHeadStrings());
    if ($_REQUEST["MODE"] == "LIST") {
        $messageList = $SHParser->getInnerHTML('<!--LOAD_SCRIPT-->', '<!--END_LOAD_SCRIPT-->') . $FHParser->getInnerHTML('<!--RCRDLIST_' . $arParams["ENTITY_XML_ID"] . '-->', '<!--RCRDLIST_END_' . $arParams["ENTITY_XML_ID"] . '-->');
        $messageNavigation = $FHParser->getTagHTML('a[class=feed-com-all]');
        $JSResult += array('status' => true, 'messageList' => $messageList, 'navigation' => $messageNavigation);
    } else {
        if ($_REQUEST["MODE"] == "RECORD") {
            $arParams["RESULT"] = !!$arParams["RESULT"] ? $arParams["RESULT"] : $_REQUEST["MID"];
            $message = $FHParser->getInnerHTML('<!--RCRD_' . $arParams["ENTITY_XML_ID"] . "-" . $arParams["RESULT"] . '-->', '<!--RCRD_END_' . $arParams["ENTITY_XML_ID"] . "-" . $arParams["RESULT"] . '-->');
            $res = $arParams["RECORDS"][$arParams["RESULT"]];
            if (!!$res["FILES"] && $res["PANELS"]["EDIT"] == "Y") {
                $_SESSION["MFI_UPLOADED_FILES_" . $arParams["mfi"]] = array();
                foreach ($res["FILES"] as $key => $arFile) {
                    $_SESSION["MFI_UPLOADED_FILES_" . $arParams["mfi"]][] = $key;
                    if (CFile::IsImage($arFile["FILE_NAME"], $arFile["CONTENT_TYPE"])) {
                        $aImgNew = CFile::ResizeImageGet($key, array("width" => 90, "height" => 90), BX_RESIZE_IMAGE_EXACT, true);
                        $res["FILES"][$key]["THUMBNAIL"] = $aImgNew["src"];
                        $aImgNew = CFile::ResizeImageGet($key, array("width" => $arParams["IMAGE_SIZE"], "height" => $arParams["IMAGE_SIZE"]), BX_RESIZE_IMAGE_PROPORTIONAL, true);
                        $res["FILES"][$key]["SRC"] = $aImgNew["src"];
                    }
                }
            }
            $JSResult += array('errorMessage' => $arParams["ERROR_MESSAGE"], 'okMessage' => $arParams["OK_MESSAGE"], 'status' => true, 'message' => $SHParser->getInnerHTML('<!--LOAD_SCRIPT-->', '<!--END_LOAD_SCRIPT-->') . $message, 'messageBBCode' => $arParams["RECORDS"][$arParams["RESULT"]]["~POST_MESSAGE_TEXT"], 'messageId' => array($arParams["ENTITY_XML_ID"], $arParams["RESULT"]), 'messageFields' => $res);
        }
    }
    $arResult["JSON"] = $JSResult;
}
Example #2
0
 private function parseHTML($response, $mode = "RECORD")
 {
     include_once __DIR__ . "/html_parser.php";
     $JSResult = array();
     $FHParser = new MPLSimpleHTMLParser($response);
     $SHParser = new MPLSimpleHTMLParser($this->getApplication()->GetHeadStrings());
     $arParams =& $this->arParams;
     if ($mode == "LIST") {
         $messageList = $SHParser->getInnerHTML('<!--LOAD_SCRIPT-->', '<!--END_LOAD_SCRIPT-->') . $FHParser->getInnerHTML('<!--RCRDLIST_' . $arParams["ENTITY_XML_ID"] . '-->', '<!--RCRDLIST_END_' . $arParams["ENTITY_XML_ID"] . '-->');
         $messageNavigation = $FHParser->getTagHTML('a[class=feed-com-all]');
         $JSResult += array('status' => "success", 'messageList' => $messageList, 'navigation' => $messageNavigation);
     } else {
         if ($mode == "RECORD") {
             $record = $arParams["RESULT"];
             if ($record <= 0) {
                 $filter = $this->request->getQuery("FILTER");
                 $record = is_array($filter) ? intval($filter["ID"]) : 0;
             }
             $message = $FHParser->getInnerHTML('<!--RCRD_' . $arParams["ENTITY_XML_ID"] . "-" . $record . '-->', '<!--RCRD_END_' . $arParams["ENTITY_XML_ID"] . "-" . $record . '-->');
             $res = false;
             if (array_key_exists($record, $arParams["RECORDS"]) && array_key_exists($record, $arParams["~RECORDS"])) {
                 $res = $arParams["RECORDS"][$record];
                 $res = array_merge($arParams["~RECORDS"][$record], $res, $this->isWeb() ? $res["WEB"] : $res["MOBILE"]);
                 unset($res["WEB"]);
                 unset($res["MOBILE"]);
                 if (!!$res["FILES"] && ($this->arParams["RIGHTS"]["EDIT"] == "ALL" || $this->arParams["RIGHTS"]["EDIT"] == "Y" || $this->arParams["RIGHTS"]["EDIT"] == "OWN" && $res["AUTHOR"]["ID"] == $this->getUser()->getId())) {
                     $_SESSION["MFI_UPLOADED_FILES_" . $arParams["mfi"]] = array();
                     foreach ($res["FILES"] as $key => $arFile) {
                         $_SESSION["MFI_UPLOADED_FILES_" . $arParams["mfi"]][] = $key;
                         if (CFile::IsImage($arFile["FILE_NAME"], $arFile["CONTENT_TYPE"])) {
                             $aImgNew = CFile::ResizeImageGet($key, array("width" => 90, "height" => 90), BX_RESIZE_IMAGE_EXACT, true);
                             $res["FILES"][$key]["THUMBNAIL"] = $aImgNew["src"];
                             $aImgNew = CFile::ResizeImageGet($key, array("width" => $arParams["IMAGE_SIZE"], "height" => $arParams["IMAGE_SIZE"]), BX_RESIZE_IMAGE_PROPORTIONAL, true);
                             $res["FILES"][$key]["SRC"] = $aImgNew["src"];
                         }
                     }
                 }
             }
             $JSResult += array('errorMessage' => $arParams["ERROR_MESSAGE"], 'okMessage' => $arParams["OK_MESSAGE"], 'status' => "success", 'message' => $SHParser->getInnerHTML('<!--LOAD_SCRIPT-->', '<!--END_LOAD_SCRIPT-->') . $message, 'messageBBCode' => $arParams["~RECORDS"][$record]["~POST_MESSAGE_TEXT"], 'messageId' => array($arParams["ENTITY_XML_ID"], $record), 'messageFields' => $res);
         }
     }
     return $JSResult;
 }