00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00031 class book_list extends WebObject
00032 {
00033 function init()
00034 {
00035 $this->addSVar('visible', 'false');
00036 }
00037
00038 function on_set_visible($event_args)
00039 {
00040 $visible = $event_args['visible'];
00041 $this->setSVar('visible', $visible);
00042 }
00043
00044 function on_delete($event_args)
00045 {
00046 $book_id = $event_args['book_id'];
00047 $lng = $event_args['lng'];
00048 $clean_sh = CONTENT.'clean.sh';
00049 $output = shell(CONTENT."clean.sh $book_id $lng");
00050 WebApp::debug_msg("<xmp>$output</xmp>");
00051 }
00052
00053 function onRender()
00054 {
00055 $this->add_recordsets();
00056 }
00057
00058 function add_recordsets()
00059 {
00060 global $webPage;
00061
00062
00063 $nr_cols = 3;
00064
00065
00066 $rs_cols = new EditableRS("cols");
00067
00068
00069 $fname = CONTENT.'books/book_list';
00070 $arr_lines = file($fname);
00071 $nr_chunks = sizeof($arr_lines) / $nr_cols;
00072 if (sizeof($arr_lines) % $nr_cols) $nr_chunks++;
00073 $arr_chunks = array_chunk($arr_lines, $nr_chunks);
00074
00075
00076 for ($i=0; $i < sizeof($arr_chunks); $i++)
00077 {
00078
00079 $rs = new EditableRS("books_$i");
00080
00081
00082 $chunk = $arr_chunks[$i];
00083 for ($j=0; $j < sizeof($chunk); $j++)
00084 {
00085 $line = $chunk[$j];
00086 if (trim($line)=='') continue;
00087
00088
00089 list($book_id, $lng, $title) = split(':', $line, 3);
00090 $title = trim($title);
00091
00092
00093 $rs->addRec(compact('book_id', 'lng', 'title'));
00094 }
00095
00096
00097 $webPage->addRecordset($rs);
00098
00099
00100 $rs_cols->addRec(array('nr'=> $i));
00101 }
00102
00103
00104 $webPage->addRecordset($rs_cols);
00105 }
00106 }
00107 ?>