summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kremmel <xing@synapse.plus.com>2005-09-03 10:20:02 +0000
committerMax Kremmel <xing@synapse.plus.com>2005-09-03 10:20:02 +0000
commit41b8dd09e250dd3ea483e1fe94faf94be09af99d (patch)
tree638233456220909511641cd190090559edc30283
parentf54d3fa65f9aed33d22ff188b4fc3ec81542566b (diff)
downloadliberty-41b8dd09e250dd3ea483e1fe94faf94be09af99d.tar.gz
liberty-41b8dd09e250dd3ea483e1fe94faf94be09af99d.tar.bz2
liberty-41b8dd09e250dd3ea483e1fe94faf94be09af99d.zip
synch recent changes from R1 to HEAD
-rw-r--r--LibertyAttachable.php26
-rw-r--r--admin/admin_liberty_inc.php12
-rw-r--r--admin/comments.php33
-rw-r--r--icons/find.pngbin0 -> 665 bytes
-rw-r--r--plugins/storage.bitfile.php14
-rw-r--r--templates/admin_comments.tpl63
-rw-r--r--templates/admin_liberty.tpl9
-rw-r--r--templates/comments.tpl1
-rw-r--r--templates/menu_liberty_admin.tpl1
9 files changed, 144 insertions, 15 deletions
diff --git a/LibertyAttachable.php b/LibertyAttachable.php
index 226004d..378b66d 100644
--- a/LibertyAttachable.php
+++ b/LibertyAttachable.php
@@ -3,7 +3,7 @@
* Management of Liberty Content
*
* @package liberty
- * @version $Header: /cvsroot/bitweaver/_bit_liberty/LibertyAttachable.php,v 1.5 2005/08/24 20:55:17 squareing Exp $
+ * @version $Header: /cvsroot/bitweaver/_bit_liberty/LibertyAttachable.php,v 1.6 2005/09/03 10:20:02 squareing Exp $
* @author spider <spider@steelsun.com>
*/
// +----------------------------------------------------------------------+
@@ -310,6 +310,12 @@ class LibertyAttachable extends LibertyContent {
if ( function_exists( $gLibertySystem->mPlugins[$guid]['expunge_function'])) {
$expungeFunc = $gLibertySystem->mPlugins[$guid]['expunge_function'];
if( $expungeFunc( $pAttachmentId ) ) {
+ $delDir = dirname( $this->mStorage[$pAttachmentId]['storage_path'] );
+ // add a safety precation to verify that images/123 is in the delete directory in case / got
+ // shoved into $this->mStorage[$pAttachmentId]['storage_path'] for some reason, which would nuke the entire storage directory
+ if( preg_match ( '/image\//', $this->mStorage[$pAttachmentId]['mime_type'] ) && preg_match( "/images\/$pAttachmentId/", $delDir ) ) {
+ unlink_r( BIT_ROOT_PATH.dirname( $this->mStorage[$pAttachmentId]['storage_path'] ) );
+ }
$sql = "DELETE FROM `".BIT_DB_PREFIX."tiki_attachments` WHERE `attachment_id`=?";
$this->mDb->query( $sql, array( $pAttachmentId ) );
}
@@ -444,7 +450,6 @@ function liberty_process_image( &$pFileHash ) {
$resizeFunc = ($gBitSystem->getPreference( 'image_processor' ) == 'imagick' ) ? 'liberty_imagick_resize_image' : 'liberty_gd_resize_image';
list($type, $ext) = split( '/', strtolower( $pFileHash['type'] ) );
mkdir_p( BIT_PKG_PATH.$pFileHash['dest_path'] );
-
if( $resizePath = $resizeFunc( $pFileHash, $ext ) ) {
$pFileHash['source_file'] = BIT_ROOT_PATH.$resizePath;
$nameHold = $pFileHash['name'];
@@ -475,12 +480,20 @@ function liberty_clear_thumbnails( &$pFileHash ) {
function liberty_generate_thumbnails( &$pFileHash ) {
global $gBitSystem;
$resizeFunc = ($gBitSystem->getPreference( 'image_processor' ) == 'imagick' ) ? 'liberty_imagick_resize_image' : 'liberty_gd_resize_image';
+ if( !preg_match( '/image\/(gif|jpg|jpeg|png)/', strtolower( $pFileHash['type'] ) ) && $gBitSystem->isFeatureActive( 'liberty_jpeg_originals' ) ) {
+ // jpeg version of original
+ $pFileHash['dest_base_name'] = 'original';
+ $pFileHash['name'] = 'original.jpg';
+ $pFileHash['max_width'] = 99999;
+ $pFileHash['max_height'] = 99999;
+ $pFileHash['icon_thumb_path'] = BIT_ROOT_PATH.$resizeFunc( $pFileHash );
+ }
// Icon thumb is 48x48
$pFileHash['dest_base_name'] = 'icon';
$pFileHash['name'] = 'icon.jpg';
$pFileHash['max_width'] = 48;
$pFileHash['max_height'] = 48;
- $pFileHash['small_thumb_path'] = BIT_ROOT_PATH.$resizeFunc( $pFileHash );
+ $pFileHash['icon_thumb_path'] = BIT_ROOT_PATH.$resizeFunc( $pFileHash );
// Avatar thumb is 100x100
$pFileHash['dest_base_name'] = 'avatar';
$pFileHash['name'] = 'avatar.jpg';
@@ -519,6 +532,7 @@ function liberty_imagick_resize_image( &$pFileHash, $pFormat = NULL ) {
// $pFileHash['error'] = imagick_failedreason( $iImg ) . imagick_faileddescription( $iImg );
$destUrl = liberty_process_generic( $pFileHash );
} else {
+ imagick_set_image_quality( $iImg, 85 );
$iwidth = imagick_getwidth( $iImg );
$iheight = imagick_getheight( $iImg );
if( (($iwidth / $iheight) > 0) && !empty( $pFileHash['max_width'] ) && !empty( $pFileHash['max_height'] ) ) {
@@ -535,17 +549,15 @@ function liberty_imagick_resize_image( &$pFileHash, $pFormat = NULL ) {
$destUrl = $pFileHash['dest_path'].$pFileHash['dest_base_name'].$destExt;
$destFile = BIT_PKG_PATH.'/'.$destUrl;
$pFileHash['name'] = $pFileHash['dest_base_name'].$destExt;
-
- //print " if ( !imagick_resize( $iImg, $pFileHash[max_width], $pFileHash[max_height], IMAGICK_FILTER_LANCZOS, 0.5, $pFileHash[max_width] x $pFileHash[max_height] > ) ) {";
+// print " if ( !imagick_resize( $iImg, $pFileHash[max_width], $pFileHash[max_height], IMAGICK_FILTER_LANCZOS, 0.5, $pFileHash[max_width] x $pFileHash[max_height] > ) ) {";
// Alternate Filter settings can seen here http://www.dylanbeattie.net/magick/filters/result.html
if ( !imagick_resize( $iImg, $pFileHash['max_width'], $pFileHash['max_height'], IMAGICK_FILTER_CATROM, 1.00, '>' ) ) {
$pFileHash['error'] .= imagick_failedreason( $iImg ) . imagick_faileddescription( $iImg );
}
- //print "2YOYOYOYO $iwidth x $iheight $destUrl <br/>";
+// print "2YOYOYOYO $iwidth x $iheight $destUrl <br/>"; flush();
- imagick_set_image_quality( $iImg, 85 );
if( function_exists( 'imagick_set_attribute' ) ) {
// this exists in the PECL package, but not php-imagick
$imagick_set_attribute($iImg,array("quality"=>1) );
diff --git a/admin/admin_liberty_inc.php b/admin/admin_liberty_inc.php
index 0fff5f9..0bedf0b 100644
--- a/admin/admin_liberty_inc.php
+++ b/admin/admin_liberty_inc.php
@@ -33,11 +33,21 @@ $formCommentFeatures = array(
);
$gBitSmarty->assign( 'formCommentFeatures', $formCommentFeatures );
+
+$formImageFeatures = array(
+ "liberty_jpeg_originals" => array(
+ 'label' => 'JPEG Originals',
+ 'note' => 'Automatically create JPEG versions of original images named \'original.jpg\' in the attachment directory with other thumbnails.',
+ 'page' => '',
+ ),
+);
+$gBitSmarty->assign( 'formImageFeatures', $formImageFeatures );
+
$formValues = array( 'image_processor', 'liberty_attachment_link_format', 'comments_per_page', 'comments_default_ordering', 'comments_default_display_mode' );
if( !empty( $_REQUEST['change_prefs'] ) ) {
$errors = array();
- $formFeatures = array_merge( $formLibertyFeatures, $formCommentFeatures );
+ $formFeatures = array_merge( $formLibertyFeatures, $formCommentFeatures, $formImageFeatures );
foreach( $formFeatures as $item => $data ) {
simple_set_toggle( $item );
}
diff --git a/admin/comments.php b/admin/comments.php
new file mode 100644
index 0000000..3583ed5
--- /dev/null
+++ b/admin/comments.php
@@ -0,0 +1,33 @@
+<?php
+require_once( '../../bit_setup_inc.php' );
+include_once( KERNEL_PKG_PATH.'simple_form_functions_lib.php' );
+
+$gBitSystem->verifyPermission( 'bit_p_admin' );
+
+$commentSettings = array(
+ "comments_reorganise_page_layout" => array(
+ 'label' => 'Position Comments at top of page',
+ 'note' => 'When posting a comment, comments are moved to the top of the page. This can be very disorienting and is only recommended when your site uses comments extensively.',
+ 'page' => '',
+ ),
+ "comments_display_option_bar" => array(
+ 'label' => 'Display Comments option bar',
+ 'note' => 'Display an option bar above comments to specify how they should be sorted and how they should be displayed. Useful if your site uses comments extensively.',
+ 'page' => '',
+ ),
+ "comments_display_expanded" => array(
+ 'label' => 'Expand Comments',
+ 'note' => 'When users first visit your site, comments can be hidden or displayed by default.',
+ 'page' => '',
+ ),
+);
+$gBitSmarty->assign( 'commentSettings', $commentSettings );
+
+if( !empty( $_REQUEST['change_prefs'] ) ) {
+ foreach( array_keys( $commentSettings ) as $item ) {
+ simple_set_toggle( $item );
+ }
+}
+
+$gBitSystem->display( 'bitpackage:liberty/admin_comments.tpl');
+?>
diff --git a/icons/find.png b/icons/find.png
new file mode 100644
index 0000000..e2f48bc
--- /dev/null
+++ b/icons/find.png
Binary files differ
diff --git a/plugins/storage.bitfile.php b/plugins/storage.bitfile.php
index ad9a1cd..be15c1f 100644
--- a/plugins/storage.bitfile.php
+++ b/plugins/storage.bitfile.php
@@ -1,6 +1,6 @@
<?php
/**
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
* @package liberty
* @subpackage plugins_storage
*/
@@ -11,7 +11,7 @@ global $gLibertySystem;
*/
define( 'PLUGIN_GUID_BIT_FILES', 'bitfile' );
-$pluginParams = array (
+$pluginParams = array (
'store_function' => 'bit_files_store',
'verify_function' => 'bit_files_verify',
'load_function' => 'bit_files_load',
@@ -64,12 +64,12 @@ function bit_files_load( $pRow ) {
global $gBitSystem, $gLibertySystem;
$ret = NULL;
if( !empty( $pRow['foreign_id'] ) && is_numeric( $pRow['foreign_id'] )) {
- $query = "SELECT *
+ $query = "SELECT *
FROM `".BIT_DB_PREFIX."tiki_attachments` ta INNER JOIN `".BIT_DB_PREFIX."tiki_files` tf ON (tf.`file_id` = ta.`foreign_id`)
WHERE ta.`foreign_id` = ? AND ta.`content_id` = ?";
if( $rs = $gBitSystem->mDb->query($query, array( $pRow['foreign_id'], $pRow['content_id'] )) ) {
$ret = $rs->fields;
- if (preg_match ( '/image\//', $ret['mime_type'] )) {
+ if (preg_match ( '/image\//', $ret['mime_type'] )) {
$ret['thumbnail_url']['avatar'] = BIT_ROOT_URL.dirname( $ret['storage_path'] ).'/avatar.jpg';
$ret['thumbnail_url']['small'] = BIT_ROOT_URL.dirname( $ret['storage_path'] ).'/small.jpg';
$ret['thumbnail_url']['medium'] = BIT_ROOT_URL.dirname( $ret['storage_path'] ).'/medium.jpg';
@@ -92,7 +92,7 @@ function bit_files_load( $pRow ) {
function bit_files_expunge( $pStorageId ) {
global $gBitUser, $gBitSystem;
$ret = FALSE;
-
+
if (is_numeric($pStorageId)) {
$sql = "SELECT * FROM `".BIT_DB_PREFIX."tiki_attachments` WHERE `attachment_id` = ?";
$rs = $gBitSystem->mDb->query($sql, array($pStorageId));
@@ -103,8 +103,8 @@ function bit_files_expunge( $pStorageId ) {
$fileRow = &$fileRs->fields;
if ($fileRow) {
$absolutePath = BIT_ROOT_PATH.'/'.$fileRow['storage_path'];
-
- if ($gBitUser->isAdmin() || $gBitUser->mUserId == $row['user_id']) {
+
+ if ($gBitUser->isAdmin() || $gBitUser->mUserId == $row['user_id']) {
if (file_exists($absolutePath)) {
unlink($absolutePath);
}
diff --git a/templates/admin_comments.tpl b/templates/admin_comments.tpl
new file mode 100644
index 0000000..a642737
--- /dev/null
+++ b/templates/admin_comments.tpl
@@ -0,0 +1,63 @@
+{strip}
+<div class="floaticon">{bithelp}</div>
+
+<div class="admin liberty">
+ <div class="header">
+ <h1>{tr}Comment Settings{/tr}</h1>
+ </div>
+
+ <div class="body">
+ {form legend="Comment Settings"}
+ {foreach from=$commentSettings key=item item=output}
+ <div class="row">
+ {formlabel label=`$output.label` for=$item}
+ {forminput}
+ {html_checkboxes name="$item" values="y" checked=`$gBitSystemPrefs.$item` labels=false id=$item}
+ {formhelp note=`$output.note` page=`$output.page`}
+ {/forminput}
+ </div>
+ {/foreach}
+
+ <div class="row">
+ {formlabel label="Comments per Page" for="comments_per_page"}
+ {forminput}
+ <select name="comments_per_page" id="comments_per_page">
+ <option value="10" {if $gBitSystemPrefs.comments_per_page eq 10}selected="selected"{/if}>10</option>
+ <option value="20" {if $gBitSystemPrefs.comments_per_page eq 20}selected="selected"{/if}>20</option>
+ <option value="50" {if $gBitSystemPrefs.comments_per_page eq 50}selected="selected"{/if}>50</option>
+ <option value="100" {if $gBitSystemPrefs.comments_per_page eq 100}selected="selected"{/if}>100</option>
+ <option value="999999" {if $gBitSystemPrefs.comments_per_page eq 999999}selected="selected"{/if}>All</option>
+ </select>
+ {formhelp note="Default number of comments per page."}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Default Sort Mode" for="comments_default_ordering"}
+ {forminput}
+ <select name="comments_default_ordering" id="comments_default_ordering">
+ <option value="commentDate_desc" {if $gBitSystemPrefs.comments_default_ordering eq 'commentDate_desc'}selected="selected"{/if}>{tr}Newest first{/tr}</option>
+ <option value="commentDate_asc" {if $gBitSystemPrefs.comments_default_ordering eq 'commentDate_asc'}selected="selected"{/if}>{tr}Oldest first{/tr}</option>
+ {*<option value="points_desc" {if $gBitSystemPrefs.comments_default_ordering eq 'points_desc'}selected="selected"{/if}>{tr}Points{/tr}</option>*}
+ </select>
+ {formhelp note="Select the default sort mode for comments."}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Comments default display mode" for="comments_default_display_mode"}
+ {forminput}
+ <select name="comments_default_display_mode" id="comments_default_display_mode">
+ <option value="threaded" {if $gBitSystemPrefs.comments_default_display_mode eq 'threaded'}selected="selected"{/if}>{tr}Threaded{/tr}</option>
+ <option value="flat" {if $gBitSystemPrefs.comments_default_display_mode eq 'flat'}selected="selected"{/if}>{tr}Flat{/tr}</option>
+ </select>
+ {/forminput}
+ </div>
+
+ <div class="row submit">
+ <input type="submit" name="change_prefs" value="{tr}Change preferences{/tr}" />
+ </div>
+ {/form}
+ </div><!-- end .body -->
+</div><!-- end .liberty -->
+{/strip}
diff --git a/templates/admin_liberty.tpl b/templates/admin_liberty.tpl
index e3805f1..0c33ea8 100644
--- a/templates/admin_liberty.tpl
+++ b/templates/admin_liberty.tpl
@@ -112,6 +112,15 @@
{/if}
{/forminput}
</div>
+ {foreach from=$formImageFeatures key=item item=output}
+ <div class="row">
+ {formlabel label=`$output.label` for=$item}
+ {forminput}
+ {html_checkboxes name="$item" values="y" checked=`$gBitSystemPrefs.$item` labels=false id=$item}
+ {formhelp note=`$output.note` page=`$output.page`}
+ {/forminput}
+ </div>
+ {/foreach}
{/legend}
{/jstab}
{/jstabs}
diff --git a/templates/comments.tpl b/templates/comments.tpl
index ad7082d..d4dc670 100644
--- a/templates/comments.tpl
+++ b/templates/comments.tpl
@@ -88,6 +88,7 @@
<input type="hidden" name="post_comment_reply_id" value="{$post_comment_reply_id}" />
<input type="hidden" name="post_comment_id" value="{$post_comment_id}" />
<table class="optionbar">
+ <caption>{tr}Comments Filter{/tr}</caption>
<tr>
<td>
<label for="comments-maxcomm">{tr}Messages{/tr} </label>
diff --git a/templates/menu_liberty_admin.tpl b/templates/menu_liberty_admin.tpl
index ba5a53d..28b411a 100644
--- a/templates/menu_liberty_admin.tpl
+++ b/templates/menu_liberty_admin.tpl
@@ -2,6 +2,7 @@
<ul>
<li><a class="item" href="{$smarty.const.KERNEL_PKG_URL}admin/index.php?page=liberty">{tr}Liberty Settings{/tr}</a></li>
<li><a class="item" href="{$smarty.const.LIBERTY_PKG_URL}admin/plugins.php">{tr}Plugins{/tr}</a></li>
+ <li><a class="item" href="{$smarty.const.LIBERTY_PKG_URL}admin/comments.php">{tr}Comments{/tr}</a></li>
{if $gBitSystem->isPackageActive( 'pdf' ) }
<li><a class="item" href="{$smarty.const.KERNEL_PKG_URL}admin/index.php?page=pdf">{tr}PDF Settings{/tr}</a></li>
{/if}