Sweden Democrats' Meeting Tool
 All Classes Files Functions Variables Pages
Public Member Functions | Public Attributes | Protected Attributes | List of all members
SD_Meeting_Tool_Base Class Reference

Base class for the SD series of Wordpress plugins. More...

Inheritance diagram for SD_Meeting_Tool_Base:
SD_Meeting_Tool_0 SD_Meeting_Tool SD_Meeting_Tool_Actions SD_Meeting_Tool_Agendas SD_Meeting_Tool_Display_Formats SD_Meeting_Tool_Displays SD_Meeting_Tool_elections SD_Meeting_Tool_List_Sorts SD_Meeting_Tool_Lists SD_Meeting_Tool_Participants SD_Meeting_Tool_Printing SD_Meeting_Tool_Registration_UI_Text_Searches SD_Meeting_Tool_Registrations SD_Meeting_Tool_Speakers

Public Member Functions

 __construct ($filename)
 activate ()
 deactivate ()
 deactivate_me ()
 admin_init ()
 admin_uninstall ()
 load_language ($domain= '')
 _ ($string)
 uninstall ()
 query ($query, $wpdb=null)
 query_single ($query)
 query_insert_id ($query)
 sql_encode ($object)
 sql_decode ($string)
 sql_table_exists ($table_name)
 get_user_role ()
 roles_as_options ()
 role_at_least ($role)
 user_id ()
 delete_option ($option)
 delete_local_option ($option)
 delete_site_option ($option)
 fix_option_name ($option)
 deregister_options ()
 get_option ($option)
 get_local_option ($option, $default=false)
 get_site_option ($option, $default=false)
 register_options ()
 update_option ($option, $value)
 update_local_option ($option, $value)
 update_site_option ($option, $value)
 display_message ($type, $string)
 message ($string)
 message_ ($string, $args= '')
 Convenience function to translate and then create a message from a string and optional sprintf arguments.
 error ($string)
 error_ ($string, $args= '')
 Convenience function to translate and then create an error message from a string and optional sprintf arguments.
 array_insert ($array, $position, $new_array)
 Insert an array into another.
 array_sort_subarrays ($array, $key)
 Sort an array of arrays using a specific key in the subarray as the sort key.
 array_rekey ($array, $key)
 array_to_object ($array, $object=null)
 ago ($time_string, $time=null)
 check_plain ($text)
 display_form_table ($inputs, $options=array())
 display_form_table_row ($input, $form=null)
 download ($filepath, $options=array())
 Output a file to the browser for downloading.
 filters ($filter_name)
 form ($options=array())
 hash ($string, $type= 'sha512')
 implode_html ($prefix, $suffix, $array)
 Implode an array in an HTML-friendly way.
 minmax ($number, $min, $max)
 mime_type ($filename)
 now ()
 object_to_array ($object)
 p ($string, $args= '')
 wpautop's a string, using sprintf to replace arguments.
 p_ ($string, $args= '')
 wpautop's a translated string, using sprintf to replace arguments.
 rmdir ($directory)
 send_mail ($mail_data)
 slug ($string)
 strip_post_slashes ($post=null)
 strtolower ($string)
 strtoupper ($string)
 tab_slug ($string)
 tabs ($options)
 time ()
 wrap ($title, $text)
 Outputs the text in Wordpress admin's panel format.

Public Attributes

 $paths = array()

Protected Attributes

 $is_network
 $site_options = array()
 $local_options = array()
 $options = array()
 $language_domain = ''
 $wpdb
 $roles

Detailed Description

Base class for the SD series of Wordpress plugins.

Provides a simple framework with common Wordpress functions.

Changelog
Author
Edward Plainview edwar.nosp@m.d.pl.nosp@m.ainvi.nosp@m.ew@s.nosp@m.verig.nosp@m.edem.nosp@m.okrat.nosp@m.erna.nosp@m..se

Constructor & Destructor Documentation

SD_Meeting_Tool_Base::__construct (   $filename)

Construct the class.

Parameters
$filenameThe full path of the parent class.

Member Function Documentation

SD_Meeting_Tool_Base::_ (   $string)

Translate a string, if possible.

Like Wordpress' internal _() method except this one automatically uses the plugin's domain.

Can function like sprintf, if any s are specified.

Parameters
$stringString to translate. s will require extra arguments to the method.
Returns
Translated string, or the untranslated string.
SD_Meeting_Tool_Base::activate ( )
SD_Meeting_Tool_Base::admin_init ( )

