Пример #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;
	}
Пример #2
0
 public function Add()
 {
     global $USER;
     if ($USER->isAuthorized()) {
         return \CUser::GetID();
     }
     $this->arFields = array_merge($this->getFields(), $this->defaultFields);
     if (!$this->arFields["EMAIL"]) {
         throw new CRUDException("Please, set email for new user");
     }
     $u = \CUser::GetList($by = "ID", $order = "DESC", array("EMAIL" => $this->arFields["EMAIL"]))->Fetch();
     if ($u) {
         return $u["ID"];
     }
     try {
         $this->generate('LOGIN')->generate('PASSWORD')->generate('GROUP_ID');
     } catch (CRUDGenerateException $e) {
         prentExpection($e->getMessage());
     }
     $objUser = new \CUser();
     $newUserID = $objUser->Add($this->arFields);
     if (!intval($newUserID)) {
         throw new CRUDException("An error was occured while adding new User in CRUD: " . $objUser->LAST_ERROR . ". Line: " . __LINE__);
     } else {
         return $newUserID;
     }
 }
Пример #3
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;
	}
Пример #4
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());
                 }
             }
         }
     }
 }
Пример #5
0
 public function Add()
 {
     \ChromePhp::log("Subscr CRUD Add");
     if ($subscriber = $this->getSubscriber()) {
         $this->user = \CUser::GetByID($subscriber)->Fetch();
         \CUser::Authorize($this->user["ID"]);
         if ($subscribe = \CSubscription::GetList(False, array("ACTIVE" => "Y", "USER_ID" => $this->user["ID"]))->Fetch()) {
             return $subscribe["ID"];
         } else {
             try {
                 return $this->addSubscribe();
             } catch (SubscribeException $e) {
                 prentExpection($e->getMessage());
             }
         }
     } else {
         throw new SubscribeUserException("No user for add to subscribers" . ". Line: " . __LINE__);
     }
 }
Пример #6
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;
	}
Пример #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("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;
	}
Пример #8
0
 private function Add()
 {
      if ($this->checker->withParams(array("NAME" => $this->arFields["NAME"], "IBLOCK_ID" => $this->arFields["IBLOCK_ID"]))->isUnique())
         {
             $this->objElement->Add($this->arFields);
             if ($this->objElement->LAST_ERROR)
             {
                 prentExpection($this->objElement->LAST_ERROR);
             }
         }
 }