Advertisement
Guest User

tiki-editpage.php in Tiki5

a guest
Jun 1st, 2010
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 55.13 KB | None | 0 0
  1. <?php
  2. // (c) Copyright 2002-2010 by authors of the Tiki Wiki/CMS/Groupware Project
  3. //
  4. // All Rights Reserved. See copyright.txt for details and a complete list of authors.
  5. // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
  6. // $Id: tiki-editpage.php 27224 2010-05-18 17:26:08Z xavidp $
  7.  
  8. // If you put some traces in this script, and can't see them
  9. // because the script automatically forwards to another URL
  10. // with a call to header(), then you will not see the traces
  11. // If you want to see the traces, set value below to true.
  12. // WARNING: DO NOT COMMIT WITH TRUE!!!!
  13. $dieInsteadOfForwardingWithHeader = false;
  14. $tracesOn = false;
  15.  
  16.  
  17. $inputConfiguration = array(
  18.     array( 'staticKeyFilters' => array(
  19.         'page' => 'pagename',
  20.         'watch' => 'digits',
  21.     ) ),
  22.     array( 'staticKeyUnset' => array(
  23.         'edit',
  24.     ) ),
  25. );
  26.  
  27. $section = "wiki page";
  28. $section_class = "tiki_wiki_page manage";   // This will be body class instead of $section
  29. require_once ('tiki-setup.php');
  30. include_once ('lib/wiki/wikilib.php');
  31. include_once ('lib/structures/structlib.php');
  32. include_once ('lib/notifications/notificationlib.php');
  33. if ($prefs['feature_ajax'] == 'y') {
  34.     require_once ("lib/ajax/ajaxlib.php");
  35.     require_once ("lib/wiki/wiki-ajax.php");
  36. }
  37. require_once ("lib/wiki/editlib.php");
  38.  
  39.  
  40. function create_staging($cats, $cat_type, $cat_name, $cat_objid, $edit, $description, $pageLang, $is_html, $hash, $page, $user) {
  41.     global $tikilib, $multilinguallib, $categlib, $prefs;
  42.  
  43.     // need to automatically create actual staging page on first approval of staging
  44.     if ($prefs["feature_wikiapproval"] == 'y' && $cat_type == 'wiki page'      
  45.         && $prefs['wikiapproval_approved_category'] > 0 && in_array($prefs['wikiapproval_approved_category'], $_REQUEST['cat_categories'])
  46.         && !$tikilib->page_exists($prefs['wikiapproval_prefix'].$cat_objid) ) {
  47.         $tikilib->create_page($prefs['wikiapproval_prefix'].$_REQUEST["page"], 0, $edit, $tikilib->now, $_REQUEST["comment"],$user,$tikilib->get_ip_address(),$description, $pageLang, $is_html, $hash);
  48.         $newstaging_cats = $cats;
  49.         $newstaging_cat_name = $prefs['wikiapproval_prefix'].$cat_name;
  50.         $newstaging_cat_objid = $prefs['wikiapproval_prefix'].$cat_objid;
  51.         $newstaging_cat_href="tiki-index.php?page=".urlencode($prefs['wikiapproval_prefix'].$cat_objid);
  52.         if ($prefs['wikiapproval_staging_category'] > 0) $newstaging_cats[] = $prefs['wikiapproval_staging_category'];
  53.         if ($prefs['wikiapproval_approved_category'] > 0 && in_array($prefs['wikiapproval_approved_category'], $newstaging_cats)) {
  54.             $newstaging_cats = array_diff($newstaging_cats,Array($prefs['wikiapproval_approved_category']));   
  55.         }
  56.         $categlib->update_object_categories($newstaging_cats, $newstaging_cat_objid, $cat_type, $cat_desc, $newstaging_cat_name, $newstaging_cat_href);
  57.         //now to link in translations if any
  58.         if ($prefs['feature_multilingual'] == 'y') {
  59.             include_once("lib/multilingual/multilinguallib.php");
  60.             $oldstaging_pageid = $tikilib->get_page_id_from_name($page);
  61.             $oldstaging_trads = $multilinguallib->getTrads('wiki page', $oldstaging_pageid);
  62.             foreach ($oldstaging_trads as $ost) {
  63.                 $oldstaging_tradname = $prefs['wikiapproval_prefix'] . $tikilib->get_page_name_from_id($ost["objId"]);
  64.                 if ($ost["lang"] != $pageLang && $tikilib->page_exists($oldstaging_tradname)) {
  65.                     $multilinguallib->insertTranslation('wiki page', $tikilib->get_page_id_from_name($prefs['wikiapproval_prefix'].$page), $pageLang, $tikilib->get_page_id_from_name($oldstaging_tradname), $ost["lang"]);
  66.                     break;
  67.                 }
  68.             }
  69.         }  
  70.     }
  71. }
  72.  
  73. function guess_new_page_attributes_from_parent_pages($page, $page_info) {
  74.     global $editlib, $smarty, $_REQUEST, $tikilib, $prefs, $need_lang;
  75.     if (!$page_info) {
  76.         //
  77.         // This is a new page being created. See if we can guess some of its attributes
  78.         // (ex: language) based on those of its parent pages.
  79.         //
  80.         $new_page_inherited_attributes =
  81.             $editlib->get_new_page_attributes_from_parent_pages($page, $page_info);
  82.         if ($editlib->user_needs_to_specify_language_of_page_to_be_created($page, $page_info)
  83.             && isset($new_page_inherited_attributes['lang'])) {
  84.             //
  85.             // Language is not set yet, but it COULD be guessed from parent pages.
  86.             // So, set it.
  87.             //
  88.             $_REQUEST['lang'] = $new_page_inherited_attributes['lang'];
  89.         }
  90.         if ($editlib->user_needs_to_specify_language_of_page_to_be_created($page, $page_info, $new_page_inherited_attributes)) {
  91.             //
  92.             // Language of new page was not defined, and could not be guessed from the
  93.             // parent pages. User will have to specify it explicitly.
  94.             //
  95.             $languages = $tikilib->list_languages(false, true);
  96.             $smarty->assign('languages', $languages);
  97.             $smarty->assign('default_lang', $prefs['language']);
  98.             $need_lang = true;
  99.             $smarty->assign('_REQUEST', $_REQUEST);
  100.         }
  101.     }
  102. }
  103.  
  104. function translationsToThisPageAreInProgress($page_id) {
  105.     global $multilinguallib;
  106.  
  107.     include_once("lib/multilingual/multilinguallib.php");
  108.  
  109.     $translations_in_progress = $multilinguallib->getTranslationsInProgressFlags($page_id);
  110.     $answer = count($translations_in_progress) > 0;
  111.     return $answer;
  112.  
  113. }
  114.  
  115. function execute_module_translation() {
  116.     global $smarty;
  117. // will show the language of the available translations. Chnage to 'n' to show the page name
  118.     $params['show_language'] = 'y';
  119. // flag to indicate that the module is appearing within the notification area of the edit page
  120.     $params['from_edit_page'] = 'y';
  121.     $params['nobox'] = 'y';
  122.     $module_reference = array(
  123.         'name' => 'translation',
  124.             'params' => array( 'show_language' => $params['show_language'], 'from_edit_page' => $params['from_edit_page'], 'nobox' => $params['nobox'] )
  125.     );
  126.  
  127.     global $modlib; require_once 'lib/modules/modlib.php'; 
  128.  
  129.     $out = $modlib->execute_module( $module_reference );
  130.     $smarty->assign('content_of_update_translation_section', $out);
  131. }
  132.  
  133. // Define all templates files that may be used with the 'zoom' feature
  134. $zoom_templates = array('wiki_edit', 'tiki-editpage');
  135.  
  136. $access->check_feature('feature_wiki');
  137.  
  138. if ($editlib->isNewTranslationMode() || $editlib->isUpdateTranslationMode()) {
  139.     $translation_mode = 'y';
  140.     include_once("lib/multilingual/multilinguallib.php");
  141. } else {
  142.     $translation_mode = 'n';
  143. }
  144. $smarty->assign('translation_mode', $translation_mode);
  145.  
  146. // If page is blank (from quickedit module or wherever) tell user -- instead of editing the default page
  147. // Dont get the page from default HomePage if not set (surely this would always be an error?)
  148. if (empty($_REQUEST["page"])) {
  149.     $smarty->assign('msg', tra("You must specify a page name, it will be created if it doesn't exist."));
  150.     $smarty->display("error.tpl");
  151.     die;
  152. }
  153.  
  154. if ( ( $stagingPage = $tikilib->get_staging_page( $_REQUEST['page'] ) ) && ($prefs['wikiapproval_master_group'] != '-1') && !in_array($prefs['wikiapproval_master_group'], $tikilib->get_user_groups($user))) {
  155.     $_REQUEST['page'] = $stagingPage;
  156. }
  157.  
  158. $page = $_REQUEST["page"];
  159. $smarty->assign('page', $page);
  160. $info = $tikilib->get_page_info($page);
  161.  
  162. // 2010-01-26: Keep in active until translation refactoring is done.
  163.  if ($editlib->isNewTranslationMode() || $editlib->isUpdateTranslationMode()) {
  164.     $editlib->prepareTranslationData();
  165.  }
  166. $editlib->make_sure_page_to_be_created_is_not_an_alias($page, $info);
  167. guess_new_page_attributes_from_parent_pages($page, $info);
  168.  
  169. if ($translation_mode == 'n' && translationsToThisPageAreInProgress($info['page_id'])) {
  170.     $smarty->assign('prompt_for_edit_or_translate', 'y');
  171.     include_once('modules/mod-func-translation.php');
  172.     execute_module_translation();  
  173. } else {
  174.     $smarty->assign('prompt_for_edit_or_translate', 'n');
  175. }
  176.  
  177. // wysiwyg decision
  178. include 'lib/setup/editmode.php';
  179.  
  180. $auto_query_args = array('wysiwyg','page_id','page', 'lang', 'hdr');
  181.  
  182. $smarty->assign_by_ref('page', $_REQUEST["page"]);
  183. // Permissions
  184. $tikilib->get_perm_object($page, 'wiki page', $info, true);
  185. if ($tiki_p_edit != 'y') {
  186.     if (empty($user)) {
  187.         global $cachelib; include_once('lib/cache/cachelib.php');
  188.         $cacheName = $tikilib->get_ip_address().$tikilib->now;
  189.         $cachelib->cacheItem($cacheName, http_build_query($_REQUEST, '', '&'), 'edit');
  190.         $smarty->assign('urllogin', "tiki-editpage.php?cache=$cacheName");
  191.     }
  192.     $smarty->assign('errortype', 401);
  193.     $smarty->assign('msg', tra("Permission denied you cannot edit this page"));
  194.     $smarty->display("error.tpl");
  195.     die;
  196. }
  197. // Anti-bot feature: if enabled, anon user must type in a code displayed in an image
  198. if (isset($_REQUEST['save']) && (!$user || $user == 'anonymous') && $prefs['feature_antibot'] == 'y') {
  199.     if((!isset($_SESSION['random_number']) || $_SESSION['random_number'] != $_REQUEST['antibotcode'])) {
  200.         $smarty->assign('msg',tra("You have mistyped the anti-bot verification code; please try again."));
  201.         $smarty->display("error.tpl");
  202.         die;
  203.     }
  204. }
  205.  
  206. $page_ref_id = '';
  207. if (isset($_REQUEST["page_ref_id"])) {
  208.     $page_ref_id = $_REQUEST["page_ref_id"];
  209. }
  210.  
  211. $smarty->assign('page_ref_id',$page_ref_id);
  212. //Is new page to be inserted into structure?
  213. if (isset($_REQUEST["current_page_id"])) {
  214.     if (empty($_REQUEST['page'])) {
  215.         $smarty->assign('msg', tra("You must specify a page name, it will be created if it doesn't exist."));
  216.         $smarty->display("error.tpl");
  217.         die;
  218.     }
  219.  
  220.     $structure_info = $structlib->s_get_structure_info($_REQUEST['current_page_id']);
  221.     if ( ($tiki_p_edit_structures != 'y' && !$tikilib->user_has_perm_on_object($user,$structure_info["pageName"],'wiki page','tiki_p_edit_structures') ) || !$tikilib->user_has_perm_on_object($user,$structure_info["pageName"],'wiki page','tiki_p_edit')) {
  222.         $smarty->assign('errortype', 401);
  223.         $smarty->assign('msg', tra("Permission denied you cannot edit this page"));
  224.         $smarty->display("error.tpl");
  225.         die;
  226.     }
  227.  
  228.     $smarty->assign('current_page_id',$_REQUEST["current_page_id"]);
  229.     if (isset($_REQUEST["add_child"])) {
  230.         $smarty->assign('add_child', "true");
  231.     }
  232. } else {
  233.     $smarty->assign('current_page_id',0);
  234.     $smarty->assign('add_child', false);
  235. }
  236.  
  237. function compare_import_versions($a1, $a2) {
  238.     return $a1["version"] - $a2["version"];
  239. }
  240.  
  241. if (isset($_REQUEST['cancel_edit'])) {
  242.     if ( ($approved = $tikilib->get_approved_page($page) ) && !$tikilib->page_exists($page)) {
  243.         $approvedPageName = $approved;
  244.         $page = $approvedPageName;
  245.     }
  246.  
  247.     $tikilib->semaphore_unset($page, $_SESSION["edit_lock_$page"]);
  248.     $url = "location:".$wikilib->sefurl($page);
  249.     if (!empty($_REQUEST['page_ref_id'])) {
  250.         $url .= '&page_ref_id='.$_REQUEST['page_ref_id'];
  251.     }  
  252.  
  253.     if ($prefs['feature_best_language'] == 'y') {
  254.         $url .= '&bl=n';
  255.     }
  256.  
  257.     if ($dieInsteadOfForwardingWithHeader) die ("-- tiki-editpage: Dying before first call to header(), so we can see traces. Forwarding to: \$url='$url'");
  258.     header($url);
  259.     die;
  260. }
  261. if (isset($_REQUEST['minor'])) {
  262.     $_REQUEST['isminor'] = 'on';
  263.     $_REQUEST['save'] = true;
  264. }
  265.  
  266. if( $user && $prefs['feature_user_watches'] == 'y' ) {
  267.     $isFormSubmit = isset($jitRequest['edit']);
  268.     if( $tikilib->page_exists($page) ) {
  269.         $currentlyWatching = (bool) $tikilib->user_watches( $user, 'wiki_page_changed', $page, 'wiki page' );
  270.     } else {
  271.         // New pages get default watch checked for authors
  272.         $currentlyWatching = ($prefs['wiki_watch_author'] == 'y');
  273.     }
  274.  
  275.     $requestedWatch = isset($_REQUEST['watch']) && $isFormSubmit;
  276.     $smarty->assign( 'show_watch', 'y' );
  277.     $smarty->assign( 'watch_checked', ( ($currentlyWatching && !$isFormSubmit) || $requestedWatch) ? 'y' : 'n' );
  278. } else {
  279.     $currentlyWatching = false;
  280.     $requestedWatch = false;
  281.     $smarty->assign( 'show_watch_controls', 'n' );
  282. }
  283.  
  284. if (isset($_REQUEST['partial_save'])) {
  285.     $_REQUEST['save'] = true;
  286. }
  287.  
  288. if (isset($_REQUEST['hdr'])) {
  289.     $smarty->assign('hdr', $_REQUEST['hdr']);
  290. }
  291.  
  292. if (isset($_REQUEST['pos'])) {
  293.     $smarty->assign('pos', $_REQUEST['pos']);
  294. }
  295.  
  296. if (isset($_REQUEST['cell'])) {
  297.     $smarty->assign('cell', $_REQUEST['cell']);
  298. }
  299.  
  300. // We set empty wiki page name as default here if not set (before including Tiki modules)
  301. if ($prefs['feature_warn_on_edit'] == 'y') {
  302.     $editpageconflict = 'n';
  303.     $beingEdited = 'n';
  304.     $semUser = '';
  305.     $u = $user? $user: 'anonymous';
  306.     if (!empty($page) && ($page != 'sandbox' || $page == 'sandbox' && $tiki_p_admin == 'y')) {
  307.         if (!isset($_REQUEST['save'])) {
  308.             if ($tikilib->semaphore_is_set($page, $prefs['warn_on_edit_time'] * 60) && $tikilib->get_semaphore_user($page) != $u) {
  309.                 $editpageconflict = 'y';
  310.             } elseif ($tiki_p_edit == 'y') {
  311.                 $_SESSION["edit_lock_$page"] = $tikilib->semaphore_set($page);
  312.             }
  313.             $semUser = $tikilib->get_semaphore_user($page);
  314.             $beingedited = 'y';
  315.         } else {
  316.             if (!empty($_SESSION["edit_lock_$page"])) {
  317.                 $tikilib->semaphore_unset($page, $_SESSION["edit_lock_$page"]);
  318.             }
  319.         }
  320.     }
  321.     if ($editpageconflict == 'y' && !isset($_REQUEST["conflictoverride"]) ) {
  322.         include_once('lib/smarty_tiki/modifier.userlink.php');
  323.         $msg = tra("This page is being edited by ") .
  324.             smarty_modifier_userlink($semUser) . ". " .
  325.             tra("Please check with the user before editing the page,
  326.             otherwise the changes will be stored as two separate versions in the history and
  327.             you will have to manually merge them later. ") ;
  328.         $msg .= '<br /><br /><a href="tiki-editpage.php?page=';
  329.         $msg .= urlencode($page);
  330.         $msg .= '&conflictoverride=y">' . tra('Override lock and carry on with edit') . '</a>';
  331.         $smarty->assign('msg',$msg);
  332.         $smarty->assign('errortitle',tra('Page is currently being edited'));
  333.         $smarty->display("error.tpl");
  334.         die;
  335.     }
  336. }
  337. $category_needed = false;
  338. $contribution_needed = false;
  339. if (isset($_REQUEST['lock_it']) && $_REQUEST['lock_it'] =='on') {
  340.     $lock_it = 'y';
  341. } else {
  342.     $lock_it = 'n';
  343. }
  344. if (isset($_REQUEST['comments_enabled']) && $_REQUEST['comments_enabled'] =='on') {
  345.     $comments_enabled = 'y';
  346. } else {
  347.     $comments_enabled = 'n';
  348. }
  349. $hash = array();
  350. $hash['lock_it'] = $lock_it;
  351. $hash['comments_enabled'] = $comments_enabled;
  352. if (!empty($_REQUEST['contributions'])) {
  353.     $hash['contributions'] = $_REQUEST['contributions'];
  354. }
  355. if (!empty($_REQUEST['contributors'])) {
  356.     $hash['contributors'] = $_REQUEST['contributors'];
  357. }
  358. if (isset($_FILES['userfile1']) && is_uploaded_file($_FILES['userfile1']['tmp_name'])) {
  359.     check_ticket('edit-page');
  360.     require ("lib/mail/mimelib.php");
  361.     $fp = fopen($_FILES['userfile1']['tmp_name'], "rb");
  362.     $data = '';
  363.     while (!feof($fp)) {
  364.         $data .= fread($fp, 8192 * 16);
  365.     }
  366.     fclose ($fp);
  367.     $name = $_FILES['userfile1']['name'];
  368.     $output = mime::decode($data);
  369.     $parts = array();
  370.     parse_output($output, $parts, 0);
  371.     $last_part = '';
  372.     $last_part_ver = 0;
  373.     usort($parts, 'compare_import_versions');
  374.     foreach ($parts as $part) {
  375.         if ($part["version"] > $last_part_ver) {
  376.             $last_part_ver = $part["version"];
  377.             $last_part = $part["body"];
  378.         }
  379.         if (isset($part["pagename"])) {
  380.             $pagename = urldecode($part["pagename"]);
  381.             $version = urldecode($part["version"]);
  382.             $author = urldecode($part["author"]);
  383.             $lastmodified = $part["lastmodified"];
  384.             if (isset($part["description"])) {
  385.                 $description = $part["description"];
  386.             } else {
  387.                 $description = '';
  388.             }
  389.             $pageLang = isset($part["lang"])? $part["lang"]: "";
  390.             $authorid = urldecode($part["author_id"]);
  391.             if (isset($part["hits"]))
  392.                 $hits = urldecode($part["hits"]);
  393.             else
  394.                 $hits = 0;
  395.             $ex = substr($part["body"], 0, 25);
  396.             //print(strlen($part["body"]));
  397.             $msg = '';
  398.             if (isset($_REQUEST['save']) && $prefs['feature_contribution'] == 'y' && $prefs['feature_contribution_mandatory'] == 'y' && (empty($_REQUEST['contributions']) || count($_REQUEST['contributions']) <= 0)) {
  399.                 $contribution_needed = true;
  400.                 $smarty->assign('contribution_needed', 'y');
  401.             } else {
  402.                 $contribution_needed = false;
  403.             }
  404.             if (isset($_REQUEST['save']) && $prefs['feature_categories'] == 'y' && $prefs['feature_wiki_mandatory_category'] >=0 && (empty($_REQUEST['cat_categories']) || count($_REQUEST['cat_categories']) <= 0)) {
  405.                 $category_needed = true;
  406.                 $smarty->assign('category_needed', 'y');
  407.             } else {
  408.                 $category_needed = false;
  409.             }
  410.             if (isset($_REQUEST["save"]) && !$category_needed && !$contribution_needed) {
  411.                 if (strtolower($pagename) != 'sandbox' || $tiki_p_admin == 'y') {
  412.                     $description = TikiFilter::get('striptags')->filter($description);
  413.                     if ($tikilib->page_exists($pagename)) {
  414.                         if ($prefs['feature_multilingual'] == 'y') {
  415.                             $info = $tikilib->get_page_info($pagename);
  416.                             if ($info['lang'] != $pageLang) {
  417.                                 include_once("lib/multilingual/multilinguallib.php");
  418.                                 if ($multilinguallib->updatePageLang('wiki page', $info['page_id'], $pageLang, true)){
  419.                                     $pageLang = $info['lang'];
  420.                                     $smarty->assign('msg', tra("The language can't be changed as its set of translations has already this language"));
  421.                                     $smarty->display("error.tpl");
  422.                                     die;
  423.                                 }
  424.                             }
  425.                         }
  426.  
  427.                         $tikilib->update_page($pagename, $part["body"], tra('page imported'), $author, $authorid, $description, 0, $pageLang, false, $hash);
  428.                     } else {
  429.                         $tikilib->create_page($pagename, $hits, $part["body"], $lastmodified, tra('created from import'), $author, $authorid, $description, $pageLang, false, $hash);
  430.                     }
  431.  
  432.                     // Handle the translation bits after actual creation/update
  433.                     // This path is never used by minor updates
  434.                     if ($prefs['feature_multilingual'] == 'y') {
  435.                         include_once("lib/multilingual/multilinguallib.php");
  436.                         unset( $tikilib->cache_page_info );
  437.  
  438.                         if ( $approved = $this->get_approved_page($page) ) {
  439.                             $oldpage = $approved;
  440.                             $oldpageid = $tikilib->get_page_id_from_name($oldpage);
  441.                             $oldtrads = $multilinguallib->getTrads('wiki page', $oldpageid);
  442.                             foreach ($oldtrads as $ot) {
  443.                                 $oldtradname = $prefs['wikiapproval_prefix'] . $tikilib->get_page_name_from_id($ot["objId"]);
  444.                                 if ($ot["lang"] != $pageLang && $tikilib->page_exists($oldtradname)) {
  445.                                     $multilinguallib->insertTranslation('wiki page', $tikilib->get_page_id_from_name($page), $pageLang, $tikilib->get_page_id_from_name($oldtradname), $ot["lang"]);
  446.                                     break;                                 
  447.                                 }                          
  448.                             }
  449.                         }
  450.  
  451.                         if( $editlib->isNewTranslationMode() ) {
  452.                             if ($editlib->aTranslationWasSavedAs('complete')) {
  453.                                 $editlib->saveCompleteTranslation();
  454.                             } else if ($editlib->aTranslationWasSavedAs('partial')) {
  455.                                 $editlib->savePartialTranslation();
  456.                             }
  457.                         } elseif( $editlib->isUpdateTranslationMode() ) {
  458.                             if ($editlib->aTranslationWasSavedAs('complete')) {
  459.                                 $editlib->saveCompleteTranslation();
  460.                             } else if ($editlib->aTranslationWasSavedAs('partial')) {
  461.                                 $editlib->savePartialTranslation();
  462.                             }
  463.                         } else {
  464.                             $info = $tikilib->get_page_info( $pagename );
  465.                             $flags = array();
  466.                             if( isset( $_REQUEST['translation_critical'] ) ) {
  467.                                 $flags[] = 'critical';
  468.                             }
  469.                             $multilinguallib->createTranslationBit( 'wiki page', $info['page_id'], $info['version'], $flags );
  470.                         }
  471.                     }
  472.                 }
  473.             } else {
  474.                 $_REQUEST["edit"] = $last_part;
  475.             }
  476.         }
  477.     }
  478.  
  479.     // If the watch state is not the same
  480.     if( $requestedWatch !== $currentlyWatching ) {
  481.         if( $requestedWatch ) {
  482.             $tikilib->add_user_watch( $user, 'wiki_page_changed', $page, 'wiki page', $page, $wikilib->sefurl($page) );
  483.         } else {
  484.             $tikilib->remove_user_watch( $user, 'wiki_page_changed', $page, 'wiki page' );
  485.         }
  486.     }
  487.  
  488.     if (isset($_REQUEST["save"])) {
  489.         unset ($_REQUEST["save"]);
  490.         if ($page_ref_id) {
  491.             $url = "tiki-index.php?page_ref_id=$page_ref_id";
  492.         } else {
  493.             $url = $wiki->sefurl($page);
  494.         }
  495.         if ($prefs['feature_best_language'] == 'y') {
  496.             $url .= '&bl=n';
  497.         }
  498.  
  499.         if ($dieInsteadOfForwardingWithHeader) die ("-- tiki-editpage: Dying before second call to header(), so we can see traces. Forwarding to: '$url'");
  500.         header("location: $url");
  501.         die;
  502.     }
  503. }
  504.  
  505. $smarty->assign('category_needed',$category_needed);
  506. $smarty->assign('contribution_needed',$contribution_needed);
  507. $wiki_up = "img/wiki_up";
  508. if ($tikidomain) { $wiki_up.= "/$tikidomain"; }
  509. // Upload pictures here
  510. if (($prefs['feature_wiki_pictures'] == 'y') && (isset($tiki_p_upload_picture)) && ($tiki_p_upload_picture == 'y')) {
  511.     $i = 1;
  512.     while ( isset($_FILES['picfile'.$i]) ) {
  513.         if ( is_uploaded_file($_FILES['picfile'.$i]['tmp_name']) ) {
  514.             $picname = $_FILES['picfile'.$i]['name'];
  515.             if ( preg_match('/\.(gif|png|jpe?g)$/i',$picname) ) {
  516.                 if (@getimagesize($_FILES['picfile'.$i]['tmp_name'])) {
  517.                     move_uploaded_file($_FILES['picfile'.$i]['tmp_name'], "$wiki_up/$picname");
  518.                     chmod("$wiki_up/$picname", 0644); // seems necessary on some system (see move_uploaded_file doc on php.net)
  519.                 }
  520.             }
  521.         }
  522.         $i++;
  523.     }
  524. }
  525. if ($prefs['feature_wiki_attachments'] == 'y' && isset($_REQUEST["attach"]) && ($tiki_p_wiki_attach_files == 'y' || $tiki_p_wiki_admin_attachments == 'y')) {
  526.     if (isset($_FILES['userfile2']) && is_uploaded_file($_FILES['userfile2']['tmp_name'])) {
  527.         $ret = $tikilib->attach_file($_FILES['userfile2']['name'], $_FILES['userfile2']['tmp_name'], $prefs['w_use_db'] == 'y'? 'db': 'dir');
  528.         if ($ret['ok']) {
  529.             $wikilib->wiki_attach_file($page, $_FILES['userfile2']['name'], $_FILES['userfile2']['type'], $_FILES['userfile2']['size'], ($prefs['w_use_db'] == 'dir')?'': $ret['data'], $_REQUEST["attach_comment"], $user, $ret['fhash']);
  530.         } else {
  531.                 $smarty->assign('msg', $ret['error']);
  532.                 $smarty->display("error.tpl");
  533.                 die();
  534.         }
  535.     }
  536. }
  537.  
  538.  
  539. // Suck another page and append to the end of current
  540. $suck_url = isset($_REQUEST["suck_url"]) ? $_REQUEST["suck_url"] : '';
  541. $parsehtml = isset ($_REQUEST["parsehtml"]) ? ($_REQUEST["parsehtml"] == 'on' ? 'y' : 'n') : ($info['is_html'] ? 'n' : 'y');
  542. $smarty->assign('parsehtml', $parsehtml);
  543. if (isset($_REQUEST['do_suck']) && strlen($suck_url) > 0)
  544. {
  545.     // \note by zaufi
  546.     //   This is ugly implementation of wiki HTML import.
  547.     //   I think it should be plugable import/export converters with ability
  548.     //   to choose from edit form what converter to use for operation.
  549.     //   In case of import converter, it can try to guess what source
  550.     //   file is (using mime type from remote server response).
  551.     //   Of couse converters may have itsown configuration panel what should be
  552.     //   pluged into wiki page edit form too... (like HTML importer may have
  553.     //   flags 'strip HTML tags' and 'try to convert HTML to wiki' :)
  554.     //   At least one export filter for wiki already coded :) -- PDF exporter...
  555.     $sdta = $tikilib->httprequest($suck_url);
  556.     if (isset($php_errormsg) && strlen($php_errormsg))
  557.     {
  558.         $smarty->assign('msg', tra("Can't import remote HTML page"));
  559.         $smarty->display("error.tpl");
  560.         die;
  561.     }
  562.     // Need to parse HTML?
  563.     if ($parsehtml == 'y') {
  564.         $sdta = $editlib->parse_html($sdta);
  565.     }
  566.     $_REQUEST['edit'] = $jitRequest['edit'] . $sdta;
  567. }
  568. // if "UserPage" complete with the user name
  569. if ($prefs['feature_wiki_userpage'] == 'y' && $tiki_p_admin != 'y' && $page == $prefs['feature_wiki_userpage_prefix']) {
  570.     $page .= $user;
  571.     $_REQUEST['page'] = $page;
  572. }
  573.  
  574. if (strtolower($_REQUEST["page"]) == 'sandbox' && $prefs['feature_sandbox'] != 'y') {
  575.     $smarty->assign('msg', tra("The SandBox is disabled"));
  576.     $smarty->display("error.tpl");
  577.     die;
  578. }
  579.  
  580. if (!isset($_REQUEST["comment"])) {
  581.     $_REQUEST["comment"] = '';
  582. }
  583.  
  584. // Get page data
  585. if(isset($info['wiki_cache'])) {
  586.     $prefs['wiki_cache'] = $info['wiki_cache'];
  587.     $smarty->assign('wiki_cache',$prefs['wiki_cache']);
  588. }
  589.  
  590. if ($info["flag"] == 'L' && !$wikilib->is_editable($page, $user, $info)) {
  591.     $smarty->assign('msg', tra("Cannot edit page because it is locked"));
  592.     $smarty->display("error.tpl");
  593.     die;
  594. }
  595.  
  596. $smarty->assign('editable','y');
  597. $smarty->assign('show_page','n');
  598. $smarty->assign('comments_show','n');
  599.  
  600. $smarty->assign_by_ref('data', $info);
  601. $smarty->assign('footnote', '');
  602. $smarty->assign('has_footnote', 'n');
  603. if ($prefs['feature_wiki_footnotes'] == 'y') {
  604.     if ($user) {
  605.         $x = $wikilib->get_footnote($user, $page);
  606.         $footnote = $wikilib->get_footnote($user, $page);
  607.         $smarty->assign('footnote', $footnote);
  608.         if ($footnote)
  609.             $smarty->assign('has_footnote', 'y');
  610.         $smarty->assign('parsed_footnote', $tikilib->parse_data($footnote));
  611.         if (isset($_REQUEST['footnote'])) {
  612.             check_ticket('edit-page');
  613.             $smarty->assign('parsed_footnote', $tikilib->parse_data($_REQUEST['footnote']));
  614.             $smarty->assign('footnote', $_REQUEST['footnote']);
  615.             $smarty->assign('has_footnote', 'y');
  616.             if (empty($_REQUEST['footnote'])) {
  617.                 $wikilib->remove_footnote($user, $page);
  618.             } else {
  619.                 $wikilib->replace_footnote($user, $page, $_REQUEST['footnote']);
  620.             }
  621.         }
  622.     }
  623. }
  624. if ((isset($_REQUEST["template_name"]) || isset($_REQUEST["templateId"])) && !isset($_REQUEST['preview']) && !isset($_REQUEST['save'])) {
  625.     global $templateslib; require_once 'lib/templates/templateslib.php';
  626.     $templateLang = isset( $_REQUEST['lang'] ) ? $_REQUEST['lang'] : null;
  627.  
  628.     if (isset($_REQUEST["templateId"]))  {
  629.         $templateId = $_REQUEST["templateId"];
  630.     } else {
  631.         include_once ('lib/multilingual/multilinguallib.php');
  632.         $templateId = $multilinguallib->getTemplateIDInLanguage('wiki', $_REQUEST["template_name"], $templateLang);
  633.     }
  634.     $template_data = $templateslib->get_template($templateId, $templateLang);
  635.     $_REQUEST["edit"] = $template_data["content"]."\n".$_REQUEST["edit"];
  636.     $smarty->assign("templateId", $templateId);
  637. }
  638.  
  639. if (isset($_REQUEST["categId"]) && $_REQUEST["categId"] > 0) {
  640.     $categs = explode('+',$_REQUEST["categId"]);
  641.     $smarty->assign('categIds',$categs);
  642.     $smarty->assign('categIdstr',$_REQUEST["categId"]);
  643. } else {
  644.     $smarty->assign('categIds',array());
  645.     $smarty->assign('categIdstr',0);
  646. }
  647.  
  648. if (isset($_REQUEST["ratingId"]) && $_REQUEST["ratingId"] > 0) {
  649.     $smarty->assign("poll_template",$_REQUEST["ratingId"]);
  650. } else {
  651.     $smarty->assign("poll_template",0);
  652. }
  653.  
  654. if(isset($_REQUEST["edit"])) {
  655.     $edit_data = $_REQUEST["edit"];
  656. } else {
  657.     if (isset($info['draft'])) {
  658.         $edit_data = $info['draft']['data'];
  659.     } elseif (isset($info["data"])) {
  660.         if ((isset($_REQUEST['hdr']) || (!empty($_REQUEST['pos']) && isset($_REQUEST['cell']))) && $prefs['wiki_edit_section'] == 'y') {
  661.             if (isset($_REQUEST['hdr'])) {
  662.                 if ($_REQUEST['hdr'] == 0) {
  663.                     list($real_start, $real_len) = $tikilib->get_wiki_section($info['data'], 1);
  664.                     $real_len = $real_start;
  665.                     $real_start = 0;
  666.                 } else {
  667.                     list($real_start, $real_len) = $tikilib->get_wiki_section($info['data'], $_REQUEST['hdr']);
  668.                 }
  669.             } else {
  670.                 include_once('lib/wiki-plugins/wikiplugin_split.php');
  671.                 list($real_start, $real_len) = wikiplugin_split_cell($info['data'], $_REQUEST['pos'], $_REQUEST['cell']);
  672.             }
  673.             $edit_data = substr($info['data'], $real_start, $real_len);
  674.         } else {
  675.             $edit_data = $info['data'];
  676.         }
  677.     } elseif ( ($approved = $tikilib->get_approved_page($page)) && !$tikilib->page_exists($page)) {
  678.     // Handle first creation of staging copy
  679.     $oldpage = $approved;
  680.     // Get page data
  681.         if ($tikilib->page_exists($oldpage)) {
  682.             $oldinfo = $tikilib->get_page_info($oldpage);
  683.             $edit_data = $oldinfo["data"];
  684.             $edit_lang = $oldinfo["lang"];
  685.         } else {
  686.             $edit_data = '';
  687.         }
  688.     } else {
  689.         $edit_data = '';
  690.     }
  691. }
  692.  
  693. $likepages = '';
  694. $smarty->assign_by_ref('likepages', $likepages);
  695. if ($prefs['feature_likePages'] == 'y' and $edit_data == '' && !$tikilib->page_exists($page)) {
  696.     $likepages = $wikilib->get_like_pages($page);
  697. }
  698.    
  699. if (isset($prefs['wiki_feature_copyrights']) && $prefs['wiki_feature_copyrights'] == 'y') {
  700.     if (isset($_REQUEST['copyrightTitle'])) {
  701.         $smarty->assign('copyrightTitle', $_REQUEST["copyrightTitle"]);
  702.     }
  703.     if (isset($_REQUEST['copyrightYear'])) {
  704.         $smarty->assign('copyrightYear', $_REQUEST["copyrightYear"]);
  705.     }
  706.     if (isset($_REQUEST['copyrightAuthors'])) {
  707.         $smarty->assign('copyrightAuthors', $_REQUEST["copyrightAuthors"]);
  708.     }
  709. }
  710.  
  711. if (isset($_REQUEST["comment"])) {
  712.     $smarty->assign_by_ref('commentdata', $_REQUEST["comment"]);
  713. } elseif (isset($info['draft'])) {
  714.     $smarty->assign_by_ref('commentdata',$info['draft']['data']);
  715. } else {
  716.     $smarty->assign('commentdata', '');
  717. }
  718. if (isset($info["description"])) {
  719.     if (isset($info['draft'])) {
  720.         $info['description'] = $info['draft']['description'];
  721.     }
  722.     $smarty->assign('description', $info["description"]);
  723.     $description = $info["description"];
  724. } else {
  725.     $smarty->assign('description', '');
  726.     $description = '';
  727. }
  728. if(isset($_REQUEST["description"])) {
  729.     $smarty->assign_by_ref('description',$_REQUEST["description"]);
  730.     $description = $_REQUEST["description"];
  731. }
  732.  
  733. $wiki_authors_style = '';
  734. if ( $prefs['wiki_authors_style_by_page'] == 'y' ) {
  735.     if ( isset($_REQUEST['wiki_authors_style']) && $tiki_p_admin_wiki == 'y' ) {
  736.         $wiki_authors_style = $_REQUEST['wiki_authors_style'];
  737.     } elseif ( isset($info['wiki_authors_style']) ) {
  738.         $wiki_authors_style = $info['wiki_authors_style'];
  739.     }
  740.     $smarty->assign('wiki_authors_style', $wiki_authors_style);
  741. }
  742.  
  743. if($is_html) {
  744.     $smarty->assign('allowhtml','y');
  745. } else {
  746.     $edit_data = str_replace( '<x>', '', $edit_data );
  747.     $smarty->assign('allowhtml','n');
  748. }
  749. if (empty($_REQUEST['lock_it']) && !empty($info['flag']) && $info['flag'] == 'L') {
  750.     $lock_it = 'y';
  751. }
  752. $smarty->assign_by_ref('lock_it', $lock_it);
  753. if ($prefs['wiki_comments_allow_per_page'] != 'n') {
  754.     if (!isset($_REQUEST['save']) && !isset($_REQUEST['preview'])) {
  755.         if (!empty($info) && !empty($info['comments_enabled'])) {
  756.             $comments_enabled =  $info['comments_enabled'];
  757.         } else {
  758.             if ($prefs['wiki_comments_allow_per_page'] == 'y') {
  759.                 $comments_enabled = 'y';
  760.             } else {
  761.                 $comments_enabled = 'n';
  762.             }
  763.         }
  764.     }
  765.     $smarty->assign_by_ref('comments_enabled', $comments_enabled);
  766. }
  767. if (isset($_REQUEST["lang"])) {
  768.     if ($prefs['feature_multilingual'] == 'y' && isset($info["lang"]) && $info['lang'] != $_REQUEST["lang"]) {
  769.         include_once("lib/multilingual/multilinguallib.php");
  770.         if ($multilinguallib->updatePageLang('wiki page', $info['page_id'], $_REQUEST["lang"], true)) {
  771.             $pageLang = $info['lang'];
  772.             $smarty->assign('msg', tra("The language can't be changed as its set of translations has already this language"));
  773.             $smarty->display("error.tpl");
  774.             die;
  775.         }
  776.     }
  777.     $pageLang = $_REQUEST["lang"];
  778. } elseif (isset($info["lang"])) {
  779.     $pageLang = $info["lang"];
  780. } elseif (isset($edit_lang)) {
  781.     $pageLang = $edit_lang;
  782. } else {
  783.     $pageLang = "";
  784. }
  785.  
  786. $smarty->assign('lang', $pageLang);
  787. if( $prefs['feature_urgent_translation'] == 'y' ) {
  788.     $urgent_allowed = true;
  789.     if( $prefs['feature_urgent_translation_master_only'] == 'y' && $pageLang != $prefs['site_language'] ) {
  790.         $urgent_allowed = false;
  791.     }
  792.     $smarty->assign( 'urgent_allowed', $urgent_allowed );
  793. }
  794. if( isset( $_REQUEST['translation_critical'] ) ) {
  795.     $smarty->assign( 'translation_critical', 1 );
  796. } else {
  797.     $smarty->assign( 'translation_critical', 0 );
  798. }
  799.  
  800. // Parse (or not) $edit_data into $parsed
  801. // Handles switching editor modes
  802. if (isset($_REQUEST['mode_normal']) && $_REQUEST['mode_normal']=='y') {
  803.     // Parsing page data as first time seeing html page in normal editor
  804.     $smarty->assign('msg', "Parsing html to wiki");
  805.     $parsed = $editlib->parseToWiki($edit_data);
  806.     $is_html = false;
  807.     $info['is_html'] = false;
  808.     $info['wysiwyg'] = false;
  809.     $smarty->assign('allowhtml','n');
  810.    
  811. } elseif (isset($_REQUEST['mode_wysiwyg']) && $_REQUEST['mode_wysiwyg']=='y') {
  812.     // Parsing page data as first time seeing wiki page in wysiwyg editor
  813.     $smarty->assign('msg', "Parsing wiki to html");
  814.     $secedit = $prefs['wiki_edit_section'];
  815.     $prefs['wiki_edit_section'] = 'n';      // get rid of the section edit icons
  816.     $exticons = $prefs['feature_wiki_ext_icon'];
  817.     $prefs['feature_wiki_ext_icon'] = 'n';      // and the external link icons
  818.     $editplugin = $prefs['wiki_edit_plugin'];
  819.     $prefs['wiki_edit_plugin'] = 'n';       // and the external link icons
  820.     $parsed = $editlib->parseToWysiwyg($edit_data);
  821.     $smarty->assign('pagedata', $parsed);
  822.     $prefs['wiki_edit_section'] = $secedit;
  823.     $prefs['feature_wiki_ext_icon'] = $exticons;
  824.     $prefs['wiki_edit_plugin'] = $editplugin;
  825.     $is_html = true;
  826.     $info['is_html'] = true;
  827.     $info['wysiwyg'] = true;
  828.     $smarty->assign('allowhtml','y');
  829. }
  830. if (empty($parsed)) {
  831.     if ( ! isset($_REQUEST['edit']) && ! $is_html ) {
  832.         // When we get data from database (i.e. we are not in preview mode) and if we don't allow HTML,
  833.         //   then we need to convert database's HTML entities into their "normal chars" equivalents
  834.         $parsed = TikiLib::htmldecode($edit_data);
  835.     } else {
  836.         $parsed = $edit_data;
  837.     }
  838. }
  839. $smarty->assign('pagedata', $parsed);
  840.  
  841. // apply the optional post edit filters before preview
  842. if(isset($_REQUEST["preview"]) || ($prefs['wiki_spellcheck'] == 'y' && isset($_REQUEST["spellcheck"]) && $_REQUEST["spellcheck"] == 'on')) {
  843.     $parsed = $tikilib->apply_postedit_handlers($parsed);
  844.     $parsed = $tikilib->parse_data($parsed, array('is_html' => $is_html, 'preview_mode'=>true));
  845. } else {
  846.     $parsed = "";
  847. }
  848.  
  849. /* SPELLCHECKING INITIAL ATTEMPT */
  850. //This nice function does all the job!
  851. if ($prefs['wiki_spellcheck'] == 'y') {
  852.     if (isset($_REQUEST["spellcheck"]) && $_REQUEST["spellcheck"] == 'on') {
  853.         $parsed = $tikilib->spellcheckreplace($edit_data, $parsed, $prefs['language'], 'editwiki');
  854.         $smarty->assign('spellcheck', 'y');
  855.     } else {
  856.         $smarty->assign('spellcheck', 'n');
  857.     }
  858. }
  859.  
  860. $smarty->assign_by_ref('parsed', $parsed);
  861. $smarty->assign('preview',0);
  862. // If we are in preview mode then preview it!
  863. if(isset($_REQUEST["preview"])) {
  864.     $smarty->assign('preview',1);
  865. }
  866.  
  867. function parse_output(&$obj, &$parts,$i) {
  868.     if(!empty($obj['parts'])) {
  869.         foreach( $obj['parts'] as $index => $part ) {
  870.             parse_output($part, $parts,$index);
  871.         }
  872.     }elseif( $obj['type'] == 'application/x-tikiwiki' ) {
  873.         $aux["body"] = $obj['body'];
  874.         $ccc=$obj['header']["content-type"];
  875.         $items = explode(';',$ccc);
  876.         foreach($items as $item) {
  877.             $portions = explode('=',$item);
  878.             if(isset($portions[0])&&isset($portions[1])) {
  879.                 $aux[trim($portions[0])]=trim($portions[1]);
  880.             }
  881.         }
  882.         $parts[]=$aux;
  883.     }
  884. }
  885. // Pro
  886. // Check if the page has changed
  887. $pageAlias = '';
  888. $cat_type='wiki page';
  889. $cat_objid = $_REQUEST["page"];
  890. if (isset($_REQUEST['save']) && $prefs['feature_contribution'] == 'y' && $prefs['feature_contribution_mandatory'] == 'y' && (empty($_REQUEST['contributions']) || count($_REQUEST['contributions']) <= 0)) {
  891.     $contribution_needed = true;
  892.     $smarty->assign('contribution_needed', 'y');
  893. } else {
  894.     $contribution_needed = false;
  895. }
  896. if (isset($_REQUEST['save']) && $prefs['feature_categories'] == 'y' && $prefs['feature_wiki_mandatory_category'] >=0 && (empty($_REQUEST['cat_categories']) || count($_REQUEST['cat_categories']) <= 0)) {
  897.     $category_needed = true;
  898.     $smarty->assign('category_needed', 'y');
  899. } else {
  900.     $category_needed = false;
  901. }
  902. if (isset($_REQUEST['save']) && $prefs['wiki_mandatory_edit_summary'] == 'y' && empty($_REQUEST['comment']) ) {
  903.     $summary_needed = true;
  904.     $smarty->assign( 'summary_needed', 'y' );
  905. } else {
  906.     $summary_needed = false;
  907. }
  908. if ($prefs['wiki_mandatory_edit_summary'] == 'y') {
  909.     $headerlib->add_jq_onready('
  910. $jq("input[name=save],input[name=minor]").click(function(){
  911.     if (!$jq("#comment").val()) {
  912.         var s = prompt("'.tra('Describe the change you made').'");
  913.         if (!s) return false;
  914.         $jq("#comment").val(s);
  915.     }
  916.     return true;
  917. })
  918. ');
  919. }
  920.  
  921. if (isset($_REQUEST["save"]) && (strtolower($_REQUEST['page']) != 'sandbox' || $tiki_p_admin == 'y') && !$category_needed && !$contribution_needed && ! $summary_needed) {
  922.     check_ticket('edit-page');
  923.     // Check if all Request values are delivered, and if not, set them
  924.     // to avoid error messages. This can happen if some features are
  925.     // disabled
  926.     if(!isset($_REQUEST["description"])) $_REQUEST["description"]='';
  927.     if(!isset($_REQUEST["wiki_authors_style"])) $_REQUEST["wiki_authors_style"]='';
  928.     if(!isset($_REQUEST["comment"])) $_REQUEST["comment"]='';
  929.     if(!isset($_REQUEST["lang"])) $_REQUEST["lang"]='';
  930.     if(!isset($_REQUEST['wysiwyg'])) $_REQUEST['wysiwyg'] = '';
  931.     if(isset($_REQUEST['wiki_cache'])) {
  932.         $wikilib->set_page_cache($_REQUEST['page'],$_REQUEST['wiki_cache']);
  933.     }
  934.     include_once("lib/imagegals/imagegallib.php");
  935.     $cat_desc = ($prefs['feature_wiki_description'] == 'y') ? substr($_REQUEST["description"],0,200) : '';
  936.     $cat_name = $_REQUEST["page"];
  937.     $cat_href="tiki-index.php?page=".urlencode($cat_objid);
  938.     $cat_lang = $_REQUEST['lang'];
  939.     $cat_object_exists = $tikilib->page_exists( $_REQUEST['page'] );
  940.     include_once("categorize.php");
  941.     include_once("poll_categorize.php");
  942.     include_once("freetag_apply.php");
  943.     $page = $_REQUEST["page"];
  944.     if($is_html) {
  945.         $edit = $_REQUEST["edit"];
  946.     } else {
  947.         $edit = htmlspecialchars($_REQUEST['edit']);
  948.     }
  949.     // add permisions here otherwise return error!
  950.     if(
  951.         isset($prefs['wiki_feature_copyrights'])
  952.         && $prefs['wiki_feature_copyrights'] == 'y'
  953.         && isset($_REQUEST['copyrightTitle'])
  954.         && isset($_REQUEST['copyrightYear'])
  955.         && isset($_REQUEST['copyrightAuthors'])
  956.         && !empty($_REQUEST['copyrightYear'])
  957.         && !empty($_REQUEST['copyrightTitle'])
  958.     ){
  959.  
  960.         include_once("lib/copyrights/copyrightslib.php");
  961.         $copyrightslib = new CopyrightsLib;
  962.         $copyrightYear = $_REQUEST['copyrightYear'];
  963.         $copyrightTitle = $_REQUEST['copyrightTitle'];
  964.         $copyrightAuthors = $_REQUEST['copyrightAuthors'];
  965.         $copyrightslib->add_copyright($page,$copyrightTitle,$copyrightYear,$copyrightAuthors,$user);
  966.     }
  967.  
  968.     // Parse $edit and eliminate image references to external URIs (make them internal)
  969.     $edit = $imagegallib->capture_images($edit);
  970.     // apply the optional page edit filters before data storage
  971.     $edit = $tikilib->apply_postedit_handlers($edit);
  972.     $exist = $tikilib->page_exists($_REQUEST['page']);
  973.     if( ! $exist && $prefs['wikiapproval_delete_staging'] == 'y'
  974.         && $approvedPageName = $tikilib->get_approved_page( $_REQUEST['page'] ) ) { //needs to create the first history = initial page for history
  975.         if ($tikilib->page_exists($approvedPageName)) {
  976.             $wikilib->duplicate_page($approvedPageName, $_REQUEST['page']);
  977.             $exist = true;
  978.         }
  979.     }
  980.     // If page exists
  981.     if(!$exist) {
  982.         // Extract links and update the page
  983.         $links = $tikilib->get_links($_REQUEST["edit"]);
  984.         /*
  985.            $notcachedlinks = $tikilib->get_links_nocache($_REQUEST["edit"]);
  986.            $cachedlinks = array_diff($links, $notcachedlinks);
  987.            $tikilib->cache_links($cachedlinks);
  988.          */
  989.         $tikilib->create_page($_REQUEST["page"], 0, $edit, $tikilib->now, $_REQUEST["comment"],$user,$tikilib->get_ip_address(),$description, $pageLang, $is_html, $hash, $_REQUEST['wysiwyg'], $wiki_authors_style);
  990.  
  991.         $info_new = $tikilib->get_page_info($page);
  992.  
  993.         if( $editlib->isNewTranslationMode() && ! empty( $pageLang ) )
  994.         {
  995.             include_once("lib/multilingual/multilinguallib.php");
  996.             $infoSource = $tikilib->get_page_info($editlib->sourcePageName);
  997.             $infoCurrent = $tikilib->get_page_info($editlib->targetPageName);
  998.             if ($multilinguallib->insertTranslation('wiki page', $infoSource['page_id'], $infoSource['lang'], $infoCurrent['page_id'], $pageLang)){
  999.                 $pageLang = $info['lang'];
  1000.                 $smarty->assign('msg', tra("The language can't be changed as its set of translations has already this language"));
  1001.                 $smarty->display("error.tpl");
  1002.                 die;
  1003.             }
  1004.         }
  1005.  
  1006.         create_staging($cats, $cat_type, $cat_name, $cat_objid, $edit, $description, $pageLang, $is_html, $hash, $page, $user);
  1007.  
  1008.         if ($prefs['feature_multilingual'] == 'y') {
  1009.             include_once("lib/multilingual/multilinguallib.php");
  1010.  
  1011.             if ( $oldpage = $tikilib->get_approved_page( $page ) ) {
  1012.                 $oldpageid = $tikilib->get_page_id_from_name($oldpage);
  1013.                 $oldtrads = $multilinguallib->getTrads('wiki page', $oldpageid);
  1014.                 foreach ($oldtrads as $ot) {
  1015.                     $oldtradname = $prefs['wikiapproval_prefix'] . $tikilib->get_page_name_from_id($ot["objId"]);
  1016.                     if ($ot["lang"] != $pageLang && $tikilib->page_exists($oldtradname)) {
  1017.                         $multilinguallib->insertTranslation('wiki page', $tikilib->get_page_id_from_name($page), $pageLang, $tikilib->get_page_id_from_name($oldtradname), $ot["lang"]);
  1018.                         break;                                 
  1019.                     }                          
  1020.                 }
  1021.             }
  1022.  
  1023.             unset( $tikilib->cache_page_info );
  1024.             if( $editlib->isNewTranslationMode() ) {
  1025.                 if ($editlib->aTranslationWasSavedAs('complete')) {
  1026.                     $editlib->saveCompleteTranslation();
  1027.                 } else if ($editlib->aTranslationWasSavedAs('partial')) {
  1028.                     $editlib->savePartialTranslation();
  1029.                 }
  1030.             } else {
  1031.                 $info = $tikilib->get_page_info( $_REQUEST['page'] );
  1032.                 $multilinguallib->createTranslationBit( 'wiki page', $info['page_id'], 1 );
  1033.             }
  1034.         }
  1035.     } else {
  1036.         $links = $tikilib->get_links($edit);
  1037.         /*
  1038.            $tikilib->cache_links($links);
  1039.          */
  1040.         $minor=(isset($_REQUEST['isminor'])&&$_REQUEST['isminor']=='on') ? 1 : 0;
  1041.  
  1042.         if ((isset($_REQUEST['hdr']) || (!empty($_REQUEST['pos']) && isset($_REQUEST['cell']))) && $prefs['wiki_edit_section'] == 'y') {
  1043.             if (isset($_REQUEST['hdr'])) {
  1044.                 if ($_REQUEST['hdr'] == 0) {
  1045.                     list($real_start, $real_len) = $tikilib->get_wiki_section($info['data'], 1);
  1046.                     $real_len = $real_start;
  1047.                     $real_start = 0;
  1048.                 } else {
  1049.                     list($real_start, $real_len) = $tikilib->get_wiki_section($info['data'], $_REQUEST['hdr']);
  1050.                 }
  1051.             } else {
  1052.                 include_once('lib/wiki-plugins/wikiplugin_split.php');
  1053.                 list($real_start, $real_len) = wikiplugin_split_cell($info['data'], $_REQUEST['pos'], $_REQUEST['cell']);
  1054.             }
  1055.             if ($edit[strlen($edit) - 1] != "\n")
  1056.                 $edit .= "\r\n";
  1057.             $edit = substr($info['data'], 0, $real_start).$edit.substr($info['data'], $real_start + $real_len);
  1058.         }
  1059.         if (isset($_REQUEST['wysiwyg']) && $_REQUEST['wysiwyg'] == 'y' && $prefs['wysiwyg_wiki_parsed'] == 'y') {//take away the <p> that fck introduces around wiki heading ! to have maketoc/edit section working
  1060.             $edit = preg_replace('/<p>!(.*)<\/p>/u', "!$1\n", $edit);
  1061.         }
  1062.         $tikilib->update_page($_REQUEST["page"],$edit,$_REQUEST["comment"],$user,$tikilib->get_ip_address(),$description,$minor,$pageLang, $is_html, $hash, null, $_REQUEST['wysiwyg'], $wiki_authors_style);
  1063.         create_staging($cats, $cat_type, $cat_name, $cat_objid, $edit, $description, $pageLang, $is_html, $hash, $page, $user);
  1064.         $info_new = $tikilib->get_page_info($page);
  1065.  
  1066.         // Handle translation bits
  1067.         if ($prefs['feature_multilingual'] == 'y' && !$minor) {
  1068.             global $multilinguallib; include_once("lib/multilingual/multilinguallib.php");
  1069.             unset( $tikilib->cache_page_info );
  1070.  
  1071.             if( $editlib->isUpdateTranslationMode() ) {
  1072.                 if ($editlib->aTranslationWasSavedAs('complete')) {
  1073.                     $editlib->saveCompleteTranslation();
  1074.                 } else if ($editlib->aTranslationWasSavedAs('partial')) {
  1075.                     $editlib->savePartialTranslation();
  1076.                 }
  1077.             } else {
  1078.                 $info = $tikilib->get_page_info( $_REQUEST['page'] );
  1079.                 $flags = array();
  1080.                 if( isset( $_REQUEST['translation_critical'] ) ) {
  1081.                     $flags[] = 'critical';
  1082.                 }
  1083.                 $multilinguallib->createTranslationBit( 'wiki page', $info['page_id'], $info['version'], $flags );
  1084.             }
  1085.         }
  1086.     }
  1087.     //Page may have been inserted from a structure page view
  1088.     if (isset($_REQUEST['current_page_id']) ) {
  1089.         $page_info = $structlib->s_get_page_info($_REQUEST['current_page_id']);
  1090.         $pageAlias = $page_info['page_alias'];
  1091.         if (isset($_REQUEST["add_child"]) ) {
  1092.             //Insert page after last child of current page
  1093.             $subpages = $structlib->s_get_pages($_REQUEST["current_page_id"]);
  1094.             $max = count($subpages);
  1095.             $last_child_ref_id = null;
  1096.             if ($max != 0) {
  1097.                 $last_child = $subpages[$max - 1];
  1098.                 $last_child_ref_id = $last_child["page_ref_id"];
  1099.             }
  1100.             $page_ref_id = $structlib->s_create_page($_REQUEST['current_page_id'], $last_child_ref_id, $_REQUEST["page"], '', $page_info['structure_id']);
  1101.         } else {
  1102.             //Insert page after current page
  1103.             $page_ref_id = $structlib->s_create_page($page_info["parent_id"], $_REQUEST['current_page_id'], $_REQUEST["page"], '', $page_info['structure_id']);
  1104.         }
  1105.         //Criss Holman added the if containing this code of which I don't know the use, but a check before the permissions copy
  1106.         //is definitely needed in case someone has tiki_p_edit/tiki_p_admin_wiki in a page belonging to a structure. chealer
  1107.         if ($tikilib->user_has_perm_on_object($user, $_REQUEST["page"],'wiki page', 'tiki_p_admin_wiki', 'tiki_p_admin_categories'))
  1108.             $userlib->copy_object_permissions($page_info["pageName"], $_REQUEST["page"],'wiki page');
  1109.     }
  1110.  
  1111.     // If the watch state is not the same
  1112.     if( $requestedWatch !== $currentlyWatching ) {
  1113.         if( $requestedWatch ) {
  1114.             $tikilib->add_user_watch( $user, 'wiki_page_changed', $page, 'wiki page', $page, $wikilib->sefurl($page) );
  1115.         } else {
  1116.             $tikilib->remove_user_watch( $user, 'wiki_page_changed', $page, 'wiki page' );
  1117.         }
  1118.     }
  1119.  
  1120.     if ($page_ref_id) {
  1121.         $url = "tiki-index.php?page_ref_id=$page_ref_id";
  1122.     } else {
  1123.         $url = $wikilib->sefurl($page);
  1124.     }
  1125.     if ($prefs['feature_best_language'] == 'y' || isset($_REQUEST['save'])) {
  1126.         $url .= '&no_bl=y';
  1127.     }
  1128.     $_SESSION['saved_msg'] = $_REQUEST["page"];
  1129.  
  1130.     if (!empty($_REQUEST['hdr'])) {
  1131.         $tmp = $tikilib->parse_data($edit);         // fills $anch[] so page refreshes at the section being edited
  1132.         $url .= "#".$anch[$_REQUEST['hdr']-1]['id'];
  1133.     }
  1134.    
  1135.     if ($dieInsteadOfForwardingWithHeader) die ("-- tiki-editpage: Dying before third call to header(), so we can see traces. Forwarding to: '$url'");
  1136.     header("location: $url");
  1137.     die;
  1138. } //save
  1139. $smarty->assign('pageAlias',$pageAlias);
  1140. if ($prefs['feature_wiki_templates'] == 'y' && $tiki_p_use_content_templates == 'y') {
  1141.     global $templateslib; require_once 'lib/templates/templateslib.php';
  1142.     $templates = $templateslib->list_templates('wiki', 0, -1, 'name_asc', '');
  1143.     $smarty->assign_by_ref('templates', $templates["data"]);
  1144. }
  1145. if ($prefs['feature_polls'] =='y' and $prefs['feature_wiki_ratings'] == 'y' && $tiki_p_wiki_admin_ratings == 'y') {
  1146.     if (!isset($polllib) or !is_object($polllib)) include("lib/polls/polllib_shared.php");
  1147.     if (!isset($categlib) or !is_object($categlib)) include("lib/categories/categlib.php");
  1148.     if (isset($_REQUEST['removepoll'])) {
  1149.         $catObjectId = $categlib->is_categorized($cat_type,$cat_objid);
  1150.         $polllib->remove_object_poll( $cat_type, $cat_objid, $_REQUEST['removepoll'] );
  1151.     }
  1152.     $polls_templates = $polllib->get_polls('t');
  1153.     $smarty->assign('polls_templates',$polls_templates['data']);
  1154.     $poll_rated = $polllib->get_ratings($cat_type,$cat_objid);
  1155.     $smarty->assign('poll_rated',$poll_rated);
  1156.     if (isset($_REQUEST['poll_template'])) {
  1157.         $smarty->assign('poll_template',$_REQUEST['poll_template']);
  1158.     }
  1159. }
  1160.  
  1161. if ($prefs['feature_multilingual'] == 'y') {
  1162.     $languages = array();
  1163.     $languages = $tikilib->list_languages();
  1164.     $smarty->assign_by_ref('languages', $languages);
  1165.  
  1166.     if( $editlib->isNewTranslationMode() ) {
  1167.         $smarty->assign( 'translationOf', $editlib->sourcePageName );
  1168.  
  1169.         if( $tikilib->page_exists( $page ) ) {
  1170.             // Display an error if the page already exists
  1171.             $smarty->assign('msg',
  1172.                                 tra("Page already exists. Go back and choose a different name.")."<P>".
  1173.                                 tra("Page name is").": '$page'");
  1174.             $smarty->display("error.tpl");
  1175.             die;
  1176.         }
  1177.  
  1178.         global $multilinguallib; include_once("lib/multilingual/multilinguallib.php");
  1179.         $sourceInfo = $tikilib->get_page_info( $editlib->sourcePageName );
  1180.         if( $multilinguallib->getTranslation('wiki page', $sourceInfo['page_id'], $_REQUEST['lang'] ) ) {
  1181.             // Display an error if the page already exists
  1182.             $smarty->assign('msg',tra("The translation set already contains a page in this language."));
  1183.             $smarty->display("error.tpl");
  1184.             die;
  1185.         }
  1186.     }
  1187.  
  1188.     if( $editlib->isTranslationMode() ) {
  1189.         include_once('lib/wiki/histlib.php');
  1190.         histlib_helper_setup_diff( $editlib->sourcePageName, $editlib->oldSourceVersion, $editlib->newSourceVersion );
  1191.         $smarty->assign( 'diff_oldver', (int) $editlib->oldSourceVersion );
  1192.         $smarty->assign( 'diff_newver', (int) $editlib->newSourceVersion );
  1193.         $smarty->assign('update_translation', 'y');
  1194.     }
  1195. }
  1196. $cat_type = 'wiki page';
  1197. $cat_objid = $_REQUEST["page"];
  1198. $cat_lang = $pageLang;
  1199. $cat_object_exists = $tikilib->page_exists( $_REQUEST['page'] );
  1200. if (!$cat_object_exists)
  1201.     $cookietab = 1;
  1202.  
  1203. $smarty->assign('section',$section);
  1204. include_once ('tiki-section_options.php');
  1205. if ($prefs['feature_freetags'] == 'y') {
  1206.     include_once ('freetag_list.php');
  1207.     // if given in the request, set the freetag list (used for preview mode, when coming back from zoom mode, ...)
  1208.     if ( isset($_REQUEST['freetag_string']) ) {
  1209.         $smarty->assign('taglist', $_REQUEST['freetag_string']);
  1210.     } elseif( $editlib->isNewTranslationMode() ) {
  1211.         $tags = $freetaglib->get_all_tags_on_object_for_language($editlib->sourcePageName, 'wiki page', $pageLang);
  1212.         $smarty->assign( 'taglist', implode( ' ', $tags ) );
  1213.     }
  1214. }
  1215. if ($prefs['feature_categories'] == 'y') {
  1216.     include_once ("categorize_list.php");
  1217.    
  1218.     if (isset($_REQUEST["current_page_id"]) && $prefs['feature_wiki_categorize_structure'] == 'y' && $categlib->is_categorized('wiki page', $structure_info["pageName"])) {
  1219.         $categIds = $categlib->get_object_categories('wiki page', $structure_info["pageName"]);
  1220.         $smarty->assign('categIds',$categIds);
  1221.     }
  1222.     if (isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], 'tiki-index.php') && !$tikilib->page_exists($_REQUEST["page"])) { // default the categs the page you come from for a new page
  1223.         if (preg_match('/page=([^\&]+)/', $_SERVER['HTTP_REFERER'], $ms))
  1224.             $p = $ms[1];
  1225.         else
  1226.             $p = $wikilib->get_default_wiki_page();
  1227.         $cs = $categlib->get_object_categories('wiki page', $p);
  1228.         for ($i = count($categories) - 1; $i >= 0; --$i) {
  1229.             if (in_array($categories[$i]['categId'], $cs))
  1230.                 $categories[$i]['incat'] = 'y';
  1231.         }
  1232.     }
  1233. }
  1234.  
  1235. $is_staging_article = ($prefs['wikiapproval_staging_category'] > 0) && (in_array($prefs['wikiapproval_staging_category'], $cats));
  1236. $page_badchars_display = ":/?#[]@!$&'()*+,;=<>";
  1237. $page_badchars = "/[:\/?#\[\]@!$&'()*+,;=<>]/";
  1238. if ($is_staging_article && $approved = $tikilib->get_approved_page($page) ) {
  1239.     $page_name = $approved;
  1240. }
  1241. else {
  1242.     $page_name = $page;
  1243. }
  1244.  
  1245. $matches = preg_match($page_badchars, $page_name);
  1246. if ($matches && ! $tikilib->page_exists($page) ) {
  1247.     $smarty->assign('page_badchars_display', $page_badchars_display);
  1248. }
  1249.  
  1250. $plugins = $wikilib->list_plugins(true, 'editwiki');
  1251.  
  1252. $smarty->assign_by_ref('plugins', $plugins);
  1253. $smarty->assign('showstructs', array());
  1254. if ($structlib->page_is_in_structure($_REQUEST["page"])) {
  1255.     $structs = $structlib->get_page_structures($_REQUEST["page"]);
  1256.     $smarty->assign('showstructs', $structs);
  1257. }
  1258. // Flag for 'page bar' that currently 'Edit' mode active
  1259. // so no need to show comments & attachments, but need
  1260. // to show 'wiki quick help'
  1261. $smarty->assign('edit_page', 'y');
  1262. $smarty->assign('categ_checked', 'n');
  1263. // Set variables so the preview page will keep the newly inputted category information
  1264. if (isset($_REQUEST['cat_categorize'])) {
  1265.     if ($_REQUEST['cat_categorize'] == 'on') {
  1266.         $smarty->assign('categ_checked', 'y');
  1267.     }
  1268. }
  1269. if ($prefs['wiki_feature_copyrights'] == 'y' && $tiki_p_edit_copyrights == 'y') {
  1270.     include_once ('lib/copyrights/copyrightslib.php');
  1271.     $copyrightslib = new CopyrightsLib;
  1272.     $copyrights = $copyrightslib->list_copyrights($_REQUEST["page"]);
  1273.     if ($copyrights['cant'])
  1274.     $smarty->assign_by_ref('copyrights', $copyrights['data']);
  1275. }
  1276. $defaultRows = $prefs['default_rows_textarea_wiki'];
  1277. include_once ('lib/toolbars/toolbarslib.php');
  1278. if (!$user or $user == 'anonymous') {
  1279.     $smarty->assign('anon_user', 'y');
  1280. }
  1281. if ($prefs['feature_contribution'] == 'y') {
  1282.     include_once('contribution.php');
  1283. }
  1284. if ($prefs['feature_wikiapproval'] == 'y') {
  1285.     if ( $approvedPageName = $tikilib->get_approved_page( $page ) ) {
  1286.         $smarty->assign('beingStaged', 'y');
  1287.         $smarty->assign('approvedPageName', $approvedPageName);
  1288.         $approvedPageExists = $tikilib->page_exists($approvedPageName);
  1289.         $smarty->assign('approvedPageExists', $approvedPageExists);
  1290.     } elseif ($prefs['wikiapproval_approved_category'] > 0 && in_array($prefs['wikiapproval_approved_category'], $cats)) {     
  1291.         $stagingPageName = $prefs['wikiapproval_prefix'] . $page;
  1292.         if ($prefs['wikiapproval_block_editapproved'] == 'y') {        
  1293.             if ($dieInsteadOfForwardingWithHeader) die ("-- tiki-editpage: Dying before fourth call to header(), so we can see traces. Forwarding to: 'tiki-editpage.php?page=$stagingPageName'");
  1294.             header("location: tiki-editpage.php?page=$stagingPageName");
  1295.         }
  1296.         $smarty->assign('needsStaging', 'y');
  1297.         $smarty->assign('stagingPageName', $stagingPageName);      
  1298.     }
  1299.     if ($prefs['wikiapproval_outofsync_category'] > 0 && in_array($prefs['wikiapproval_outofsync_category'], $cats)) {
  1300.         $smarty->assign('outOfSync', 'y');
  1301.         if (!isset($_REQUEST['preview'])) {
  1302.             $smarty->assign('preview',1);
  1303.             $parsed = $tikilib->parse_data($edit_data, array('is_html' => $is_html));
  1304.             $smarty->assign('parsed', $parsed);
  1305.             $smarty->assign('staging_preview', 'y');
  1306.         }
  1307.         if (isset($approvedPageName)) {
  1308.             include_once('lib/wiki/histlib.php');
  1309.             $approvedPageInfo = $histlib->get_page_from_history($approvedPageName, 0);
  1310.             if ($info['lastModif'] > $approvedPageInfo['lastModif']) {
  1311.                 $lastSyncVersion = $histlib->get_version_by_time($page, $approvedPageInfo['lastModif']);
  1312.                 // get very first version if unable to get last sync version.
  1313.                 if ($lastSyncVersion == 0) $lastSyncVersion = $histlib->get_version_by_time($page, 0, 'after');
  1314.                 // if really not possible, just give up.
  1315.                 if ($lastSyncVersion > 0) $smarty->assign('lastSyncVersion', $lastSyncVersion );
  1316.             }
  1317.         }      
  1318.     }
  1319. }
  1320.  
  1321. if( $prefs['feature_multilingual'] == 'y' ) {
  1322.     global $multilinguallib; include_once('lib/multilingual/multilinguallib.php');
  1323.     $trads = $multilinguallib->getTranslations('wiki page', $info['page_id'], $page, $info['lang']);
  1324.     $smarty->assign('trads', $trads);
  1325. }
  1326.  
  1327. // Get edit session timeout in seconds
  1328. $smarty->assign('edittimeout', ini_get('session.gc_maxlifetime'));
  1329.  
  1330. // setup tab showing flags (only avoiding empty tabs for now - regroup better of less than X features later)
  1331. // tools tab
  1332. if (($prefs['feature_wiki_templates'] == 'y' && $tiki_p_use_content_templates == 'y') ||
  1333.     ($prefs['feature_wiki_usrlock'] == 'y' && ($tiki_p_lock == 'y' || $tiki_p_admin_wiki == 'y')) ||
  1334.     ($prefs['feature_wiki_replace'] == 'y' && $_SESSION['wysiwyg'] != 'y') ||
  1335.     $prefs['wiki_spellcheck'] == 'y' ||
  1336.     ($prefs['feature_wiki_allowhtml'] == 'y' && $tiki_p_use_HTML == 'y' && $_SESSION['wysiwyg'] != 'y') ||
  1337.     $prefs['feature_wiki_import_html'] == 'y' ||
  1338.     $prefs['wiki_comments_allow_per_page'] != 'n' ||
  1339.     ($tiki_p_admin_wiki == 'y' && $prefs['feature_wiki_import_page'] == 'y') ||
  1340.     ($_SESSION['wysiwyg'] != 'y' && ($prefs['feature_wiki_attachments'] == 'y' && ($tiki_p_wiki_attach_files == 'y' && $tiki_p_wiki_admin_attachments == 'y')))) {
  1341.     $smarty->assign('showToolsTab', 'y');
  1342. }
  1343. if (strtolower($page) != 'sandbox' &&
  1344.             ($prefs['wiki_feature_copyrights']  == 'y' ||
  1345.             ($prefs['feature_freetags'] == 'y' && $tiki_p_freetags_tag == 'y') ||
  1346.             $prefs['feature_wiki_icache'] == 'y' ||
  1347.             $prefs['feature_contribution'] == 'y' ||
  1348.             $prefs['feature_wiki_structure'] == 'y' ||
  1349.             $prefs['wiki_feature_copyrights']  == 'y' ||
  1350.             ($tiki_p_admin_wiki == 'y' && $prefs['wiki_authors_style_by_page'] == 'y')) ||
  1351.         ($prefs['feature_wiki_description'] == 'y' || $prefs['metatag_pagedesc'] == 'y') ||
  1352.         $prefs['feature_wiki_footnotes'] == 'y' ||
  1353.         ($prefs['feature_wiki_ratings'] == 'y' && $tiki_p_wiki_admin_ratings =='y') ||
  1354.         $prefs['feature_multilingual'] == 'y') {
  1355.     $smarty->assign('showPropertiesTab', 'y');
  1356. }
  1357.  
  1358. ask_ticket('edit-page');
  1359. // disallow robots to index page:
  1360. $smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');
  1361. // Display the Edit Template or language check
  1362. if ($need_lang) {
  1363.     $smarty->assign('mid', 'tiki-choose_page_language.tpl');
  1364. } else {
  1365.     $smarty->assign('mid', 'tiki-editpage.tpl');
  1366. }
  1367. $smarty->assign('showtags', 'n');
  1368. $smarty->assign('qtnum', '1');
  1369. $smarty->assign('qtcycle', '');
  1370. $smarty->display("tiki.tpl");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement