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
00025 include_once dirname(__FILE__).'/edit_funcs.php';
00026
00033 class edit extends WebObject
00034 {
00035 function on_set_lock($event_args)
00036 {
00037 $lock = $event_args['lock'];
00038 set_node_lock($lock, 'edit');
00039 }
00040
00041 function on_move_up($event_args)
00042 {
00043 $node_path = $event_args['node_path'];
00044 lock_index();
00045 transform_index('move_up', array('path'=>$node_path));
00046 updatenavig_moveup($node_path);
00047 update_subnodes_html_all_langs();
00048 unlock_index();
00049 }
00050
00051 function on_move_down($event_args)
00052 {
00053 $node_path = $event_args['node_path'];
00054 lock_index();
00055 transform_index('move_down', array('path'=>$node_path));
00056 updatenavig_movedown($node_path);
00057 update_subnodes_html_all_langs();
00058 unlock_index();
00059 }
00060
00061 function on_delete($event_args)
00062 {
00063
00064 if (locked_by_somebody()) return;
00065
00066 $node_path = WebApp::getSVar('docbook->node_path');
00067 if ($node_path=='./' or $node_path=='./INFO/')
00068 {
00069 WebApp::message(T_("This node cannot be deleted."));
00070 return;
00071 }
00072
00073
00074 $refs = get_node_references();
00075 if ($refs != '')
00076 {
00077
00078 $msg = T_("This node cannot be deleted because it is referenced by \n v_refs \nFirst delete the references.");
00079 $msg = str_replace('v_refs', $refs, $msg);
00080 WebApp::message($msg);
00081
00082 return;
00083 }
00084
00085 lock_index();
00086
00087
00088 $navig = get_arr_navigation($node_path);
00089
00090
00091 transform_index('delete', array('path'=>$node_path));
00092
00093
00094 update_navigation_all_langs($navig['prev_path']);
00095 update_navigation_all_langs($navig['next_path']);
00096
00097
00098 delete_removefolders_all_langs($node_path);
00099
00100
00101 $parent_path = ereg_replace('[^/]+/$', '', $node_path);
00102 WebApp::setSVar('docbook->node_path', $parent_path);
00103
00104
00105 update_subnodes_html_all_langs($parent_path);
00106
00107 unlock_index();
00108 }
00109
00110 function on_add_subnode($event_args)
00111 {
00112 $id = $event_args['id'];
00113 $title = $event_args['title'];
00114 $type = $event_args['type'];
00115
00116
00117 $output = process_index('edit/get_node_id.xsl', array('id'=>$id));
00118 if ($output==$id)
00119 {
00120 $msg = T_("The id 'v_id' is already used by another section.");
00121 $msg = str_replace('v_id', $id, $msg);
00122 WebApp::message($msg);
00123 return;
00124 }
00125
00126 lock_index();
00127
00128
00129 $node_path = WebApp::getSVar('docbook->node_path');
00130 $params = array('id'=>$id, 'title'=>$title,
00131 'type'=>$type, 'path'=>$node_path);
00132 transform_index('add_subnode', $params);
00133
00134
00135 create_new_node($id, $title, $type);
00136
00137
00138 $new_node_path = $node_path.$id.'/';
00139 update_cache_files_all_langs($new_node_path);
00140
00141 unlock_index();
00142 }
00143
00144 function on_change_id($event_args)
00145 {
00146
00147 if (locked_by_somebody()) return;
00148
00149 $new_id = trim($event_args['id']);
00150
00151
00152 if (!change_id_validate($new_id)) return;
00153
00154 lock_index();
00155
00156 $book_id = WebApp::getSVar('docbook->book_id');
00157 $node_path = WebApp::getSVar('docbook->node_path');
00158 $new_node_path = ereg_replace('[^/]+/$', $new_id.'/', $node_path);
00159
00160
00161 $params = array('path'=>$node_path, 'new_id'=>$new_id);
00162 transform_index('update_node', $params);
00163
00164
00165 WebApp::setSVar('docbook->node_path', $new_node_path);
00166
00167
00168 changeid_movefolders($node_path, $new_node_path);
00169
00170
00171 changeid_setid($new_id);
00172
00173
00174 changeid_updatecache($new_node_path);
00175
00176 unlock_index();
00177 }
00178
00179 function on_change_title($event_args)
00180 {
00181
00182 if (locked_by_somebody()) return;
00183
00184 lock_index();
00185
00186 $new_title = $event_args['title'];
00187 $node_path = WebApp::getSVar('docbook->node_path');
00188
00189
00190 $xsl_file = XSLT."edit/set_content_title.xsl";
00191 $params = "--stringparam title \"$new_title\" ";
00192 $xml_file = file_content_xml(WS_BOOKS, $node_path);
00193 $content_xml = shell("xsltproc $params $xsl_file $xml_file");
00194 write_file($xml_file, $content_xml);
00195
00196
00197 update_cache_files($node_path);
00198
00199
00200 add_to_modified_nodes();
00201
00202
00203 set_node_status('modified');
00204
00205 unlock_index();
00206 }
00207
00208 function onParse()
00209 {
00210
00211 $node_path = WebApp::getSVar('docbook->node_path');
00212 $node_types = process_index_node('get_node_type');
00213 list($node_type,$subnode_type) = explode(':', chop($node_types));
00214 WebApp::addGlobalVars(compact('node_type','subnode_type'));
00215 }
00216
00217 function onRender()
00218 {
00219
00220 $arr_state = get_node_state();
00221 WebApp::addVar('status', $arr_state['status']);
00222 $m_user = $arr_state['m_user'];
00223 $m_email = $arr_state['m_email'];
00224 WebApp::addVar('m_user', "<a href='mailto:$m_email'>$m_user</a>");
00225 $m_time = get_date_str($arr_state['m_timestamp']);
00226 WebApp::addVar('m_time', $m_time);
00227
00228
00229 $locked_by_somebody = locked_by_somebody($arr_state);
00230 $str_locked_by_somebody = ($locked_by_somebody ? 'true' : 'false');
00231 $str_locked = (is_locked($arr_state) ? 'true' : 'false');
00232 WebApp::addVar('locked_by_somebody', $str_locked_by_somebody);
00233 WebApp::addVar('locked', $str_locked);
00234
00235
00236 if ($locked_by_somebody)
00237 {
00238 extract($arr_state);
00239 $msg = T_("This node is locked for v_mode\n\
00240 by v_l_user (v_l_email).\n\
00241 Please try again later.");
00242 $msg = str_replace('v_mode', $mode, $msg);
00243 $msg = str_replace('v_l_user', $l_user, $msg);
00244 $msg = str_replace('v_l_email', $l_email, $msg);
00245 WebApp::message($msg);
00246 WebApp::addVar('l_mode', $mode);
00247 WebApp::addVar('l_user', "<a href='mailto:$l_email'>$l_user</a>");
00248 return;
00249 }
00250
00251
00252 $node_path = WebApp::getSVar('docbook->node_path');
00253 ereg('([^/]+)/$', $node_path, $regs);
00254 $id = $regs[1];
00255 if ($id=='.') $id = WebApp::getSVar('docbook->book_id');
00256 WebApp::addVar("id", $id);
00257
00258
00259 $this->add_nodetypes_rs();
00260
00261
00262 add_subsections_rs();
00263 }
00264
00270 function add_nodetypes_rs()
00271 {
00272 $rs = new EditableRS('node_types');
00273
00274 $node_type = WebApp::getVar('node_type');
00275 $subnode_type = WebApp::getVar('subnode_type');
00276 switch ($node_type)
00277 {
00278 case 'book':
00279 $arr_types = array('chapter', 'appendix', 'preface');
00280 break;
00281 case 'article':
00282 $arr_types = array('section', 'appendix');
00283 break;
00284 case 'preface':
00285 case 'chapter':
00286 case 'section':
00287 case 'appendix':
00288 if ($subnode_type!='') $arr_types = array($subnode_type);
00289 else $arr_types = array('section', 'simplesect');
00290 break;
00291 default:
00292 case 'bookinfo':
00293 case 'articleinfo':
00294 case 'simplesect':
00295 $arr_types = array();
00296 break;
00297 }
00298
00299 for ($i=0; $i < sizeof($arr_types); $i++)
00300 {
00301 $t = $arr_types[$i];
00302 $rs->addRec(array('id' => $t, 'label' => $t));
00303 }
00304
00305 global $webPage;
00306 $webPage->addRecordset($rs);
00307 }
00308 }
00309 ?>