CSPICE_PXFRM2 returns the 3x3 matrix that transforms position
vectors from one specified frame at a specified epoch to another
specified frame at another specified epoch.
Given:
from name of a reference frame recognized by spicelib that
corresponds to the input 'etfrom'.
[1,m] = size(from); char = class(from)
to name of a reference frame recognized by spicelib that
corresponds to the desired output at 'etto''.
[1,l] = size(to); char = class(to)
etfrom epoch in ephemeris seconds past the epoch of J2000 (TDB)
corresponding to the 'from' reference frame.
[1,n] = size(etfrom); double = class(etfrom)
etto epoch in ephemeris seconds past the epoch of J2000 (TDB) that
corresponds to the 'to' reference frame.
[1,n] = size(etto); double = class(etto)
the call:
result = cspice_pxfrm2( from, to, etfrom, etto)
returns:
rotate operator(s) that transform position vector(s) from the
reference frame 'from' at epoch 'etfrom' to the frame 'to' at
epoch 'etto'.
If [1,1] = size(etfrom) then [3,3] = size(rotate).
If [1,n] = size(etfrom) then [3,3,n] = size(rotate).
double = class(rotate)
If (x, y, z) is a position relative to the reference
frame 'from' at time 'etfrom' then the vector ( x', y',
z') is the same position relative to the frame 'to' at
epoch 'etto'.
Any numerical results shown for this example may differ between
platforms as the results depend on the SPICE kernels used as input
and the machine specific arithmetic implementation.
Suppose that MGS has taken a picture of Mars at time 'etrec' with
the MOC narrow angle camera. We want to know the latitude and
longitude associated with two pixels projected to Mars'
surface: the boresight and one along the boundary of the
field of view (FOV). Due to light time, the photons taken in
the picture left Mars at time 'etemit', when Mars was at a
different state than at time 'etrec'.
In order to solve this problem, we could use the 'cspice_sincpt'
routine for both pixels, but this would be slow. Instead, we
will assume that the light time for each pixel is the same. We
will call 'cspice_sincpt' once to get the light time and surface point
associated with the boresight. Then, we will rotate the first
FOV boundary vector from the camera frame at 'etrec' to the
body-fixed Mars frame at 'etemit', and call the faster routine
'cspice_surfpt' to retrieve the surface point for the FOV boundary
vector.
This example problem could be extended to find the latitude
and longitude associated with every pixel in an instrument's
field of view, but this example is simplified to only solve
for two pixels: the boresight and one along the boundary of
the field of view.
Assumptions:
1) The light times from the surface points in the camera's
field of view to the camera are equal.
2) The camera offset from the center of gravity of the
spacecraft is zero. If the data are more accurate
and precise, this assumption can be easily discarded.
3) An ellipsoid shape model for the target body is
sufficient.
4) The boundary field of view vector returned from 'cspice_getfov'
is associated with a boundary field of view pixel. If
this example were extended to include a geometric camera
model, this assumption would not be needed since the
direction vectors associated with each pixel would be
calculated from the geometric camera model.
Example program starts here.
% --------------------- Program Setup ---------------------
metakr = 'mgs_ex.tm';
camera = 'MGS_MOC_NA';
NCORNR = 4;
ABCORR = 'CN+S';
%
% Load kernels
%
cspice_furnsh( metakr );
%
% Convert the time the picture was taken from a
% UTC time string to seconds past J2000, TDB.
%
etrec = cspice_str2et( '2003 OCT 13 06:00:00 UTC' );
%
% Assume the one-way light times from different
% surface points on Mars to MGS within the camera's
% FOV are equal. This means the photons that make
% up different pixels were all emitted from Mars at
% 'etemit' and received by MGS at 'etrec'. It would be
% slow to process images using 'cspice_sincpt' for every
% pixel. Instead, we will use 'cspice_sincpt' on the
% boresight pixel and use 'cspice_surfpt' for the first FOV
% boundary pixel. If this example program were extended
% to include all of the camera's pixels, 'cspice_surfpt' would
% be used for the remaining pixels.
%
% Get the MGS MOC Narrow angle camera (MGS_MOC_NA)
% ID code. Then look up the field of view (FOV)
% parameters by calling 'cspice_getfov'.
%
[camid, found] = cspice_bodn2c( camera );
if ( ~found )
txt = sprintf( ['SPICE(NOTRANSLATION)' ...
'Could not find ID code for instrument %s.' ], ...
camera );
error( txt )
end
%
% 'cspice_getfov' will return the name of the camera-fixed frame
% in the string OBSREF, the camera boresight vector in
% the array BSIGHT, and the FOV corner vectors in the
% array BOUNDS.
%
[shape, obsref, bsight, bounds] = cspice_getfov( camid, NCORNR);
fprintf( '\nObservation Reference Frame: %s\n', obsref );
%
% ----------- Boresight Surface Intercept -----------
%
% Retrieve the time, surface intercept point, and vector
% from MGS to the boresight surface intercept point
% in IAU_MARS coordinates.
%
[ spoint, etemit, srfvec, found ] = ...
cspice_sincpt( 'Ellipsoid', 'Mars', etrec, 'IAU_MARS', ...
ABCORR, 'MGS' , obsref, bsight );
if ( ~found )
txt = sprintf( ['SPICE(NOINTERCEPT)' ...
'Intercept not found for boresight vector.' ]);
error( txt )
end
%
% Convert the intersection point of the boresight
% vector and Mars from rectangular into latitudinal
% coordinates. Convert radians to degrees.
%
[ radius, lon, lat ] = cspice_reclat( spoint );
lon = lon * cspice_dpr;
lat = lat * cspice_dpr;
fprintf( ['\n' ...
'Boresight surface intercept coordinates:\n' ...
' Radius (km) : %f\n' ...
' Latitude (deg): %f\n' ...
' Longitude (deg): %f\n' ], ...
radius, lat, lon );
%
% ------ 1st Boundary FOV Surface Intercept (cspice_surfpt) -----
%
% Now we will transform the first FOV corner vector into the
% IAU_MARS frame so the surface intercept point can be
% calculated using cspice_surfpt, which is faster than
% cspice_subpnt.
%
% If this example program were extended to include all
% of the pixels in the camera's FOV, a few steps, such as
% finding the rotation matrix from the camera frame to the
% IAU_MARS frame, looking up the semi-axis values for Mars,
% and finding the position of MGS with respect to Mars could
% be done once and used for every pixel.
%
% Find the rotation matrix from the ray's reference
% frame at the time the photons were received (etrec)
% to IAU_MARS at the time the photons were emitted
% (etemit).
%
[rotate] = cspice_pxfrm2( obsref, 'IAU_MARS', etrec, etemit );
%
% Look up the semi-axis values for Mars.
%
radii = cspice_bodvrd( 'MARS', 'RADII', 3 );
%
% Find the position of the center of Mars with respect
% to MGS. The position of the observer with respect
% to Mars is required for the call to 'cspice_surfpt'. Note:
% the apparent position of MGS with respect to Mars is
% not the same as the negative of Mars with respect to MGS.
%
pos_mgs_wrt_mars = spoint - srfvec;
%
% The first boundary FOV pixel must be rotated into the
% IAU_MARS reference frame.
%
bndvec = rotate * bounds(:,1);
%
% Calculate the surface point of the boundary FOV
% vector.
%
[surface_point, found] = cspice_surfpt ( pos_mgs_wrt_mars, ...
bndvec, radii(1), ...
radii(2), radii(3) );
if ( ~found )
txt = 'SPICE(NOTFOUND)Could not calculate surface point.';
error( txt )
end
surf_point_using_surfpt = surface_point;
%
% Convert the intersection point of the boundary
% FOV vector and Mars from rectangular into
% latitudinal coordinates. Convert radians
% to degrees.
%
[ radius, lon, lat ] = cspice_reclat( surface_point );
lon = lon * cspice_dpr;
lat = lat * cspice_dpr;
fprintf( ['\n' ...
'Boundary vector surface intercept\n' ...
'coordinates using cspice_surfpt:\n' ...
' Radius (km) : %f\n' ...
' Latitude (deg): %f\n' ...
' Longitude (deg): %f\n' ...
' Emit time using boresight LT (s): %10.9f\n'], ...
radius, lat, lon, etemit );
%
% ------ 1st Boundary FOV Surface Intercept Verification ----
%
% For verification only, we will calculate the surface
% intercept coordinates for the first boundary vector
% using 'cspice_sincpt' and compare to the faster
% 'cspice_surfpt' method.
%
[ surface_point, etemit, srfvec, found ] = ...
cspice_sincpt( 'Ellipsoid', 'Mars', etrec, 'IAU_MARS', ...
ABCORR, 'MGS' , obsref, bounds(:,1) );
if ( ~found )
txt = sprintf( ['SPICE(NOTFOUND)' ...
'Intercept not found for ' ...
'the boundary FOV vector.' ]);
error( txt )
end
%
% Convert the intersection point of the first boundary
% vector and Mars from rectangular into latitudinal
% coordinates. Convert radians to degrees.
%
[ radius, lon, lat ] = cspice_reclat( surface_point );
lon = lon * cspice_dpr;
lat = lat * cspice_dpr;
fprintf( ['\n' ...
'Boundary vector surface intercept\n' ...
'coordinates using cspice_sincpt:\n' ...
' Radius (km) : %f\n' ...
' Latitude (deg): %f\n' ...
' Longitude (deg): %f\n' ...
' Emit time using boresight LT (s): %10.9f\n\n'], ...
radius, lat, lon, etemit );
distance = cspice_vdist ( surf_point_using_surfpt, surface_point );
fprintf( [ 'Distance between surface points of the first\n' ...
'boundary vector using cspice_surfpt and\n' ...
'cspice_sincpt:\n' ...
' Distance (mm): %f\n' ], ...
distance*10^6 );
%
% It's always good form to unload kernels after use,
% particularly in MATLAB due to data persistence.
%
cspice_kclear
MATLAB outputs:
Observation Reference Frame: MGS_MOC_NA
Boresight surface intercept coordinates:
Radius (km) : 3384.940410
Latitude (deg): -48.479580
Longitude (deg): -123.436454
Boundary vector surface intercept
coordinates using cspice_surfpt:
Radius (km) : 3384.941136
Latitude (deg): -48.477482
Longitude (deg): -123.474080
Emit time using boresight LT (s): 119296864.181059480
Boundary vector surface intercept
coordinates using cspice_sincpt:
Radius (km) : 3384.941136
Latitude (deg): -48.477482
Longitude (deg): -123.474079
Emit time using boresight LT (s): 119296864.181059465
Distance between surface points of the first
boundary vector using cspice_surfpt and
cspice_sincpt:
Distance (mm): 32.139880
None.
For important details concerning this module's function, please refer to
the CSPICE routine pxfrm2_c.
MICE.REQ
FRAMES
-Mice Version 1.0.0 12-MAR-2012 SCK (JPL)
Position transformation matrix for different epochs
|


Zend Framework comes with a standard set of filters, which are ready for you to use.
The Alnum filter can be used to return only alphabetic characters and digits in the unicode “letter” and “number” categories, respectively. All other characters are suppressed.
Supported Options for Alnum Filter
The following options are supported for Alnum:
Alnum([ boolean $allowWhiteSpace [, string $locale ]])
$allowWhiteSpace: If set to true then whitespace characters are allowed. Otherwise they are suppressed. Default is “false” (whitespace is not allowed).
Methods for getting/setting the allowWhiteSpace option are also available: getAllowWhiteSpace() and setAllowWhiteSpace()
$locale: The locale string used in identifying the characters to filter (locale name, e.g. en_US). If unset, it will use the default locale (Locale::getDefault()).
Methods for getting/setting the locale are also available: getLocale() and setLocale()
Alnum Filter Usage
1 2 3 4 5 6 7 8 9 | // Default settings, deny whitespace
$filter = new \Zend\I18n\Filter\Alnum();
echo $filter->filter("This is (my) content: 123");
// Returns "Thisismycontent123"
// First param in constructor is $allowWhiteSpace
$filter = new \Zend\I18n\Filter\Alnum(true);
echo $filter->filter("This is (my) content: 123");
// Returns "This is my content 123"
|
Note
Alnum works on almost all languages, except: Chinese, Japanese and Korean. Within these languages the english alphabet is used instead of the characters from these languages. The language itself is detected using the Locale.
The Alpha filter can be used to return only alphabetic characters in the unicode “letter” category. All other characters are suppressed.
Supported Options for Alpha Filter
The following options are supported for Alpha:
Alpha([ boolean $allowWhiteSpace [, string $locale ]])
$allowWhiteSpace: If set to true then whitespace characters are allowed. Otherwise they are suppressed. Default is “false” (whitespace is not allowed).
Methods for getting/setting the allowWhiteSpace option are also available: getAllowWhiteSpace() and setAllowWhiteSpace()
$locale: The locale string used in identifying the characters to filter (locale name, e.g. en_US). If unset, it will use the default locale (Locale::getDefault()).
Methods for getting/setting the locale are also available: getLocale() and setLocale()
Alpha Filter Usage
1 2 3 4 5 6 7 8 9 | // Default settings, deny whitespace
$filter = new \Zend\I18n\Filter\Alpha();
echo $filter->filter("This is (my) content: 123");
// Returns "Thisismycontent"
// Allow whitespace
$filter = new \Zend\I18n\Filter\Alpha(true);
echo $filter->filter("This is (my) content: 123");
// Returns "This is my content "
|
Note
Alpha works on almost all languages, except: Chinese, Japanese and Korean. Within these languages the english alphabet is used instead of the characters from these languages. The language itself is detected using the Locale.
Zend\Filter\BaseName allows you to filter a string which contains the path to a file and it will return the base name of this file.
Supported Options
There are no additional options for Zend\Filter\BaseName.
Basic Usage
A basic example of usage is below:
1 2 3 | $filter = new Zend\Filter\BaseName();
print $filter->filter('/vol/tmp/filename');
|
This will return ‘filename’.
1 2 3 | $filter = new Zend\Filter\BaseName();
print $filter->filter('/vol/tmp/filename.txt');
|
This will return ‘filename.txt‘.
This filter changes a given input to be a BOOLEAN value. This is often useful when working with databases or when processing form values.
Supported Options
The following options are supported for Zend\Filter\Boolean:
Default Behavior
By default, this filter works by casting the input to a BOOLEAN value; in other words, it operates in a similar fashion to calling (boolean) $value.
1 2 3 4 | $filter = new Zend\Filter\Boolean();
$value = '';
$result = $filter->filter($value);
// returns false
|
This means that without providing any configuration, Zend\Filter\Boolean accepts all input types and returns a BOOLEAN just as you would get by type casting to BOOLEAN.
Changing the Default Behavior
Sometimes casting with (boolean) will not suffice. Zend\Filter\Boolean allows you to configure specific types to convert, as well as which to omit.
The following types can be handled:
All other given values will return TRUE by default.
There are several ways to select which of the above types are filtered. You can give one or multiple types and add them, you can give an array, you can use constants, or you can give a textual string. See the following examples:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | // converts 0 to false
$filter = new Zend\Filter\Boolean(Zend\Filter\Boolean::INTEGER);
// converts 0 and '0' to false
$filter = new Zend\Filter\Boolean(
Zend\Filter\Boolean::INTEGER + Zend\Filter\Boolean::ZERO
);
// converts 0 and '0' to false
$filter = new Zend\Filter\Boolean(array(
'type' => array(
Zend\Filter\Boolean::INTEGER,
Zend\Filter\Boolean::ZERO,
),
));
// converts 0 and '0' to false
$filter = new Zend\Filter\Boolean(array(
'type' => array(
'integer',
'zero',
),
));
|
You can also give an instance of Zend\Config\Config to set the desired types. To set types after instantiation, use the setType() method.
Localized Booleans
As mentioned previously, Zend\Filter\Boolean can also recognise localized “yes” and “no” strings. This means that you can ask your customer in a form for “yes” or “no” within his native language and Zend\Filter\Boolean will convert the response to the appropriate boolean value.
To set the desired locale, you can either use the locale option, or the method setLocale().
1 2 3 4 5 6 7 8 9 10 11 12 | $filter = new Zend\Filter\Boolean(array(
'type' => Zend\Filter\Boolean::ALL,
'locale' => 'de',
));
// returns false
echo $filter->filter('nein');
$filter->setLocale('en');
// returns true
$filter->filter('yes');
|
Disable Casting
Sometimes it is necessary to recognise only TRUE or FALSE and return all other values without changes. Zend\Filter\Boolean allows you to do this by setting the casting option to FALSE.
In this case Zend\Filter\Boolean will work as described in the following table, which shows which values return TRUE or FALSE. All other given values are returned without change when casting is set to FALSE
| Type | True | False |
|---|---|---|
| Zend\Filter\Boolean::BOOLEAN | TRUE | FALSE |
| Zend\Filter\Boolean::INTEGER | 0 | 1 |
| Zend\Filter\Boolean::FLOAT | 0.0 | 1.0 |
| Zend\Filter\Boolean::STRING | “” | |
| Zend\Filter\Boolean::ZERO | “0” | “1” |
| Zend\Filter\Boolean::EMPTY_ARRAY | array() | |
| Zend\Filter\Boolean::NULL | NULL | |
| Zend\Filter\Boolean::FALSE_STRING | “false” (case independently) | “true” (case independently) |
| Zend\Filter\Boolean::YES | localized “yes” (case independently) | localized “no” (case independently) |
The following example shows the behaviour when changing the casting option:
1 2 3 4 5 6 7 8 9 10 11 12 13 | $filter = new Zend\Filter\Boolean(array(
'type' => Zend\Filter\Boolean::ALL,
'casting' => false,
));
// returns false
echo $filter->filter(0);
// returns true
echo $filter->filter(1);
// returns the value
echo $filter->filter(2);
|
This filter allows you to use own methods in conjunction with Zend\Filter. You don’t have to create a new filter when you already have a method which does the job.
Supported Options
The following options are supported for Zend\Filter\Callback:
Basic Usage
The usage of this filter is quite simple. Let’s expect we want to create a filter which reverses a string.
1 2 3 4 | $filter = new Zend\Filter\Callback('strrev');
print $filter->filter('Hello!');
// returns "!olleH"
|
As you can see it’s really simple to use a callback to define a own filter. It is also possible to use a method, which is defined within a class, by giving an array as callback.
1 2 3 4 5 6 7 8 9 | // Our classdefinition
class MyClass
{
public function Reverse($param);
}
// The filter definition
$filter = new Zend\Filter\Callback(array('MyClass', 'Reverse'));
print $filter->filter('Hello!');
|
To get the actual set callback use getCallback() and to set another callback use setCallback().
Note
Possible exceptions
You should note that defining a callback method which can not be called will raise an exception.
Default Parameters Within a Callback
It is also possible to define default parameters, which are given to the called method as array when the filter is executed. This array will be concatenated with the value which will be filtered.
1 2 3 4 5 6 7 | $filter = new Zend\Filter\Callback(
array(
'callback' => 'MyMethod',
'options' => array('key' => 'param1', 'key2' => 'param2')
)
);
$filter->filter(array('value' => 'Hello'));
|
When you would call the above method definition manually it would look like this:
1 | $value = MyMethod('Hello', 'param1', 'param2');
|
These two filters are capable of compressing and decompressing strings, files, and directories.
Supported Options
The following options are supported for Zend\Filter\Compress and Zend\Filter\Decompress:
Supported Compression Adapters
The following compression formats are supported by their own adapter:
Each compression format has different capabilities as described below. All compression filters may be used in approximately the same ways, and differ primarily in the options available and the type of compression they offer (both algorithmically as well as string vs. file vs. directory)
Generic Handling
To create a compression filter you need to select the compression format you want to use. The following description takes the Bz2 adapter. Details for all other adapters are described after this section.
The two filters are basically identical, in that they utilize the same backends. Zend\Filter\Compress should be used when you wish to compress items, and Zend\Filter\Decompress should be used when you wish to decompress items.
For instance, if we want to compress a string, we have to initiate Zend\Filter\Compress and indicate the desired adapter.
1 | $filter = new Zend\Filter\Compress('Bz2');
|
To use a different adapter, you simply specify it to the constructor.
You may also provide an array of options or a Traversable object. If you do, provide minimally the key “adapter”, and then either the key “options” or “adapterOptions” (which should be an array of options to provide to the adapter on instantiation).
1 2 3 4 5 6 | $filter = new Zend\Filter\Compress(array(
'adapter' => 'Bz2',
'options' => array(
'blocksize' => 8,
),
));
|
Note
Default compression Adapter
When no compression adapter is given, then the Gz adapter will be used.
Almost the same usage is we want to decompress a string. We just have to use the decompression filter in this case.
1 | $filter = new Zend\Filter\Decompress('Bz2');
|
To get the compressed string, we have to give the original string. The filtered value is the compressed version of the original string.
1 2 3 | $filter = new Zend\Filter\Compress('Bz2');
$compressed = $filter->filter('Uncompressed string');
// Returns the compressed string
|
Decompression works the same way.
1 2 3 | $filter = new Zend\Filter\Decompress('Bz2');
$compressed = $filter->filter('Compressed string');
// Returns the uncompressed string
|
Note
Note on string compression
Not all adapters support string compression. Compression formats like Rar can only handle files and directories. For details, consult the section for the adapter you wish to use.
Creating an Archive
Creating an archive file works almost the same as compressing a string. However, in this case we need an additional parameter which holds the name of the archive we want to create.
1 2 3 4 5 6 7 8 | $filter = new Zend\Filter\Compress(array(
'adapter' => 'Bz2',
'options' => array(
'archive' => 'filename.bz2',
),
));
$compressed = $filter->filter('Uncompressed string');
// Returns true on success and creates the archive file
|
In the above example the uncompressed string is compressed, and is then written into the given archive file.
Note
Existing archives will be overwritten
The content of any existing file will be overwritten when the given filename of the archive already exists.
When you want to compress a file, then you must give the name of the file with its path.
1 2 3 4 5 6 7 8 | $filter = new Zend\Filter\Compress(array(
'adapter' => 'Bz2',
'options' => array(
'archive' => 'filename.bz2'
),
));
$compressed = $filter->filter('C:\temp\compressme.txt');
// Returns true on success and creates the archive file
|
You may also specify a directory instead of a filename. In this case the whole directory with all its files and subdirectories will be compressed into the archive.
1 2 3 4 5 6 7 8 | $filter = new Zend\Filter\Compress(array(
'adapter' => 'Bz2',
'options' => array(
'archive' => 'filename.bz2'
),
));
$compressed = $filter->filter('C:\temp\somedir');
// Returns true on success and creates the archive file
|
Note
Do not compress large or base directories
You should never compress large or base directories like a complete partition. Compressing a complete partition is a very time consuming task which can lead to massive problems on your server when there is not enough space or your script takes too much time.
Decompressing an Archive
Decompressing an archive file works almost like compressing it. You must specify either the archive parameter, or give the filename of the archive when you decompress the file.
1 2 3 | $filter = new Zend\Filter\Decompress('Bz2');
$decompressed = $filter->filter('filename.bz2');
// Returns true on success and decompresses the archive file
|
Some adapters support decompressing the archive into another subdirectory. In this case you can set the target parameter.
1 2 3 4 5 6 7 8 9 | $filter = new Zend\Filter\Decompress(array(
'adapter' => 'Zip',
'options' => array(
'target' => 'C:\temp',
)
));
$decompressed = $filter->filter('filename.zip');
// Returns true on success and decompresses the archive file
// into the given target directory
|
Note
Directories to extract to must exist
When you want to decompress an archive into a directory, then that directory must exist.
Bz2 Adapter
The Bz2 Adapter can compress and decompress:
This adapter makes use of PHP‘s Bz2 extension.
To customize compression, this adapter supports the following options:
All options can be set at instantiation or by using a related method. For example, the related methods for ‘Blocksize’ are getBlocksize() and setBlocksize(). You can also use the setOptions() method which accepts all options as array.
Gz Adapter
The Gz Adapter can compress and decompress:
This adapter makes use of PHP‘s Zlib extension.
To customize the compression this adapter supports the following options:
All options can be set at initiation or by using a related method. For example, the related methods for ‘Level’ are getLevel() and setLevel(). You can also use the setOptions() method which accepts all options as array.
Lzf Adapter
The Lzf Adapter can compress and decompress:
Note
Lzf supports only strings
The Lzf adapter can not handle files and directories.
This adapter makes use of PHP‘s Lzf extension.
There are no options available to customize this adapter.
Rar Adapter
The Rar Adapter can compress and decompress:
Note
Rar does not support strings
The Rar Adapter can not handle strings.
This adapter makes use of PHP‘s Rar extension.
Note
Rar compression not supported
Due to restrictions with the Rar compression format, there is no compression available for free. When you want to compress files into a new Rar archive, you must provide a callback to the adapter that can invoke a Rar compression program.
To customize the compression this adapter supports the following options:
All options can be set at instantiation or by using a related method. For example, the related methods for ‘Target’ are getTarget() and setTarget(). You can also use the setOptions() method which accepts all options as array.
Tar Adapter
The Tar Adapter can compress and decompress:
Note
Tar does not support strings
The Tar Adapter can not handle strings.
This adapter makes use of PEAR‘s Archive_Tar component.
To customize the compression this adapter supports the following options:
All options can be set at instantiation or by using a related method. For example, the related methods for ‘Target’ are getTarget() and setTarget(). You can also use the setOptions() method which accepts all options as array.
Note
Directory usage
When compressing directories with Tar then the complete file path is used. This means that created Tar files will not only have the subdirectory but the complete path for the compressed file.
Zip Adapter
The Zip Adapter can compress and decompress:
Note
Zip does not support string decompression
The Zip Adapter can not handle decompression to a string; decompression will always be written to a file.
This adapter makes use of PHP‘s Zip extension.
To customize the compression this adapter supports the following options:
All options can be set at instantiation or by using a related method. For example, the related methods for ‘Target’ are getTarget() and setTarget(). You can also use the setOptions() method which accepts all options as array.
Returns the string $value, removing all but digits.
Supported Options
There are no additional options for Zend\Filter\Digits.
Basic Usage
A basic example of usage is below:
1 2 3 | $filter = new Zend\Filter\Digits();
print $filter->filter('October 2012');
|
This returns “2012”.
1 2 3 | $filter = new Zend\Filter\Digits();
print $filter->filter('HTML 5 for Dummies');
|
This returns “5”.
Given a string containing a path to a file, this function will return the name of the directory.
Supported Options
There are no additional options for Zend\Filter\Dir.
Basic Usage
A basic example of usage is below:
1 2 3 | $filter = new Zend\Filter\Dir();
print $filter->filter('/etc/passwd');
|
This returns “/etc”.
1 2 3 | $filter = new Zend\Filter\Dir();
print $filter->filter('C:/Temp/x');
|
This returns “C:/Temp”.
These filters allow to encrypt and decrypt any given string. Therefor they make use of Adapters. Actually there are adapters for the Zend\Crypt\BlockCipher class and the OpenSSL extension of PHP.
Supported Options
The following options are supported for Zend\Filter\Encrypt and Zend\Filter\Decrypt:
Zend\Crypt\Symmetric\Mcrypt. It should be one of the algorithm ciphers supported by Zend\Crypt\Symmetric\Mcrypt (see the getSupportedAlgorithms() method). If not set it defaults to aes, the Advanced Encryption Standard (see Zend\Crypt\BlockCipher for more details).
Adapter Usage
As these two encryption methodologies work completely different, also the usage of the adapters differ. You have to select the adapter you want to use when initiating the filter.
1 2 3 4 5 | // Use the BlockCipher adapter
$filter1 = new Zend\Filter\Encrypt(array('adapter' => 'BlockCipher'));
// Use the OpenSSL adapter
$filter2 = new Zend\Filter\Encrypt(array('adapter' => 'openssl'));
|
To set another adapter you can also use setAdapter(), and the getAdapter() method to receive the actual set adapter.
1 2 3 | // Use the OpenSSL adapter
$filter = new Zend\Filter\Encrypt();
$filter->setAdapter('openssl');
|
Note
When you do not supply the adapter option or do not use setAdapter(), then the BlockCipher adapter will be used per default.
Encryption with BlockCipher
To encrypt a string using the BlockCipher you have to specify the encryption key using the setKey() method or passing it during the constructor.
1 2 3 4 5 6 7 8 9 10 11 12 | // Use the default AES encryption algorithm
$filter = new Zend\Filter\Encrypt(array('adapter' => 'BlockCipher'));
$filter->setKey('encryption key');
// or
// $filter = new Zend\Filter\Encrypt(array(
// 'adapter' => 'BlockCipher',
// 'key' => 'encryption key'
// ));
$encrypted = $filter->filter('text to be encrypted');
printf ("Encrypted text: %s\n", $encrypted);
|
You can get and set the encryption values also afterwards with the getEncryption() and setEncryption() methods.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | // Use the default AES encryption algorithm
$filter = new Zend\Filter\Encrypt(array('adapter' => 'BlockCipher'));
$filter->setKey('encryption key');
var_dump($filter->getEncryption());
// Will print:
//array(4) {
// ["key_iteration"]=>
// int(5000)
// ["algorithm"]=>
// string(3) "aes"
// ["hash"]=>
// string(6) "sha256"
// ["key"]=>
// string(14) "encryption key"
//}
|
Note
The BlockCipher adapter uses the Mcrypt PHP extension by default. That means you will need to install the Mcrypt module in your PHP environment.
If you don’t specify an initialization Vector (salt or iv), the BlockCipher will generate a random value during each encryption. If you try to execute the following code the output will be always different (note that even if the output is always different you can decrypt it using the same key).
1 2 3 4 5 6 7 8 9 | $key = 'encryption key';
$text = 'message to encrypt';
// use the default adapter that is BlockCipher
$filter = new \Zend\Filter\Encrypt();
$filter->setKey('encryption key');
for ($i=0; $i < 10; $i++) {
printf("%d) %s\n", $i, $filter->filter($text));
}
|
If you want to obtain the same output you need to specify a fixed Vector, using the setVector() method. This script will produce always the same encryption output.
1 2 3 4 5 6 7 8 | // use the default adapter that is BlockCipher
$filter = new \Zend\Filter\Encrypt();
$filter->setKey('encryption key');
$filter->setVector('12345678901234567890');
printf("%s\n", $filter->filter('message'));
// output:
// 04636a6cb8276fad0787a2e187803b6557f77825d5ca6ed4392be702b9754bb3MTIzNDU2Nzg5MDEyMzQ1NgZ+zPwTGpV6gQqPKECinig=
|
Note
For a security reason it’s always better to use a different Vector on each encryption. We suggest to use the setVector() method only if you really need it.
Decryption with BlockCipher
For decrypting content which was previously encrypted with BlockCipher you need to have the options with which the encryption has been called.
If you used only the encryption key, you can just use it to decrypt the content. As soon as you have provided all options decryption is as simple as encryption.
1 2 3 4 5 6 7 8 | $content = '04636a6cb8276fad0787a2e187803b6557f77825d5ca6ed4392be702b9754bb3MTIzNDU2Nzg5MDEyMzQ1NgZ+zPwTGpV6gQqPKECinig=';
// use the default adapter that is BlockCipher
$filter = new Zend\Filter\Decrypt();
$filter->setKey('encryption key');
printf("Decrypt: %s\n", $filter->filter($content));
// output:
// Decrypt: message
|
Note that even if we did not specify the same Vector, the BlockCipher is able to decrypt the message because the Vector is stored in the encryption string itself (note that the Vector can be stored in plaintext, it is not a secret, the Vector is only used to improve the randomness of the encryption algorithm).
Note
You should also note that all settings which be checked when you create the instance or when you call setEncryption().
Encryption with OpenSSL
When you have installed the OpenSSL extension you can use the OpenSSL adapter. You can get or set the public keys also afterwards with the getPublicKey() and setPublicKey() methods. The private key can also be get and set with the related getPrivateKey() and setPrivateKey() methods.
1 2 3 4 5 6 7 8 9 10 11 | // Use openssl and provide a private key
$filter = new Zend\Filter\Encrypt(array(
'adapter' => 'openssl',
'private' => '/path/to/mykey/private.pem'
));
// of course you can also give the public keys at initiation
$filter->setPublicKey(array(
'/public/key/path/first.pem',
'/public/key/path/second.pem'
));
|
Note
Note that the OpenSSL adapter will not work when you do not provide valid keys.
When you want to encode also the keys, then you have to provide a passphrase with the setPassphrase() method. When you want to decode content which was encoded with a passphrase you will not only need the public key, but also the passphrase to decode the encrypted key.
1 2 3 4 5 6 7 8 9 10 11 12 | // Use openssl and provide a private key
$filter = new Zend\Filter\Encrypt(array(
'adapter' => 'openssl',
'private' => '/path/to/mykey/private.pem'
));
// of course you can also give the public keys at initiation
$filter->setPublicKey(array(
'/public/key/path/first.pem',
'/public/key/path/second.pem'
));
$filter->setPassphrase('mypassphrase');
|
At last, when you use OpenSSL you need to give the receiver the encrypted content, the passphrase when have provided one, and the envelope keys for decryption.
This means for you, that you have to get the envelope keys after the encryption with the getEnvelopeKey() method.
So our complete example for encrypting content with OpenSSL look like this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | // Use openssl and provide a private key
$filter = new Zend\Filter\Encrypt(array(
'adapter' => 'openssl',
'private' => '/path/to/mykey/private.pem'
));
// of course you can also give the public keys at initiation
$filter->setPublicKey(array(
'/public/key/path/first.pem',
'/public/key/path/second.pem'
));
$filter->setPassphrase('mypassphrase');
$encrypted = $filter->filter('text_to_be_encoded');
$envelope = $filter->getEnvelopeKey();
print $encrypted;
// For decryption look at the Decrypt filter
|
Simplified usage with Openssl
As seen before, you need to get the envelope key to be able to decrypt the previous encrypted value. This can be very annoying when you work with multiple values.
To have a simplified usage you can set the package option to TRUE. The default value is FALSE.
1 2 3 4 5 6 7 8 9 10 11 12 | // Use openssl and provide a private key
$filter = new Zend\Filter\Encrypt(array(
'adapter' => 'openssl',
'private' => '/path/to/mykey/private.pem',
'public' => '/public/key/path/public.pem',
'package' => true
));
$encrypted = $filter->filter('text_to_be_encoded');
print $encrypted;
// For decryption look at the Decrypt filter
|
Now the returned value contains the encrypted value and the envelope. You don’t need to get them after the compression. But, and this is the negative aspect of this feature, the encrypted value can now only be decrypted by using Zend\Filter\Encrypt.
Compressing Content
Based on the original value, the encrypted value can be a very large string. To reduce the value Zend\Filter\Encrypt allows the usage of compression.
The compression option can either be set to the name of a compression adapter, or to an array which sets all wished options for the compression adapter.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | // Use basic compression adapter
$filter1 = new Zend\Filter\Encrypt(array(
'adapter' => 'openssl',
'private' => '/path/to/mykey/private.pem',
'public' => '/public/key/path/public.pem',
'package' => true,
'compression' => 'bz2'
));
// Use basic compression adapter
$filter2 = new Zend\Filter\Encrypt(array(
'adapter' => 'openssl',
'private' => '/path/to/mykey/private.pem',
'public' => '/public/key/path/public.pem',
'package' => true,
'compression' => array('adapter' => 'zip', 'target' => '\usr\tmp\tmp.zip')
));
|
Note
Decryption with same settings
When you want to decrypt a value which is additionally compressed, then you need to set the same compression settings for decryption as for encryption. Otherwise the decryption will fail.
Decryption with OpenSSL
Decryption with OpenSSL is as simple as encryption. But you need to have all data from the person who encrypted the content. See the following example:
1 2 3 4 5 6 7 8 9 10 11 | // Use openssl and provide a private key
$filter = new Zend\Filter\Decrypt(array(
'adapter' => 'openssl',
'private' => '/path/to/mykey/private.pem'
));
// of course you can also give the envelope keys at initiation
$filter->setEnvelopeKey(array(
'/key/from/encoder/first.pem',
'/key/from/encoder/second.pem'
));
|
Note
Note that the OpenSSL adapter will not work when you do not provide valid keys.
Optionally it could be necessary to provide the passphrase for decrypting the keys themself by using the setPassphrase() method.
1 2 3 4 5 6 7 8 9 10 11 12 | // Use openssl and provide a private key
$filter = new Zend\Filter\Decrypt(array(
'adapter' => 'openssl',
'private' => '/path/to/mykey/private.pem'
));
// of course you can also give the envelope keys at initiation
$filter->setEnvelopeKey(array(
'/key/from/encoder/first.pem',
'/key/from/encoder/second.pem'
));
$filter->setPassphrase('mypassphrase');
|
At last, decode the content. Our complete example for decrypting the previously encrypted content looks like this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | // Use openssl and provide a private key
$filter = new Zend\Filter\Decrypt(array(
'adapter' => 'openssl',
'private' => '/path/to/mykey/private.pem'
));
// of course you can also give the envelope keys at initiation
$filter->setEnvelopeKey(array(
'/key/from/encoder/first.pem',
'/key/from/encoder/second.pem'
));
$filter->setPassphrase('mypassphrase');
$decrypted = $filter->filter('encoded_text_normally_unreadable');
print $decrypted;
|
Returns the string $value, converting characters to their corresponding HTML entity equivalents where they exist.
Supported Options
The following options are supported for Zend\Filter\HtmlEntities:
quotestyle: Equivalent to the PHP htmlentities native function parameter quote_style. This allows you to define what will be done with ‘single’ and “double” quotes. The following constants are accepted: ENT_COMPAT, ENT_QUOTES ENT_NOQUOTES with the default being ENT_COMPAT.
charset: Equivalent to the PHP htmlentities native function parameter charset. This defines the character set to be used in filtering. Unlike the PHP native function the default is ‘UTF-8’. See “http://php.net/htmlentities” for a list of supported character sets.
Note
This option can also be set via the $options parameter as a Traversable object or array. The option key will be accepted as either charset or encoding.
doublequote: Equivalent to the PHP htmlentities native function parameter double_encode. If set to false existing html entities will not be encoded. The default is to convert everything (true).
Note
This option must be set via the $options parameter or the setDoubleEncode() method.
Basic Usage
See the following example for the default behavior of this filter.
1 2 3 | $filter = new Zend\Filter\HtmlEntities();
print $filter->filter('<');
|
Quote Style
Zend\Filter\HtmlEntities allows changing the quote style used. This can be useful when you want to leave double, single, or both types of quotes un-filtered. See the following example:
1 2 3 4 | $filter = new Zend\Filter\HtmlEntities(array('quotestyle' => ENT_QUOTES));
$input = "A 'single' and " . '"double"';
print $filter->filter($input);
|
The above example returns A 'single' and "double". Notice that 'single' as well as "double" quotes are filtered.
1 2 3 4 | $filter = new Zend\Filter\HtmlEntities(array('quotestyle' => ENT_COMPAT));
$input = "A 'single' and " . '"double"';
print $filter->filter($input);
|
The above example returns A 'single' and "double". Notice that "double" quotes are filtered while 'single' quotes are not altered.
1 2 3 4 | $filter = new Zend\Filter\HtmlEntities(array('quotestyle' => ENT_NOQUOTES));
$input = "A 'single' and " . '"double"';
print $filter->filter($input);
|
The above example returns A 'single' and "double". Notice that neither "double" or 'single' quotes are altered.
Helper Methods
To change or retrieve the quotestyle after instantiation, the two methods setQuoteStyle() and getQuoteStyle() may be used respectively. setQuoteStyle() accepts one parameter $quoteStyle. The following constants are accepted: ENT_COMPAT, ENT_QUOTES, ENT_NOQUOTES
1 2 3 4 | $filter = new Zend\Filter\HtmlEntities();
$filter->setQuoteStyle(ENT_QUOTES);
print $filter->getQuoteStyle(ENT_QUOTES);
|
To change or retrieve the charset after instantiation, the two methods setCharSet() and getCharSet() may be used respectively. setCharSet() accepts one parameter $charSet. See “http://php.net/htmlentities” for a list of supported character sets.
1 2 3 4 | $filter = new Zend\Filter\HtmlEntities();
$filter->setQuoteStyle(ENT_QUOTES);
print $filter->getQuoteStyle(ENT_QUOTES);
|
To change or retrieve the doublequote option after instantiation, the two methods setDoubleQuote() and getDoubleQuote() may be used respectively. setDoubleQuote() accepts one boolean parameter $doubleQuote.
1 2 3 4 | $filter = new Zend\Filter\HtmlEntities();
$filter->setQuoteStyle(ENT_QUOTES);
print $filter->getQuoteStyle(ENT_QUOTES);
|
Zend\Filter\Int allows you to transform a scalar value which contains into an integer.
Supported Options
There are no additional options for Zend\Filter\Int.
Basic Usage
A basic example of usage is below:
1 2 3 | $filter = new Zend\Filter\Int();
print $filter->filter('-4 is less than 0');
|
This will return ‘-4’.
This filter will change the given input to be NULL if it meets specific criteria. This is often necessary when you work with databases and want to have a NULL value instead of a boolean or any other type.
Supported Options
The following options are supported for Zend\Filter\Null:
Default Behavior
Per default this filter works like PHP‘s empty() method; in other words, if empty() returns a boolean TRUE, then a NULL value will be returned.
1 2 3 4 | $filter = new Zend\Filter\Null();
$value = '';
$result = $filter->filter($value);
// returns null instead of the empty string
|
This means that without providing any configuration, Zend\Filter\Null will accept all input types and return NULL in the same cases as empty().
Any other value will be returned as is, without any changes.
Changing the Default Behavior
Sometimes it’s not enough to filter based on empty(). Therefor Zend\Filter\Null allows you to configure which type will be converted and which not.
The following types can be handled:
There are several ways to select which of the above types are filtered. You can give one or multiple types and add them, you can give an array, you can use constants, or you can give a textual string. See the following examples:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | // converts false to null
$filter = new Zend\Filter\Null(Zend\Filter\Null::BOOLEAN);
// converts false and 0 to null
$filter = new Zend\Filter\Null(
Zend\Filter\Null::BOOLEAN + Zend\Filter\Null::INTEGER
);
// converts false and 0 to null
$filter = new Zend\Filter\Null( array(
Zend\Filter\Null::BOOLEAN,
Zend\Filter\Null::INTEGER
));
// converts false and 0 to null
$filter = new Zend\Filter\Null(array(
'boolean',
'integer',
));
|
You can also give a Traversable or an array to set the wished types. To set types afterwards use setType().
The NumberFormat filter can be used to return locale-specific number and percentage strings. It extends the NumberParse filter, which acts as wrapper for the NumberFormatter class within the Internationalization extension (Intl).
Supported Options for NumberFormat Filter
The following options are supported for NumberFormat:
NumberFormat([ string $locale [, int $style [, int $type ]]])
$locale: (Optional) Locale in which the number would be formatted (locale name, e.g. en_US). If unset, it will use the default locale (Locale::getDefault())
Methods for getting/setting the locale are also available: getLocale() and setLocale()
$style: (Optional) Style of the formatting, one of the format style constants. If unset, it will use NumberFormatter::DEFAULT_STYLE as the default style.
Methods for getting/setting the format style are also available: getStyle() and setStyle()
$type: (Optional) The formatting type to use. If unset, it will use NumberFormatter::TYPE_DOUBLE as the default type.
Methods for getting/setting the format type are also available: getType() and setType()
NumberFormat Filter Usage
1 2 3 4 5 6 7 8 9 10 11 | $filter = new \Zend\I18n\Filter\NumberFormat("de_DE");
echo $filter->filter(1234567.8912346);
// Returns "1.234.567,891"
$filter = new \Zend\I18n\Filter\NumberFormat("en_US", NumberFormatter::PERCENT);
echo $filter->filter(0.80);
// Returns "80%"
$filter = new \Zend\I18n\Filter\NumberFormat("fr_FR", NumberFormatter::SCIENTIFIC);
echo $filter->filter(0.00123456789);
// Returns "1,23456789E-3"
|
Zend\Filter\PregReplace performs a search using regular expressions and replaces all found elements.
Supported Options
The following options are supported for Zend\Filter\PregReplace:
Basic Usage
To use this filter properly you must give two options:
The option pattern has to be given to set the pattern which will be searched for. It can be a string for a single pattern, or an array of strings for multiple pattern.
To set the pattern which will be used as replacement the option replacement has to be used. It can be a string for a single pattern, or an array of strings for multiple pattern.
1 2 3 4 5 6 7 8 | $filter = new Zend\Filter\PregReplace(array(
'pattern' => '/bob/',
'replacement' => 'john',
));
$input = 'Hi bob!';
$filter->filter($input);
// returns 'Hi john!'
|
You can use getPattern() and setPattern() to set the matching pattern afterwards. To set the replacement pattern you can use getReplacement() and setReplacement().
1 2 3 4 5 6 7 | $filter = new Zend\Filter\PregReplace();
$filter->setMatchPattern(array('bob', 'Hi'))
->setReplacement(array('john', 'Bye'));
$input = 'Hi bob!';
$filter->filter($input);
// returns 'Bye john!'
|
For a more complex usage take a look into PHP‘s PCRE Pattern Chapter.
This filter will resolve given links and pathnames and returns canonicalized absolute pathnames.
Supported Options
The following options are supported for Zend\Filter\RealPath:
Basic Usage
For any given link of pathname its absolute path will be returned. References to ‘/./‘, ‘/../‘ and extra ‘/‘ characters in the input path will be stripped. The resulting path will not have any symbolic link, ‘/./‘ or ‘/../‘ character.
Zend\Filter\RealPath will return FALSE on failure, e.g. if the file does not exist. On BSD systems Zend\Filter\RealPath doesn’t fail if only the last path component doesn’t exist, while other systems will return FALSE.
1 2 3 4 5 | $filter = new Zend\Filter\RealPath();
$path = '/www/var/path/../../mypath';
$filtered = $filter->filter($path);
// returns '/www/mypath'
|
Non-Existing Paths
Sometimes it is useful to get also paths when they don’t exist, f.e. when you want to get the real path for a path which you want to create. You can then either give a FALSE at initiation, or use setExists() to set it.
1 2 3 4 5 6 | $filter = new Zend\Filter\RealPath(false);
$path = '/www/var/path/../../non/existing/path';
$filtered = $filter->filter($path);
// returns '/www/non/existing/path'
// even when file_exists or realpath would return false
|
This filter converts any input to be lowercased.
Supported Options
The following options are supported for Zend\Filter\StringToLower:
Basic Usage
This is a basic example:
1 2 3 4 | $filter = new Zend\Filter\StringToLower();
print $filter->filter('SAMPLE');
// returns "sample"
|
Different Encoded Strings
Per default it will only handle characters from the actual locale of your server. Characters from other charsets would be ignored. Still, it’s possible to also lowercase them when the mbstring extension is available in your environment. Simply set the wished encoding when initiating the StringToLower filter. Or use the setEncoding() method to change the encoding afterwards.
1 2 3 4 5 6 7 8 | // using UTF-8
$filter = new Zend\Filter\StringToLower('UTF-8');
// or give an array which can be useful when using a configuration
$filter = new Zend\Filter\StringToLower(array('encoding' => 'UTF-8'));
// or do this afterwards
$filter->setEncoding('ISO-8859-1');
|
Note
Setting wrong encodings
Be aware that you will get an exception when you want to set an encoding and the mbstring extension is not available in your environment.
Also when you are trying to set an encoding which is not supported by your mbstring extension you will get an exception.
This filter converts any input to be uppercased.
Supported Options
The following options are supported for Zend\Filter\StringToUpper:
Basic Usage
This is a basic example for using the StringToUpper filter:
1 2 3 4 | $filter = new Zend\Filter\StringToUpper();
print $filter->filter('Sample');
// returns "SAMPLE"
|
Different Encoded Strings
Like the StringToLower filter, this filter handles only characters from the actual locale of your server. Using different character sets works the same as with StringToLower.
1 2 3 4 | $filter = new Zend\Filter\StringToUpper(array('encoding' => 'UTF-8'));
// or do this afterwards
$filter->setEncoding('ISO-8859-1');
|
This filter modifies a given string such that certain characters are removed from the beginning and end.
Supported Options
The following options are supported for Zend\Filter\StringTrim:
Basic Usage
A basic example of usage is below:
1 2 3 | $filter = new Zend\Filter\StringTrim();
print $filter->filter(' This is (my) content: ');
|
The above example returns ‘This is (my) content:’. Notice that the whitespace characters have been removed.
Default Behavior
1 2 3 4 | $filter = new Zend\Filter\StringTrim(':');
// or new Zend\Filter\StringTrim(array('charlist' => ':'));
print $filter->filter(' This is (my) content:');
|
The above example returns ‘This is (my) content’. Notice that the whitespace characters and colon are removed. You can also provide a Traversable or an array with a ‘charlist’ key. To set the desired character list after instantiation, use the setCharList() method. The getCharList() return the values set for charlist.
This filter modifies a given string and removes all new line characters within that string.
Supported Options
There are no additional options for Zend\Filter\StripNewLines:
Basic Usage
A basic example of usage is below:
1 2 3 | $filter = new Zend\Filter\StripNewLines();
print $filter->filter(' This is (my)``\n\r``content: ');
|
The above example returns ‘This is (my) content:’. Notice that all newline characters have been removed.
This filter can strip XML and HTML tags from given content.
Warning
Zend\Filter\StripTags is potentially unsecure
Be warned that Zend\Filter\StripTags should only be used to strip all available tags.
Using Zend\Filter\StripTags to make your site secure by stripping some unwanted tags will lead to unsecure and dangerous code.
Zend\Filter\StripTags must not be used to prevent XSS attacks. This filter is no replacement for using Tidy or HtmlPurifier.
Supported Options
The following options are supported for Zend\Filter\StripTags:
stripped from the given content.
from the given content.
Basic Usage
See the following example for the default behaviour of this filter:
1 2 3 | $filter = new Zend\Filter\StripTags();
print $filter->filter('<B>My content</B>');
|
As result you will get the stripped content ‘My content’.
When the content contains broken or partial tags then the complete following content will be erased. See the following example:
1 2 3 | $filter = new Zend\Filter\StripTags();
print $filter->filter('This contains <a href="http://example.com">no ending tag');
|
The above will return ‘This contains’ with the rest being stripped.
Allowing Defined Tags
Zend\Filter\StripTags allows stripping of all but defined tags. This can be used for example to strip all tags but links from a text.
1 2 3 4 | $filter = new Zend\Filter\StripTags(array('allowTags' => 'a'));
$input = "A text with <br/> a <a href='link.com'>link</a>";
print $filter->filter($input);
|
The above will return ‘A text with a <a href=’link.com’>link</a>’ as result. It strips all tags but the link. By providing an array you can set multiple tags at once.
Warning
Do not use this feature to get a probably secure content. This component does not replace the use of a proper configured html filter.
Allowing Defined Attributes
It is also possible to strip all but allowed attributes from a tag.
1 2 3 4 | $filter = new Zend\Filter\StripTags(array('allowTags' => 'img', 'allowAttribs' => 'src'));
$input = "A text with <br/> a <img src='picture.com' width='100'>picture</img>";
print $filter->filter($input);
|
The above will return ‘A text with a <img src=’picture.com’>picture</img>’ as result. It strips all tags but img. Additionally from the img tag all attributes but src will be stripped. By providing an array you can set multiple attributes at once.
This filter can set a scheme on an URI, if a scheme is not present. If a scheme is present, that scheme will not be affected, even if a different scheme is enforced.
Supported Options
The following options are supported for Zend\Filter\UriNormalize:
Basic Usage
See the following example for the default behaviour of this filter:
1 2 3 4 5 | $filter = new Zend\Filter\UriNormalize(array(
'enforcedScheme' => 'https'
));
echo $filter->filter('www.example.com');
|
As the result the string https://www.example.com will be output.
The source code of this file is hosted on GitHub. Everyone can update and fix errors in this document with few clicks - no downloads needed.


