class classified_context_condition_path in Classified Ads 7.3
Same name and namespace in other branches
- 6.3 plugins/classified_context_condition_path.inc \classified_context_condition_path
Merge Classified Ads paths within a Context path condition.
As a context plugin, method names cannot respect naming conventions.
phpcs:disable Drupal.NamingConventions.ValidFunctionName, phpcs:disable Drupal.NamingConventions.ValidClassName phpcs:disable PSR1.Methods.CamelCapsMethodName phpcs:disable PSR1.Classes.ClassDeclaration phpcs:disable Squiz.Classes.ValidClassName
Hierarchy
- class \context_condition
- class \context_condition_path
Expanded class hierarchy of classified_context_condition_path
1 string reference to 'classified_context_condition_path'
- classified_context_plugins in ./
classified.module - Implements hook_context_plugins().
File
- plugins/
classified_context_condition_path.inc, line 25 - A plugin declaring the Classified Ads paths as context conditions.
View source
class classified_context_condition_path extends context_condition_path {
/**
* Helper listing the paths to register.
*
* @param bool $assoc
* Use associative array format ?
*
* @return array|false
* The paths.
*/
protected function get_classified_paths($assoc = FALSE) {
$ret = array(
'admin/config/content/classified',
'admin/config/content/classified/*',
'classified',
'classified/*',
'user/*/classified',
'user/*/classified/*',
);
if ($assoc) {
$ret = drupal_map_assoc($ret);
}
return $ret;
}
/**
* Condition form.
*
* @return array
* A form array for the condition.
*/
public function condition_form($context) {
$form = array();
$form['1'] = parent::condition_form($context);
$all_paths = explode("\n", $form['1']['#default_value']);
$classified_paths = $this
->get_classified_paths();
sort($classified_paths);
$common_paths = array_values(array_intersect($all_paths, $classified_paths));
sort($common_paths);
$form['2'] = array(
'#title' => t('Auto Classified path set'),
'#description' => t('Helper: merge all paths belonging to the Classified Ads application into the above list.'),
'#type' => 'checkbox',
'#default_value' => $common_paths == $classified_paths,
);
return $form;
}
/**
* Condition form submit handler.
*
* Merge the Classified Ads paths into the manually entered paths list.
*
* @return array
* An array of paths on which the condition will hold.
*/
public function condition_form_submit($values) {
$auto_path = array_pop($values);
$values = reset($values);
$paths = parent::condition_form_submit($values);
if ($auto_path) {
$paths = array_merge($paths, $this
->get_classified_paths(TRUE));
sort($paths);
}
// Coder limitation: unlike usual FAPI, Context submit handlers return data.
return $paths;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
classified_context_condition_path:: |
public | function |
Condition form. Overrides context_condition_path:: |
|
classified_context_condition_path:: |
public | function |
Condition form submit handler. Overrides context_condition_path:: |
|
classified_context_condition_path:: |
protected | function | Helper listing the paths to register. | |
context_condition:: |
property | |||
context_condition:: |
property | |||
context_condition:: |
property | |||
context_condition:: |
property | |||
context_condition:: |
function | Marks a context as having met this particular condition. | ||
context_condition:: |
function | Check whether this condition is used by any contexts. Can be used to prevent expensive condition checks from being triggered when no contexts use this condition. | ||
context_condition:: |
function | Context editor form for conditions. | 2 | |
context_condition:: |
function | Context editor form submit handler. | ||
context_condition:: |
function | Retrieve options from the context provided. | ||
context_condition:: |
function | Retrieve all contexts with the condition value provided. | 2 | |
context_condition:: |
function | Options form. Provide additional options for your condition. | 4 | |
context_condition:: |
function | Options form submit handler. | ||
context_condition:: |
function | Settings form. Provide variable settings for your condition. | ||
context_condition:: |
function | Clone our references when we're being cloned. | ||
context_condition:: |
function | Constructor. Do not override. | ||
context_condition_path:: |
function |
Omit condition values. We will provide a custom input form for our conditions. Overrides context_condition:: |
||
context_condition_path:: |
function | Execute. | 3 | |
context_condition_path:: |
protected | function | Match the subject against a set of regex patterns. Similar to drupal_match_path() but also handles negation through the use of the ~ character. |