PageRenderTime 50ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 1ms

/module/exhibits/index.php

https://github.com/jasonchua/ndxzwebsite
PHP | 1578 lines | 1065 code | 381 blank | 132 comment | 104 complexity | 920968e53c987e0b9814dd70e2f6aedc MD5 | raw file
Possible License(s): AGPL-1.0
  1. <?php if (!defined('SITE')) exit('No direct script access allowed');
  2. class Exhibits extends Router
  3. {
  4. var $publishing = FALSE;
  5. var $error = FALSE;
  6. var $error_msg;
  7. var $pub_status = 0;
  8. var $page_id;
  9. var $object = array();
  10. function Exhibits()
  11. {
  12. parent::Router();
  13. // which object are we accessing?
  14. define('OBJECT', 'exhibit');
  15. $find['obj_ref_type'] = OBJECT;
  16. $this->object = $this->db->selectArray(PX.'objects_prefs', $find, 'record');
  17. // library of $_POST options
  18. $submits = array('upd_view','img_upload','publish_x',
  19. 'add_page','delete_x','publish_page','upd_ord','upd_img_ord',
  20. 'upd_section','upd_cbox','upd_settings','upd_delete','unpublish_x',
  21. 'del_bg_img','bg_img_upload', 'upd_jxs', 'upd_jximg', 'upd_jxdelimg',
  22. 'upd_jxtext', 'add_sec', 'del_sec', 'edit_sec');
  23. // from $_POST to method
  24. $this->posted($this, $submits);
  25. }
  26. function page_index()
  27. {
  28. global $go, $default;
  29. $go['page'] = getURI('page', 0, 'digit', 5);
  30. $this->template->location = $this->lang->word('main');
  31. // sub-locations
  32. $this->template->sub_location[] =
  33. array($this->lang->word('settings'), "?a=$go[a]&amp;q=settings");
  34. $this->template->sub_location[] = array($this->lang->word('new'),
  35. '#', "onclick=\"toggle('add-page'); return false;\"");
  36. // javascript stuff
  37. $this->template->add_js('jquery.js');
  38. $this->template->add_js('iutil.js');
  39. $this->template->add_js('idrag.js');
  40. $this->template->add_js('idrop.js');
  41. $this->template->add_js('isortables.js');
  42. $this->template->add_js('jquery.inplace.js');
  43. load_module_helper('files', $go['a']);
  44. $script = "<script type='text/javascript'>
  45. function serialize(s)
  46. {
  47. serial = $.SortSerialize(s);
  48. $.post('?a=$go[a]', { name : serial.hash, upd_ord : 'true' },
  49. function(html) { $('div#dhtml').html(html); }
  50. );
  51. setTimeout(fader, 3000);
  52. }
  53. $(document).ready(function()
  54. {
  55. $('ul').Sortable(
  56. {
  57. accept : 'sortableitem',
  58. activeclass : 'sortableactive',
  59. hoverclass : 'sortablehover',
  60. helperclass : 'sorthelper',
  61. opacity : 0.8,
  62. revert : true,
  63. tolerance : 'intersect',
  64. onStop : serialize
  65. })
  66. $('.inplace1').editInPlace({ params: 'upd_section=true',
  67. saving_text: '".$this->lang->word('saving')."',
  68. url: '?a=$go[a]' });
  69. $('.switchBox').toggleCheckboxes({ params: 'upd_cbox=true',
  70. saving_text: '".$this->lang->word('saving')."',
  71. url: '?a=$go[a]' });
  72. " . $this->template->get_special_js() . "
  73. });
  74. </script>";
  75. $this->template->add_script = $script;
  76. // ++++++++++++++++++++++++++++++++++++++++++++++++++++
  77. $body = '';
  78. $body .= "<div id='tab'>\n";
  79. $body .= "<div id='add-page' style='display: none;' class='bg-grey'>\n";
  80. $body .= "<div class='c3'>\n";
  81. $body .= "<div class='col'>\n";
  82. $body .= ips($this->lang->word('page title'), 'input', 'title', NULL, "maxlength='50'", 'text', $this->lang->word('required'),'req');
  83. $body .= input('add_page', 'submit', $attr='', $this->lang->word('add page'));
  84. $body .= "</div>\n";
  85. $body .= "<div class='col'>\n";
  86. $body .= ips($this->lang->word('section'), 'getSection', 'section_id', NULL, NULL, NULL, $this->lang->word('required'),'req');
  87. $body .= "</div>\n";
  88. //if ($this->object['obj_org'] == 1)
  89. //{
  90. $body .= "<div class='col'>\n";
  91. $body .= ips($this->lang->word('project year'), 'getYear', 'year', NULL, NULL, NULL, NULL,'req');
  92. $body .= "</div>\n";
  93. //}
  94. //else
  95. //{
  96. //$body .= input('year', 'hidden', NULL, date('Y'));
  97. //}
  98. $body .= "<div class='cl'><!-- --></div>\n</div>\n";
  99. $body .= "</div>\n\n";
  100. $this->lib_class('organize');
  101. $this->organize->obj_org = $this->object['obj_org'];
  102. $body .= $this->organize->order();
  103. $body .= div(p('&nbsp;'),"id='dhtml'");
  104. // 'tab' div
  105. $body .= "</div>\n";
  106. $this->template->body = $body;
  107. return;
  108. }
  109. function page_settings()
  110. {
  111. global $go, $default;
  112. $this->template->location = $this->lang->word('settings');
  113. // sub-locations
  114. $this->template->sub_location[] = array($this->lang->word('main'),"?a=$go[a]");
  115. // the record
  116. $rs = $this->db->fetchRecord("SELECT *
  117. FROM ".PX."objects_prefs
  118. WHERE obj_ref_type = '".OBJECT."'");
  119. $body = ($this->error == TRUE) ?
  120. div($this->error_msg,"id='show-error'").br() : '';
  121. load_module_helper('files', $go['a']);
  122. load_helpers(array('editortools', 'output'));
  123. // ++++++++++++++++++++++++++++++++++++++++++++++++++++
  124. $body .= "<div class='bg-grey'>\n";
  125. $body .= "<div class='c3'>\n";
  126. // First column
  127. $body .= "<div class='col'>\n";
  128. $body .= ips($this->lang->word('exhibition name'), 'input', 'obj_name',
  129. $rs['obj_name'], "maxlength='50'", 'text', $this->lang->word('required'),'req');
  130. $body .= ips($this->lang->word('advanced mode'), 'getGeneric', 'obj_mode', $rs['obj_mode']);
  131. if ($rs['obj_mode'] == 1)
  132. {
  133. $body .= "<label>".$this->lang->word('theme')."</label>\n";
  134. $body .= getThemes(DIRNAME . BASENAME . '/site/', $rs['obj_theme']);
  135. $body .= ips($this->lang->word('organize'), 'getOrganize', 'obj_org', $rs['obj_org']);
  136. }
  137. //$body .= ips($this->lang->word('use editor'), 'getGeneric', 'writing', $rs['writing']);
  138. if ($default['reporting'] == TRUE)
  139. {
  140. $body .= p('<strong>'.$this->lang->word('below required').'</strong>', "class='red-text'").br();
  141. $body .= ips($this->lang->word('email address'), 'input', 'obj_email', $rs['obj_email'],
  142. "maxlength='100'", 'text', $this->lang->word('from registration'));
  143. $body .= ips($this->lang->word('api key'), 'input', 'obj_apikey', $rs['obj_apikey'],
  144. "maxlength='32'", 'text');
  145. if (($rs['obj_email'] == '') || ($rs['obj_email'] == ''))
  146. $body .= p($this->lang->word('register at') .' ' . href('indexhibit', 'http://www.indexhibit.org/register/', "target='_blank'"));
  147. }
  148. $body .= "</div>\n";
  149. // second column
  150. $body .= "<div class='col'>\n";
  151. if ($rs['obj_mode'] == 1)
  152. {
  153. $body .= label($this->lang->word('pre nav text').' '.span($this->lang->word('html allowed')));
  154. $body .= textarea(stripForForm($rs['obj_itop'], 1), "style='height:99px;'", 'obj_itop');
  155. }
  156. $body .= label($this->lang->word('post nav text').' '.span($this->lang->word('html allowed')));
  157. $body .= textarea(stripForForm($rs['obj_ibot'], 1), "style='height:99px;'", 'obj_ibot');
  158. $body .= div(input('upd_settings', 'submit', NULL, $this->lang->word('update')), "style='text-align: right;'");
  159. $body .= "</div>\n";
  160. if ($rs['obj_mode'] == 1)
  161. {
  162. // third column
  163. $body .= "<div class='col'>\n";
  164. $body .= label($this->lang->word('sections')) . br();
  165. $body .= getSections();
  166. $body .= "</div>\n";
  167. }
  168. $body .= "<div class='cl'><!-- --></div>\n";
  169. $body .= "</div>";
  170. $this->template->body = $body;
  171. return;
  172. }
  173. function page_edit()
  174. {
  175. global $go, $default;
  176. $this->template->location = $this->lang->word('edit');
  177. // sub-locations
  178. $this->template->sub_location[] = array($this->lang->word('main'), "?a=$go[a]");
  179. $this->template->add_js('jquery.js');
  180. $this->template->add_js('jquery.inplace.js');
  181. $this->template->add_js('toolman.dragdrop.js');
  182. $this->template->add_js('ndxz.exhibit-edit.js');
  183. if ($default['color_picker'] == TRUE)
  184. {
  185. $this->template->add_js('plugin.js');
  186. }
  187. $this->template->add_css('plugin.css');
  188. $script = "<script type='text/javascript'>
  189. <!--
  190. var action = '$go[a]';
  191. var ide = '$go[id]';
  192. //-->
  193. </script>";
  194. $this->template->add_script = $script;
  195. // the record
  196. $rs = $this->db->fetchRecord("SELECT *
  197. FROM ".PX."objects, ".PX."objects_prefs, ".PX."sections
  198. WHERE id = '$go[id]'
  199. AND object = '".OBJECT."'
  200. AND section_id = secid
  201. AND object = obj_ref_type");
  202. load_module_helper('files', $go['a']);
  203. load_helpers(array('editortools', 'output'));
  204. // we need this for a bunch of things
  205. $bgcolor = ($rs['color'] == '') ? 'ffffff' : $rs['color'];
  206. // ++++++++++++++++++++++++++++++++++++++++++++++++++++
  207. $body = ($this->error == TRUE) ?
  208. div($this->error_msg,"id='show-error'").br() : '';
  209. $body .= "<div id='tab'>\n";
  210. $body .= "<div class='c5'>\n";
  211. // left column
  212. $body .= "<div class='colA'>\n";
  213. $body .= "<div class='bg-grey'>\n";
  214. $body .= "<div>\n";
  215. // rewrite this so we can save texts...
  216. $body .= div("<h3><span class='sec-title'>$rs[sec_desc]</span> <span class='inplace1'>$rs[title]</span></h3>", "class='col'");
  217. $body .= div(p("&nbsp;", "id='ajaxhold'"), "class='col txt-right'");
  218. $body .= "<div class='cl'><!-- --></div>\n";
  219. $body .= "</div>\n";
  220. $body .= editorTools($rs['content'], $this->access->prefs['user_mode'], editorButtons($rs['status']), $rs['process']);
  221. $body .= "<div>\n";
  222. $body .= div(label($this->lang->word('images')), "class='col'");
  223. $body .= div(p("&nbsp;", "id='imgshold'"), "class='col txt-right'");
  224. $body .= "<div class='cl'><!-- --></div>\n";
  225. $body .= "</div>\n";
  226. // the uploader part
  227. $body .= "<div id='iframe'><iframe src='?a=$go[a]&q=jxload&id=$go[id]' frameborder='0' scrolling='auto' width='625' height='100'></iframe></div>\n";
  228. // end uploader part
  229. $body .= "<div id='img-container'>";
  230. $body .= getExhibitImages($go['id']);
  231. $body .= "</div>\n";
  232. // end images part
  233. $body .= "</div>\n";
  234. $body .= "</div>\n";
  235. // end left colum
  236. // right column
  237. $body .= "<div class='colB'>\n";
  238. $body .= "<div class='colB-set'>\n";
  239. $body .= "<div class='colB-pad'>\n";
  240. $body .= label($this->lang->word('publish')).br();
  241. $body .= getOnOff($rs['status'], "class='listed' id='ajx-status'");
  242. $body .= "<label>".$this->lang->word('exhibition format')."</label>\n";
  243. $body .= getPresent(DIRNAME . BASENAME . '/site/plugin/', $rs['format']);
  244. if ($this->access->prefs['user_mode'] == 1)
  245. {
  246. $body .= label($this->lang->word('thumb max') . showHelp($this->lang->word('thumb max'))).br();
  247. $body .= getThumbSize($rs['thumbs'], "class='listed' id='ajx-thumbs'");
  248. $body .= label($this->lang->word('image max')).br();
  249. $body .= getImageSizes($rs['images'], "class='listed' id='ajx-images'");
  250. }
  251. // background color - this is a mess
  252. $body .= "<label>".$this->lang->word('background color')."</label>\n";
  253. if ($default['color_picker'] == TRUE)
  254. {
  255. $body .= getColorPicker($bgcolor);
  256. }
  257. else
  258. {
  259. $body .= "<div style='margin: 3px 0 5px 0;' onclick=\"toggle('plugin2'); return false;\"><span id='plugID' style='background: #$bgcolor; cursor: pointer;'>&nbsp;</span> ";
  260. $body .= span('#'.$bgcolor, "id='colorTest2'");
  261. $body .= "</div>\n";
  262. $body .= "<div id='plugin2' style='display:none;'>\n";
  263. $body .= "<input type='text' id='colorBox' name='color' value='$bgcolor' style='margin-bottom: 0;' maxlength='7' />\n";
  264. $body .= "<input type='button' onclick=\"updateColor();\" value='Update' />\n";
  265. $body .= "</div>\n";
  266. }
  267. $body .= p("<small>".$this->lang->word('edit color')."</small>","style='margin-bottom: 12px;'");
  268. // end background color
  269. // background image
  270. $body .= "<label>".$this->lang->word('background image')." <span class='small-txt'>" . getLimit() . " max</span></label>\n";
  271. $body .= "<div id='iframe'><iframe src='?a=$go[a]&q=jxbg&id=$go[id]' frameborder='0' scrolling='no' width='200' height='55'></iframe></div>\n";
  272. // aditional options
  273. $body .= "<div style='margin: 3px 0 5px 0;' onclick=\"toggle('adt-options'); return false;\"><label style='cursor:pointer;'>".$this->lang->word('additional options')."</label> ";
  274. $body .= "<div id='adt-options' style='display:none; padding-top:12px;'>\n";
  275. $body .= label($this->lang->word('background tiling')).br();
  276. $body .= getOnOff($rs['tiling'], "class='listed' id='ajx-tiling'");
  277. if ($this->access->prefs['user_mode'] == 1)
  278. {
  279. $body .= label($this->lang->word('page process')).br();
  280. $body .= getOnOff($rs['process'], "class='listed' id='ajx-process'");
  281. $body .= label($this->lang->word('hide page')).br();
  282. $body .= getOnOff($rs['hidden'], "class='listed' id='ajx-hidden'");
  283. }
  284. $body .= "</div>\n";
  285. $body .= "</div>\n";
  286. // end advanced
  287. // hidden fields
  288. $body .= input('hord', 'hidden', NULL, $rs['ord']);
  289. $body .= input('hsection_id', 'hidden', NULL, $rs['section_id']);
  290. $body .= "</div>\n";
  291. $body .= "</div>\n";
  292. $body .= "</div>\n";
  293. // end right column
  294. $body .= "<div class='cl'><!-- --></div>\n";
  295. $body .= "</div>\n";
  296. // the script for colors
  297. if ($default['color_picker'] == TRUE)
  298. {
  299. $body .= "<script type='text/javascript'>
  300. function mkColor(v) { \$S('plugID').background='#'+v; }
  301. loadSV(); updateH('$bgcolor');
  302. </script>";
  303. }
  304. $this->template->body = $body;
  305. return;
  306. }
  307. function page_section()
  308. {
  309. global $go, $default;
  310. $this->template->location = $this->lang->word('section');
  311. // sub-locations
  312. $this->template->sub_location[] = array($this->lang->word('settings'),"?a=$go[a]&q=settings");
  313. $this->template->sub_location[] = array($this->lang->word('main'),"?a=$go[a]");
  314. // the record
  315. $rs = $this->db->fetchRecord("SELECT *
  316. FROM ".PX."sections
  317. WHERE secid = '$go[id]'");
  318. $body = ($this->error == TRUE) ?
  319. div($this->error_msg,"id='show-error'").br() : '';
  320. load_module_helper('files', $go['a']);
  321. load_helpers(array('editortools', 'output'));
  322. // ++++++++++++++++++++++++++++++++++++++++++++++++++++
  323. $body .= "<div class='bg-grey'>\n";
  324. $body .= "<div class='c3'>\n";
  325. // First column
  326. $body .= "<div class='col'>\n";
  327. $body .= "<label>" . $this->lang->word('path') . "</label>";
  328. $body .= "<h2>" . BASEURL . "$rs[sec_path]</h2>" . br();
  329. $body .= ips($this->lang->word('section name'), 'input', 'sec_desc',
  330. $rs['sec_desc'], "maxlength='50'", 'text', $this->lang->word('required'),'req');
  331. $body .= ips($this->lang->word('folder name'), 'input', 'section',
  332. $rs['section'], "maxlength='50'", 'text', $this->lang->word('required'),'req');
  333. $body .= "<label>" . $this->lang->word('section order') . "</label>";
  334. $body .= getSectionOrd($rs['sec_ord'], 'sec_ord', NULL);
  335. $body .= ips($this->lang->word('projects section'), 'getGeneric', 'sec_proj', $rs['sec_proj']);
  336. $body .= ips($this->lang->word('section display'), 'getGeneric', 'sec_disp', $rs['sec_disp']);
  337. if ($default['reporting'] == TRUE)
  338. {
  339. $body .= ips($this->lang->word('reporting'), 'getGeneric', 'sec_report', $rs['sec_report']);
  340. }
  341. if ($rs['secid'] != 1)
  342. {
  343. $body .= input('del_sec', 'submit', "onclick=\"javascript:return confirm('" . $this->lang->word('sure delete section') . "');return false;\"", $this->lang->word('delete'));
  344. }
  345. $body .= input('edit_sec', 'submit', NULL, $this->lang->word('update'));
  346. $body .= input('hsecid', 'hidden', NULL, $rs['secid']);
  347. $body .= input('hsec_ord', 'hidden', NULL, $rs['sec_ord']);
  348. $body .= "</div>\n";
  349. $body .= "<div class='cl'><!-- --></div>\n";
  350. $body .= "</div>";
  351. $this->template->body = $body;
  352. return;
  353. }
  354. function page_view()
  355. {
  356. global $go;
  357. // the record
  358. $rs = $this->db->fetchRecord("SELECT *
  359. FROM ".PX."media
  360. WHERE media_id = '$go[id]'
  361. AND media_obj_type = '".OBJECT."'");
  362. // ++++++++++++++++++++++++++++++++++++++++++++++++++++
  363. $body = "<div style='width:125px; float:left;'><img src='" . BASEURL . GIMGS . "/th-$rs[media_file]' width='100' /><br /><br /><a href='" . BASEURL . GIMGS . "/$rs[media_file]' target='_new'>" . $this->lang->word('view full size') . "</a></div>\n";
  364. $body .= "\n";
  365. $body .= "<div style='width:495px; float:left;'>\n";
  366. $body .= ips($this->lang->word('image title'), 'input', 'media_title',
  367. $rs['media_title'], "id='media_title' maxlength='35'", 'text');
  368. $body .= ips($this->lang->word('image caption'), 'input', 'media_caption',
  369. $rs['media_caption'], "id='media_caption' maxlength='35'", 'text');
  370. // buttons
  371. $body .= "<input type='button' value='" . $this->lang->word('cancel') . "' onclick=\"getExhibit(); return false;\" />\n";
  372. $body .= "<input type='button' value='" . $this->lang->word('delete') . "' onclick=\"deleteImage('$rs[media_file]'); return false;\" />\n";
  373. $body .= "<input type='button' value='" . $this->lang->word('update') . "' onclick=\"updateImage($rs[media_id]); return false;\" />\n";
  374. $body .= "</div>\n";
  375. $body .= "<div class='cl'><!-- --></div>\n";
  376. header ('Content-type: text/html; charset=utf-8');
  377. echo $body;
  378. exit;
  379. }
  380. function page_prv()
  381. {
  382. global $go;
  383. $this->template->location = $this->lang->word('preview');
  384. // sub-locations
  385. $this->template->sub_location[] = array($this->lang->word('main'), "?a=$go[a]");
  386. // the record
  387. $rs = $this->db->fetchRecord("SELECT title, sec_desc
  388. FROM ".PX."objects, ".PX."sections
  389. WHERE id = '$go[id]'
  390. AND object = '".OBJECT."'
  391. AND section_id = secid");
  392. // ++++++++++++++++++++++++++++++++++++++++++++++++++++
  393. $title_area = div(div("<h3><span class='sec-title'>$rs[sec_desc]</span> $rs[title]</h3><br />\n","class='col'").
  394. div(href($this->lang->word('edit'), "?a=$go[a]&amp;q=edit&amp;id=$go[id]"), "class='col txt-right'").
  395. "<div class='cl'><!-- --></div>","class='c2'");
  396. $body = div($title_area.
  397. "<iframe class='prv-text' src='?a=system&amp;q=prv&amp;id=$go[id]'></iframe>\n".
  398. "<div class='cl'><!-- --></div>","class='c1 bg-grey'");
  399. $this->template->body = $body;
  400. }
  401. function page_jximg()
  402. {
  403. global $go;
  404. load_module_helper('files', $go['a']);
  405. header ('Content-type: text/html; charset=utf-8');
  406. echo getExhibitImages($go['id']);
  407. exit;
  408. }
  409. function page_jxload()
  410. {
  411. global $go, $default;
  412. load_module_helper('files', $go['a']);
  413. if (isset($_POST['jxload']))
  414. {
  415. // perform the upload
  416. $this->sbmt_img_upload();
  417. $more = "<script type='text/javascript'>
  418. $(document).ready(function(){
  419. parent.getExhibit();
  420. });
  421. </script>\n";
  422. }
  423. $more = (!isset($more)) ? '' : $more;
  424. $this->template->add_js('jquery.js');
  425. $this->template->add_js('jquery.multifile.js');
  426. $script = "<style type='text/css'>
  427. #uploader input { font-size: 9px; }
  428. #files_list div, #files_list input { margin: 0 0 1px 0; padding: 0; }
  429. </style>
  430. $more";
  431. $this->template->add_script = $script;
  432. $body = "<div style='text-align:left;' id='uploader'>\n";
  433. $body .= "<form enctype='multipart/form-data' action='?a=$go[a]&q=jxload&id=$go[id]' method='post'>\n";
  434. $body .= "<div style='float:left; width:200px;'>\n";
  435. $body .= "<input id='my_file_element' type='file' name='filename[]' >\n";
  436. $body .= "<input type='submit' name='jxload' value='" . $this->lang->word('upload') . "'>\n";
  437. $body .= "</form>\n";
  438. $body .= p('<strong>' . $this->lang->word('filetypes') . ':</strong> ' . $this->lang->word('allowed formats') . br() . '<strong>' . $this->lang->word('max file size') . ':</strong> ' . getLimit(), "class='red'");
  439. $body .= "</div>\n";
  440. $body .= "<div style='float:left; width:400px; text-align:right;'>\n";
  441. $body .= "<div id='files_list'></div>\n";
  442. $body .= "</div>\n";
  443. $body .= "<div class='cl'><!-- --></div>\n";
  444. $body .= "</div>\n";
  445. $body .= "<script>\n";
  446. // this tells us how many we can upload at a time
  447. $body .= "var multi_selector = new MultiSelector( document.getElementById( 'files_list' ), " . $default['exhibit_imgs'] . " );\n";
  448. $body .= "multi_selector.addElement( document.getElementById( 'my_file_element' ) );\n";
  449. $body .= "</script>\n";
  450. $this->template->body = $body;
  451. $this->template->output('iframe');
  452. exit;
  453. }
  454. function page_jxbg()
  455. {
  456. global $go;
  457. if (isset($_POST['upload']))
  458. {
  459. if (isset($_POST['deletion']))
  460. {
  461. load_module_helper('files', $go['a']);
  462. $clean['bgimg'] = '';
  463. $this->db->updateArray(PX.'objects', $clean, "id='$go[id]'");
  464. $filename = $_POST['filename'];
  465. // we need to delete the picture too...
  466. if (file_exists(DIRNAME . '/files/' . $filename))
  467. {
  468. unlink(DIRNAME . '/files/' . $filename);
  469. }
  470. }
  471. else
  472. {
  473. // perform the upload
  474. $this->sbmt_bg_img_upload();
  475. }
  476. }
  477. $this->template->add_js('jquery.js');
  478. $script = "<style type='text/css'>
  479. body { text-align: left; }
  480. </style>
  481. <script type='text/javascript'>
  482. $(document).ready(function()
  483. {
  484. $('#iform').change( function() {
  485. $('#iform')[0].submit();
  486. parent.updating(\"<span class='notify'>" . $this->lang->word('updating') . "</span>\");
  487. });
  488. $('#iform #delete').click( function() {
  489. $('#iform')[0].submit();
  490. parent.updating(\"<span class='notify'>" . $this->lang->word('updating') . "</span>\");
  491. });
  492. });
  493. </script>";
  494. $this->template->add_script = $script;
  495. // the record
  496. $rs = $this->db->fetchRecord("SELECT bgimg
  497. FROM ".PX."objects
  498. WHERE id = '$go[id]'");
  499. if ($rs['bgimg'] != '')
  500. {
  501. $body = "<form action='?a=$go[a]&q=jxbg&id=$go[id]' method='post' name='iform' id='iform'>\n";
  502. $body .= "<div>\n";
  503. $body .= "<a href='" . BASEURL . BASEFILES . "/$rs[bgimg]' target='_new'><img src='" . BASEURL . BASEFILES . "/$rs[bgimg]' width='25' style='padding-top:2px;' valign='center' border='0' /></a>";
  504. $body .= " <input type='button' name='delete' id='delete' value='" . $this->lang->word('delete') . "' style='padding-top:0;' />\n";
  505. $body .= "<input type='hidden' name='upload' value='1' />\n";
  506. $body .= "<input type='hidden' name='deletion' value='1' />\n";
  507. $body .= "<input type='hidden' name='filename' value='$rs[bgimg]' />\n";
  508. $body .= "</div>\n";
  509. $body .= "</form>\n";
  510. }
  511. else
  512. {
  513. $body = "<form enctype='multipart/form-data' action='?a=$go[a]&q=jxbg&id=$go[id]' method='post' name='iform' id='iform'>\n";
  514. $body .= "<div>\n";
  515. $body .= "<input type='file' id='jxbg' name='jxbg' />\n";
  516. $body .= "<input type='hidden' name='upload' value='1' />\n";
  517. $body .= "</div>\n";
  518. $body .= "</form>\n";
  519. }
  520. $this->template->body = $body;
  521. $this->template->output('iframe');
  522. exit;
  523. }
  524. function publisher()
  525. {
  526. ($this->pub_status == 1) ? $this->sbmt_publish_x() : $this->sbmt_unpublish_x();
  527. }
  528. // we need a way to protect these page from outside access
  529. function sbmt_add_page()
  530. {
  531. $OBJ->template->errors = TRUE;
  532. global $go;
  533. // can we do this better?
  534. $processor =& load_class('processor', TRUE, 'lib');
  535. $clean['title'] = $processor->process('title',array('notags', 'reqNotEmpty'));
  536. $clean['section_id'] = $processor->process('section_id',array('notags', 'reqNotEmpty'));
  537. $clean['year'] = $processor->process('year',array('notags' ,'reqNotEmpty'));
  538. if ($processor->check_errors())
  539. {
  540. // get our error messages
  541. $error_msg = $processor->get_errors();
  542. $this->errors = TRUE;
  543. $GLOBALS['error_msg'] = $error_msg;
  544. $this->template->special_js = "toggle('add-page');";
  545. return;
  546. }
  547. else
  548. {
  549. // we need to deal with the order of things...
  550. $this->db->updateRecord("UPDATE ".PX."objects SET
  551. ord = ord + 1
  552. WHERE
  553. section_id = ".$this->db->escape($clean['section_id'])."");
  554. // a few more things
  555. $clean['udate'] = getNow();
  556. $clean['object'] = OBJECT;
  557. $clean['ord'] = 1;
  558. $clean['creator'] = $this->access->prefs['ID'];
  559. $last = $this->db->insertArray(PX.'objects', $clean);
  560. system_redirect("?a=$go[a]&q=edit&id=$last");
  561. }
  562. return;
  563. }
  564. // we need a way to protect these page from outside access
  565. function sbmt_add_sec()
  566. {
  567. $OBJ->template->errors = TRUE;
  568. global $go;
  569. // can we do this better?
  570. $processor =& load_class('processor', TRUE, 'lib');
  571. $clean['sec_desc'] = $processor->process('sec_desc',array('notags','reqNotEmpty'));
  572. $clean['section'] = $processor->process('section',array('notags','reqNotEmpty'));
  573. $temp['hsec_ord'] = $processor->process('hsec_ord',array('digit'));
  574. if ($processor->check_errors())
  575. {
  576. // get our error messages
  577. $error_msg = $processor->get_errors();
  578. $this->errors = TRUE;
  579. $GLOBALS['error_msg'] = $error_msg;
  580. $this->template->special_js = "toggle('add-sec');";
  581. return;
  582. }
  583. else
  584. {
  585. // a few more things
  586. $clean['sec_date'] = getNow();
  587. $clean['sec_ord'] = $temp['hsec_ord'] + 1;
  588. // we need to romanize the path based upon 'section'
  589. load_helpers( array('output', 'romanize') );
  590. $folder_name = load_class('publish', TRUE, 'lib');
  591. $folder_name->title = trim($clean['section']);
  592. $clean['section'] = $folder_name->processTitle();
  593. $clean['sec_path'] = '/' . $clean['section'];
  594. $last = $this->db->insertArray(PX.'sections', $clean);
  595. system_redirect("?a=$go[a]&q=section&id=$last");
  596. }
  597. return;
  598. }
  599. function sbmt_edit_sec()
  600. {
  601. global $go;
  602. $processor =& load_class('processor', TRUE, 'lib');
  603. $temp['hsec_ord'] = $processor->process('hsec_ord',array('digit'));
  604. $temp['hsecid'] = $processor->process('hsecid',array('digit'));
  605. $clean['sec_desc'] = $processor->process('sec_desc',array('notags', 'reqnotempty'));
  606. $clean['section'] = $processor->process('section',array('nophp', 'reqnotempty'));
  607. $clean['sec_proj'] = $processor->process('sec_proj',array('boolean'));
  608. $clean['sec_report'] = $processor->process('sec_report',array('boolean'));
  609. $clean['sec_disp'] = $processor->process('sec_disp',array('boolean'));
  610. $clean['sec_ord'] = $processor->process('sec_ord',array('digit'));
  611. if ($processor->check_errors())
  612. {
  613. // get our error messages
  614. $error_msg = $processor->get_errors();
  615. $this->errors = TRUE;
  616. $GLOBALS['error_msg'] = $error_msg;
  617. return;
  618. }
  619. else
  620. {
  621. if ($clean['sec_proj'] == 1)
  622. {
  623. // update all sections with sec_proj = 0
  624. $this->db->updateRecord("UPDATE ".PX."sections SET sec_proj = '0'");
  625. }
  626. // so nice and messy!
  627. if ($clean['sec_ord'] != $temp['hsec_ord'])
  628. {
  629. // we need to reorder things
  630. if ($clean['sec_ord'] > $temp['hsec_ord']) {
  631. $this->db->updateRecord("UPDATE ".PX."sections SET
  632. sec_ord = sec_ord-1
  633. WHERE
  634. (sec_ord > '$temp[hsec_ord]')
  635. AND (sec_ord <= '$clean[sec_ord]')");
  636. } elseif ($clean['sec_ord'] < $temp['hsec_ord']) {
  637. $this->db->updateRecord("UPDATE ".PX."sections SET
  638. sec_ord = sec_ord+1
  639. WHERE
  640. (sec_ord < '$temp[hsec_ord]')
  641. AND (sec_ord >= '$clean[sec_ord]')");
  642. } else {
  643. // do nothing here
  644. }
  645. }
  646. // we need to romanize the path based upon 'section'
  647. load_helpers( array('output', 'romanize') );
  648. $folder_name = load_class('publish', TRUE, 'lib');
  649. $folder_name->title = trim($clean['section']);
  650. $clean['section'] = $folder_name->processTitle();
  651. if ($go['id'] != 1)
  652. {
  653. // you can update the sec_path
  654. $clean['sec_path'] = '/' . $clean['section'];
  655. }
  656. $this->db->updateArray(PX.'sections', $clean, "secid='$go[id]'");
  657. // send an update notice
  658. $this->template->action_update = 'updated';
  659. }
  660. }
  661. function sbmt_del_sec()
  662. {
  663. global $go;
  664. $processor =& load_class('processor', TRUE, 'lib');
  665. $temp['hsec_ord'] = $processor->process('hsec_ord',array('digit'));
  666. // delete section
  667. $this->db->deleteArray(PX.'sections', "secid = $go[id]");
  668. // delete pages
  669. $this->db->deleteRecord("DELETE FROM ".PX."objects WHERE section_id = '$go[id]'");
  670. // so nice and messy!
  671. $this->db->updateRecord("UPDATE ".PX."sections SET
  672. sec_ord = sec_ord-1
  673. WHERE
  674. (sec_ord > '$temp[hsec_ord]')");
  675. system_redirect("?a=$go[a]&q=settings");
  676. }
  677. function sbmt_publish_x()
  678. {
  679. global $default;
  680. $this->publishing = TRUE;
  681. // get record
  682. $rs = $this->db->fetchRecord("SELECT id, title, secid, sec_path, status, report,
  683. obj_apikey, obj_email, sec_report
  684. FROM ".PX."objects, ".PX."objects_prefs, ".PX."sections
  685. WHERE id = '".$this->page_id."'
  686. AND object = '".OBJECT."'
  687. AND obj_ref_type = object
  688. AND section_id = secid");
  689. // not again
  690. if ($rs['status'] == 1) return;
  691. load_helper('output');
  692. load_helper('romanize');
  693. $URL =& load_class('publish', TRUE, 'lib');
  694. // make the url
  695. $URL->title = $rs['title'];
  696. $URL->section = $rs['sec_path'];
  697. $check_url = $URL->makeURL();
  698. // check for dupe
  699. $check = $this->db->fetchArray("SELECT id
  700. FROM ".PX."objects
  701. WHERE url = '$check_url'");
  702. // if dupe alert
  703. if ($check)
  704. {
  705. // let's just append things
  706. $previous = count($check);
  707. $previous = $previous + 1 . '/';
  708. }
  709. else
  710. {
  711. $previous = '';
  712. }
  713. $clean['url'] = $check_url . $previous;
  714. // report to system
  715. // we need to be sure this is a project
  716. if ($default['reporting'] == TRUE)
  717. {
  718. if (($rs['report'] != 1) && ($rs['obj_apikey'] != '')
  719. && ($rs['obj_email'] != '') && ($rs['sec_report'] == 1))
  720. {
  721. $REST =& load_class('rest', TRUE, 'lib');
  722. $REST->apikey = $rs['obj_apikey'];
  723. $REST->email = $rs['obj_email'];
  724. $REST->id = $rs['id'];
  725. $REST->title = $rs['title'];
  726. $REST->url = BASEURL . $clean['url'];
  727. $var = $REST->report_to_indexhibit();
  728. if ($var == TRUE) $clean['report'] = 1;
  729. }
  730. }
  731. // need to update table
  732. $clean['status'] = 1;
  733. $clean['udate'] = getNow();
  734. $clean['pdate'] = getNow();
  735. $clean['url'] = $clean['url'];
  736. $clean['object'] = OBJECT;
  737. $this->db->updateArray(PX.'objects', $clean, "id='".$this->page_id."'");
  738. }
  739. function sbmt_unpublish_x()
  740. {
  741. // need to update table
  742. $clean['status'] = 2;
  743. $clean['udate'] = getNow();
  744. $clean['pdate'] = '0000-00-00 00:00:00';
  745. $clean['url'] = '';
  746. $this->db->updateArray(PX.'objects', $clean, "id='".$this->page_id."'");
  747. }
  748. function sbmt_delete_x()
  749. {
  750. global $go;
  751. if ($go['id'] == 1)
  752. {
  753. system_redirect("?a=$go[a]"); // this can not be deleted
  754. return;
  755. }
  756. $processor =& load_class('processor', TRUE, 'lib');
  757. $clean['hsection_id'] = $processor->process('hsection_id',array('notags','digit'));
  758. $clean['hord'] = $processor->process('hord',array('notags','digit'));
  759. $this->db->deleteArray(PX.'objects', "id='$go[id]'");
  760. // we need to deal with the order of things...
  761. $this->db->updateRecord("UPDATE ".PX."objects SET
  762. ord = ord - 1
  763. WHERE
  764. section_id = ".$this->db->escape($clean['hsection_id'])."
  765. AND ord >= ".$this->db->escape($clean['hord'])."");
  766. system_redirect("?a=$go[a]");
  767. }
  768. function sbmt_upd_delete()
  769. {
  770. global $go;
  771. $file = $this->db->fetchRecord("SELECT media_id,media_ref_id,media_file
  772. FROM ".PX."media
  773. WHERE media_id='$go[id]'");
  774. if ($file)
  775. {
  776. if (file_exists(DIRNAME . GIMGS . '/' . $file['media_file']))
  777. {
  778. unlink(DIRNAME . GIMGS . '/' . $file['media_file']);
  779. $this->db->deleteArray(PX.'media', "media_id='$file[media_id]'");
  780. }
  781. }
  782. system_redirect("?a=$go[a]&q=edit&id=$file[media_ref_id]");
  783. }
  784. function sbmt_upd_view()
  785. {
  786. global $go;
  787. $processor =& load_class('processor', TRUE, 'lib');
  788. $clean['media_title'] = $processor->process('media_title', array('notags'));
  789. $clean['media_caption'] = $processor->process('media_caption', array('nophp'));
  790. if ($processor->check_errors())
  791. {
  792. // get our error messages
  793. $error_msg = $processor->get_errors();
  794. $this->errors = TRUE;
  795. $GLOBALS['error_msg'] = $error_msg;
  796. return;
  797. }
  798. else
  799. {
  800. $clean['media_udate'] = getNow();
  801. $this->db->updateArray(PX.'media', $clean, "media_id='$go[id]'");
  802. system_redirect("?a=$go[a]&q=view&id=$go[id]");
  803. }
  804. }
  805. function sbmt_upd_ord()
  806. {
  807. $vars = explode('&', $_POST['name']);
  808. foreach ($vars as $next)
  809. {
  810. $var[] = explode('=', $next);
  811. }
  812. foreach ($var as $out)
  813. {
  814. // perhaps this preg can be better...
  815. $out[0] = preg_replace('/[^[:digit:]]/', '', $out[0]);
  816. $out[1] = preg_replace('/[^[:digit:]]/', '', $out[1]);
  817. $blah[$out[0]][] = $out[1];
  818. }
  819. foreach ($blah as $key => $do)
  820. {
  821. $i = 1;
  822. foreach ($do as $it)
  823. {
  824. // it must be a year
  825. // unless you have 1001 or more pages
  826. if (strlen($key) > 4)
  827. {
  828. // get the year - it's at the end
  829. $yeara = substr($key, -4);
  830. $year = "year = ".$this->db->escape($yeara).",";
  831. // get the section_id...everything but the year
  832. $section_id = preg_replace("/$yeara$/", '', $key);
  833. }
  834. else
  835. {
  836. // no year
  837. $year = '';
  838. // need the section id
  839. $section_id = $key;
  840. }
  841. $this->db->updateRecord("UPDATE ".PX."objects SET
  842. ord = ".$this->db->escape($i).",
  843. $year
  844. section_id = ".$this->db->escape($section_id)."
  845. WHERE
  846. id = ".$this->db->escape($it)."");
  847. $i++;
  848. }
  849. }
  850. // make this better later
  851. header ('Content-type: text/html; charset=utf-8');
  852. echo "<span class='notify'>".$this->lang->word('updated')."</span>";
  853. exit;
  854. }
  855. function sbmt_upd_cbox()
  856. {
  857. // make a boolean validator
  858. $clean['sec_disp'] = $_POST['checked'];
  859. $cleaned['secid'] = str_replace('b', '', $_POST['element_id']);
  860. $this->db->updateArray(PX.'sections', $clean, "secid = '$cleaned[secid]'");
  861. if ($clean['sec_disp'] == 1)
  862. {
  863. header ('Content-type: text/html; charset=utf-8');
  864. echo input('boxy', 'checkbox', "checked='checked' id='b$cleaned[secid]'", 1);
  865. }
  866. else
  867. {
  868. header ('Content-type: text/html; charset=utf-8');
  869. echo input('boxy', 'checkbox', "id='b$cleaned[secid]'", 0);
  870. }
  871. exit;
  872. }
  873. function sbmt_upd_section()
  874. {
  875. if ($_POST['update_value'] == '') { echo 'Error'; exit; }
  876. $clean['sec_desc'] = $_POST['update_value'];
  877. $clean['secid'] = str_replace('s', '', $_POST['element_id']);
  878. $this->db->updateArray(PX.'sections', $clean, "secid=$clean[secid]");
  879. // back to our page
  880. header ('Content-type: text/html; charset=utf-8');
  881. echo $clean['sec_desc'];
  882. exit;
  883. }
  884. function sbmt_bg_img_upload()
  885. {
  886. global $go, $uploads;
  887. $dir = DIRNAME . BASEFILES . '/';
  888. $types = $uploads['images'];
  889. $IMG =& load_class('media', TRUE, 'lib');
  890. $thetype = explode('.', strtolower($_FILES['jxbg']['name']));
  891. $thetype = array_pop($thetype);
  892. $name = $go['id'] . '_background' . '.' . $thetype;
  893. if (in_array($thetype, $types))
  894. {
  895. if ($_FILES['jxbg']['size'] < $IMG->upload_max_size)
  896. {
  897. // if uploaded we can work with it
  898. if (move_uploaded_file($_FILES['jxbg']['tmp_name'], $dir . '/' . $name))
  899. {
  900. $clean['bgimg'] = $name;
  901. $this->db->updateArray(PX.'objects', $clean, "id='$go[id]'");
  902. @chmod($dir . '/' . $name, 0755);
  903. return;
  904. }
  905. else
  906. {
  907. // error on upload
  908. }
  909. }
  910. else
  911. {
  912. // too big
  913. }
  914. }
  915. }
  916. function sbmt_upd_img_ord()
  917. {
  918. // make this more safe
  919. $vars = explode(',', $_POST['order']);
  920. foreach ($vars as $out)
  921. {
  922. $out = preg_replace('/[^[:digit:]]/', '', $out);
  923. $order[] = $out;
  924. }
  925. if (is_array($order))
  926. {
  927. $i = 1;
  928. foreach ($order as $do)
  929. {
  930. $this->db->updateRecord("UPDATE ".PX."media SET
  931. media_order = ".$this->db->escape($i)."
  932. WHERE
  933. media_id = ".$this->db->escape($do)."");
  934. $i++;
  935. }
  936. }
  937. // make this better later
  938. header ('Content-type: text/html; charset=utf-8');
  939. echo "<span class='notify'>".$this->lang->word('updated')."</span>";
  940. exit;
  941. }
  942. function sbmt_upd_settings()
  943. {
  944. global $go, $default;
  945. $processor =& load_class('processor', TRUE, 'lib');
  946. load_helper('textprocess');
  947. $clean['obj_name'] = $processor->process('obj_name',array('notags','reqNotEmpty'));
  948. $clean['obj_itop'] = $processor->process('obj_itop',array('nophp'));
  949. $clean['obj_ibot'] = $processor->process('obj_ibot',array('nophp'));
  950. $clean['obj_theme'] = $processor->process('obj_theme', array('notags'));
  951. $clean['obj_org'] = $processor->process('obj_org', array('notags'));
  952. $clean['obj_mode'] = $processor->process('obj_mode', array('notags', 'boolean'));
  953. //$user['writing'] = $processor->process('writing', array('digit'));
  954. if ($default['reporting'] == TRUE)
  955. {
  956. $clean['obj_apikey'] = $processor->process('obj_apikey', array('notags'));
  957. $clean['obj_email'] = $processor->process('obj_email', array('notags'));
  958. }
  959. // defaults!
  960. $clean['obj_org'] = ($clean['obj_mode'] == 1) ? $clean['obj_org'] : 1;
  961. $theme = ($clean['obj_theme'] == '') ? 'eatock' : $clean['obj_theme'];
  962. $clean['obj_theme'] = ($clean['obj_mode'] == 1) ? $theme : 'eatock';
  963. // process the text...
  964. $clean['obj_itop'] = textProcess($clean['obj_itop'], 1);
  965. $clean['obj_ibot'] = textProcess($clean['obj_ibot'], 1);
  966. if ($processor->check_errors())
  967. {
  968. // get our error messages
  969. $error_msg = $processor->get_errors();
  970. $this->errors = TRUE;
  971. $GLOBALS['error_msg'] = $error_msg;
  972. return;
  973. }
  974. else
  975. {
  976. // redundant...but we need it.
  977. $user['user_mode'] = $clean['obj_mode'];
  978. if ($user['user_mode'] != 1)
  979. {
  980. // language?
  981. // but what if this file was deleted?
  982. $clean['obj_itop'] = "<p><%obj_name%><br />
  983. <a href=\'<%baseurl%><plug:ndxz_rewriter url=\'/about-this-site/\' />\'>" . $this->lang->word('about this site') . "</a></p>";
  984. }
  985. else
  986. {
  987. if ($clean['obj_itop'] == '')
  988. {
  989. $clean['obj_itop'] = "<p><%obj_name%><br />
  990. <a href=\'<%baseurl%><plug:ndxz_rewriter url=\'/about-this-site/\' />\'>" . $this->lang->word('about this site') . "</a></p>";
  991. }
  992. }
  993. $this->db->updateArray(PX.'objects_prefs', $clean, "obj_ref_type='".OBJECT."'");
  994. $this->db->updateArray(PX.'users', $user, "ID='".$this->access->prefs['ID']."'");
  995. // send an update notice
  996. $this->template->action_update = 'updated';
  997. }
  998. }
  999. // only images, nothing fancy here...
  1000. function sbmt_img_upload()
  1001. {
  1002. global $go, $uploads, $default;
  1003. $OBJ->template->errors = TRUE;
  1004. load_module_helper('files', $go['a']);
  1005. $IMG =& load_class('media', TRUE, 'lib');
  1006. // we'll query for all our defaults first...
  1007. $rs = $this->db->fetchRecord("SELECT thumbs, images
  1008. FROM ".PX."objects
  1009. WHERE id = '$go[id]'
  1010. AND object = '".OBJECT."'");
  1011. // we need to get these from some defaults someplace
  1012. $IMG->thumbsize = ($rs['thumbs'] != '') ? $rs['thumbs'] : 200;
  1013. $IMG->maxsize = ($rs['images'] != '') ? $rs['images'] : 9999;
  1014. $IMG->quality = $default['img_quality'];
  1015. $IMG->makethumb = TRUE;
  1016. $IMG->path = DIRNAME . GIMGS . '/';
  1017. load_helper('output');
  1018. $URL =& load_class('publish', TRUE, 'lib');
  1019. // +++++++++++++++++++++++++++++++++++++++++++++++++++
  1020. // oh so messy
  1021. // our input array is a mess - clean out empty elements
  1022. $_FILES['filename']['name'] = array_diff($_FILES['filename']['name'], array(""));
  1023. $_FILES['filename']['tmp_name'] = array_diff($_FILES['filename']['tmp_name'], array(""));
  1024. $_FILES['filename']['size'] = array_diff($_FILES['filename']['size'], array(""));
  1025. // rewrite arrays
  1026. foreach ($_FILES['filename']['tmp_name'] as $key => $file)
  1027. {
  1028. $new_images[] = array('temp'=>$file, 'name'=>$_FILES['filename']['name'][$key],
  1029. 'size'=>$_FILES['filename']['size'][$key]);
  1030. }
  1031. if (empty($new_images)) return;
  1032. // reverse the array
  1033. rsort($new_images);
  1034. $x = 0;
  1035. $added_x = array();
  1036. foreach ($new_images as $key => $image)
  1037. {
  1038. if ($image['size'] < $IMG->upload_max_size)
  1039. {
  1040. $test = explode('.', strtolower($image['name']));
  1041. $thetype = array_pop($test);
  1042. $URL->title = implode('_', $test);
  1043. $new_title = $URL->processTitle();
  1044. $IMG->type = '.' . $thetype;
  1045. $IMG->filename = $IMG->checkName($go['id'] . '_' . $new_title) . '.' . $thetype;
  1046. if (in_array($thetype, $uploads['images']))
  1047. {
  1048. // if uploaded we can work with it
  1049. if (move_uploaded_file($image['temp'],
  1050. $IMG->path . '/' . $IMG->filename))
  1051. {
  1052. $x++;
  1053. $IMG->image = $IMG->path . '/' . $IMG->filename;
  1054. $IMG->uploader();
  1055. $clean['media_id'] = 'NULL';
  1056. $clean['media_order'] = $x;
  1057. $clean['media_ref_id'] = $go['id'];
  1058. $clean['media_file'] = $IMG->filename;
  1059. $clean['media_mime'] = $thetype;
  1060. $clean['media_obj_type'] = OBJECT;
  1061. $clean['media_x'] = $IMG->out_size['x'];
  1062. $clean['media_y'] = $IMG->out_size['y'];
  1063. $clean['media_kb'] = $IMG->file_size;
  1064. $added_x[$x] = $this->db->insertArray(PX.'media', $clean);
  1065. @chmod($IMG->path . '/' . $IMG->filename, 0755);
  1066. }
  1067. else
  1068. {
  1069. // file not uploaded
  1070. }
  1071. }
  1072. else
  1073. {
  1074. // need to report back if things don't work
  1075. // not a valid format
  1076. }
  1077. }
  1078. else
  1079. {
  1080. // nothing, it's too big
  1081. }
  1082. }
  1083. // update the order of things
  1084. if ($x > 0)
  1085. {
  1086. $this->db->updateRecord("UPDATE ".PX."media SET
  1087. media_order = media_order + $x
  1088. WHERE
  1089. (media_id NOT IN (" .implode(',', $added_x). "))
  1090. AND media_ref_id = '$go[id]'");
  1091. }
  1092. }
  1093. function sbmt_upd_jximg()
  1094. {
  1095. global $go;
  1096. load_module_helper('files', $go['a']);
  1097. header ('Content-type: text/html; charset=utf-8');
  1098. $clean['media_id'] = (int) $_POST['id'];
  1099. $clean['media_title'] = ($_POST['v'] == '') ? '' : utf8Urldecode($_POST['v']);
  1100. $clean['media_caption'] = ($_POST['x'] == '') ? '' : utf8Urldecode($_POST['x']);
  1101. $this->db->updateArray(PX.'media', $clean, "media_id=$clean[media_id]");
  1102. header ('Content-type: text/html; charset=utf-8');
  1103. echo "<span class='notify'>" . $this->lang->word('updating') . "</span>";
  1104. exit;
  1105. }
  1106. function sbmt_upd_jxtext()
  1107. {
  1108. global $go;
  1109. header ('Content-type: text/html; charset=utf-8');
  1110. load_module_helper('files', $go['a']);
  1111. $clean['id'] = (int) $_POST['id'];
  1112. $_POST['content'] = ($_POST['v'] == '') ? '' : utf8Urldecode($_POST['v']);
  1113. //$_POST['content'] = ($_POST['v'] == '') ? '' : $_POST['v'];
  1114. //echo $_POST['content']; exit;
  1115. // we need preference on processing
  1116. $rs = $this->db->fetchRecord("SELECT process
  1117. FROM ".PX."objects
  1118. WHERE id = '$clean[id]'");
  1119. $processor =& load_class('processor', TRUE, 'lib');
  1120. load_helper('textprocess');
  1121. $clean['content'] = $processor->process('content', array('nophp'));
  1122. $clean['content'] = textProcess($clean['content'], $rs['process']);
  1123. $clean['udate'] = getNow();
  1124. $clean['object'] = OBJECT;
  1125. $this->db->updateArray(PX.'objects', $clean, "id='$clean[id]'");
  1126. header ('Content-type: text/html; charset=utf-8');
  1127. echo "<span class='notify'>" . $this->lang->word('updating') . "</span>";
  1128. exit;
  1129. }
  1130. function sbmt_upd_jxdelimg()
  1131. {
  1132. global $go;
  1133. load_module_helper('files', $go['a']);
  1134. // id here really is the name of the file
  1135. $clean['media_id'] = $_POST['id'];
  1136. $this->db->deleteArray(PX.'media', "media_file='$clean[media_id]'");
  1137. deleteImage($clean['media_id']); // image
  1138. deleteImage($clean['media_id'], 'th'); // thumbnail
  1139. deleteImage($clean['media_id'], 'sys'); // system thumbnail
  1140. header ('Content-type: text/html; charset=utf-8');
  1141. echo "<span class='notify'>" . $this->lang->word('updating') . "</span>";
  1142. exit;
  1143. }
  1144. function sbmt_upd_jxs()
  1145. {
  1146. $clean['id'] = (int) $_POST['id'];
  1147. switch ($_POST['x']) {
  1148. case 'ajx-status':
  1149. if ($clean['id'] == 1) break;
  1150. $clean['status'] = (int) $_POST['v'];
  1151. $this->pub_status = $clean['status'];
  1152. $this->page_id = $clean['id'];
  1153. $this->publisher();
  1154. break;
  1155. case 'ajx-images':
  1156. $clean['images'] = (int) $_POST['v'];
  1157. break;
  1158. case 'ajx-thumbs':
  1159. $clean['thumbs'] = (int) $_POST['v'];
  1160. break;
  1161. case 'ajx-process':
  1162. $clean['process'] = (int) $_POST['v'];
  1163. break;
  1164. case 'ajx-hidden':
  1165. $clean['hidden'] = (int) $_POST['v'];
  1166. break;
  1167. case 'ajx-tiling':
  1168. $clean['tiling'] = (int) $_POST['v'];
  1169. break;
  1170. case 'color':
  1171. $clean['color'] = $_POST['v'];
  1172. break;
  1173. case 'year':
  1174. $clean['year'] = $_POST['v'];
  1175. break;
  1176. case 'present':
  1177. $clean['format'] = $_POST['v'];
  1178. break;
  1179. case 'break':
  1180. $clean['break'] = (int) $_POST['v'];
  1181. break;
  1182. case 'title':
  1183. if ($_POST['update_value'] == '') { echo 'Error'; exit; }
  1184. $clean['title'] = $_POST['update_value'];
  1185. $this->db->updateArray(PX.'objects', $clean, "id='$clean[id]'");
  1186. header ('Content-type: text/html; charset=utf-8');
  1187. echo $clean['title'];
  1188. exit;
  1189. break;
  1190. }
  1191. if ($clean['id'] > 0) $this->db->updateArray(PX.'objects', $clean, "id='$clean[id]'");
  1192. header ('Content-type: text/html; charset=utf-8');
  1193. echo "<span class='notify'>" . $this->lang->word('updating') . "</span>";
  1194. exit;
  1195. }
  1196. }
  1197. ?>