Permalink
Browse files

working on integrating the new plugin system. need only edit plugin a…

…nd integration into the pages…
  • Loading branch information...
1 parent 11a6bbf commit 7aae787fea2e347a145133c30a52c8b656c15ab7 @frozeman committed Aug 1, 2012
View
@@ -354,7 +354,9 @@
<!-- ***************************************************************************************** -->
<!-- ** HEADER ******************************************************************************* -->
<header class="main">
+ <?php if(!empty($userConfig)) { ?>
<div id="sessionTimout" class="toolTipBottom blue" title="<?php echo $langFile['LOGIN_TIP_AUTOLOGOUT']; ?>::">00:00:00</div>
+ <?php } ?>
<!-- Top Anchor -->
<a id="top"></a>
@@ -1295,7 +1295,7 @@ public function createMetaTags($charset = 'UTF-8', $author = false, $publisher =
var feindura_deactivateFrontendEditing = '".$_SESSION['feinduraSession']['login']['deactivateFrontendEditing']."';
var feindura_langFile = {
ERRORWINDOW_TITLE: \"".$this->languageFile['errorWindow_h1']."\",
- ERROR_SAVE: \"".$this->languageFile['EDITOR_savepage_error_save']."\",
+ ERROR_SAVE: \"".$this->languageFile['ERROR_SAVEPAGE']."\",
ERROR_SETSTARTPAGE: \"".$this->languageFile['SORTABLEPAGELIST_setStartPage_error_save']."\",
FUNCTIONS_STARTPAGE_SET: \"".$this->languageFile['SORTABLEPAGELIST_functions_startPage_set']."\",
FUNCTIONS_STARTPAGE: \"".$this->languageFile['SORTABLEPAGELIST_functions_startPage']."\",
@@ -1104,26 +1104,28 @@ public static function savePage($pageContent) {
// write the plugins
if(is_array($pageContent['plugins'])) {
- foreach($pageContent['plugins'] as $key => $value) {
+ foreach($pageContent['plugins'] as $pluginName => $plugins) {
// save plugin settings only if plugin is activated
- if($pageContent['plugins'][$key]['active']) {
- foreach($value as $insideKey => $finalValue) {
- // CHECK BOOL VALUES and change to FALSE
- if(strpos(strtolower($insideKey),'bool') !== false ||
- is_bool($pageContent['plugins'][$key][$insideKey]) ||
- $pageContent['plugins'][$key][$insideKey] == 'true' ||
- $pageContent['plugins'][$key][$insideKey] == 'false')
- $fileContent .= "\$pageContent['plugins']['".$key."']['".$insideKey."'] = ".XssFilter::bool($pageContent['plugins'][$key][$insideKey],true).";\n";
- elseif(strpos(strtolower($insideKey),'url') !== false)
- $fileContent .= "\$pageContent['plugins']['".$key."']['".$insideKey."'] = '".XssFilter::url($pageContent['plugins'][$key][$insideKey])."';\n";
- elseif(strpos(strtolower($insideKey),'path') !== false)
- $fileContent .= "\$pageContent['plugins']['".$key."']['".$insideKey."'] = '".XssFilter::path($pageContent['plugins'][$key][$insideKey])."';\n";
- elseif(strpos(strtolower($insideKey),'number') !== false)
- $fileContent .= "\$pageContent['plugins']['".$key."']['".$insideKey."'] = '".XssFilter::number($pageContent['plugins'][$key][$insideKey])."';\n";
- else
- $fileContent .= "\$pageContent['plugins']['".$key."']['".$insideKey."'] = '".XssFilter::text($pageContent['plugins'][$key][$insideKey])."';\n";
+ foreach($plugins as $pluginNumber => $plugin) {
+ if($plugin['active']) {
+ foreach($plugin as $insideKey => $finalValue) {
+ // CHECK BOOL VALUES and change to FALSE
+ if(strpos(strtolower($insideKey),'bool') !== false ||
+ is_bool($plugin[$insideKey]) ||
+ $plugin[$insideKey] == 'true' ||
+ $plugin[$insideKey] == 'false')
+ $fileContent .= "\$pageContent['plugins']['".$pluginName."'][".$pluginNumber."]['".$insideKey."'] = ".XssFilter::bool($plugin[$insideKey],true).";\n";
+ elseif(strpos(strtolower($insideKey),'url') !== false)
+ $fileContent .= "\$pageContent['plugins']['".$pluginName."'][".$pluginNumber."]['".$insideKey."'] = '".XssFilter::url($plugin[$insideKey])."';\n";
+ elseif(strpos(strtolower($insideKey),'path') !== false)
+ $fileContent .= "\$pageContent['plugins']['".$pluginName."'][".$pluginNumber."]['".$insideKey."'] = '".XssFilter::path($plugin[$insideKey])."';\n";
+ elseif(strpos(strtolower($insideKey),'number') !== false)
+ $fileContent .= "\$pageContent['plugins']['".$pluginName."'][".$pluginNumber."]['".$insideKey."'] = '".XssFilter::number($plugin[$insideKey])."';\n";
+ else
+ $fileContent .= "\$pageContent['plugins']['".$pluginName."'][".$pluginNumber."]['".$insideKey."'] = '".XssFilter::text($plugin[$insideKey])."';\n";
+ }
+ $fileContent .= "\n";
}
- $fileContent .= "\n";
}
}
}
@@ -0,0 +1,128 @@
+<?php
+/*
+ feindura - Flat File Content Management System
+ Copyright (C) Fabian Vogelsteller [frozeman.de]
+
+ This program is free software;
+ you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with this program;
+ if not,see <http://www.gnu.org/licenses/>.
+
+* controllers/savePage.controller.php version 0.1
+*
+* Takes data and saves it in the pageContent array of the page.
+*
+* Needs the following POST array format:
+*
+* <code>
+* array (
+* 'page' => 2,
+* 'category' => 0,
+* 'return' => false, // whether or not the saved data should be returned
+* 'language' => 'en' // let it empty if the data is not localized
+* 'type' => 'title'
+* 'data' => array(
+* 0 => 'New Title'
+* )
+* )
+* </code>
+*
+*/
+
+/**
+ * Includes the login.include.php and feindura.include.php and filter the basic data
+ */
+require_once(dirname(__FILE__)."/../includes/secure.include.php");
+
+
+// SAVE the PAGE
+// -----------------------------------------------------------------------------
+if(is_numeric($_POST['page']) && !empty($_POST['type']) && is_array($_POST['data'])) {
+
+ // var
+ $return = '';
+ $langCode = ($websiteConfig['multiLanguageWebsite']['active']) ? $_POST['language'] : 0;
+
+ // read the page
+ $pageContent = GeneralFunctions::readPage($_POST['page'],$_POST['category']);
+
+ // switch the types
+ switch ($_POST['type']) {
+ // save the plugins
+ case 'plugins':
+ $pluginsBefore = $pageContent['plugins'];
+ unset($pageContent['plugins']);
+ foreach ($_POST['data'] as $plugins) {
+ $pluginNumber = substr($plugins, strpos($plugins, '#')+1);
+ $pluginName = substr($plugins, 0 ,strpos($plugins, '#'));
+
+ // add new plugins, but prevent to overwrite existing ones
+ if(is_array($pluginsBefore[$pluginName][$pluginNumber]))
+ $pageContent['plugins'][$pluginName][$pluginNumber] = $pluginsBefore[$pluginName][$pluginNumber];
+ else
+ $pageContent['plugins'][$pluginName][$pluginNumber]['active'] = true;
+ }
+ break;
+
+ default:
+ # code...
+ break;
+ }
+
+ // ->> SAVE the PAGE
+ if(GeneralFunctions::savePage($pageContent)) {
+ // clear cache
+ GeneralFunctions::deleteFolder(dirname(__FILE__).'/../../pages/cache/');
+
+ // ->> save the FEEDS, if activated
+ saveFeeds($pageContent['category']);
+ // ->> save the SITEMAP
+ saveSitemap();
+
+ // show the saved data if return is TRUE
+ if($_POST['return']) {
+ $return = str_replace("\'", "'", $return);
+ $return = str_replace('\"', '"', $return);
+ die($return);
+ }
+
+ // ->> on FAILURE
+ } else {
+ ?>
+ <script type="text/javascript">
+ /* <![CDATA[ */
+ var errorWindow = feindura_displayError('<?php echo $langFile['errorWindow_h1']; ?>','<?php echo $langFile['ERROR_SAVEPAGE']; ?>');
+ errorWindow.fade('hide');
+ errorWindow.inject(document.body);
+ errorWindow.fade(1);
+ /* ]]> */
+ </script>
+ <?php
+ }
+
+
+
+ // -> replace the existing data with the new one
+ // if(is_array($pageContent['localized'])) {
+ // $pageContent['localized'][$langCode]['title'] = ($_POST['type'] == 'title') ? $_POST['data'] : $pageContent['localized'][$langCode]['title'];
+ // $pageContent['localized'][$langCode]['content'] = ($_POST['type'] == 'editContent') ? $_POST['data'] : $pageContent['localized'][$langCode]['content'];
+ // $tmpReturn = ($_POST['type'] == 'title') ? $pageContent['localized'][$langCode]['title'] : $tmpReturn;
+ // $tmpReturn = ($_POST['type'] == 'editContent') ? $pageContent['localized'][$langCode]['content'] : $tmpReturn;
+ // // legacy fallback
+ // } else {
+ // $pageContent['title'] = ($_POST['type'] == 'title') ? $_POST['data'] : $pageContent['title'];
+ // $pageContent['content'] = ($_POST['type'] == 'editContent') ? $_POST['data'] : $pageContent['content'];
+ // $tmpReturn = ($_POST['type'] == 'title') ? $pageContent['title'] : $tmpReturn;
+ // $tmpReturn = ($_POST['type'] == 'editContent') ? $pageContent['content'] : $tmpReturn;
+ // }
+
+
+}
+
+?>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -23,14 +23,14 @@
// $activatedPlugins from editor.php
// vars
-$blockContentEdited = (isset($pageContent['plugins']))
- ? '&nbsp;<img src="library/images/icons/edited_small.png" class="toolTipLeft" title="'.$langFile['EDITOR_pluginSettings_h1'].' '.$langFile['EDITOR_block_edited'].'::" alt="icon" width="27" height="23">'
- : '';
+// $blockContentEdited = (isset($pageContent['plugins']))
+// ? '&nbsp;<img src="library/images/icons/edited_small.png" class="toolTipLeft" title="'.$langFile['EDITOR_pluginSettings_h1'].' '.$langFile['EDITOR_block_edited'].'::" alt="icon" width="27" height="23">'
+// : '';
?>
<div class="box">
- <h1><?php echo $langFile['EDITOR_pluginSettings_h1'].$blockContentEdited; ?></h1>
+ <h1><?php echo $langFile['EDITOR_pluginSettings_h1']; ?></h1>
<ul class="jsMultipleSelect resizeOnHover" data-jsMultipleSelect="plugins" data-name="plugins" data-type="duplicates">
<li class="filter"><input type="text" placeholder="<?php echo $langFile['SORTABLEPAGELIST_headText1']; ?>"></li>
<?php
@@ -44,11 +44,11 @@
// // vars
$pluginFolderName = basename($pluginFolder);
- $pluginCountryCode = (file_exists(dirname(__FILE__).'/../../plugins/'.$pluginFolderName.'/languages/'.$_SESSION['feinduraSession']['backendLanguage'].'.php'))
+ $pluginnumberryCode = (file_exists(dirname(__FILE__).'/../../plugins/'.$pluginFolderName.'/languages/'.$_SESSION['feinduraSession']['backendLanguage'].'.php'))
? $_SESSION['feinduraSession']['backendLanguage']
: 'en';
- // unset($pluginConfig,$pluginLangFile);
- $pluginLangFile = @include(dirname(__FILE__).'/../../plugins/'.$pluginFolderName.'/languages/'.$pluginCountryCode.'.php');
+ unset($pluginLangFile);
+ $pluginLangFile = @include(dirname(__FILE__).'/../../plugins/'.$pluginFolderName.'/languages/'.$pluginnumberryCode.'.php');
// $pluginConfig = @include(dirname(__FILE__).'/../../plugins/'.$pluginFolderName.'/config.php');
// $pluginName = (isset($pluginLangFile['feinduraPlugin_title'])) ? $pluginLangFile['feinduraPlugin_title'] : $pluginFolderName;
@@ -59,7 +59,101 @@
</ul>
- <ul class="jsMultipleSelectDestination" data-jsMultipleSelect="plugins">
-
+ <ul id="pluginMultipleSelect" class="jsMultipleSelectDestination" data-jsMultipleSelect="plugins">
+ <?php
+ foreach ($pageContent['plugins'] as $pluginName => $plugins) {
+ foreach ($plugins as $pluginNumber => $plugin) {
+ echo '<li data-name="plugins" data-value="'.$pluginName.'" data-number="'.$pluginNumber.'"></li>';
+ }
+ }
+ ?>
</ul>
+
+ <a href="#" class="ok button center" id="savePluginSelectionSubmit" style="display:none"></a>
+
+ <!-- EDIT PLUGINS SCRIPTS -->
+ <script type="text/javascript">
+ /* <![CDATA[ */
+ (function(){
+
+ // ADD the LINK to EDIT THE PLUGIN TO the OPTION
+ var modifyOption = function(value,name,clone){
+ // modify the selected plugin
+ var closeButton = clone.getChildren('a')[0];
+ var newLink = new Element('a',{'text':clone.get('text').replace('×',''), 'class':'editSelection', 'href': '#', events:{
+ click: function(e){
+ e.stop();
+
+ // vars
+ number = clone.retrieve('number');
+ openWindowBox('library/views/windowBox/editPlugins.php?plugin='+value+'&number='+number,newLink.get('text'));
+ }
+ }});
+ clone.set('html','');
+ clone.grab(newLink).grab(closeButton);
+ };
+
+
+ // ->> EVENTS
+ // SELECT
+ $('pluginMultipleSelect').addEvent('select',function(value,name,clone,option){
+ modifyOption(value,name,clone);
+
+ // show the save button
+ $('savePluginSelectionSubmit').show();
+
+ });
+
+ // PARESED
+ $('pluginMultipleSelect').addEvent('parsed',modifyOption);
+
+ // REMOVE
+ $('pluginMultipleSelect').addEvent('remove',function(value,name,clone,option,select){
+ // show the save button
+ $('savePluginSelectionSubmit').show();
+ });
+
+
+ // ON SAVE
+ $('savePluginSelectionSubmit').addEvent('click',function(e){
+ e.stop();
+
+ var selectedOptions = $('pluginMultipleSelect').retrieve('selectedOptions');
+ var selectedJson = {
+ 'page': <?php echo $pageContent['id']; ?>,
+ 'category': <?php echo $pageContent['category']; ?>,
+ 'return':false,
+ 'type':'plugins',
+ 'data':[]
+ };
+
+ selectedOptions.each(function(option){
+
+ var value = option.retrieve('value');
+ var number = option.retrieve('number');
+ value += '#'+ number;
+
+ if(typeOf(value) !== 'null')
+ selectedJson.data.push(value);
+ });
+
+ new Request({
+ url: 'library/controllers/savePage.controller.php',
+ method: 'post',
+ data: selectedJson,
+ evalScripts: true,
+ onRequest: function(){
+
+ },
+ onSuccess: function(responseText){
+ console.log(responseText);
+ }
+ }).send();
+
+ });
+
+ })();
+ /* ]]> */
+ </script>
+
</div>
@@ -213,6 +213,7 @@ function resizeElementsOnHover() {
var orgSize = element.getSize().y;
element.setStyle('height',startSize);
+ element.set('tween',{transition: Fx.Transitions.Quint.easeInOut})
element.addEvents({
'mouseenter': function(){
element.tween('height',orgSize);
@@ -76,7 +76,8 @@ function feindura_str_replace(s, r, c) {
function feindura_displayError(title,errorText) {
// creates the errorWindow
var errorWindow = new Element('div',{id:'errorWindow','class':'feindura', 'style':'left:50%;margin-left:-260px;'});
- errorWindow.grab(new Element('div',{'class':'feindura_top', 'html': title}));
+ errorWindow.setStyle('top',window.getScroll().y + 100);
+ errorWindow.grab(new Element('h1',{'text': title}));
var errorWindowContent = new Element('div',{'class':'content warning', 'html':'<div class="scroll">'+errorText+'</div>'});
var errorWindowOkButton = new Element('a',{'class':'ok button center', 'href':'#'});
errorWindowContent.grab(errorWindowOkButton);
@@ -162,8 +162,12 @@ function requestSite(site,siteTitle,dataOrFormId) {
// Inject the new DOM elements into the h1.
windowBox.grab(new Element('h1',{'text':siteTitle}),'top');
+ } else {
+ if(typeOf($$('#windowBox > h1')[0]) !== 'null')
+ $$('#windowBox > h1')[0].destroy();
}
+
/* set toolTips to all objects with a toolTip class */
setToolTips();
@@ -51,7 +51,7 @@
$sharedLangFile['errorWindow_h1'] = 'Es sind Fehler aufgetreten!';
$sharedLangFile['SORTABLEPAGELIST_setStartPage_error_save'] = '<b>Die Startseite konnte nicht festgelegt werden.</b>';
-$sharedLangFile['EDITOR_savepage_error_save'] = '<b>Die Seite konnte nicht gespeichert werden.</b>';
+$sharedLangFile['ERROR_SAVEPAGE'] = '<b>Die Seite konnte nicht gespeichert werden.</b>';
$sharedLangFile['ADMINSETUP_ERROR_PHPVERSION'] = 'FEHLER<br><br><span class="feinduraInline">fein<em>dura</em></span> benötigt mindestens PHP version'; // PHP 5.1
@@ -51,7 +51,7 @@
$sharedLangFile['errorWindow_h1'] = 'An error occured!';
$sharedLangFile['SORTABLEPAGELIST_setStartPage_error_save'] = '<b>Could not set the start page.</b>';
-$sharedLangFile['EDITOR_savepage_error_save'] = '<b>The page could not be saved.</b>';
+$sharedLangFile['ERROR_SAVEPAGE'] = '<b>The page could not be saved.</b>';
$sharedLangFile['ADMINSETUP_ERROR_PHPVERSION'] = 'ERROR<br><br><span class="feinduraInline">fein<em>dura</em></span> requires at least PHP version'; // PHP 5.2.3
// -----------------------------------------------------------------------------------------------
@@ -53,7 +53,7 @@
$sharedLangFile['errorWindow_h1'] = 'une erreur s\'est produite!';
$sharedLangFile['SORTABLEPAGELIST_setStartPage_error_save'] = '<b>activation de la page d\'accueil impossible.</b>';
-$sharedLangFile['EDITOR_savepage_error_save'] = '<b>Cette page ne pouvait pas être sauvegardée.</b>';
+$sharedLangFile['ERROR_SAVEPAGE'] = '<b>Cette page ne pouvait pas être sauvegardée.</b>';
$sharedLangFile['ADMINSETUP_ERROR_PHPVERSION'] = 'ERREUR<br><br><span class="feinduraInline">fein<em>dura</em></span> nécessite au moins la version de PHP'; // PHP 5.2.3
// -----------------------------------------------------------------------------------------------
Oops, something went wrong.

0 comments on commit 7aae787

Please sign in to comment.