|
DQ skinning for Unity
Dual Quaternion skinning implementation with bulging compensation
|
Replaces Unity's default linear skinning with DQ skinning More...
Public Member Functions | |
| void | SetViewFrustrumCulling (bool viewFrustrumculling) |
| Enable or disable view frustrum culling. When moving the bones manually to test the script, bounding box does not update (it is pre-calculated based on available animations), which may lead to improper culling. More... | |
| bool | GetViewFrustrumCulling () |
| Returns current state of view frustrum culling. More... | |
| float[] | GetBlendShapeWeights () |
| Returns an array of currently applied blend shape weights. Default range is 0-100. It is possible to apply negative weights or exceeding 100. More... | |
| void | SetBlendShapeWeights (float[] weights) |
| Applies blend shape weights from the given array. Default range is 0-100. It is possible to apply negative weights or exceeding 100. More... | |
| void | SetBlendShapeWeight (int index, float weight) |
| Set weight for the blend shape with given index. Default range is 0-100. It is possible to apply negative weights or exceeding 100. More... | |
| float | GetBlendShapeWeight (int index) |
| Returns currently applied weight for the blend shape with given index. Default range is 0-100. It is possible to apply negative weights or exceeding 100. More... | |
| void | UpdatePerVertexCompensationCoef () |
| If the value of boneOrientationVector was changed while DualQuaternionSkinner is active (started == true), UpdatePerVertexCompensationCoef() must be called in order for the change to take effect. More... | |
Public Attributes | |
| Vector3 | boneOrientationVector = Vector3.up |
| Bone orientation is required for bulge-compensation. Do not set directly, use custom editor instead. More... | |
| float | bulgeCompensation = 0 |
| Adjusts the amount of bulge-compensation. More... | |
| ComputeShader | shaderComputeBoneDQ |
| ComputeShader | shaderDQBlend |
| ComputeShader | shaderApplyMorph |
Properties | |
| bool | started = false [get] |
| Indicates whether DualQuaternionSkinner is currently active. More... | |
| Mesh | mesh [get] |
| UnityEngine.Mesh that is currently being rendered. More... | |
Replaces Unity's default linear skinning with DQ skinning
Add this component to a GameObject that has SkinnedMeshRenderer attached.
Do not remove SkinnedMeshRenderer component!
Make sure that all materials of the animated object are using shader "MadCake/Material/Standard hacked for DQ skinning"
Definition at line 11 of file DualQuaternionSkinner.cs.
| float DualQuaternionSkinner.GetBlendShapeWeight | ( | int | index | ) |
Returns currently applied weight for the blend shape with given index.
Default range is 0-100.
It is possible to apply negative weights or exceeding 100.
| index | Index of the blend shape |
Definition at line 269 of file DualQuaternionSkinner.cs.
| float [] DualQuaternionSkinner.GetBlendShapeWeights | ( | ) |
Returns an array of currently applied blend shape weights.
Default range is 0-100.
It is possible to apply negative weights or exceeding 100.
Definition at line 201 of file DualQuaternionSkinner.cs.
| bool DualQuaternionSkinner.GetViewFrustrumCulling | ( | ) |
Returns current state of view frustrum culling.
Definition at line 182 of file DualQuaternionSkinner.cs.
| void DualQuaternionSkinner.SetBlendShapeWeight | ( | int | index, |
| float | weight | ||
| ) |
Set weight for the blend shape with given index.
Default range is 0-100.
It is possible to apply negative weights or exceeding 100.
| index | Index of the blend shape |
| weight | Weight to be applied |
Definition at line 244 of file DualQuaternionSkinner.cs.
| void DualQuaternionSkinner.SetBlendShapeWeights | ( | float[] | weights | ) |
Applies blend shape weights from the given array.
Default range is 0-100.
It is possible to apply negative weights or exceeding 100.
| weights | An array of weights to be applied |
Definition at line 218 of file DualQuaternionSkinner.cs.
| void DualQuaternionSkinner.SetViewFrustrumCulling | ( | bool | viewFrustrumculling | ) |
Enable or disable view frustrum culling.
When moving the bones manually to test the script, bounding box does not update (it is pre-calculated based on available animations), which may lead to improper culling.
Definition at line 167 of file DualQuaternionSkinner.cs.
| void DualQuaternionSkinner.UpdatePerVertexCompensationCoef | ( | ) |
If the value of boneOrientationVector was changed while DualQuaternionSkinner is active (started == true), UpdatePerVertexCompensationCoef() must be called in order for the change to take effect.
Definition at line 306 of file DualQuaternionSkinner.cs.
| Vector3 DualQuaternionSkinner.boneOrientationVector = Vector3.up |
Bone orientation is required for bulge-compensation.
Do not set directly, use custom editor instead.
Definition at line 17 of file DualQuaternionSkinner.cs.
| float DualQuaternionSkinner.bulgeCompensation = 0 |
Adjusts the amount of bulge-compensation.
Definition at line 66 of file DualQuaternionSkinner.cs.
|
get |
UnityEngine.Mesh that is currently being rendered.
Definition at line 290 of file DualQuaternionSkinner.cs.
|
get |
Indicates whether DualQuaternionSkinner is currently active.
Definition at line 75 of file DualQuaternionSkinner.cs.


