function afg_reports_html_page() { global $afg_photo_size_map, $afg_on_off_map, $afg_descr_map, $afg_columns_map, $afg_bg_color_map, $afg_width_map, $pf, $afg_sort_order_map, $afg_slideshow_map, $wpdb; ?> <div class='wrap'> <h2><img src="<?php echo BASE_URL . '/images/logo_big.png'; ?> " align='center'/>Flickr Gallery Settings</h2> <?php if ($_GET && wp_verify_nonce($_REQUEST['nonce'], 'ajax-afg-removeimg-nonce-' . $_REQUEST['report'])) { //$photo = $pf->photos_getAllContexts($_REQUEST['report']); $ret = $wpdb->update($wpdb->prefix . "flickruploads", array('status' => -1), array('photoid' => $_REQUEST['report']), array('%d'), array('%s')); /* foreach ($photo['set'] as $id => $set){ $pf->photosets_removePhoto($set['id'] ,$_REQUEST['report']); } $pf->photosets_addPhoto(get_option('afg_banned_photoset'),$_REQUEST['report'] ); */ } else { echo $_REQUEST['nonce']; echo 'ajax-afg-removeimg-nonce-' . $_REQUEST['report']; echo wp_create_nonce('ajax-afg-removeimg-nonce-' . $photo['id']); echo wp_verify_nonce($_REQUEST['nonce'], 'ajax-afg-removeimg-nonce-' . $_REQUEST['report']); } $url = $_SERVER['REQUEST_URI']; ?> <form method='post' action='<?php echo $url; ?> '> <?php echo afg_generate_version_line(); ?> <div class="postbox-container" style="width:69%; margin-right:1%"> <div id="poststuff"> <div class="postbox" style='box-shadow:0 0 2px'> <h3>Reported images</h3> <?php $rsp_obj = $wpdb->get_results("\r\n SELECT photoid as id, photosecret as secret, farm, server \r\n FROM {$wpdb->prefix}flickruploads\r\n WHERE status=1 \r\n ", ARRAY_A); if (!$rsp_obj) { echo afg_error(); } else { foreach ($rsp_obj as $photo) { $photo_url = "http://farm{$photo['farm']}.static.flickr.com/{$photo['server']}/{$photo['id']}_{$photo['secret']}_s.jpg"; $linkurl = $url . '&report=' . $photo['id'] . '&nonce=' . wp_create_nonce('ajax-afg-removeimg-nonce-' . $photo['id']); echo '<a href="' . $linkurl . '" class="ban-image"><img src="' . $photo_url . '"/></a>'; } } ?> </div> </div> </div> </form> <?php if (DEBUG) { print_all_options(); } }
function afg_advanced_settings_page() { $url = $_SERVER['REQUEST_URI']; ?> <div class='wrap'> <h2><img src="<?php echo BASE_URL . '/images/logo_big.png'; ?> " align='center'/>Advanced Settings | Flickr Gallery</h2> <?php if (isset($_POST['afg_advanced_save_changes']) && $_POST['afg_advanced_save_changes']) { update_option('afg_disable_slideshow', isset($_POST['afg_disable_slideshow']) ? $_POST['afg_disable_slideshow'] : ''); update_option('afg_slideshow_option', $_POST['afg_slideshow_option']); update_option('afg_custom_css', $_POST['afg_custom_css']); echo "<div class='updated'><p><strong>Settings updated successfully.</strong></p></div>"; } ?> <form method='post' action='<?php echo $url; ?> '> <?php echo afg_generate_version_line(); ?> <div class="postbox-container" style="width:69%; margin-right:1%"> <div id="poststuff"> <div class="postbox" style='box-shadow:0 0 2px'> <h3>Custom CSS</h3> <div style="background-color:#FFFFE0; border-color:#E6DB55; maargin:5px 0 15px; border-radius:3px 3px 3px 3px; border-width: 1px; border-style: solid; padding: 8px 10px; line-height: 20px"> Check <a href='<?php echo BASE_URL . '/afg.css'; ?> ' target='_blank'>afg.css</a> to see existing classes and properties for gallery which you can redefine here. Note that there is no validation applied to CSS Code entered here, so make sure that you enter valid CSS. </div><br/> <textarea id='afg_custom_css' name='afg_custom_css'><?php echo get_option('afg_custom_css'); ?> </textarea> <script type="text/javascript">var myCodeMirror = CodeMirror.fromTextArea(document.getElementById('afg_custom_css'), { lineNumbers: true, indentUnit: 4, theme: "cobalt", matchBrackets: true} );</script> </div> </div> <input type="submit" name="afg_advanced_save_changes" id="afg_advanced_save_changes" class="button-primary" value="Save Changes" /> </div> <div class="postbox-container" style="width: 29%;"> <?php $message = "Settings on this page are global and hence apply to all your Galleries."; echo afg_box('Help', $message); // echo afg_donate_box(); // echo afg_share_box(); ?> </div> </form> </div> <?php }
function afg_add_gallery() { global $afg_photo_size_map, $afg_on_off_map, $afg_descr_map, $afg_columns_map, $afg_bg_color_map, $afg_photo_source_map, $pf; $user_id = get_option('afg_user_id'); $photosets_map = array(); $groups_map = array(); $galleries_map = array(); $rsp_obj = $pf->photosets_getList($user_id); if (!$pf->error_code) { foreach ($rsp_obj['photoset'] as $photoset) { $photosets_map[$photoset['id']] = $photoset['title']['_content']; } } $rsp_obj = $pf->galleries_getList($user_id); if (!$pf->error_code) { foreach ($rsp_obj['galleries']['gallery'] as $gallery) { $galleries_map[$gallery['id']] = $gallery['title']['_content']; } } if (get_option('afg_flickr_token')) { $rsp_obj = $pf->groups_pools_getGroups(); if (!$pf->error_code) { foreach ($rsp_obj['group'] as $group) { $groups_map[$group['nsid']] = $group['name']; } } } else { $rsp_obj = $pf->people_getPublicGroups($user_id); if (!$pf->error_code) { foreach ($rsp_obj as $group) { $groups_map[$group['nsid']] = $group['name']; } } } ?> <div class='wrap'> <h2><img src="<?php echo BASE_URL . '/images/logo_big.png'; ?> " align='center'/>Add Gallery | Flickr Gallery</h2> <?php if ($_POST && $_POST['afg_add_gallery_name']) { if (isset($_POST['afg_per_page_check']) && $_POST['afg_per_page_check']) { $_POST['afg_per_page'] = ''; } else { if (!(ctype_digit($_POST['afg_per_page']) && (int) $_POST['afg_per_page'])) { $_POST['afg_per_page'] = ''; echo "<div class='updated'><p><strong>You entered invalid value for Per Page option. It has been set to Default.</strong></p></div>"; } } $gallery = array('name' => $_POST['afg_add_gallery_name'], 'gallery_descr' => $_POST['afg_add_gallery_descr'], 'photo_source' => $_POST['afg_photo_source_type'], 'per_page' => afg_filter($_POST['afg_per_page']), 'sort_order' => afg_filter($_POST['afg_sort_order']), 'photo_size' => afg_filter($_POST['afg_photo_size']), 'captions' => afg_filter($_POST['afg_captions']), 'descr' => afg_filter($_POST['afg_descr']), 'columns' => afg_filter($_POST['afg_columns']), 'slideshow_option' => afg_filter($_POST['afg_slideshow_option']), 'credit_note' => afg_filter($_POST['afg_credit_note']), 'bg_color' => afg_filter($_POST['afg_bg_color']), 'width' => afg_filter($_POST['afg_width']), 'pagination' => afg_filter($_POST['afg_pagination'])); if ($_POST['afg_photo_source_type'] == 'photoset') { $gallery['photoset_id'] = implode(",", $_POST['afg_photosets_box']); } else { if ($_POST['afg_photo_source_type'] == 'gallery') { $gallery['gallery_id'] = $_POST['afg_galleries_box']; } else { if ($_POST['afg_photo_source_type'] == 'group') { $gallery['group_id'] = $_POST['afg_groups_box']; } else { if ($_POST['afg_photo_source_type'] == 'tags') { $gallery['tags'] = $_POST['afg_tags']; } } } } if ($gallery['photo_size'] == 'custom') { if (ctype_digit($_POST['afg_custom_size']) && (int) $_POST['afg_custom_size'] >= 50 && (int) $_POST['afg_custom_size'] <= 500) { $gallery['custom_size'] = $_POST['afg_custom_size']; } else { $gallery['custom_size'] = 100; echo "<div class='updated'><p><strong>You entered invalid value for Custom Width option. It has been set to 100.</strong></p></div>"; } $gallery['custom_size_square'] = $_POST['afg_custom_size_square'] ? $_POST['afg_custom_size_square'] : 'false'; } $galleries = get_option('afg_galleries'); $galleries[] = $gallery; update_option('afg_galleries', $galleries); end($galleries); $id = key($galleries); ?> <div class="updated"><p><strong> <?php echo "Gallery \"{$_POST['afg_add_gallery_name']}\" created successfully. Shortcode for this gallery is </strong>[AFG_gallery id='{$id}']"; ?> </p></div> <?php } echo afg_generate_version_line(); $url = $_SERVER['REQUEST_URI']; ?> <form method='post' action='<?php echo $url; ?> '> <div class="postbox-container" style="width:69%; margin-right:1%"> <div id="poststuff"> <div class="postbox" style='box-shadow:0 0 2px'> <h3>Gallery Parameters</h3> <table class='form-table'> <tr valign='top'> <th scope='row'>Gallery Name</th> <td><input maxlength='30' type='text' id='afg_add_gallery_name' name='afg_add_gallery_name' onblur='verifyBlank()' value='' /><font size='3' color='red'>*</font></td> </tr> <tr valign='top'> <th scope='row'>Gallery Description</th> <td><input maxlength='100' size='70%' type='text' id='afg_add_gallery_descr' name='afg_add_gallery_descr'" value="" /></td> </tr> </table> </div></div> <?php echo afg_generate_flickr_settings_table($photosets_map, $galleries_map, $groups_map); echo afg_generate_gallery_settings_table(); ?> <input type="submit" disabled='true' id="afg_save_changes" class="button-primary" value="Add Gallery" /> </div> <div class="postbox-container" style="width: 29%;"> <?php $message = "<b>Gallery Description</b> - Provide a meaningful description of" . " your gallery for you to recognize it easily.<br /><br />" . " <b>Gallery Source</b> - Where do you want to fetch your photos from?" . " Your Flickr Photostream, a Photoset, a Gallery or a Group?<br /><br />" . " <b>What is <i>Default</i>?</b> - When you select <i>" . " Default</i> for a setting, it will be inherited from <a href=\"" . $_SERVER['PHP_SELF'] . "?page=afg_plugin_page\"><i>Default" . " Settings</i></a>. The setting here is stored as reference to the" . " setting on Default Settings page, so if you change the <i>Default" . " Settings</i>, the setting for this specific gallery will also change."; echo afg_box('Help', $message); //echo afg_donate_box(); //echo afg_share_box(); ?> </div> </form> <?php }
function afg_admin_html_page() { global $afg_photo_size_map, $afg_on_off_map, $afg_descr_map, $afg_columns_map, $afg_bg_color_map, $afg_width_map, $pf, $afg_sort_order_map, $afg_slideshow_map; function upgrade_handler() { $galleries = get_option('afg_galleries'); if ($galleries) { foreach ($galleries as &$gallery) { if (!isset($gallery['slideshow_option']) && $gallery['slideshow_option'] == 'highslide') { $gallery['slideshow_option'] = 'swipebox'; } } update_option('afg_galleries', $galleries); } unset($gallery); $afg_cache_refresh_interval = get_option('afg_cache_refresh_interval'); if (!isset($afg_cache_refresh_interval)) { update_option('afg_cache_refresh_interval', '1d'); } } upgrade_handler(); if ($_POST) { global $pf, $custom_size_err_msg; if (isset($_POST['submit']) && $_POST['submit'] == 'Delete Cached Galleries') { delete_afg_caches(); echo "<div class='updated'><p><strong>Cached data deleted successfully.</strong></p></div>"; } else { if (isset($_POST['submit']) && $_POST['submit'] == 'Save Changes') { update_option('afg_api_key', $_POST['afg_api_key']); if (!$_POST['afg_api_secret'] || $_POST['afg_api_secret'] != get_option('afg_api_secret')) { update_option('afg_flickr_token', ''); } update_option('afg_api_secret', $_POST['afg_api_secret']); update_option('afg_user_id', $_POST['afg_user_id']); if (ctype_digit($_POST['afg_per_page']) && (int) $_POST['afg_per_page']) { update_option('afg_per_page', $_POST['afg_per_page']); } else { update_option('afg_per_page', 10); echo "<div class='updated'><p><strong>You entered invalid value for Per Page option. It has been set to 10.</strong></p></div>"; } update_option('afg_sort_order', $_POST['afg_sort_order']); update_option('afg_photo_size', $_POST['afg_photo_size']); if (get_option('afg_photo_size') == 'custom') { if (ctype_digit($_POST['afg_custom_size']) && (int) $_POST['afg_custom_size'] >= 50 && (int) $_POST['afg_custom_size'] <= 500) { update_option('afg_custom_size', $_POST['afg_custom_size']); if (!is_dir(dirname(__FILE__) . "/cache")) { if (!wp_mkdir_p(dirname(__FILE__) . "/cache")) { echo "<div class='updated'><p>Could not create directory - '" . dirname(__FILE__) . "/cache'. This is required for custom size photos to be displayed. Manually create this directory and set permissions for this directory as 777.</p></div>"; } } } else { update_option('afg_custom_size', 100); echo "<div class='updated'><p><strong>You entered invalid value for Custom Width option. It has been set to 100.</strong></p></div>"; } update_option('afg_custom_size_square', $_POST['afg_custom_size_square'] ? $_POST['afg_custom_size_square'] : 'false'); } update_option('afg_captions', $_POST['afg_captions']); update_option('afg_descr', $_POST['afg_descr']); update_option('afg_columns', $_POST['afg_columns']); update_option('afg_slideshow_option', $_POST['afg_slideshow_option']); update_option('afg_width', $_POST['afg_width']); update_option('afg_bg_color', $_POST['afg_bg_color']); if (isset($_POST['afg_credit_note']) && $_POST['afg_credit_note']) { update_option('afg_credit_note', 'on'); } else { update_option('afg_credit_note', 'off'); } if (isset($_POST['afg_pagination']) && $_POST['afg_pagination']) { update_option('afg_pagination', 'off'); } else { update_option('afg_pagination', 'on'); } echo "<div class='updated'><p><strong>Settings updated successfully.</br></br><font style='color:red'>Important Note:</font> If you have installed a caching plugin (like WP Super Cache or W3 Total Cache etc.), you may have to delete your cached pages for the settings to take effect.</strong></p></div>"; if (get_option('afg_api_secret') && !get_option('afg_flickr_token')) { echo "<div class='updated'><p><strong>Click \"Grant Access\" button to authorize Awesome Flickr Gallery to access your private photos from Flickr.</strong></p></div>"; } } } create_afgFlickr_obj(); } $url = $_SERVER['REQUEST_URI']; ?> <form method='post' action='<?php echo $url; ?> '> <div id='afg-wrap'> <h2><a href='http://www.ronakg.com/projects/awesome-flickr-gallery-wordpress-plugin/'><img src="<?php echo BASE_URL . '/images/logo_big.png'; ?> " align='center'/></a>Awesome Flickr Gallery Settings</h2> <?php echo afg_generate_version_line(); ?> <div id="afg-main-box"> <h3>Flickr User Settings</h3> <table class='widefat afg-settings-box'> <tr> <th class="afg-label"></th> <th class="afg-input"></th> <th class="afg-help-bubble"></th> </tr> <tr> <td>Flickr User ID</td> <td><input class='afg-input' type='text' name='afg_user_id' value="<?php echo get_option('afg_user_id'); ?> " /><b>*</b></td> <td><div class="afg-help">Don't know your Flickr User ID? Get it from <a href="http://idgettr.com/" target='blank'>here.</a></div></td> </tr> <tr> <td>Flickr API Key</td> <td><input class='afg-input' type='text' name='afg_api_key' value="<?php echo get_option('afg_api_key'); ?> " ><b>*</b></input> </td> <td> <div class='afg-help'>Don't have a Flickr API Key? Get it from <a href="http://www.flickr.com/services/api/keys/" target='blank'>here.</a> Go through the <a href='http://www.flickr.com/services/api/tos/'>Flickr API Terms of Service.</a></div></td> </tr> <tr> <td>Flickr API Secret</td> <td><input class='afg-input' type='text' name='afg_api_secret' id='afg_api_secret' value="<?php echo get_option('afg_api_secret'); ?> "/> <br /><br /> <?php if (get_option('afg_api_secret')) { if (get_option('afg_flickr_token')) { echo "<input type='button' class='button-secondary' value='Access Granted' disabled=''"; } else { ?> <input type="button" class="button-primary" value="Grant Access" onClick="document.location.href='<?php echo get_admin_url() . 'admin-ajax.php?action=afg_gallery_auth'; ?> ';"/> <?php } } else { echo "<input type='button' class='button-secondary' value='Grant Access' disabled=''"; } ?> </td> <td class="afg-help"><b>ONLY</b> If you want to include your <b>Private Photos</b> in your galleries, enter your Flickr API Secret here and click Save Changes. </td> </tr> </table> <table class='widefat afg-settings-box'> <h3>Gallery Settings</h3> <tr> <th class="afg-label"></th> <th class="afg-input"></th> <th class="afg-help-bubble"></th> </tr> <tr> <td>Max Photos Per Page</td> <td><input type='text' name='afg_per_page' id='afg_per_page' onblur='verifyPerPageBlank()' maxlength='3' value="<?php echo get_option('afg_per_page') ? get_option('afg_per_page') : 10; ?> " /><b>*</b></td> </tr> <tr> <td>Sort order of Photos</td> <td><select name='afg_sort_order' id='afg_sort_order'> <?php echo afg_generate_options($afg_sort_order_map, get_option('afg_sort_order', 'flickr')); ?> </select> <td class="afg-help">Set the sort order of the photos as per your liking and forget about how photos are arranged on Flickr.</td> </td> </tr> <tr> <td>Size of the Photos</td> <td><select name='afg_photo_size' id='afg_photo_size' onchange='customPhotoSize()'> <?php echo afg_generate_options($afg_photo_size_map, get_option('afg_photo_size', '_m')); ?> </select></td> </tr> <tr valign='top' id='afg_custom_size_block' style='display:none'> <td>Custom Width</td> <td><input type='text' size='3' maxlength='3' name='afg_custom_size' id='afg_custom_size' onblur='verifyCustomSizeBlank()' value="<?php echo get_option('afg_custom_size') ? get_option('afg_custom_size') : 100; ?> ">* (in px) Square? <input type='checkbox' name='afg_custom_size_square' value='true' <?php if (get_option('afg_custom_size_square') == 'true') { echo "checked=''"; } ?> > </td> <td class="afg-help">Fill in the exact width for the photos (min 50, max 500). Height of the photos will be adjusted accordingly to maintain aspect ratio of the photo. Enable <b>Square</b> to crop the photo to a square aspect ratio.<br />Warning: Custom photo sizes may not work with your webhost, please use built-in sizes, it's more reliable and faster too.</td> </tr> <tr> <td>Photo Titles</td> <td><select name='afg_captions'> <?php echo afg_generate_options($afg_on_off_map, get_option('afg_captions', 'on')); ?> </select></td> <td class="afg-help">Photo Title setting applies only to Thumbnail (and above) size photos.</td> </tr> <tr> <td>Photo Descriptions</td> <td><select name='afg_descr'> <?php echo afg_generate_options($afg_descr_map, get_option('afg_descr', 'off')); ?> </select></td> <td class="afg-help">Photo Description setting applies only to Small and Medium size photos.</td> </tr> <tr> <td>Number of Columns</td> <td><select name='afg_columns'> <?php echo afg_generate_options($afg_columns_map, get_option('afg_columns', '2')); ?> </select></td> </tr> <tr> <td>Slideshow Behavior</td> <td><select name='afg_slideshow_option'> <?php echo afg_generate_options($afg_slideshow_map, get_option('afg_slideshow_option', 'swipebox')); ?> </select></td> </tr> <tr> <td>Background Color</td> <td><select name='afg_bg_color'> <?php echo afg_generate_options($afg_bg_color_map, get_option('afg_bg_color', 'Transparent')); ?> </select></td> </tr> <tr> <td>Gallery Width</td> <td><select name='afg_width'> <?php echo afg_generate_options($afg_width_map, get_option('afg_width', 'auto')); ?> </select></td> <td class="afg-help">Width of the Gallery is relative to the width of the page where Gallery is being generated. <i>Automatic</i> is 100% of page width.</td> </tr> <tr> <td>Disable Pagination?</td> <td><input type='checkbox' name='afg_pagination' value='off' <?php if (get_option('afg_pagination', 'off') == 'off') { echo 'checked=\'\''; } ?> /></td> <td class="afg-help">Useful when displaying gallery in a sidebar widget where you want only few recent photos.</td> </tr> <tr> <td>Add a Small Credit Note?</td> <td><input type='checkbox' name='afg_credit_note' value='Yes' <?php if (get_option('afg_credit_note', 'on') == 'on') { echo "checked=''"; } ?> /></td> <td class="afg-help">Credit Note will appear at the bottom of the gallery as - Powered by <a href="http://www.ronakg.com/projects/awesome-flickr-gallery-wordpress-plugin" title="Awesome Flickr Gallery by Ronak Gandhi"/> AFG</a></td> </tr> </table> <br /> <input type="submit" name="submit" id="afg_save_changes" class="button-primary" value="Save Changes" /> <br /><br /> <h3>Your Photostream Preview</h3> <table class='widefat afg-settings-box'> <tr><th>If your Flickr Settings are correct, 5 of your recent photos from your Flickr photostream should appear here.</th></tr> <td><div style="margin-top:15px"> <?php global $pf; if (get_option('afg_flickr_token')) { $rsp_obj = $pf->people_getPhotos(get_option('afg_user_id'), array('per_page' => 5, 'page' => 1)); } else { $rsp_obj = $pf->people_getPublicPhotos(get_option('afg_user_id'), NULL, NULL, 5, 1); } if (!$rsp_obj) { echo afg_error(); } else { foreach ($rsp_obj['photos']['photo'] as $photo) { $photo_url = "http://farm{$photo['farm']}.static.flickr.com/{$photo['server']}/{$photo['id']}_{$photo['secret']}_s.jpg"; echo "<img src=\"{$photo_url}\"/> "; } } ?> </div> <br /> <span style="margin-top:15px"> Note: This preview is based on the Flickr Settings only. Gallery Settings have no effect on this preview. You will need to insert gallery code to a post or page to actually see the Gallery.</span> </td> </table> <br /> <input type="submit" name="submit" class="button-secondary" value="Delete Cached Galleries"/> </div> <?php if (DEBUG) { print_all_options(); } ?> <div id="afg-side-box"> <?php $message = "<b>What are Default Settings?</b> - Default Settings serve as a\n template for the galleries. When you create a new gallery, you can assign\n <i>Use Default</i> to a setting. Such a setting will reference the <b>Default\n Settings</b> instead of a specific setting defined for that particular\n gallery. <br /> <br />\n When you change any of <b>Default Settings</b>, all the settings in a gallery\n referencing the <b>Default Settings</b> will inherit the new value.<br /><br />\n <font color='red'><b>Important Note about Private Photos:</b></font><br/>To access\n your private photos from Flickr, make sure that your App's authentication\n type is set to <b>Web Application</b> and the <b>Callback URL</b>\n points to <font color='blue'><i>" . get_admin_url() . "</i></font>\n "; echo afg_box('Help', $message); $message = "Just insert the code <strong><font color='steelblue'>[AFG_gallery]</font></strong> in any of your posts or pages to display the Awesome Flickr Gallery.\n <br /><p style='text-align:center'><i>-- OR --</i></p>You can create a new Awesome Flickr Gallery with different settings on page <a href='{$_SERVER['PHP_SELF']}?page=afg_add_gallery_page'>Add Galleries."; echo afg_box('Usage Instructions', $message); echo afg_donate_box(); echo afg_share_box(); ?> </div> </div> </form> <?php }
function afg_edit_galleries() { global $afg_photo_size_map, $afg_on_off_map, $afg_descr_map, $afg_columns_map, $afg_bg_color_map, $afg_photo_source_map, $default_gallery_id, $pf; $user_id = get_option('afg_user_id'); $cur_page_url = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? "https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] : "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; preg_match('/\\&gallery_id=(?P<gallery_id>\\d+)/', $cur_page_url, $matches); if ($matches && !$default_gallery_id) { $default_gallery_id = $matches['gallery_id']; $match_pos = strpos($cur_page_url, "&gallery_id={$default_gallery_id}"); $cur_page_url = substr($cur_page_url, 0, $match_pos); } $photosets_map = array(); $groups_map = array(); $galleries_map = array(); afg_get_sets_groups_galleries($photosets_map, $groups_map, $galleries_map, $user_id); ?> <div class='wrap'> <h2><a href='http://www.ronakg.com/projects/awesome-flickr-gallery-wordpress-plugin/'><img src="<?php echo BASE_URL . '/images/logo_big.png'; ?> " align='center'/></a>Edit Galleries | Awesome Flickr Gallery</h2> <?php if ($_POST && $_POST['afg_edit_gallery_name']) { global $warning; if ($warning) { echo "<div class='updated'><p><strong>You entered invalid value for Per Page option. It has been set to Default.</strong></p></div>"; $warning = false; } echo "<div class='updated'><p><strong>Gallery updated successfully.</strong></p></div>"; } echo afg_generate_version_line(); $url = $_SERVER['REQUEST_URI']; ?> <form method='post' action='<?php echo $url; ?> '> <div id="afg-wrap"> <div id="afg-main-box"> <h3>Saved Galleries</h3> <table class='widefat fixed afg-settings-box'> <tr> <th class="afg-label"></th> <th class="afg-input"></th> <th class="afg-help-bubble"></th> </tr> <tr> <td>Select Gallery to Edit</td> <td><select id='afg_photo_gallery' name='afg_photo_gallery' onchange='loadGallerySettings()'> <?php echo afg_get_galleries($default_gallery_id); ?> </select></td> <tr> <td>Gallery Name</td> <td><input class='afg-input' maxlength='30' type='text' id='afg_edit_gallery_name' name='afg_edit_gallery_name' onblur='verifyEditBlank()' value="" />*</td> </tr> <tr> <td>Gallery Description</td> <td><input class='afg-input' maxlength='100' type='text' id='afg_edit_gallery_descr' name='afg_edit_gallery_descr' value="" /></td> </tr> </table> <?php echo afg_generate_flickr_settings_table($photosets_map, $galleries_map, $groups_map); echo afg_generate_gallery_settings_table(); $gals = get_option('afg_galleries'); if (sizeof($gals) == 1) { $disable_submit = True; } else { $disable_submit = False; } ?> <input type="submit" id="afg_save_changes" class="button-primary" <?php if ($disable_submit) { echo "disabled='yes'"; } ?> value="Save Changes" style="margin-top: 15px"/> <br /><br /> </div> <div id="afg-side-box"> <h3>Gallery Code</h3> <table class='widefat fixed afg-side-box'> <tr valign='top'> <td> <p id='afg_flickr_gallery_code'>[AFG_gallery]</p> </td> </tr> </table> <?php echo afg_box('Usage Instructions', 'Insert the Gallery Code in any of your posts or pages to display your Flickr Gallery.'); echo afg_donate_box(); echo afg_share_box(); ?> </div> </div> </form> <?php }
function afg_edit_galleries() { global $afg_photo_size_map, $afg_on_off_map, $afg_descr_map, $afg_columns_map, $afg_bg_color_map, $afg_photo_source_map, $default_gallery_id, $pf; $user_id = get_option('afg_user_id'); $cur_page_url = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? "https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] : "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; preg_match('/\\&gallery_id=(?P<gallery_id>\\d+)/', $cur_page_url, $matches); if ($matches && !$default_gallery_id) { $default_gallery_id = $matches['gallery_id']; $match_pos = strpos($cur_page_url, "&gallery_id={$default_gallery_id}"); $cur_page_url = substr($cur_page_url, 0, $match_pos); } $photosets_map = array(); $rsp_obj = $pf->photosets_getList($user_id); if (!$pf->error_code) { foreach ($rsp_obj['photoset'] as $photoset) { $photosets_map[$photoset['id']] = $photoset['title']['_content']; } } $galleries_map = array(); $rsp_obj = $pf->galleries_getList($user_id); if (!$pf->error_code) { foreach ($rsp_obj['galleries']['gallery'] as $gallery) { $galleries_map[$gallery['id']] = $gallery['title']['_content']; } } $groups_map = array(); if (get_option('afg_flickr_token')) { $rsp_obj = $pf->groups_pools_getGroups(); if (!$pf->error_code) { foreach ($rsp_obj['group'] as $group) { $groups_map[$group['nsid']] = $group['name']; } } } else { $rsp_obj = $pf->people_getPublicGroups($user_id); if (!$pf->error_code) { foreach ($rsp_obj as $group) { $groups_map[$group['nsid']] = $group['name']; } } } ?> <div class='wrap'> <h2><a href='http://www.ronakg.com/projects/awesome-flickr-gallery-wordpress-plugin/'><img src="<?php echo BASE_URL . '/images/logo_big.png'; ?> " align='center'/></a>Edit Galleries | Awesome Flickr Gallery</h2> <?php if ($_POST && $_POST['afg_edit_gallery_name']) { global $warning; if ($warning) { echo "<div class='updated'><p><strong>You entered invalid value for Per Page option. It has been set to Default.</strong></p></div>"; $warning = false; } echo "<div class='updated'><p><strong>Gallery updated successfully.</strong></p></div>"; } echo afg_generate_version_line(); $url = $_SERVER['REQUEST_URI']; ?> <form method='post' action='<?php echo $url; ?> '> <div class="postbox-container" style="width:69%; margin-right:1%"> <div id="poststuff"> <div class="postbox" style='box-shadow:0 0 2px'> <h3>Saved Galleries</h3> <table class='form-table'> <tr valign='top'> <th scope='row'>Select Gallery to Edit</th> <td><select id='afg_photo_gallery' name='afg_photo_gallery' onchange='loadGallerySettings()'> <?php echo afg_get_galleries($default_gallery_id); ?> </select></td> <tr valign='top'> <th scope='row'>Gallery Name</th> <td><input maxlength='30' type='text' id='afg_edit_gallery_name' name='afg_edit_gallery_name' onblur='verifyEditBlank()' value="" /><font size='3' color='red'>*</font></td> </tr> <tr valign='top'> <th scope='row'>Gallery Description</th> <td><input maxlength='100' size='70%' type='text' id='afg_edit_gallery_descr' name='afg_edit_gallery_descr' value="" /></td> </tr> </table> </div></div> <?php echo afg_generate_flickr_settings_table($photosets_map, $galleries_map, $groups_map); echo afg_generate_gallery_settings_table(); $gals = get_option('afg_galleries'); if (sizeof($gals) == 1) { $disable_submit = True; } else { $disable_submit = False; } ?> <input type="submit" id="afg_save_changes" class="button-primary" <?php if ($disable_submit) { echo "disabled='yes'"; } ?> value="Save Changes" /> <br /><br /> <div id="poststuff"> <div class="postbox" style='box-shadow:0 0 2px'> <h3>Gallery Code</h3> <table class='form-table'> <tr valign='top'> <td> <p id='afg_flickr_gallery_code'>[AFG_gallery]</p> </td> </tr> </table> </div></div> </div> <div class="postbox-container" style="width: 29%;"> <?php echo afg_box('Usage Instructions', 'Insert the Gallery Code in any of your posts of pages to display your Flickr Gallery.'); echo afg_donate_box(); echo afg_share_box(); ?> </div> </form> <?php }
function afg_add_users() { $users = get_option('afg_users'); $default_user = get_option('afg_user_id'); ?> <div class='wrap'> <h2><img src="<?php echo BASE_URL . '/images/logo_big.png'; ?> " align='center'/>Add Gallery | Flickr Gallery</h2> <?php if ($_POST) { $users = get_option('afg_users'); if ($_POST['submit'] == 'Add User') { if ($_POST['afg_new_user_id']) { $users[$_POST['afg_new_user_id']] = $_POST['afg_new_user_name']; update_option('afg_users', $users); ?> <div class="updated"><p><strong>User Added Successfully.</strong> </p></div> <?php } } $modified = false; if ($_POST['submit'] == 'Delete Selected Users') { foreach ($users as $uid => $uname) { if ($_POST['delete_user_' . $uid] == 'on') { unset($users[$uid]); $modified = true; } } if ($modified) { update_option('afg_users', $users); ?> <div class="updated"><p><strong>Users Deleted Successfully.</strong> </p></div> <?php } } } echo afg_generate_version_line(); $url = $_SERVER['REQUEST_URI']; $users = get_option('afg_users'); ?> <form method='post' action='<?php echo $url; ?> '> <div class="postbox-container" style="width:70%;"> <div id="poststuff"> <div class="postbox"> <h3>Add New User</h3> <table class='form-table'> <tr valign='top'> <th scope='row'>User ID</th> <td width='20%'><input maxlength='30' type='text' id='afg_new_user_id' name='afg_new_user_id'/><font size='3' color='red'>*</font></td> <td><font size='2'>Don't know your Flickr Usesr ID? Get it from <a href="http://idgettr.com/" target='blank'>here.</a></font></td> </tr> <tr valign='top'> <th scope='row'>User Name</th> <td><input maxlength='30' type='text' id='afg_new_user_name' name='afg_new_user_name' value="" /></td> <td><font size='2'>This is NOT your Flickr username. This is just for your reference to easily cofigure settings for the plugin. You can write any name in this field.</font></td> </tr> </table> </div> <?php ?> <input type="submit" name="submit" id="afg_add_users" class="button-primary" value="Add User" /> <br><br> <div class="postbox"> <h3>Saved Users</h3> <table class='form-table' style='margin-top:0'> <tr style='border:1px solid Gainsboro' valign='top'> <th cope='row'><input type='checkbox' name='delete_all_users' id='delete_all_users' onclick="CheckAllDeleteUsers()"/></th> <th scope='row'><strong>User ID</strong></th> <th scope='row'><strong>User Name</strong></th> </tr> <?php $users = get_option('afg_users'); foreach ($users as $uid => $uname) { if ($uid) { echo "<tr style='border:1px solid Gainsboro' valign='top'>"; echo "<td style='width:4%'><input type='checkbox' name='delete_user_{$uid}' id='delete_user_{$uid}' /></td>"; echo "<td style='width:12%'>{$uid}</td>"; echo "<th style='width:22%'>{$uname}</th>"; echo "</tr>"; } } ?> </table> </div> <input type="submit" name="submit" class="button" value="Delete Selected Users" /> </div></div> <div class="postbox-container" style="width: 29%;"> <?php //echo afg_donate_box(); ?> </div> </form> <?php }
function afg_twins_html_page() { global $afg_photo_size_map, $afg_on_off_map, $afg_descr_map, $afg_columns_map, $afg_bg_color_map, $afg_width_map, $pf, $afg_sort_order_map, $afg_slideshow_map, $wpdb; ?> <div class='wrap'> <h2><img src="<?php echo BASE_URL . '/images/logo_big.png'; ?> " align='center'/>Flickr Gallery Settings</h2> <?php $url_parts = parse_url($_SERVER['REQUEST_URI']); $url = (isset($url_parts['path']) ? $url_parts['path'] : '') . (isset($url_parts['query']) ? '?' . $url_parts['query'] : ''); ?> <form method='post' action='<?php echo $url; ?> '> <?php echo afg_generate_version_line(); ?> <div class="postbox-container" style="width:69%; margin-right:1%"> <div id="poststuff"> <div class="postbox" style='box-shadow:0 0 2px'> <?php //echo $_POST['nonce'] ."<br />\n"; //echo wp_create_nonce( 'ajax-afg-editimg-nonce-'. $_POST['twin']) ."<br />\n"; if ($_POST && !wp_verify_nonce(trim($_POST['editnonce']), 'ajax-afg-editimg-nonce-' . $_POST['twin'])) { die('Security check'); } if ($_POST && wp_verify_nonce(trim($_POST['editnonce']), 'ajax-afg-editimg-nonce-' . $_POST['twin'])) { $wpdb->show_errors(); $ret = $wpdb->update($wpdb->prefix . "flickrtwins", array('sport' => isset($_POST['sport']) ? $_POST['sport'] : '', 'age' => isset($_POST['age']) ? $_POST['age'] : '', 'gender' => isset($_POST['gender']) ? $_POST['gender'] : '', 'imagetitle' => isset($_POST['imagetitle']) ? $_POST['imagetitle'] : '', 'imagestory' => isset($_POST['imagestory']) ? $_POST['imagestory'] : '', 'published' => isset($_POST['published']) ? 1 : 0, 'photoid' => $_POST['twin']), array('photoid' => $_POST['twin']), array('%s', '%s', '%s', '%s', '%s', '%d'), array('%s')); if ($ret !== 1) { $ret = $wpdb->insert($wpdb->prefix . "flickrtwins", array('sport' => isset($_POST['sport']) ? $_POST['sport'] : '', 'age' => isset($_POST['age']) ? $_POST['age'] : '', 'gender' => isset($_POST['gender']) ? $_POST['gender'] : '', 'imagetitle' => isset($_POST['imagetitle']) ? $_POST['imagetitle'] : '', 'imagestory' => isset($_POST['imagestory']) ? $_POST['imagestory'] : '', 'published' => isset($_POST['published']) ? 1 : 0, 'photoid' => $_POST['twin'], 'photosecret' => $_POST['photosecret'], 'farm' => $_POST['farm'], 'server' => $_POST['server'], 'submittedtime' => time()), array('%s', '%s', '%s', '%s', '%s', '%d', '%s', '%s', '%s', '%s', '%d')); if ($ret === False) { echo '<h4>Insert failed</h4>'; } else { echo '<h4>Inserted</h4>'; } } else { echo '<h4>Updated</h4>'; } //exit( var_dump( $wpdb->last_query ) ); } if (!$_POST && $_GET && wp_verify_nonce($_REQUEST['nonce'], 'ajax-afg-twinimg-nonce-' . $_GET['twin'])) { ?> <h3>Twin image</h3> <?php $photoinfo = $pf->photos_getInfo($_REQUEST['twin']); $photo_url = "http://farm{$photoinfo['photo']['farm']}.static.flickr.com/{$photoinfo['photo']['server']}/{$photoinfo['photo']['id']}_{$photoinfo['photo']['secret']}_s.jpg"; echo '<img src="' . $photo_url . '"/>'; $twin = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . "flickrtwins WHERE photoid ='" . $photoinfo['photo']['id'] . "';"); //var_dump( $wpdb->last_query ); //print_R($twin); ?> <div class="form-item "> <label for="sport"> Sport <em class="error the-red" id="sport_error"></em> </label> <select name="sport" id="sport" class="form-input " /> <option value=""></option> <?php $results = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "flickrsports WHERE published = 1"); foreach ($results as $row) { ?> <option value="<?php echo $row->id; ?> " <?php echo $row->id == $twin->sport ? 'selected="selected"' : ''; ?> ><?php echo $row->sport; ?> </option> <?php } ?> </select> </div> <div class="form-item "> <label for="age"> Age <em class="error the-red" id="age_error"></em> </label> <select name="age" id="age" class="form-input " > <option value="1" <?php echo intval($twin->age) == 1 ? 'selected="selected"' : ''; ?> >0-3</option> <option value="2" <?php echo intval($twin->age) == 2 ? 'selected="selected"' : ''; ?> >4-7</option> <option value="3" <?php echo intval($twin->age) == 3 ? 'selected="selected"' : ''; ?> >8-12</option> <option value="4" <?php echo intval($twin->age) == 4 ? 'selected="selected"' : ''; ?> >13-15</option> <option value="5" <?php echo intval($twin->age) == 5 ? 'selected="selected"' : ''; ?> >16+</option> </select> </div> <div class="form-item "> <label for="gender"> Gender <em class="error the-red" id="gender_error"></em> </label> <select name="gender" id="gender" class="form-input " > <option value=""></option> <option value="m" <?php echo 'm' == $twin->gender ? 'selected="selected"' : ''; ?> >Male</option> <option value="f" <?php echo 'f' == $twin->gender ? 'selected="selected"' : ''; ?> >Female</option> <option value="n" <?php echo 'n' == $twin->gender ? 'selected="selected"' : ''; ?> >Not specified</option> </select> </div> <div class="form-item"> <label for="imagetitle"> The Title of your image <em class="error the-red" id="build_error"></em> </label> <input type="text" name="imagetitle" id="imagetitle" class="form-input" value="<?php echo stripslashes($twin->imagetitle); ?> " /> </div> <div class="form-item"> <label for="imagestory"> The story of your image <em class="error the-red" id="imagestory_error"></em> </label> <textarea name="imagestory" id="imagestory" class="form-input"><?php echo stripslashes($twin->imagestory); ?> </textarea> </div> <?php wp_nonce_field('ajax-afg-editimg-nonce-' . $photoinfo['photo']['id'], 'editnonce'); ?> <input type="hidden" name="twin" value="<?php echo $photoinfo['photo']['id']; ?> " /> <input type="hidden" name="photosecret" value="<?php echo $photoinfo['photo']['secret']; ?> " /> <input type="hidden" name="farm" value="<?php echo $photoinfo['photo']['farm']; ?> " /> <input type="hidden" name="server" value="<?php echo $photoinfo['photo']['server']; ?> " /> <div class="form-item "> <label for="published"> Published <em class="error the-red" id="published_error"></em> <input type="checkbox" name="published" id="published" class="form-input" value="1" <?php echo '1' == $twin->published ? 'checked="checked"' : ''; ?> /> </label> </div> <div class="form-item "> <button type="submit" value="save"> Save </button> </div> <?php } else { ?> <h3>Twin images</h3> <?php global $pf; $extras = 'url_l, description, date_upload, date_taken, owner_name'; if (trim(get_option('afg_twins_photoset')) != '') { $rsp_obj = $pf->photosets_getPhotos(get_option('afg_twins_photoset'), $extras, NULL, 500); if (!$rsp_obj) { echo afg_error(); } else { foreach ($rsp_obj['photoset']['photo'] as $photo) { $photo_url = "http://farm{$photo['farm']}.static.flickr.com/{$photo['server']}/{$photo['id']}_{$photo['secret']}_s.jpg"; $linkurl = $url . '&twin=' . $photo['id'] . '&nonce=' . wp_create_nonce('ajax-afg-twinimg-nonce-' . $photo['id']); echo '<a href="' . $linkurl . '"><img src="' . $photo_url . '"/></a>'; } } } } ?> </div> </div> </div> </form> <?php }
function afg_view_edit_sports() { ?> <div class='wrap'> <h2><img src="<?php echo BASE_URL . '/images/logo_big.png'; ?> " align='center'/>Sports | Flickr Gallery</h2> <?php global $wpdb; $results = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}flickrsports"); if (isset($_POST['submit']) && $_POST['submit'] == 'Submit') { foreach ($results as $row) { if (isset($_POST['delete_sport_' . $row->id]) && $_POST['delete_sport_' . $row->id] == 'on') { $wpdb->update($wpdb->prefix . "flickrsports", array('published' => $row->published == 1 ? 0 : 1), array('id' => $row->id), array('%d'), array('%d')); } } if (trim($_POST['sport_new']) != '') { $wpdb->insert($wpdb->prefix . "flickrsports", array('sport' => trim($_POST['sport_new']), 'published' => 1), array('%s', '%d')); } } ?> <?php echo afg_generate_version_line(); $url = $_SERVER['REQUEST_URI']; ?> <form method='post' action='<?php echo $url; ?> '> <div class="postbox-container" style="width:69%; margin-right:1%"> <div id="poststuff"> <div class="postbox" style='box-shadow:0 0 2px'> <h3>Sports</h3> <table class='form-table' style='margin-top:0'> <tr style='border:1px solid Gainsboro' valign='top'> <th scope='row'></th> <th scope='row'><strong>ID</strong></th> <th scope='row'><strong>Sport</strong></th> <th scope='row'><strong>Published</strong></th> </tr> <?php $results = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "flickrsports"); foreach ($results as $row) { ?> <tr style='border:1px solid Gainsboro' valign='top'> <td style='width:4%'><input type='checkbox' name='delete_sport_<?php echo $row->id; ?> ' id='delete_sport_<?php echo $row->id; ?> ' /></td> <td style='width:12%'><?php echo $row->id; ?> </td> <th style='width:22%'><?php echo $row->sport; ?> </th> <td style='width:4%'><?php echo $row->published == 1 ? 'X' : ''; ?> </td> </tr> <?php } ?> <tr style='border:1px solid Gainsboro' valign='top'> <td style='width:4%'></td> <td style='width:12%'></td> <th style='width:22%'><input type="text" name="sport_new" /></th> <td style='width:4%'></td> </tr> </table> </div></div> <input type="submit" name="submit" class="button" value="Submit" /> </div> <div class="postbox-container" style="width: 29%;"> <?php echo afg_usage_box('the Gallery Code'); //echo afg_donate_box(); //echo afg_share_box(); ?> </div> </form> <?php }
function afg_view_delete_galleries() { ?> <div class='wrap'> <h2><a href='http://www.ronakg.com/projects/awesome-flickr-gallery-wordpress-plugin/'><img src="<?php echo BASE_URL . '/images/logo_big.png'; ?> " align='center'/></a>Saved Galleries | Awesome Flickr Gallery</h2> <?php if (isset($_POST['submit']) && $_POST['submit'] == 'Delete Selected Galleries') { $galleries = get_option('afg_galleries'); foreach ($galleries as $id => $ginfo) { if ($id) { if (isset($_POST['delete_gallery_' . $id]) && $_POST['delete_gallery_' . $id] == 'on') { unset($galleries[$id]); } } } update_option('afg_galleries', $galleries); ?> <div class="updated"><p><strong><?php echo 'Galleries deleted successfully.'; ?> </strong></p></div> <?php } echo afg_generate_version_line(); $url = $_SERVER['REQUEST_URI']; ?> <form onsubmit="return verifySelectedGalleries()" method='post' action='<?php echo $url; ?> '> <div class="postbox-container" style="width:69%; margin-right:1%"> <div id="poststuff"> <div class="postbox" style='box-shadow:0 0 2px'> <h3>Saved Galleries</h3> <table class='form-table' style='margin-top:0'> <tr style='border:1px solid Gainsboro' valign='top'> <th cope='row'><input type='checkbox' name='delete_all_galleries' id='delete_all_galleries' onclick="CheckAllDeleteGalleries()"/></th> <th scope='row'><strong>ID</strong></th> <th scope='row'><strong>Name</strong></th> <th scope='row'><strong>Gallery Code</strong></th> <th scope='row'><strong>Description</strong></th> </tr> <?php $galleries = get_option('afg_galleries'); foreach ($galleries as $id => $ginfo) { echo "<tr style='border:1px solid Gainsboro' valign='top'>"; if ($id) { echo "<td style='width:4%'><input type='checkbox' name='delete_gallery_{$id}' id='delete_gallery_{$id}' /></td>"; } else { echo "<td style='width:4%'></td>"; } echo "<td style='width:12%'>{$id}</td>"; if ($id) { echo "<th style='width:22%'>\r\n <a href=\"{$_SERVER['PHP_SELF']}?page=afg_edit_galleries_page&gallery_id={$id}\" title='Edit this gallery'>\r\n {$ginfo['name']}</a></th>"; echo "<td style='width:22%; color:steelblue; font-size:110%;' onfocus='this.select()'>[AFG_gallery id='{$id}']</td>"; } else { echo "<th style='width:22%'>{$ginfo['name']}</th>"; echo "<td style='width:22%; color:steelblue; font-size:110%;' onfocus='this.select()'>[AFG_gallery]</td>"; } echo "<td>{$ginfo['gallery_descr']}</td>"; echo "</tr>"; } ?> </table> </div></div> <input type="submit" name="submit" class="button" value="Delete Selected Galleries" /> </div> <div class="postbox-container" style="width: 29%;"> <?php echo afg_usage_box('the Gallery Code'); echo afg_donate_box(); echo afg_share_box(); ?> </div> </form> <?php }
function afg_advanced_settings_page() { $url = $_SERVER['REQUEST_URI']; ?> <h2><a href='http://www.ronakg.com/projects/awesome-flickr-gallery-wordpress-plugin/'><img src="<?php echo BASE_URL . '/images/logo_big.png'; ?> " align='center'/></a>Advanced Settings | Awesome Flickr Gallery</h2> <?php if (isset($_POST['afg_advanced_save_changes']) && $_POST['afg_advanced_save_changes']) { update_option('afg_disable_slideshow', isset($_POST['afg_disable_slideshow']) ? $_POST['afg_disable_slideshow'] : ''); update_option('afg_custom_css', $_POST['afg_custom_css']); update_option('afg_cache_refresh_interval', $_POST['afg-cache-refresh-interval']); echo "<div class='updated'><p><strong>Settings updated successfully.</strong></p></div>"; } ?> <form method='post' action='<?php echo $url; ?> '> <div id='afg-wrap'> <?php global $afg_cache_refresh_interval_map; echo afg_generate_version_line(); ?> <div id="afg-main-box"> <h3>Advanced Settings</h3> <table class='widefat afg-settings-box'> <tr> <th class="afg-label"></th> <th class="afg-input"></th> <th class="afg-help-bubble"></th> </tr> <tr> <td>Cache Refresh Interval</td> <td><select name='afg-cache-refresh-interval' id='afg-cache-refresh-interval'> <?php echo afg_generate_options($afg_cache_refresh_interval_map, get_option('afg_cache_refresh_interval', '1d')); ?> </select></td> <td> <div class="afg-help">How frequently should cached galleries update? Select a value that relates to your photos upload frequency on Flickr. Default is set to 1 day.</div></td> </tr> </table> <h3>Custom CSS</h3> <div style="background-color:#FFFFE0; border-color:#E6DB55; maargin:5px 0 15px; border-radius:3px 3px 3px 3px; border-width: 1px; border-style: solid; padding: 8px 10px; line-height: 20px"> Check <a href='<?php echo BASE_URL . '/afg.css'; ?> ' target='_blank'>afg.css</a> to see existing classes and properties for gallery which you can redefine here. Note that there is no validation applied to CSS Code entered here, so make sure that you enter valid CSS. </div><br/> <textarea id='afg_custom_css' name='afg_custom_css'><?php echo get_option('afg_custom_css'); ?> </textarea> <script type="text/javascript">var myCodeMirror = CodeMirror.fromTextArea(document.getElementById('afg_custom_css'), { lineNumbers: true, indentUnit: 4, theme: "cobalt", matchBrackets: true} );</script> <input style='margin-top:15px' type="submit" name="afg_advanced_save_changes" id="afg_advanced_save_changes" class="button-primary" value="Save Changes" /> </div> <div id="afg-side-box"> <?php $message = "Settings on this page are global and hence apply to all your Galleries."; echo afg_box('Help', $message); echo afg_donate_box(); echo afg_share_box(); ?> </div> </div> </form> <?php }
function afg_view_delete_galleries() { ?> <div class='wrap'> <h2><a href='http://www.ronakg.com/projects/awesome-flickr-gallery-wordpress-plugin/'><img src="<?php echo BASE_URL . '/images/logo_big.png'; ?> " align='center'/></a>Saved Galleries | Awesome Flickr Gallery</h2> <?php if (isset($_POST['submit']) && $_POST['submit'] == 'Delete Selected Galleries') { $galleries = get_option('afg_galleries'); foreach ($galleries as $id => $ginfo) { if ($id) { if (isset($_POST['delete_gallery_' . $id]) && $_POST['delete_gallery_' . $id] == 'on') { unset($galleries[$id]); } } } update_option('afg_galleries', $galleries); ?> <div class="updated"><p><strong><?php echo 'Galleries deleted successfully.'; ?> </strong></p></div> <?php } echo afg_generate_version_line(); $url = $_SERVER['REQUEST_URI']; ?> <form onsubmit="return verifySelectedGalleries()" method='post' action='<?php echo $url; ?> '> <div id="afg-wrap"> <div id="afg-main-box"> <h3>Saved Galleries</h3> <table class='wp-list-table widefat fixed pages afg-settings-box'> <tr style="border:1px solid gray"> <th style='width:5%'><input type='checkbox' name='delete_all_galleries' id='delete_all_galleries' onclick="CheckAllDeleteGalleries()"/></th> <th style='width:12%'><strong>Gallery ID</strong></th> <th style='width:20%'><strong>Gallery Name</strong></th> <th style='width:20%'><strong>Gallery Code</strong></th> <th style='width:43%'><strong>Description</strong></th> </tr> <?php $row_count = 0; $galleries = get_option('afg_galleries'); foreach ($galleries as $id => $ginfo) { if ($row_count % 2 == 0) { echo "<tr class='afg-saved-alternate'>"; } else { echo "<tr>"; } $row_count++; if ($id) { echo "<td><input type='checkbox' name='delete_gallery_{$id}' id='delete_gallery_{$id}' /></td>"; } else { echo "<td></td>"; } echo "<td>{$id}</td>"; if ($id) { echo "<td>\n <a href=\"{$_SERVER['PHP_SELF']}?page=afg_edit_galleries_page&gallery_id={$id}\" title='Edit this gallery'>\n {$ginfo['name']}</a></td>"; echo "<td style='color:steelblue;' onfocus='this.select()'>[AFG_gallery id='{$id}']</td>"; } else { echo "<td>{$ginfo['name']}</td>"; echo "<td style='color:steelblue;' onfocus='this.select()'>[AFG_gallery]</td>"; } echo "<td>{$ginfo['gallery_descr']}</td>"; echo "</tr>"; } ?> </table> <input style='margin-top:15px' type="submit" name="submit" class="button" value="Delete Selected Galleries" /> </div> <div id="afg-side-box"> <?php echo afg_usage_box('the Gallery Code'); echo afg_donate_box(); echo afg_share_box(); ?> </div> </div> </form> <?php }
function afg_add_gallery() { global $afg_photo_size_map, $afg_on_off_map, $afg_descr_map, $afg_columns_map, $afg_bg_color_map, $afg_photo_source_map, $pf; $user_id = get_option('afg_user_id'); $photosets_map = array(); $groups_map = array(); $galleries_map = array(); afg_get_sets_groups_galleries($photosets_map, $groups_map, $galleries_map, $user_id); ?> <div class='wrap'> <h2><a href='http://www.ronakg.com/projects/awesome-flickr-gallery-wordpress-plugin/'><img src="<?php echo BASE_URL . '/images/logo_big.png'; ?> " align='center'/></a>Add Gallery | Awesome Flickr Gallery</h2> <?php if ($_POST && $_POST['afg_add_gallery_name']) { if (isset($_POST['afg_per_page_check']) && $_POST['afg_per_page_check']) { $_POST['afg_per_page'] = ''; } else { if (!(ctype_digit($_POST['afg_per_page']) && (int) $_POST['afg_per_page'])) { $_POST['afg_per_page'] = ''; echo "<div class='updated'><p><strong>You entered invalid value for Per Page option. It has been set to Default.</strong></p></div>"; } } $gallery = array('name' => $_POST['afg_add_gallery_name'], 'gallery_descr' => $_POST['afg_add_gallery_descr'], 'photo_source' => $_POST['afg_photo_source_type'], 'per_page' => afg_filter($_POST['afg_per_page']), 'sort_order' => afg_filter($_POST['afg_sort_order']), 'photo_size' => afg_filter($_POST['afg_photo_size']), 'captions' => afg_filter($_POST['afg_captions']), 'descr' => afg_filter($_POST['afg_descr']), 'columns' => afg_filter($_POST['afg_columns']), 'slideshow_option' => afg_filter($_POST['afg_slideshow_option']), 'credit_note' => afg_filter($_POST['afg_credit_note']), 'bg_color' => afg_filter($_POST['afg_bg_color']), 'width' => afg_filter($_POST['afg_width']), 'pagination' => afg_filter($_POST['afg_pagination'])); if ($_POST['afg_photo_source_type'] == 'photoset') { $gallery['photoset_id'] = $_POST['afg_photosets_box']; } else { if ($_POST['afg_photo_source_type'] == 'gallery') { $gallery['gallery_id'] = $_POST['afg_galleries_box']; } else { if ($_POST['afg_photo_source_type'] == 'group') { $gallery['group_id'] = $_POST['afg_groups_box']; } else { if ($_POST['afg_photo_source_type'] == 'tags') { $gallery['tags'] = $_POST['afg_tags']; } } } } if ($gallery['photo_size'] == 'custom') { if (ctype_digit($_POST['afg_custom_size']) && (int) $_POST['afg_custom_size'] >= 50 && (int) $_POST['afg_custom_size'] <= 500) { $gallery['custom_size'] = $_POST['afg_custom_size']; if (!is_dir(dirname(__FILE__) . "/cache")) { if (!wp_mkdir_p(dirname(__FILE__) . "/cache")) { echo "<div class='updated'><p>Could not create directory - '" . dirname(__FILE__) . "/cache'. This is required for custom size photos to be displayed. Manually create this directory and set permissions for this directory as 777.</p></div>"; } } } else { $gallery['custom_size'] = 100; echo "<div class='updated'><p><strong>You entered invalid value for Custom Width option. It has been set to 100.</strong></p></div>"; } $gallery['custom_size_square'] = isset($_POST['afg_custom_size_square']) ? $_POST['afg_custom_size_square'] : 'false'; } $galleries = get_option('afg_galleries'); $galleries[] = $gallery; update_option('afg_galleries', $galleries); end($galleries); $id = key($galleries); ?> <div class="updated"><p><strong> <?php echo "Gallery \"{$_POST['afg_add_gallery_name']}\" created successfully. Shortcode for this gallery is </strong>[AFG_gallery id='{$id}']"; ?> </p></div> <?php } $url = $_SERVER['REQUEST_URI']; ?> <form method='post' action='<?php echo $url; ?> '> <div id="afg-wrap"> <?php echo afg_generate_version_line(); ?> <div id="afg-main-box"> <h3>Gallery Parameters</h3> <table class='widefat afg-settings-box'> <tr> <th class="afg-label"></th> <th class="afg-input"></th> <th class="afg-help-bubble"></th> </tr> <tr> <td>Gallery Name</td> <td><input class='afg-input' maxlength='30' type='text' id='afg_add_gallery_name' name='afg_add_gallery_name' onblur='verifyBlank()' value='' />*</td> </tr> <tr> <td>Gallery Description</td> <td><input class='afg-input' maxlength='100' type='text' id='afg_add_gallery_descr' name='afg_add_gallery_descr' value="" /></td> </tr> </table> <?php echo afg_generate_flickr_settings_table($photosets_map, $galleries_map, $groups_map); echo afg_generate_gallery_settings_table(); ?> <br /> <input type="submit" disabled='true' id="afg_save_changes" class="button-primary" value="Add Gallery" /> </div> <div id='afg-side-box'> <?php $message = "<b>Gallery Description</b> - Provide a meaningful description of" . " your gallery for you to recognize it easily.<br /><br />" . " <b>Gallery Source</b> - Where do you want to fetch your photos from?" . " Your Flickr Photostream, a Photoset, a Gallery or a Group?<br /><br />" . " <b>What is <i>Default</i>?</b> - When you select <i>" . " Default</i> for a setting, it will be inherited from <a href=\"" . $_SERVER['PHP_SELF'] . "?page=afg_plugin_page\"><i>Default" . " Settings</i></a>. The setting here is stored as reference to the" . " setting on Default Settings page, so if you change the <i>Default" . " Settings</i>, the setting for this specific gallery will also change."; echo afg_box('Help', $message); echo afg_donate_box(); echo afg_share_box(); ?> </div> </form> <?php }