-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunction_extra.php
114 lines (95 loc) · 2.64 KB
/
function_extra.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
106
107
108
109
110
111
112
113
114
<?php
// Additional fields.
function get_file_link($item) {
return market_dao_item_get_field('s_file_link', $item);
}
function get_version($item) {
return market_dao_item_get_field('s_file_version', $item);
}
function get_file($item) {
return market_dao_item_get_field('s_file_zip', $item);
}
function get_github_url($item) {
return market_dao_item_get_field('s_github_url', $item);
}
function get_downloads($item) {
return market_dao_item_get_field('i_downloads', $item);
}
function delete_file($item) {
return market_dao_item_delete_file($item);
}
function get_donation_link($user) {
return market_dao_user_get_field('s_donation_link', $user);
}
// Helpers.
function item_is_theme() {
$aCategories = Category::newInstance()->hierarchy( osc_item_category_id() );
$parentCategory = osc_get_category('id', $aCategory['fk_i_parent_id']);
if($aCategories[1]['s_name'] == "Themes" || osc_item_category() == "Themes") {
return true;
}
}
function item_default_image_url() {
if(item_is_theme()) {
$icon = "images/theme_noimage.jpg";
} else {
$icon = "images/plugin_noimage.jpg";
}
return osc_current_web_theme_url($icon);
}
function dev($user) {
if(osc_is_web_user_logged_in() && osc_users_enabled()) {
if(Session::newInstance()->_get('userCompany') != '') {
return (bool) Session::newInstance()->_get('userCompany');
} else {
$dev = User::newInstance()->findByPrimaryKey($user);
Session::newInstance()->_set('userCompany', $dev['b_company']);
return (bool) $dev['b_company'];
}
}
return false;
}
function item_version() {
return get_version(osc_item_id());
}
function download_url(){
$id = osc_item_id();
if(get_file_link($id) != '') {
return get_file_link($id);
} else {
return osc_base_url()."oc-content/uploads/".get_file(osc_item_id());
}
}
function user_total_plugins($user) {
if(!is_numeric($user)) {
return 0;
}
return MarketModel_CoreItem::newInstance()->countByCategoryUser(MARKET_PLUGINS_CATID, $user);
}
function user_total_themes($user) {
if(!is_numeric($user)) {
return 0;
}
return MarketModel_CoreItem::newInstance()->countByCategoryUser(MARKET_THEMES_CATID, $user);
}
function user_total_plugins_formatted($user) {
$count = user_total_plugins($user);
if($count === 0) {
return '<strong>No</strong> plugins';
} elseif($count === 1) {
return '<strong>1</strong> plugin';
} else {
return '<strong>'.$count.'</strong> plugins';
}
}
function user_total_themes_formatted($user) {
$count = user_total_themes($user);
if($count === 0) {
return '<strong>No</strong> themes';
} elseif($count === 1) {
return '<strong>1</strong> theme';
} else {
return '<strong>'.$count.'</strong> themes';
}
}
?>