生成验证码图片.

@return mixed
196525
public function createImage()
    {
        $this->initImage(); //创建基本图片
        $this->createText(); //输出验证码字符
        if ($this->distortion) {
            $this->distortionText();
        } //扭曲文字
        $this->createNoisePoint(); //产生干扰点
        $this->createNoiseLine(); //产生干扰线
        if ($this->showBorder) {
            imagerectangle($this->image, 0, 0, $this->width - 1, $this->height - 1, $this->randFontColor);
        } //添加边框
        imagepng($this->image);
        imagedestroy($this->image);
        if ($this->distortion) {
            imagedestroy($this->distortionImage);
        }

        return $this->textContent;
    }
225846
function createXml()
  {
    $this->parameters["appid"] = $this->appId;//公众账号ID
    $this->parameters["mch_id"] = $this->MCHID;//商户号
    $this->parameters["nonce_str"] = $this->weObj->generateNonceStr();//随机字符串
    $this->parameters["sign"] = $this->getSign($this->parameters);//签名
    return  $this->arrayToXml($this->parameters);
  }
605154
public function actionCreate()
    {
        $model = new WechatForm();
        if ($model->load(Yii::$app->request->post())) {
            if (Request::isAjax()) {
                Yii::$app->getResponse()->format = Response::FORMAT_JSON;
                return ActiveForm::validate($model);
            } elseif ($model->save()) {
                return $this->flash('公众号创建成功! 请补充余下公众号设置以激活公众号', 'info', ['update', 'id' => $model->id]);
            }
        }
        return $this->render('create', [
            'model' => $model
        ]);
    }
1225890
public function generate(): string
    {
        $status = Tags::NBSP;
        if ($this->statusData['status-type'] !== '' && $this->statusData['status-text'] !== '') {
            $status = [
                Tags::div(
                    $this->getConstant($this->statusData['status-text']),
                    ['class' => $this->getConstant($this->statusData['status-type'])]
                )
            ];
        }
        return Tags::div($status, ['class' => 'status']);
    }
312084
public function generate() {
        
        $session = new Session();

        if(false === $session -> has('_token')) {
            $session -> add('_token', []);
        }

        $name  = TokenHash :: create(20, true, true, true);
        $value = TokenHash :: create(40, true, true, true);

        $session -> add('_token', [$name => $value]);
        $amount = count($session -> get('_token'));
        $limit  = Application :: get(['token', 'amount'], self :: TOKEN_AMOUNT);

        if($amount >= $limit) {
            $session -> add('_token', array_slice($session -> pull('_token'), $amount - $limit, null, true));
        }

        return (object) ['name' => $name, 'value' => $value];
    }
708819
public function generate()
	{
		$args = func_get_args();
		$useKeyLength = array_shift($args);

		if (!is_bool($useKeyLength)) {
			array_unshift($args, $useKeyLength);
			$useKeyLength = false;
		}

		$callables = call_user_func_array(array($this, 'flattenArguments'), $args);

		$key = $this->keygen($useKeyLength ? $this->length : $this->getAdjustedKeyLength());

		while ($callable = current($callables)) {
			if (is_callable($callable)) {
				$key = call_user_func($callable, $key);
			}
			next($callables);
		}

		return sprintf("%s%s%s", $this->prefix, $key, $this->suffix);
	}
