Обновляет форму

@return string

@since 1.01
182644
private function actionUpdate()
    {
        $oldName = arg('update');
        $newName = arg('name');
        $forms = $this->plugin->getForms();
        if ($oldName == $newName || $forms->get($newName) === false)
        {
            $forms->update($oldName, arg('code'), arg('title'));

            $url = arg('submitURL');
            if ($oldName != $newName)
            {
                $forms->rename($oldName, $newName);
                $url = str_replace('edit=' . $oldName, 'edit=' . $newName, $url);
            }
            HTTP::redirect($url);
        }
        ErrorMessage('Форма с таким именем уже есть! Укажите другое имя.');
        return $this->actionEditDialog($oldName);
    }
840556
protected function getValue()
    {
        if (isset($this->_maker, $this->_name)){
            $parent = $this->_maker->getValue(); // Берется значения родителя (родитель, возможно, берет значения у своего родителя..)
            return isset($parent[$this->_name])? $parent[$this->_name] : null; // Из него выбирается своё
        }else{
            return $this->_value;
        }
    }
110945
public function current() {
		if ($this->string === null) {
			$this->string = fgets($this->file);
		}
		
		$string = rtrim($this->string, "\n\r");
		
		if ($this->delimiter === null) {
			return $string;
		} 
		
		$dataRaw = explode($this->delimiter, $string);
		$data    = [];

		if ($this->partsNames === null) {
			foreach ($dataRaw as $key => $part) {
				$data[self::UNNAMED_PREFIX . $key] = $part;
			}
			
			return $data;
		}
		
		foreach ($dataRaw as $key => $part) {
			if (isset($this->partsNames[$key])) {
				$data[$this->partsNames[$key]] = $part;
				continue;
			}
			
			$data[self::UNNAMED_PREFIX . $key] = $part;
		}

		return $data;
	}
1369818
public function getElement()
    {
        $this->startCommentBlock();
        foreach ($this->description as $line) {
            $this->addLine($line);
        }
        $this->addBlankLine();

        if (count($this->var_types) > 0) {
            $type_ltgh = max(array_map('mb_strlen', $this->var_types));
            $var_ltgh = max(array_map('mb_strlen', array_keys($this->var_types)));
            foreach ($this->var_types as $name => $type) {
                $type = str_pad($type, $type_ltgh);
                $param = str_pad($name, $var_ltgh);
                $this->addLine('@param '.$type.'$'.$param.' '.$this->var_descriptions[$name]);
            }
            $this->addBlankLine();
        }

        if (count($this->params) > 0) {
            $params_ltgh = array_map('strlen', array_keys($this->params));
            foreach ($this->params as $param => $value) {
                $this->addLine('@'.str_pad($param, max($params_ltgh)).' '.$value);
            }
        }

        $this->endCommentBlock();
        return $this->lines;
    }
1296529
private function _cfPrefix(): string
    {
        if ($this->cfPrefix && ($cfPrefix = rtrim(Craft::parseEnv($this->cfPrefix), '/')) !== '') {
            return $cfPrefix . '/';
        }
        return '';
    }
1346766
public function toString() {
		$txt = $this->getName ();
		$txt .= $this->getPesel ();
		$txt .= "id:";
		$txt .= $this->getId ();
		$txt .= "oid:";
		$txt .= $this->getOddzialId ();
		$txt .= "d:";
		$data = $this->getDataKategoryzacji ();
		if ($data instanceof \DateTime) {
			$txt .= $this->getDataKategoryzacji ()->format ( "Y-m-d" );
		} else {
			$txt .= $this->getDataKategoryzacji ();
		}
		return $txt;
	}
623002
public function main()
    {
        $mainPageHTML = '';
        $dbMaterials = array();

        // Получим все материалы
        if (
        dbQuery('samsoncms\api\Material')
            ->join('user')
            ->cond('Active', 1)
            ->cond('Draft', 0)
            ->order_by('Created', 'DESC')
            ->cond('Name', "", dbRelation::NOT_EQUAL)
            ->limit(5)
            ->exec($dbMaterials)
        ) {
            // Render material rows
            $rowsHTML = '';
            foreach ($dbMaterials as $dbMaterial) {
                $rowsHTML .= $this->view('main/row')
                    ->set($dbMaterial, 'material')
                    ->set(isset($dbMaterial->onetoone['_user']) ? $dbMaterial->onetoone['_user'] : array(), 'user')
                    ->output();
            }

            for ($i = sizeof($dbMaterials); $i < 5; $i++) {
                $rowsHTML .= $this->view('main/row')->output();
            }

            // Render main template
            $mainPageHTML = $this->view('main/index')->set($rowsHTML, 'rows')->output();
        }

        // Return material block HTML on main page
        return $mainPageHTML;
    }
