source: branches/1.2/workflow/inc/nano/NanoUtil.class.php @ 1349

Revision 1349, 3.0 KB checked in by niltonneto, 15 years ago (diff)

Ticket #561 - Inclusão do módulo Workflow faltante nessa versão.

  • Property svn:executable set to *
Line 
1<?php
2
3/**
4 * NanoUtil class provides nice methods often used functionality
5 *
6 * @package NanoAjax
7 *
8 */
9class NanoUtil
10{
11    /**
12     * Enter description here...
13     *
14     * @param string $string
15     * @return boolean
16     */
17    static public function isNotEmptyString( $string = '' )
18    {
19        return ( is_string($string) && '' != $string );
20    }
21
22    /**
23     * Enter description here...
24     *
25     * @param array $array
26     * @return boolean
27     */
28    static public function isNotEmptyArray( $array = array() )
29    {
30        return ( is_array($array) && count($array) > 0 );
31    }
32
33    /**
34     * Enter description here...
35     *
36     * @param array $array
37     * @param mixed $key
38     * @param string $default
39     * @return mixed
40     */
41    static public function getParam( $array, $key, $default = '' )
42    {
43        return ( ( is_array($array) && isset($key) && array_key_exists($key,$array) )
44                       ? $array[$key]
45                       : $default );
46    }
47
48    /**
49     * Enter description here...
50     *
51     * @param array $array
52     * @param unknown_type $key
53     * @param unknown_type $fallback_array
54     * @param unknown_type $fallback_key
55     * @param unknown_type $default
56     * @return unknown
57     */
58    static public function getParamFallback( $array, $key, $fallback_array, $fallback_key, $default = '' )
59    {
60        return ( '' != self::getParam( $array         , $key         , $default ) )
61                     ? self::getParam( $array         , $key         , $default )
62                     : self::getParam( $fallback_array, $fallback_key, $default );
63    }
64
65    /**
66     * Enter description here...
67     *
68     * @param unknown_type $object
69     * @param unknown_type $property
70     * @param unknown_type $key
71     * @param unknown_type $default
72     * @return unknown
73     */
74    static public function getProp( $object, $property, $key, $default = '' )
75    {
76        return ( ( is_object($object)
77                   &&
78                   isset($object->$property)
79                   &&
80                   !empty($key)
81                   &&
82                   is_array($object->$property)
83                   &&
84                   isset($object->{$property}[$key]) )
85                      ? $object->{$property}[$key]
86                      : $default );
87    }
88
89    /**
90     * Enter description here...
91     *
92     * @return unknown
93     */
94    static public function getThisScript()
95    {
96        return self::getRawFilename( $_SERVER['SCRIPT_NAME'] );
97    }
98
99    /**
100     * Enter description here...
101     *
102     * @return unknown
103     */
104    static public function getCurrentScriptWithPath()
105    {
106        return $_SERVER['SCRIPT_NAME'];
107    }
108
109    /**
110     * Enter description here...
111     *
112     * @return unknown
113     */
114    static public function getFullUri()
115    {
116        $protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')
117                        ? "https://"
118                        : "http://";
119
120        return $protocol.$_SERVER['HTTP_HOST'].self::getCurrentScriptWithPath();
121    }
122}
123
124?>
Note: See TracBrowser for help on using the repository browser.