Ejemplo n.º 1
0
    public function go()
    {
        try
        {
            $this->checker = \Ns\Bitrix\Helper::Create('iblock')->useVariant('checker');
        }
        catch (\Exception $e)
        {
            prentExpection($e->getMessage());
        }
        foreach ($this->dom->find("table.fileinfo") as $table)
        {
            $this->arFields = array();
            $this->arFields["IBLOCK_ID"] = self::ALFADOCUMENTS_IBLOCK_ID;
            $table = \phpQuery::pq($table);
            $this->arFields["NAME"] = $table->find('a:eq(1)')->text();
            $this->arFields["PROPERTY_VALUES"]["LINK"] = $table->find('a:eq(1)')->attr("href");
            prent($this->arFields);
            $this->Add();

        }
        /**
         * Check and add element to infoblock Terminals
         */

        return true;
	}
Ejemplo n.º 2
0
    public function go()
    {
        require_once $_SERVER["DOCUMENT_ROOT"] . "/classes/XML.php";
        $xml = file_get_contents("http://alfabank.by/a-blog.xml");
        $rss = new \XML($xml);
        foreach ($rss->rss->channel->item as $it) {
            $dom = \phpQuery::newDocumentHTML($it->childByName("content:encoded"));
            $date = date_create($it->pubDate->getData());
            $arResult = array(
                "IBLOCK_ID" => self::ABLOG_IBLOCK_ID,
                "NAME" => $it->title->getData(),
                "DATE_ACTIVE_FROM" => date_format($date, 'd.m.Y'),
                "PREVIEW_TEXT" => $it->description->getData(),
                "PREVIEW_PICTURE" => \CFile::MakeFileArray($dom->find('img')->attr('src')),
                "DETAIL_TEXT" => $it->childByName("content:encoded"),
                "CODE" => \Ns\Bitrix\Helper::Create('iblock')->useVariant('text')->translite($it->title->getData()),
                "PROPERTY_VALUES" => array("ORIGINAL_LINK" => $it->link->getData())
            );
            $this->objElement->Add($arResult);
            if ($this->objElement->LAST_ERROR) {
                prentExpection($this->objElement->LAST_ERROR);
            }
        }

        return true;
	}
Ejemplo n.º 3
0
 public function Add($email = '', $name = '')
 {
     global $USER;
     if ($USER->isAuthorized()) {
         return $USER->getID();
     } else {
         try {
             $validator = \Ns\Bitrix\Helper::Create('iblock')->useVariant('validator');
         } catch (\Exception $e) {
             prentExpection($e->getMessage());
         }
         $this->user["email"] = $validator->email($email);
         $this->user["name"] = $validator->xss($name);
         if (!$this->user["email"]) {
             $e["ERROR"]["EMAIL"] = "Y";
         }
         if (!$this->user["name"]) {
             $e["ERROR"]["NAME"] = "Y";
         }
         if (is_array($e)) {
             return $e;
         } else {
             $user = \CUser::GetList($by = "ID", $order = "desc", array("EMAIL" => $this->user["email"]));
             if ($user->SelectedRowsCount() > 0) {
                 $this->user = $user->Fetch();
                 \ChromePhp::log($this->user);
                 try {
                     global $APPLICATION;
                     $this->sendEmailToLogin();
                 } catch (\Exception $e) {
                     prentExpection($e->getMessage());
                 }
                 return True;
             } else {
                 $arFields = array("EMAIL" => $this->user["email"], "NAME" => $this->user["name"]);
                 try {
                     return \Ns\Bitrix\Helper::Create('user')->useVariant('crud')->withFields($arFields)->withGroupId(self::NEW_USER_SUBSCRIBE_GROUP)->Add();
                 } catch (CRUDException $e) {
                     prentExpection($e->getMessage());
                 } catch (\Exception $e1) {
                     prentExpection($e1->getMessage());
                 }
             }
         }
     }
 }
