文章标签接口

@param string $title - 篇章的标题，最大80字节
@param string $content - 篇章的正文，最大65535字节
@param array $options - 可选参数对象，key: value都为string类型
@description options列表:
@return array
765469
public function keyword($title, $content, $options = [])
    {
        $data = array_merge([
            'title'   => $title, 
            'content' => $content
        ], $options);

        return $this->send('keyword', $data);
    }
79922
public function barDump($subject, $title = null, array $options = null)
    {
        return $this->dump($subject)->bar($title);
    }
880199
public function listGroupItem($title, $options = [])
    {
        $class = 'list-group-item';
        if (isset($options['active']) && $options['active']) {
            $class = "$class active";
        }
        $defaults = [
            'class' => $class,
        ];
        $text = $this->_generateListGroupText($title);
        $options = array_merge($defaults, $options);
        return $this->div('list-group-item', $text, $options);
    }
1107319
public function display($content, $options = [])
    {
        $content = parent::display($content, $options);
        if (!empty($options['source'])) {
            return $content;
        }
        if (isset($options['meta']) &&  !isset($options['nl2br'])) {
            $options['nl2br'] = $options['meta'];
        }
        if ((isset($options['nl2br']) && $options['nl2br']) || !isset($options['nl2br'])) {
            $content = nl2br($content);
        }
        if (!empty($options['length'])) {
            $options['keep_tags'] = empty($options['keep_tags']) ? '' : $options['keep_tags']; //ie <br>,<p>
            $content = StringHelper::cutString(strip_tags($content, $options['keep_tags']), $options['length']);
            if ($options['keep_tags'] && $content) {
                $dom = new DOMDocument; // fix unclosed html tags
                $dom->loadHTML($content);
                $content = $dom->saveBodyHTML();
            }
        }
        return $content;
    }
55928
public function renderContent($content, $title = null)
    {
        if ($content instanceof Renderable) {
            $content = $content->render();
        }

        return $this->admin->template()->view('_layout.inner')
            ->with('title', $title)
            ->with('content', $content)
            ->with('breadcrumbKey', $this->parentBreadcrumb);
    }
610559
public function add(string $content, array $options = [])
    {
        $options = array_intersect_key($options, self::$columns_options_def) + self::$columns_options_def;
        $options['content'] = $content;

        $this->columns[] = $options;

        return $this;
    }
808469
protected function _tooltipTitle(array $options, $tooltip)
    {
        if ($tooltip === true && !Arr::key('title', $options)) {
            $options['title'] = strip_tags($options['label']);
        }

        if (is_string($tooltip)) {
            $options['title'] = $tooltip;
        }

        return $options;
    }
1323817
public function getFieldValue(Content $content, $field, $language, $options = [])
    {
        $fieldObj = $content->getField($field, $language);

        if (null === $fieldObj) {
            $fieldObj = $content->getField($field);
        }

        $contentType = $this->contentTypeService->loadContentType($content->contentInfo->contentTypeId);
        $imageFieldIdentifier = $this->getImageFieldIdentifier($content->id, $language);

        $relatedContentId = $this->getRelation($content, $fieldObj->fieldDefIdentifier, $language);
        $mapping = $this->relationMapper->getMapping($contentType->identifier, $field);

        try {
            if ($relatedContentId && $mapping) {
                $relatedContent = $this->contentService->loadContent($relatedContentId);

                if ($relatedContent && $relatedContent->versionInfo->contentInfo->published) {
                    $relatedContentType = $this->contentTypeService->loadContentType($relatedContent->contentInfo->contentTypeId);

                    if ($relatedContentType->identifier != $mapping['content']) {
                        throw new InvalidRelationException(
                            sprintf(
                                "Invalid relation: field '%s:%s' (object: %s, field: %s) has improper relation to object '%s' (object: %s) but '%s:%s' expected.",
                                $contentType->identifier,
                                $field,
                                $content->id,
                                $fieldObj->id,
                                $relatedContentType->identifier,
                                $relatedContentId,
                                $mapping['content'],
                                $mapping['field']
                            )
                        );
                    }
                    $relatedField = $content->getField($mapping['field'], $language);
                    $value = $relatedField ? $this->getParsedFieldValue($relatedField, $relatedContent, $language, $imageFieldIdentifier, $options) : '';
                } else {
                    $value = '';
                }
            } else {
                $value = $fieldObj ? $this->getParsedFieldValue($fieldObj, $content, $language, $imageFieldIdentifier, $options) : '';
            }
        } catch (InvalidRelationException $exception) {
            $this->logger->warning($exception->getMessage());

            $value = '';
        }

        return $value;
    }
