Documentation is available at misc.php
- <?php
- /**
- * Useful ancillary functions, not helpdesk-specific
- * Copyright OSI 2005. All rights reserved.
- * It is expected that version 1.0 will be GPLed, but this interim work
- * is kept closed until 1.0 is ready.
- *
- * @package helpdesk
- * @version $Id
- * 20050920
- * - Added _helpdesk_notempty()
- */
- define('HELPDESKUNIMPLEMENTED', t('To be implemented')) ;
- /**
- * Returns the type of a node, because Drupal uses two
- * conventions for this: either node passed as its type or as an object
- * @param mixed $node The node
- * @return string The node type
- */
- function _helpdesk_node_type ($node)
- {
- return is_string ($node) ? $node : $node->type ;
- }
- /**
- * A safer way of accessing a node's properties
- *
- * @param mixed $node
- * @param string $prop
- * @return string
- */
- function _helpdesk_get_node_property ($node, $prop)
- {
- if (!isset($node))
- $ret = '(node not set)' ;
- elseif (is_object($node))
- $ret = isset($node->$prop) ? $node->$prop : '(property not set)' ;
- elseif (is_array($node))
- $ret = array_key_exists($prop, $node) ? $node[$prop] : '(array key not found)' ;
- else
- $ret = $node ;
- return $ret ;
- }
- /**
- * Returns a non empty string for anything passed to it.
- *
- * @param mixed $var The var to be displayed.
- * @param string $default Value to be returned if variable is empty or non scalar
- * @param bool $debug Provides detailed output for non-scalar types instead of defaulting
- * @return string HTML code
- */
- function _helpdesk_notempty ($var, $default = ' ', $debug = FALSE)
- {
- if (!isset($var))
- return $default ;
- if (is_scalar($var))
- return ($var <> '') ? $var : $default ;
- if (is_resource($var))
- return $debug
- ? get_resource_type($var)
- : $default ;
- if (is_object($var))
- {
- if ($debug)
- {
- $ret = ' ';
- print_r ($var, $ret) ;
- $ret = "<pre>$ret</pre>" ;
- }
- else
- $ret = $default ;
- return $ret ;
- }
- if (is_array($var))
- {
- if ($debug)
- {
- $ret = '' ;
- print_r ($var, $ret) ;
- $ret = "<pre>$ret</pre>" ;
- }
- else
- $ret = $default ;
- return $ret ;
- }
- // No other type is supposed to exist
- return "Error in _helpdesk_notempty(): variable of unknown type '" . gettype($var) . "' passed. Cannot process." ;
- }
- ?>
Documentation generated on Tue, 01 Nov 2005 23:15:03 +0100 by phpDocumentor 1.3.0RC3