159255
public function getFileInfo()
    {
        return array(
            "originalName" => $this->oriName ,
            "name" => $this->fileName ,
            "url" => $this->fullName ,
            "size" => $this->fileSize ,
            "type" => $this->fileType ,
            "state" => $this->stateInfo
        );
    }
789059
public function getLink()
    {
        if ( ! $this->has())
        {
            throw new NotFoundException('Не удалось найти запрошенный ресурс.');
        }

        $response = $this->client->send(new Request($this->uri->withPath($this->uri->getPath().'resources/download')
                                                              ->withQuery(http_build_query([
                                                                  'path'       => (string) $this->getPath()
                                                              ], null, '&')), 'GET'));

        if ($response->getStatusCode() == 200)
        {
            $response = json_decode($response->getBody(), true);

            if (isset($response['href']))
            {
                return $response['href'];
            }
        }

        throw new \UnexpectedValueException('Не удалось запросить разрешение на скачивание, повторите заново');
    }
632328
protected function generateErrorMessage(): string
    {
        switch ($this->type) {
            case 'image/png':
                $readableType = _('PNGファイル');
                break;
            case 'image/jpeg':
                $readableType = _('JFIF (JPEG) ファイル');
                break;
            case 'image/svg+xml':
                $readableType = _('SVGファイル');
                break;
        }
        return sprintf(_('「%1$s」は妥当な%2$sではありません。'), $this->filename, $readableType);
    }
