Welcompose
[ class tree: Welcompose ] [ index: Welcompose ] [ all elements ]

Class: Utility_Helper

Source Location: /utility_classes/helper.class.php

Class Overview




Variables

Methods



Class Details

[line 38]


[ Top ]


Class Variables

static $instance =  null

[line 45]

Singleton



Tags:

access:  public

Type:   object


[ Top ]

$base =  null

[line 52]

Reference to base class



Tags:

access:  public

Type:   object


[ Top ]

$textile =  null

[line 59]

Textile object



Tags:

access:  protected

Type:   object


[ Top ]



Class Methods


constructor __construct [line 66]

Utility_Helper __construct( )

Start instance of base class, load configuration and establish database connection. Please don't call the constructor direcly, use the singleton pattern instead.



Tags:

access:  public


[ Top ]

method applyMarkdown [line 791]

string applyMarkdown( string $str, [bool $strip_html = true])

Applies markdown on given string. Takes the string to convert as first argument, the information if HTML should be stripped before using markdown as second argument. Returns the converted string.



Tags:

throws:  Utility_HelperException
access:  public


Parameters:

string   $str   String to convert
bool   $strip_html   Stip html

[ Top ]

method applyTextile [line 826]

string applyTextile( string $str, [bool $strip_html = true])

Applies Textile on given string. Takes the string to convert as first argument, the information if HTML should be stripped before using markdown as second argument. Returns the converted string.



Tags:

throws:  Utility_HelperException
access:  public


Parameters:

string   $str   String to convert
bool   $strip_html   Stip html

[ Top ]

method calculatePageIndex [line 974]

array calculatePageIndex( int $total_items, int $interval)

Calculates a page index on basis of the total item count and the number of items per page. Tasks the total item count as first argument, the number of items per page as second argument. Returns array.



Tags:

throws:  Utility_HelperException
access:  public


Parameters:

int   $total_items   Total item count
int   $interval   Number of items per page

[ Top ]

method createMeaningfulString [line 865]

string createMeaningfulString( string $str)

Replaces non-url-friendly characters like whitespaces etc. with something more url friendly to create the 'meaningful urls'. Takes the string to convert as first argument. Returns the converted string.

See helper::_urlTranslationTable() for the whole character translation table.




Tags:

access:  public


Parameters:

string   $str  

[ Top ]

method dateFromQuickFormDate [line 1081]

string dateFromQuickFormDate( $values)

Creates date string as expected by MySQL's date fields from QuickForm's date element.



Tags:

access:  public


Parameters:

   $values  

[ Top ]

method datesForTimeframe [line 564]

array datesForTimeframe( string $timeframe)

Calculates start/end dates for given timeframe. Takes the name of the timeframe as first argument. Returns array with to values: timeframe_start and timeframe end.

See Utility_Helper::getTimeframes() for a list of supported timeframes.




Tags:

throws:  Utility_HelperException
access:  public


Parameters:

string   $timeframe   Timeframe name

[ Top ]

method datetimeFromQuickFormDate [line 1019]

string datetimeFromQuickFormDate( $values)

Creates date string as expected by MySQL's datetime fields from QuickForm's date element.



Tags:

access:  public


Parameters:

   $values  

[ Top ]

method datetimeFromQuickFormDateWithNull [line 1050]

string datetimeFromQuickFormDateWithNull( $values)

Creates date string as expected by MySQL's datetime fields from QuickForm's date element. Return null when empty.



Tags:

access:  public


Parameters:

   $values  

[ Top ]

method getTimeframes [line 271]

array getTimeframes( )

Returns array with available timeframes.



Tags:

access:  public


[ Top ]

method testSqlDataForPearErrors [line 942]

bool testSqlDataForPearErrors( array &$sqlData)

Tests array of sql data for pear errors. Takes array with sql data as first argument, returns bool.



Tags:

throws:  Utility_HelperException
access:  public


Parameters:

array   &$sqlData   Sql data

[ Top ]

method timeFromQuickFormDate [line 1108]

string timeFromQuickFormDate( $values)

Creates time string as expected by MySQL's time fields from QuickForm's date element.