Filter for admin_init.

Reimplemented in SD_Meeting_Tool_Printing.

SD_Meeting_Tool_Base::admin_uninstall ( )

Shows the uninstall form.

Form is currently only available in English.

SD_Meeting_Tool_Base::ago (   $time_string,
  $time = null 
)

Display the time ago as human-readable string.

Parameters
$time_string"2010-04-12 15:19"
$timeAn optional timestamp to base time difference on, if not now.
Returns
"28 minutes ago"
SD_Meeting_Tool_Base::array_insert (   $array,
  $position,
  $new_array 
)

Insert an array into another.

Like array_splice but better, because it even inserts the new key.

Parameters
$arrayArray into which to insert the new array.
$positionPosition into which to insert the new array.
$new_arrayThe new array which is to be inserted.
Returns
The complete array.
SD_Meeting_Tool_Base::array_rekey (   $array,
  $key 
)

Make a value a key.

Given an array of arrays, take the key from the subarray and makes it the key of the main array.

Parameters
$arrayArray to rearrange.
$keyWhich if the subarray keys to make the key in the main array.
Returns
array Rearranged array.
SD_Meeting_Tool_Base::array_sort_subarrays (   $array,
  $key 
)

Sort an array of arrays using a specific key in the subarray as the sort key.

Parameters
$arrayAn array of arrays.
$keyKey in subarray to use as sort key.
Returns
The array of arrays.
SD_Meeting_Tool_Base::array_to_object (   $array,
  $object = null 
)

Convert an array to stdClass, or appends the $array to an existing $object.

Parameters
$arrayArray to convert.
$objectExisting object, if any, to append data to.
Returns
Object with fields from the array.
SD_Meeting_Tool_Base::check_plain (   $text)
SD_Meeting_Tool_Base::deactivate ( )

Overridable method to deactive the plugin.

SD_Meeting_Tool_Base::deactivate_me ( )

Deactivates the plugin.

SD_Meeting_Tool_Base::delete_local_option (   $option)

Deletes a local option.

Parameters
$optionName of option to delete.
SD_Meeting_Tool_Base::delete_option (   $option)

Deletes a site option.

If this is a network, the site option is preferred.

Parameters
$optionName of option to delete.
SD_Meeting_Tool_Base::delete_site_option (   $option)

Deletes a site option.

Parameters
$optionName of option to delete.
SD_Meeting_Tool_Base::deregister_options ( )

Removes all the options this plugin uses.

SD_Meeting_Tool_Base::display_form_table (   $inputs,
  $options = array() 
)
SD_Meeting_Tool_Base::display_form_table_row (   $input,
  $form = null 
)
SD_Meeting_Tool_Base::display_message (   $type,
  $string 
)

Displays a message.

Autodetects HTML / text.

Parameters
$typeType of message: error, warning, whatever. Free content.
$stringThe message to display.
SD_Meeting_Tool_Base::download (   $filepath,
  $options = array() 
)

Output a file to the browser for downloading.

Parameters
$filePath to file on disk.
$nameDownloaded file's name.
$mime_typeOptional mime_type.
Author
http://w-shadow.com/blog/2007/08/12/how-to-force-file-download-with-php/

