forked from Deesen/YAMS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyams.extender.inc.php
203 lines (179 loc) · 4.49 KB
/
yams.extender.inc.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<?php
/**
* A Ditto extendender for use with YAMS
*
* @author PMS (http://modxcms.com/forums/index.php?action=profile;u=12570)
* @copyright Nashi Power (http://nashi.podzone.org/) 2009
* @license GPL v3
* @package YAMS (http://modxcms.com/extras/package/?package=543)
* @see Forum (http://modxcms.com/forums/index.php/board,381.0.html)
*
*/
// require_once( dirname( __FILE__ ) . '/class/yams.class.inc.php' );
// ---------------------------------------------------
// Group: Placeholders
// Define the values of custom placeholders for access in the tpl like so [+phname+]
// ---------------------------------------------------
// Variable: $placeholders['example']
// Add the placeholder example to the custom placeholders list
// with the source pagetitle in both display and backend using the
// exampleFunction callback and pagetitle as the field for QuickEdit.
// If you only needed the placeholder in the frontent you would just
// use "pagetitle" as the first value of the array. If the callback
// was in a class use the array($initialized_class,"member") method.
$placeholders['title'] = array(
array( '*' )
, 'yamsChooseLangPageTitle'
);
$placeholders['pagetitle'] = array(
array( '*' )
, 'yamsChooseLangPageTitle'
);
$placeholders['longtitle'] = array(
array( '*' )
, 'yamsChooseLangLongTitle'
);
$placeholders['description'] = array(
array( '*' )
, 'yamsChooseLangDescription'
);
$placeholders['introtext'] = array(
array( '*' )
, 'yamsChooseLangIntroText'
);
$placeholders['menutitle'] = array(
array( '*' )
, 'yamsChooseLangMenuTitle'
);
$placeholders['content'] = array(
array( '*' )
, 'yamsChooseLangContent'
);
$GLOBALS['ditto_object'] = $ditto;
if ( ! function_exists( 'yamsChooseLangPageTitle' ) )
{
function yamsChooseLangPageTitle( $resource )
{
global $ditto_object;
$yams = YAMS::GetInstance();
if ( ! $yams->IsMultilingualDocument(
$resource['id']
// , $resource['template']
) )
{
return $resource['pagetitle'];
}
$output = $yams->MultiLangExpand(
'data'
, 'pagetitle'
, $resource['id']
);
return $output;
}
}
if ( ! function_exists( 'yamsChooseLangLongTitle' ) )
{
function yamsChooseLangLongTitle( $resource )
{
global $ditto_object;
$yams = YAMS::GetInstance();
if ( ! $yams->IsMultilingualDocument(
$resource['id']
// , $resource['template']
) )
{
return $resource['longtitle'];
}
$output = $yams->MultiLangExpand(
'data'
, 'longtitle'
, $resource['id']
);
return $output;
}
}
if ( ! function_exists( 'yamsChooseLangDescription' ) )
{
function yamsChooseLangDescription( $resource )
{
global $ditto_object;
$yams = YAMS::GetInstance();
if ( ! $yams->IsMultilingualDocument(
$resource['id']
// , $resource['template']
) )
{
return $resource['description'];
}
$output = $yams->MultiLangExpand(
'data'
, 'description'
, $resource['id']
);
return $output;
}
}
if ( ! function_exists( 'yamsChooseLangIntroText' ) )
{
function yamsChooseLangIntroText( $resource )
{
global $ditto_object;
$yams = YAMS::GetInstance();
if ( ! $yams->IsMultilingualDocument(
$resource['id']
// , $resource['template']
) )
{
return $resource['introtext'];
}
$output = $yams->MultiLangExpand(
'data'
, 'introtext'
, $resource['id']
);
return $output;
}
}
if ( ! function_exists( 'yamsChooseLangMenuTitle' ) )
{
function yamsChooseLangMenuTitle( $resource )
{
global $ditto_object;
$yams = YAMS::GetInstance();
if ( ! $yams->IsMultilingualDocument(
$resource['id']
// , $resource['template']
) )
{
return $resource['menutitle'];
}
$output = $yams->MultiLangExpand(
'data'
, 'menutitle'
, $resource['id']
);
return $output;
}
}
if ( ! function_exists( 'yamsChooseLangContent' ) )
{
function yamsChooseLangContent( $resource )
{
global $ditto_object;
$yams = YAMS::GetInstance();
if ( ! $yams->IsMultilingualDocument(
$resource['id']
// , $resource['template']
) )
{
return $resource['content'];
}
$output = $yams->MultiLangExpand(
'data'
, 'content'
, $resource['id']
);
return $output;
}
}
?>