985334
public static function generate()
    {
        self::dispatchEvent(self::EVENT_GET_MENU);

        $return = '';

        // sort menu by it's order
        uksort(self::$menu, 'strnatcmp');;

        /** @var Menu $item */
        foreach (self::$menu as $item) {
            if ($item->resources && !self::userHasResource($item->resources)) {
                continue;
            }

            if ($children = $item->getChildren()) {
                $subItems = '';

                // sort menu by it's order
                uksort($children, 'strnatcmp');;

                /** @var Menu $child */
                foreach ($children as $child) {
                    if ($child->resources && !self::userHasResource($child->resources)) {
                        continue;
                    }

                    $subItems .= '<li><a href="' . $child->getLink() . '">' . $child->getLabel() . '</a></li>';
                }

                $return .= '<li class="treeview">
                  <a href="#">
                    <i class="fa ' . $item->getIcon() . '"></i>
                    <span>' . $item->getLabel() . '</span>
                    <i class="fa fa-angle-left pull-right"></i>
                  </a>
                  <ul class="treeview-menu">
                    ' . $subItems . '
                  </ul>
                </li>';
            } else {
                $return .= '<li>
                        <a href="' . $item->getLink() . '">
                            <i class="fa ' . $item->getIcon() . ' fa-fw"></i> <span>' . $item->getLabel() . '</span>
                        </a>
                    </li>';
            }
        }

        return $return;
    }
174464
public function generate()
	{
		if (TL_MODE === 'BE') {
			return parent::generate();
		}

		$parentKey = ($this->arrData['ptable'] ?: 'tl_article') . '__' . $this->arrData['pid'];
		if (isset($GLOBALS['TL_RS_COLUMNS'][$parentKey])) {
			if (!$GLOBALS['TL_RS_COLUMNS'][$parentKey]['active']) {
				trigger_error('Missing column stop element before column wrapper stop element ID ' . $this->id . '.', E_USER_WARNING);
			}
			unset($GLOBALS['TL_RS_COLUMNS'][$parentKey]);
		}
		else {
			trigger_error('Missing column wrapper start element before column wrapper stop element ID ' . $this->id . '.', E_USER_WARNING);
		}

		$htmlSuffix = '';

		if (!empty($GLOBALS['TL_RS_COLUMNS_STACK'][$parentKey])) {
			$GLOBALS['TL_RS_COLUMNS'][$parentKey] = array_pop($GLOBALS['TL_RS_COLUMNS_STACK'][$parentKey]);
			if ($GLOBALS['TL_RS_COLUMNS'][$parentKey]['active']) {
				$htmlSuffix .= '</div>';
			}
		}

		return parent::generate() . $htmlSuffix;
	}
825992
public function generate()
    {
        if (feof($this->h))
            rewind($this->h);

        return (float) fgets($this->h);
    }
566928
public function generate()
    {
        $result = '';

        $table  = $this->buildTable();
        $fields = $this->buildFields();

        $result.='INSERT INTO '.$table.' '.$fields;

        return $result;
    }
