Changeset 29890

Show
Ignore:
Timestamp:
01/25/08 01:05:40 (6 months ago)
Author:
henrikmelin
Message:

A plethora of bugfixes. Moved from Prototype to jQuery. Hopefully improved cross-brower compatability

Files:

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" --> 
    62 
    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> 
    86 
    97<div id="ads"> 
     
    1513      $contents = get_post_meta(get_option('administer_post_id'), 'administer_content', true); 
    1614      $positions = get_post_meta(get_option('administer_post_id'), 'administer_positions', true); 
     15 
     16 
     17echo '<pre>'; 
     18// print_r($contents); 
     19echo '</pre>'; 
    1720 
    1821      // Identify orphans 
     
    7679                  <?php 
    7780                  foreach($position as $ad) { 
    78                         administer_content_template($ad); 
     81                        administer_content_template($ad, $index++); 
    7982                  } 
    8083                  echo '</div>'; 
  • ad-minister/trunk/ad-minister-create.php

    r29627 r29890  
    4242                  echo '<div id="message" class="updated fade"><p><strong>' . __('There is no content! Do make some.', 'ad-minister') . '</strong></p></div>'; 
    4343 
    44  
    4544?> 
    4645 
    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"> 
    4847<?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> 
    5049 
    5150      <div id="class"> 
     
    5352      </div> 
    5453 
     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> 
    5563 
     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 /* 
    56140      <div class="title2"> 
    57141            <strong class="title2"><?php _e('Title', 'ad-minister'); ?>: </strong> 
     
    74158                        //--> 
    75159                  </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.'); ?>) 
    77161                  </fieldset> 
    78162            </div> 
    79163       
    80             <p><strong class="add_option"><label for="ad_scheduele_edit_"><?php _e('Schedule', '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> 
    81165            <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> 
    82166            <p><strong class="add_option"><?php _e('Position', 'ad-minister'); ?>: </strong><div class="ad_field2"><?php echo administer_position_select(); ?></div></p>  
    83167            <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> 
    85169 
    86170            <div class="add_buttons" id="buttons"> 
     
    91175            </div> 
    92176      </div> 
     177      */ 
     178      ?> 
    93179 
    94180</form> 
     
    100186      <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> 
    101187 
    102       <iframe id="uploading" name="uploading" frameborder="0" src="upload.php?style=inline&#038;tab=browse&#038;post_id=<?php echo get_option('administer_post_id'); ?>&#038;_wpnonce=4b899edbfd">This feature requires iframe support.</iframe>      
     188      <iframe id="uploading" name="uploading" frameborder="0" src="upload.php?style=inline&#038;tab=browse&#038;post_id=<?php echo get_option('administer_post_id'); ?>&#038;_wpnonce=4b899edbfd">This feature requires iframe support.</iframe> 
  • ad-minister/trunk/ad-minister-functions.php

    r29627 r29890  
    2929      <script type='text/javascript' src="<?php echo get_option('siteurl') . '/' . WPINC; ?>/js/tw-sack.js?ver=1.6.1"></script> 
    3030      <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> 
    3132      <script type='text/javascript' src="<?php echo get_option('siteurl') . '/' . WPINC; ?>/js/quicktags.js"></script> 
    3233 
     
    3435            <h2> 
    3536                  <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"> 
    3738                              <img style="height: 50px" src="<?php echo get_option('siteurl') . '/' . PLUGINDIR . '/' . dirname(plugin_basename (__FILE__)); ?>/img/henrik.png"> 
    3839                        </a>               
     
    4142      </h2> 
    4243      <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> 
    4950      </ul> 
    5051 
     
    7071      // Get the position name 
    7172      $position     = stripslashes($content['position']); //p2m_meta('ad_position_' . $nbr); 
    72 //    $position     = $p2m_meta($position_key); 
    7373      if (!$position) $position = 'key_not_set'; 
    7474 
    7575      $show_checked = ($content['show'] == 'true') ? ' checked="checked"' : ''; 
    7676      $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'
    7878      // 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'; 
    8180       
    8281      $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 . '': ''; 
    8683      $wrap_checked = ($content['wrap'] == 'true') ? ' checked="checked"' : ''; 
    8784      $code = stripslashes($content['code']); 
     
    9895 
    9996                        <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>  
    10198                        </div> 
    10299 
     
    105102                  <div style="background: #99ee99; padding: 10px;"> 
    106103                        <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>  
    108105 
    109106                  <span id="ad_scheduele_view_%nbr%">' . $scheduele_div . '</span> 
     
    119116 
    120117                        <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> 
    122119                        </div> 
    123120 
     
    128125 
    129126                              <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> 
    134131                                    <div>' . administer_position_select($nbr, $content['position']) . '</div> 
    135132                              <label for="ad_wrap_edit_%nbr%" class="ad_field">Use wrapper? </label> 
     
    172169                        <td> 
    173170                              %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> 
    175172                        </td> 
    176173                        <td><img id="aj_%nbr%" class="notifier" src="%url%/img/rotating_arrow.gif" style="display: none;"></td> 
     
    194191      '; 
    195192      // 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> |' : ''; 
    197194      $html = str_replace('%edit_link%', $edit_link, $html); 
    198195      $html = str_replace('%nbr%', $nbr, $html); 
     
    225222                  $got_selected = true; 
    226223            } 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>'; 
    228226      } 
    229227 
     
    386384            $parts = explode(':', ltrim(rtrim($time))); 
    387385            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'); 
    390389            } 
    391390            $now = time(); 
     
    419418                        $li_ends .= '<li>'; 
    420419                        $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.'; 
    422421                        $li_ends .= '</li>'; 
    423422                  } 
     
    425424                        $li_starts .= '<li>'; 
    426425                        $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.'; 
    428427                        $li_starts .= '</li>'; 
    429428                  }            
     
    431430      } 
    432431 
    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">&raquo;</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'); 
    443441} 
    444442 
     
    449447function administer_translate(){ 
    450448    // 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__)) ); 
    452450} 
    453451 
     
    597595            if ($ad['position'] != $pos) continue; 
    598596             
     597            // Is the option to show the content ticked. 
     598            if ($ad['show'] == 'false') continue;  
     599 
    599600            // Is the content schedueled to show? 
    600601            $valid = false; 
    601  
    602602            $ages = adminiseter_content_age($ad['scheduele']); 
    603  
    604603            foreach ($ages as $age) {  
    605  
    606604                  // No scheduele, so content always valid 
    607605                  if (!$age['start'] && !$age['end']) $valid = true; 
     
    609607                  if ($age['start'] < 0 && $age['end'] > 0) $valid = true; 
    610608            } 
    611              
    612             // Is the option to show the content ticked. 
    613             if ($ad['show'] == 'true') $valid = true; 
    614              
     609 
    615610            // Sum the weights if the content is valid 
    616611            if ($valid) { 
     
    623618            } 
    624619      } 
     620 
     621      // Make sure we have some valid content 
     622      if (count($valids) == 0) return 0; 
    625623 
    626624      // Get a pseudo random number 
  • ad-minister/trunk/ad-minister-help.php

    r29627 r29890  
    2323<div style='padding: 20px;'> 
    2424 
    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> 
    2628 
    2729<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  
    44            */ 
    55            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(); 
    88            } 
    99            /* 
     
    1414                  // No duplicate keys please 
    1515                  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. '); 
    1717                        return false; 
    1818                  } 
    1919 
    2020                  // Check for empty key names 
    21                   if (!$('position_key_edit_' + nbr).value) { 
     21                  if (!jQuery('#position_key_edit_' + nbr).val()) { 
    2222                        alert("<?php _e("The Position Key can not be empty!"); ?>"); 
    2323                        return false; 
     
    2626                  // Set up the data to save                 
    2727                  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()
    3333                  send['type']             = 'widget'; 
    3434                   
    35                   p2m_send_ajax('save_position', send, 'aj_' + nbr); 
     35                  p2m_send_ajax('save_position', send, '#aj_' + nbr); 
    3636                   
    3737                  var params = new Array('key', 'desc', 'before', 'after'); 
    3838                  //for (var param in params) { 
    3939                  for (var i=0; i < params.length; i++) { 
    40                         $('position_' + params[i] + '_' + nbr).innerHTML = $('position_' + params[i] + '_edit_' + nbr).value.replace('<', '&lt;').replace('>', '&gt;'); //.replace('<', '&lt;').replace('>', '&gt;');              
     40                        jQuery('#position_' + params[i] + '_' + nbr).html(jQuery('#position_' + params[i] + '_edit_' + nbr).val().replace('<', '&lt;').replace('>', '&gt;')); //.replace('<', '&lt;').replace('>', '&gt;');              
    4141                  } 
    4242                   
     
    4949                  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'); ?>")) { 
    5050                        var send = new Array(); 
    51                         send['position']  = $('position_key_edit_' + nbr).value
     51                        send['position']  = jQuery('#position_key_edit_' + nbr).val()
    5252                        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(); 
    5555                  } 
    5656            } 
     
    6060            function p2m_add_position () { 
    6161                  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
    6363                  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); 
    6566            } 
    6667            /* 
     
    6869            */ 
    6970            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(); 
    7273            } 
    7374             
     
    8081 
    8182                  // 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() != '') { 
    8384                        alert('<?php _e('The Weight must be a number!', 'ad-minister'); ?>'); 
    8485                        return 0; 
     
    8687                   
    8788                  // Handle orphaned content  
    88                   if (!$('ad_position_edit_' + nbr).value)  
     89                  if (!jQuery('#ad_position_edit_' + nbr).val())  
    8990                        if (!confirm("Since you didn't change the position, the item you are saving will remain orphaned. Is this alright?", 'ad-minister')) return false; 
    9091 
    9192                  // 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;                                    
    9495 
    9596                  p2m_save_content (nbr); 
    9697 
    9798                  // Parse the scheduele 
    98                   var scheduele = $('ad_scheduele_edit_' + nbr).value
     99                  var scheduele = jQuery('#ad_scheduele_edit_' + nbr).val()
    99100                  if (scheduele != '') { 
    100101                        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('')
    104105 
    105106                  // 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;  
    110115                   
    111116                  // 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')
    114119 
    115120                  // Toggle the view 
     
    117122 
    118123                  // 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>'); 
    120125            } 
    121126            /* 
     
    123128            */ 
    124129            function p2m_save_content (nbr) { 
     130 
    125131                  // Call ajax functions to save the changes 
    126132                  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['wrap']         = $('ad_wrap_edit_' + nbr).checked
    131                   send['weight']       = $('ad_quota_edit_' + nbr).value
    132                   send['show']            = $('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
    135141                  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); 
    137145            }      
    138146            /* 
     
    143151                        // Zero the values 
    144152                        send = new Array(); 
    145                         send['id'] = $('ad_id_' + nbr).value
     153                        send['id'] = jQuery('#ad_id_' + nbr).val()
    146154                        p2m_send_ajax('delete_content', send, ''); 
    147                         $('ad_' + nbr).remove();           
     155                        jQuery('#ad_' + nbr).remove();           
    148156                  } 
    149157            } 
     
    152160            */     
    153161            function p2m_does_position_key_exist ( nbr ) { 
    154                   var positions = $('widget_positions_body').childElements(); 
     162                  var positions = jQuery('#widget_positions_body > *'); 
    155163                  for (var i = 0; i < positions.length; i++) {  
    156164                        var number = positions[i].id.replace('position_view_', ''); 
    157165                        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; 
    159167                  } 
    160168                  return false;            
     
    164172            */     
    165173            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*') 
    166179                  var not_yet = true; 
    167180                  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                  //} 
    172186                  return to_add; 
    173187            } 
     
    182196            */     
    183197            function p2m_ready(domid) { 
    184                   if ($(domid)) $(domid).hide(); 
     198                  if (jQuery(domid)) jQuery(domid).hide(); 
    185199            }            
    186200            function p2m_preview_ad() { 
    187                   $('preview').innerHTML = $('content').value
     201                  jQuery('#preview').html(jQuery('#content').val())
    188202            } 
    189203            function p2m_send_ajax(action, send, notification_domid) { 
     
    193207 
    194208                  // 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(); 
    197211                        mysack.setVar('notification_domid', notification_domid); 
    198212                  } 
     
    201215                  var nbr = 0 
    202216                  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]);      
    205219                        nbr++; 
    206220                  } 
     
    210224            mysack.execute = 1; 
    211225                  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 ); 
    214228                  mysack.onError = function() { alert('AJAX error!')}; 
    215229                  mysack.runAJAX(); 
  • ad-minister/trunk/ad-minister-positions.php

    r29627 r29890  
    2020 
    2121<form> 
    22  
    23 <h3>Template Positions</h3> 
    24  
    2522<div id="positions"> 
    2623 
     24      <h3>Template Positions</h3> 
    2725 
    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"> 
    2929            <thead> 
    3030                  <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> 
    3535                  </tr> 
    3636            </thead> 
     
    5858       
    5959      <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> 
    6062 
    6163      <div id="positions"> 
    62       <table id="templatePositions"> 
     64      <table class="templatePositions"> 
    6365            <thead> 
    6466                  <tr> 
    65                         <th id="positionKey" scope="col" style=""><?php _e('Position Name', '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