static function process() { global $advman_list; $q = Advman_Tools::get_search_query(); echo '<div class="wrap"><h2>' . __('Ads', 'advman'); if (!empty($q)) { printf(' <span class="subtitle">' . __('Search results for “%s”', 'advman') . '</span>', $q); } echo '</h2>'; $advman_list->views(); $advman_list->prepare_items(); ?> <form method="get"> <input type="hidden" name="page" value="advman-list"> <?php $advman_list->search_box('search', 'ad'); ?> </form> <form method="post"> <?php wp_nonce_field('advman-bulk-actions'); $advman_list->display(); ?> </form> </div> <?php }
/** * This function is called from the Wordpress Settings menu */ function settings() { // Get our options and see if we're handling a form submission. $action = OX_Tools::sanitize_post_var('advman-action'); if ($action == 'save') { global $advman_engine; $settings = array('openx-market', 'openx-market-cpm', 'openx-sync', 'enable-php', 'stats', 'purge-stats-days'); foreach ($settings as $setting) { $value = isset($_POST["advman-{$setting}"]) ? OX_Tools::sanitize($_POST["advman-{$setting}"]) : false; $advman_engine->setSetting($setting, $value); } } $template = Advman_Tools::get_template('Settings'); $template->display(); }
static function display_save_settings($ad, $nw = false) { $revisions = $nw ? $ad->get_network_property('revisions') : $ad->get_property('revisions'); list($last_user, $last_timestamp, $last_timestamp2) = Advman_Tools::get_last_edit($revisions); ?> <div id="advman-submitad" class="submitbox"> <div id="minor-publishing"> <div style="display:none;"><input type="submit" name="save" value="<?php _e('Save', 'advman'); ?> " /></div> <div id="minor-publishing-actions"> <div id="save-action"> <input id="save-post" class="button button-highlighted" type="submit" tabindex="4" value="<?php _e('Apply', 'advman'); ?> " onclick="document.getElementById('advman-action').value='apply';" /> </div> <?php if (!$nw) { ?> <div id="preview-action"> <a class="preview button" href="<?php echo $ad->get_preview_url(); ?> " id="post-preview" tabindex="4"><?php _e('Preview Ad', 'advman'); ?> </a> <input type="hidden" name="wp-preview" id="wp-preview" value="" /> </div><!-- preview-action --> <?php } ?> <div class="clear"></div> </div><!-- minor-publishing-actions --> <div id="misc-publishing-actions"> <?php if (!$nw) { ?> <div class="misc-pub-section"> <label for="post_status"><?php _e('Status:', 'advman'); ?> </label> <b><a href="javascript:submit();" class="edit-post-status hide-if-no-js" onclick="document.getElementById('advman-action').value='<?php echo $ad->active ? 'deactivate' : 'activate'; ?> '; document.getElementById('advman-form').submit();"><?php echo $ad->active ? __('Active', 'advman') : __('Paused', 'advman'); ?> </a></b> </div><!-- misc-pub-section --> <?php } ?> <div class="misc-pub-section curtime misc-pub-section-last"> <span id="timestamp"><?php echo __('Last edited', 'advman') . ' <abbr title="' . $last_timestamp2 . '"><b>' . $last_timestamp . __(' ago', 'advman') . '</b></abbr> ' . __('by', 'advman') . ' ' . $last_user; ?> </span> </div><!-- misc-pub-section curtime misc-pub-section-last --> </div><!-- misc-publishing-actions --> <div class="clear"></div> </div><!-- minor-publishing --> <div id="major-publishing-actions"> <div id="delete-action"> <a class="submitdelete deletion" href="javascript:submit();" onclick="document.getElementById('advman-action').value='cancel'; document.getElementById('advman-form').submit();"><?php _e('Cancel', 'advmgr'); ?> </a> </div><!-- delete-action --> <div id="publishing-action"> <input type="submit" class="button-primary" id="advman_save" tabindex="5" accesskey="p" value="<?php _e('Save', 'advman'); ?> " onclick="document.getElementById('advman-action').value='save';" /> </div><!-- publishing-action --> <div class="clear"></div> </div><!-- major-publishing-actions --> </div><!-- advman-submitad --> <?php }
function display($target = null, $filter = null) { global $advman_engine; $ads = $advman_engine->getAds(); $date = date('Y-m-d'); $adCount = 0; $activeAdCount = 0; $networks = array(); if (!empty($ads)) { $adCount = sizeof($ads); foreach ($ads as $ad) { if ($ad->active) { $activeAdCount++; } $networks[strtolower(get_class($ad))] = $ad->network_name; } } $filterActive = !empty($filter['active']) ? $filter['active'] : null; $filterNetwork = !empty($filter['network']) ? $filter['network'] : null; $defaultAdName = $advman_engine->getSetting('default-ad'); ?> <div class="wrap"> <div id="icon-edit" class="icon32"><br /></div> <h2><?php _e('Manage Your Advertising', 'advman'); ?> </h2> <script type='text/javascript'> /* <![CDATA[ */ function advman_setAction(action, id, name, network) { submit = true; if (action == 'delete') { if ( confirm('You are about to permanently delete the ' + network + ' ad:\n\n [' + id + '] ' + name + '\n\nAre you sure?\n(Press \'Cancel\' to keep, \'OK\' to delete)') ) { submit = true; } else { submit = false; } } if (submit) { document.getElementById('advman-action').value = action; document.getElementById('advman-target').value = id; document.getElementById('advman-form').submit(); } } /* ]]> */ </script> <form action="" method="post" id="advman-form" enctype="multipart/form-data"> <input type="hidden" id="advman-action" name="advman-action" /> <input type="hidden" id="advman-target" name="advman-target" /> <div class="tablenav"> <div class="alignleft actions"> <select id="advman-bulk-top" name="action"> <option value="" selected="selected"><?php _e('Bulk Actions', 'advman'); ?> </option> <option value="copy"><?php _e('Copy', 'advman'); ?> </option> <option value="delete"><?php _e('Delete', 'advman'); ?> </option> </select> <input type="submit" value="<?php _e('Apply', 'advman'); ?> " name="doaction" id="doaction" class="button-secondary action" onclick="document.getElementById('advman-action').value = document.getElementById('advman-bulk-top').value;" /> <select name='advman-filter-network' class='postform' > <option value='0'> <?php _e('View all ad types', 'advman'); ?> </option> <?php foreach ($networks as $network => $networkName) { ?> <option class="level-0"<?php echo $filterNetwork == $network ? ' selected' : ''; ?> value="<?php echo $network; ?> "> <?php printf(__('View only %s ads', 'advman'), $networkName); ?> </option> <?php } ?> </select> <select name='advman-filter-active' class='postform' > <option value='0'> <?php _e('View all ad statuses', 'advman'); ?> </option> <option class="level-0"<?php echo $filterActive == 'active' ? ' selected' : ''; ?> value="active"> <?php _e('View active ads only', 'advman'); ?> </option> <option class="level-0"<?php echo $filterActive == 'inactive' ? ' selected' : ''; ?> value="inactive"> <?php _e('View paused ads only', 'advman'); ?> </option> </select> <input type="submit" id="post-query-submit" value="<?php _e('Filter', 'advman'); ?> " class="button-secondary" onclick="document.getElementById('advman-action').value = 'filter';" /> <?php if (!empty($filterActive) || !empty($filterNetwork)) { ?> <input type="submit" value="<?php _e('Clear', 'advman'); ?> " class="button-secondary" onclick="document.getElementById('advman-action').value = 'clear';" /> <?php } ?> </div> <div class="clear"></div> </div> <div class="clear"></div> <table class="widefat post fixed" cellspacing="0"> <thead> <tr> <th scope="col" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th> <th scope="col" class="manage-column column-title" style=""><?php _e('Name', 'advman'); ?> </th> <th scope="col" class="manage-column column-advman-type" style=""><?php _e('Type', 'advman'); ?> </th> <th scope="col" class="manage-column column-advman-format" style=""><?php _e('Format', 'advman'); ?> </th> <th scope="col" class="manage-column column-advman-active" style=""><?php _e('Active', 'advman'); ?> </th> <th scope="col" class="manage-column column-advman-default" style=""><?php _e('Default', 'advman'); ?> </th> <th scope="col" class="manage-column column-date" style=""><?php _e('Last Edit', 'advman'); ?> </th> <th scope="col" class="manage-column column-advman-notes" style=""><?php _e('Notes', 'advman'); ?> </th> </tr> </thead> <tfoot> <tr> <th scope="col" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th> <th scope="col" class="manage-column column-title" style=""><?php _e('Name', 'advman'); ?> </th> <th scope="col" class="manage-column column-advman-type" style=""><?php _e('Type', 'advman'); ?> </th> <th scope="col" class="manage-column column-advman-format" style=""><?php _e('Format', 'advman'); ?> </th> <th scope="col" class="manage-column column-advman-active" style=""><?php _e('Active', 'advman'); ?> </th> <th scope="col" class="manage-column column-advman-default" style=""><?php _e('Default', 'advman'); ?> </th> <th scope="col" class="manage-column column-date" style=""><?php _e('Last Edit', 'advman'); ?> </th> <th scope="col" class="manage-column column-advman-notes" style=""><?php _e('Notes', 'advman'); ?> </th> </tr> </tfoot> <tbody> <?php foreach ($ads as $ad) { if ($filterActive == 'active' && $ad->active || $filterActive == 'inactive' && !$ad->active || empty($filterActive)) { if ($filterNetwork == strtolower(get_class($ad)) || empty($filterNetwork)) { ?> <tr id='post-3' class='alternate author-self status-publish iedit' valign="top"> <th scope="row" class="check-column"><input type="checkbox" name="advman-targets[]" value="<?php echo $ad->id; ?> " /></th> <td class="post-title column-title"> <strong><a class="row-title" href="javascript:advman_setAction('edit','<?php echo $ad->id; ?> ');" title="<?php printf(__('Edit the ad "%s"', 'advman'), $ad->name); ?> ">[<?php echo $ad->id; ?> ] <?php echo $ad->name; ?> </a></strong> <div class="row-actions"> <span class='edit'><a href="javascript:advman_setAction('edit','<?php echo $ad->id; ?> ');" title="<?php printf(__('Edit the ad "%s"', 'advman'), $ad->name); ?> "><?php _e('Edit', 'advman'); ?> </a> | </span> <span class='edit'><a class='submitdelete' title="<?php _e('Copy this ad', 'advman'); ?> " href="javascript:advman_setAction('copy','<?php echo $ad->id; ?> ');"><?php _e('Copy', 'advman'); ?> </a> | </span> <span class='edit'><a class='submitdelete' title="<?php _e('Delete this ad', 'advman'); ?> " href="javascript:advman_setAction('delete','<?php echo $ad->id; ?> ', '<?php echo $ad->name; ?> ', '<?php echo $ad->network_name; ?> ');" onclick=""><?php _e('Delete', 'advman'); ?> </a> | </span> <span class='edit'><a href="<?php echo $ad->get_preview_url(); ?> " target="wp-preview" id="post-preview" tabindex="4"><?php _e('Preview', 'advman'); ?> </a></span> </div> </td> <td class="advman-type column-advman-type"><a href="javascript:advman_setAction('edit-network','<?php echo $ad->id; ?> ');" title="<?php printf(__('Edit the ad network "%s"', 'advman'), $ad->network_name); ?> "><?php echo $ad->network_name; ?> </a></td> <td class="advman-format column-advman-format"> <?php echo $this->displayFormat($ad); ?> </td> <td class="advman-active column-advman-active"><a href="javascript:advman_setAction('<?php echo $ad->active ? 'deactivate' : 'activate'; ?> ','<?php echo $ad->id; ?> ');"> <?php echo $ad->active ? __('Yes', 'advman') : __('No', 'advman'); ?> </a></td> <td class="advman-default column-advman-default"><a href="javascript:advman_setAction('default','<?php echo $ad->id; ?> ');"> <?php echo $ad->name == $defaultAdName ? __('Yes', 'advman') : __('No', 'advman'); ?> </a></td> <?php list($last_user, $last_timestamp, $last_timestamp2) = Advman_Tools::get_last_edit($ad->get_property('revisions')); ?> <td class="date column-date"><abbr title="<?php echo $last_timestamp2; ?> "><?php echo $last_timestamp . __(' ago', 'advman'); ?> </abbr><br /> <?php echo __('by', 'advman') . ' ' . $last_user; ?> </td> <td class="advman-notes column-advman-notes"><abbr title="<?php echo $ad->get_property('notes'); ?> "><?php echo $ad->get_property('notes'); ?> </abbr></td> </tr> <?php } } } ?> </tbody> </table> <div class="tablenav"> <div class="alignleft actions"> <select id="advman-bulk-bottom" name="action"> <option value="" selected="selected"><?php _e('Bulk Actions', 'advman'); ?> </option> <option value="copy"><?php _e('Copy', 'advman'); ?> </option> <option value="delete"><?php _e('Delete', 'advman'); ?> </option> </select> <input type="submit" value="<?php _e('Apply', 'advman'); ?> " name="doaction" id="doaction" class="button-secondary action" onclick="document.getElementById('advman-action').value = document.getElementById('advman-bulk-bottom').value;" /> <br class="clear" /> </div> <br class="clear" /> </div> </form> <div class="clear"></div></div><!-- wpbody-content --> <div class="clear"></div></div><!-- wpbody --> <div class="clear"></div></div><!-- wpcontent --> </div><!-- wpwrap --> <?php }
static function admin_enqueue_scripts($hook) { if (Advman_Tools::is_advman_page($hook)) { // scripts wp_enqueue_script('prototype'); wp_enqueue_script('postbox'); wp_enqueue_script('jquery-multiselect', ADVMAN_URL . '/scripts/jquery.multiSelect.js', array('jquery')); wp_enqueue_script('advman', ADVMAN_URL . '/scripts/advman.js'); // styles wp_enqueue_style('advman', ADVMAN_URL . '/scripts/advman.css'); wp_enqueue_style('advman-multiselect', ADVMAN_URL . '/scripts/jquery.multiSelect.css'); } }
function display($ad, $nw = false) { $target = $nw ? strtolower(get_class($ad)) : $ad->id; $mode = $nw ? 'edit_network' : 'edit_ad'; $revisions = $nw ? $ad->get_network_property('revisions') : $ad->get_property('revisions'); list($last_user, $last_timestamp, $last_timestamp2) = Advman_Tools::get_last_edit($revisions); ?> <form action="" method="post" id="advman-form" enctype="multipart/form-data"> <input type="hidden" name="advman-mode" id="advman-mode" value="<?php echo $mode; ?> "> <input type="hidden" name="advman-action" id="advman-action"> <input type="hidden" name="advman-target" id="advman-target" value="<?php echo $target; ?> "> <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> <div class="wrap"> <?php if ($nw) { ?> <h2><?php printf(__('Edit %s Network Settings', 'advman'), "<span class='" . strtolower(get_class($ad)) . "'>" . $ad->network_name . "</span>"); ?> </h2> <?php } else { ?> <h2><?php printf(__('Edit Settings for %s Ad:', 'advman'), $ad->network_name); ?> <span class="<?php echo strtolower(get_class($ad)); ?> "><?php echo "[{$ad->id}] " . $ad->name; ?> </span></h2> <?php } ?> <div id="poststuff"> <div class="submitbox" id="submitpost"> <div id="previewview"> <?php if (!$nw) { ?> <a id='advman-ad-preview' href="<?php echo $ad->get_preview_url(); ?> " target="wp_preview"><?php _e('Preview this Ad', 'advman'); ?> </a> <?php } ?> </div><!-- previewview --> <div class="inside"> <?php if (!$nw) { ?> <p><strong><label for='post_status'><?php _e('Ad Status'); ?> </label></strong></p> <p> <select name='advman-active' id='post_status'> <option<?php echo $ad->active ? " selected='selected'" : ""; ?> value='yes'><?php _e('Active', 'advman'); ?> </option> <option<?php echo $ad->active ? "" : " selected='selected'"; ?> value='no'><?php _e('Paused', 'advman'); ?> </option> </select> </p> <?php } ?> <p class="curtime"><?php echo __('Last edited', 'advman') . ' <abbr title="' . $last_timestamp2 . '"><b>' . $last_timestamp . ' ' . __('ago', 'advman') . '</b></abbr> ' . __('by', 'advman') . ' ' . $last_user; ?> </p> </div><!-- inside --> <div style="white-space:nowrap"> <p class="submit"> <input type="button" value="<?php _e('Cancel', 'advman'); ?> " onclick="document.getElementById('advman-action').value='cancel'; this.form.submit();"> <input type="button" value="<?php _e('Apply', 'advman'); ?> " onclick="document.getElementById('advman-action').value='apply'; this.form.submit();"> <input type="submit" value="<?php _e('Save »', 'advman'); ?> " class="button button-highlighted" onclick="document.getElementById('advman-action').value='save';" /> </p> </div> <div class="side-info"> <h5><?php _e('Shortcuts', 'advman'); ?> </h5> <ul> <?php if ($nw) { if (!empty($ad->url)) { ?> <li><a href="<?php echo $ad->url; ?> "><?php printf(__('%s home page', 'advman'), $ad->network_name); ?> </a></li> <?php } ?> <li><a href="javascript:submit();" onclick="document.getElementById('advman-action').value='reset'; document.getElementById('advman-target').value='<?php echo strtolower(get_class($ad)); ?> '; document.getElementById('advman-form').submit();"><?php printf(__('Reset %s settings to defaults', 'advman'), $ad->network_name); ?> </a></li> <?php } else { ?> <li><a href="javascript:submit();" onclick="if(confirm('<?php printf(__('You are about to copy the %s ad:', 'advman'), $ad->networkName); ?> \n\n <?php echo '[' . $ad->id . '] ' . $ad->name; ?> \n\n<?php _e('Are you sure?', 'advman'); ?> \n<?php _e('(Press Cancel to do nothing, OK to copy)', 'advman'); ?> ')){document.getElementById('advman-action').value='copy'; document.getElementById('advman-form').submit(); } else {return false;}"><?php _e('Copy this ad', 'advman'); ?> </a></li> <li><a href="javascript:submit();" onclick="if(confirm('<?php printf(__('You are about to permanently delete the %s ad:', 'advman'), $ad->network_name); ?> \n\n <?php echo '[' . $ad->id . '] ' . $ad->name; ?> \n\n<?php _e('Are you sure?', 'advman'); ?> \n<?php _e('(Press Cancel to keep, OK to delete)', 'advman'); ?> ')){document.getElementById('advman-action').value='delete'; document.getElementById('advman-form').submit(); } else {return false;}"><?php _e('Delete this ad', 'advman'); ?> </a></li> <li><a href="javascript:submit();" onclick="document.getElementById('advman-action').value='edit'; document.getElementById('advman-target').value='<?php echo strtolower(get_class($ad)); ?> '; document.getElementById('advman-form').submit();"><?php printf(__('Edit %s Defaults', 'advman'), $ad->network_name); ?> </a></li> <?php } ?> </ul> <?php $notes = $nw ? $ad->get_network_property('notes') : $ad->get_property('notes'); ?> <h5><?php _e('Notes', 'advman'); ?> </h5> <label for="ad_code"><?php _e('Display any notes about this ad here:', 'advman'); ?> </label><br /><br /> <textarea rows="8" cols="22" name="advman-notes" id="advman-notes"><?php echo $notes; ?> </textarea><br /> </div><!-- side-info --> </div><!-- submitpost --> <div id="post-body"> <?php // Title $this->display_title($ad, $nw); // Show normal boxes do_meta_boxes('advman', 'main', $ad); // Show advanced screen $this->display_advanced($ad); // Show advanced boxes do_meta_boxes('advman', 'advanced', $ad); ?> </div> </div> </div> </form> </div><!-- wpbody --> </div><!-- wpcontent --> </div><!-- wpwrap --> <?php }
function factory($class, $aAd = null, $data = null) { if (class_exists($class)) { $ad = new $class(); if (is_null($data)) { $data = $this->data; } if (is_null($aAd)) { $ad->active = true; $ad->name = OX_Tools::generate_name($ad->network_name); } else { $ad->name = $aAd['name']; $ad->id = $aAd['id']; $ad->active = $aAd['active']; $aProperties = Advman_Tools::get_properties_from_array($aAd); $ad->p = $aProperties; } if (empty($data['networks'][$class])) { $ad->np = $ad->get_network_property_defaults(); } else { $ad->np = $data['networks'][$class]; } return $ad; } else { return false; } }
function prepare_items() { $filter = $this->_get_filter(); $q = Advman_Tools::get_search_query(); $columns = $this->get_columns(); $hidden = array(); $sortable = $this->get_sortable_columns(); $this->_column_headers = array($columns, $hidden, $sortable); // Retrieve the ad data from the DB $data = $this->get_data($filter, $q); usort($data, array(&$this, 'usort_reorder')); $total_items = count($data); $per_page = 10; $current_page = $this->get_pagenum(); $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page)); $this->items = array_slice($data, ($current_page - 1) * $per_page, $per_page); }