function context_condition_keywords::execute in Context Keywords 7
Same name and namespace in other branches
- 6 context_condition_keywords.inc \context_condition_keywords::execute()
Execute.
File
- ./
context_condition_keywords.inc, line 46
Class
- context_condition_keywords
- Expose keywordss as a context condition.
Code
function execute() {
if ($this
->condition_used()) {
// Include both the keywords alias and normal keywords for matching.
if (!isset($_SESSION['HTTP_REFERER'])) {
$_SESSION['HTTP_REFERER'] = $_SERVER['HTTP_REFERER'];
}
$url = $_SESSION['HTTP_REFERER'];
// Check to see if $_GET["keywords"], if it does, check if it's a URL or individual arguments.
$query = drupal_get_query_parameters();
if (isset($query['keywords'])) {
if (strpos($query['keywords'], '/')) {
$current_keywords[] = context_keywords_provider_parse_url($query['keywords']);
}
else {
$current_keywords[] = $query['keywords'];
}
}
else {
$current_keywords[] = context_keywords_provider_parse_url($url);
}
$default = TRUE;
foreach ($this
->get_contexts() as $context) {
$keywords = $this
->fetch_from_context($context, 'values');
if ($this
->match($current_keywords, $keywords, FALSE)) {
$default = FALSE;
$this
->condition_met($context);
}
}
if ($default) {
foreach ($this
->get_contexts() as $context) {
$keywords = $this
->fetch_from_context($context, 'values');
if ($this
->match($current_keywords, $keywords, TRUE)) {
$this
->condition_met($context);
}
}
}
}
}