PageRenderTime 53ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 2ms

/system/cp/cp.publish_ad.php

https://github.com/danboy/Croissierd
PHP | 9837 lines | 6347 code | 2490 blank | 1000 comment | 1050 complexity | cb9f56f24aac85e72e5f9a15660ae259 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /*
  3. =====================================================
  4. ExpressionEngine - by EllisLab
  5. -----------------------------------------------------
  6. http://expressionengine.com/
  7. -----------------------------------------------------
  8. Copyright (c) 2003 - 2010 EllisLab, Inc.
  9. =====================================================
  10. THIS IS COPYRIGHTED SOFTWARE
  11. PLEASE READ THE LICENSE AGREEMENT
  12. http://expressionengine.com/docs/license.html
  13. =====================================================
  14. File: cp.publish_ad.php
  15. -----------------------------------------------------
  16. Purpose: The publish administration functions
  17. =====================================================
  18. */
  19. if ( ! defined('EXT'))
  20. {
  21. exit('Invalid file request');
  22. }
  23. class PublishAdmin {
  24. var $reserved = array('random', 'date', 'title', 'url_title', 'edit_date', 'comment_total', 'username', 'screen_name', 'most_recent_comment', 'expiration_date');
  25. // Default "open" and "closed" status colors
  26. var $status_color_open = '009933';
  27. var $status_color_closed = '990000';
  28. // Category arrays
  29. var $categories = array();
  30. var $cat_update = array();
  31. var $temp;
  32. /** -----------------------------------------------------------
  33. /** Constructor
  34. /** -----------------------------------------------------------*/
  35. // All it does it fetch the language file needed by the class
  36. //-----------------------------------------------------------
  37. function PublishAdmin()
  38. {
  39. global $LANG, $DSP;
  40. // Fetch language file
  41. $LANG->fetch_language_file('publish_ad');
  42. }
  43. /* END */
  44. /** -----------------------------------------------------------
  45. /** Weblog management page
  46. /** -----------------------------------------------------------*/
  47. // This function displays the "weblog management" page
  48. // accessed via the "admin" tab
  49. //-----------------------------------------------------------
  50. function weblog_overview($message = '')
  51. {
  52. global $LANG, $DSP, $DB, $PREFS;
  53. if ( ! $DSP->allowed_group('can_admin_weblogs'))
  54. {
  55. return $DSP->no_access_message();
  56. }
  57. $DSP->title = $LANG->line('weblog_management');
  58. $DSP->crumb = $DSP->anchor(BASE.AMP.'C=admin'.AMP.'area=weblog_administration', $LANG->line('weblog_administration'));
  59. $DSP->crumb .= $DSP->crumb_item($LANG->line('weblog_management'));
  60. $DSP->right_crumb($LANG->line('create_new_weblog'), BASE.AMP.'C=admin'.AMP.'M=blog_admin'.AMP.'P=new_weblog');
  61. // Fetch weblogs
  62. $query = $DB->query("SELECT weblog_id, blog_name, blog_title FROM exp_weblogs WHERE site_id = '".$DB->escape_str($PREFS->ini('site_id'))."' AND is_user_blog = 'n' ORDER BY blog_title");
  63. if ($query->num_rows == 0)
  64. {
  65. $DSP->body = $DSP->qdiv('tableHeading', $LANG->line('weblog_management'));
  66. $DSP->body .= $DSP->div('box');
  67. $DSP->body .= $DSP->qdiv('itemWrapper', $DSP->heading($LANG->line('no_weblogs_exist'), 5));
  68. $DSP->body .= $DSP->qdiv('itemWrapper', $DSP->anchor( BASE.AMP.'C=admin'.AMP.'M=blog_admin'.AMP.'P=new_weblog', $LANG->line('create_new_weblog')));
  69. $DSP->body .= $DSP->div_c();
  70. return;
  71. }
  72. $r = $DSP->qdiv('tableHeading', $LANG->line('weblog_management'));
  73. if ($message != '')
  74. {
  75. $r .= $DSP->qdiv('box', stripslashes($message));
  76. }
  77. $r .= $DSP->table('tableBorder', '0', '', '100%');
  78. $r .= $DSP->tr().
  79. $DSP->td('tableHeadingAlt', '30px').$LANG->line('weblog_id').$DSP->td_c().
  80. $DSP->td('tableHeadingAlt').$LANG->line('weblog_name').$DSP->td_c().
  81. $DSP->td('tableHeadingAlt', '', '4').$LANG->line('weblog_short_name').$DSP->td_c().
  82. $DSP->tr_c();
  83. $i = 0;
  84. foreach($query->result as $row)
  85. {
  86. $style = ($i % 2) ? 'tableCellOne' : 'tableCellTwo'; $i++;
  87. $r .= $DSP->tr();
  88. $r .= $DSP->table_qcell($style, $DSP->qspan('default', $row['weblog_id']));
  89. $r .= $DSP->table_qcell($style, $DSP->qspan('defaultBold', $row['blog_title']).$DSP->nbs(5));
  90. $r .= $DSP->table_qcell($style, $DSP->qspan('default', $row['blog_name']).$DSP->nbs(5));
  91. $r .= $DSP->table_qcell($style,
  92. $DSP->anchor(
  93. BASE.AMP.'C=admin'.AMP.'M=blog_admin'.AMP.'P=blog_prefs'.AMP.'weblog_id='.$row['weblog_id'],
  94. $LANG->line('edit_preferences')
  95. ));
  96. $r .= $DSP->table_qcell($style,
  97. $DSP->anchor(
  98. BASE.AMP.'C=admin'.AMP.'M=blog_admin'.AMP.'P=group_prefs'.AMP.'weblog_id='.$row['weblog_id'],
  99. $LANG->line('edit_groups')
  100. ));
  101. $r .= $DSP->table_qcell($style,
  102. $DSP->anchor(
  103. BASE.AMP.'C=admin'.AMP.'M=blog_admin'.AMP.'P=delete_conf'.AMP.'weblog_id='.$row['weblog_id'],
  104. $LANG->line('delete')
  105. ));
  106. $r .= $DSP->tr_c();
  107. }
  108. $r .= $DSP->table_c();
  109. // Assign output data
  110. $DSP->body = $r;
  111. }
  112. /* END */
  113. /** --------------------------------------------------------------
  114. /** "Create new weblog" form
  115. /** --------------------------------------------------------------*/
  116. // This function displays the form used to create a new weblog
  117. //--------------------------------------------------------------
  118. function new_weblog_form()
  119. {
  120. global $DSP, $IN, $DB, $REGX, $LANG, $FNS, $PREFS;
  121. if ( ! $DSP->allowed_group('can_admin_weblogs'))
  122. {
  123. return $DSP->no_access_message();
  124. }
  125. $r = <<<EOT
  126. <script type="text/javascript">
  127. <!--
  128. function show_hide(id)
  129. {
  130. if (document.getElementById(id))
  131. {
  132. if (document.getElementById(id).style.display == 'none')
  133. {
  134. document.getElementById(id).style.display = 'block';
  135. }
  136. else
  137. {
  138. document.getElementById(id).style.display = 'none';
  139. }
  140. }
  141. }
  142. //-->
  143. </script>
  144. EOT;
  145. $r .= $DSP->form_open(array('action' => 'C=admin'.AMP.'M=blog_admin'.AMP.'P=create_blog'));
  146. $r .= $DSP->table('tableBorder', '0', '', '100%');
  147. $r .= $DSP->tr()
  148. .$DSP->td('tableHeading', '', '2').$LANG->line('create_new_weblog').$DSP->td_c()
  149. .$DSP->tr_c();
  150. // Weblog "full name" field
  151. $r .= $DSP->tr().
  152. $DSP->table_qcell('tableCellTwo', $DSP->required().NBS.$DSP->qspan('defaultBold', $LANG->line('full_weblog_name', 'blog_title'))).
  153. $DSP->table_qcell('tableCellTwo', $DSP->input_text('blog_title', '', '20', '100', 'input', '260px')).
  154. $DSP->tr_c();
  155. // Weblog "short name" field
  156. $r .= $DSP->tr().
  157. $DSP->table_qcell('tableCellOne', $DSP->required().NBS.$DSP->qspan('defaultBold', $LANG->line('short_weblog_name', 'blog_name')).$DSP->qdiv('', $LANG->line('single_word_no_spaces')), '40%').
  158. $DSP->table_qcell('tableCellOne', $DSP->input_text('blog_name', '', '20', '40', 'input', '260px'), '60%').
  159. $DSP->tr_c();
  160. // Duplicate Preferences Select List
  161. $r .= $DSP->tr().
  162. $DSP->table_qcell('tableCellTwo', $DSP->qspan('defaultBold', $LANG->line('duplicate_weblog_prefs')));
  163. $w = $DSP->input_select_header('duplicate_weblog_prefs');
  164. $w .= $DSP->input_select_option('', $LANG->line('do_not_duplicate'));
  165. $wquery = $DB->query("SELECT weblog_id, blog_title FROM exp_weblogs WHERE site_id = '".$DB->escape_str($PREFS->ini('site_id'))."' ORDER BY blog_name");
  166. if ($wquery->num_rows > 0)
  167. {
  168. foreach($wquery->result as $row)
  169. {
  170. $w .= $DSP->input_select_option($row['weblog_id'], $row['blog_title']);
  171. }
  172. }
  173. $w .= $DSP->input_select_footer();
  174. $r .= $DSP->table_qcell('tableCellTwo', $w).
  175. $DSP->tr_c();
  176. // Edit Group Preferences option
  177. $r .= $DSP->tr().
  178. $DSP->table_qcell('tableCellOne', $DSP->qspan('defaultBold', $LANG->line('edit_group_prefs')), '40%').
  179. $DSP->table_qcell('tableCellOne', $DSP->input_radio('edit_group_prefs', 'y', '', 'onclick="show_hide(\'group_preferences\');"').
  180. NBS.$LANG->line('yes').
  181. NBS.NBS.
  182. $DSP->input_radio('edit_group_prefs', 'n', 1, 'onclick="show_hide(\'group_preferences\');"').
  183. NBS.$LANG->line('no'), '60%').
  184. $DSP->tr_c();
  185. $r .= $DSP->table_c().BR;
  186. // GROUP FIELDS
  187. $g = '';
  188. $i = 0;
  189. $cat_group = '';
  190. $status_group = '';
  191. $field_group = '';
  192. $r .= $DSP->div('', '', 'group_preferences', '', 'style="display:none;"');
  193. $r .= $DSP->table('tableBorder', '0', '', '100%');
  194. $r .= $DSP->tr().
  195. $DSP->td('tableHeadingAlt', '100%', 2).$LANG->line('edit_group_prefs').$DSP->td_c().
  196. $DSP->tr_c();
  197. // Category group select list
  198. $style = ($i % 2) ? 'tableCellOne' : 'tableCellTwo'; $i++;
  199. $query = $DB->query("SELECT group_id, group_name FROM exp_category_groups WHERE site_id = '".$DB->escape_str($PREFS->ini('site_id'))."' ORDER BY group_name");
  200. $g .= $DSP->tr().
  201. $DSP->table_qcell($style, $DSP->qspan('defaultBold', $LANG->line('category_group')), '40%', 'top');
  202. $g .= $DSP->td($style).
  203. $DSP->input_select_header('cat_group[]', ($query->num_rows > 0) ? 'y' : '');
  204. $selected = '';
  205. $g .= $DSP->input_select_option('', $LANG->line('none'), $selected);
  206. if ($query->num_rows > 0)
  207. {
  208. foreach ($query->result as $row)
  209. {
  210. $g .= $DSP->input_select_option($row['group_id'], $row['group_name']);
  211. }
  212. }
  213. $g .= $DSP->input_select_footer().
  214. $DSP->td_c().
  215. $DSP->tr_c();
  216. // Status group select list
  217. $style = ($i % 2) ? 'tableCellOne' : 'tableCellTwo'; $i++;
  218. $query = $DB->query("SELECT group_id, group_name FROM exp_status_groups WHERE site_id = '".$DB->escape_str($PREFS->ini('site_id'))."' ORDER BY group_name");
  219. $g .= $DSP->tr().
  220. $DSP->table_qcell($style, $DSP->qspan('defaultBold', $LANG->line('status_group')));
  221. $g .= $DSP->td($style).
  222. $DSP->input_select_header('status_group');
  223. $selected = '';
  224. $g .= $DSP->input_select_option('', $LANG->line('none'), $selected);
  225. if ($query->num_rows > 0)
  226. {
  227. foreach ($query->result as $row)
  228. {
  229. $selected = ($status_group == $row['group_id']) ? 1 : '';
  230. $g .= $DSP->input_select_option($row['group_id'], $row['group_name'], $selected);
  231. }
  232. }
  233. $g .= $DSP->input_select_footer().
  234. $DSP->td_c().
  235. $DSP->tr_c();
  236. // Field group select list
  237. $style = ($i % 2) ? 'tableCellOne' : 'tableCellTwo'; $i++;
  238. $query = $DB->query("SELECT group_id, group_name FROM exp_field_groups WHERE site_id = '".$DB->escape_str($PREFS->ini('site_id'))."' ORDER BY group_name");
  239. $g .= $DSP->tr().
  240. $DSP->table_qcell($style, $DSP->qspan('defaultBold', $LANG->line('field_group')));
  241. $g .= $DSP->td($style).
  242. $DSP->input_select_header('field_group');
  243. $selected = '';
  244. $g .= $DSP->input_select_option('', $LANG->line('none'), $selected);
  245. if ($query->num_rows > 0)
  246. {
  247. foreach ($query->result as $row)
  248. {
  249. $selected = ($field_group == $row['group_id']) ? 1 : '';
  250. $g .= $DSP->input_select_option($row['group_id'], $row['group_name'], $selected);
  251. }
  252. }
  253. $g .= $DSP->input_select_footer().
  254. $DSP->td_c().
  255. $DSP->tr_c().
  256. $DSP->table_c().BR.
  257. $DSP->div_c();
  258. $r .= $g;
  259. // Table end
  260. // Create Template
  261. if ($DSP->allowed_group('can_admin_templates'))
  262. {
  263. $r .= $DSP->table('tableBorder', '0', '', '100%')
  264. .$DSP->tr()
  265. .$DSP->td('tableHeadingAlt', '', '3').$LANG->line('template_creation').$DSP->td_c()
  266. .$DSP->tr_c();
  267. $r .= $DSP->tr()
  268. .$DSP->table_qcell('tableCellOne', $DSP->input_radio('create_templates', 'no', 1), '2%')
  269. .$DSP->td('tableCellOne', '', '3').$DSP->qdiv('defaultBold', $LANG->line('no')).$DSP->td_c()
  270. .$DSP->tr_c();
  271. $data = $FNS->create_directory_map(PATH_THEMES.'site_themes/', TRUE);
  272. $d = '&nbsp;';
  273. if (count($data) > 0)
  274. {
  275. $d = $DSP->input_select_header('template_theme');
  276. foreach ($data as $val)
  277. {
  278. if ($val == 'rss.php')
  279. continue;
  280. if ( ! file_exists(PATH_THEMES.'site_themes/'.$val.'/'.$val.'.php'))
  281. {
  282. continue;
  283. }
  284. $nval = str_replace("_", " ", $val);
  285. $nval = ucwords($nval);
  286. $d .= $DSP->input_select_option($val, $nval);
  287. }
  288. $d .= $DSP->input_select_footer();
  289. }
  290. $r .= $DSP->tr()
  291. .$DSP->table_qcell('tableCellTwo', $DSP->input_radio('create_templates', 'theme', ''), '2%', 'top')
  292. .$DSP->table_qcell('tableCellTwo', $DSP->qdiv('defaultBold', $LANG->line('use_a_theme'), '38%')
  293. .$DSP->qdiv('itemWrapper',$DSP->input_checkbox('add_rss', 'y', 0).' '.$LANG->line('include_rss_templates')))
  294. .$DSP->table_qcell('tableCellTwo', $d, '60%')
  295. .$DSP->tr_c();
  296. $sql = "SELECT group_id, group_name, exp_sites.site_label
  297. FROM exp_template_groups, exp_sites
  298. WHERE exp_template_groups.site_id = exp_sites.site_id ";
  299. if ($PREFS->ini('multiple_sites_enabled') !== 'y')
  300. {
  301. $sql .= "AND exp_template_groups.site_id = '1' ";
  302. }
  303. if (USER_BLOG == TRUE)
  304. {
  305. $sql .= "AND exp_template_groups.group_id = '".$SESS->userdata['tmpl_group_id']."'";
  306. }
  307. else
  308. {
  309. $sql .= "AND exp_template_groups.is_user_blog = 'n'";
  310. }
  311. $sql .= " ORDER BY exp_template_groups.group_name";
  312. $query = $DB->query($sql);
  313. $d = $DSP->input_select_header('old_group_id');
  314. foreach ($query->result as $row)
  315. {
  316. $d .= $DSP->input_select_option($row['group_id'], ($PREFS->ini('multiple_sites_enabled') == 'y') ? $row['site_label'].NBS.'-'.NBS.$row['group_name'] : $row['group_name']);
  317. }
  318. $d .= $DSP->input_select_footer();
  319. $r .= $DSP->tr()
  320. .$DSP->table_qcell('tableCellOne', $DSP->input_radio('create_templates', 'duplicate', ''))
  321. .$DSP->table_qcell('tableCellOne', $DSP->qdiv('defaultBold', $LANG->line('duplicate_group')))
  322. .$DSP->table_qcell('tableCellOne', $d)
  323. .$DSP->tr_c();
  324. $r .= $DSP->tr()
  325. .$DSP->table_qcell('tableCellTwo', NBS)
  326. .$DSP->table_qcell('tableCellTwo', $DSP->qdiv('defaultBold', $DSP->required().$LANG->line('template_group_name')).$DSP->qdiv('', $LANG->line('new_group_instructions')).$DSP->qdiv('', $LANG->line('single_word_no_spaces')))
  327. .$DSP->td('tableCellTwo', '', '').$DSP->input_text('group_name', '', '16', '50', 'input', '130px').$DSP->td_c()
  328. .$DSP->tr_c();
  329. $r .= $DSP->table_c();
  330. }
  331. // Submit button
  332. $r .= $DSP->qdiv('itemWrapper', $DSP->required(1));
  333. $r .= $DSP->qdiv('', $DSP->input_submit($LANG->line('submit')));
  334. $r .= $DSP->form_close();
  335. // Assign output data
  336. $DSP->title = $LANG->line('create_new_weblog');
  337. $DSP->crumb = $DSP->anchor(BASE.AMP.'C=admin'.AMP.'area=weblog_administration', $LANG->line('weblog_administration')).
  338. $DSP->crumb_item($DSP->anchor(BASE.AMP.'C=admin'.AMP.'M=blog_admin'.AMP.'P=blog_list', $LANG->line('weblog_management'))).
  339. $DSP->crumb_item($LANG->line('new_weblog'));
  340. $DSP->body = $r;
  341. }
  342. /* END */
  343. /** -----------------------------------------------------------
  344. /** Weblog preference submission handler
  345. /** -----------------------------------------------------------*/
  346. // This function receives the submitted weblog preferences
  347. // and stores them in the database.
  348. //-----------------------------------------------------------
  349. function update_weblog_prefs()
  350. {
  351. global $DSP, $IN, $DB, $LOG, $LANG, $FNS, $PREFS, $SESS, $LOC;
  352. if ( ! $DSP->allowed_group('can_admin_weblogs'))
  353. {
  354. return $DSP->no_access_message();
  355. }
  356. // If the $weblog_id variable is present we are editing an
  357. // existing weblog, otherwise we are creating a new one
  358. $edit = (isset($_POST['weblog_id'])) ? TRUE : FALSE;
  359. $add_rss = (isset($_POST['add_rss'])) ? TRUE : FALSE;
  360. unset($_POST['add_rss']);
  361. $return = ($IN->GBL('return')) ? TRUE : FALSE;
  362. unset($_POST['return']);
  363. unset($_POST['edit_group_prefs']);
  364. $dupe_id = $IN->GBL('duplicate_weblog_prefs');
  365. unset($_POST['duplicate_weblog_prefs']);
  366. // Check for required fields
  367. $error = array();
  368. if ($_POST['blog_name'] == '')
  369. {
  370. $error[] = $LANG->line('no_weblog_name');
  371. }
  372. if ($_POST['blog_title'] == '')
  373. {
  374. $error[] = $LANG->line('no_weblog_title');
  375. }
  376. if (preg_match('/[^a-z0-9\-\_]/i', $_POST['blog_name']))
  377. {
  378. $error[] = $LANG->line('invalid_short_name');
  379. }
  380. if (isset($_POST['url_title_prefix']) && $_POST['url_title_prefix'] != '')
  381. {
  382. $_POST['url_title_prefix'] = strtolower(strip_tags($_POST['url_title_prefix']));
  383. if ( ! preg_match("/^[\w\-]+$/", $_POST['url_title_prefix']))
  384. {
  385. $error[] = $LANG->line('invalid_url_title_prefix');
  386. }
  387. }
  388. if (count($error) > 0)
  389. {
  390. $msg = '';
  391. foreach($error as $val)
  392. {
  393. $msg .= $val.BR;
  394. }
  395. return $DSP->error_message($msg);
  396. }
  397. if (isset($_POST['comment_expiration']))
  398. {
  399. if ( ! is_numeric($_POST['comment_expiration']) || $_POST['comment_expiration'] == '')
  400. {
  401. $_POST['comment_expiration'] = 0;
  402. }
  403. }
  404. // Is the weblog name taken?
  405. $sql = "SELECT COUNT(*) AS count FROM exp_weblogs WHERE site_id = '".$DB->escape_str($PREFS->ini('site_id'))."' AND blog_name = '".$DB->escape_str($_POST['blog_name'])."'";
  406. if ($edit == TRUE)
  407. {
  408. $sql .= " AND weblog_id != '".$DB->escape_str($_POST['weblog_id'])."'";
  409. }
  410. $query = $DB->query($sql);
  411. if ($query->row['count'] > 0)
  412. {
  413. return $DSP->error_message($LANG->line('taken_weblog_name'));
  414. }
  415. /** -----------------------------------------
  416. /** Template Error Trapping
  417. /** -----------------------------------------*/
  418. if ($edit == FALSE)
  419. {
  420. $create_templates = $IN->GBL('create_templates');
  421. $old_group_id = $IN->GBL('old_group_id');
  422. $group_name = strtolower($IN->GBL('group_name', 'POST'));
  423. $template_theme = $FNS->filename_security($IN->GBL('template_theme'));
  424. unset($_POST['create_templates']);
  425. unset($_POST['old_group_id']);
  426. unset($_POST['group_name']);
  427. unset($_POST['template_theme']);
  428. if ($create_templates != 'no')
  429. {
  430. $LANG->fetch_language_file('templates');
  431. if ( ! $DSP->allowed_group('can_admin_templates'))
  432. {
  433. return $DSP->no_access_message();
  434. }
  435. if ( ! $group_name)
  436. {
  437. return $DSP->error_message($LANG->line('group_required'));
  438. }
  439. if ( ! preg_match("#^[a-zA-Z0-9_\-/]+$#i", $group_name))
  440. {
  441. return $DSP->error_message($LANG->line('illegal_characters'));
  442. }
  443. $reserved[] = 'act';
  444. $reserved[] = 'trackback';
  445. if ($PREFS->ini("forum_is_installed") == 'y' AND $PREFS->ini("forum_trigger") != '')
  446. {
  447. $reserved[] = $PREFS->ini("forum_trigger");
  448. }
  449. if (in_array($group_name, $reserved))
  450. {
  451. return $DSP->error_message($LANG->line('reserved_name'));
  452. }
  453. $query = $DB->query("SELECT COUNT(*) AS count FROM exp_template_groups
  454. WHERE site_id = '".$DB->escape_str($PREFS->ini('site_id'))."'
  455. AND group_name = '".$DB->escape_str($group_name)."'");
  456. if ($query->row['count'] > 0)
  457. {
  458. return $DSP->error_message($LANG->line('template_group_taken'));
  459. }
  460. }
  461. }
  462. /** -----------------------------------------
  463. /** Create Weblog
  464. /** -----------------------------------------*/
  465. // Construct the query based on whether we are updating or inserting
  466. if (isset($_POST['apply_expiration_to_existing']))
  467. {
  468. $this->update_comment_expiration($_POST['weblog_id'], $_POST['comment_expiration']);
  469. }
  470. unset($_POST['apply_expiration_to_existing']);
  471. if (isset($_POST['cat_group']) && is_array($_POST['cat_group']))
  472. {
  473. foreach($_POST['cat_group'] as $key => $value)
  474. {
  475. unset($_POST['cat_group_'.$key]);
  476. }
  477. $_POST['cat_group'] = implode('|', $_POST['cat_group']);
  478. }
  479. if ($edit == FALSE)
  480. {
  481. unset($_POST['weblog_id']);
  482. unset($_POST['clear_versioning_data']);
  483. $_POST['blog_url'] = $FNS->fetch_site_index();
  484. $_POST['blog_lang'] = $PREFS->ini('xml_lang');
  485. $_POST['blog_encoding'] = $PREFS->ini('charset');
  486. // Assign field group if there is only one
  487. if ( ! isset($_POST['field_group']) OR (isset($_POST['field_group']) && ! is_numeric($_POST['field_group'])))
  488. {
  489. $query = $DB->query("SELECT group_id FROM exp_field_groups WHERE site_id = '".$DB->escape_str($PREFS->ini('site_id'))."'");
  490. if ($query->num_rows == 1)
  491. {
  492. $_POST['field_group'] = $query->row['group_id'];
  493. }
  494. }
  495. // Insert data
  496. $_POST['site_id'] = $PREFS->ini('site_id');
  497. // duplicating preferences?
  498. if ($dupe_id !== FALSE AND is_numeric($dupe_id))
  499. {
  500. $wquery = $DB->query("SELECT * FROM exp_weblogs WHERE weblog_id = '".$DB->escape_str($dupe_id)."'");
  501. if ($wquery->num_rows == 1)
  502. {
  503. $exceptions = array('weblog_id', 'site_id', 'blog_name', 'blog_title', 'total_entries',
  504. 'total_comments', 'total_trackbacks', 'last_entry_date', 'last_comment_date',
  505. 'last_trackback_date');
  506. foreach($wquery->row as $key => $val)
  507. {
  508. // don't duplicate fields that are unique to each weblog
  509. if (! in_array($key, $exceptions))
  510. {
  511. switch ($key)
  512. {
  513. // category, field, and status fields should only be duped
  514. // if both weblogs are assigned to the same group of each
  515. case 'cat_group':
  516. // allow to implicitly set category group to "None"
  517. if (! isset($_POST[$key]))
  518. {
  519. $_POST[$key] = $val;
  520. }
  521. break;
  522. case 'status_group':
  523. case 'field_group':
  524. if (! isset($_POST[$key]) OR $_POST[$key] == '')
  525. {
  526. $_POST[$key] = $val;
  527. }
  528. break;
  529. case 'deft_status':
  530. if (! isset($_POST['status_group']) OR $_POST['status_group'] == $wquery->row['status_group'])
  531. {
  532. $_POST[$key] = $val;
  533. }
  534. break;
  535. case 'search_excerpt':
  536. if (! isset($_POST['field_group']) OR $_POST['field_group'] == $wquery->row['field_group'])
  537. {
  538. $_POST[$key] = $val;
  539. }
  540. break;
  541. case 'deft_category':
  542. if (! isset($_POST['cat_group']) OR count(array_diff(explode('|', $_POST['cat_group']), explode('|', $wquery->row['cat_group']))) == 0)
  543. {
  544. $_POST[$key] = $val;
  545. }
  546. break;
  547. case 'blog_url':
  548. case 'comment_url':
  549. case 'search_results_url':
  550. case 'tb_return_url':
  551. case 'ping_return_url':
  552. case 'rss_url':
  553. if ($create_templates != 'no')
  554. {
  555. if ( ! isset($old_group_name))
  556. {
  557. $gquery = $DB->query("SELECT group_name FROM exp_template_groups WHERE group_id = '".$DB->escape_str($old_group_id)."'");
  558. $old_group_name = $gquery->row['group_name'];
  559. }
  560. $_POST[$key] = str_replace("/{$old_group_name}/", "/{$group_name}/", $val);
  561. }
  562. else
  563. {
  564. $_POST[$key] = $val;
  565. }
  566. break;
  567. default :
  568. $_POST[$key] = $val;
  569. break;
  570. }
  571. }
  572. }
  573. }
  574. }
  575. $sql = $DB->insert_string('exp_weblogs', $_POST);
  576. $DB->query($sql);
  577. $insert_id = $DB->insert_id;
  578. $weblog_id = $insert_id;
  579. $success_msg = $LANG->line('weblog_created');
  580. $crumb = $DSP->crumb_item($LANG->line('new_weblog'));
  581. $LOG->log_action($success_msg.$DSP->nbs(2).$_POST['blog_title']);
  582. }
  583. else
  584. {
  585. if (isset($_POST['clear_versioning_data']))
  586. {
  587. $DB->query("DELETE FROM exp_entry_versioning WHERE weblog_id = '".$DB->escape_str($_POST['weblog_id'])."'");
  588. unset($_POST['clear_versioning_data']);
  589. }
  590. $sql = $DB->update_string('exp_weblogs', $_POST, 'weblog_id='.$DB->escape_str($_POST['weblog_id']));
  591. $DB->query($sql);
  592. $weblog_id = $DB->escape_str($_POST['weblog_id']);
  593. $success_msg = $LANG->line('weblog_updated');
  594. $crumb = $DSP->crumb_item($LANG->line('update'));
  595. }
  596. /** -----------------------------------------
  597. /** Create Templates
  598. /** -----------------------------------------*/
  599. if ($edit == FALSE)
  600. {
  601. if ($create_templates != 'no')
  602. {
  603. $query = $DB->query("SELECT COUNT(*) AS count FROM exp_template_groups WHERE is_user_blog = 'n'");
  604. $group_order = $query->row['count'] +1;
  605. $DB->query(
  606. $DB->insert_string(
  607. 'exp_template_groups',
  608. array(
  609. 'group_id' => '',
  610. 'group_name' => $group_name,
  611. 'group_order' => $group_order,
  612. 'is_site_default' => 'n',
  613. 'site_id' => $PREFS->ini('site_id')
  614. )
  615. )
  616. );
  617. $group_id = $DB->insert_id;
  618. if ($create_templates == 'duplicate')
  619. {
  620. $query = $DB->query("SELECT group_name FROM exp_template_groups WHERE group_id = '".$DB->escape_str($old_group_id)."'");
  621. $old_group_name = $query->row['group_name'];
  622. $query = $DB->query("SELECT template_name, template_data, template_type, template_notes, cache, refresh, no_auth_bounce, allow_php, php_parse_location FROM exp_templates WHERE group_id = '".$DB->escape_str($old_group_id)."'");
  623. if ($query->num_rows == 0)
  624. {
  625. $DB->query(
  626. $DB->insert_string(
  627. 'exp_templates',
  628. array(
  629. 'template_id' => '',
  630. 'group_id' => $group_id,
  631. 'template_name' => 'index',
  632. 'edit_date' => $LOC->now,
  633. 'site_id' => $PREFS->ini('site_id')
  634. )
  635. )
  636. );
  637. }
  638. else
  639. {
  640. $old_blog_name = '';
  641. foreach ($query->result as $row)
  642. {
  643. if ($old_blog_name == '')
  644. {
  645. if (preg_match_all("/weblog=[\"'](.+?)[\"']/", $row['template_data'], $matches))
  646. {
  647. for ($i = 0; $i < count($matches['1']); $i++)
  648. {
  649. if (substr($matches['1'][$i], 0, 1) != '{')
  650. {
  651. $old_blog_name = $matches['1'][$i];
  652. break;
  653. }
  654. }
  655. }
  656. }
  657. $temp = str_replace('weblog="'.$old_blog_name.'"', 'weblog="'.$_POST['blog_name'].'"', $row['template_data']);
  658. $temp = str_replace("weblog='".$old_blog_name."'", 'weblog="'.$_POST['blog_name'].'"', $temp);
  659. $temp = preg_replace("/{stylesheet=.+?\/(.+?)}/", "{stylesheet=".$group_name."/\\1}", $temp);
  660. $temp = preg_replace("#assign_variable:master_weblog_name=\".+?\"#", 'assign_variable:master_weblog_name="'.$_POST['blog_name'].'"', $temp);
  661. $temp = preg_replace("#assign_variable:master_weblog_name=\'.+?\'#", "assign_variable:master_weblog_name='".$_POST['blog_name']."'", $temp);
  662. $temp = preg_replace('#assign_variable:my_template_group=(\042|\047)([^\\1]*?)\\1#', "assign_variable:my_template_group=\\1{$group_name}\\1", $temp);
  663. $temp = preg_replace("#".$old_group_name."/(.+?)#", $group_name."/\\1", $temp);
  664. $data = array(
  665. 'template_id' => '',
  666. 'group_id' => $group_id,
  667. 'template_name' => $row['template_name'],
  668. 'template_notes' => $row['template_notes'],
  669. 'cache' => $row['cache'],
  670. 'refresh' => $row['refresh'],
  671. 'no_auth_bounce' => $row['no_auth_bounce'],
  672. 'php_parse_location' => $row['php_parse_location'],
  673. 'allow_php' => ($SESS->userdata['group_id'] == 1) ? $row['allow_php'] : 'n',
  674. 'template_type' => $row['template_type'],
  675. 'template_data' => $temp,
  676. 'edit_date' => $LOC->now,
  677. 'site_id' => $PREFS->ini('site_id')
  678. );
  679. $DB->query($DB->insert_string('exp_templates', $data));
  680. }
  681. }
  682. }
  683. else
  684. {
  685. $type = 'core';
  686. if ($fp = @opendir(PATH_MOD))
  687. {
  688. while (false !== ($file = readdir($fp)))
  689. {
  690. if (strpos($file, '.') === FALSE)
  691. {
  692. if ($file == 'mailinglist')
  693. {
  694. $type = 'full';
  695. break;
  696. }
  697. }
  698. }
  699. closedir($fp);
  700. }
  701. require PATH_THEMES.'site_themes/'.$template_theme.'/'.$template_theme.'.php';
  702. foreach ($template_matrix as $tmpl)
  703. {
  704. $Q[] = array($tmpl['0'](), "INSERT INTO exp_templates(template_id, group_id, template_name, template_type, template_data, edit_date, site_id)
  705. VALUES ('', '$group_id', '".$DB->escape_str($tmpl['0'])."', '".$DB->escape_str($tmpl['1'])."', '{template}', '".$LOC->now."', '".$DB->escape_str($PREFS->ini('site_id'))."')");
  706. }
  707. if ($add_rss == TRUE)
  708. {
  709. require PATH_THEMES.'site_themes/rss/rss.php';
  710. $Q[] = array(rss_2(), "INSERT INTO exp_templates(template_id, group_id, template_name, template_type, template_data, edit_date, site_id)
  711. VALUES ('', '$group_id', 'rss_2.0', 'rss', '{template}', '".$DB->escape_str($LOC->now)."', '".$DB->escape_str($PREFS->ini('site_id'))."')");
  712. $Q[] = array(atom(), "INSERT INTO exp_templates(template_id, group_id, template_name, template_type, template_data, edit_date, site_id)
  713. VALUES ('', '$group_id', 'atom', 'rss', '{template}', '".$DB->escape_str($LOC->now)."', '".$DB->escape_str($PREFS->ini('site_id'))."')");
  714. }
  715. foreach ($Q as $val)
  716. {
  717. $temp = $val['0'];
  718. $temp = str_replace('weblog="weblog1"', 'weblog="'.$_POST['blog_name'].'"', $temp);
  719. $temp = str_replace("weblog='weblog1'", 'weblog="'.$_POST['blog_name'].'"', $temp);
  720. $temp = str_replace('my_weblog="weblog1"', 'my_weblog="'.$_POST['blog_name'].'"', $temp);
  721. $temp = str_replace("my_weblog='weblog1'", 'my_weblog="'.$_POST['blog_name'].'"', $temp);
  722. $temp = str_replace('weblog="default_site"', 'weblog="'.$_POST['blog_name'].'"', $temp);
  723. $temp = str_replace("weblog='default_site'", 'weblog="'.$_POST['blog_name'].'"', $temp);
  724. $temp = str_replace('my_weblog="default_site"', 'my_weblog="'.$_POST['blog_name'].'"', $temp);
  725. $temp = str_replace("my_weblog='default_site'", 'my_weblog="'.$_POST['blog_name'].'"', $temp);
  726. $temp = str_replace('my_template_group="site"', 'my_template_group="'.$group_name.'"', $temp);
  727. $temp = str_replace("my_template_group='site'", 'my_template_group="'.$group_name.'"', $temp);
  728. $temp = str_replace("{stylesheet=weblog/weblog_css}", "{stylesheet=".$group_name."/site_css}", $temp);
  729. $temp = str_replace("{stylesheet=site/site_css}", "{stylesheet=".$group_name."/site_css}", $temp);
  730. $temp = str_replace('assign_variable:master_weblog_name="weblog1"', 'assign_variable:master_weblog_name="'.$_POST['blog_name'].'"', $temp);
  731. $temp = preg_replace("#weblog/(.+?)#", $group_name."/\\1", $temp);
  732. $temp = addslashes($temp);
  733. $sql = str_replace('{template}', $temp, $val['1']);
  734. $DB->query($sql);
  735. }
  736. }
  737. }
  738. }
  739. $message = $DSP->qdiv('itemWrapper', $DSP->qspan('success', $success_msg).NBS.NBS.'<b>'.$_POST['blog_title'].'</b>');
  740. if ($edit == FALSE OR $return === TRUE)
  741. return $this->weblog_overview($message);
  742. else
  743. return $this->edit_blog_form($message, $weblog_id);
  744. }
  745. /* END */
  746. /** -------------------------------------------
  747. /** Update weblog entries with comment expiration
  748. /** -------------------------------------------*/
  749. function update_comment_expiration($weblog_id = '', $expiration = '')
  750. {
  751. global $DSP, $IN, $DB, $LOG, $LANG, $FNS, $PREF;
  752. if ( ! $DSP->allowed_group('can_admin_weblogs'))
  753. {
  754. return $DSP->no_access_message();
  755. }
  756. if ($weblog_id == '')
  757. {
  758. return FALSE;
  759. }
  760. if ($expiration == '')
  761. $expiration = 0;
  762. $time = $expiration * 86400;
  763. $expdate = '';
  764. $query = $DB->query("SELECT entry_id, entry_date FROM exp_weblog_titles WHERE weblog_id = '".$DB->escape_str($weblog_id)."'");
  765. if ($query->num_rows > 0)
  766. {
  767. foreach ($query->result as $row)
  768. {
  769. if ($expiration > 0)
  770. {
  771. $expdate = $row['entry_date'] + $time;
  772. }
  773. $DB->query("UPDATE exp_weblog_titles SET comment_expiration_date = '$expdate' WHERE entry_id = '".$DB->escape_str($row['entry_id'])."'");
  774. }
  775. }
  776. return;
  777. }
  778. /* END */
  779. /** -------------------------------------------
  780. /** Create pull-down optios from dirctory map
  781. /** -------------------------------------------*/
  782. function render_map_as_select_options($zarray, $array_name = '')
  783. {
  784. foreach ($zarray as $key => $val)
  785. {
  786. if ( is_array($val))
  787. {
  788. if ($array_name != "")
  789. $key = $array_name.'/'.$key;
  790. $this->render_map_as_select_options($val, $key);
  791. }
  792. else
  793. {
  794. if ($array_name <> "")
  795. $val = $array_name.'/'.$val;
  796. if (substr($val, -4) == '.php')
  797. {
  798. if ($val != 'theme_master.php')
  799. {
  800. $this->template_map[] = $val;
  801. }
  802. }
  803. }
  804. }
  805. }
  806. /* END */
  807. /** -----------------------------------------------------------
  808. /** Weblog preferences form
  809. /** -----------------------------------------------------------*/
  810. // This function displays the form used to edit the various
  811. // preferences for a given weblog
  812. //-----------------------------------------------------------
  813. function edit_blog_form($msg='', $weblog_id='')
  814. {
  815. global $DSP, $IN, $DB, $REGX, $LANG, $FNS, $PREFS;
  816. if ( ! $DSP->allowed_group('can_admin_weblogs'))
  817. {
  818. return $DSP->no_access_message();
  819. }
  820. // Set default values
  821. $i = 0;
  822. $blog_name = '';
  823. $blog_title = '';
  824. $cat_group = '';
  825. $status_group = '';
  826. // If we don't have the $weblog_id variable, bail out.
  827. if ($weblog_id == '')
  828. {
  829. if ( ! $weblog_id = $IN->GBL('weblog_id'))
  830. {
  831. return FALSE;
  832. }
  833. }
  834. if ( ! is_numeric($weblog_id))
  835. {
  836. return FALSE;
  837. }
  838. $query = $DB->query("SELECT * FROM exp_weblogs WHERE weblog_id = '$weblog_id'");
  839. foreach ($query->row as $key => $val)
  840. {
  841. $$key = $val;
  842. }
  843. if ($msg != '')
  844. {
  845. $DSP->body .= $DSP->qdiv('box', $msg);
  846. }
  847. $DSP->body_props .= ' onload="showHideMenu(\'weblog\');"';
  848. // Build the output
  849. ob_start();
  850. ?>
  851. <script type="text/javascript">
  852. <!--
  853. var lastShownObj = '';
  854. var lastShownColor = '';
  855. function showHideMenu(objValue)
  856. {
  857. if (lastShownObj != '')
  858. {
  859. document.getElementById(lastShownObj+'_pointer').getElementsByTagName('a')[0].style.color = lastShownColor;
  860. document.getElementById(lastShownObj + '_on').style.display = 'none';
  861. }
  862. lastShownObj = objValue;
  863. lastShownColor = document.getElementById(objValue+'_pointer').getElementsByTagName('a')[0].style.color;
  864. document.getElementById(objValue + '_on').style.display = 'block';
  865. document.getElementById(objValue+'_pointer').getElementsByTagName('a')[0].style.color = '#000';
  866. }
  867. //-->
  868. </script>
  869. <?php
  870. $buffer = ob_get_contents();
  871. ob_end_clean();
  872. $DSP->body .= $buffer;
  873. // Third table cell contains are preferences in hidden <div>'s
  874. $r = $DSP->form_open(array('action' => 'C=admin'.AMP.'M=blog_admin'.AMP.'P=update_preferences'));
  875. $r .= $DSP->input_hidden('weblog_id', $weblog_id);
  876. $r .= $DSP->qdiv('default', '', 'menu_contents');
  877. $r .= '<div id="weblog_on" style="display: none; padding:0; margin: 0;">';
  878. $r .= $DSP->table('tableBorder', '0', '', '100%');
  879. $r .= $DSP->tr();
  880. $r .= "<td class='tableHeadingAlt' id='weblog2' colspan='2'>";
  881. $r .= NBS.$LANG->line('weblog_base_setup').$DSP->td_c();
  882. $r .= $DSP->tr_c();
  883. /** -------------------------
  884. /** General settings
  885. /** ------------------------*/
  886. // Weblog "full name" field
  887. $style = ($i++ % 2) ? 'tableCellOne' : 'tableCellTwo' ;
  888. $r .= $DSP->tr().
  889. $DSP->table_qcell($style, $DSP->required().NBS.$DSP->qspan('defaultBold', $LANG->line('full_weblog_name', 'blog_title')), '50%').
  890. $DSP->table_qcell($style, $DSP->input_text('blog_title', $blog_title, '20', '100', 'input', '260px'), '50%').
  891. $DSP->tr_c();
  892. // Weblog "short name" field
  893. $style = ($i++ % 2) ? 'tableCellOne' : 'tableCellTwo' ;
  894. $r .= $DSP->tr().
  895. $DSP->table_qcell($style, $DSP->required().NBS.$DSP->qspan('defaultBold', $LANG->line('short_weblog_name', 'blog_name')).$DSP->nbs(2).'-'.$DSP->nbs(2).$LANG->line('single_word_no_spaces'), '50%').
  896. $DSP->table_qcell($style, $DSP->input_text('blog_name', $blog_name, '20', '40', 'input', '260px'), '50%').
  897. $DSP->tr_c();
  898. // Weblog descriptions field
  899. $style = ($i++ % 2) ? 'tableCellOne' : 'tableCellTwo' ;
  900. $r .= $DSP->tr().
  901. $DSP->table_qcell($style, $DSP->qspan('defaultBold', $LANG->line('blog_description', 'blog_descriptions')), '50%').
  902. $DSP->table_qcell($style, $DSP->input_text('blog_description', $blog_description, '50', '225', 'input', '100%'), '50%').
  903. $DSP->tr_c();
  904. // Weblog Language
  905. $style = ($i++ % 2) ? 'tableCellOne' : 'tableCellTwo' ;
  906. $r .= $DSP->tr().
  907. $DSP->table_qcell($style, $DSP->qspan('defaultBold', $LANG->line('blog_lang', 'blog_lang')), '50%').
  908. $DSP->table_qcell($style, $FNS->encoding_menu('languages', 'blog_lang', $blog_lang), '50%').
  909. $DSP->tr_c();
  910. // Weblog Encoding
  911. $style = ($i++ % 2) ? 'tableCellOne' : 'tableCellTwo' ;
  912. $r .= $DSP->tr().
  913. $DSP->table_qcell($style, $DSP->qspan('defaultBold', $LANG->line('blog_encoding', 'blog_encoding')), '50%').
  914. $DSP->table_qcell($style, $FNS->encoding_menu('charsets', 'blog_encoding', $blog_encoding), '50%').
  915. $DSP->tr_c().
  916. $DSP->table_c();
  917. $r .= $DSP->div_c();
  918. /** ---------------------------
  919. /** Paths
  920. /** ---------------------------*/
  921. $r .= '<div id="paths_on" style="display: none; padding:0; margin: 0;">';
  922. $r .= $DSP->table('tableBorder', '0', '', '100%');
  923. $r .= $DSP->tr();
  924. $r .= "<td class='tableHeadingAlt' id='paths2' colspan='2'>";
  925. $r .= NBS.$LANG->line('paths').$DSP->td_c();
  926. $r .= $DSP->tr_c();
  927. // Weblog URL field
  928. $style = ($i++ % 2) ? 'tableCellOne' : 'tableCellTwo' ;
  929. $r .= $DSP->tr().
  930. $DSP->table_qcell($style, $DSP->qspan('defaultBold', $LANG->line('blog_url', 'blog_url')).$DSP->qdiv('default', $LANG->line('weblog_url_exp')), '50%').
  931. $DSP->table_qcell($style, $DSP->input_text('blog_url', $blog_url, '50', '80', 'input', '100%'), '50%').
  932. $DSP->tr_c();
  933. // comment URL
  934. $style = ($i++ % 2) ? 'tableCellOne' : 'tableCellTwo' ;
  935. $r .= $DSP->tr().
  936. $DSP->table_qcell($style, $DSP->qspan('defaultBold', $LANG->line('comment_url', 'comment_url')).$DSP->qdiv('default', $LANG->line('comment_url_exp')), '50%').
  937. $DSP->table_qcell($style, $DSP->input_text('comment_url', $comment_url, '50', '80', 'input', '100%'), '50%').
  938. $DSP->tr_c();
  939. // Search results URL
  940. $style = ($i++ % 2) ? 'tableCellOne' : 'tableCellTwo' ;
  941. $r .= $DSP->tr().
  942. $DSP->table_qcell($style, $DSP->qspan('defaultBold', $LANG->line('search_results_url', 'search_results_url')).$DSP->qdiv('default', $LANG->line('search_results_url_exp')), '50%').
  943. $DSP->table_qcell($style, $DSP->input_text('search_results_url', $search_results_url, '50', '80', 'input', '100%'), '50%').
  944. $DSP->tr_c();
  945. // TB return URL
  946. $style = ($i++ % 2) ? 'tableCellOne' : 'tableCellTwo' ;
  947. $r .= $DSP->tr().
  948. $DSP->table_qcell($style, $DSP->qspan('defaultBold', $LANG->line('tb_return_url', 'tb_return_url')).$DSP->qdiv('default', $LANG->line('tb_return_url_exp')), '50%').
  949. $DSP->table_qcell($style, $DSP->input_text('tb_return_url', $tb_return_url, '50', '80', 'input', '100%'), '50%').
  950. $DSP->tr_c();
  951. // Ping pMachine URL
  952. $style = ($i++ % 2) ? 'tableCellOne' : 'tableCellTwo' ;
  953. $r .= $DSP->tr().
  954. $DSP->table_qcell($style, $DSP->qspan('defaultBold', $LANG->line('ping_return_url', 'ping_return_url')).$DSP->qdiv('default', $LANG->line('ping_return_url_exp')), '50%').
  955. $DSP->table_qcell($style, $DSP->input_text('ping_return_url', $ping_return_url, '50', '80', 'input', '100%'), '50%').
  956. $DSP->tr_c();
  957. // RSS URL - Extended Ping
  958. $style = ($i++ % 2) ? 'tableCellOne' : 'tableCellTwo' ;
  959. $r .= $DSP->tr().
  960. $DSP->table_qcell($style, $DSP->qspan('defaultBold', $LANG->line('rss_url', 'rss_url')).$DSP->qdiv('default', $LANG->line('rss_url_exp')), '50%').
  961. $DSP->table_qcell($style, $DSP->input_text('rss_url', $rss_url, '50', '80', 'input', '100%'), '50%').
  962. $DSP->tr_c();
  963. // live_look_template
  964. $style = ($i++ % 2) ? 'tableCellOne' : 'tableCellTwo' ;
  965. $r .= $DSP->tr()
  966. .$DSP->table_qcell($style, $DSP->qspan('defaultBold', $LANG->line('live_look_template')))
  967. .$DSP->td($style, '50%')
  968. .$DSP->input_select_header('live_look_template')
  969. .$DSP->input_select_option('0', $LANG->line('no_live_look_template'), ($live_look_template == 0) ? '1' : 0);
  970. $sql = "SELECT tg.group_name, t.template_id, t.template_name
  971. FROM exp_template_groups tg, exp_templates t
  972. WHERE tg.group_id = t.group_id
  973. AND tg.site_id = '".$DB->escape_str($PREFS->ini('site_id'))."' ";
  974. if (USER_BLOG == TRUE)
  975. {
  976. $sql .= "AND tg.group_id = '".$SESS->userdata['tmpl_group_id']."' ";
  977. }
  978. else
  979. {
  980. $sql .= "AND tg.is_user_blog = 'n' ";
  981. }
  982. $sql .= " ORDER BY tg.group_name, t.template_name";
  983. $tquery = $DB->query($sql);
  984. if ($tquery->num_rows > 0)
  985. {
  986. foreach ($tquery->result as $template)
  987. {
  988. $r .= $DSP->input_select_option($template['template_id'], $template['group_name'].'/'.$template['template_name'], (($template['template_id'] == $live_look_template) ? 1 : ''));
  989. }
  990. }
  991. $r .= $DSP->input_select_footer()
  992. .$DSP->td_c()
  993. .$DSP->tr_c();
  994. $r .= $DSP->tr_c().
  995. $DSP->table_c();
  996. $r .= $DSP->div_c();
  997. /** ---------------------------
  998. /** Administrative settings
  999. /** ---------------------------*/
  1000. $r .= '<div id="admin_on" style="display: none; padding:0; margin: 0;">';
  1001. $r .= $DSP->table('tableBorder', '0', '', '100%');
  1002. $r .= $DSP->tr();
  1003. $r .= "<td class='tableHeadingAlt' id='admin2' colspan='2'>";
  1004. $r .= NBS.$LANG->line('default_settings').$DSP->td_c();
  1005. $r .= $DSP->tr_c();
  1006. // Default status menu
  1007. $style = ($i++ % 2) ? 'tableCellOne' : 'tableCellTwo' ;
  1008. $r .= $DSP->tr().
  1009. $DSP->table_qcell($style, $DSP->qspan('defaultBold', $LANG->line('default_status')), '50%');
  1010. $r .= $DSP->td($style, '50%').
  1011. $DSP->input_select_header('deft_status');
  1012. $query = $DB->query("SELECT * FROM exp_statuses WHERE group_id = '".$DB->escape_str($status_group)."' ORDER BY status");
  1013. if ($query->num_rows == 0)
  1014. {
  1015. $selected = ($deft_status == 'open') ? 1 : '';
  1016. $r .= $DSP->input_select_option('open', $LANG->line('open'), $selected);
  1017. $selected = ($deft_status == 'closed') ? 1 : '';
  1018. $r .= $DSP->input_select_option('closed', $LANG->line('closed'), $selected);
  1019. }
  1020. else
  1021. {
  1022. foreach ($query->result as $row)
  1023. {
  1024. $selected = ($deft_status == $row['status']) ? 1 : '';
  1025. $status_name = ($row['status'] == 'open' OR $row['status'] == 'closed') ? $LANG->line($row['status']) : $row['status'];
  1026. $r .= $DSP->input_select_option($row['status'], $status_name, $selected);
  1027. }
  1028. }
  1029. $r .= $DSP->input_select_footer().
  1030. $DSP->td_c().
  1031. $DSP->tr_c();
  1032. // Default category menu
  1033. $style = ($i++ % 2) ? 'tableCellOne' : 'tableCellTwo' ;
  1034. $r .= $DSP->tr().
  1035. $DSP->table_qcell($style, $DSP->qspan('defaultBold', $LANG->line('default_category')), '50%');
  1036. $r .= $DSP->td($style, '50%').
  1037. $DSP->input_select_header('deft_category');
  1038. $selected = '';
  1039. $r .= $DSP->input_select_option('', $LANG->line('none'), $selected);
  1040. $cats = implode("','", $DB->escape_str(explode('|', $cat_group)));
  1041. $query = $DB->query("SELECT CONCAT(g.group_name, ': ', c.cat_name) as display_name, c.cat_id, c.cat_name, g.group_name
  1042. FROM exp_categories c, exp_category_groups g
  1043. WHERE g.group_id = c.group_id
  1044. AND c.group_id IN ('{$cats}') ORDER BY display_name");
  1045. if ($query->num_rows > 0)
  1046. {
  1047. foreach ($query->result as $row)
  1048. {
  1049. $selected = ($deft_category == $row['cat_id']) ? 1 : '';
  1050. $r .= $DSP->input_select_option($row['cat_id'], $row['display_name'], $selected);
  1051. }
  1052. }
  1053. $r .= $DSP->input_select_footer().
  1054. $DSP->td_c().
  1055. $DSP->tr_c();
  1056. // Enable comments
  1057. $style = ($i++ % 2) ? 'tableCellOne' : 'tableCellTwo' ;
  1058. $r .= $DSP->tr()
  1059. .$DSP->table_qcell($style, $DSP->qspan('defaultBold', $LANG->line('deft_comments')), '50%')
  1060. .$DSP->td($style, '50%');
  1061. $r .= $LANG->line('yes')
  1062. .$DSP->input_radio('deft_comments', 'y', ($deft_comments == 'y') ? 1 : '').$DSP->nbs(3);
  1063. $r .= $LANG->line('no')
  1064. .$DSP->input_radio('deft_comments', 'n', ($deft_comments == 'n') ? 1 : '')
  1065. .$DSP->td_c()
  1066. .$DSP->tr_c();

Large files files are truncated, but you can click here to view the full file