Tags:

access:  public


Parameters:

   $values  

[ Top ]

method _searchLikewise [line 768]

string _searchLikewise( string $field, string $str)

Creates sql fragment to search for given string Take the table field name as first argument and the search string as second. Returns sql fragment string.



Tags:

throws:  Utility_HelperException
access:  public


Parameters:

string   $field   Table field name
string   $str   Search fragment

[ Top ]

method _sqlForCurrentDate [line 734]

string _sqlForCurrentDate( string $field, string $current_date)

Creates sql fragment for given current date (now()). Takes the name of the date field as first argument, the value of the parameter as second argument. Returns string.



Tags:

return:  Sql fragment
throws:  Utility_HelperException
access:  public


Parameters:

string   $field   Date field name
string   $current_date   Current Date value

[ Top ]

method _sqlForOrderMacro [line 107]

string _sqlForOrderMacro( string $definition, array $macros)

Translate order definition into sql statements

Order definition

  1.  DATE;MANUFACTURER:ASC;DATE:DESC;ID;STATUS:ASC

Macro definition

  1.  $macros array(
  2.      'DATE' => '`catalogue_articles`.`date_added`',
  3.      'MANUFACTURER' => '`catalogue_manufacturer`.`id`'
  4.  );




Tags:

throws:  Utility_HelperException
access:  public


Parameters:

string   $definition   Order definition
array   $macros   Macro definition

[ Top ]

method _sqlForTimeframe [line 316]

string _sqlForTimeframe( string $field, string $timeframe)

Creates sql fragment for given timeframe. Takes the name of the date field as first argument, the name of the timeframe as second argument. Returns string.

See Utility_Helper::getTimeframes() for a list of supported timeframes.




Tags:

return:  Sql fragment
throws:  Utility_HelperException
access:  public


Parameters:

string   $field   Date field name
string   $timeframe   Timeframe name

[ Top ]

method _sqlInFromArray [line 149]

string _sqlInFromArray( string $field, array $values)

Generates IN clause for database queries. Takes the field to search as first argument, the values for the IN clause as second argument. Returns string with sql query fragment. Sample:

  1.  echo $helper->_sqlInFromArray('id'array(12));
  2.  // result:
  3.  // id IN (1, 2)




Tags:

throws:  Utility_HelperException
access:  public


Parameters:

string   $field   Field name
array   $values   Search values

[ Top ]

method _sqlLikeFromArray [line 234]

string _sqlLikeFromArray( string $field, array $values, [string $concat = 'OR'])

Generates multiple LIKE clauses for database queries from array of

search values. Takes the field to search as first argument, the values for the LIKE clauses as second argument and an optional concatenation operator as third argument. Returns string with sql query fragment. Sample:

  1.  echo $helper->_sqlLikeFromArray('id'array(12)'AND');
  2.  // result:
  3.  // id LIKE 1 AND LIKE 2
  4.  
  5.  echo $helper->_sqlLikeFromArray('id'array(12)'OR');
  6.  // result:
  7.  // id LIKE 1 OR LIKE 2




Tags:

throws:  Utility_HelperException
access:  public


Parameters:

string   $field   Field name
array   $values   Search values
string   $concat   Concatenation operator

[ Top ]

method _sqlNotInFromArray [line 188]

string _sqlNotInFromArray( string $field, array $values)

Generates NOT IN clause for database queries. Takes the field to search as first argument, the values for the NOT IN clause as second argument. Returns string with sql query fragment. Sample:

  1.  echo $helper->_sqlNotInFromArray('id'array(12));
  2.  // result:
  3.  // id NOT IN (1, 2)




Tags:

throws:  Utility_HelperException
access:  public


Parameters:

string   $field   Field name
array   $values   Search values

[ Top ]

method _urlTranslationTable [line 912]

array _urlTranslationTable( )

Url translation table

Creates and returns the url translation table for helper::createMeaningfulString().




Tags:

access:  protected


[ Top ]


Documentation generated on Sun, 08 Jan 2012 17:51:51 +0100 by phpDocumentor 1.4.3