Phiri Praises Bafana Persistence
by Soccer LadumaBafana Bafana know the ability that they have within their ranks, and for that reason weren’t frustrated when chance after chance was spurned against Sudan over the weekend.
Read: Sobhi Warns SA - ‘Let’s Not Forget We Scored Six…’
Lebogang Phiri proved to be the hero for South Africa as his rocket at the end of the first half proved to be the winner for Molefi Ntseki’s side, but Lebo Mothiba, Thapelo Morena, Kermit Erasmus and Thulani Serero could all have been on the scoresheet as well.
Despite to missed chances though, Bafana were happy to pick up three points against a stubborn Sudanese side that already had their first win of 2021 Africa Cup of Nations qualification, and it meant that Ntseki had his first competitive victory since taking over.
Phiri, who was speaking to the media after the game, insists that they always had faith in themselves though, saying, “For us as players on the pitch we don’t feel so frustrated, because we know the ability we have as individuals and as a collective as well.
Read: Bafana Hopeful Bags Euro Brace
“It was proven when we scored in the final minutes of the first half, and we’d created so many chances before that - nobody gave up, felt frustrated, or felt ‘Ok this is going to be a long day of missing chances’.
“We kept belief in what we were doing, and the outcome of the game shows it all.”
Phiri will now return to France where he’ll be hoping to help EA Guingamp in their quest to return to Ligue 1 next season.
Earn Airtime & Data With Soccer Laduma’s Social Media App - Download Now


