options['activateCSS'] = $_POST['activateCSS'];
$ngg->options['CSSfile'] = $act_cssfile;
update_option('ngg_options', $ngg->options);
nggGallery::show_message(__('Update Successfully','nggallery'));
}
} else {
// get the options
if (isset($_POST['file']))
$act_cssfile = $_POST['file'];
else
$act_cssfile = $ngg->options['CSSfile'];
}
// set the path
$real_file = NGGALLERY_ABSPATH . "css/" . $act_cssfile;
}
if (isset($_POST['updatecss'])) {
check_admin_referer('ngg_style');
if ( !current_user_can('edit_themes') )
wp_die('
'.__('You do not have sufficient permissions to edit templates for this blog.').'
');
$newcontent = stripslashes($_POST['newcontent']);
if (is_writeable($real_file)) {
$f = fopen($real_file, 'w+');
fwrite($f, $newcontent);
fclose($f);
nggGallery::show_message(__('CSS file successfully updated','nggallery'));
}
}
// get the content of the file
//TODO: BUG : Read failed after write a file, maybe a Cache problem
$error = ( !is_file($real_file) );
if (!$error && filesize($real_file) > 0) {
$f = fopen($real_file, 'r');
$content = fread($f, filesize($real_file));
$content = htmlspecialchars($content);
}
?>
' . sprintf(__('Editing %s','nggallery'), $file_show) . '';
} else {
echo '' . sprintf(__('Browsing %s','nggallery'), $file_show) . '';
}
?>
' . __('Oops, no such file exists! Double check the name and try again, merci.','nggallery') . '
';
}
?>
read()) !== false) {
if (preg_match('|^\.+$|', $file))
continue;
if (is_dir($plugin_root.'/'.$file)) {
$plugins_subdir = @ dir($plugin_root.'/'.$file);
if ($plugins_subdir) {
while (($subfile = $plugins_subdir->read()) !== false) {
if (preg_match('|^\.+$|', $subfile))
continue;
if (preg_match('|\.css$|', $subfile))
$plugin_files[] = "$file/$subfile";
}
}
} else {
if (preg_match('|\.css$|', $file))
$plugin_files[] = $file;
}
}
}
if ( !$plugins_dir || !$plugin_files )
return $cssfiles;
foreach ( $plugin_files as $plugin_file ) {
if ( !is_readable("$plugin_root/$plugin_file"))
continue;
$plugin_data = ngg_get_cssfiles_data("$plugin_root/$plugin_file");
if ( empty ($plugin_data['Name']) )
continue;
$cssfiles[plugin_basename($plugin_file)] = $plugin_data;
}
uasort($cssfiles, create_function('$a, $b', 'return strnatcasecmp($a["Name"], $b["Name"]);'));
return $cssfiles;
}
// parse the Header information
function ngg_get_cssfiles_data($plugin_file) {
$plugin_data = implode('', file($plugin_file));
preg_match("|CSS Name:(.*)|i", $plugin_data, $plugin_name);
preg_match("|Description:(.*)|i", $plugin_data, $description);
preg_match("|Author:(.*)|i", $plugin_data, $author_name);
if (preg_match("|Version:(.*)|i", $plugin_data, $version))
$version = trim($version[1]);
else
$version = '';
$description = wptexturize(trim($description[1]));
$name = trim($plugin_name[1]);
$author = trim($author_name[1]);
return array ('Name' => $name, 'Description' => $description, 'Author' => $author, 'Version' => $version );
}
?>