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); } }
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!')); } }
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']); } }
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; } }
public function testParseTags() { $tags = 'test,test2,test3,#test4'; $this->assertEquals(Tags::parseTags($tags), array('#test', '#test2', '#test3', '#test4')); }