First commit
This commit is contained in:
BIN
cms/plugins/pluginloader/page_data/css/cross.gif
Normal file
BIN
cms/plugins/pluginloader/page_data/css/cross.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 631 B |
52
cms/plugins/pluginloader/page_data/css/stylesheet.css
Normal file
52
cms/plugins/pluginloader/page_data/css/stylesheet.css
Normal file
@ -0,0 +1,52 @@
|
||||
#pd_tabs {
|
||||
font-weight: normal;
|
||||
margin-top: 10px;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#pd_tabs a {
|
||||
border: 1px solid #9ab;
|
||||
border-radius: 5px 5px 0 0;
|
||||
padding:4px 6px 1px 6px;
|
||||
background: #c6c9cc;
|
||||
}
|
||||
|
||||
#pd_tabs a:hover {
|
||||
border: 1px solid #c60;
|
||||
background: #c60;
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#pd_tabs a.active_tab {
|
||||
border: 1px solid #345;
|
||||
padding:4px 6px 1px 6px;
|
||||
background: #345;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#pd_views {
|
||||
background:#fff;
|
||||
}
|
||||
|
||||
#pd_views a#pd_editor_toggle {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
float: right;
|
||||
background:url(cross.gif) no-repeat top right;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#pd_views .active_view {
|
||||
display: block;
|
||||
padding: 1.5ex 3ex;
|
||||
border: 1px solid #808080;
|
||||
}
|
||||
|
||||
#pd_views .inactive_view {
|
||||
display: none;
|
||||
display: block;
|
||||
padding: 1.5ex 3ex;
|
||||
border: 1px solid #808080;
|
||||
display: none;
|
||||
}
|
BIN
cms/plugins/pluginloader/page_data/css/tab_active.gif
Normal file
BIN
cms/plugins/pluginloader/page_data/css/tab_active.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
BIN
cms/plugins/pluginloader/page_data/css/tab_hover.gif
Normal file
BIN
cms/plugins/pluginloader/page_data/css/tab_hover.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
BIN
cms/plugins/pluginloader/page_data/css/tab_inactive.gif
Normal file
BIN
cms/plugins/pluginloader/page_data/css/tab_inactive.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
125
cms/plugins/pluginloader/page_data/index.php
Normal file
125
cms/plugins/pluginloader/page_data/index.php
Normal file
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
if (!defined('CMSIMPLE_VERSION') || preg_match('#/pluginloader/page_data/index.php#i',$_SERVER['SCRIPT_NAME']))
|
||||
{
|
||||
die('no direct access');
|
||||
}
|
||||
|
||||
/* utf8-marker = äöüß */
|
||||
|
||||
// MODIFIED FOR CMSimple 4.8.1 by ge-webdesign.de 2020-01
|
||||
// Ready for php 7.4.1
|
||||
|
||||
/**
|
||||
* Page-Data
|
||||
* Part of the Pluginloader V.2.1.x
|
||||
*
|
||||
* Generates an array with an element for each
|
||||
* page, generated in CMSimple. This allows to
|
||||
* store separate data for each page, which
|
||||
* can be handeled by plugins.
|
||||
*
|
||||
* @author Martin Damken
|
||||
* @link http://www.zeichenkombinat.de
|
||||
* @version 1.0.03
|
||||
* @package pluginloader
|
||||
* @subpackage page_data
|
||||
*/
|
||||
|
||||
define('PL_PAGE_DATA_FOLDER', $pth['folder']['plugins'] . $pluginloader_cfg['foldername_pluginloader'] . '/page_data/');
|
||||
define('PL_PAGE_DATA_FILE', $pth['file']['pagedata']);
|
||||
define('PL_PAGE_DATA_STYLESHEET', PL_PAGE_DATA_FOLDER . 'css/stylesheet.css');
|
||||
define('PL_URI_SEPARATOR', $cf['uri']['seperator']);
|
||||
|
||||
require_once(PL_PAGE_DATA_FOLDER . 'page_data_router.php');
|
||||
require_once(PL_PAGE_DATA_FOLDER . 'page_data_model.php');
|
||||
require_once(PL_PAGE_DATA_FOLDER . 'page_data_views.php');
|
||||
|
||||
/**
|
||||
* Check if page-data-file exists, if not: try to
|
||||
* create a new one with basic data-fields.
|
||||
*/
|
||||
if (!file_exists(PL_PAGE_DATA_FILE)) {
|
||||
if ($fh = fopen(PL_PAGE_DATA_FILE, 'w')) {
|
||||
fwrite($fh, '<?php' . "\n" . '$page_data_fields[] = \'url\';' . "\n" . '$page_data_fields[] = \'last_edit\';' . "\n" . '?>');
|
||||
chmod(PL_PAGE_DATA_FILE, 0666);
|
||||
fclose($fh);
|
||||
} else {
|
||||
e('cntwriteto', 'file', PL_PAGE_DATA_FILE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of PL_Page_Data_Router
|
||||
*/
|
||||
$pd_router = new PL_Page_Data_Router(PL_PAGE_DATA_FILE, $h);
|
||||
|
||||
if ($adm) {
|
||||
|
||||
/**
|
||||
* Check for any changes to handle
|
||||
* First: check for changes from texteditor
|
||||
*/
|
||||
if ($function == 'save') {
|
||||
/**
|
||||
* Collect the headings and pass them over to the router
|
||||
*/
|
||||
|
||||
/* do not activate without backup ;-)
|
||||
if($cf['use']['h1only_pagesplitting'] == 'true')
|
||||
{
|
||||
$text = preg_replace("/<h1.*?class=\".*?_level[1-6]_page_.*?\".*?>( | |\xC2\xA0| )?<\/h1>/isu", "", stsl($text));
|
||||
}
|
||||
else
|
||||
{
|
||||
$text = preg_replace("/<h[1-" . $cf['menu']['levels'] . "][^>]*>( | |\xC2\xA0| )?<\/h[1-" . $cf['menu']['levels'] . "]>/isu", "", stsl($text));
|
||||
}
|
||||
*/
|
||||
|
||||
if($cf['use']['h1only_pagesplitting'] == 'true')
|
||||
{
|
||||
preg_match_all('/<h1.*class=\".*_level[1-6]_page_.*\".*>(.+)<\/h1>/isU', $text, $matches);
|
||||
}
|
||||
else
|
||||
{
|
||||
preg_match_all('/<h[1-' . $cf['menu']['levels'] . '].*>(.+)<\/h[1-' . $cf['menu']['levels'] . ']>/isU', $text, $matches);
|
||||
}
|
||||
|
||||
|
||||
$pd_router->refresh_from_texteditor($matches[1], $s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Second: check for hanges from MenuManager
|
||||
*/
|
||||
if (isset($menumanager) && $menumanager && $action == 'saverearranged' && (isset($text) ? strlen($text) : 0 ) > 0) {
|
||||
$pd_router->refresh_from_menu_manager($text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finally check for some changed page infos
|
||||
*/
|
||||
if ($s > -1 && isset($_POST['save_page_data'])) {
|
||||
if(!isset($_SESSION)){session_start();}
|
||||
csrfProtection();
|
||||
$params = $_POST;
|
||||
unset($params['save_page_data']);
|
||||
$pd_router->update($s, $params);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Now we are up to date
|
||||
* If no page has been selected yet, we
|
||||
* are on the start page: Get its index
|
||||
*/
|
||||
if ($s == -1 && !$f && $o == '' && $su == '') {
|
||||
$pd_s = 0;
|
||||
} else {
|
||||
$pd_s = $s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the infos about the current page
|
||||
*/
|
||||
$pd_current = $pd_router->find_page($pd_s);
|
||||
?>
|
320
cms/plugins/pluginloader/page_data/page_data_model.php
Normal file
320
cms/plugins/pluginloader/page_data/page_data_model.php
Normal file
@ -0,0 +1,320 @@
|
||||
<?php
|
||||
|
||||
if (!defined('CMSIMPLE_VERSION') || preg_match('#/pluginloader/page_data/page_data_model.php#i',$_SERVER['SCRIPT_NAME']))
|
||||
{
|
||||
die('no direct access');
|
||||
}
|
||||
|
||||
/*
|
||||
==================================================
|
||||
This file is a part of CMSimple 5.10
|
||||
Released: 2023-??
|
||||
Project website: www.cmsimple.org
|
||||
==================================================
|
||||
adapted for php 8.2: ge-webdesign.de 2023-01
|
||||
*/
|
||||
|
||||
/* utf8-marker = äöüß */
|
||||
/**
|
||||
* Page-Data - Module page_data_model
|
||||
* Part of the Pluginloader V.2.1.x
|
||||
*
|
||||
* Handles the page-data-array including
|
||||
* read and write of the files.
|
||||
*
|
||||
* @author Martin Damken
|
||||
* @link http://www.zeichenkombinat.de
|
||||
* @version 1.0.02
|
||||
* @package pluginloader
|
||||
* @subpackage page_data
|
||||
*/
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Model
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
|
||||
class PL_Page_Data_Model{
|
||||
|
||||
var $data, $params, $tabs, $headings, $temp_data;
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Model::PL_Page_Data_Model()
|
||||
*
|
||||
* @param mixed $h CMSimple's headings-array
|
||||
* @return
|
||||
*/
|
||||
function __construct($h){
|
||||
$this -> headings = $h;
|
||||
include_once(PL_PAGE_DATA_FILE);
|
||||
$this -> params = $page_data_fields;
|
||||
$this -> data = $page_data;
|
||||
$this -> temp_data = isset($temp_data) ? $temp_data : array();
|
||||
$this -> read();
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Model::read()
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
function read(){
|
||||
foreach($this -> headings as $id => $value){
|
||||
$needs_save = false;
|
||||
foreach($this -> params as $param){
|
||||
if(!isset($this -> data[$id][$param])){
|
||||
$needs_save = true;
|
||||
|
||||
switch ($param) {
|
||||
case 'url': $this -> data[$id][$param] = uenc(strip_tags($value));
|
||||
break;
|
||||
default:$this -> data[$id][$param] = '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($needs_save){
|
||||
$this -> save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Model::refresh()
|
||||
*
|
||||
* @param mixed $data
|
||||
* @return
|
||||
*/
|
||||
function refresh($data = null){
|
||||
if(isset($data)){
|
||||
$this -> data = $data;
|
||||
$this -> save();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Model::add_param()
|
||||
*
|
||||
* @param mixed $field
|
||||
* @return
|
||||
*/
|
||||
function add_param($field){
|
||||
$this -> params[] = $field;
|
||||
$this -> save();
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Model::add_tab()
|
||||
*
|
||||
* @param mixed $title
|
||||
* @param mixed $view_file
|
||||
* @return
|
||||
*/
|
||||
function add_tab($title, $view_file){
|
||||
$this -> tabs[$title] = $view_file;
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Model::find_key()
|
||||
*
|
||||
* @param mixed $key
|
||||
* @return
|
||||
*/
|
||||
function find_key($key){
|
||||
return $key>=0 ? $this->data[$key] : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Model::find_field_value()
|
||||
*
|
||||
* @param mixed $field
|
||||
* @param mixed $value
|
||||
* @return array $results
|
||||
*/
|
||||
function find_field_value($field, $value){
|
||||
$results = array();
|
||||
foreach($this->data as $id => $page){
|
||||
if(strstr($page[$field],$value)){
|
||||
$results[$id] = $page;
|
||||
}
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Model::find_arrayfield_value()
|
||||
*
|
||||
* @param mixed $field
|
||||
* @param mixed $value
|
||||
* @param mixed $separator
|
||||
* @return array $results
|
||||
*/
|
||||
function find_arrayfield_value($field, $value, $separator){
|
||||
$results = array();
|
||||
foreach($this->data as $id => $page){
|
||||
$array = explode($separator, $page[$field]);
|
||||
|
||||
foreach($array as $page_data){
|
||||
if($value == trim($page_data)){
|
||||
$results[$id] = $page;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Model::find_field_value_sortkey()
|
||||
*
|
||||
* @param mixed $field
|
||||
* @param mixed $value
|
||||
* @param mixed $sort_key
|
||||
* @param mixed $sort_flag
|
||||
* @param mixed $separator
|
||||
* @return
|
||||
*/
|
||||
function find_field_value_sortkey($field, $value, $sort_key, $sort_flag, $separator){
|
||||
if($separator){
|
||||
$results = $this -> find_arrayfield_value($field, $value, $separator);
|
||||
} else {
|
||||
$results = $this -> find_field_value($field, $value);
|
||||
}
|
||||
foreach($results as $key => $value) {
|
||||
$temp[] = $value[$sort_key];
|
||||
$ids[] = $key;
|
||||
}
|
||||
array_multisort($temp, $sort_flag, $ids);
|
||||
$results = array();
|
||||
if(is_array($ids) && count($ids) > 0){
|
||||
foreach($ids as $id){
|
||||
|
||||
$results[$id] = $this -> data[$id];
|
||||
}
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Model::create()
|
||||
*
|
||||
* @param mixed $params
|
||||
* @return
|
||||
*/
|
||||
function create($params = null){
|
||||
$clean = array();
|
||||
foreach($this -> params as $field){
|
||||
$clean[$field] = '';
|
||||
}
|
||||
$page = array_merge($clean, $params);
|
||||
return $page;
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Model::replace()
|
||||
*
|
||||
* @param mixed $pages
|
||||
* @param mixed $index
|
||||
* @return
|
||||
*/
|
||||
function replace($pages, $index){
|
||||
array_splice($this -> data, $index, 1, $pages);
|
||||
$this -> save();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Model::store_temp()
|
||||
*
|
||||
* @param mixed $page
|
||||
* @return
|
||||
*/
|
||||
function store_temp($page){
|
||||
foreach($page as $field => $value){
|
||||
if(in_array($field, $this -> params)){
|
||||
$this->temp_data[$field] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Model::delete()
|
||||
*
|
||||
* @param mixed $key
|
||||
* @return
|
||||
*/
|
||||
function delete($key){
|
||||
array_splice($this -> data, $key, 1);
|
||||
$this -> save();
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Model::update_key()
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param mixed $params
|
||||
* @return
|
||||
*/
|
||||
function update_key($key, $params){
|
||||
foreach($params as $field => $value){
|
||||
$this->data[$key][$field] = $value;
|
||||
}
|
||||
$this->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Model::save()
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
function save(){
|
||||
global $pluginloader_tx, $o, $adm, $cl;
|
||||
if(!file_exists(PL_PAGE_DATA_FILE)){
|
||||
if($adm){
|
||||
$o .= '<div class = "pluginerror">'.$pluginloader_tx['error']['cntopen'].PL_PAGE_DATA_FILE.'</div>';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(!is_writeable(PL_PAGE_DATA_FILE)){
|
||||
if($adm){
|
||||
$o .= '<div class = "pluginerror">'.$pluginloader_tx['error']['cntwriteto'].PL_PAGE_DATA_FILE.'</div>';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$data_string = "<?php \n";
|
||||
$data_string.= "/* utf8-marker = äöüß */ \n";
|
||||
$data_string .= "################## Data fields ############\n";
|
||||
foreach($this -> params as $param){
|
||||
$data_string .= "\$page_data_fields[] = '". $param ."';\n";
|
||||
}
|
||||
|
||||
$data_string .= "\n################## Recently deleted ############\n";
|
||||
foreach($this -> temp_data as $key => $value){
|
||||
$data_string .= "\$temp_data['".$key."'] = '". str_replace('\"', '"', addslashes($value)) ."';\n";
|
||||
}
|
||||
|
||||
$data_string .= "\n################## Page Data ############\n";
|
||||
|
||||
ksort($this->data, SORT_NUMERIC);
|
||||
$i = 0;
|
||||
foreach($this -> data as $key => $values){
|
||||
foreach($values as $value_key => $value){
|
||||
$data_string .= "\$page_data[".$i."]['".$value_key."'] = '". str_replace('\"', '"', addslashes($value)) ."';\n";
|
||||
}
|
||||
$data_string .= "\n//----------\n";
|
||||
$i++;
|
||||
}
|
||||
$data_string .= "?>";
|
||||
|
||||
$fh = fopen(PL_PAGE_DATA_FILE, "w");
|
||||
fwrite($fh,$data_string);
|
||||
fclose($fh);
|
||||
return;
|
||||
}
|
||||
}
|
||||
?>
|
367
cms/plugins/pluginloader/page_data/page_data_router.php
Normal file
367
cms/plugins/pluginloader/page_data/page_data_router.php
Normal file
@ -0,0 +1,367 @@
|
||||
<?php
|
||||
|
||||
if (!defined('CMSIMPLE_VERSION') || preg_match('#/pluginloader/page_data/page_data_router.php#i',$_SERVER['SCRIPT_NAME']))
|
||||
{
|
||||
die('no direct access');
|
||||
}
|
||||
|
||||
/* utf8-marker = äöüß */
|
||||
/**
|
||||
* Page-Data - Module page_data_router
|
||||
* Part of the Pluginloader V.2.1.x
|
||||
*
|
||||
* Handles all the data that has to be
|
||||
* collected to generate tha page-data-array.
|
||||
*
|
||||
* @author Martin Damken
|
||||
* @link http://www.zeichenkombinat.de
|
||||
* @version 1.0.00
|
||||
* @package pluginloader
|
||||
* @subpackage page_data
|
||||
*/
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Router
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
|
||||
class PL_Page_Data_Router{
|
||||
var $model, $current_page;
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Router::PL_Page_Data_Router()
|
||||
*
|
||||
* @param mixed $data_file
|
||||
* @param mixed $h
|
||||
* @return
|
||||
*/
|
||||
function __construct($data_file, $h){
|
||||
$this -> model = new PL_Page_Data_Model($h);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Router::add_interest()
|
||||
*
|
||||
* @param mixed $field
|
||||
* @return
|
||||
*/
|
||||
function add_interest($field){
|
||||
if(!in_array($field, $this -> model -> params)){
|
||||
$this -> model -> add_param($field);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Router::add_tab()
|
||||
*
|
||||
* @param mixed $tab_name
|
||||
* @param mixed $tab_view
|
||||
* @return
|
||||
*/
|
||||
function add_tab($tab_name, $tab_view){
|
||||
$this -> model -> add_tab($tab_name, $tab_view);
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Router::find_page()
|
||||
*
|
||||
* @param mixed $id
|
||||
* @return
|
||||
*/
|
||||
function find_page($id){
|
||||
$page = $this -> model -> find_key($id);
|
||||
return $page;
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Router::find_all()
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
function find_all(){
|
||||
return $this->model->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Router::new_page()
|
||||
*
|
||||
* @param mixed $params
|
||||
* @return
|
||||
*/
|
||||
function new_page($params = null){
|
||||
$page = $this -> model -> create($params);
|
||||
return $page;
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Router::insert()
|
||||
*
|
||||
* @param mixed $pages
|
||||
* @param mixed $index
|
||||
* @return
|
||||
*/
|
||||
function insert($pages, $index){
|
||||
$this -> model -> replace($pages, $index);
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Router::destroy()
|
||||
*
|
||||
* @param mixed $key
|
||||
* @return
|
||||
*/
|
||||
function destroy($key){
|
||||
|
||||
$this -> model -> delete($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of all pages containing $value in $field.
|
||||
* If $separator is given the $field will be translated to an array
|
||||
* - explode($separator, $value) - before the search.
|
||||
*
|
||||
* @param string $field
|
||||
* @param string $value
|
||||
* @param string $separator
|
||||
* @return array
|
||||
*/
|
||||
function find_field_value($field, $value, $separator = null){
|
||||
if($separator){
|
||||
$results = $this -> model -> find_arrayfield_value($field, $value, $separator);
|
||||
return $results;
|
||||
}
|
||||
$results = $this -> model -> find_field_value($field, $value);
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Router::find_field_value_sortkey()
|
||||
*
|
||||
* @param mixed $field
|
||||
* @param mixed $value
|
||||
* @param mixed $sort_key
|
||||
* @param mixed $sort_flag
|
||||
* @param mixed $separator
|
||||
* @return
|
||||
*/
|
||||
function find_field_value_sortkey($field, $value, $sort_key, $sort_flag = null, $separator = null){
|
||||
$results = $this -> model -> find_field_value_sortkey($field, $value, $sort_key, $sort_flag, $separator);
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Router::refresh_from_texteditor()
|
||||
*
|
||||
* @param mixed $headings
|
||||
* @param mixed $index
|
||||
* @return
|
||||
*/
|
||||
function refresh_from_texteditor($headings, $index){
|
||||
if(count($headings) == 0){
|
||||
/**
|
||||
* Current page has been deleted:
|
||||
* Store it temporary, maybe the user
|
||||
* wants to paste it in somewhere again,
|
||||
* and remove it from the page infos
|
||||
*/
|
||||
$this -> keep_in_mind($index);
|
||||
$this -> destroy($index);
|
||||
}
|
||||
if(count($headings) > 1){
|
||||
/**
|
||||
* At least one page was inserted:
|
||||
* Create an array of the new pages
|
||||
* and insert it into the page data
|
||||
*/
|
||||
$new_pages = array();
|
||||
$current_page = $this -> find_page($index);
|
||||
foreach($headings as $key => $heading){
|
||||
$url = preg_replace('/\s+/isu', ' ', trim(strip_tags($heading)));
|
||||
$url = uenc($url);
|
||||
|
||||
switch ($url) {
|
||||
case $current_page['url']:
|
||||
/**
|
||||
* Keeping the current page data:
|
||||
* this attempt fails, if NEW pages are
|
||||
* added AND current heading was CHANGED
|
||||
*/
|
||||
foreach($current_page as $field => $value){
|
||||
$params[$field] = $value;
|
||||
}
|
||||
break;
|
||||
case $this -> model -> temp_data['url']:
|
||||
/**
|
||||
* This is the 'url' of the recently deleted
|
||||
* page. Most probably it was just pasted in
|
||||
* again. So don't be shy, get the old infos
|
||||
* for this new page
|
||||
*/
|
||||
foreach($this -> model -> temp_data as $field => $value){
|
||||
$params[$field] = $value;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/**
|
||||
* The 'url' is used for ... look right above
|
||||
*/
|
||||
$params['url'] = $url;
|
||||
break;
|
||||
}
|
||||
$params['last_edit'] = time();
|
||||
$new_pages[] = $params;
|
||||
$params = array();
|
||||
}
|
||||
$this -> model -> replace($new_pages, $index);
|
||||
}
|
||||
if(count($headings) == 1){
|
||||
/**
|
||||
* The heading may have changed, stay up to date.
|
||||
*/
|
||||
$url = preg_replace('/\s+/isu', ' ', trim(strip_tags($headings[0])));
|
||||
$params['url'] = uenc($url);
|
||||
$params['last_edit'] = time();
|
||||
$this -> update($index, $params);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Router::refresh_from_menu_manager()
|
||||
*
|
||||
* @param mixed $changes
|
||||
* @return
|
||||
*/
|
||||
function refresh_from_menu_manager($changes){
|
||||
$changes = explode(',', $changes);
|
||||
/**
|
||||
* Create an up-to-date page data array ...
|
||||
*/
|
||||
$new_data = array();
|
||||
/**
|
||||
* index counter is needed for changed headings
|
||||
*/
|
||||
$i = 0;
|
||||
foreach($changes as $temp){
|
||||
$infos = explode('^', $temp);
|
||||
$old_position = $infos[0];
|
||||
if($old_position == 'New'){
|
||||
/**
|
||||
* Page was added: create a new record
|
||||
* These informations are created by default
|
||||
*/
|
||||
$params = array();
|
||||
$title = trim(strip_tags($infos[2]));
|
||||
$url = uenc(strip_tags($title));
|
||||
$params['url'] = $url;
|
||||
$new_data[] = $this -> new_page($params);
|
||||
} else{
|
||||
/**
|
||||
* Get the old record
|
||||
*/
|
||||
$new_data[] = $this -> find_page($old_position);
|
||||
}
|
||||
if(isset($infos[3])){
|
||||
/**
|
||||
* if the heading has changed:
|
||||
* update 'url'
|
||||
*/
|
||||
$url = uenc(trim(strip_tags($infos[3])));
|
||||
$new_data[$i]['url'] = $url;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
/**
|
||||
* Replace the old data with the new array
|
||||
*/
|
||||
$this -> model -> refresh($new_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Router::update()
|
||||
*
|
||||
* @param mixed $s
|
||||
* @param mixed $params
|
||||
* @return
|
||||
*/
|
||||
function update($s, $params){
|
||||
$update_params = array();
|
||||
foreach($params as $field => $update){
|
||||
if(in_array($field, $this -> model -> params)){
|
||||
$update_params[$field] = $update;
|
||||
}
|
||||
}
|
||||
$this -> model -> update_key($s, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Router::edit()
|
||||
*
|
||||
* @param mixed $pd_s
|
||||
* @return
|
||||
*/
|
||||
function edit($pd_s){
|
||||
$page = $this -> find_page($pd_s);
|
||||
$view_provider = new PL_Page_Data_View($page, $this -> model -> tabs);
|
||||
return $view_provider->edit_view($page);
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Router::create_tabs()
|
||||
*
|
||||
* @param mixed $s
|
||||
* @return string Returns views of installed plugins
|
||||
*/
|
||||
function create_tabs($s){
|
||||
global $edit, $f, $o, $su;
|
||||
if(is_array($this -> model -> tabs) && count($this -> model ->tabs) > 0 && $edit == true){
|
||||
if ($s == -1 && !$f && $o == '' && $su == ''){
|
||||
$pd_s = 0;
|
||||
} else {
|
||||
$pd_s = $s;
|
||||
}
|
||||
$page = $this -> find_page($pd_s);
|
||||
if($pd_s > -1){
|
||||
$view_provider = new PL_Page_Data_View($page, $this -> model -> tabs);
|
||||
return $view_provider->pd_forms();
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Router::keep_in_mind()
|
||||
*
|
||||
* @param mixed $pd_s
|
||||
* @return
|
||||
*/
|
||||
function keep_in_mind($pd_s){
|
||||
$page = $this->find_page($pd_s);
|
||||
$this -> model -> store_temp($page);
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_Router::check_temp()
|
||||
*
|
||||
* @param mixed $url
|
||||
* @return
|
||||
*/
|
||||
function check_temp($url){
|
||||
$temp = $this -> model -> find_key('temp');
|
||||
$test = explode(PL_URI_SEPARATOR, $url);
|
||||
if($test[count($test)-1] == $temp['url']){
|
||||
$params = array();
|
||||
foreach($temp as $field => $value){
|
||||
if($field !== 'url'){
|
||||
$params[$field] = $value;
|
||||
}
|
||||
}
|
||||
$this -> model -> delete('temp');
|
||||
$this -> model -> update_key($url, $params);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
?>
|
108
cms/plugins/pluginloader/page_data/page_data_views.php
Normal file
108
cms/plugins/pluginloader/page_data/page_data_views.php
Normal file
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
if (!defined('CMSIMPLE_VERSION') || preg_match('#/pluginloader/page_data/page_data_views.php#i',$_SERVER['SCRIPT_NAME']))
|
||||
{
|
||||
die('no direct access');
|
||||
}
|
||||
|
||||
/* utf8-marker = äöüß */
|
||||
|
||||
// $sn => ./ ge-webdesign.de 2024-01
|
||||
// adapted for CMSimple 4 and 5 ge-webdesign.de 2012-2023
|
||||
|
||||
/**
|
||||
* Page-Data - Module page_data_views
|
||||
* Part of the Pluginloader V.2.1.x
|
||||
*
|
||||
* Provides an interface for plugins to
|
||||
* handle the page_data.
|
||||
*
|
||||
* @author Martin Damken
|
||||
* @link http://www.zeichenkombinat.de
|
||||
* @version 1.0.04
|
||||
* @package pluginloader
|
||||
* @subpackage page_data
|
||||
*/
|
||||
|
||||
/**
|
||||
* PL_Page_Data_View
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
|
||||
class PL_Page_Data_View{
|
||||
var $page, $tabs;
|
||||
/**
|
||||
* PL_Page_Data_View::PL_Page_Data_View()
|
||||
*
|
||||
* @param mixed $page
|
||||
* @param mixed $tabs
|
||||
* @return
|
||||
*/
|
||||
function __construct($page, $tabs = null){
|
||||
$this->page = $page;
|
||||
$this -> tabs = $tabs;
|
||||
}
|
||||
|
||||
/**
|
||||
* PL_Page_Data_View::pd_forms()
|
||||
*
|
||||
* @return string $view Returns created view
|
||||
*/
|
||||
function pd_forms(){
|
||||
global $h, $plugin_tx, $su, $hjs;
|
||||
$hjs .= '<link rel="stylesheet" href="'.PL_PAGE_DATA_STYLESHEET.'" type="text/css">';
|
||||
|
||||
$view = "\n". '<div id = "pd_tabs">';
|
||||
|
||||
foreach($this -> tabs as $title => $code){
|
||||
$view .= '
|
||||
<a class="inactive_tab" id="tab_'.$title.'" onclick="toggle_tab(\''.$title.'\');"><span>'.$title.'</span></a>';
|
||||
}
|
||||
|
||||
$view .= "\n</div>\n".'<div id="pd_views">';
|
||||
|
||||
foreach($this -> tabs as $title => $file){
|
||||
$view .= "\n".'<div id="PLTab_'.$title.'" class="inactive_view">
|
||||
<a id="pd_editor_toggle" class="pd_open" onclick="toggle_tab(\''.$title.'\');"> </a>';
|
||||
if(file_exists($file)){
|
||||
include_once($file);
|
||||
$function = explode('.',basename($file));
|
||||
$function = $function[0];
|
||||
|
||||
$view .= $function($this -> page);
|
||||
}
|
||||
else {$view .= "Could not find ". $file;}
|
||||
$view .= "\n"."</div>\n";
|
||||
}
|
||||
$view .= "\n".'</div>';
|
||||
|
||||
$hjs .= "\n".'<script type="text/javascript">
|
||||
/* <![CDATA[ */
|
||||
function toggle_tab(tabID) {
|
||||
var curr_view = document.getElementById("PLTab_" + tabID);
|
||||
var curr_tab = document.getElementById("tab_" + tabID);
|
||||
if(curr_tab.className == "active_tab") {
|
||||
curr_view.className = "inactive_view";
|
||||
curr_tab.className = "inactive_tab";
|
||||
return;
|
||||
}
|
||||
var views = document.getElementById("pd_views").getElementsByTagName("div");
|
||||
var tabs = document.getElementById("pd_tabs").getElementsByTagName("a");
|
||||
for (i = 0; i < views.length; i++) {
|
||||
if(views[i].id.substr(0, 6) == "PLTab_") {
|
||||
views[i].className = "inactive_view";
|
||||
}
|
||||
}
|
||||
for (i = 0; i < tabs.length; i++) {
|
||||
tabs[i].className = "inactive_tab";
|
||||
}
|
||||
curr_tab.className = "active_tab";
|
||||
curr_view.className = "active_view";
|
||||
return;
|
||||
}
|
||||
/* ]]> */'."\n".'</script>'."\n";
|
||||
return $view;
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user