aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/LocalFilesEditor/include
diff options
context:
space:
mode:
authorpatdenice <patdenice@piwigo.org>2011-04-13 10:38:45 +0000
committerpatdenice <patdenice@piwigo.org>2011-04-13 10:38:45 +0000
commit7211eee1caba1b1d798449b6df6def86c50552ef (patch)
treee56f5030267867ab82aa4328eb9f5cc42d3429b5 /plugins/LocalFilesEditor/include
parentacd200d6472f4e141c45c51c2d15dea8667d71d5 (diff)
merge r10348 from trunk to branch 2.2
Clean code git-svn-id: http://piwigo.org/svn/branches/2.2@10349 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--plugins/LocalFilesEditor/include/css.inc.php45
-rw-r--r--plugins/LocalFilesEditor/include/functions.inc.php (renamed from plugins/LocalFilesEditor/functions.inc.php)0
-rw-r--r--plugins/LocalFilesEditor/include/lang.inc.php53
-rw-r--r--plugins/LocalFilesEditor/include/localconf.inc.php26
-rw-r--r--plugins/LocalFilesEditor/include/plug.inc.php25
-rw-r--r--plugins/LocalFilesEditor/include/tpl.inc.php140
6 files changed, 289 insertions, 0 deletions
diff --git a/plugins/LocalFilesEditor/include/css.inc.php b/plugins/LocalFilesEditor/include/css.inc.php
new file mode 100644
index 000000000..42c6b6920
--- /dev/null
+++ b/plugins/LocalFilesEditor/include/css.inc.php
@@ -0,0 +1,45 @@
+<?php
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+$edited_file = isset($_POST['edited_file']) ? $_POST['edited_file'] : '';
+$content_file = '';
+
+if ((isset($_POST['edit'])) and !is_numeric($_POST['file_to_edit']))
+{
+ $edited_file = $_POST['file_to_edit'];
+ if (file_exists($edited_file))
+ {
+ $content_file = file_get_contents($edited_file);
+ }
+ else
+ {
+ $content_file = "/* " . l10n('locfiledit_newfile') . " */\n\n";
+ }
+}
+
+$selected = 0;
+$options[] = l10n('locfiledit_choose_file');
+$options[] = '----------------------';
+$value = PHPWG_ROOT_PATH.PWG_LOCAL_DIR . "css/rules.css";
+$options[$value] = 'local / css / rules.css';
+if ($edited_file == $value) $selected = $value;
+$options[] = '----------------------';
+
+foreach (get_dirs($conf['themes_dir']) as $theme_id)
+{
+ $value = PHPWG_ROOT_PATH.PWG_LOCAL_DIR . 'css/'.$theme_id.'-rules.css';
+ $options[$value] = 'local / css / '.$theme_id.'-rules.css';
+ if ($edited_file == $value)
+ $selected = $value;
+}
+
+$template->assign('css_lang_tpl', array(
+ 'OPTIONS' => $options,
+ 'SELECTED' => $selected
+ )
+);
+
+$codemirror_mode = 'text/css';
+
+?> \ No newline at end of file
diff --git a/plugins/LocalFilesEditor/functions.inc.php b/plugins/LocalFilesEditor/include/functions.inc.php
index b85887852..b85887852 100644
--- a/plugins/LocalFilesEditor/functions.inc.php
+++ b/plugins/LocalFilesEditor/include/functions.inc.php
diff --git a/plugins/LocalFilesEditor/include/lang.inc.php b/plugins/LocalFilesEditor/include/lang.inc.php
new file mode 100644
index 000000000..fe5a4f85c
--- /dev/null
+++ b/plugins/LocalFilesEditor/include/lang.inc.php
@@ -0,0 +1,53 @@
+<?php
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+$edited_file = isset($_POST['edited_file']) ? $_POST['edited_file'] : '';
+$content_file = '';
+
+if ((isset($_POST['edit'])) and !is_numeric($_POST['file_to_edit']))
+{
+ $edited_file = $_POST['file_to_edit'];
+ if (file_exists($edited_file))
+ {
+ $content_file = file_get_contents($edited_file);
+ }
+ else
+ {
+ $content_file = "<?php\n\n/* ".l10n('locfiledit_newfile')." */\n\n\n\n\n?>";
+ }
+}
+
+$selected = 0;
+$options[] = l10n('locfiledit_choose_file');
+$options[] = '----------------------';
+foreach (get_languages() as $language_code => $language_name)
+{
+ $value = PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'language/'.$language_code.'.lang.php';
+ if ($edited_file == $value)
+ {
+ $selected = $value;
+ $template->assign('show_default', array(
+ array(
+ 'URL' => LOCALEDIT_PATH.'show_default.php?file=language/'.$language_code.'/common.lang.php',
+ 'FILE' => 'common.lang.php'
+ ),
+ array(
+ 'URL' => LOCALEDIT_PATH.'show_default.php?file=language/'.$language_code.'/admin.lang.php',
+ 'FILE' => 'admin.lang.php'
+ )
+ )
+ );
+ }
+ $options[$value] = $language_name;
+}
+
+$template->assign('css_lang_tpl', array(
+ 'OPTIONS' => $options,
+ 'SELECTED' => $selected
+ )
+ );
+
+$codemirror_mode = 'application/x-httpd-php';
+
+?> \ No newline at end of file
diff --git a/plugins/LocalFilesEditor/include/localconf.inc.php b/plugins/LocalFilesEditor/include/localconf.inc.php
new file mode 100644
index 000000000..b801db236
--- /dev/null
+++ b/plugins/LocalFilesEditor/include/localconf.inc.php
@@ -0,0 +1,26 @@
+<?php
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+$edited_file = PHPWG_ROOT_PATH.PWG_LOCAL_DIR . "config/config.inc.php";
+
+if (file_exists($edited_file))
+{
+ $content_file = file_get_contents($edited_file);
+}
+else
+{
+ $content_file = "<?php\n\n/* ".l10n('locfiledit_newfile')." */\n\n\n\n\n?>";
+}
+
+$template->assign('show_default', array(
+ array(
+ 'URL' => LOCALEDIT_PATH.'show_default.php?file=include/config_default.inc.php',
+ 'FILE' => 'config_default.inc.php'
+ )
+ )
+);
+
+$codemirror_mode = 'application/x-httpd-php';
+
+?> \ No newline at end of file
diff --git a/plugins/LocalFilesEditor/include/plug.inc.php b/plugins/LocalFilesEditor/include/plug.inc.php
new file mode 100644
index 000000000..55c4b2dde
--- /dev/null
+++ b/plugins/LocalFilesEditor/include/plug.inc.php
@@ -0,0 +1,25 @@
+<?php
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+$edited_file = PHPWG_PLUGINS_PATH . "PersonalPlugin/main.inc.php";
+
+if (file_exists($edited_file))
+{
+ $content_file = file_get_contents($edited_file);
+}
+else
+{
+ $content_file = "<?php\n/*
+Plugin Name: " . l10n('locfiledit_onglet_plug') . "
+Version: 1.0
+Description: " . l10n('locfiledit_onglet_plug') . "
+Plugin URI: http://piwigo.org
+Author:
+Author URI:
+*/\n\n\n\n\n?>";
+}
+
+$codemirror_mode = 'application/x-httpd-php';
+
+?> \ No newline at end of file
diff --git a/plugins/LocalFilesEditor/include/tpl.inc.php b/plugins/LocalFilesEditor/include/tpl.inc.php
new file mode 100644
index 000000000..aea29ed9d
--- /dev/null
+++ b/plugins/LocalFilesEditor/include/tpl.inc.php
@@ -0,0 +1,140 @@
+<?php
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+$edited_file = isset($_POST['edited_file']) ? $_POST['edited_file'] : '';
+$content_file = '';
+
+if ((isset($_POST['edit'])) and !is_numeric($_POST['file_to_edit']))
+{
+ $edited_file = $_POST['file_to_edit'];
+ if (file_exists($edited_file))
+ {
+ $content_file = file_get_contents($edited_file);
+ }
+ else
+ {
+ $content_file = "{* " . l10n('locfiledit_newfile') . " *}\n\n";
+ }
+}
+
+$newfile_page = isset($_GET['newfile']);
+
+// Edit new tpl file
+if (isset($_POST['create_tpl']))
+{
+ $filename = $_POST['tpl_name'];
+ if (empty($filename))
+ {
+ array_push($page['errors'], l10n('locfiledit_empty_filename'));
+ }
+ if (get_extension($filename) != 'tpl')
+ {
+ $filename .= '.tpl';
+ }
+ if (!preg_match('/^[a-zA-Z0-9-_.]+$/', $filename))
+ {
+ array_push($page['errors'], l10n('locfiledit_filename_error'));
+ }
+ if (is_numeric($_POST['tpl_model']) and $_POST['tpl_model'] != '0')
+ {
+ array_push($page['errors'], l10n('locfiledit_model_error'));
+ }
+ if (file_exists($_POST['tpl_parent'] . '/' . $filename))
+ {
+ array_push($page['errors'], l10n('locfiledit_file_already_exists'));
+ }
+ if (!empty($page['errors']))
+ {
+ $newfile_page = true;
+ }
+ else
+ {
+ $edited_file = $_POST['tpl_parent'] . '/' . $filename;
+ $content_file = ($_POST['tpl_model'] == '0') ? $new_file['tpl'] : file_get_contents($_POST['tpl_model']);
+ }
+}
+
+if ($newfile_page)
+{
+ $filename = isset($_POST['tpl_name']) ? $_POST['tpl_name'] : '';
+ $selected['model'] = isset($_POST['tpl_model']) ? $_POST['tpl_model'] : '0';
+ $selected['parent'] = isset($_POST['tpl_parent']) ? $_POST['tpl_parent'] : PHPWG_ROOT_PATH . 'template-extension';
+
+ // Parent directories list
+ $options['parent'] = array(PHPWG_ROOT_PATH . 'template-extension' => 'template-extension');
+ $options['parent'] = array_merge($options['parent'], get_rec_dirs(PHPWG_ROOT_PATH . 'template-extension'));
+
+ $options['model'][] = l10n('locfiledit_empty_page');
+ $options['model'][] = '----------------------';
+ $i = 0;
+ foreach (get_extents() as $pwg_template)
+ {
+ $value = PHPWG_ROOT_PATH . 'template-extension/' . $pwg_template;
+ $options['model'][$value] = 'template-extension / ' . str_replace('/', ' / ', $pwg_template);
+ $i++;
+ }
+ foreach (get_dirs($conf['themes_dir']) as $theme_id)
+ {
+ if ($i)
+ {
+ $options['model'][] = '----------------------';
+ $i = 0;
+ }
+ $dir = $conf['themes_dir'] . '/' . $theme_id . '/template/';
+ if (is_dir($dir) and $content = opendir($dir))
+ {
+ while ($node = readdir($content))
+ {
+ if (is_file($dir.$node) and get_extension($node) == 'tpl')
+ {
+ $value = $dir . $node;
+ $options['model'][$value] = $theme_id . ' / ' . $node;
+ $i++;
+ }
+ }
+ }
+ }
+ if (end($options['model']) == '----------------------')
+ {
+ array_pop($options['model']);
+ }
+ // Assign variables to template
+ $template->assign('create_tpl', array(
+ 'NEW_FILE_NAME' => $filename,
+ 'MODEL_OPTIONS' => $options['model'],
+ 'MODEL_SELECTED' => $selected['model'],
+ 'PARENT_OPTIONS' => $options['parent'],
+ 'PARENT_SELECTED' => $selected['parent']
+ )
+ );
+}
+else
+{
+ // List existing template extensions
+ $selected = 0;
+ $options[] = l10n('locfiledit_choose_file');
+ $options[] = '----------------------';
+ foreach (get_extents() as $pwg_template)
+ {
+ $value = './template-extension/' . $pwg_template;
+ $options[$value] = str_replace('/', ' / ', $pwg_template);
+ if ($edited_file == $value) $selected = $value;
+ }
+ if ($selected == 0 and !empty($edited_file))
+ {
+ $options[$edited_file] = str_replace(array('./template-extension/', '/'), array('', ' / '), $edited_file);
+ $selected = $edited_file;
+ }
+ $template->assign('css_lang_tpl', array(
+ 'OPTIONS' => $options,
+ 'SELECTED' => $selected,
+ 'NEW_FILE_URL' => $my_base_url.'-tpl&amp;newfile',
+ 'NEW_FILE_CLASS' => empty($edited_file) ? '' : 'top_right'
+ )
+ );
+}
+
+$codemirror_mode = 'text/html';
+
+?> \ No newline at end of file