if ( isset($_SERVER['HTTP_RANGE']) ) { if ( ! function_exists( 'download_416' ) ) function download_416( $filesize ) { header('HTTP/1.1 416 Requested Range Not Satisfiable'); header('Content-Range: bytes *\/' . $o->filesize); // Required in 416. *\/ *\/ *\/ }

if (!preg_match('^bytes=*-*(,*-*)*$', $_SERVER['HTTP_RANGE'])) { { download_416( $o->filesize ); return; }

$ranges = explode(',', substr($_SERVER['HTTP_RANGE'], 6) ); foreach ( $ranges as $range ) { $parts = explode('-', $range); $start = $parts[0]; // If this is empty, this should be 0. $end = $parts[1]; // If this is empty or greater than than filelength - 1, this should be filelength - 1.

if ($start > $end) { download_416( $o->filesize ); return; } } } else

SD_Meeting_Tool_Base::error (   $string)

Displays an error message.

The only thing that makes it an error message is that the div has the class "error".

Parameters
$stringString to display.
SD_Meeting_Tool_Base::error_ (   $string,
  $args = '' 
)

Convenience function to translate and then create an error message from a string and optional sprintf arguments.

Parameters
$stringString to translate and create into an error message.
Returns
A translated error message.
SD_Meeting_Tool_Base::filters (   $filter_name)
SD_Meeting_Tool_Base::fix_option_name (   $option)

Normalizes the name of an option.

Will prepend the class name in front, to make the options easily findable in the table.

Parameters
$optionOption name to fix.
SD_Meeting_Tool_Base::form (   $options = array())

Creates a new SD_Form.

Parameters
$optionsDefault options to send to the SD form constructor.
Returns
A new SD form class.
SD_Meeting_Tool_Base::get_local_option (   $option,
  $default = false 
)

Gets the value of a local option.

Parameters
$optionName of option to get.
$defaultThe default value if the option === false
Returns
Value.
SD_Meeting_Tool_Base::get_option (   $option)

Get a site option.

If this is a network, the site option is preferred.

Parameters
$optionName of option to get.
Returns
Value.
SD_Meeting_Tool_Base::get_site_option (   $option,
  $default = false 
)

Gets the value of a site option.

Parameters
$optionName of option to get.
$defaultThe default value if the option === false
Returns
Value.
SD_Meeting_Tool_Base::get_user_role ( )

Returns the user's role as a string.

Returns
User's role as a string.
SD_Meeting_Tool_Base::hash (   $string,
  $type = 'sha512' 
)

Returns a hash value of a string. The standard hash type is sha512 (64 chars).

Parameters
$stringString to hash.
$typeHash to use. Default is sha512.
Returns
Hashed string.
SD_Meeting_Tool_Base::implode_html (   $prefix,
  $suffix,
  $array 
)

Implode an array in an HTML-friendly way.

Used to implode arrays using HTML tags before, between and after the array. Good for lists.

Parameters
$prefixli
$suffix/li
$arrayThe array of strings to implode.
Returns
The imploded string.
SD_Meeting_Tool_Base::load_language (   $domain = '')

Loads this plugin's language files.

Reads the language data from the class's name domain as default.

Parameters
$domainOptional domain.
SD_Meeting_Tool_Base::message (   $string)

Displays an informational message.

Parameters
$stringString to display.
SD_Meeting_Tool_Base::message_ (   $string,
  $args = '' 
)

Convenience function to translate and then create a message from a string and optional sprintf arguments.

Parameters
$stringString to translate and create into a message.
Returns
A translated message.
SD_Meeting_Tool_Base::mime_type (   $filename)
SD_Meeting_Tool_Base::minmax (   $number,
  $min,
  $max 
)

Returns the number corrected into the min and max values.

SD_Meeting_Tool_Base::now ( )

Returns WP's current timestamp (corrected for UTC)

Returns
Current timestamp in MYSQL datetime format.
SD_Meeting_Tool_Base::object_to_array (   $object)

Convert an object to an array.

Parameters
$objectObject or array of objects to convert to a simple array.
Returns
Array.
SD_Meeting_Tool_Base::p (   $string,
  $args = '' 
)

wpautop's a string, using sprintf to replace arguments.

Parameters
$stringString to wpautop.
$argsOptional arguments to sprintf.
Returns
The wpautop'd sprintf string.
SD_Meeting_Tool_Base::p_ (   $string,
  $args = '' 
)

wpautop's a translated string, using sprintf to replace arguments.

Parameters
$stringString to translate and then wpautop.
$argsOptional arguments to _() / sprintf.
Returns
The wpautop'd, translated string.
SD_Meeting_Tool_Base::query (   $query,
  $wpdb = null 
)

Sends a query to wpdb and return the results.

Parameters
$queryThe SQL query.
$wpdbAn optional, other WPDB if the standard $wpdb isn't good enough for you.
Returns
array The rows from the query.
SD_Meeting_Tool_Base::query_insert_id (   $query)

Fire an SQL query and return the row ID of the inserted row.

Parameters
$queryThe SQL query.
Returns
The inserted ID.
SD_Meeting_Tool_Base::query_single (   $query)

Fire an SQL query and return the results only if there is one row result.

Parameters
$queryThe SQL query.
Returns
Either the row as an array, or false if more than one row.
SD_Meeting_Tool_Base::register_options ( )

Registers all the options this plugin uses.

SD_Meeting_Tool_Base::rmdir (   $directory)

Recursively removes a directory.

Assumes that all files in the directory, and the dir itself, are writeable.

Parameters
$directoryDirectory to remove.
SD_Meeting_Tool_Base::role_at_least (   $role)

Checks whether the user's role is at least $role.

Parameters
$roleRole as string.
Returns
True if role is at least $role.
SD_Meeting_Tool_Base::roles_as_options ( )

Returns the user roles as a select options array.

Returns
The user roles as a select options array.
SD_Meeting_Tool_Base::send_mail (   $mail_data)

Sends mail via SMTP.

Parameters
$mail_dataMail data.
SD_Meeting_Tool_Base::slug (   $string)

Sanitizes a string.

Parameters
$stringString to sanitize.
SD_Meeting_Tool_Base::sql_decode (   $string)

Converts a base64 encoded, serialized string back into an object.

Parameters
$stringSerialized, base64-encoded string.
Returns
Object, if possible.
SD_Meeting_Tool_Base::sql_encode (   $object)

Converts an object to a base64 encoded, serialized string, ready to be inserted into sql.

Parameters
$objectAn object.
Returns
Serialized, base64-encoded string.
SD_Meeting_Tool_Base::sql_table_exists (   $table_name)

Returns whether a table exists.

Parameters
$table_nameTable name to check for.
Returns
True if the table exists.
SD_Meeting_Tool_Base::strip_post_slashes (   $post = null)
SD_Meeting_Tool_Base::strtolower (   $string)

Multibyte strtolower.

Parameters
$stringString to lowercase.
Returns
Lowercased string.
SD_Meeting_Tool_Base::strtoupper (   $string)

Multibyte strtoupper.

Parameters
$stringString to uppercase.
Returns
Uppercased string.
SD_Meeting_Tool_Base::tab_slug (   $string)

Sanitizes the name of a tab.

Parameters
$stringString to sanitize.
SD_Meeting_Tool_Base::tabs (   $options)

Displays Wordpress tabs.

Parameters
$optionsSee options.
SD_Meeting_Tool_Base::time ( )

Returns the current time(), corrected for UTC and DST.

Returns
int Current, corrected timestamp.
SD_Meeting_Tool_Base::uninstall ( )
SD_Meeting_Tool_Base::update_local_option (   $option,
  $value 
)

Updates a local option.

Parameters
optionName of option to update.
$valueNew value
SD_Meeting_Tool_Base::update_option (   $option,
  $value 
)

Updates a site option.

If this is a network, the site option is preferred.

Parameters
$optionName of option to update.
$valueNew value
SD_Meeting_Tool_Base::update_site_option (   $option,
  $value 
)

Updates a site option.

Parameters
$optionName of option to update.
$valueNew value
SD_Meeting_Tool_Base::user_id ( )

Return the user_id of the current user.

Returns
int The user's ID.
SD_Meeting_Tool_Base::wrap (   $title,
  $text 
)

Outputs the text in Wordpress admin's panel format.

Parameters
$titleH2 title to display.
$textText to display.
Returns
HTML wrapped HTML.

Member Data Documentation

SD_Meeting_Tool_Base::$is_network
protected

Stores whether this blog is a network blog.

SD_Meeting_Tool_Base::$language_domain = ''
protected

Text domain of .PO translation.

If left unset will be set to the base filename minus the .php

SD_Meeting_Tool_Base::$local_options = array()
protected

Array of options => default_values that this plugin stores locally.

SD_Meeting_Tool_Base::$options = array()
protected

Array of options => default_values that this plugin stores locally or globally.

Deprecated:
SD_Meeting_Tool_Base::$paths = array()

Contains the paths to the plugin and other places of interest.

The keys in the array are:

name
filename
filename_from_plugin_directory
path_from_plugin_directory
path_from_base_directory
url

SD_Meeting_Tool_Base::$roles
protected
Initial value:
array(
'administrator' => array(
'name' => 'administrator',
'current_user_can' => 'manage_options',
),
'editor' => array(
'name' => 'editor',
'current_user_can' => 'manage_links',
),
'author' => array(
'name' => 'author',
'current_user_can' => 'publish_posts',
),
'contributor' => array(
'name' => 'contributor',
'current_user_can' => 'edit_posts',
),
'subscriber' => array(
'name' => 'subscriber',
'current_user_can' => 'read',
),
)

The list of the standard user roles in Wordpress.

First an array of role_name => array

And then each role is an array of name => role_name and current_user_can => capability.

SD_Meeting_Tool_Base::$site_options = array()
protected

Array of options => default_values that this plugin stores sitewide.

SD_Meeting_Tool_Base::$wpdb
protected

Links to Wordpress' database object.


The documentation for this class was generated from the following file: