diff options
author | cash <cash.costello@gmail.com> | 2011-11-19 18:43:35 -0500 |
---|---|---|
committer | cash <cash.costello@gmail.com> | 2011-11-19 18:43:35 -0500 |
commit | 98664daa72a390fe760b69116af8bfa9327826e3 (patch) | |
tree | 0c28594625cd810dcb2c22fc736191071c55b7fa /views/default/forms/photos | |
parent | 4562cfbb1a630b14fd194271f99f1f8c098dc38d (diff) | |
download | elgg-98664daa72a390fe760b69116af8bfa9327826e3.tar.gz elgg-98664daa72a390fe760b69116af8bfa9327826e3.tar.bz2 |
album creation and editing is working
Diffstat (limited to 'views/default/forms/photos')
-rw-r--r-- | views/default/forms/photos/admin/settings.php | 179 | ||||
-rw-r--r-- | views/default/forms/photos/ajax_upload.php | 141 | ||||
-rw-r--r-- | views/default/forms/photos/album/save.php | 48 | ||||
-rw-r--r-- | views/default/forms/photos/basic_upload.php | 104 |
4 files changed, 472 insertions, 0 deletions
diff --git a/views/default/forms/photos/admin/settings.php b/views/default/forms/photos/admin/settings.php new file mode 100644 index 000000000..06b3f4cb9 --- /dev/null +++ b/views/default/forms/photos/admin/settings.php @@ -0,0 +1,179 @@ +<?php +/** + * Tidypics admin settings form body + */ + +$plugin = find_plugin_settings('tidypics'); + + +// Main settings +$form_body = '<h3>' . elgg_echo('tidypics:settings:heading:main') . '</h3>'; + +// Tagging +$tagging = $plugin->tagging; +if (!$tagging) { + $tagging = "enabled"; +} +$form_body .= '<p class="admin_debug">' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:tagging') => 'enabled'), 'internalname' => 'tagging', 'value' => $tagging )) . "</p>"; + +// 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>"; + +// 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>"; + +// 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) { + $quota = 0; +} +$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/forms/photos/ajax_upload.php b/views/default/forms/photos/ajax_upload.php new file mode 100644 index 000000000..a1d13e80b --- /dev/null +++ b/views/default/forms/photos/ajax_upload.php @@ -0,0 +1,141 @@ +<?php +/** + * Tidypics ajax upload form body + * + * @uses $vars['album'] + */ + +elgg_extend_view('metatags', 'tidypics/js/uploader'); + +$album = $vars['album']; + +$ts = time(); +$token = generate_action_token($ts); +$batch = time(); +$tidypics_token = md5(session_id() . get_site_secret() . $ts . get_loggedin_user()->salt); + +$basic_uploader_url = current_page_url() . '/basic'; +$upload_endpoint_url = "{$vars['url']}action/tidypics/ajax_upload/"; +$upload_complete_url = "{$vars['url']}action/tidypics/ajax_upload_complete/"; + +$maxfilesize = (float) get_plugin_setting('maxfilesize','tidypics'); +if (!$maxfilesize) { + $maxfilesize = 5; +} + +$quota = get_plugin_setting('quota','tidypics'); +if ($quota) { + $image_repo_size_md = get_metadata_byname($album->container_guid, "image_repo_size"); + $image_repo_size = (int)$image_repo_size_md->value; + $image_repo_size = $image_repo_size / 1024 / 1024; + $quote_percentage = round(100 * ($image_repo_size / $quota)); + // for small quotas, so one decimal place + if ($quota < 10) { + $image_repo_size = sprintf('%.1f', $image_repo_size); + } else { + $image_repo_size = round($image_repo_size); + } + if ($image_repo_size > $quota) { + $image_repo_size = $quota; + } +} + +?> + +<div class="contentWrapper"> + + <p><?php echo sprintf(elgg_echo('tidypics:uploader:instructs'), $basic_uploader_url); ?></p> + + <ul id="tidypics_uploader_steps"> + <li> + <div id="tidypics_uploader"> + <a id="tidypics_choose_button" href="<?php echo $basic_uploader_url; ?>"> + 1. <?php echo elgg_echo('tidypics:uploader:choose'); ?> + </a> + <div id="tidypics_flash_uploader"> + <input type="file" id="uploadify" name="uploadify" /> + </div> + </div> + </li> + <li> + <a id="tidypics_upload_button" class="tidypics_disable" href="javascript:$('#uploadify').uploadifyUpload();"> + 2. <?php echo elgg_echo('tidypics:uploader:upload'); ?> + </a> + </li> + <li> + <a id="tidypics_describe_button" class="tidypics_disable" href="<?php echo $vars['url']; ?>pg/photos/batch/<?php echo $batch; ?>"> + 3. <?php echo elgg_echo('tidypics:uploader:describe'); ?> + </a> + </li> + </ul> +</div> + +<script type="text/javascript"> + +$("#uploadify").uploadify({ + 'uploader' : '<?php echo $vars['url']; ?>mod/tidypics/vendors/uploadify/uploadify.swf', + 'script' : '<?php echo $upload_endpoint_url; ?>', + 'scriptData' : { + 'album_guid' : '<?php echo $album->guid; ?>', + 'user_guid' : '<?php echo get_loggedin_userid(); ?>', + '__elgg_token' : '<?php echo $token; ?>', + '__elgg_ts' : '<?php echo $ts; ?>', + 'Elgg' : '<?php echo session_id(); ?>', + 'tidypics_token' : '<?php echo $tidypics_token; ?>', + 'batch' : '<?php echo $batch; ?>' + }, + 'fileDataName' : 'Image', + 'cancelImg' : '<?php echo $vars['url']; ?>_graphics/icon_customise_remove.gif', + 'multi' : true, + 'auto' : false, + 'wmode' : 'transparent', + 'buttonImg' : " ", + 'height' : 20, + 'width' : 130, + 'onEmbedFlash' : function(event) { + $("#" + event.id).hover( + function(){ + $("#tidypics_choose_button").addClass('tidypics_choose_button_hover'); + }, + function(){ + $("#tidypics_choose_button").removeClass('tidypics_choose_button_hover'); + } + ); + }, + 'onSelectOnce' : function() { + $("#tidypics_upload_button").removeClass('tidypics_disable'); + }, + 'onAllComplete' : function() { + $("#tidypics_choose_button").addClass('tidypics_disable'); + $("#tidypics_upload_button").addClass('tidypics_disable'); + $("#tidypics_choose_button").attr("href", "javascript:void(0)"); + $("#tidypics_upload_button").attr("href", "javascript:void(0)"); + + $("#tidypics_describe_button").removeClass('tidypics_disable'); + $.post( + '<?php echo $upload_complete_url; ?>', + { + album_guid : '<?php echo $album->guid; ?>', + __elgg_token : '<?php echo $token; ?>', + __elgg_ts : '<?php echo $ts; ?>', + batch : '<?php echo $batch; ?>' + } + ); + }, + 'onComplete' : function(event, queueID, fileObj, response) { + // check for errors here + if (response != 'success') { + $("#uploadify" + queueID + " .percentage").text(" - " + response); + $("#uploadify" + queueID).addClass('uploadifyError'); + } + $("#uploadify" + queueID + " > .cancel").remove(); + return false; + }, + 'onCancel' : function(event, queueID, fileObj, data) { + if (data.fileCount == 0) { + $("#tidypics_upload_button").addClass('tidypics_disable'); + } + } + +}); +</script> diff --git a/views/default/forms/photos/album/save.php b/views/default/forms/photos/album/save.php new file mode 100644 index 000000000..8a1202c07 --- /dev/null +++ b/views/default/forms/photos/album/save.php @@ -0,0 +1,48 @@ +<?php +/** + * Save album form body + * + * @author Cash Costello + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2 + */ + +$title = elgg_extract('title', $vars, ''); +$description = elgg_extract('description', $vars, ''); +$tags = elgg_extract('tags', $vars, ''); +$access_id = elgg_extract('access_id', $vars, get_default_access()); +$container_guid = elgg_extract('container_guid', $vars, elgg_get_page_owner_guid()); +$guid = elgg_extract('guid', $vars, 0); + +?> + +<div> + <label><?php echo elgg_echo('album:title'); ?></label> + <?php echo elgg_view('input/text', array('name' => 'title', 'value' => $title)); ?> +</div> +<div> + <label><?php echo elgg_echo('album:desc'); ?></label> + <?php echo elgg_view('input/longtext', array('name' => 'description', 'value' => $description)); ?> +</div> +<div> + <label><?php echo elgg_echo('tags'); ?></label> + <?php echo elgg_view('input/tags', array('name' => 'tags', 'value' => $tags)); ?> +</div> +<?php + +$categories = elgg_view('input/categories', $vars); +if ($categories) { + echo $categories; +} + +?> +<div> + <label><?php echo elgg_echo('access'); ?></label> + <?php echo elgg_view('input/access', array('name' => 'access_id', 'value' => $access_id)); ?> +</div> +<div class="elgg-foot"> +<?php +echo elgg_view('input/hidden', array('name' => 'guid', 'value' => $guid)); +echo elgg_view('input/hidden', array('name' => 'container_guid', 'value' => $container_guid)); +echo elgg_view('input/submit', array('value' => elgg_echo('save'))); +?> +</div> diff --git a/views/default/forms/photos/basic_upload.php b/views/default/forms/photos/basic_upload.php new file mode 100644 index 000000000..55ab854a4 --- /dev/null +++ b/views/default/forms/photos/basic_upload.php @@ -0,0 +1,104 @@ +<?php +/** + * Tidypics basic uploader form + * + * This only handled uploading the images. Editing the titles and descriptions + * are handled with the edit forms. + * + * @uses $vars['album'] + */ + +global $CONFIG; + +$album = $vars['album']; +$access_id = $album->access_id; + +$maxfilesize = (float) get_plugin_setting('maxfilesize','tidypics'); +if (!$maxfilesize) { + $maxfilesize = 5; +} + +$quota = get_plugin_setting('quota','tidypics'); +if ($quota) { + $image_repo_size_md = get_metadata_byname($album->container_guid, "image_repo_size"); + $image_repo_size = (int)$image_repo_size_md->value; + $image_repo_size = $image_repo_size / 1024 / 1024; + $quote_percentage = round(100 * ($image_repo_size / $quota)); + // for small quotas, so one decimal place + if ($quota < 10) { + $image_repo_size = sprintf('%.1f', $image_repo_size); + } else { + $image_repo_size = round($image_repo_size); + } + if ($image_repo_size > $quota) { + $image_repo_size = $quota; + } +} + +?> +<div id="tidypics_ref"></div> +<div class="contentWrapper"> + <?php + ob_start(); + ?> + <p style="line-height:1.6em;"> + <label><?php echo elgg_echo("tidypics:uploader:upload"); ?></label><br /> + <i><?php echo sprintf(elgg_echo('tidypics:uploader:basic'), $maxfilesize); ?></i><br /> + <?php + if ($quota) { + ?> + <i><?php echo elgg_echo("tidypics:quota") . ' ' . $image_repo_size . '/' . $quota . " MB ({$quote_percentage}%)"; ?></i><br /> + <?php + } + ?> + <div class="tidypics_popup"> + <?php echo elgg_echo("tidypics:uploading:images"); ?><br /> + <div style="margin:20px 0px 20px 80px;"><img id="progress" alt="..." border="0" src="<?php echo $vars['url'].'mod/tidypics/graphics/loader.gif' ?>" /></div> + </div> + <ol id="tidypics_image_upload_list"> + <?php + for ($x = 0; $x < 10; $x++) { + echo '<li>' . elgg_view("input/file",array('internalname' => "upload_$x")) . '</li>'; + } + ?> + </ol> +</p> +<p> + <?php + if ($album) { + echo '<input type="hidden" name="album_guid" value="' . $album->guid . '" />'; + } + if ($access_id) { + echo '<input type="hidden" name="access_id" value="' . $access_id . '" />'; + } + ?> + <input type="submit" value="<?php echo elgg_echo("save"); ?>" onclick="displayProgress();" /> +</p> +<?php +$form_body = ob_get_clean(); +echo $form_body; + +?> +</div> +<script type="text/javascript"> + + function displayProgress() + { + offsetY = 60; + offsetX = 120; + + divWidth = $('#tidypics_ref').width(); + imgOffset = $('#tidypics_ref').offset(); + imgWidth = $('#tidypics_ref').width(); + + _top = imgOffset.top + offsetY; + _left = imgOffset.left + offsetX; + + $('.tidypics_popup').show().css({ + "top": _top + "px", + "left": _left + "px" + }); + + setTimeout('document.images["progress"].src = "<?php echo $vars['url'].'mod/tidypics/graphics/loader.gif' ?>"', 200); + } +</script>
\ No newline at end of file |