Ejemplo n.º 4
0
    public function go()
    {
        try
        {
            $this->checker = \Ns\Bitrix\Helper::Create('iblock')->useVariant('checker');
        }
        catch (\Exception $e)
        {
            prentExpection($e->getMessage());
        }
        foreach ($this->dom->find("span.cat_block") as $span)
        {
            $this->arFields = array();
            $this->arFields["IBLOCK_ID"] = self::ALFATAXES_IBLOCK_ID;
            /**
             * Получение Даты создания и Имени новости
             */
            $span = \phpQuery::pq($span);
            if ($span->find("strong"))
            {
                $mainSection = $this->findOrCreateSection($span->find("strong")->text());
            }
            $this->arFields["IBLOCK_SECTION_ID"] = $this->findOrCreateSection($span->find("a:eq(0)")->text(), $mainSection);
            foreach ($span->find('table.fileinfo') as $table)
            {
                $table = \phpQuery::pq($table);
                $this->arFields["NAME"] = $table->find("a:eq(1)")->text();
                $this->arFields["PROPERTY_VALUES"]["LINK"] = $table->find("a:eq(1)")->attr("href");
                prent($this->arFields);
                // $this->Add();
            }

            /**
             * Compose name for element of infoblock
             */
        }
        /**
         * Check and add element to infoblock Terminals
         */

        return true;
	}
Ejemplo n.º 5
0
    public function go()
    {
        try
        {
            $this->checker = \Ns\Bitrix\Helper::Create('iblock')->useVariant('checker');
        }
        catch (\Exception $e)
        {
            prentExpection($e->getMessage());
        }
        $table = \phpQuery::pq($this->dom->find("table.mainfnt"));
        foreach ($table->find("tr") as $tr)
        {
            /**
             * Получение Даты создания и Имени новости
             */
            $tr = \phpQuery::pq($tr);
            $this->arFields["PROPERTY_VALUES"]["CITY"] = $tr->find('td:eq(0)')->text();
            $this->arFields["PROPERTY_VALUES"]["ADDRESS"] = $tr->find('td:eq(1)')->text();
            $this->arFields["PROPERTY_VALUES"]["LOCATION"] = $tr->find('td:eq(2)')->text();
            $this->arFields["PROPERTY_VALUES"]["CURRENCY"] = $tr->find('td:eq(3)')->text();
            $this->arFields["PROPERTY_VALUES"]["OPERATION_TIME"] = $tr->find('td:eq(4)')->text();
            $this->arFields["PROPERTY_VALUES"]["STATUS"] = $tr->find('td:eq(5)')->text();
            if ($this->arFields["PROPERTY_VALUES"]["LOCATION"] == "РАСПОЛОЖЕНИЕ") {
                continue;
            }
            /**
             * Compose name for element of infoblock
             */
            $this->arFields["NAME"] = $this->composeName();
            $this->Add();
        }
        /**
         * Check and add element to infoblock Terminals
         */
        return true;
	}
Ejemplo n.º 6
0
            $item["IBLOCK_ID"],
            $item["ID"],
            0,
            array("SECTION_BUTTONS"=>false, "SESSID"=>false)
        );
        $item["EDIT_LINK"] = $arButtons["edit"]["edit_element"]["ACTION_URL"];
        $item["DELETE_LINK"] = $arButtons["edit"]["delete_element"]["ACTION_URL"];

        if ($item["PREVIEW_PICTURE"]) {
            if ($arParams["RESIZE_PREVIEW_PICTURE"] === "Y") {
                $item["PREVIEW_PICTURE"] = \imageResize(array("WIDTH" => $arParams["RESIZE_WIDTH"], "HEIGHT" => $arParams["RESIZE_HEIGHT"], "MODE" => "cut"), \CFile::GetPath($item["PREVIEW_PICTURE"]));
            } else {
                $item["PREVIEW_PICTURE"] = \CFile::GetPath($item["PREVIEW_PICTURE"]);
            }
        }
        if ($arParams["SHOW_DATE"] === "Y") {
            $item["DATE"]["DAY"] = FormatDate('d', MakeTimeStamp($item["DATE_ACTIVE_FROM"]));
            $item["DATE"]["MONTH"] = FormatDate('F', MakeTimeStamp($item["DATE_ACTIVE_FROM"]));
        }
        if (!$item["PREVIEW_TEXT"]) {
            if ($arParams["CUT_TEXT_VALUE"]) {
                $item["PREVIEW_TEXT"] = \Ns\Bitrix\Helper::Create('iblock')->useVariant('text')->cut($item["PREVIEW_TEXT"], ($arParams["CUT_TEXT_VALUE"]) ? $arParams["CUT_TEXT_VALUE"] : false);
            }
        }
        $arResult["ITEMS"][$item["ID"]] = $item;
    }

    $obCache->EndDataCache(array("arResult" => $arResult));
}