892565
function render()
    {
        $result = '';     # Выходной код

        if (empty($this->form['name'])) $result .= ErrorBox(errFormHasNoName);
        if (count($this->form['fields'])) foreach($this->form['fields'] as $item) {
            # Проверяем права доступа к элементу
            if ((!isset($item['access'])) || (UserRights($item['access']))) {
                $this->field_prep($item);
                $control = 'render_'.$item['type'];
                #if (method_exists($this, $control)) $result .= call_user_func(array($this, $control), $item);
                if (method_exists($this, $control)) {
                    $result .= $this->$control($item);
                }
                else
                {
                    Eresus_Kernel::app()->getPage()->addErrorMessage(
                        sprintf(errFormUnknownType, $item['type'], $this->form['name']));
                }
            }
        }
        $this->onsubmit .= $this->validator;
        if (!empty($this->onsubmit))
        {
            Eresus_Kernel::app()->getPage()->addScripts("
				function ".$this->form['name']."Submit()
				{
					var result = true;
					var form = document.forms.namedItem('".$this->form['name']."');
					".$this->onsubmit.";
					return result;
				}
			");
        }
        # FIXME: sub_id - устаревший элемент
        $referer = arg('sub_id') ?
            Eresus_Kernel::app()->getPage()->url(array('sub_id'=>'')) :
            Eresus_Kernel::app()->getPage()->url(array('id'=>''));
        $this->hidden .= "\t\t".'<input type="hidden" name="submitURL" value="'.$referer.'" />';
        $this->hidden = "\t<div class=\"hidden\">\n\t\t{$this->hidden}\n\t</div>";
        $result =
            "<form ".(empty($this->form['name'])?'':'name="'.$this->form['name'].'" id="'.$this->form['name'].'" ')."action=\"".
            Eresus_Kernel::app()->getPage()->url()."\" method=\"post\"".(empty($this->onsubmit)?'':' onsubmit="return '.$this->form['name'].'Submit();"').($this->file?' enctype="multipart/form-data"':'').">\n".
            $this->hidden.
            "\n\t<table width=\"100%\">\n".
            "\t\t<tr><td style=\"height: 0px; font-size: 0px; padding: 0px;\">".img('style/dot.gif')."</td><td style=\"width: 100%; height: 0px; font-size: 0px; padding: 0px;\">".img('style/dot.gif')."</td>\n\t\t</tr>\n".
            $result.
            "\t\t<tr><td colspan=\"2\" class=\"ui-button-box\"><br />".
            ((isset($this->form['buttons']) && isset($this->form['buttons']['ok']))?'<button name="form_ok" type="submit">'.$this->form['buttons']['ok'].'</button> ':'').
            (!isset($this->form['buttons']) || in_array('ok', $this->form['buttons'])?"<button name=\"form_ok\" type=\"submit\">".strOk."</button> ":'').

            ((isset($this->form['buttons']) && isset($this->form['buttons']['apply']))?'<button name="form_apply" type="submit" onclick="formApplyClick(\''.$this->form['name'].'\')">'.$this->form['buttons']['apply']."</button> ":'').
            (!isset($this->form['buttons']) || in_array('apply', $this->form['buttons'])?"<button name=\"form_apply\" type=\"submit\" onclick=\"formApplyClick('".$this->form['name']."')\">" . strApply . '</button> ':'').

            ((isset($this->form['buttons']) && isset($this->form['buttons']['reset']))?'<button name="form_reset" type="reset">'.$this->form['buttons']['reset'].'</button> ':'').
            (isset($this->form['buttons']) && in_array('reset', $this->form['buttons'])?"<button name=\"form_reset\" type=\"reset\">".strReset."</button> ":'').

            ((isset($this->form['buttons']) && isset($this->form['buttons']['cancel']) && (!is_array($this->form['buttons']['cancel'])))?'<input name="form_cancel" type="button" onclick="javascript:history.back();">' . $this->form['buttons']['cancel'] . '</button>' : '').
            ((!isset($this->form['buttons']) || (in_array('cancel', $this->form['buttons'])))?"<button name=\"form_cancel\" type=\"button\" onclick=\"javascript:history.back();\">".strCancel . '</button>' :'').
            ((isset($this->form['buttons']['cancel']) && (is_array($this->form['buttons']['cancel'])))?"<button name=\"form_cancel\" type=\"button\" onclick=\"window.location.href='".$this->form['buttons']['cancel']['url']."'\">" . $this->form['buttons']['cancel']['label'] . '</button>':'').

            "</td>\n\t\t</tr>\n".
            "\t</table>\n</form>\n";

        return $result;
    }
717937
public function getUnrestrictedValue()
    {
        if ($this->unrestricted_value)
        {
            return $this->unrestricted_value;
        }

        //Оно может быть не сохранено если определяли по ip
        $result = [];

        $result[] = ArrayHelper::getValue($this->data, 'region_with_type');
        $result[] = ArrayHelper::getValue($this->data, 'area_with_type');
        $result[] = ArrayHelper::getValue($this->data, 'city_with_type');
        $result[] = ArrayHelper::getValue($this->data, 'settlement_with_type');
        $result[] = ArrayHelper::getValue($this->data, 'street_with_type');

        $result = array_unique($result);

        foreach ($result as $key => $value)
        {
            if (!$value)
            {
                unset($result[$key]);
            }
        }

        return implode(", ", $result);
    }
754286
public function toString()
    {
        if ($this->hidden) {
            return '';
        }
        
        return trim($this->getName() .
            (!empty($this->version) && !$this->version->hidden ? ' ' . $this->getVersion() : '')) .
            (!empty($this->edition) ? ' ' . $this->edition : '');
    }
876162
public function toString()
    {
        if ($this->max !== -1) {
            return vsprintf('{length: %d <= x <= %d}', [
                $this->min,
                $this->max,
            ]);
        }

        return vsprintf('{length: %d <= x}', [
            $this->min,
        ]);
    }
1324090
public function toString()
    {
        if (!empty($this->alias)) {
            return $this->alias;
        }

        $version = '';

        if (!empty($this->nickname)) {
            $version .= $this->nickname . ' ';
        }

        if (!empty($this->value)) {
            if (preg_match("/([0-9]+)(?:\.([0-9]+))?(?:\.([0-9]+))?(?:\.([0-9]+))?(?:([ab])([0-9]+))?/", $this->value, $match)) {
                $v = [ $match[1] ];

                if (array_key_exists(2, $match) && strlen($match[2])) {
                    $v[] = $match[2];
                }

                if (array_key_exists(3, $match) && strlen($match[3])) {
                    $v[] = $match[3];
                }

                if (array_key_exists(4, $match) && strlen($match[4])) {
                    $v[] = $match[4];
                }

                if (!empty($this->details)) {
                    if ($this->details < 0) {
                        array_splice($v, $this->details, 0 - $this->details);
                    }

                    if ($this->details > 0) {
                        array_splice($v, $this->details, count($v) - $this->details);
                    }
                }

                if (isset($this->builds) && !$this->builds) {
                    $count = count($v);
                    for ($i = 0; $i < $count; $i++) {
                        if ($v[$i] > 999) {
                            array_splice($v, $i, 1);
                        }
                    }
                }

                $version .= implode($v, '.');

                if (array_key_exists(5, $match) && strlen($match[5])) {
                    $version .= $match[5] . (!empty($match[6]) ? $match[6] : '');
                }
            }
        }

        return $version;
    }
311856
public function getHTML()
    {
        // Открывающий тег
        $html = '<' . $this->tagName;

        /* Добавляем атрибуты */
        foreach ($this->attrs as $name => $value)
        {
            $html .= ' ' . $name;

            if ($value !== true)
            {
                $html .= '="' . $value . '"';
            }
        }

        $html .= '>';

        /* Если есть содержимое, то добавляем его и закрывающий тег */
        if ($this->contents !== null)
        {
            $html .= $this->contents . '</' . $this->tagName . '>';
        }

        return $html;
    }
147788
private function getFileName()
    {
        --$this->currentFileIndex;
        do{
            ++$this->currentFileIndex;
            $fileName = $this->currentNoIndexFileName;
            if($this->currentFileIndex > 0)
            {
                $fileName .= '(' . $this->currentFileIndex . ')';
            }
            $fileName .= $this->currentFileExt;
        }while(is_file($fileName) && filesize($fileName) >= $this->maxSize);
        return $fileName;
    }