danielebarchiesi@0: t("String"), danielebarchiesi@0: // keyword to use for %substitution danielebarchiesi@0: 'keyword' => 'string', danielebarchiesi@0: 'description' => t('A string is a minimal context that simply holds a string that can be used for some other purpose.'), danielebarchiesi@0: 'settings form' => 'ctools_string_settings_form', danielebarchiesi@0: 'context' => 'ctools_string_context', danielebarchiesi@0: 'placeholder form' => array( danielebarchiesi@0: '#type' => 'textfield', danielebarchiesi@0: '#description' => t('Enter a value for this argument'), danielebarchiesi@0: ), danielebarchiesi@0: 'path placeholder' => 'ctools_string_path_placeholder', // This is in pagemanager. danielebarchiesi@0: ); danielebarchiesi@0: danielebarchiesi@0: /** danielebarchiesi@0: * Discover if this argument gives us the term we crave. danielebarchiesi@0: */ danielebarchiesi@0: function ctools_string_context($arg = NULL, $conf = NULL, $empty = FALSE) { danielebarchiesi@0: // If unset it wants a generic, unfilled context. danielebarchiesi@0: if ($empty) { danielebarchiesi@0: return ctools_context_create_empty('string'); danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: $context = ctools_context_create('string', $arg); danielebarchiesi@0: $context->original_argument = $arg; danielebarchiesi@0: danielebarchiesi@0: return $context; danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: /** danielebarchiesi@0: * Settings form for the argument danielebarchiesi@0: */ danielebarchiesi@0: function ctools_string_settings_form(&$form, &$form_state, $conf) { danielebarchiesi@0: $form['settings']['use_tail'] = array( danielebarchiesi@0: '#title' => t('Get all arguments after this one'), danielebarchiesi@0: '#type' => 'checkbox', danielebarchiesi@0: '#default_value' => !empty($conf['use_tail']), danielebarchiesi@0: '#description' => t('If checked, this string will include all arguments. For example, if the path is "path/%" and the user visits "path/foo/bar", if this is not checked the string will be "foo". If it is checked the string will be "foo/bar".'), danielebarchiesi@0: ); danielebarchiesi@0: // return $form; danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: /** danielebarchiesi@0: * Switch the placeholder based upon user settings. danielebarchiesi@0: */ danielebarchiesi@0: function ctools_string_path_placeholder($argument) { danielebarchiesi@0: if (empty($argument['settings']['use_tail'])) { danielebarchiesi@0: return '%pm_arg'; danielebarchiesi@0: } danielebarchiesi@0: else { danielebarchiesi@0: return '%pm_arg_tail'; danielebarchiesi@0: } danielebarchiesi@0: }