1018289
public function generate()
	{
		$arrOptions = array();
		$strClass = 'tl_select';
		$strStyle = '<style>.group-result {padding-top: 5px !important; line-height: 20px !important;}';
		$count = 1;

		if ($this->multiple)
		{
			$this->strName .= '[]';
			$strClass = 'tl_mselect';
		}

		// Add an empty option (XHTML) if there are none
		if (empty($this->arrOptions))
		{
			$this->arrOptions = array(array('value'=>'', 'label'=>'-'));
		}
		
		foreach ($this->arrOptions as $strKey=>$arrOption)
		{
			if (isset($arrOption['value']))
			{
				$arrOptions[] = sprintf('<option value="%s"%s>%s</option>',
										 \StringUtil::specialchars($arrOption['value']),
										 $this->isSelected($arrOption),
										 $arrOption['label']);

				if (isset($GLOBALS['TL_CTB_IMG'][$arrOptgroup['value']]))
				{
					$objImage = \FilesModel::findByUuid($GLOBALS['TL_CTB_IMG'][$arrOptgroup['value']]);
				}
				
				if ($objImage === null)
				{
					$strStyle .= '#ctrl_type_chzn_o_'.$count.' {position: relative; padding-left: 90px; line-height: 41px;}#ctrl_type_chzn_o_'.$count++.'::before {content: ""; position: absolute; left: 20px; top:2px; width: 60px; height: 40px; border: 1px solid #ccc; background: #eee; background-size: 60px 40px;}';
				}
				else
				{
					$strStyle .= '#ctrl_type_chzn_o_'.$count.' {position: relative; padding-left: 90px; line-height: 41px;}#ctrl_type_chzn_o_'.$count++.'::before {content: ""; position: absolute; left: 20px; top:2px; width: 60px; height: 40px; border: 1px solid #ccc; background: #eee url('.$objImage->path.'); background-size: 60px 40px;}';
				}
			}
			else
			{
				$arrOptgroups = array();

				foreach ($arrOption as $arrOptgroup)
				{
					$arrOptgroups[] = sprintf('<option value="%s"%s>%s</option>',
											   \StringUtil::specialchars($arrOptgroup['value']),
											   $this->isSelected($arrOptgroup),
											   $arrOptgroup['label']);

					if (isset($GLOBALS['TL_CTB_IMG'][$arrOptgroup['value']]))
					{
						$objImage = \FilesModel::findByUuid($GLOBALS['TL_CTB_IMG'][$arrOptgroup['value']]);
					}

					if ($objImage === null)
					{
						$strStyle .= '#ctrl_type_chzn_o_'.$count.' {position: relative; padding-left: 90px; line-height: 41px;}#ctrl_type_chzn_o_'.$count++.'::before {content: ""; position: absolute; left: 20px; top:2px; width: 60px; height: 40px; border: 1px solid #ccc; background: #eee; background-size: 60px 40px;}';
					}
					else
					{
						$strStyle .= '#ctrl_type_chzn_o_'.$count.' {position: relative; padding-left: 90px; line-height: 41px;}#ctrl_type_chzn_o_'.$count++.'::before {content: ""; position: absolute; left: 20px; top:2px; width: 60px; height: 40px; border: 1px solid #ccc; background: #eee url('.$objImage->path.'); background-size: 60px 40px;}';
					}

				}

				$arrOptions[] = sprintf('<optgroup label="&nbsp;%s">%s</optgroup>', \StringUtil::specialchars($strKey), implode('', $arrOptgroups));
				$count++;
			}
		}

		// Chosen
		if ($this->chosen)
		{
			$strClass .= ' tl_chosen';
		}


		$strStyle .= '</style>';
	
		return sprintf('%s<select name="%s" id="ctrl_%s" class="%s%s"%s onfocus="Backend.getScrollOffset()">%s</select>%s',
						($this->multiple ? '<input type="hidden" name="'. rtrim($this->strName, '[]') .'" value="">' : ''),
						$this->strName,
						$this->strId,
						$strClass,
						(($this->strClass != '') ? ' ' . $this->strClass : ''),
						$this->getAttributes(),
						implode('', $arrOptions),
						$strStyle);
	}
876895
public function generate()
    {
        // Add empty option (XHTML) if there are none
        if (empty($this->arrOptions)) {
            $this->arrOptions = array(
                array(
                    'value' => '',
                    'label' => '-'
                )
            );
        }

        $strClass = ('' !== $this->strClass ? ' class="' . $this->strClass . '"' : '');
        $strStyle = ('' !== $this->arrAttributes['style'] ? ' style="' . $this->arrAttributes['style'] . '"' : '');

        return $this->checkOptGroup($this->arrOptions, $strClass, $strStyle);
    }
418770
public function generate()
	{
		$this->strTemplate = $this->customTpl ?: $this->type;

		// Return output for the backend if in BE mode
		if (($output = $this->rsceGetBackendOutput()) !== null) {
			return $output;
		}

		try {
			return parent::generate();
		}
		catch (\Exception $exception) {

			if (TL_MODE === 'BE') {

				$template = new CustomTemplate($this->strTemplate);
				$template->setData($this->Template->getData());
				$this->Template = $template;

				return $this->Template->parse();

			}

			throw $exception;
		}
	}