580125
private function generateFile($content, $chunkPath, array $options)
    {
        $data = new ContentData($content, $options);

        $this->outputGenerator->reset();
        $this->outputGenerator->startDocument($data);

        $contents = array();
        foreach ($data->contents as $contentTypes) {
            foreach ($contentTypes as $contentType) {
                $contents[] = $contentType;
            }
        }

        $this->contentListElementGenerator->generateElement($this->outputGenerator, $contents);

        unset($contents);

        $filePath = $this->fileSystemHelper->getDir() . $chunkPath;
        $this->fileSystemHelper->save($filePath, $this->outputGenerator->endDocument($data));

        unset($data);

        $this->logger->info(sprintf('Generating file: %s', $filePath));
    }
656173
public function create( $title = null, $content = null )
    {
        $post = wp_insert_post(array(
            'post_type'    => $this->postType,
            'post_title'   => $title,
            'post_content' => $content,
            'post_status'  => 'draft',
        ));

        return new static($post);
    }
669757
protected function _get_title( $content ) {
		preg_match( '/<meta +?property=["\']og:title["\'][^\/>]*? content=["\']([^"\']+?)["\'].*?\/?>/si', $content, $reg );
		if ( ! empty( $reg[1] ) ) {
			return $reg[1];
		}

		preg_match( '/<title>([^"\']+?)<\/title>/si', $content, $reg );
		if ( ! empty( $reg[1] ) ) {
			return $reg[1];
		}
	}
21079
public function data($content, $options = [])
    {
        if (isset($options['returnAll']) && $options['returnAll']) {
            return BlockSelectOption::getOptionsArray($this->_block->id);
        }
        return parent::data($content);
    }
239983
public function transform($content, $options = [])
    {
        if (!$content || !is_string($content)) {
            return $content;
        }

        // prepend slashes if necessary
        if (strpos((string) $content, self::NAMESPACE_DELIMITER) !== 0) {
            $content = self::NAMESPACE_DELIMITER . $content;
        }

        if (empty($options[self::NAMESPACE_OPTION_INDEX])) {
            return $content;
        }

        if (strpos($content, $options[self::NAMESPACE_OPTION_INDEX]) === false) {
            if (strpos($options[self::NAMESPACE_OPTION_INDEX], self::NAMESPACE_DELIMITER) !== 0) {
                $content = self::NAMESPACE_DELIMITER . $options[self::NAMESPACE_OPTION_INDEX] . $content;
            } else {
                $content = $options[self::NAMESPACE_OPTION_INDEX] . $content;
            }
        }

        return $content;
    }
398692
public function raw($title, array $options = array())
    {
        $options['parent'] = $this->id;

        return $this->builder->raw($title, $options);
    }
1216537
public function value($options = [], $content = '')
    {
        if (!is_array($options)) {
            $options = ['value' => $options];
        }

        $this->values[] = new Option($this->form->expression('option'), $options, $content);
        return $this;
    }
473756
public static function addAnchor($content, $url, $keywords) {
		$keywords = static::keywordsFormat($keywords);

		if (!$keywords) {
			return $content;
		}

		$keywords = static::keywordsFormat($keywords);
		$anchors = explode(',', $keywords);

		// 把内容中的所有连接先进行base64编码
		$content = preg_replace_callback("/(<a.+?>.*?<\\/a>)/i", function($matchs) {
			return "'<[base['.base64_encode('{$matchs[1]}').']]>'";
		}, $content);

		foreach ($anchors as $anchor) {
			if (!$anchor) {
				continue;
			}

			if(false === $pos = strpos($content, $anchor)) {
				continue;
			}

			$name = urlencode($anchor);
			$replace = "<a href=\"{$url}#{$name}\" name=\"{$name}\" title=\"{$anchor}\">{$anchor}</a>";

			$content = substr($content, 0, $pos) . $replace . substr($content, $pos + strlen($anchor));
		}

		// 解码原本的链接内容
		$content = preg_replace_callback("/<\\[base\\[(.*?)\\]\\]>/i", function($matchs) {
			return "str_replace('\\\"', '\"', base64_decode('{$matchs[1]}'))";
		}, $content);

		return $content;
	}
720332
protected function getEOL($content)
    {
        static $eols = [
            "\r\n",
            "\n",
            "\r",
        ];
        foreach($eols as $eol)
        {
            if(strpos($content, $eol))
            {
                return $eol;
            }
        }
        return PHP_EOL;
    }