403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/wbs24.saleemailcvetdvor/lib/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/wbs24.saleemailcvetdvor/lib/Admin.php
<?php
namespace Wbs24\Saleemailcvetdvor;

use Bitrix\Main\Localization\Loc;

class Admin
{
    use Exception;
    use Helper;

    protected $main;
    protected $moduleId;
    protected $suffix;
    protected $wrappers;

    protected $destanations;

    public function __construct($objects = [])
    {
        $this->main = $objects['Main'] ?? new Main($objects);
        $this->moduleId = $this->main->getModuleId();
        $this->suffix = strtoupper($this->moduleId);
        $this->wrappers = new Wrappers($objects);

        $this->$destanations = $this->main->getDestanations();
    }

    public function getAdminLinkOfDestanations()
    {
        $destanationIblockId = $this->main->getDestanationIblockId();
        $link =
            $destanationIblockId
            ?
                ' - <a href="//'.$_SERVER['HTTP_HOST'].'/bitrix/admin/iblock_element_admin.php?IBLOCK_ID='
                .$destanationIblockId
                .'&type=aspro_next_regionality&lang=ru&find_el_y=Y&clear_filter=Y&apply_filter=Y"'
                .' target="_blank">'
                .Loc::getMessage($this->suffix.".EDIT")
                .'</a>'
            : ''
        ;

        return $link;
    }

    public function getCityOptions()
    {
        $options = [];
        $quantity = $this->maxLines;

        for ($i = 1; $i <= $quantity; $i++) {
            $options[] = ["city_".$i, Loc::getMessage($this->suffix.".CITY"), "", ["text", 20]];
            $options[] = ["email_".$i, Loc::getMessage($this->suffix.".EMAIL"), "", ["text", 20]];

            if ($i >= $this->maxCity) break;
        }

        return $options;
    }

    public function getCityOptionsAsHtml()
    {
        $html = '';
        $quantity = $this->maxLines;

        for ($i = 1; $i <= $quantity; $i++) {
            $city = $this->wrappers->Option->get($this->moduleId, 'city_'.$i);
            $email = $this->wrappers->Option->get($this->moduleId, 'email_'.$i);

            $html .=
                '<tr>'
                    .'<td width="50%" class="adm-detail-content-cell-l">'
                        .Loc::getMessage($this->suffix.".CITY").' '
                        .'<input type="text" size="20" maxlength="255" value="'.$city.'" name="city_'.$i.'">'
                    .'</td>'
                    .'<td width="50%" class="adm-detail-content-cell-r">'
                        .Loc::getMessage($this->suffix.".EMAIL").' '
                        .'<input type="text" size="20" maxlength="255" value="'.$email.'" name="email_'.$i.'">'
                    .'</td>'
                .'</tr>'
            ;

            if ($this->needBreakList($city, $counter)) {
                $this->maxCity = $i;
                break;
            }
        }

        return $html;
    }

    public function getDestanationOptions()
    {
        $options = [];

        foreach ($this->$destanations as $i => $destanation) {
            $options[] = ["sender_city_".$i, Loc::getMessage($this->suffix.".SENDER_CITY"), "", ["text", 20]];
            $options[] = ["destanation_ratio_".$i, Loc::getMessage($this->suffix.".RATIO"), "1", ["text", 2]];
        }

        return $options;
    }

    public function getDestanationOptionsAsHtml()
    {
        $html = '';
        $cityListTemplate = $this->getSenderCityListTemplate();

        foreach ($this->$destanations as $i => $destanation) {
            $senderCity = $this->wrappers->Option->get($this->moduleId, 'sender_city_'.$i);
            $cityListHtml = $this->getSenderCityListHtml($cityListTemplate, 'sender_city_'.$i, $senderCity);
            $ratio = $this->wrappers->Option->get($this->moduleId, 'destanation_ratio_'.$i) ?: 1;

            $html .=
                '<tr>'
                    .'<td width="50%" class="adm-detail-content-cell-l">'
                        .Loc::getMessage($this->suffix.".DESTANATION").' '
                        .'<input style="opacity: 0.8;" type="text" size="20" maxlength="255" value="'.$destanation.'" name="destanation_'.$i.'" disabled>'
                    .'</td>'
                    .'<td width="50%" class="adm-detail-content-cell-r">'
                        .Loc::getMessage($this->suffix.".RATIO").' '
                        .'<input type="text" size="2" maxlength="255" value="'.$ratio.'" name="destanation_ratio_'.$i.'">'
                        .' &nbsp; '.Loc::getMessage($this->suffix.".SENDER_CITY").' '
                        .$cityListHtml
                    .'</td>'
                .'</tr>'
            ;
        }

        return $html;
    }

    protected function getSenderCityListTemplate()
    {
        $html = '<select name="%NAME%">';
        $cityList = $this->getSenderCityList();

        foreach ($cityList as $city) {
            $html .= '<option value="'.$city.'">'.$city.'</option>';
        }

        $html .= '</select>';

        return $html;
    }

    protected function getSenderCityListHtml($template, $name, $value)
    {
        $html = str_replace('%NAME%', $name, $template);
        $valueAttribute = 'value="'.$value.'"';
        $html = str_replace($valueAttribute, $valueAttribute.' selected', $html);

        return $html;
    }

    public function getSenderCityList()
    {
        $cityList = [];
        $quantity = $this->maxLines;

        for ($i = 1; $i <= $quantity; $i++) {
            $city = $this->wrappers->Option->get($this->moduleId, 'city_'.$i);
            if ($city) $cityList[] = $city;

            if ($this->needBreakList($city, $counter)) break;
        }

        return array_unique($cityList);
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit