Permalink
Browse files

build 970: add restore last version feature

  • Loading branch information...
1 parent 32a7ba6 commit a2396cf3393ed749beb65718ba21d1bd436a051b @frozeman committed Aug 20, 2012
View
@@ -1,7 +1,7 @@
feindura - Flat File Content Management System
Version
2.0 beta
-Build 969
+Build 970
==================================================
Copyright (C) Fabian Vogelsteller [frozeman.de]
published under the GNU General Public License version 3
@@ -24,6 +24,7 @@ ChangeLog:
2.0 beta
+ build 970: add restore last version feature
build 969: made more use of the pagesMetaData array, should boost the perfomance, still issues with the previous state button
build 968: changed versin name to beta, moved userlist to the header sidebar
build 967: small header fixes
View
@@ -1,3 +1,3 @@
feindura - Flat File CMS (Version,Build)
2.0 beta
-969
+970
View
@@ -29,6 +29,7 @@
*/
require_once(dirname(__FILE__)."/library/controller.loader.php");
+
// VARs
// -----------------------------------------------------------------------------------
// store the current location, this will be used when the user comes back from the frontend
@@ -220,7 +221,7 @@
},
//complete
onComplete: function () {
- window.location = 'index.php?logout';
+ window.location.href = 'index.php?logout';
}
})
<?php } ?>
@@ -244,8 +245,8 @@
<div class="menuBlock">
<div class="languageSelection">
- <a href="<?php echo GeneralFunctions::addParameterToUrl('backendLanguage','de'); ?>" tabindex="20" class="de toolTipBottom" title="Deutsch::"></a>
- <a href="<?php echo GeneralFunctions::addParameterToUrl('backendLanguage','en'); ?>" tabindex="21" class="en toolTipBottom" title="English::"></a>
+ <a href="<?php echo GeneralFunctions::addParameterToUrl('backendLanguage','en'); ?>" tabindex="20" class="en toolTipBottom" title="English::"></a>
+ <a href="<?php echo GeneralFunctions::addParameterToUrl('backendLanguage','de'); ?>" tabindex="21" class="de toolTipBottom" title="Deutsch::"></a>
<a href="<?php echo GeneralFunctions::addParameterToUrl('backendLanguage','fr'); ?>" tabindex="22" class="fr toolTipBottom" title="français::"></a>
<a href="<?php echo GeneralFunctions::addParameterToUrl('backendLanguage','it'); ?>" tabindex="23" class="it toolTipBottom" title="italiano::"></a>
<a href="<?php echo GeneralFunctions::addParameterToUrl('backendLanguage','ru'); ?>" tabindex="24" class="ru toolTipBottom" title="русский::"></a>
@@ -364,6 +365,9 @@
// -> CHECK for deletePageThumbnail
$showPageThumbnailDelete = (empty($_GET['site']) && !empty($pageContent['thumbnail'])) ? true : false;
+ // -> CHECK for restore page (if and old state exists)
+ $showRestorePage = ($previousStatePageContent) ? true : false;
+
// -> CHECK if show SUBMENU
$showSubMenu = (($showPageThumbnailUpload || $showCreatePage || $showPageThumbnailUpload || GeneralFunctions::hasPermission('fileManager') || $showDeletePage)) ? true : false;
@@ -471,6 +475,7 @@
<?php if($showFrontendEditing ||
$showDeletePage ||
+ $showRestorePage ||
$showPageThumbnailUpload ||
$showPageThumbnailDelete ||
($websiteConfig['multiLanguageWebsite']['active'] && $isInPageEditor) ||
@@ -518,9 +523,22 @@
<li><a <?php echo 'href="?site=deletePage&amp;category='.$_GET['category'].'&amp;page='.$_GET['page'].'" onclick="openWindowBox(\'library/views/windowBox/deletePage.php?category='.$_GET['category'].'&amp;page='.$_GET['page'].'\',\''.$langFile['BUTTON_DELETEPAGE'].'\');return false;" title="'.$langFile['BUTTON_DELETEPAGE'].'::'.$langFile['BUTTON_TOOLTIP_DELETEPAGE'].'"'; ?> tabindex="32" class="deletePage toolTipBottom"></a></li>
- <?php $showSpacer = true;
+ <?php $showSpacer = false;
}
+ // RESTORE PAGE
+ if($showRestorePage) {
+ if($showSpacer) { ?>
+
+ <li class="spacer"></li>
+
+ <?php } ?>
+
+ <li><a <?php echo 'href="index.php?category='.$pageContent['category'].'&amp;page='.$pageContent['id'].'&amp;status=revertToPreviousState&amp;reload='.rand(0,999).'" title="::'.sprintf($langFile['EDITOR_BUTTON_RESTORELASTSTATE'],GeneralFunctions::dateDayBeforeAfter($previousStatePageContent['lastSaveDate']).' '.formatTime($previousStatePageContent['lastSaveDate'])).'"'; ?> tabindex="33" class="restorePage toolTipBottom"></a></li>
+
+ <?php
+ } if($showDeletePage || $showRestorePage) $showSpacer = true;
+
// PAGETHUMBNAILUPLOAD
if($showPageThumbnailUpload) {
if($showSpacer) { ?>
@@ -529,13 +547,13 @@
<?php } ?>
- <li><a <?php echo 'href="?site=uploadPageThumbnail&amp;category='.$_GET['category'].'&amp;page='.$_GET['page'].'" onclick="openWindowBox(\'library/views/windowBox/uploadPageThumbnail.php?site='.$_GET['site'].'&amp;category='.$_GET['category'].'&amp;page='.$_GET['page'].'\',\''.$langFile['BUTTON_THUMBNAIL_UPLOAD'].'\');return false;" title="'.$langFile['BUTTON_THUMBNAIL_UPLOAD'].'::'.$langFile['BUTTON_TOOLTIP_THUMBNAIL_UPLOAD'].'"'; ?> tabindex="33" class="uploadPageThumbnail toolTipBottom"></a></li>
+ <li><a <?php echo 'href="?site=uploadPageThumbnail&amp;category='.$_GET['category'].'&amp;page='.$_GET['page'].'" onclick="openWindowBox(\'library/views/windowBox/uploadPageThumbnail.php?site='.$_GET['site'].'&amp;category='.$_GET['category'].'&amp;page='.$_GET['page'].'\',\''.$langFile['BUTTON_THUMBNAIL_UPLOAD'].'\');return false;" title="'.$langFile['BUTTON_THUMBNAIL_UPLOAD'].'::'.$langFile['BUTTON_TOOLTIP_THUMBNAIL_UPLOAD'].'"'; ?> tabindex="34" class="uploadPageThumbnail toolTipBottom"></a></li>
<?php
// PAGETHUMBNAILDELETE
if($showPageThumbnailDelete) { ?>
- <li><a <?php echo 'href="?site=deletePageThumbnail&amp;category='.$_GET['category'].'&amp;page='.$_GET['page'].'" onclick="openWindowBox(\'library/views/windowBox/deletePageThumbnail.php?site='.$_GET['site'].'&amp;category='.$_GET['category'].'&amp;page='.$_GET['page'].'\',\''.$langFile['BUTTON_THUMBNAIL_DELETE'].'\');return false;" title="'.$langFile['BUTTON_THUMBNAIL_DELETE'].'::'.$langFile['BUTTON_TOOLTIP_THUMBNAIL_DELETE'].'"'; ?> tabindex="34" class="deletePageThumbnail toolTipBottom"></a></li>
+ <li><a <?php echo 'href="?site=deletePageThumbnail&amp;category='.$_GET['category'].'&amp;page='.$_GET['page'].'" onclick="openWindowBox(\'library/views/windowBox/deletePageThumbnail.php?site='.$_GET['site'].'&amp;category='.$_GET['category'].'&amp;page='.$_GET['page'].'\',\''.$langFile['BUTTON_THUMBNAIL_DELETE'].'\');return false;" title="'.$langFile['BUTTON_THUMBNAIL_DELETE'].'::'.$langFile['BUTTON_TOOLTIP_THUMBNAIL_DELETE'].'"'; ?> tabindex="35" class="deletePageThumbnail toolTipBottom"></a></li>
<?php }
$showSpacer = true;
@@ -553,15 +571,15 @@
<?php }
if($missingLanguages) { ?>
- <li><a <?php echo 'href="?site=addPageLanguage&amp;category='.$_GET['category'].'&amp;page='.$_GET['page'].'" onclick="openWindowBox(\'library/views/windowBox/addPageLanguage.php?site='.$_GET['site'].'&amp;category='.$_GET['category'].'&amp;page='.$_GET['page'].'\',\''.$langFile['BUTTON_WEBSITELANGUAGE_ADD'].'\');return false;" title="'.$langFile['BUTTON_WEBSITELANGUAGE_ADD'].'::'.$langFile['BUTTON_TOOLTIP_WEBSITELANGUAGE_ADD'].'"'; ?> tabindex="35" class="addPageLanguage toolTipBottom"></a></li>
+ <li><a <?php echo 'href="?site=addPageLanguage&amp;category='.$_GET['category'].'&amp;page='.$_GET['page'].'" onclick="openWindowBox(\'library/views/windowBox/addPageLanguage.php?site='.$_GET['site'].'&amp;category='.$_GET['category'].'&amp;page='.$_GET['page'].'\',\''.$langFile['BUTTON_WEBSITELANGUAGE_ADD'].'\');return false;" title="'.$langFile['BUTTON_WEBSITELANGUAGE_ADD'].'::'.$langFile['BUTTON_TOOLTIP_WEBSITELANGUAGE_ADD'].'"'; ?> tabindex="36" class="addPageLanguage toolTipBottom"></a></li>
<?php
}
// DELETE PAGE LANGUAGE
if(isset($_GET['page']) && !isset($pageContent['localized'][0]) && isset($pageContent['localized'][$_SESSION['feinduraSession']['websiteLanguage']])) { ?>
<!-- <li class="spacer"></li> -->
- <li><a <?php echo 'href="?site=deletePageLanguage&amp;category='.$_GET['category'].'&amp;page='.$_GET['page'].'&amp;language='.$_SESSION['feinduraSession']['websiteLanguage'].'" onclick="openWindowBox(\'library/views/windowBox/deletePageLanguage.php?site='.$_GET['site'].'&amp;category='.$_GET['category'].'&amp;page='.$_GET['page'].'&amp;language='.$_SESSION['feinduraSession']['websiteLanguage'].'\',\''.$langFile['BUTTON_WEBSITELANGUAGE_DELETE'].'\');return false;" title="'.$langFile['BUTTON_WEBSITELANGUAGE_DELETE'].'::'.sprintf($langFile['BUTTON_TOOLTIP_WEBSITELANGUAGE_DELETE'],'[strong]'.$languageNames[$_SESSION['feinduraSession']['websiteLanguage']].'[/strong]').'"'; ?> tabindex="36" class="removePageLanguage toolTipBottom"></a></li>
+ <li><a <?php echo 'href="?site=deletePageLanguage&amp;category='.$_GET['category'].'&amp;page='.$_GET['page'].'&amp;language='.$_SESSION['feinduraSession']['websiteLanguage'].'" onclick="openWindowBox(\'library/views/windowBox/deletePageLanguage.php?site='.$_GET['site'].'&amp;category='.$_GET['category'].'&amp;page='.$_GET['page'].'&amp;language='.$_SESSION['feinduraSession']['websiteLanguage'].'\',\''.$langFile['BUTTON_WEBSITELANGUAGE_DELETE'].'\');return false;" title="'.$langFile['BUTTON_WEBSITELANGUAGE_DELETE'].'::'.sprintf($langFile['BUTTON_TOOLTIP_WEBSITELANGUAGE_DELETE'],'[strong]'.$languageNames[$_SESSION['feinduraSession']['websiteLanguage']].'[/strong]').'"'; ?> tabindex="37" class="removePageLanguage toolTipBottom"></a></li>
<?php }
$showSpacer = true;
@@ -1632,7 +1632,7 @@ public function createMenu($idType = 'category', $ids = false, $menuTag = false,
// -> STOREs the LINKs in an Array
$links = array();
- if($pages !== false) {
+ if(!empty($pages)) {
// create a link out of every page in the array
foreach($pages as $page) {
// creates the link
@@ -1688,7 +1688,7 @@ public function createMenu($idType = 'category', $ids = false, $menuTag = false,
}
}
} else
- return array(false);
+ return array();
return $this->generateMenu($links,$menuTag,$breakAfter);
}
@@ -3061,7 +3061,7 @@ public function listPages($idType = 'category', $ids = false, $shortenText = fal
if($sortByCategories === true)
$pages = GeneralFunctions::sortPages($pages);
- if($pages !== false) {
+ if(!empty($pages)) {
// -> list a category(ies)
// ------------------------------
@@ -990,6 +990,7 @@ public static function readPage($page,$category = false,$readPrevious = false) {
// ->> ELSE load the page and store it in the storePages PROPERTY
} else {
+ // add the previous name when reading the previous state
$previous = ($readPrevious) ? '.previous' : '';
// adds .php to the end if its missing
@@ -1008,7 +1009,7 @@ public static function readPage($page,$category = false,$readPrevious = false) {
//echo 'CATEGORY: '.$category.'<br>';
// ->> INCLUDE
- if($fp = @fopen(dirname(__FILE__).'/../../pages/'.$category.$page,'r')) {
+ if($fp = @fopen(dirname(__FILE__).'/../../pages/'.$category.$page,'rb')) {
flock($fp,LOCK_SH);
$pageContent = @include(dirname(__FILE__).'/../../pages/'.$category.$page);
flock($fp,LOCK_UN);
@@ -1017,6 +1018,7 @@ public static function readPage($page,$category = false,$readPrevious = false) {
// return content array
if(is_array($pageContent)) {
+
// UNESCPAE the SINGLE QUOTES '
if(is_array($pageContent['localized'])) {
foreach ($pageContent['localized'] as $key => $value)
@@ -1055,6 +1057,7 @@ public static function readPage($page,$category = false,$readPrevious = false) {
* - <var>"\n?>"</var> the php end tag
*
* @param array $pageContent the $pageContent array of the page to save
+ * @param bool $readPrevious (optional) if TRUE it will save the given $pageContent as a previous state of the page
*
* @uses $adminConfig for the save path of the flatfiles
* @uses addStoredPage() to store the saved file agiain, and overwrite th old stored page
@@ -1074,7 +1077,7 @@ public static function readPage($page,$category = false,$readPrevious = false) {
* - 1.0 initial release
*
*/
- public static function savePage($pageContent) {
+ public static function savePage($pageContent,$savePrevious = false) {
// check if array is pageContent array
if(!self::isPageContentArray($pageContent))
@@ -1093,8 +1096,11 @@ public static function savePage($pageContent) {
// get path
$filePath = ($categoryId === false || $categoryId == 0)
- ? dirname(__FILE__).'/../../pages/'.$pageId.'.php'
- : dirname(__FILE__).'/../../pages/'.$categoryId.'/'.$pageId.'.php';
+ ? dirname(__FILE__).'/../../pages/'.$pageId
+ : dirname(__FILE__).'/../../pages/'.$categoryId.'/'.$pageId;
+
+ // previous or current state
+ $filePath .= ($savePrevious) ? '.previous.php' : '.php';
// escape \ and '
$pageContent = XssFilter::escapeBasics($pageContent);
@@ -1174,14 +1180,17 @@ public static function savePage($pageContent) {
@chmod($filePath,self::$adminConfig['permissions']);
- // writes the new saved page to the $storedPages property
- self::removeStoredPage($pageContent['id']); // remove the old one
- unset($pageContent);
- $pageContent = include($filePath);
- self::addStoredPage($pageContent);
+ // only when current, reload the storedPages array and pagesMetaData
+ if(!$savePrevious) {
+ // writes the new saved page to the $storedPages property
+ self::removeStoredPage($pageContent['id']); // remove the old one
+ unset($pageContent);
+ $pageContent = include($filePath);
+ self::addStoredPage($pageContent);
- // reload the $pagesMetaData array
- self::savePagesMetaData();
+ // reload the $pagesMetaData array
+ self::savePagesMetaData();
+ }
return true;
} else
@@ -2269,7 +2278,7 @@ static function createBreadCrumbsArray($page,$category) {
*/
public static function cleanPluginPlaceholders($content) {
// remove the src attribute
- $content = preg_replace('#src\=\"((?:(?!").)*library\/thirdparty\/ckeditor\/plugins\/feinduraSnippets\/snippetFill\.gif?)\"#i', 'src="#"', $content);
+ $content = preg_replace('#src\=\"((?:(?!").)*library\/thirdparty\/ckeditor\/plugins\/feinduraSnippets\/snippetFill\.gif?)\"#i', 'src="noImage.png"', $content);
// add the draggable=true back again
if(strpos($content, 'class="feinduraPlugin" draggable="true"') === false)
@@ -30,20 +30,21 @@
// REVERT to a PREVIOUS STATE
// -----------------------------------------------------------------------------
if(isBlocked() === false && $_GET['status'] == 'revertToPreviousState') {
- $categoryFolder = ($category == 0) ? '' : $category.'/';
- GeneralFunctions::dump(dirname(__FILE__).'/../../pages/'.$categoryFolder.$page.'.previous.php');
+ // vars
+ $categoryFolder = ($category == 0) ? '' : $category.'/';
if(file_exists(dirname(__FILE__).'/../../pages/'.$categoryFolder.$page.'.previous.php')) {
- // rename the previous to a temp name
- rename(dirname(__FILE__).'/../../pages/'.$categoryFolder.$page.'.previous.php', dirname(__FILE__).'/../../pages/'.$categoryFolder.$page.'.previousTmp.php');
- // rename the current state to ..previous.php
- copy(dirname(__FILE__).'/../../pages/'.$categoryFolder.$page.'.php', dirname(__FILE__).'/../../pages/'.$categoryFolder.$page.'.previous.php');
- // rename the previous to the current page
- if(rename(dirname(__FILE__).'/../../pages/'.$categoryFolder.$page.'.previousTmp.php', dirname(__FILE__).'/../../pages/'.$categoryFolder.$page.'.php')) {
- $messagePopUp .= '<div class="alert alert-info">Revert to the last State</div>';
- GeneralFunctions::removeStoredPage($page);
+
+ $currentState = GeneralFunctions::readPage($page,$category);
+ if(($previousState = GeneralFunctions::readPage($page,$category,true)) !== false) {
+
+ GeneralFunctions::savePage($previousState);
+ GeneralFunctions::savePage($currentState,true);
+
+ $messagePopUp .= '<div class="alert alert-info">'.sprintf($langFile['EDITOR_MESSAGE_RESTOREDTOLASTSTATE'],GeneralFunctions::dateDayBeforeAfter($previousState['lastSaveDate']).' '.formatTime($previousState['lastSaveDate'])).'</div>';
}
+ unset($currentState,$previousState);
}
}
@@ -230,8 +231,10 @@
// -> LOAD PAGE
-if($pageContent = GeneralFunctions::readPage($page,$category))
+if($pageContent = GeneralFunctions::readPage($page,$category)) {
$newPage = false;
+ $previousStatePageContent = GeneralFunctions::readPage($pageContent['id'],$pageContent['category'],true);
+}
// otherwise offer NEW PAGE
else
$newPage = true;
@@ -246,7 +249,7 @@
$activatedPlugins = unserialize($categoryConfig[$category]['plugins']);
// -> check if the thumbnail still exists, if not clear the thumbnail state of the file
-if(!file_exists(DOCUMENTROOT.$adminConfig['uploadPath'].$adminConfig['pageThumbnail']['path'].$pageContent['thumbnail']) && isBlocked() === false) {
+if(!empty($pageContent['thumbnail']) && isBlocked() === false && !file_exists(DOCUMENTROOT.$adminConfig['uploadPath'].$adminConfig['pageThumbnail']['path'].$pageContent['thumbnail'])) {
$pageContent['thumbnail'] = '';
GeneralFunctions::savePage($pageContent);
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -135,7 +135,7 @@
// -> SEND BACKEND HEADER
-header('Content-Type:text/html; charset=UTF-8');
-header('Content-Language:'.$_SESSION['feinduraSession']['backendLanguage']);
+// header('Content-Type:text/html; charset=UTF-8');
+// header('Content-Language:'.$_SESSION['feinduraSession']['backendLanguage']);
?>
@@ -24,7 +24,7 @@
?>
-<div class="box">
+<div class="box" id="selectPluginsBox">
<h1 class="toolTipTop" title="::<?php echo sprintf($langFile['EDITOR_TEXT_EDITPLUGINSINEDITOR'],'[i class=\'icons codeSnippets\'][/i]'); ?>"><img src="library/images/icons/pluginsIcon_middle.png" alt="icon" style="position:relative; top:-2px; margin-right:0px;"><?php echo $langFile['EDITOR_pluginSettings_h1']; ?></h1>
<ul class="jsMultipleSelect resizeOnHover" data-jsMultipleSelect="plugins" data-name="newPlugins" data-type="duplicates">
<li class="filter"><input type="text" placeholder="<?php echo $langFile['SORTABLEPAGELIST_headText1']; ?>"></li>
@@ -168,6 +168,10 @@
// ADD PLUGIN to the EDITOR
HTMLEditor.insertHtml(clone.retrieve('pluginPlaceholder').getString());
+
+ // fix the WEBKIT BUG, when selecting, that it scrolls
+ if(Browser.chrome || Browser.safari)
+ new Fx.Scroll(window.document,{duration:0}).toElement($('selectPluginsBox'));
});
// REMOVE
@@ -214,6 +214,6 @@
include(dirname(__FILE__).'/pageMetaData.include.php');
?>
- <input type="submit" value="" id="HTMLEditorSubmit" class="button submit center" title="<?php echo $langFile['FORM_BUTTON_SUBMIT']; ?>" onclick="$('savedBlock').value = 'pageSettings'; submitAnchor('editorForm','pageSettings');">
+ <input type="submit" value="" class="button submit center" title="<?php echo $langFile['FORM_BUTTON_SUBMIT']; ?>" onclick="$('savedBlock').value = 'pageSettings'; submitAnchor('editorForm','pageSettings');">
</div>
</div>
Oops, something went wrong.

0 comments on commit a2396cf

Please sign in to comment.