LATTICE See also Contents file for LATTICE and its subfolders. LATTICE at2py - ELSTR=AT2PY(ELEM) convert AT element tp pyat at2str - Makes the string representation of an AT element ataddmpolecomppoly - Adds a multipole component to an existing polynomial, ataddmpoleerrors - Ataddrandmpole adds a random multipole component to all elements of type atdivelem - LINE=ATDIVELEM(ELEM,FRAC) divide an element into pieces atelem - Makes a new AT element structure from another element, atfastring - Generate simplified AT structures atfitchrom - ATFITTUNE fits chromaticites by scaling 2 sextupol families atfittune - Fits linear tunes by scaling 2 quadrupole families atgetcells - Performs a search on MATLAB cell arrays of structures atgetfieldvalues - Retrieves the field values AT cell array of elements atguessclass - Tries to determine the class of an element atindex - Extracts the information about element families and atinsertelems - Insert elements at given locations in a line atloadfielderrs - Will load a field error structure into a ring atmakefielderrstruct - MAKERNDFIELDERRS will create a field error data structure atreduce - Remove useless elements from an AT structure atsbreak - Insert markers at given s positions in a lattice atsetfieldvalues - Sets the field values of MATLAB cell array of structures atsetRFCavity - - sets the RF Cavity with the passmethod RFCavityPass atsetshift - Sets the misalignment vectors atsettilt - Sets the entrance and exit rotation matrices atshiftelem - Set new displacement parameters atsplitelem - Creates a line by inserting one or more elements into a base element attiltelem - Sets new rotation parameters atwritem - Creates a .m file to store an AT structure atwritepy - Creates a .m file to store an AT structure buildlat - Places elements from FAMLIST into cell array THERING combinebypassmethod - Combines adjacent elements that have the same specified pass method combinelinear45 - Combines adjacent elements that use 4-by-5 PassMethods entrancefields - () Return the list of field names affecting the element entrance exitfields - () Return the list of field names affecting the element exit findcells - Performs a search on MATLAB cell arrays of structures findtags - Looks for string matches in 'Tag' field of AT lattice elements getargs - Process positional arguments from the input arguments getcellstruct - Retrieves the field values MATLAB cell array of structures getflag - Check the presence of a flag in an argument list getoption - Extract a keyword argument from the input arguments insertelem0 - - quick and dirty: insertindrift - Inserts one or more elements into a drift element isatelem - Tests if an input argument is a valid AT element isatlattice - Tests if an input argument is a valid AT lattice mergedrift - Removes a lattice element and merges the two adjacent drift spaces mvelem - (ELEMPOS, DIST) moves an element located at ELEMPOS in THERING mvfield - Move fields from one structure to another parseargs - Check and expands optional argument lists reverse - Reverses the order of elements in a one-dimensional MATLAB ARRAY rmelem0 - Removes elements of length 0 from the accelerator lattice setcellstruct - Sets the field values of MATLAB cell array of structures setshift - Sets the misalignment vectors T1, T2 for elements settags - Sets the 'Tag' field in AT lattice elements settilt - Sets the entrance and exit misalignment matrixes splitdrift - Inserts an element into a drift space symplectify - Makes a matrix more symplectic LATTICE/CONVERTERS readmad - Reads the file output of MAD commands LATTICE/CONVERTERS/AT2ELEGANT AT_2_Elegant - This functions converts the AT lattice AT_ring in elegant form LATTICE/CONVERTERS/AT2G4BL ATtoG4BL - Function [outtext]=ATtoG4BL(P_0,particle,folder) LATTICE/CONVERTERS/AT2MAD8 AT_2_mad8 - Function [elelat,def,lines]=AT_2_mad8(AT_ring,linename) LATTICE/CONVERTERS/AT2MADX AT_2_madX - Function [elelat,defs,lines]=AT_2_madX(AT_ring,linename) LATTICE/CONVERTERS/AT2OPA AT_2_OPA - Function AT_2_OPA(AT_ring,linename) LATTICE/CONVERTERS/ELEGANT2AT ele2at_run_me - Test_elegant_converter elegant2at - Function elegant2at(elegantlattice,E0,outfilename) ParseAtributesELEGANT_2_AT - Determines atribute and sets field in sxs{i} structure AT LATTICE/CONVERTERS/MAD82MADX mad8TOmadx - Converts mad8 sequence files to madX LATTICE/CONVERTERS/MADX2AT atfrommadx - Function atfrommadx(seqfilemadX,E0,outfilename) buildATLattice - Given a list (cell array) of elements with specified field Spos (center of element (madx default)) in a ParseAtributesMADX_2_AT - Determines atribute and sets field in sxs{i} structure AT reshapeToCellArray - If CEL_CEL is a cell array of structures and cell arrays it converts it a LATTICE/CONVERTERS/MADX2AT/EXAMPLES convertMADXtoATExample - Simple lattice test (uncomment to run) LATTICE/CONVERTERS/MADX2G4BL madx2g4bl - Function [outtext]=madx2g4bl(P_0,particle,folder) LATTICE/ELEMENT_CREATION ataperture - Creates a aperture element atbaselem - Create an AT element structure + various checks atcorrector - Creates a drift space element with class 'Corrector' atdampMatElem - Creates an element that applies the global damping matrix atdrift - Creates a drift space element with Class 'Drift' atidtable - (FAMNAME,Nslice,filename,Energy,method) atM66 - (FAMNAME,M66,PASSMETHOD) atM66Tijk - ATM66(FAMNAME,M66,Tijk,PASSMETHOD) atmarker - Creates a marker space element atmonitor - Creates a Beam Position Monitor element with Class 'Monitor' atmultipole - Creates a multipole element atquadrupole - Creates a quadrupole element with Class 'Quadrupole' atQuantDiff - Creates a quantum diffusion element atrbend - Creates a rectangular bending magnet element with class 'Bend' atrfcavity - Creates an rfcavity element with Class 'RFCavity' atringparam - Creates a RingParameter Element which should go at the beginning of the ring atsbend - Creates a sector bending magnet element with class 'Bend' atsextupole - Creates a sextupole element with class 'Sextupole' atskewquad - Creates a skew quadrupole element with Class 'Multipole' atsolenoid - Creates a new solenoid element with Class 'Solenoid' atthinmultipole - Creates a thin multipole element atwiggler - Create a WIGGLER element LATTICE/ELEMENT_CREATION/PRIVATE decodeatargs - Separates arguments and resources LATTICE/PARAMGROUP atparamgroup - PARAMETER GROUP in AT is a general way mkparamgroup - Simplifies creation of AT parameter groups restoreparamgroup - Restores the values of multiple physical saveparamgroup - Saves the values of multiple physical setparamgroup - Modifies a group of parameters LATTICE/SURVEY atgeometry - Computes the 2-D position of all elements (no vertical bend) atgeometry3 - Computes the 3-D position of all elements This file was generated by updateContents.m on 04 Mar 2018 at 00:00:04.


***INCLUDES SPOILERS TO BOOK AND MOVIE***
Ender’s Game is a book I meant to read. Everyone I know has read it and just loved it. When I heard the movie was coming out, I decided it was time to read it in time to see the movie.
 I had a great time and just spectacular attendees who had great questions! If you have a chance to go to AngleBrackets (or it’s sister conference, DevIntersection) make the trip. They’re coming to Orlando this fall!
I had a chance to do two talks and an all-day course. If you attended these, check out the source code and slides (where applicable) below:
My book about my life as a software developer (The Opinionated Software Developer: What Twenty-Five Years of Slinging Code Has Taught Me) is available for free until October 31st. Consequently this is same the time I am at AngleBrackets (part of DevIntersection) in Las Vegas talking about Mobile Web, PhoneGap and Designing for Developers.
If you haven’t gotten the book yet, here is your chance for free! This has been the book I wanted to write for years now. Don't look for code in this book (ok, there are exactly two lines of code) - but instead I am writing about what being a software developer has meant to me. Hopefully some of the advice and observations will help you in your own career too!
As the leaves change, I realize that I am going to be on the road a bit this month. I am doing a conference, a meetup and the MVP summit. I just want to get my Skymiles Platinum card ; )
If you’re at any of the following events, please come up and say hello. Don’t be shy. I don’t bite…at least not hard.
Web API is a pretty sexy REST stack (though others are cool too). As I’ve been talking about it a lot lately, the biggest question by far is authentication and authorization. There are many options including OAuth, Token-based authentication, basic authentication, and even custom solutions. One option that should be included is to use your existing ASP.NET Forms-Based Authentication.
As a preview to my recently released course on ASP.NET Web API, we’ve released a clip that shows you how to piggy-back on ASP.NET Authentication to protect your Web API interfaces:
As some of you know, I authored a Pluralsight course on JavaScript for C# Developers. We’ve released an excerpt from that course covering how JavaScript function scopes work.
If you’re just getting started learning JavaScript, it can be easy to bring your C# biases to the language since they both have curly braces. Hopefully this excerpt will help:
I recently released my new writing project: “The Opinionated Software Developer”. This short book (about 35 pages according to Kindle) is a quick look at my experience in software development. It includes a history of my experience in the field as well as a look at the software developer psyche. The hope was to share my opinions about being a developer in the industry including how to deal with co-workers, how to avoid being a brat developer and how to motivate developers in larger organizations.
Most developers I know simply hate web design. As far as many developers are concerned CSS is evil. What CSS does for the web is magical but can be painful for developers that are used to functional or structural languages.
Luckily the browsers come to the rescue with great tooling. Here is a preview from my “Debugging the Web” Pluralsight course” which shows some of the basics:
2001-2013 © Shawn Wildermuth. ALL Rights Reserved.