$this->IncludeComponentTemplate();
Ejemplo n.º 7
0
    public function go()
    {
        try
        {
            $this->checker = \Ns\Bitrix\Helper::Create('iblock')->useVariant('checker');
        }
        catch (\Exception $e)
        {
            prentExpection($e->getMessage());
        }
        $table = \phpQuery::pq($this->dom->find("div#catalog")->find("table#tbl"));
        $index = 0;
        foreach ($table->find("tr") as $tr)
        {
            var_dump($index);
            if (++$index == 1) {
                continue;
            }
            $this->arFields = array();
            $this->arFields["IBLOCK_ID"] = self::ALFATERMINALS_IBLOCK_ID;
            $this->arFields["IBLOCK_SECTION_ID"] = ($this->type == "alfa") ? self::ALFATERMINALS_SECTION_ID : self::SBSTERMINALS_SECTION_ID;
            /**
             * Получение информации о банкомете
             */
            $tr = \phpQuery::pq($tr);
            /**
             * 1. Name
             */
            $this->arFields["NAME"] = $tr->find('td:eq(0)')->find("a")->text();
            $infoLink = $tr->find('td:eq(0)')->find("a")->attr("href");
            /**
             * 2. State
             */
            $this->arFields["PROPERTY_VALUES"]["STATE"] = $tr->find('td:eq(1)')->text();
            /**
             * 3. City as link
             */
            $this->arFields["PROPERTY_VALUES"]["BIND_CITY"] = $this->findCity($tr->find('td:eq(2)')->text());
            /**
             * 4. City text
             */
            $this->arFields["PROPERTY_VALUES"]["CITY"] = $tr->find('td:eq(2)')->text();
            /**
             * 5. Address
             */
            $this->arFields["PROPERTY_VALUES"]["ADDRESS"] = $tr->find('td:eq(3)')->text();
             /**
             * 5. Operating mode
             */
            $this->arFields["PROPERTY_VALUES"]["OPERATION_TIME"] = $tr->find('td:eq(4)')->text();
            /**
             * Find nessesary element of link
             */
            try
            {
                $this->arFields["PROPERTY_VALUES"]["WORK_TYPES"] = $this->findWorkType($this->arFields["PROPERTY_VALUES"]["OPERATION_TIME"]);
            }
            catch (\Exception $e)
            {
                prentExpection($e->getMessage());
            }

            $html = file_get_contents("http://www.alfabank.by" . $infoLink);
            $fullInfo = \phpQuery::newDocumentHTML($html);

            $info = \phpQuery::pq($fullInfo->find("div.content"));

            /**
             * Compose currency string
             */
            $info->find("div.section.s1")->find('table')->find('tr');
            foreach ($info->find("div.section.s4")->find('ul')->find('li') as $li) {
                $li = \phpQuery::pq($li);
                $strCurrency .= $li->text() . " ";
            }
            $this->arFields["PROPERTY_VALUES"]["CURRENCY"] = trim($strCurrency); unset($strCurrency);
            /**
             * Lat & len of map
             */
            // $coordinates = explode(",", $info->find("div.section:eq(5)")->find("div.ya_map_data")->text());
            $coordinates = $info->find("div.section:eq(5)")->find("div.ya_map_data")->text();
            $this->arFields["PROPERTY_VALUES"]["POINT"] = $coordinates;

            /**
             * Compose name for element of infoblock
             */
            prent($this->arFields);
            $this->Add();
        }
        /**
         * Check and add element to infoblock Terminals
         */

        return true;
	}