本文整理汇总了PHP中Tags::parseTags方法的典型用法代码示例。如果您正苦于以下问题:PHP Tags::parseTags方法的具体用法?PHP Tags::parseTags怎么用?PHP Tags::parseTags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tags
的用法示例。
在下文中一共展示了Tags::parseTags方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check
public function check(&$params)
{
$tagOptions = $this->config['options']['tags'];
$tags = $tagOptions['value'];
$tags = is_array($tags) ? $tags : Tags::parseTags($tags, true);
if (!empty($tags) && isset($params['tags'])) {
if (!is_array($params['tags'])) {
$params['tags'] = explode(',', $params['tags']);
}
$params['tags'] = array_map(function ($item) {
return preg_replace('/^#/', '', $item);
}, $params['tags']);
// must have at least 1 tag in the list:
if (count(array_intersect($params['tags'], $tags)) > 0) {
return $this->checkConditions($params);
} else {
return array(false, 'Web lead tag condition was not met');
}
} elseif (!empty($tags) && !isset($params['tags'])) {
// trigger requires tags but record has none
return array(false, 'Web lead tag condition was not met');
} else {
// trigger has no tag conditions
return $this->checkConditions($params);
}
}
示例2: check
public function check(&$params)
{
$tags = $this->config['options']['tags']['value'];
$tags = is_array($tags) ? $tags : Tags::parseTags($tags, true);
if (!empty($tags) && isset($params['tags'])) {
// Check passed params to be sure they're set
if (!is_array($params['tags'])) {
$params['tags'] = explode(',', $params['tags']);
}
$params['tags'] = array_map(function ($item) {
return preg_replace('/^#/', '', $item);
}, $params['tags']);
// must have at least 1 tag in the list:
if (count(array_intersect($params['tags'], $tags)) > 0) {
return $this->checkConditions($params);
} else {
return array(false, Yii::t('studio', 'No tags on the record matched those in the tag trigger criteria.'));
}
} else {
// config is invalid or record has no tags (tags are not optional)
return array(false, empty($tags) ? Yii::t('studio', 'No tags in the trigger criteria!') : Yii::t('studio', 'Tags parameter missing!'));
}
}
示例3: parseFile
public function parseFile(array $files = array())
{
foreach ($files as $post => $value) {
$regExp = new RegExp();
$this->path = $regExp->match($value['path']);
$this->cookie = $regExp->match($value['cookie']);
$this->filesize = $regExp->match($value['filesize']);
$info = new SplFileInfo($value['path']);
$this->extension = $info->getExtension();
$tagArr = $regExp->match($value['tags']);
$tags = new Tags();
$this->tags = $tags->parseTags($tagArr);
//creating aray from the string of tags
$this->description = $regExp->match($value['description']);
$this->user_id = $regExp->match($value['user_id']);
$this->token = $regExp->match($value['token']);
$this->id = $regExp->match($value['id']);
$this->time = $regExp->match($value['time']);
$this->count = $regExp->match($value['count']);
$exif = exif_read_data('uploads/' . $value['path'], 0, true);
$this->exif = $exif;
$this->public = $regExp->match($value['public']);
}
}
示例4: parseValue
public static function parseValue($value, $type, &$params = null, $renderFlag = true)
{
if (is_string($value)) {
if (strpos($value, '=') === 0) {
// It's a formula. Evaluate it.
$evald = X2FlowFormatter::parseFormula($value, $params);
// Fail silently because there's not yet a good way of reporting
// problems that occur in parseFormula --
$value = '';
if ($evald[0]) {
$value = $evald[1];
}
} else {
// Run token replacement:
$value = X2FlowFormatter::replaceVariables($value, $params, $type, $renderFlag, true);
}
}
switch ($type) {
case 'boolean':
return (bool) $value;
case 'time':
case 'date':
case 'dateTime':
if (ctype_digit((string) $value)) {
// must already be a timestamp
return $value;
}
if ($type === 'date') {
$value = Formatter::parseDate($value);
} elseif ($type === 'dateTime') {
$value = Formatter::parseDateTime($value);
} else {
$value = strtotime($value);
}
return $value === false ? null : $value;
case 'link':
$pieces = explode('_', $value);
if (count($pieces) > 1) {
return $pieces[0];
}
return $value;
case 'tags':
return Tags::parseTags($value);
default:
return $value;
}
}
示例5: testParseTags
public function testParseTags()
{
$tags = 'test,test2,test3,#test4';
$this->assertEquals(Tags::parseTags($tags), array('#test', '#test2', '#test3', '#test4'));
}