diff options
-rw-r--r-- | actions/photos/admin/settings.php | 66 | ||||
-rw-r--r-- | activate.php | 20 | ||||
-rw-r--r-- | languages/en.php | 13 | ||||
-rw-r--r-- | lib/tidypics.php | 17 | ||||
-rw-r--r-- | start.php | 1 | ||||
-rw-r--r-- | views/default/forms/photos/admin/settings.php | 290 | ||||
-rw-r--r-- | views/default/tidypics/css.php | 4 |
7 files changed, 152 insertions, 259 deletions
diff --git a/actions/photos/admin/settings.php b/actions/photos/admin/settings.php index a401d9bf3..1a4a4bdda 100644 --- a/actions/photos/admin/settings.php +++ b/actions/photos/admin/settings.php @@ -16,62 +16,16 @@ foreach ($params as $k => $v) { } } -system_message(elgg_echo('tidypics:settings:save:ok')); -forward(REFERER); - -// check boxes -if (is_array(get_input('download_link'))) { // this can be done due to way Elgg uses checkboxes - set_plugin_setting('download_link', 'enabled', 'tidypics'); -} else { - set_plugin_setting('download_link', 'disabled', 'tidypics'); -} - -if (is_array(get_input('tagging'))) { - set_plugin_setting('tagging', 'enabled', 'tidypics'); -} else { - set_plugin_setting('tagging', 'disabled', 'tidypics'); -} - -if (is_array(get_input('photo_ratings'))) { - set_plugin_setting('photo_ratings', 'enabled', 'tidypics'); -} else { - set_plugin_setting('photo_ratings', 'disabled', 'tidypics'); -} - -if (is_array(get_input('exif'))) { - set_plugin_setting('exif', 'enabled', 'tidypics'); -} else { - set_plugin_setting('exif', 'disabled', 'tidypics'); -} - -if (is_array(get_input('view_count'))) { - set_plugin_setting('view_count', 'enabled', 'tidypics'); -} else { - set_plugin_setting('view_count', 'disabled', 'tidypics'); -} - -if (is_array(get_input('uploader'))) { - set_plugin_setting('uploader', 'enabled', 'tidypics'); -} else { - set_plugin_setting('uploader', 'disabled', 'tidypics'); -} - -if (is_array(get_input('grp_perm_override'))) { - set_plugin_setting('grp_perm_override', 'enabled', 'tidypics'); -} else { - set_plugin_setting('grp_perm_override', 'disabled', 'tidypics'); -} - - // image sizes $image_sizes = array(); -$image_sizes['large_image_width'] = get_input('large_thumb_width'); -$image_sizes['large_image_height'] = get_input('large_thumb_height'); -$image_sizes['small_image_width'] = get_input('small_thumb_width'); -//$image_sizes['small_image_height'] = get_input('small_thumb_height'); -$image_sizes['small_image_height'] = get_input('small_thumb_width'); -$image_sizes['thumb_image_width'] = get_input('thumb_width'); -//$image_sizes['thumb_image_height'] = get_input('thumb_height'); -$image_sizes['thumb_image_height'] = get_input('thumb_width'); -set_plugin_setting('image_sizes', serialize($image_sizes), 'tidypics'); +$image_sizes['large_image_width'] = get_input('large_image_width'); +$image_sizes['large_image_height'] = get_input('large_image_height'); +$image_sizes['small_image_width'] = get_input('small_image_width'); +$image_sizes['small_image_height'] = get_input('small_image_height'); +$image_sizes['tiny_image_width'] = get_input('tiny_image_width'); +$image_sizes['tiny_image_height'] = get_input('tiny_image_height'); +$plugin->setSetting('image_sizes', serialize($image_sizes)); + +system_message(elgg_echo('tidypics:settings:save:ok')); +forward(REFERER); diff --git a/activate.php b/activate.php index ca74c6119..25d34338c 100644 --- a/activate.php +++ b/activate.php @@ -21,8 +21,28 @@ if (get_subtype_id('object', 'image')) { // set default settings $plugin = elgg_get_plugin_from_id('tidypics'); +$image_sizes = array(); +$image_sizes['large_image_width'] = $image_sizes['large_image_height'] = 600; +$image_sizes['small_image_width'] = $image_sizes['small_image_height'] = 153; +$image_sizes['tiny_image_width'] = $image_sizes['tiny_image_height'] = 60; +$image_sizes = serialize($image_sizes); + $defaults = array( 'tagging' => true, + 'view_count' => true, + 'uploader' => true, + 'exif' => true, + 'download_link' => true, + + 'maxfilesize' => 5, + 'image_lib' => 'GD', + + 'img_river_view' => 'batch', + 'album_river_view' => 'set', + + 'image_sizes' => $image_sizes, + + 'grp_perm_override' => true, ); foreach ($defaults as $name => $value) { diff --git a/languages/en.php b/languages/en.php index e93ee3197..58055039c 100644 --- a/languages/en.php +++ b/languages/en.php @@ -64,25 +64,30 @@ $english = array( 'tidypics:settings:download_link' => "Show download link", 'tidypics:settings:tagging' => "Enable photo tagging", 'tidypics:settings:photo_ratings' => "Enable photo ratings (requires rate plugin of Miguel Montes or compatible)", - 'tidypics:settings:exif' => "Show EXIF data", - 'tidypics:settings:view_count' => "View counter", + 'tidypics:settings:exif' => "Display EXIF data", + 'tidypics:settings:view_count' => "Display view count", 'tidypics:settings:uploader' => "Use Flash uploader", 'tidypics:settings:grp_perm_override' => "Allow group members full access to group albums", 'tidypics:settings:maxfilesize' => "Maximum image size in megabytes (MB):", 'tidypics:settings:quota' => "User/Group Quota (MB) - 0 equals no quota", 'tidypics:settings:watermark' => "Enter text to appear in the watermark", - 'tidypics:settings:im_path' => "Enter the path to your ImageMagick commands (with trailing slash)", + 'tidypics:settings:im_path' => "Enter the path to your ImageMagick commands", 'tidypics:settings:img_river_view' => "How many entries in activity river for each batch of uploaded images", 'tidypics:settings:album_river_view' => "Show the album cover or a set of photos for new album", 'tidypics:settings:largesize' => "Primary image size", 'tidypics:settings:smallsize' => "Album view image size", - 'tidypics:settings:thumbsize' => "Thumbnail image size", + 'tidypics:settings:tinysize' => "Thumbnail image size", + 'tidypics:settings:sizes:instructs' => 'You may need to change the CSS if you change the default sizes', 'tidypics:settings:im_id' => "Image ID", 'tidypics:settings:heading:img_lib' => "Image Library Settings", 'tidypics:settings:heading:main' => "Major Settings", 'tidypics:settings:heading:river' => "Activity Integration Options", 'tidypics:settings:heading:sizes' => "Thumbnail Size", 'tidypics:settings:heading:groups' => "Group Settings", + 'tidypics:option:all' => 'All', + 'tidypics:option:none' => 'None', + 'tidypics:option:cover' => 'Cover', + 'tidypics:option:set' => 'Set', //actions 'album:create' => "Create new album", diff --git a/lib/tidypics.php b/lib/tidypics.php index 7eedb246d..0a4586c29 100644 --- a/lib/tidypics.php +++ b/lib/tidypics.php @@ -91,6 +91,23 @@ function tidypics_prepare_form_vars($entity = null) { return $values; } +function tidypics_get_image_libraries() { + $options = array(); + if (extension_loaded('gd')) { + $options['GD'] = 'GD'; + } + + if (extension_loaded('imagick')) { + $options['ImageMagickPHP'] = 'imagick PHP extension'; + } + + $disablefunc = explode(',', ini_get('disable_functions')); + if (is_callable('exec') && !in_array('exec', $disablefunc)) { + $options['ImageMagick'] = 'ImageMagick executable'; + } + + return $options; +} /********************************************************************* * the functions below replace broken core functions or add functions @@ -25,6 +25,7 @@ function tidypics_init() { // Extend CSS elgg_extend_view('css/elgg', 'tidypics/css'); + elgg_extend_view('css/admin', 'tidypics/css'); // Add photos link to owner block/hover menus elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'tidypics_owner_block_menu'); diff --git a/views/default/forms/photos/admin/settings.php b/views/default/forms/photos/admin/settings.php index ea1e12de8..5c71e24f6 100644 --- a/views/default/forms/photos/admin/settings.php +++ b/views/default/forms/photos/admin/settings.php @@ -1,134 +1,132 @@ <?php /** * Tidypics admin settings form body + * + * @todo watermark, quota, remove original image, group only upload not delete */ $plugin = elgg_get_plugin_from_id('tidypics'); +// main settings +$checkboxes = array('tagging', 'view_count', 'uploader', 'exif', 'download_link'); +foreach ($checkboxes as $checkbox) { + echo '<div>'; + $checked = $plugin->$checkbox ? 'checked' : false; + echo elgg_view('input/checkbox', array( + 'name' => "params[$checkbox]", + 'value' => true, + 'checked' => (bool)$plugin->$checkbox, + )); + echo ' ' . elgg_echo("tidypics:settings:$checkbox"); + echo '</div>'; +} + +// max image size echo '<div>'; -$checked = $plugin->tagging ? 'checked' : false; -echo elgg_view('input/checkbox', array( - 'name' => 'params[tagging]', - 'value' => true, - 'checked' => (bool)$plugin->tagging, +echo elgg_echo('tidypics:settings:maxfilesize'); +echo elgg_view('input/text', array( + 'name' => 'params[maxfilesize]', + 'value' => $plugin->maxfilesize, )); -echo ' ' . elgg_echo('tidypics:settings:tagging'); echo '</div>'; -// Thumbnail sizes +// image library +echo '<h3>' . elgg_echo('tidypics:settings:heading:img_lib') . '</h3>'; +echo'<div>'; +echo elgg_echo('tidypics:settings:image_lib') . ': '; +echo elgg_view('input/dropdown', array( + 'name' => 'params[image_lib]', + 'options_values' => tidypics_get_image_libraries(), + 'value' => $plugin->image_lib, +)); +echo '</div>'; echo '<div>'; -echo '<h3>' . elgg_echo('tidypics:settings:heading:sizes') . '</h3>'; -echo "<h6>You must edit the css if you change the default sizes</h6>"; -$image_sizes = unserialize($plugin->image_sizes); +echo elgg_echo('tidypics:settings:im_path') . ' '; +echo elgg_view("input/text", array('name' => 'params[im_path]', 'value' => $$plugin->im_path)); +echo '</div>'; -/* -if(!$image_sizes) { - $image_sizes = array(); // set default values - $image_sizes['large_image_width'] = $image_sizes['large_image_height'] = 600; - $image_sizes['small_image_width'] = $image_sizes['small_image_height'] = 153; - $image_sizes['thumb_image_width'] = $image_sizes['thumb_image_height'] = 60; -} else { - $image_sizes = unserialize($image_sizes); -} - * - */ +// river integration +echo '<h3>' . elgg_echo('tidypics:settings:heading:river') . '</h3>'; +echo '<div>'; +echo elgg_echo('tidypics:settings:img_river_view') . ': '; +echo elgg_view('input/dropdown', array( + 'name' => 'params[img_river_view]', + 'options_values' => array( + 'all' => elgg_echo('tidypics:option:all'), + 'batch' => '1', + 'none' => elgg_echo('tidypics:option:none'), + ), + 'value' => $plugin->img_river_view, +)); +echo '</div>'; +echo '<div>'; +echo elgg_echo('tidypics:settings:album_river_view') . ': '; +echo elgg_view('input/dropdown', array( + 'name' => 'params[album_river_view]', + 'options_values' => array( + 'cover' => elgg_echo('tidypics:option:cover'), + 'set' => elgg_echo('tidypics:option:set'), + ), + 'value' => $plugin->album_river_view, +)); +echo '</div>'; + + +// thumbnail sizes +echo '<div>'; +echo '<h3>' . elgg_echo('tidypics:settings:heading:sizes') . '</h3>'; +echo '<h6>' . elgg_echo('tidypics:settings:sizes:instructs') . '</h6>'; +$image_sizes = unserialize($plugin->image_sizes); +echo '<table>'; $sizes = array('large', 'small', 'tiny'); foreach ($sizes as $size) { + echo '<tr>'; + echo '<td class="pas">'; echo elgg_echo("tidypics:settings:{$size}size"); - echo ' width: '; + echo '</td><td class="pas">'; + echo 'width: '; echo elgg_view('input/text', array( - 'name' => "{$size}_thumb_width", + 'name' => "{$size}_image_width", 'value' => $image_sizes["{$size}_image_width"], - 'style' => 'width: 150px;' + 'class' => 'tidypics-input-thin', )); - echo ' height: '; + echo '</td><td class="pas">'; + echo 'height: '; echo elgg_view('input/text', array( - 'name' => "{$size}_thumb_height", + 'name' => "{$size}_image_height", 'value' => $image_sizes["{$size}_image_height"], - 'style' => 'width: 150px;' + 'class' => 'tidypics-input-thin', )); + echo '</td>'; + echo '</tr>'; } - -$form_body .= 'width: <input style="width: 20%;" type="text" name="large_thumb_width" value=' . "\"{$image_sizes['large_image_width']}\"" . ' class="input-text" /> '; -$form_body .= 'height: <input style="width: 20%;" type="text" name="large_thumb_height" value=' . "\"{$image_sizes['large_image_height']}\"" . ' class="input-text" /></p>'; - -$form_body .= "<p>" . elgg_echo('tidypics:settings:smallsize') . "<br />"; -$form_body .= 'width and height: <input style="width: 20%;" type="text" name="small_thumb_width" value=' . "\"{$image_sizes['small_image_width']}\"" . ' class="input-text" /> '; -//$form_body .= 'height: <input style="width: 20%;" type="text" name="small_thumb_height" value=' . "\"{$image_sizes['small_image_height']}\"" . ' class="input-text" /></p>'; - -$form_body .= "<p>" . elgg_echo('tidypics:settings:thumbsize') . "<br />"; -$form_body .= 'width and height: <input style="width: 20%;" type="text" name="thumb_width" value=' . "\"{$image_sizes['thumb_image_width']}\"" . ' class="input-text" /> '; -//$form_body .= 'height: <input style="width: 20%;" type="text" name="thumb_height" value=' . "\"{$image_sizes['thumb_image_height']}\"" . ' class="input-text" /></p>'; +echo '</table>'; echo '</div>'; -echo elgg_view('input/submit', array('value' => elgg_echo("save"))); -return true; - - -// Main settings -echo '<h3>' . elgg_echo('tidypics:settings:heading:main') . '</h3>'; - -// Tagging -$tagging = $plugin->tagging ? $plugin->tagging : 'enabled'; +// Group albums +echo '<h3>' . elgg_echo('tidypics:settings:heading:groups') . '</h3>'; echo '<div>'; -echo elgg_view("input/checkboxes", array( - 'name' => 'tagging', - 'value' => $tagging, - 'options' => array( - elgg_echo('tidypics:settings:tagging') => 'enabled' - ), +$checked = $plugin->grp_perm_override ? 'checked' : false; +echo elgg_view('input/checkbox', array( + 'name' => "params[grp_perm_override]", + 'value' => true, + 'checked' => (bool)$plugin->grp_perm_override, )); -echo "</div>"; +echo ' ' . elgg_echo("tidypics:settings:grp_perm_override"); +echo '</div>'; -// Download Link -$download_link = $plugin->download_link; -if (!$download_link) { - $download_link = "enabled"; -} -$form_body .= '<p class="admin_debug">' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:download_link') => 'enabled'), 'internalname' => 'download_link', 'value' => $download_link )) . "</p>"; -// Ratings -$photo_ratings = $plugin->photo_ratings; -if (!$photo_ratings) { - $photo_ratings = "disabled"; -} -$form_body .= '<p class="admin_debug">' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:photo_ratings') => 'enabled'), 'internalname' => 'photo_ratings', 'value' => $photo_ratings )) . "</p>"; - -// Show EXIF -$exif = $plugin->exif; -if (!$exif) { - $exif = "disabled"; -} -$form_body .= '<p class="admin_debug">' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:exif') => 'enabled'), 'internalname' => 'exif', 'value' => $exif )) . "</p>"; +echo elgg_view('input/submit', array('value' => elgg_echo("save"))); -// Show View count -$view_count = $plugin->view_count; -if (!$view_count) { - $view_count = "enabled"; -} -$form_body .= '<p class="admin_debug">' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:view_count') => 'enabled'), 'internalname' => 'view_count', 'value' => $view_count )) . "</p>"; +return true; -// Use flash uploader -$uploader = $plugin->uploader; -if (!$uploader) { - $uploader = "enabled"; -} -$form_body .= '<p class="admin_debug">' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:uploader') => 'enabled'), 'internalname' => 'uploader', 'value' => $uploader )) . "</p>"; // Watermark Text $form_body .= "<p>" . elgg_echo('tidypics:settings:watermark') . "<br />"; $form_body .= elgg_view("input/text",array('internalname' => 'params[watermark_text]', 'value' => $plugin->watermark_text)) . "</p>"; -// Max Image Size -$maxfilesize = $plugin->maxfilesize; -if (!$maxfilesize) { - $maxfilesize = (int)5; // 5 MB -} -$form_body .= "<p>" . elgg_echo('tidypics:settings:maxfilesize') . "<br />"; -$form_body .= elgg_view("input/text",array('internalname' => 'params[maxfilesize]', 'value' => $maxfilesize)) . "</p>"; - // Quota Size $quota = $plugin->quota; if (!$quota) { @@ -137,109 +135,3 @@ if (!$quota) { $form_body .= "<p>" . elgg_echo('tidypics:settings:quota') . "<br />"; $form_body .= elgg_view("input/text",array('internalname' => 'params[quota]', 'value' => $quota)) . "</p>"; -// Image Library -if (extension_loaded('imagick')) { - $img_lib_options['ImageMagickPHP'] = 'imagick PHP extension'; -} - -$disablefunc = explode(',', ini_get('disable_functions')); -if (is_callable('exec') && !in_array('exec',$disablefunc)) { - $img_lib_options['ImageMagick'] = 'ImageMagick Cmdline'; -} - -$img_lib_options['GD'] = 'GD'; - -$form_body .= '<h3>' . elgg_echo('tidypics:settings:heading:img_lib') . '</h3>'; -$image_lib = $plugin->image_lib; -if (!$image_lib) { - $image_lib = 'GD'; -} -$form_body .= '<p>' . elgg_echo('tidypics:settings:image_lib') . ': '; -$form_body .= elgg_view('input/pulldown', array( - 'internalname' => 'params[image_lib]', - 'options_values' => $img_lib_options, - 'value' => $image_lib -)); -$form_body .= '<br/>Note: If you want to select ImageMagick Command Line, first confirm that it is installed on your server.</p>'; - -if (is_callable('exec') && !in_array('exec', $disablefunc)) { - // Image Magick Path - $im_path = $plugin->im_path; - if(!$im_path) { - $im_path = ""; - } - $form_body .= "<p>" . elgg_echo('tidypics:settings:im_path') . "<br />"; - $form_body .= elgg_view("input/text",array('internalname' => 'params[im_path]', 'value' => $im_path)) . "</p>"; -} - - -// River Image options -$form_body .= '<h3>' . elgg_echo('tidypics:settings:heading:river') . '</h3>'; -$img_river_view = $plugin->img_river_view; -if (!$img_river_view) { - $img_river_view = 'batch'; -} -$form_body .= '<p>' . elgg_echo('tidypics:settings:img_river_view') . ': '; -$form_body .= elgg_view('input/pulldown', array( - 'internalname' => 'params[img_river_view]', - 'options_values' => array( - 'all' => 'all', - 'batch' => '1', - 'none' => 'none', - ), - 'value' => $img_river_view -)); -$form_body .= '</p>'; - -// River Album options -$album_river_view = $plugin->album_river_view; -if (!$album_river_view) { - $album_river_view = 'set'; -} -$form_body .= '<p>' . elgg_echo('tidypics:settings:album_river_view') . ': '; -$form_body .= elgg_view('input/pulldown', array( - 'internalname' => 'params[album_river_view]', - 'options_values' => array( - 'cover' => 'cover', - 'set' => 'set', - ), - 'value' => $album_river_view -)); -$form_body .= '</p>'; - -// Thumbnail sizes -$form_body .= '<h3>' . elgg_echo('tidypics:settings:heading:sizes') . '</h3>'; -$form_body .= "<h6>You must edit the css if you change the default sizes</h6>"; -$image_sizes = $plugin->image_sizes; -if(!$image_sizes) { - $image_sizes = array(); // set default values - $image_sizes['large_image_width'] = $image_sizes['large_image_height'] = 600; - $image_sizes['small_image_width'] = $image_sizes['small_image_height'] = 153; - $image_sizes['thumb_image_width'] = $image_sizes['thumb_image_height'] = 60; -} else { - $image_sizes = unserialize($image_sizes); -} -$form_body .= "<p>" . elgg_echo('tidypics:settings:largesize') . "<br />"; -$form_body .= 'width: <input style="width: 20%;" type="text" name="large_thumb_width" value=' . "\"{$image_sizes['large_image_width']}\"" . ' class="input-text" /> '; -$form_body .= 'height: <input style="width: 20%;" type="text" name="large_thumb_height" value=' . "\"{$image_sizes['large_image_height']}\"" . ' class="input-text" /></p>'; - -$form_body .= "<p>" . elgg_echo('tidypics:settings:smallsize') . "<br />"; -$form_body .= 'width and height: <input style="width: 20%;" type="text" name="small_thumb_width" value=' . "\"{$image_sizes['small_image_width']}\"" . ' class="input-text" /> '; -//$form_body .= 'height: <input style="width: 20%;" type="text" name="small_thumb_height" value=' . "\"{$image_sizes['small_image_height']}\"" . ' class="input-text" /></p>'; - -$form_body .= "<p>" . elgg_echo('tidypics:settings:thumbsize') . "<br />"; -$form_body .= 'width and height: <input style="width: 20%;" type="text" name="thumb_width" value=' . "\"{$image_sizes['thumb_image_width']}\"" . ' class="input-text" /> '; -//$form_body .= 'height: <input style="width: 20%;" type="text" name="thumb_height" value=' . "\"{$image_sizes['thumb_image_height']}\"" . ' class="input-text" /></p>'; - - -// Group permission override -$form_body .= '<h3>' . elgg_echo('tidypics:settings:heading:groups') . '</h3>'; -$grp_perm_override = $plugin->grp_perm_override; -if (!$grp_perm_override) { - $grp_perm_override = "enabled"; -} -$form_body .= '<p class="admin_debug">' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:grp_perm_override') => 'enabled'), 'internalname' => 'grp_perm_override', 'value' => $grp_perm_override )) . "</p>"; - -$form_body .= elgg_view('input/submit', array('value' => elgg_echo("save"))); - -echo $form_body; diff --git a/views/default/tidypics/css.php b/views/default/tidypics/css.php index bf47d42b7..e35b8e73f 100644 --- a/views/default/tidypics/css.php +++ b/views/default/tidypics/css.php @@ -11,6 +11,10 @@ margin: 5px 10px; } +.tidypics-input-thin { + width: 120px; +} + <?php return true; ?> |