Changeset 29890
- Timestamp:
- 01/25/08 01:05:40 (6 months ago)
- Files:
-
- ad-minister/trunk/ad-minister-content.php (modified) (3 diffs)
- ad-minister/trunk/ad-minister-create.php (modified) (5 diffs)
- ad-minister/trunk/ad-minister-functions.php (modified) (19 diffs)
- ad-minister/trunk/ad-minister-help.php (modified) (1 diff)
- ad-minister/trunk/ad-minister-js.php (modified) (17 diffs)
- ad-minister/trunk/ad-minister-positions.php (modified) (2 diffs)
- ad-minister/trunk/ad-minister-settings.php (modified) (2 diffs)
- ad-minister/trunk/ad-minister.css (modified) (2 diffs)
- ad-minister/trunk/ad-minister.php (modified) (2 diffs)
- ad-minister/trunk/ad-minister.po (modified) (9 diffs)
- ad-minister/trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
ad-minister/trunk/ad-minister-content.php
r29627 r29890 1 <?php 2 // $ad_post_id = get_option('p2m_ad_post_id'); 3 // $url = get_option('siteurl') . '/wp-admin/edit.php?page=p2m-ad_manager/p2m-ad-manager.php'; 4 ?> 5 <form method="post" action="options.php" name="post"> 1 <!-- form method="post" action="options.php" name="post" --> 6 2 7 <h3 style="font-size: 20px;"></h3> 3 <h3 style="font-size: 20px;"><?php _e('Content', 'ad-minister'); ?></h3> 4 5 <p><?php _e('Click Show/Hide to see the content.', 'ad-minister'); ?></p> 8 6 9 7 <div id="ads"> … … 15 13 $contents = get_post_meta(get_option('administer_post_id'), 'administer_content', true); 16 14 $positions = get_post_meta(get_option('administer_post_id'), 'administer_positions', true); 15 16 17 echo '<pre>'; 18 // print_r($contents); 19 echo '</pre>'; 17 20 18 21 // Identify orphans … … 76 79 <?php 77 80 foreach($position as $ad) { 78 administer_content_template($ad );81 administer_content_template($ad, $index++); 79 82 } 80 83 echo '</div>'; ad-minister/trunk/ad-minister-create.php
r29627 r29890 42 42 echo '<div id="message" class="updated fade"><p><strong>' . __('There is no content! Do make some.', 'ad-minister') . '</strong></p></div>'; 43 43 44 45 44 ?> 46 45 47 <form method="POST" action=" <?php echo get_option('siteurl') ?>/wp-admin/edit.php?page=ad-minister/ad-minister.php&tab=upload">46 <form method="POST" action="edit.php?page=ad-minister&tab=upload"> 48 47 <?php // onSubmit="return p2m_save_made_ad();" ?> 49 <h3 class="large"> <?php _e('Create content', 'ad-minister'); ?>:</h3>48 <h3 class="large">Create content:</h3> 50 49 51 50 <div id="class"> … … 53 52 </div> 54 53 54 <table class="create"> 55 <tr class="title"> 56 <td class="cleft"> 57 <label class="create" for="title"><?php _e('Title', 'ad-minister'); ?>: </label> 58 </td> 59 <td> 60 <input class="create" name="title" id='title' type="text"> 61 </td> 62 </tr> 55 63 64 <tr class="param"> 65 <td> 66 <label class="create" for="content"><?php _e('Html code', 'ad-minister'); ?>:</label> 67 </td> 68 <td> 69 <fieldset id="postdiv"> 70 <div id="quicktags"> 71 <script type='text/javascript' src='<?php echo get_option('siteurl') ?>/wp-includes/js/quicktags.js'></script> 72 </div> 73 <div><textarea class='mceEditor' rows='10' cols='40' name='content' id='content'></textarea></div> 74 <script type="text/javascript"> 75 //<!-- 76 edCanvas = document.getElementById('content'); 77 //--> 78 </script> 79 (<?php _e('may include JavaScript, but will not execute in the preview. Add files using the file browser below.'); ?>) 80 </fieldset> 81 </td> 82 </tr> 83 84 <tr class="param"> 85 <td> 86 <label class="create" for="scheduele"><?php _e('Scheduele', 'ad-minister'); ?>: </label> 87 </td> 88 <td> 89 <input class="create" name="scheduele" type="text" id="scheduele" /><br /> 90 (<?php _e('Optional', 'ad-minister'); ?>, E.g. 2007-12-01:2008-01-01) 91 </td> 92 </tr> 93 94 <tr class="param"> 95 <td> 96 <label class="create" for="weight"><?php _e('Weight', 'ad-minister'); ?>: </label> 97 </td> 98 <td> 99 <input class="create" name="weight" type="text" id="weight" /><br /> 100 (<?php _e('Optional, should be a number', 'ad-minister'); ?>) 101 </td> 102 </tr> 103 104 <tr class="param"> 105 <td> 106 <label class="create" for="ad_position_edit_"><?php _e('Position', 'ad-minister'); ?></label> 107 </td> 108 <td> 109 <?php echo administer_position_select(); ?> 110 </td> 111 </tr> 112 113 <tr class="param"> 114 <td> 115 <label class="create" for="show"><?php _e('Make visible?', 'ad-minister'); ?></label> 116 </td> 117 <td> 118 <label><input name="show" type="checkbox" id="show" checked="checked" /> (<?php _e('tick for yes', 'ad-minister'); ?>)</label> 119 </td> 120 </tr> 121 122 <tr class="param"> 123 <td> 124 <label class="create" for="wrap"><?php _e('Use wrapper?', 'ad-minister'); ?></label> 125 </td> 126 <td> 127 <label><input name="wrap" type="checkbox" id="wrap" checked="checked" /> (<?php _e('tick for yes', 'ad-minister'); ?>)</label> </td> 128 </tr> 129 <tr> 130 <td></td> 131 <td> 132 <input type="hidden" name="page" value="ad-minister/ad-minister.php"> 133 <input type="button" value="<?php _e('Preview', 'ad-minister'); ?>" onclick="p2m_preview_ad(); return false;"> 134 <input type="submit" value="<?php _e('Save', 'ad-minister'); ?>"> 135 </td> 136 <tr> 137 </table> 138 139 <?php /* 56 140 <div class="title2"> 57 141 <strong class="title2"><?php _e('Title', 'ad-minister'); ?>: </strong> … … 74 158 //--> 75 159 </script> 76 (<?php _e('may include JavaScript, but will not execute in the preview. Add files using the file browser below.' , 'ad-minister'); ?>)160 (<?php _e('may include JavaScript, but will not execute in the preview. Add files using the file browser below.'); ?>) 77 161 </fieldset> 78 162 </div> 79 163 80 <p><strong class="add_option"><label for="ad_scheduele_edit_"><?php _e('Schedu le', 'ad-minister'); ?>: </label></strong><div class="ad_field2"><input name="scheduele" style="width: 99%;" type="text" id="ad_scheduele_edit_" /></div><div class="ad_field2">(<?php _e('Optional', 'ad-minister'); ?>, E.g. 2007-12-01:2008-01-01)</div></p>164 <p><strong class="add_option"><label for="ad_scheduele_edit_"><?php _e('Scheduele', 'ad-minister'); ?>: </label></strong><div class="ad_field2"><input name="scheduele" style="width: 99%;" type="text" id="ad_scheduele_edit_" /></div><div class="ad_field2">(<?php _e('Optional', 'ad-minister'); ?>, E.g. 2007-12-01:2008-01-01)</div></p> 81 165 <p><strong class="add_option"><label for="ad_quota_edit_"><?php _e('Weight', 'ad-minister'); ?>: </label></strong><div class="ad_field2"><input name="weight" class="add_option" type="text" id="ad_quota_edit_" /> (<?php _e('Optional', 'ad-minister'); ?>) </div></p> 82 166 <p><strong class="add_option"><?php _e('Position', 'ad-minister'); ?>: </strong><div class="ad_field2"><?php echo administer_position_select(); ?></div></p> 83 167 <p><strong class="add_option"><label for="ad_show_edit_"><?php _e('Make visible?', 'ad-minister'); ?></label></strong> <label><input name="show" type="checkbox" id="ad_show_edit_" checked="checked" /> (<?php _e('tick for yes', 'ad-minister'); ?>)</label></p> 84 <p><strong class="add_option"><label for="ad_wrap_edit_"><?php _e('Use wrapper?', 'ad-minister'); ?></label></strong> <label><input name="wrap" type="checkbox" id="ad_ show_edit_" checked="checked" /> (<?php _e('tick for yes', 'ad-minister'); ?>)</label></p>168 <p><strong class="add_option"><label for="ad_wrap_edit_"><?php _e('Use wrapper?', 'ad-minister'); ?></label></strong> <label><input name="wrap" type="checkbox" id="ad_wrap_edit_" checked="checked" /> (<?php _e('tick for yes', 'ad-minister'); ?>)</label></p> 85 169 86 170 <div class="add_buttons" id="buttons"> … … 91 175 </div> 92 176 </div> 177 */ 178 ?> 93 179 94 180 </form> … … 100 186 <p><?php _e("Click on the thumbnail of the file to get the option to insert it. Press 'Send to editor' to insert image/file.", 'ad-minister'); ?></p> 101 187 102 <iframe id="uploading" name="uploading" frameborder="0" src="upload.php?style=inline&tab=browse&post_id=<?php echo get_option('administer_post_id'); ?>&_wpnonce=4b899edbfd">This feature requires iframe support.</iframe> 188 <iframe id="uploading" name="uploading" frameborder="0" src="upload.php?style=inline&tab=browse&post_id=<?php echo get_option('administer_post_id'); ?>&_wpnonce=4b899edbfd">This feature requires iframe support.</iframe> ad-minister/trunk/ad-minister-functions.php
r29627 r29890 29 29 <script type='text/javascript' src="<?php echo get_option('siteurl') . '/' . WPINC; ?>/js/tw-sack.js?ver=1.6.1"></script> 30 30 <script type='text/javascript' src="<?php echo get_option('siteurl') . '/' . WPINC; ?>/js/prototype.js?ver=1.5.1.1"></script> 31 <script type='text/javascript' src="<?php echo get_option('siteurl') . '/' . WPINC; ?>/js/jquery/jquery.js"></script> 31 32 <script type='text/javascript' src="<?php echo get_option('siteurl') . '/' . WPINC; ?>/js/quicktags.js"></script> 32 33 … … 34 35 <h2> 35 36 <div style="float: right; font-size: 18px; padding-right: 10px;"> 36 <a href="http://labs.dagensskiva.com/ " style="border: 0px;">37 <a href="http://labs.dagensskiva.com/plugins/ad-minister/" style="border: 0px;" target="_blank"> 37 38 <img style="height: 50px" src="<?php echo get_option('siteurl') . '/' . PLUGINDIR . '/' . dirname(plugin_basename (__FILE__)); ?>/img/henrik.png"> 38 39 </a> … … 41 42 </h2> 42 43 <ul id="submenu"> 43 <?php $url = get_option('siteurl') . '/wp-admin/edit.php?page=ad-minister/ad-minister.php'; ?>44 <li><a <?php if ($tab == 'content') echo 'class="current"'; ?> href="<?php echo $url; ?>&tab=content"><?php _e('Content' , 'ad-minister'); ?></a></li>45 <li><a <?php if ($tab == 'upload') echo 'class="current"'; ?> href="<?php echo $url; ?>&tab=upload"><?php _e('Create content' , 'ad-minister'); ?></a></li>46 <li><a <?php if ($tab == 'positions') echo 'class="current"'; ?>href="<?php echo $url; ?>&tab=positions"><?php _e('Positions ', 'ad-minister'); ?></a></li>47 <li><a <?php if ($tab == 'settings') echo 'class="current"'; ?> href="<?php echo $url; ?>&tab=settings"><?php _e('Settings' , 'ad-minister'); ?></a></li>48 <li><a <?php if ($tab == 'help') echo 'class="current"'; ?> href="<?php echo $url; ?>&tab=help"><?php _e('Help' , 'ad-minister'); ?>!</a></li>44 <?php $url = 'edit.php?page=ad-minister'; ?> 45 <li><a <?php if ($tab == 'content') echo 'class="current"'; ?> href="<?php echo $url; ?>&tab=content"><?php _e('Content'); ?></a></li> 46 <li><a <?php if ($tab == 'upload') echo 'class="current"'; ?> href="<?php echo $url; ?>&tab=upload"><?php _e('Create content'); ?></a></li> 47 <li><a <?php if ($tab == 'positions') echo 'class="current"'; ?>href="<?php echo $url; ?>&tab=positions"><?php _e('Positions/Widgets'); ?></a></li> 48 <li><a <?php if ($tab == 'settings') echo 'class="current"'; ?> href="<?php echo $url; ?>&tab=settings"><?php _e('Settings'); ?></a></li> 49 <li><a <?php if ($tab == 'help') echo 'class="current"'; ?> href="<?php echo $url; ?>&tab=help"><?php _e('Help'); ?>!</a></li> 49 50 </ul> 50 51 … … 70 71 // Get the position name 71 72 $position = stripslashes($content['position']); //p2m_meta('ad_position_' . $nbr); 72 // $position = $p2m_meta($position_key);73 73 if (!$position) $position = 'key_not_set'; 74 74 75 75 $show_checked = ($content['show'] == 'true') ? ' checked="checked"' : ''; 76 76 $title_edit = stripslashes($content['title']); 77 $title_show = ($title_edit) ? $title_edit : __('Title not set', 'ad-minister');77 $title_show = ($title_edit) ? $title_edit : 'Title not set'; 78 78 // Handle Weight, handled internally as quota. 79 // $edit_quota = $content['quota']; //p2m_meta('ad_quota_' . $nbr); 80 $weight = ($content['weight']) ? $content['weight'] : __('Automatic', 'ad-minister'); 79 $weight = ($content['weight']) ? $content['weight'] : 'Automatic'; 81 80 82 81 $scheduele = $content['scheduele']; //p2m_meta('ad_scheduele_' . $nbr); 83 // $scheduele_parsed = administer_parse_scheduele($scheduele); 84 // $scheduele = str_replace(':', ' to ', $content['scheduele']); 85 $scheduele_div = ($scheduele = str_replace(':', ' to ', $content['scheduele'])) ? '| <strong>' . __('Schedule', 'ad-minister') . ': </strong>' . $scheduele . '': ''; 82 $scheduele_div = ($scheduele = str_replace(':', ' to ', $content['scheduele'])) ? '| <strong>Scheduele: </strong>' . $scheduele . '': ''; 86 83 $wrap_checked = ($content['wrap'] == 'true') ? ' checked="checked"' : ''; 87 84 $code = stripslashes($content['code']); … … 98 95 99 96 <div style="float: right; margin-right: 10px;"> 100 <a href="#" onclick="p2m_edit_ad(%nbr%); return false;"> ' . __('Edit', 'ad-minister') . '</a> | <a href="#" onclick="p2m_delete_ad(%nbr%); return false;">' . __('Delete', 'ad-minister') . '</a>97 <a href="#" onclick="p2m_edit_ad(%nbr%); return false;">Edit</a> | <a href="#" onclick="p2m_delete_ad(%nbr%); return false;">Delete</a> 101 98 </div> 102 99 … … 105 102 <div style="background: #99ee99; padding: 10px;"> 106 103 <div> 107 <input id="ad_show_%nbr%" type="checkbox" onclick="p2m_toggle_show(%nbr%);" ' . $show_checked . ' > <strong><label for="ad_show_%nbr%">' . __('Visible?', 'ad-minister') . '</label></strong> | <strong>' . __('Weight', 'ad-minister') . ':</strong> <span id="ad_quota_view_%nbr%">' . $weight . '</span>104 <input id="ad_show_%nbr%" type="checkbox" onclick="p2m_toggle_show(%nbr%);" ' . $show_checked . ' /> <strong><label for="ad_show_%nbr%">Visible?</label></strong> | <strong>Weight:</strong> <span id="ad_quota_view_%nbr%">' . $weight . '</span> 108 105 109 106 <span id="ad_scheduele_view_%nbr%">' . $scheduele_div . '</span> … … 119 116 120 117 <div style="float: right; margin-right: 10px;"> 121 <a href="#" onClick="p2m_save_ad(%nbr%); return false;"> ' . __('Save', 'ad-minister') . '</a>118 <a href="#" onClick="p2m_save_ad(%nbr%); return false;">Save</a> 122 119 </div> 123 120 … … 128 125 129 126 <label class="ad_field" for="ad_scheduele_edit_%nbr%">Scheduele: </label> 130 <div class="ad_field"><input class="ad_field" type="text" id="ad_scheduele_edit_%nbr%" name="ad_scheduele_edit_%nbr%" value="' . $content['scheduele'] . '"> ( ' . __('Optional', 'ad-minister') . ')</div>131 <label class="ad_field" for="ad_quota_edit_%nbr%"> ' . __('Weight', 'ad-minister') . ': </label>132 <div class="ad_field"><input class="ad_field_small" class="ad_field" type="text" id="ad_quota_edit_%nbr%" name="ad_quota_edit_%nbr%" value="' . $content['weight'] . '"> ( ' . __('Optional, should be a number', 'ad-minister') . ') </div>133 <label class="ad_field"> ' . __('Position', 'ad-minister') . ': </label>127 <div class="ad_field"><input class="ad_field" type="text" id="ad_scheduele_edit_%nbr%" name="ad_scheduele_edit_%nbr%" value="' . $content['scheduele'] . '"> (Optional)</div> 128 <label class="ad_field" for="ad_quota_edit_%nbr%">Weight: </label> 129 <div class="ad_field"><input class="ad_field_small" class="ad_field" type="text" id="ad_quota_edit_%nbr%" name="ad_quota_edit_%nbr%" value="' . $content['weight'] . '"> (Optional, should be a number) </div> 130 <label class="ad_field">Position key: </label> 134 131 <div>' . administer_position_select($nbr, $content['position']) . '</div> 135 132 <label for="ad_wrap_edit_%nbr%" class="ad_field">Use wrapper? </label> … … 172 169 <td> 173 170 %edit_link% 174 <a href="#" onclick="p2m_delete_position(\'%nbr%\'); return false;"> ' . __('Remove', 'ad-minister') . '</a>171 <a href="#" onclick="p2m_delete_position(\'%nbr%\'); return false;">Remove</a> 175 172 </td> 176 173 <td><img id="aj_%nbr%" class="notifier" src="%url%/img/rotating_arrow.gif" style="display: none;"></td> … … 194 191 '; 195 192 // Inject template values 196 $edit_link = ($position['type'] == 'widget') ? '<a href="#" onclick="p2m_edit_position(\'%nbr%\'); return false;">' . __('Edit', 'ad-minister') . '</a> |' : '';193 $edit_link = ($position['type'] != 'template') ? '<a href="#" onclick="p2m_edit_position(\'%nbr%\'); return false;">Edit</a> |' : ''; 197 194 $html = str_replace('%edit_link%', $edit_link, $html); 198 195 $html = str_replace('%nbr%', $nbr, $html); … … 225 222 $got_selected = true; 226 223 } else $selected = ''; 227 $html .= '<option value="' . $positions[$key]['position'] . '"' . $selected .'>' . $positions[$key]['position'] . '</option>'; 224 $description = ($positions[$key]['description']) ? ' (' . $positions[$key]['description'] . ')' : ''; 225 $html .= '<option value="' . $positions[$key]['position'] . '"' . $selected .'>' . $positions[$key]['position'] . $description . '</option>'; 228 226 } 229 227 … … 386 384 $parts = explode(':', ltrim(rtrim($time))); 387 385 if (count($parts) == 2) { 388 $start = strtotime($parts[0]); 389 $end = strtotime($parts[1]); 386 // Make the dates inclusive 387 $start = strtotime($parts[0] . ' 00:00:00'); 388 $end = strtotime($parts[1] . ' 23:59:59'); 390 389 } 391 390 $now = time(); … … 419 418 $li_ends .= '<li>'; 420 419 $li_ends .= '<a href="' . $url . '&cshow=' . urlencode($con['position']) . '">' . $con['title'] . '</a>'; 421 $li_ends .= ' expires in' . round($age['end'], 1) . ' days.';420 $li_ends .= ' ' . __('expires in', 'ad-minister') . ' ' . round($age['end'], 1) . ' days.'; 422 421 $li_ends .= '</li>'; 423 422 } … … 425 424 $li_starts .= '<li>'; 426 425 $li_starts .= '<a href="' . $url . '&cshow=' . urlencode($con['position']) . '">' . $con['title'] . '</a>'; 427 $li_starts .= ' starts in' . round($age['start'], 1) . ' days.';426 $li_starts .= ' ' . __('starts in', 'ad-minister') . ' ' . round($age['start'], 1) . ' days.'; 428 427 $li_starts .= '</li>'; 429 428 } … … 431 430 } 432 431 433 if ($li_starts || $li_ends) echo '<h3><a href=" ' . $url . '">Ad-minister</a></h3>'; 434 if ($li_starts) { 435 echo '<p>The following content is becomng active in the next ' . $period . ' days.</p>'; 436 echo "<ul>${li_starts}</ul>"; 437 } 438 if ($li_ends) { 439 echo '<p>The following content expires in the next ' . $period . ' days.</p>'; 440 echo "<ul>${li_ends}</ul>"; 441 } 442 if ($li_starts && !li_ends) echo 'No upcoming activity.'; 432 // if ($li_starts || $li_ends) 433 printf('<h3>Ad-minister <a href="%s" title="'. __('Go to', 'ad-minister') . ' Ad-minister">»</a></h3>', $url); 434 if ($li_starts) 435 printf('<p>' . __('The following content is becomng active in the next %s days', 'ad-minister') . '</p><ul>%s</ul>', $period, $li_starts); 436 437 if ($li_ends) 438 printf('<p>' . __('The following content expires in the next %s days', 'ad-minister') . '</p><ul>%s</ul>', $period, $li_ends); 439 440 if ($li_starts && !li_ends) _e('No upcoming activity.', 'ad-minister'); 443 441 } 444 442 … … 449 447 function administer_translate(){ 450 448 // Load a language 451 load_plugin_textdomain(' ad-minister', PLUGINDIR . '/' . dirname(plugin_basename (__FILE__)) );449 load_plugin_textdomain('p2m-ad-manager', PLUGINDIR . '/' . dirname(plugin_basename (__FILE__)) ); 452 450 } 453 451 … … 597 595 if ($ad['position'] != $pos) continue; 598 596 597 // Is the option to show the content ticked. 598 if ($ad['show'] == 'false') continue; 599 599 600 // Is the content schedueled to show? 600 601 $valid = false; 601 602 602 $ages = adminiseter_content_age($ad['scheduele']); 603 604 603 foreach ($ages as $age) { 605 606 604 // No scheduele, so content always valid 607 605 if (!$age['start'] && !$age['end']) $valid = true; … … 609 607 if ($age['start'] < 0 && $age['end'] > 0) $valid = true; 610 608 } 611 612 // Is the option to show the content ticked. 613 if ($ad['show'] == 'true') $valid = true; 614 609 615 610 // Sum the weights if the content is valid 616 611 if ($valid) { … … 623 618 } 624 619 } 620 621 // Make sure we have some valid content 622 if (count($valids) == 0) return 0; 625 623 626 624 // Get a pseudo random number ad-minister/trunk/ad-minister-help.php
r29627 r29890 23 23 <div style='padding: 20px;'> 24 24 25 For more information on how this plugin works, go to <a href="http://labs.dagensskiva.com/plugins/ad-minister/">http://labs.dagensskiva.com/plugins/ad-minister/</a>. 25 <p>For more information on how this plugin works, go to <a href="http://labs.dagensskiva.com/plugins/ad-minister/">http://labs.dagensskiva.com/plugins/ad-minister/</a>.</p> 26 27 <p>Please report bugs to <a href="mailto:henrik@dagensskiva.com">henrik@dagensskiva.com</a>.</p> 26 28 27 29 <p>This plugin is geared towards the generation of revenue for websites by enabling the ease of hadling advertising. It is completely free, but if you feel that you've made enough money to contribute to this project, then please do. Your contibution will enable the future development of this plugin.</p> ad-minister/trunk/ad-minister-js.php
r29627 r29890 4 4 */ 5 5 function p2m_edit_position(nbr) { 6 $('position_view_' + nbr).toggle();7 $('position_edit_' + nbr).toggle();6 jQuery('#position_view_' + nbr).toggle(); 7 jQuery('#position_edit_' + nbr).toggle(); 8 8 } 9 9 /* … … 14 14 // No duplicate keys please 15 15 if (p2m_does_position_key_exist(nbr)) { 16 alert('The Position Key "'+ $('position_key_edit_' + nbr).value+ '" already extits. ');16 alert('The Position Key "'+ jQuery('#position_key_edit_' + nbr).val() + '" already extits. '); 17 17 return false; 18 18 } 19 19 20 20 // Check for empty key names 21 if (! $('position_key_edit_' + nbr).value) {21 if (!jQuery('#position_key_edit_' + nbr).val()) { 22 22 alert("<?php _e("The Position Key can not be empty!"); ?>"); 23 23 return false; … … 26 26 // Set up the data to save 27 27 var send = new Array(); 28 send['position'] = $('position_key_edit_' + nbr).value;29 send['position_old'] = $('position_key_' + nbr).innerHTML;30 send['description'] = $('position_desc_edit_' + nbr).value;31 send['before'] = $('position_before_edit_' + nbr).value;32 send['after'] = $('position_after_edit_' + nbr).value;28 send['position'] = jQuery('#position_key_edit_' + nbr).val(); 29 send['position_old'] = jQuery('#position_key_' + nbr).text(); 30 send['description'] = jQuery('#position_desc_edit_' + nbr).val(); 31 send['before'] = jQuery('#position_before_edit_' + nbr).val(); 32 send['after'] = jQuery('#position_after_edit_' + nbr).val(); 33 33 send['type'] = 'widget'; 34 34 35 p2m_send_ajax('save_position', send, ' aj_' + nbr);35 p2m_send_ajax('save_position', send, '#aj_' + nbr); 36 36 37 37 var params = new Array('key', 'desc', 'before', 'after'); 38 38 //for (var param in params) { 39 39 for (var i=0; i < params.length; i++) { 40 $('position_' + params[i] + '_' + nbr).innerHTML = $('position_' + params[i] + '_edit_' + nbr).value.replace('<', '<').replace('>', '>'); //.replace('<', '<').replace('>', '>');40 jQuery('#position_' + params[i] + '_' + nbr).html(jQuery('#position_' + params[i] + '_edit_' + nbr).val().replace('<', '<').replace('>', '>')); //.replace('<', '<').replace('>', '>'); 41 41 } 42 42 … … 49 49 if (confirm("<?php _e('Are you sure you want to remove the position', 'ad-minister'); ?>'" + $('position_key_' + nbr).innerHTML + "'? \n\n<?php _e('Any content attached to this position may be orphaned!', 'ad-minister'); ?>")) { 50 50 var send = new Array(); 51 send['position'] = $('position_key_edit_' + nbr).value;51 send['position'] = jQuery('#position_key_edit_' + nbr).val(); 52 52 p2m_send_ajax('delete_position', send, ''); 53 $('position_view_' + nbr).remove();54 $('position_edit_' + nbr).remove();53 jQuery('#position_view_' + nbr).remove(); 54 jQuery('#position_edit_' + nbr).remove(); 55 55 } 56 56 } … … 60 60 function p2m_add_position () { 61 61 var html = '<?php echo addslashes(str_replace("\n", "", str_replace("\r", "", administer_get_position_template('', 9999)))); ?>'; 62 var nbr = p2m_nbr_to_add('position_view_');62 var nbr = jQuery('#widget_positions_body > *').length / 2 + jQuery('#positions_body > *').length / 2; 63 63 html = html.replace(/9999/g, nbr); 64 new Insertion.Bottom('widget_positions_body', html); 64 // new Insertion.Bottom('widget_positions_body', html); 65 jQuery('#widget_positions_body').append(html); 65 66 } 66 67 /* … … 68 69 */ 69 70 function p2m_edit_ad(nbr) { 70 $('ad_view_' + nbr).toggle();71 $('ad_edit_' + nbr).toggle();71 jQuery('#ad_view_' + nbr).toggle(); 72 jQuery('#ad_edit_' + nbr).toggle(); 72 73 } 73 74 … … 80 81 81 82 // The weight needs to be a number, unless left empty 82 if (! $('ad_quota_edit_' + nbr).value.match(/^\d+$/) && $('ad_quota_edit_' + nbr).value!= '') {83 if (!jQuery('#ad_quota_edit_' + nbr).val().match(/^\d+$/) && jQuery('#ad_quota_edit_' + nbr).val() != '') { 83 84 alert('<?php _e('The Weight must be a number!', 'ad-minister'); ?>'); 84 85 return 0; … … 86 87 87 88 // Handle orphaned content 88 if (! $('ad_position_edit_' + nbr).value)89 if (!jQuery('#ad_position_edit_' + nbr).val()) 89 90 if (!confirm("Since you didn't change the position, the item you are saving will remain orphaned. Is this alright?", 'ad-minister')) return false; 90 91 91 92 // Did the user change the position? 92 var pos_key = $('ad_position_edit_' + nbr).value;93 var reload = ( $('ad_position_view_' + nbr).value == pos_key || pos_key == '') ? false : true;93 var pos_key = jQuery('#ad_position_edit_' + nbr).val(); 94 var reload = (jQuery('#ad_position_view_' + nbr).val() == pos_key || !pos_key ) ? false : true; 94 95 95 96 p2m_save_content (nbr); 96 97 97 98 // Parse the scheduele 98 var scheduele = $('ad_scheduele_edit_' + nbr).value;99 var scheduele = jQuery('#ad_scheduele_edit_' + nbr).val(); 99 100 if (scheduele != '') { 100 101 scheduele = scheduele.replace(/:/g, ' to '); 101 // scheduele = scheduele.replace(/-/g, '/');102 $('ad_scheduele_view_' + nbr).innerHTML = ' | <strong><?php _e('Scheduele', 'ad-minister'); ?>:<\/strong> ' + scheduele;103 } else $('ad_scheduele_view_' + nbr).innerHTML = '';102 jQuery('#ad_scheduele_view_' + nbr).html(' | <strong><?php _e('Scheduele', 'ad-minister'); ?>:<\/strong> ' + scheduele); 103 // $('ad_scheduele_view_' + nbr).innerHTML = ' | <strong><?php _e('Scheduele', 'ad-minister'); ?>:<\/strong> ' + scheduele; 104 } else jQuery('#ad_scheduele_view_' + nbr).text(''); 104 105 105 106 // Fill in the display values 106 $('ad_code_view_' + nbr).innerHTML = $('ad_code_edit_' + nbr).value; 107 $('ad_position_view_' + nbr).innerHTML = $('ad_position_edit_' + nbr).value; 108 $('ad_title_view_' + nbr).innerHTML = $('ad_title_edit_' + nbr).value; 109 $('ad_position_view_' + nbr).value = $('ad_position_edit_' + nbr).value; 107 jQuery('#ad_code_view_' + nbr).html(jQuery('#ad_code_edit_' + nbr).val()); 108 jQuery('#ad_position_view_' + nbr).val(jQuery('#ad_position_edit_' + nbr).val()); 109 jQuery('#ad_title_view_' + nbr).html(jQuery('#ad_title_edit_' + nbr).val()); 110 // jQuery('#ad_weight_view_' + nbr).text(jQuery('#ad_weight_edit_' + nbr).val()); 111 112 113 // jQuery('#ad_code_view_' + nbr).text(jQuery('#ad_code_edit_' + nbr).val()); 114 // jQuery('#ad_position_view_' + nbr).value = $('ad_position_edit_' + nbr).value; 110 115 111 116 // Handle the 'Automatic' weight function 112 if ( $('ad_quota_edit_' + nbr).value) $('ad_quota_view_' + nbr).innerHTML = $('ad_quota_edit_' + nbr).value;113 else $('ad_quota_view_' + nbr).innerHTML = 'Automatic ';117 if (jQuery('#ad_quota_edit_' + nbr).val()) jQuery('#ad_quota_view_' + nbr).text(jQuery('#ad_quota_edit_' + nbr).val()); 118 else jQuery('#ad_quota_view_' + nbr).text('Automatic'); 114 119 115 120 // Toggle the view … … 117 122 118 123 // Tell user to reload page if the position changed 119 if (reload == true) new Insertion.After('ad_position_view_div_' + nbr, '<div style="background: #ff7777; height: 20px; padding: 20px;"><?php _e('Since you changed the position of this object, you should now reload this page.', 'administer'); ?><\/div>');124 if (reload == true) jQuery('#ad_position_view_div_' + nbr).after('<div style="background: #ff5555; height: 20px; padding: 20px;"><?php _e('Hey! Since you changed the position, you should now reload this page.', 'ad-minister'); ?><\/div>'); 120 125 } 121 126 /* … … 123 128 */ 124 129 function p2m_save_content (nbr) { 130 125 131 // Call ajax functions to save the changes 126 132 send = new Array(); 127 send['position'] = $('ad_position_edit_' + nbr).value;128 send['position_old'] = $('ad_position_view_' + nbr).value;129 send['code'] = $('ad_code_edit_' + nbr).value;130 send['w rap'] = $('ad_wrap_edit_' + nbr).checked;131 send[' weight'] = $('ad_quota_edit_' + nbr).value;132 send['s how'] = $('ad_show_' + nbr).checked;133 send[' title'] = $('ad_title_edit_' + nbr).value;134 send[' scheduele'] = $('ad_scheduele_edit_' + nbr).value;133 send['position'] = jQuery('#ad_position_edit_' + nbr).val(); 134 send['position_old'] = jQuery('#ad_position_view_' + nbr).val(); 135 send['code'] = jQuery('#ad_code_edit_' + nbr).val(); 136 send['weight'] = jQuery('#ad_quota_edit_' + nbr).val(); 137 send['title'] = jQuery('#ad_title_edit_' + nbr).val(); 138 send['scheduele'] = jQuery('#ad_scheduele_edit_' + nbr).val(); 139 send['show'] = document.getElementById('ad_show_' + nbr).checked; 140 send['wrap'] = document.getElementById('ad_wrap_edit_' + nbr).checked; 135 141 send['id'] = nbr; 136 p2m_send_ajax('save_content', send, 'aj_' + nbr); 142 143 // Send our data off to the server 144 p2m_send_ajax('save_content', send, '#aj_' + nbr); 137 145 } 138 146 /* … … 143 151 // Zero the values 144 152 send = new Array(); 145 send['id'] = $('ad_id_' + nbr).value;153 send['id'] = jQuery('#ad_id_' + nbr).val(); 146 154 p2m_send_ajax('delete_content', send, ''); 147 $('ad_' + nbr).remove();155 jQuery('#ad_' + nbr).remove(); 148 156 } 149 157 } … … 152 160 */ 153 161 function p2m_does_position_key_exist ( nbr ) { 154 var positions = $('widget_positions_body').childElements();162 var positions = jQuery('#widget_positions_body > *'); 155 163 for (var i = 0; i < positions.length; i++) { 156 164 var number = positions[i].id.replace('position_view_', ''); 157 165 if (number.match(/^\d+$/) && nbr != number) 158 if ( $('position_key_' + number).innerHTML == $('position_key_edit_' + nbr).value) return true;166 if (jQuery('#position_key_' + number).text() == jQuery('#position_key_edit_' + nbr).val()) return true; 159 167 } 160 168 return false; … … 164 172 */ 165 173 function p2m_nbr_to_add(id_prefix) { 174 alert('#positions > *' + id_prefix + '*'); 175 176 return jQuery('#widget_positions_body > *').length / 2; 177 178 // user jQuery(parent > '#boooo*') 166 179 var not_yet = true; 167 180 var to_add = 0; 168 while (not_yet) { 169 if ($(id_prefix + to_add)) to_add++; 170 else not_yet = false; 171 } 181 //while (not_yet) { 182 // alert('#' + id_prefix + to_add); 183 // if (jQuery('#' + id_prefix + to_add)) to_add++; 184 // else not_yet = false; 185 //} 172 186 return to_add; 173 187 } … … 182 196 */ 183 197 function p2m_ready(domid) { 184 if ( $(domid)) $(domid).hide();198 if (jQuery(domid)) jQuery(domid).hide(); 185 199 } 186 200 function p2m_preview_ad() { 187 $('preview').innerHTML = $('content').value;201 jQuery('#preview').html(jQuery('#content').val()); 188 202 } 189 203 function p2m_send_ajax(action, send, notification_domid) { … … 193 207 194 208 // Set the color of the notification domid 195 if (notification_domid != '' && $(notification_domid)) {196 $(notification_domid).show();209 if (notification_domid != '' && jQuery(notification_domid)) { 210 jQuery(notification_domid).show(); 197 211 mysack.setVar('notification_domid', notification_domid); 198 212 } … … 201 215 var nbr = 0 202 216 for (var key in send) { 203 mysack.setVar( 'key_' + nbr, key);204 mysack.setVar( 'value_' + nbr, send[key]);217 mysack.setVar('key_' + nbr, key); 218 mysack.setVar('value_' + nbr, send[key]); 205 219 nbr++; 206 220 } … … 210 224 mysack.execute = 1; 211 225 mysack.method = 'POST'; 212 mysack.setVar( "action", ('administer_' + action));213 mysack.encVar( "cookie", document.cookie, false );226 mysack.setVar('action', ('administer_' + action)); 227 mysack.encVar('cookie', document.cookie, false ); 214 228 mysack.onError = function() { alert('AJAX error!')}; 215 229 mysack.runAJAX(); ad-minister/trunk/ad-minister-positions.php
r29627 r29890 20 20 21 21 <form> 22 23 <h3>Template Positions</h3>24 25 22 <div id="positions"> 26 23 24 <h3>Template Positions</h3> 27 25 28 <table id="templatePositions"> 26 <p><?php _e('These are the positions defined within the theme that you are using.', 'ad-minister'); ?></p> 27 28 <table class="templatePositions"> 29 29 <thead> 30 30 <tr> 31 <th id="positionKey" scope="col" style=""><?php _e('Position Name', 'ad-minister'); ?></th>32 <th id="templatePositionsDescription" scope="col"><?php _e('Description', 'ad-minister'); ?></th>33 <th id="templateFunctions" scope="col" colspan="1"><?php _e('Wrapper', 'ad-minister'); ?></th>34 <th id="templatePositionsActions" colspan="2" scope="col"><?php _e('Actions', 'ad-minister'); ?></th>31 <th class="positionKey" scope="col" style=""><?php _e('Position Name', 'ad-minister'); ?></th> 32 <th class="templatePositionsDescription" scope="col"><?php _e('Description', 'ad-minister'); ?></th> 33 <th class="templateFunctions" scope="col" colspan="1">Wrapper</th> 34 <th class="templatePositionsActions" colspan="2" scope="col"><?php _e('Actions', 'ad-minister'); ?></th> 35 35 </tr> 36 36 </thead> … … 58 58 59 59 <h3>Widget Positions</h3> 60 61 <p><?php _e('Below are the Ad-minister widgets available to be <a href="widgets.php">placed your blog</a> (the positions below are prepended with \'Ad: \' on as to identify them).', 'ad-minister'); ?></p> 60 62 61 63 <div id="positions"> 62 <table id="templatePositions">64 <table class="templatePositions"> 63 65 <thead> 64 66 <tr> 65 <th id="positionKey" scope="col" style=""><?php _e('PositionName', 'ad-minister'); ?></th>66 <th id="templatePositionsDescription" scope="col"><?php _e('Description', 'ad-minister'); ?></th>67 <th id="templateFunctions" scope="col" colspan="1"><?php _e('Wrapper', 'ad-minister'); ?></th>68
