+////////// just return a truncated text
+function truncate ($text,$numb,$etc = "...") {
+ if (strlen($text) <= $numb) return $text;
+ return substr($text, 0, $numb).$etc;
+}
+// ditto but in case the text is too lare, returns a <span> with its 'title' set to the full value
+function truncate_and_popup ($text,$numb,$etc = "...") {
+ if (strlen($text) <= $numb) return $text;
+ $display=substr($text, 0, $numb).$etc;
+ return sprintf("<span title='%s'>%s</span>",$text,$display);
+}
+
+// generates <(atom) class=(class)> (text) </(atom)>
+function html_atom ($atom,$text,$class="") {
+ $html="<$atom";
+ if ($class) $html .= " class='$class'";
+ $html .= ">$text</$atom>";
+ return $html;
+}
+function html_div ($text,$class="") { return html_atom ('div',$text,$class); }
+function html_span ($text,$class="") { return html_atom ('span',$text,$class); }
+
+// should use the same channel as the php errors..
+function plc_error_html ($text) { return html_div ($text,'plc-error'); }
+function plc_error ($text) { print plc_error_html ("Error " . $text); }
+
+function errors_init() { return array();}
+function errors_record ($adm, $errors) {
+ if ($adm->error()) {
+ $tmp=$adm->error();
+ $errors []= $tmp;
+ }
+ return $errors;
+}
+
+function errors_display ($errors) {
+ if ($errors) {
+ print( "<div class='plc-error'>" );
+ print( "<p>The following errors occured:</p>" );
+ print("<ul>");
+ foreach( $errors as $error )
+ print( "<li>$error</li>\n" );
+ print( "</ul></div>\n" );
+ }
+}
+
+function plc_warning_html ($text) { return html_span($text,'plc-warning'); }
+function plc_warning ($text) { print plc_warning_html("Warning " . $text); }
+
+function bold_html ($text) { return html_span($text,'bold'); }
+
+// shows a php variable verbatim with a heading message
+function plc_debug ($message,$object) {
+ print "<br />" . $message . "<pre>";
+ print_r ($object);
+ print "</pre>";
+}
+
+function plc_debug_txt ($message,$txt) {
+ print "<br />" . $message . "<pre>";
+ $txt=str_replace(" ","<SPC>",$txt);
+ $txt=str_replace("\t","<TAB>",$txt);
+ $txt=str_replace("\n","<LF>",$txt);
+ $txt=str_replace("\r","<CR>",$txt);
+ print $txt . "<EOF>";
+ print "</pre>";
+}
+
+$plc_prof_start=0.;
+$plc_prof_time=0.;
+$plc_prof_counter=0;
+function plc_debug_prof_start () {
+ global $plc_prof_counter, $plc_prof_start, $plc_prof_time;
+ $plc_prof_counter=0;
+ plc_debug(strftime("[0] %T (start)") ,"heating up");
+ $plc_prof_time=microtime(true);
+ $plc_prof_start=$plc_prof_time;
+}
+function plc_debug_prof ($message,$object) {
+ global $plc_prof_counter, $plc_prof_start, $plc_prof_time;
+ $plc_prof_counter+=1;
+ $now=microtime(true);
+ $timelabel=strftime("%T");
+ $prof_message=sprintf("[%d] %s (%2.3f s -- %2.3f s) ",$plc_prof_counter,$timelabel,
+ ($now-$plc_prof_time),($now-$plc_prof_start));
+ plc_debug($prof_message.$message,$object);
+ $plc_prof_time=$now;
+}
+function plc_debug_prof_end () {
+ plc_debug_prof ("end","cooling down");
+}
+
+if (! function_exists ("drupal_set_error")) {
+ function drupal_set_error ($text) {
+ drupal_set_message ("<span class=error>$text</span>");
+ }
+ }
+
+//////////////////////////////////////////////////////////// sort out for obsolete / trash