/
dependencies.php
105 lines (91 loc) · 2.45 KB
/
dependencies.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
/**
* @package EasySocial
* @copyright Copyright (C) 2010 - 2014 Stack Ideas Sdn Bhd. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* EasySocial is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
defined( '_JEXEC' ) or die( 'Unauthorized Access' );
// This is required if anyone needs access to the engine.
require_once( JPATH_ROOT . '/administrator/components/com_easysocial/constants.php' );
// This is required if anyone needs access to the engine.
require_once( JPATH_ROOT . '/administrator/components/com_easysocial/tables/table.php' );
// Exception library
require_once( SOCIAL_LIB . '/exception/exception.php' );
// We need our own routing library
require_once( SOCIAL_LIB . '/router.php' );
jimport( 'joomla.filesystem.file' );
if( !function_exists( 'dump' ) )
{
function dump()
{
$args = func_get_args();
echo '<pre>';
foreach( $args as $arg )
{
var_dump( $arg );
}
echo '</pre>';
exit;
}
}
// @Copyright message
define( 'SOCIAL_SCRIPT_CODE' , '<div class="center mt-20"><a href="http://stackideas.com/easysocial">Joomla Social Network</a> powered by EasySocial</div>');
/**
* Reusable classes
*/
class SocialObject
{
/**
* Given an array of items, map it against the object properties.
*
* @access public
* @param Array A list of items in an associative array.
* @return null
*/
public function map( $items )
{
// @task: Process arrays
if( is_array( $items ) )
{
foreach( $items as $itemKey => $itemValue )
{
if( isset( $this->$itemKey ) )
{
$this->$itemKey = $itemValue;
}
}
}
// @task: If this is a stdclass object.
if( is_object( $items ) )
{
$properties = get_object_vars( $items );
foreach( $properties as $property )
{
if( isset( $this->$property ) )
{
$this->$property = $items->$property;
}
}
}
}
/**
* Returns a property value from the object.
*
* @access public
* @param string $key The key property.
* @param string $default The default value if the property is empty.
*/
public function get( $key , $default = '' )
{
if( !isset( $this->$key ) || empty( $this->$key ) || is_null( $this->$key ) )
{
return $default;
}
return $this->$key;
}
}