937760
private function createCrease(): string
    {
        // 构造 字段
        $fields = $this->db->createFields($this->fields);
        if (!$fields) {
            return '';
        }

        // 构造查询条件
        list ($where, $wherePrepare, $whereParams) = $this->db->createWhere($this->where);
        if ($where === false) {
            return '';
        }

        // 构造Crease的字段
        $fields = explode(',', $fields);
        list ($sets, $setsPrepare, $setsParams) = $this->createCreaseFields($fields, $this->creaseOperator, $this->creaseDiff);

        $this->sql = $this->db->createUpdate($this->table, $sets, $where);
        $this->prepare = $this->db->createUpdate($this->table, $setsPrepare, $wherePrepare);
        $this->params = array_merge($setsParams, $whereParams);

        $this->tables = [$this->table];
        return $this->prepare;
    }
425529
public function generate()
	{
		$arrSet = array();
		$arrValues = array();
		$blnHasOrder = ($this->orderField != '' && \is_array($this->{$this->orderField}));

		if (!empty($this->varValue)) // can be an array
		{
			$objArticles = \ArticleModel::findMultipleByIds((array) $this->varValue);

			if ($objArticles !== null)
			{
				while ($objArticles->next())
				{
					$arrSet[] = $objArticles->id;
					$arrValues[$objArticles->id] = \Image::getHtml('articles' . ((!$objArticles->published || ($objArticles->start != '' && $objArticles->start > time()) || ($objArticles->stop != '' && $objArticles->stop < time())) ? '_' : '') . '.svg') . ' ' . $objArticles->title . ' (' . $objArticles->alias . \Config::get('urlSuffix') . ')';
				}
			}

			// Apply a custom sort order
			if ($blnHasOrder)
			{
				$arrNew = array();

				foreach ((array) $this->{$this->orderField} as $i)
				{
					if (isset($arrValues[$i]))
					{
						$arrNew[$i] = $arrValues[$i];
						unset($arrValues[$i]);
					}
				}

				if (!empty($arrValues))
				{
					foreach ($arrValues as $k=>$v)
					{
						$arrNew[$k] = $v;
					}
				}

				$arrValues = $arrNew;
				unset($arrNew);
			}
		}

		$return = '<input type="hidden" name="'.$this->strName.'" id="ctrl_'.$this->strId.'" value="'.implode(',', $arrSet).'">' . ($blnHasOrder ? '
  <input type="hidden" name="'.$this->strOrderName.'" id="ctrl_'.$this->strOrderId.'" value="'.$this->{$this->orderField}.'">' : '') . '
  <div class="selector_container">' . (($blnHasOrder && \count($arrValues) > 1) ? '
    <p class="sort_hint">' . $GLOBALS['TL_LANG']['MSC']['dragItemsHint'] . '</p>' : '') . '
    <ul id="sort_'.$this->strId.'" class="'.($blnHasOrder ? 'sortable' : '').'">';

		foreach ($arrValues as $k=>$v)
		{
			$return .= '<li data-id="'.$k.'">'.$v.'</li>';
		}

		$return .= '</ul>';

		if (!\System::getContainer()->get('contao.picker.builder')->supportsContext('article'))
		{
			$return .= '
	<p><button class="tl_submit" disabled>'.$GLOBALS['TL_LANG']['MSC']['changeSelection'].'</button></p>';
		}
		else
		{
			$extras = array
			(
				'fieldType' => $this->fieldType,
				'source' => $this->strTable.'.'.$this->currentRecord,
			);

			if (\is_array($this->rootNodes))
			{
				$extras['rootNodes'] = array_values($this->rootNodes);
			}

			$return .= '
	<p><a href="' . ampersand(\System::getContainer()->get('contao.picker.builder')->getUrl('article', $extras)) . '" class="tl_submit" id="at_' . $this->strName . '">'.$GLOBALS['TL_LANG']['MSC']['changeSelection'].'</a></p>
	<script>
	  $("at_' . $this->strName . '").addEvent("click", function(e) {
		e.preventDefault();
		Backend.openModalSelector({
		  "id": "tl_listing",
		  "title": "' . \StringUtil::specialchars(str_replace("'", "\\'", $GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['label'][0])) . '",
		  "url": this.href + document.getElementById("ctrl_'.$this->strId.'").value,
		  "callback": function(table, value) {
			new Request.Contao({
			  evalScripts: false,
			  onSuccess: function(txt, json) {
				$("ctrl_' . $this->strId . '").getParent("div").set("html", json.content);
				json.javascript && Browser.exec(json.javascript);
			  }
			}).post({"action":"reloadArticletree", "name":"' . $this->strId . '", "value":value.join("\t"), "REQUEST_TOKEN":"' . REQUEST_TOKEN . '"});
		  }
		});
	  });
	</script>' . ($blnHasOrder ? '
	<script>Backend.makeMultiSrcSortable("sort_'.$this->strId.'", "ctrl_'.$this->strOrderId.'", "ctrl_'.$this->strId.'")</script>' : '');
		}

		$return = '<div>' . $return . '</div></div>';

		return $return;
	}
869604
public function generate()
	{
		$html = array();

		foreach ($this->properties as $property => $value):
			if (is_array($value)):
				foreach ($value as $_value) {
					$html[] = strtr(
						static::OPENGRAPH_TAG,
						array(
							'[property]' => static::OPENGRAPH_PREFIX . $property,
							'[value]'    => $_value
						)
					);
				}
			else:
				$html[] = strtr(
					static::OPENGRAPH_TAG,
					array(
						'[property]' => static::OPENGRAPH_PREFIX . $property,
						'[value]'    => $value
					)
				);
			endif;
		endforeach;

		return implode(PHP_EOL, $html);
	}
589844
public function generate()
	{
		$fieldName = substr($this->strId, 0, -21);
		$fieldIndex = explode('__', $fieldName);
		$fieldIndex = (int) $fieldIndex[count($fieldIndex) - 1];

		$toolbar = '<div class="rsce_list_toolbar">';
		$toolbar .= '<a href="" class="rsce_list_toolbar_up" onclick="rsceMoveElement(this, -1);return false;" title="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_up'] . '" data-rsce-title="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_up'] . '">' . \Image::getHtml('up.svg', $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_up']) . '</a> ';
		$toolbar .= '<a href="" class="rsce_list_toolbar_down" onclick="rsceMoveElement(this, 1);return false;" title="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_down'] . '" data-rsce-title="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_down'] . '">' . \Image::getHtml('down.svg', $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_down']) . '</a> ';
		$toolbar .= \Image::getHtml('drag.svg', sprintf($GLOBALS['TL_LANG']['MSC']['move']), 'class="drag-handle rsce_list_toolbar_drag" title="' . sprintf($GLOBALS['TL_LANG']['MSC']['move']) . '"') . ' ';
		$toolbar .= '<a href="" class="rsce_list_toolbar_delete" onclick="rsceDeleteElement(this);return false;" title="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_delete'] . '" data-rsce-title="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_delete'] . '">' . \Image::getHtml('delete.svg', $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_delete']) . '</a> ';
		$toolbar .= '<a href="" class="rsce_list_toolbar_duplicate" onclick="rsceDuplicateElement(this);return false;" title="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_duplicate'] . '" data-rsce-title="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_duplicate'] . '">' . \Image::getHtml('copy.svg', $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_duplicate']) . '</a> ';
		$toolbar .= '<a href="" class="rsce_list_toolbar_new" onclick="rsceNewElementAfter(this);return false;" title="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_new'] . '" data-rsce-title="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_new'] . '">' . \Image::getHtml('new.svg', $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_new']) . '</a> ';
		$toolbar .= '</div>';

		return '<div class="rsce_list_item'
			. (empty($this->arrConfiguration['tl_class']) ? '' : ' ' . $this->arrConfiguration['tl_class'])
			. '" data-rsce-name="' . $fieldName . '">'
			. ($this->strLabel ? '<h2 class="rsce_list_item_title" data-rsce-label="' . $this->arrConfiguration['label_template'] . '">' . $this->strLabel . '</h2>' : '')
			. $toolbar
			. '<fieldset class="tl_box rsce_group rsce_group_no_legend">';
	}