Equivalence between flow graphs
Almost bisimulation is almost the equivalence we would like between
graphs. For example:
=
=
Unfortunately, it is too coarse, and fails to be a congruence:
=
A simulation between G1 and G2
is an almost simulation which is a function on
incoming edges of G1.


After the XDMAC selected channel has been programmed, XDMAD_PrepareChannel() is to enable clock and dma peripheral of the DMA, and set Configuration register to set up the transfer type (memory or non-memory peripheral for source and destination) and flow control device.


Definition at line 881 of file paragraphs.cpp.
◆ GeometricClassifierState()
◆ AlignsideTabIndex()
| int tesseract::GeometricClassifierState::AlignsideTabIndex |
( |
int |
row_idx | ) |
const |
|
inline |
◆ AlignTabs()
◆ AssumeLeftJustification()
| void tesseract::GeometricClassifierState::AssumeLeftJustification |
( |
| ) |
|
|
inline |
◆ AssumeRightJustification()
| void tesseract::GeometricClassifierState::AssumeRightJustification |
( |
| ) |
|
|
inline |
◆ Fail()
| void tesseract::GeometricClassifierState::Fail |
( |
int |
min_debug_level, |
|
|
const char * |
why |
|
) |
| const |
|
inline |
◆ FirstWordWouldHaveFit()
| bool tesseract::GeometricClassifierState::FirstWordWouldHaveFit |
( |
int |
row_a, |
|
|
int |
row_b |
|
) |
| |
|
inline |
◆ IsFullRow()
| bool tesseract::GeometricClassifierState::IsFullRow |
( |
int |
i | ) |
const |
|
inline |
Definition at line 925 of file paragraphs.cpp.
928 void Fail(
int min_debug_level,
const char *why)
const {
◆ Model()
◆ OffsideTabs()
◆ PrintRows()
| void tesseract::GeometricClassifierState::PrintRows |
( |
| ) |
const |
|
inline |
◆ body_indent
| int tesseract::GeometricClassifierState::body_indent = 0 |
◆ debug_level
| int tesseract::GeometricClassifierState::debug_level = 0 |
◆ eop_threshold
| int tesseract::GeometricClassifierState::eop_threshold = 0 |
◆ first_indent
| int tesseract::GeometricClassifierState::first_indent = 0 |
◆ just
◆ left_tabs
◆ ltr
| bool tesseract::GeometricClassifierState::ltr = false |
◆ margin
| int tesseract::GeometricClassifierState::margin = 0 |
◆ right_tabs
◆ row_end
| int tesseract::GeometricClassifierState::row_end = 0 |
◆ row_start
| int tesseract::GeometricClassifierState::row_start = 0 |
◆ rows
◆ tolerance
| int tesseract::GeometricClassifierState::tolerance = 0 |
The documentation for this struct was generated from the following file:


{% extends 'base-outer.html' %} {% block title %}About Huxley{% endblock title %} {% block content %}
Hi there! We're glad you're interested in learning more about Huxley.
Back to LoginHuxley was created by Kunal Mehta and William Chieng, two 3rd-year Cal Computer Science undergraduates.
We used a lot of great tools to put this app together. Check them out below:
We want to give a shout-out to the following resources, which were incredibly helpful and without which we may not have been able to complete Huxley.


Ruby: Classes
Intro
Ruby is an object oriented programming language. Like most modern programming languages including C/C++, Java, C#, etc. Ruby, also, includes classes and objects. To get started, let’s define a class in Ruby and learn the types of variables we can set within a Ruby class.
Class Definition
In Ruby, classes start with the keyword class followed by the class name and it ends with the keyword end.
class Die end
Variables
There are four types of variables we can use within a Ruby class:
- Local variables: set and used within a method
- Instance variables: set and used within methods for a particular instance or object; preceded by @ sign
- Ex: @sides
- Class variables: set and used within a class; preceded by @@ sign
- Ex: @@sides
- Global variables: set and used outside a class; can be accessed by different classes and are preceded by a $ sign
- Ex: $sides
Instance Methods
Next, let’s learn about creating methods within a class in Ruby. Let us take a closer look at the problem from Devbootcamp’s phase 0, unit 2, exercise 1:
Problem
Implement a basic Die class which can be initialized with some number of sides. We can then roll the die, returning a random number.
Solution
In the example above, three instance methods were written to solve the given problem. Now, in order to call the instance methods, we need to call the “new” method to create an object. [New is a class method and it is used to create an instance or an object which is required to call the instance methods.] For ex:
p Die.sides #=> NoMethodError p Die.new(6).sides #=> 6


BetAndRuin
Home
Events
Settings
All events
All events By can Bet
Unresolved Events
Resolved Events
Users
All Users
Banned Users
News
Create
Event
News
Statistics
Server Status
Settings
Log out
Users
Viewing
200
Users
Search
Search
Previous
1
2
...
3
4
Next
Id
Username
Email
Name
Surname
Phone Number
First Login
Last Login
Ip address
Wallet Funds
User rank
View More Details
1
Ccass
<EMAIL_ADDRESS>Carlos
Dominguez
123456789
Thu Mar 14 08:52:37 CET 2019
Thu Mar 14 08:52:37 CET 2019
<IP_ADDRESS>
0.0
1
More Details


First read about WillPaginate::Finder::ClassMethods, then see WillPaginate::ViewHelpers. The magical array you’re handling in-between is WillPaginate::Collection.
Happy paginating!
# File lib/will_paginate.rb, line 52 def self.construct_count_options_from_args(*args) result = super result[0] = '*' if result[0].is_a?(String) and result[0] =~ /\.\*$/ result end
shortcut for enable_actionpack and enable_activerecord combined
# File lib/will_paginate.rb, line 14 def enable enable_actionpack enable_activerecord end
hooks WillPaginate::ViewHelpers into ActionView::Base
# File lib/will_paginate.rb, line 20 def enable_actionpack return if ActionView::Base.instance_methods.include_method? :will_paginate require 'will_paginate/view_helpers' ActionView::Base.send :include, ViewHelpers if defined?(ActionController::Base) and ActionController::Base.respond_to? :rescue_responses ActionController::Base.rescue_responses['WillPaginate::InvalidPage'] = :not_found end end
hooks WillPaginate::Finder into ActiveRecord::Base and classes that deal with associations
# File lib/will_paginate.rb, line 32 def enable_activerecord return if ActiveRecord::Base.respond_to? :paginate require 'will_paginate/finder' ActiveRecord::Base.send :include, Finder # support pagination on associations a = ActiveRecord::Associations [ a::AssociationCollection ].tap { |classes| # detect http://dev.rubyonrails.org/changeset/9230 unless a::HasManyThroughAssociation.superclass == a::HasManyAssociation classes << a::HasManyThroughAssociation end }.each do |klass| klass.send :include, Finder::ClassMethods klass.class_eval { alias_method_chain :method_missing, :paginate } end # monkeypatch Rails ticket #2189: "count breaks has_many :through" ActiveRecord::Base.class_eval do protected def self.construct_count_options_from_args(*args) result = super result[0] = '*' if result[0].is_a?(String) and result[0] =~ /\.\*$/ result end end end
Enable named_scope, a feature of Rails 2.1, even if you have older Rails (tested on Rails 2.0.2 and 1.2.6).
You can pass false for patch parameter to skip monkeypatching associations. Use this if you feel that named_scope broke has_many, has_many :through or has_and_belongs_to_many associations in your app. By passing false, you can still use named_scope in your models, but not through associations.
# File lib/will_paginate.rb, line 68 def enable_named_scope(patch = true) return if defined? ActiveRecord::NamedScope require 'will_paginate/named_scope' require 'will_paginate/named_scope_patch' if patch ActiveRecord::Base.send :include, WillPaginate::NamedScope end
Generated with the Darkfish Rdoc Generator 2.


Latest _Trek_ Boldly Goes Nowhere
STAR TREK: INSURRECTION
Review by Victory A. Marasigan http://www.gl.umbc.edu/~vmaras1/reviewsidx.html
It's hard to believe it's been nearly five years since "The Next Generation" crew gave up their top-rated syndicated TV series "to explore new worlds and new civilizations" on the big screen. What's not as difficult to believe is the ebb of rich characterizations and fresh storylines their infrequent adventures have necessitated. _Star Trek: Insurrection_, the crew's third feature, sadly rings more like a _Return to Mayberry_-type reunion than a thrilling further adventure.
This time around, the Enterprise and her crew must travel to a remote planet, where one of their own has apparently gone renegade and taken people hostage. Captain Picard (Patrick Stewart) and crew manage to subdue their comrade and beam down to investigate, only to find a small colony of youthful Ba'ku living in an eerily tranquil, unchanging paradise. The actual threat to these humanoid people is a group of stretchy-faced aliens called the Son'a (led by _Amadeus_' F. Murray Abraham) who, under the sanction of the Federation, have devised a sneaky plan to steal the planet -- and its rejuvenating resources -- right out from under the Ba'ku's wrinkle-free noses.
The planet's virtual Fountain of Youth is a thinly-veiled excuse to show Our Gang acting uncharacteristically giddy and energetic, a la the break-dancing old geezers in Cocoon. Counselor Troi and Commander Riker (Marina Sirtis and director Jonathan Frakes) rekindle their early TV series romance. Worf (Michael Dorn) goes through Klingon puberty all over again. Geordi LaForge (Levar Burton) gets to see for the first time. And Picard finds love with a sweet (and improbably unattached) Ba'ku (Donna Murphy). It's too bad the planet's powers can't work true miracles, like subtracting the pounds some of the crew have gained during their two-year hiatus (Is it just me, or is Commander Riker prematurely showing the famous Captain Kirk lovehandles?).
The temporary augmentations brought about by the planetary anomaly only highlight a failure of the new movie voyages so far. After three films, no major changes in the characters' lives have occurred, barring Picard's Ahab-Moby Dick awakening in _First Contact_. Beloved personalities like Troi and Worf have become mere caricatures of themselves. And the pasty-white android Commander Data (Brent Spiner) has had nothing to do but plod along and "discover" yet another strange facet of humanity -- in this case the concept of adolescent fun (Really, after almost a decade on the Enterprise, you'd think he'd have learned the meaning of "fun" long ago).
Much of Insurrection's self-aware script plays off the fact that these characters know each other so well, they can predict exactly what the other is going to do in any given situation. Their familiarity with each other is sort of a private joke, albeit one which seasoned viewers of the series will eat up. It's all too apparent that writers Rick Berman and Michael Piller were trying to duplicate the virtues of their last film, the enjoyable _First Contact_. But all the eye-winking humor and space-chase action they packed into this outing can't mask the fact that the story is silly, dull, and ultimately inconsequential to the _Star Trek_ mythos. Unless the Enterprise breaks free of the orbit into which it's currently locked, the hit-or-miss legacy of the franchise will likely continue.
GRADE: C+
Reviewed December 9, 1998 at RC Eastpoint, Baltimore, MD.
The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).
The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.
Please direct comments/criticisms of the review to relevant newsgroups.
Broken URLs inthe reviews are the responsibility of the author.
The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.
Related links: index of all rec.arts.movies.reviews reviews


We take this question very seriously. If your goal is to launch a career as a developer, be prepared to put in tremendous time and effort both during and after our program. A successful job search might take 3 weeks or it might take 6+ months. The last thing we want to do is enroll a student who is not able to comfortably endure this reality.


A Couple More Things
Tell us a little bit more about you.
Education
School
Major
Job ;
Height
Body Type
Ethnicity
Religion
Political View


About
Enable3d is written in TypeScript, and wraps three.js and ammo.js.
Enable3d is designed in a modular way. Means, you can benefit from enable3d in 3 different ways. As a physics extension for three.js, in Standalone Mode or as 3D Extension for Phaser.
There are like 3 levels of wrapping where @enable/ammoPhysics is the lowest level, then @enable3d/threeGraphic and finally @enable3d/phaser on top.
Examples
Get Started
Simply clone the enable3d-project-template.


您能将您要上传的头像拖动到上面，也可以使用下面的文件选择输入框 File API & FileReader API not supported XHR2's FormData is not supported XHR2's upload progress isn't supported 上传进度：0


Sign in to Github
Username or email address
Password
Forgot password?
New to Github?
Create an account.


We’re all familiar with search engine friendly URLs ie. a filter on ‘Mid range’ would be hyphenated to /mid-range
.
TL;DR you can have a slug with multiple hyphenated search terms by iterating and extracting the terms in your taxonomy from the slug but you must ensure only one slug will be serving your content by automatically redirecting malformed slugs.
The old way
When asked to build a search page off user’s UI selection filters I’d first approach it with the classic query string, ie. user clicking filter for ‘mid range’ and ‘contemporary’ would result in a result page URL with search%5B%5D=mid range&search%5B%5D=contemporary
or perhaps with the ID of the filter term. Not very search engine friendly I’ve been told.
A friendlier approach
I’d suggest a unique term separator (not occurring in any term) for example: /mid-range_contemporary
or adding a separate segment for each term filtered on /contemporary/mid-range/
. In the latter you’d be expected to populate /contemporary
with relevant content, and you’d have to prevent the user from clicking ‘mid range’ before ‘contemporary’.
A polymorphic way
Recently I was told that a better search engine approach would be to have a single segment based on the previous user selection example: /mid-range-contemporary
, and after clicking ‘gray decks’ the URL would become /mid-range-contemporary-gray-decks
. But /gray-decks-mid-range-contemporary
should return the same result page.
All these examples are from a real web site called zillow.com (that my SEO team used as an example). I determined these were not to be called search engine friendly (SEF) URL anymore but search engine polymorphic (SEP) URL.
Polymorphism
in biology occurs when two or more clearly different phenotypes exist in the same population of a species - in other words, the occurrence of more than one form or morph. In order to be classified as such, morphs must occupy the same habitat at the same time and belong to a panmictic population (one with random mating).
– Wikipedia
And here’s a real example knocking at my door: zillow tag system changing their urls exactly per my SEO team request.
After seeing it happening before my eyes I had to find a way to do it.
Ruby on Rails spike on polymorphic URLs
I started from a route receiving the polymorphic slug:
get '/digs/:polymorphic_slug' => 'polymorphic#index'
and hand it over to the controller action that would delegate the lookup:
lookup = PolymorphicSlugLookup.new(params[:polymorphic_slug])
terms = []
dictionary = Dictionary.new
lookup.ids.each do |id|
terms << dictionary.term(id)
end
flash[:notice] = "You searched for : #{terms.join(' ')}"
The PolymorphicSlugLookup class is where given the slug, I gather every term from the slug until is empty.
class PolymorphicSlugLookup
def initialize(slug)
@slug = slug
@dictionary = Dictionary.new
end
def ids
@ids = []
@dictionary.ordered_terms.each do |term|
if @slug.match(/-?#{term}-?/)
@slug.gsub!(/-?#{term}-?/, '')
@ids << @dictionary.id(term)
end
break if @slug.empty?
end
@ids
end
end
Having ordered terms is critical to avoid shorter terms being a partial match. Which is a constraint of this system: if we have two terms ‘fire’ and ‘fireplace’ then the longer will take precedence and override the shorter.
Resource uniqueness
You don’t want to have two URLs serving the same resource ie. /mid-range-contemporary-gray-decks
and /gray-mid-range-contemporary-decks
. You can prevent this from your UI but users could type or start linking content to it and the curent solution would serve that content.
Assuming the lookup returns ids ordered according to your SEO value, you could redirect if the original slug doesn’t match. A solution is to have a PolymorphicSlugRedirect
that given the result of a lookup, would compare it with the requested slug.
lookup = PolymorphicSlugLookup.new(params[:polymorphic_slug])
redirect = PolymorphicSlugRedirect.new(params[:polymorphic_slug], lookup.ids)
if redirect.execute?
redirect_to "/digs/#{redirect.destination}"
end
# render search response...
How slow is this?
Well, I’ve benchmarked the look up:
Benchmark.bm do |x|
x.report { lookup = PolymorphicSlugLookup.new('bathrooms'); lookup.ids }
end
with about 100 terms preloaded in memory:
$ ruby benchmark.rb
user system total real
0.000000 0.000000 0.000000 ( 0.002699)
with about 1000 terms:
$ ruby benchmark.rb
user system total real
0.010000 0.010000 0.020000 ( 0.014530)
with now over 10000 terms the lookup is now taking a significant 150ms:
$ ruby benchmark.rb
user system total real
0.140000 0.010000 0.150000 ( 0.149572)
I haven’t tested this with any caching but assuming you find a suitable expiration policy you could HTTP cache those URLs.
I committed this sample app on https://github.com/agenteo/lab-search-engine-friendly-urls.
Conclusion
My inital gut feeling was this URL requirement was odd and not in touch with reality. I later realized I was wrong, and how having a mutating or polymorphic segment is indeed pretty natural.
This will help us apply our SEO requirements, I am curious if you’ve seen zillow search engine friendly/polymorphic like filters anywhere else.


Period films based on literary masterpieces range from the superior ("Age of Innocence," "The Remains of the Day") to the detrimental ("The Scarlet Letter"). "The Crucible" falls somewhere in between and, although it is not a great film, it is certainly a passionate, powerful film that does justice to Arthur Miller's spectacular 1953 play. Its power has not been diminished on the big screen.
"The Crucible" is set during the 17th century when an array of witchhunts began. mostly led by the teenage girls who were accused. Set in 1692, the movie starts off with a devilish ceremony where a group of girls are ranting in the woods of Salem, Massachussetts, performing an unholy ritual.  This unholy practice is witnessed by Abigail's uncle, Reverend Parris (Bruce Davison), and a witchcraft trial commences the next day. And almost immeiately, the accusations, denials and name-calling begins - Abigail and the others decide to fool everyone into thinking that the devil is visible, but visible only to them.
Numerous innocent townspeople are accused, including John Proctor (Daniel Day-Lewis), a farmer who had a brief affair with Abigail and is now married to his strictly devout wife, Elizabeth (Joan Allen). Abigail's form of revenge is to accuse the reverent Elizabeth of witchcraft - at this point, any of these girls can accuse anyone in town of witchcraft no matter how false the claims may be (they go through extreme measures to prove them, too). The trials continue and destroy many lives (mostly by hanging). Paul Scofield plays Judge Danforth who overlooks the trials, and decides that if the accused confess to their demonic ways, they will not be hanged. He presides over the trial with doubts but is inclined to believe that demons of another kind have infiltrated this town.
"The Crucible" is a startling, alert interpretation of the Miller play, which should come as no surprise since Miller wrote the screenplay himself. The performances by the young actresses are over-the-top but necessarily so, to establish the lengths of their insane accusations. Winona Ryder is effectively hateful as the angry, vengeful Abigail (a far cry from her role in "Little Women"), a frail, demonic child ready to pounce. Daniel Day-Lewis is also superb as the brave, decent Proctor who simultaneously finds his soul being eaten away by Abigail and his love growing stronger for Elizabeth. Joan Allen ("Nixon") gives the most understated performance as the seemingly frigid Elizabeth, and her final scene with Proctor is heartbreaking to witness. And let's not forget the overpoweringly magnetic Paul Scofield ("Quiz Show"), a delectable presence whenever he's on screen spouting his lines with gusto and verve. Another Academy Award nomination is in order for this grand actor of the cinema, in addition to the whole cast.
If "The Crucible" falls short of greatness, it is because director Nicholas Hytner ("The Madness of King George") plunges us into a sea of excess right from the start, giving us little time to catch up with the story or the characters (Ryder's portrayal of Abigail is nutty and vicious from the beginning). Still, this beautifully mounted version summons the rage, hatred and madness of those rough times with knowing cinematic skill, and doesn't commit the fatal flaw of becoming a static, filmed play.
For more reviews, check out JERRY AT THE MOVIES at http://buffs.moviething.com/buffs/faust/
E-mail me with any questions, concerns or general comments at<EMAIL_ADDRESS>or at<EMAIL_ADDRESS>The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).
The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.
Please direct comments/criticisms of the review to relevant newsgroups.
Broken URLs inthe reviews are the responsibility of the author.
The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.
Related links: index of all rec.arts.movies.reviews reviews


Full Phot¶
-
full_phot.
find_sources_full
(img, fwhm, bg_std, threshold=4.0)[source]¶ Use
pyraf daofind
to located sources on a stacked image.doafind
options :: iraf.unlearn(iraf.apphot.daofind) iraf.datapars.setParam(‘fwhmpsf’,fwhm,check=1) iraf.datapars.setParam(‘datamin’,-900,check=1) iraf.datapars.setParam(‘datamax’,60000,check=1) iraf.datapars.setParam(‘sigma’,bg_std,check=1) iraf.findpars.setParam(‘threshold’,threshold) iraf.apphot.daofind.setParam(‘output’,output) iraf.apphot.daofind(image=img, verbose=”no”, verify=’no’)Parameters: - img (str) – String containing name of the image currently in use
- fwhm (float) – fwhm measure of sources in field
- bg_std (float) – standard deviation of background in image
- threshold (float) – detection threshold for sources
Note
Produces a coordinate file based on the name of the image. The file name will be
img.nofits()+_sources.coo
-
full_phot.
phot_sources_full
(img, fwhm, airmass, apfactor)[source]¶ Run
pyraf phot
on the sources found byfind sources_full
Parameters: - img (str) – String containing name of the image currently in use
- fwhm (float) – fwhm measurement in image
- airmass (float) – airmass of image
- apfactor (float) – multile of fwhm to use for photometry
Note
Will retrun a
.phot
table with the nameimg.nofits()+.srcphot
-
full_phot.
phot_sources_xy2sky
(img, inst)[source]¶ Convert the x,y positions in the phot table produced by
phot_sources_full
into Ra and Dec positions.Parameters: - img (str) – String containing name of the image currently in use
- inst (str) – ODI configuration.
podi
or5odi
Note
Returns a table with the name
img.nofits()+.srcphotrd
-
full_phot.
match_phot_srcs
(img1, img2)[source]¶ Match the sources in two images. This function reads in the photometry tables produces by
phot_sources_xy2sky
and used the Ra and Dec positions to match the sources between the images.Parameters: - img1 (str) – Name of the stacked image in the first filter (e.g. odi_g)
- img2 (str) – Name of the stacked image in the second filter (e.g. odi_r)
Note
Produces a catalog of matched sources for each image.
img1[:-5]+.match.srscrd
andimg2[:-5]+.match.srscrd
These magnitudes are combined in the filecalibration.dat
.