DrupalBin
Submit Code
About
Recent Posts
Code
Why won't this work?
Code
Code
radioactivity flags
Fix for Fix for term description to display as a sub-page title for each different termid (argument)
array_splice??
Fix for term description to display as a sub-page title for each differnet termid (argument)
Code
Fix for Hide page titles for certain node types in page.tpl.php
more
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Log in using OpenID
Cancel OpenID login
Create new account
Request new password
Tags
CCK
drupal
fapi
jquery
menu
module
Panels
simpletest
test
theme
user
views
more tags
Home
Fix for Flexifilter API Lesson #1.5
View
Fix
January 12, 2008 - 4:08pm — Anonymous
<?php
// $Id$
function
example_flexifilter_conditions
(
)
{
$conditions
=
array
(
)
;
$conditions
[
'example_text_all_uppercase'
]
=
array
(
'label'
=
>
t
(
'Text is all uppercase'
)
,
'description'
=
>
t
(
'TRUE if all of the text is uppercase'
)
,
'callback'
=
>
'example_condition_isupper'
,
'group'
=
>
t
(
'Text'
)
,
)
;
return
$conditions
;
}
function
example_condition_isupper
(
$op
,
$settings
,
$text
)
{
switch
(
$op
)
{
case
'settings'
:
$form
=
array
(
)
;
return
$form
;
case
'prepare'
:
case
'process'
:
return
preg_match
(
"/[^A-Z
\n
\t
]/"
,
$text
)
==
0
;
default
:
return
$text
;
}
}
function
example_flexifilter_components
(
)
{
$components
=
array
(
)
;
$components
[
'example_toupper'
]
=
array
(
'label'
=
>
t
(
'To Uppercase'
)
,
'callback'
=
>
'example_component_toupper'
,
'group'
=
>
t
(
'Text: Simple'
)
,
'step'
=
>
'either'
,
)
;
return
$components
;
}
function
example_component_toupper
(
$op
,
$settings
,
$text
)
{
switch
(
$op
)
{
case
'settings'
:
$form
=
array
(
)
;
$form
[
'case'
]
=
array
(
'#type'
=
>
'select'
,
'#title'
=
>
t
(
'Case transformation'
)
,
'#options'
=
>
array
(
'upper'
=
>
t
(
'To Uppercase'
)
,
'lower'
=
>
t
(
'To Lowercase'
)
,
)
,
'#default_value'
=
>
isset
(
$settings
[
'case'
]
)
?
$settings
[
'case'
]
:
'upper'
,
)
;
return
$form
;
case
'prepare'
:
case
'process'
:
if
(
$settings
[
'case'
]
==
'upper'
)
{
return
strtoupper
(
$text
)
;
}
else
{
return
strtolower
(
$text
)
;
}
default
:
return
$text
;
}
}
Submit Fix
Summary:
Tags:
Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Show summary in full view
<?php // $Id$ function example_flexifilter_conditions() { $conditions = array(); $conditions['example_text_all_uppercase'] = array( 'label' => t('Text is all uppercase'), 'description' => t('TRUE if all of the text is uppercase'), 'callback' => 'example_condition_isupper', 'group' => t('Text'), ); return $conditions; } function example_condition_isupper($op, $settings, $text) { switch($op) { case 'settings': $form = array(); return $form; case 'prepare': case 'process': return preg_match("/[^A-Z \n\t]/", $text) == 0; default: return $text; } } function example_flexifilter_components() { $components = array(); $components['example_toupper'] = array( 'label' => t('To Uppercase'), 'callback' => 'example_component_toupper', 'group' => t('Text: Simple'), 'step' => 'either', ); return $components; } function example_component_toupper($op, $settings, $text) { switch($op) { case 'settings': $form = array(); $form['case'] = array( '#type' => 'select', '#title' => t('Case transformation'), '#options' => array( 'upper' => t('To Uppercase'), 'lower' => t('To Lowercase'), ), '#default_value' => isset($settings['case']) ? $settings['case'] : 'upper', ); return $form; case 'prepare': case 'process': if ($settings['case'] == 'upper') { return strtoupper($text); } else { return strtolower($text); } default: return $text; } }
Syntax highlighting mode:
ActionScript
ColdFusion
Diff
Drupal 5
Drupal 6
HTML
INI
Javascript
MySQL
PHP
Python
robots.txt
SQL
Text
Select the syntax highlighting mode to use.
See Also:
Order
Title:
URL:
-1
0
1
Title:
URL:
-1
0
1
Any links you'd like to have associated with the post (Drupal.org issue, Wikipedia article, etc).
File attachments
Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.
Attach new file:
The maximum upload size is
1 MB
. Only files with the following extensions may be uploaded:
jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp
.