4 /** Set the display object method for a given module.
5 * @param $module A string containing the module name - eg "file"
6 * @param $function The name of your function matching the prototype $name($object_id, $object_type, $view) where $object_type is the description of the object eg "file::file".
8 function display_set_display_function($module, $function)
12 if (!isset($CFG->displayobjectfunctions
))
13 $CFG->displayobjectfunctions
= array();
15 $CFG->displayobjectfunctions
[$module] = $function;
18 /** Call a function's display object code and returns its html
19 * @param $module The module name eg 'file'
20 * @param $object_id The id of the object
21 * @param $object_type The type of the object - eg 'file::file' - largely ignored.
22 * @param $view Do we want to display a full view or a limited view - 'full' or 'summary'?
24 function display_run_displayobject($module, $object_id, $object_type, $view = 'full')
29 if (isset($CFG->displayobjectfunctions
[$module]))
31 $function = $CFG->displayobjectfunctions
[$module];
32 if (is_callable($function))
34 $result = $function($object_id, $object_type, $view);
41 /** Add a hook for displaying annotations for an object.
42 * @param $object_type The type of object you're registering the hook for
43 * @param $function The function to register it to
45 function display_set_display_annotation_function($object_type, $function)
49 if (!isset($CFG->displayobjectannotationfunctions
))
50 $CFG->displayobjectannotationfunctions
= array();
52 $CFG->displayobjectannotationfunctions
[$object_type][] = $function;
55 /** Display the annotations for a specific object type.
56 * @param $object The id of the object
57 * @param $object_type The type of the object - eg 'file::file' - largely ignored.
58 * @param $view Do we want to display a full view or a limited view - 'full' or 'summary'?
60 function display_run_displayobjectannotations($object, $object_type, $view = 'full')
65 if (isset($CFG->displayobjectannotationfunctions
[$object_type]))
67 foreach ($CFG->displayobjectannotationfunctions
[$object_type] as $function)
69 if (is_callable($function))
71 $result .= $function($object, $object_type, $view);
79 // Function to sanitise RTF edit text
80 /* function RTESafe($strText) {
81 //returns safe code for preloading in the RTE
82 $tmpString = trim($strText);
84 //convert all types of single quotes
85 $tmpString = str_replace(chr(145), chr(39), $tmpString);
86 $tmpString = str_replace(chr(146), chr(39), $tmpString);
87 $tmpString = str_replace("'", "'", $tmpString);
89 //convert all types of double quotes
90 $tmpString = str_replace(chr(147), chr(34), $tmpString);
91 $tmpString = str_replace(chr(148), chr(34), $tmpString);
93 //replace carriage returns & line feeds
94 $tmpString = str_replace(chr(10), " ", $tmpString);
95 $tmpString = str_replace(chr(13), " ", $tmpString);
100 function display_input_field ($parameter) {
101 // Displays different HTML depending on input field type
107 0 => input name to display (for forms etc)
109 2 => type of input field
110 3 => reference name (for tag fields and so on)
111 4 => ID number (if any)
121 if (isset($parameter) && sizeof($parameter) > 2) {
123 if (!isset($parameter[4])) {
127 if (!isset($parameter[5])) {
128 $parameter[5] = $_SESSION['userid'];
131 $cleanid = $parameter[0];
132 if (!ereg("^[A-Za-z][A-Za-z0-9_:\\.-]*$", $cleanid)) {
133 if (!ereg("^[A-Za-z]", $cleanid)) {
134 $cleanid = "id_" . $cleanid;
136 $cleanid = ereg_replace("[^A-Za-z0-9_:\\.-]", "__", $cleanid);
139 switch($parameter[2]) {
142 $run_result .= "<input type=\"text\" name=\"".$parameter[0]."\" value=\"".htmlspecialchars(stripslashes($parameter[1]), ENT_COMPAT
, 'utf-8')."\" style=\"width: 95%\" id=\"".$cleanid."\" />";
145 $run_result .= "<input type=\"password\" name=\"".$parameter[0]."\" value=\"".htmlspecialchars(stripslashes($parameter[1]), ENT_COMPAT
, 'utf-8')."\" style=\"width: 95%\" id=\"".$cleanid."\" />";
148 $run_result .= "<textarea name=\"".$parameter[0]."\" id=\"".$cleanid."\" style=\"width: 95%; height: 100px\">".htmlspecialchars(stripslashes($parameter[1]), ENT_COMPAT
, 'utf-8')."</textarea>";
152 $keywords = stripslashes($parameter[1]);
153 preg_match_all("/\[\[([A-Za-z0-9 ]+)\]\]/i",$keywords,$keyword_list);
154 $keyword_list = $keyword_list[1];
156 if (is_array($keyword_list) && sizeof($keyword_list) > 0) {
158 foreach($keyword_list as $key => $list_item) {
159 $keywords .= $list_item;
160 if ($key < sizeof($keyword_list) - 1) {
165 $parameter[1] = $keywords;
167 if (!isset($data['profile:preload'][$parameter[3]])) {
169 if ($tags = get_records_select('tags',"tagtype = ? and ref = ? and owner = ?",array($parameter[3],$parameter[4],$parameter[5]),'tag ASC')) {
171 foreach($tags as $key => $tag) {
175 $keywords .= stripslashes($tag->tag
);
179 $parameter[1] = $keywords;
181 // $parameter[1] = $data['profile:preload'][$parameter[3]];
183 // $parameter[1] = var_export($parameter,true);
184 $run_result .= "<textarea name=\"".$parameter[0]."\" id=\"".$cleanid."\" style=\"width: 95%; height: 100px\">".htmlspecialchars(stripslashes($parameter[1]), ENT_COMPAT
, 'utf-8')."</textarea>";
187 $run_result .= "<textarea name=\"".$parameter[0]."\" id=\"".$cleanid."\" style=\"width: 95%; height: 200px\">".htmlspecialchars(stripslashes($parameter[1]), ENT_COMPAT
, 'utf-8')."</textarea>";
191 $run_result .= <<< END
192 <script language
="JavaScript" type
="text/javascript">
194 function submitForm() {
195 //make sure hidden and iframe values are in sync before submitting form
196 //to sync only 1 rte, use updateRTE(rte)
197 //to sync all rtes, use updateRTEs
198 updateRTE('<?php echo $parameter[0]; ?>');
200 //alert("rte1 = " + document.elggform.<?php echo $parameter[0]; ?>.value);
202 //change the following line to true to submit form
206 $content = RTESafe(stripslashes($parameter[1]));
207 $run_result .= <<< END
208 //Usage: initRTE(imagesPath, includesPath, cssFile)
209 initRTE("/units/display/rtfedit/images/", "/units/display/rtfedit/", "/units/display/rtfedit/rte.css");
211 <noscript
><p
><b
>Javascript must be enabled to
use this form
.</b
></p
></noscript
>
212 <script language
="JavaScript" type
="text/javascript">
214 writeRichText('<?php echo $parameter[0];?>', '<?php echo $content; ?>', 220, 200, true, false);
220 $run_result .= "<input type=\"hidden\" name=\"".$parameter[0]."\" value=\"blank\" id=\"".$cleanid."\" />";
228 $run_result .= "<input type=\"text\" name=\"".$parameter[0]."\" value=\"".htmlspecialchars(stripslashes($parameter[1]), ENT_COMPAT
, 'utf-8')."\" style=\"width: 95%\" id=\"".$cleanid."\" />";
231 $run_result .= "<textarea name=\"".$parameter[0]."\" id=\"".$parameter[0]."\" style=\"width: 95%; height: 200px\">".htmlspecialchars(stripslashes($parameter[1]), ENT_COMPAT
, 'utf-8')."</textarea>";
234 if (isset($CFG->display_field_module
[$parameter[2]])) {
235 $callback = $CFG->display_field_module
[$parameter[2]] . "_display_input_field";
236 if (is_callable($callback)) {
237 $run_result .= $callback($parameter);
248 function log_on_pane () {
251 // Elgg default globals
263 // If this is someone else's portfolio, display the user's icon
264 if ($page_owner != -1) {
265 $run_result .= run("profile:user:info");
268 if ((!defined("logged_on") || logged_on
== 0) && $page_owner == -1) {
270 $body = '<form action="'.url
.'login/index.php" method="post">';
272 if ($CFG->publicreg
== true && ($CFG->maxusers
== 0 ||
(count_users('person') < $CFG->maxusers
))) {
273 $reg_link = '<a href="' . url
. 'mod/invite/register.php">'. __gettext("Register") .'</a> |';
278 $body .= templates_draw(array(
280 'context' => 'contentholder',
281 'title' => __gettext("Log On"),
286 <td align="right"><p>
287 <label>' . __gettext("Username") . ' <input type="text" name="username" id="username" style="size: 200px" /></label><br />
288 <label>' . __gettext("Password") . ' <input type="password" name="password" id="password" style="size: 200px" />
293 <td align="right"><p>
294 <input type="hidden" name="action" value="log_on" />
295 <label>' . __gettext("Log on") . ':<input type="submit" name="submit" value="'.__gettext("Go").'" /></label><br /><br />
296 <label><input type="checkbox" name="remember" checked="checked" />
297 ' . __gettext("Remember Login") . '</label><br />
300 <a href="' . url
. 'mod/invite/forgotten_password.php">'. __gettext("Forgotten password") .'</a>
312 $run_result .= $body;
319 function display_output_field ($parameter) {
320 // Displays different HTML depending on input field type
326 0 => input name to display (for forms etc)
328 2 => type of input field
329 3 => reference name (for tag fields and so on)
330 4 => ID number (if any)
331 5 => Owner (if not specified, current $page_owner is assumed)
343 if (isset($parameter) && sizeof($parameter) > 1) {
345 if (!isset($parameter[4])) {
348 if (!isset($parameter[5])) {
349 if (isset($page_owner)) {
350 $parameter[5] = $page_owner;
356 switch($parameter[1]) {
359 $run_result = "<img src=\"http://web.icq.com/whitepages/online?icq=".htmlspecialchars(stripslashes($parameter[0]), ENT_COMPAT
, 'utf-8')."&img=5\" height=\"18\" width=\"18\" /> <b>".htmlspecialchars(stripslashes($parameter[0]), ENT_COMPAT
, 'utf-8')."</b> (<a href=\"http://wwp.icq.com/scripts/search.dll?to=".htmlspecialchars(stripslashes($parameter[0]), ENT_COMPAT
, 'utf-8')."\">" . __gettext("Add User") . "</a>, <a href=\"http://wwp.icq.com/scripts/contact.dll?msgto=".htmlspecialchars(stripslashes($parameter[0]), ENT_COMPAT
, 'utf-8')."\">". __gettext("Send Message") ."</a>)";
362 $run_result = "<a href=\"callto://".htmlspecialchars(stripslashes($parameter[0]), ENT_COMPAT
, 'utf-8')."\">".htmlspecialchars(stripslashes($parameter[0]), ENT_COMPAT
, 'utf-8')."</a> <img src=\"http://goodies.skype.com/graphics/skypeme_btn_small_white.gif\" alt=\"Skype Me!\" border=\"0\" />";
365 $run_result = "MSN <b>".htmlspecialchars(stripslashes($parameter[0]), ENT_COMPAT
, 'utf-8')."</b>";
368 $run_result = "<img src=\"http://big.oscar.aol.com/".htmlspecialchars(stripslashes($parameter[0]), ENT_COMPAT
, 'utf-8')."?on_url=http://www.aol.com/aim/gr/online.gif&off_url=http://www.aol.com/aim/gr/offline.gif\" width=\"14\" height=\"17\" /> <b>".htmlspecialchars(stripslashes($parameter[0]), ENT_COMPAT
, 'utf-8')."</b> (<a href=\"aim:addbuddy?screenname=".htmlspecialchars(stripslashes($parameter[0]), ENT_COMPAT
, 'utf-8')."\">". __gettext("Add Buddy") ."</a>, <a href=\"aim:goim?screenname=".htmlspecialchars(stripslashes($parameter[0]), ENT_COMPAT
, 'utf-8')."&message=Hello\">". __gettext("Send Message") ."</a>)";
373 $run_result = nl2br(stripslashes($parameter[0]));
377 $keywords = stripslashes($parameter[0]);
378 preg_match_all("/\[\[([A-Za-z0-9 ]+)\]\]/i",$keywords,$keyword_list);
379 $keyword_list = $keyword_list[1];
381 if (is_array($keyword_list) && sizeof($keyword_list) > 0) {
383 $where = run("users:access_level_sql_where",$_SESSION['userid']);
384 foreach($keyword_list as $key => $list_item) {
385 $number = count_records_select('profile_data',"($where) and name = '".$parameter[2]."' and value like \"%[[".$list_item."]]%\"");
387 $keywords .= "<a href=\"/profile/search.php?".$parameter[2]."=".$list_item."\" title=\"$number users\">";
389 $keywords .= $list_item;
393 if ($key < sizeof($keyword_list) - 1) {
398 $run_result = $keywords;
400 $where = run("users:access_level_sql_where",$_SESSION['userid']);
402 if ($tags = get_records_select('tags',"($where) AND tagtype = " . $db->qstr($parameter[2]) . " AND ref = ".$parameter[4],null,'tag ASC')) {
404 foreach($tags as $tag) {
408 $numberoftags = count_records('tags','tag',$tag->tag
);
409 if ($numberoftags > 1) {
410 $keywords .= "<a href=\"".url
."search/index.php?".$parameter[2]."=".urlencode(stripslashes($tag->tag
))."&ref=".$parameter[4]."&owner=".$parameter[5]."\" >";
412 $keywords .= htmlspecialchars(stripslashes($tag->tag
), ENT_COMPAT
, 'utf-8');
413 if ($numberoftags > 1) {
419 $run_result = $keywords;
422 $run_result = preg_replace("/[\\d\\w\\.\\-_]+@([\\d\\w\\-_\\.]+\\.)+([\\w]{2,6})/i","<a href=\"mailto:$0\">$0</a>",$parameter[0]);
425 $run_result = $parameter[0];
426 if (substr_count($run_result,"http://") == 0) {
427 $run_result = "http://" . $run_result;
429 $run_result = "<a href=\"" . $run_result . "\" target=\"_blank\">" . $run_result . "</a>";
432 if (isset($CFG->display_field_module
[$parameter[1]])) {
433 $callback = $CFG->display_field_module
[$parameter[1]] . "_display_output_field";
434 if (is_callable($callback)) {
435 $run_result = $callback($parameter);
444 function displaymenu_top () {
448 if (logged_on
== 1) {
450 return templates_draw(array(
451 'context' => 'topmenu',
452 'menuitems' => menu_join('', $PAGE->menu_top
)
462 function displaymenu () {
466 return templates_draw(array(
468 'menuitems' => menu_join('', $PAGE->menu
)
475 function displaymenu_sub () {
479 if (logged_on
== 1) {
481 return templates_draw(array(
482 'context' => 'submenu',
483 'menuitems' => menu_join('', $PAGE->menu_sub
)
492 function displaymenu_user () {
494 if (logged_on
== 1) {
496 return templates_draw(array(
498 'menuitems' => menu_join('', $PAGE->menu_user
)
510 // Elgg default globals
520 $function['display:log_on_pane'][] = path
. "units/display/function_log_on_pane.php";
521 $function['display:sidebar'][] = path
. "units/display/function_log_on_pane.php";
524 $function['display:input_field'][] = path
. "units/display/function_input_field_display.php";
525 $function['display:output_field'][] = path
. "units/display/function_output_field_display.php";