コード例 #1
0
ファイル: widget.php プロジェクト: etruel/WPeMyAds
 /**
  * Creates the edit form for the widget.
  *
  */
 function form($instance)
 {
     //Defaults
     $instance = wp_parse_args((array) $instance, array('title' => 'My Ads', 'show_title' => '1', 'zone' => '', 'zone2' => '', 'WPeMyAdsPage' => ''));
     $title = htmlspecialchars($instance['title']);
     $show_title = htmlspecialchars($instance['show_title']);
     $zone = htmlspecialchars($instance['zone']);
     $zone2 = htmlspecialchars($instance['zone2']);
     $WPeMyAdsPage = htmlspecialchars($instance['WPeMyAdsPage']);
     //$valid = ($instance['zone_status']['valid'] == 'YES');
     $xzones = get_etruel_AdServe_zones();
     $doSelect = "<select name='" . $this->get_field_name('zone') . "' id='" . $this->get_field_id('zone') . "'>\n";
     $doSelect .= "\t\t\t<option value=''> </option>\n";
     $doSelect2 = "<select name='" . $this->get_field_name('zone2') . "' id='" . $this->get_field_id('zone2') . "'>\n";
     $doSelect2 .= "\t\t\t<option value=''> </option>\n";
     foreach ($xzones as $rk) {
         $doSelect .= "\t\t\t<option value='{$rk->keywords}' ";
         $doSelect .= $rk->keywords == $zone ? " selected" : "";
         $doSelect .= ">" . $rk->keywords . "</option>\n";
         $doSelect2 .= "\t\t\t<option value='{$rk->keywords}' ";
         $doSelect2 .= $rk->keywords == $zone2 ? " selected" : "";
         $doSelect2 .= ">" . $rk->keywords . "</option>\n";
     }
     $doSelect .= "\t\t\t</select>";
     $doSelect2 .= "\t\t\t</select>";
     # Output the options
     echo '<p><label for="show_title" style="float:Right;"><input id="' . $this->get_field_id('show_title') . '" name="' . $this->get_field_name('show_title') . '" type="checkbox" value="' . $show_title . '"' . (!$show_title ? '' : 'checked') . '/> ' . __('Show Title') . '</label><label for="' . $this->get_field_name('title') . '">' . __('Title:') . '<br /><input style="width: 100%;" id="' . $this->get_field_id('title') . '" name="' . $this->get_field_name('title') . '" type="text" value="' . $title . '" /></label></p>';
     # zone
     echo '<p><label for="' . $this->get_field_name('zone') . '">' . __('1ra Zona:') . '  ';
     echo $doSelect;
     echo '</label></p>';
     # zone2
     echo '<p><label for="' . $this->get_field_name('zone2') . '">' . __('2da Zona:');
     echo $doSelect2;
     echo '</label></p>';
     # WPeMyAdsPage = Condicion para mostrar el widget Ej: is_page('algo') o is_front_page()
     echo '<p style="margin-bottom: 0;"><label for="' . $this->get_field_name('WPeMyAdsPage') . '">' . __('Logic URL:') . ' <input style="width: 200px;" id="' . $this->get_field_id('WPeMyAdsPage') . '" name="' . $this->get_field_name('WPeMyAdsPage') . '" type="text" value="' . $WPeMyAdsPage . '" /></label><br /><small><a href="Javascript:void(0);" onclick="jQuery(this).parent().parent().next().toggle();">' . __('Click here to see/hide examples') . '</a></small></p><div class="wpeexa" style="display:none;"><table style="width:100%;display:block;margin-left:20px;font: smaller \'Courier New\', Courier, mono;"> <tr><td>is_front_page()</td><td>is_page(\'slug\')</td></tr><tr><td>is_single(\'slug\')</td><td>is_author(\'slug\')</td></tr><tr><td>is_tag(\'slug\')</td><td>is_category(\'slug\')</td></tr></table></div>';
     echo '<p></p>';
 }
コード例 #2
0
ファイル: ad.php プロジェクト: etruel/WPeMyAds
function etruel_AdServe_Manage()
{
    global $wpdb, $user_email, $user_login;
    $table_name = $wpdb->prefix . "adserve";
    # Tabla OVERVIEW
    //$lastmonth = date('Ym', mktime(0, 0, 0, date("m")-1 , date("d") - 1, date("Y")));
    //$yesterday = date('Ymd', time()-86400);
    ?>
	
	<div class='wrap'>
		<h2>My Ads</h2>  <input type='button' class='button' name='reset' id='reset' value='New'>
	<div id="side-info-column" class="inner-sidebar">
		<?php 
    include plugin_dir_path(__FILE__) . 'myplugins.php';
    ?>
	</div>	
	<?php 
    print "<div id='table-content'><table class='widefat AdsTable'><thead><tr><th scope='col'>Site</th><th scope='col'>Zones</th><th scope='col'>Active</th><th scope='col'>Impressions</th><th scope='col'>Clicks</th><th scope='col'>Ratio</th><th scope='col'>Credits</th>";
    if (etruel_check_user_role('administrator')) {
        print "<th scope='col'>" . __('User') . "</th>";
    }
    print "<th scope='col'>Actions</th></tr></thead>";
    print "<tbody id='the-list'>";
    $qry = $wpdb->get_results("SELECT * FROM {$table_name} ORDER BY active DESC, credits DESC;");
    $first = false;
    foreach ($qry as $rk) {
        $first = true;
        $user = $rk->user != null && $rk->user != "" ? $rk->user : $user_login;
        // si no tiene usuario le asigno el actual
        //$user = (etruel_check_user_role('administrator')) ? $user : $user ;
        $script = $rk->src;
        $editform = "loadData('{$rk->id}', '{$rk->title}', '{$rk->scriptcode}', '{$rk->url}', '{$script}', '{$rk->email}', '{$rk->keywords}', '{$rk->width}', '{$rk->height}','{$user}');";
        print "<tr id='fila{$rk->id}' class='adfila'>";
        $tdtitle = "<td>";
        if ($rk->url === '') {
            $tdtitle .= "<strong>{$rk->title}</strong>";
        } else {
            $tdtitle .= "<a target='_Blank' title='" . __('open site on new window') . "' href='{$rk->url}'><strong>{$rk->title}</strong></a>";
        }
        if (etruel_check_user_role('administrator') || $rk->user == $user_login || $user == $user_login) {
            $tdtitle .= "<br /><a class='adedit' title='" . __('edit') . "' onclick=\"" . $editform . "\">" . __('edit') . "</a>";
        } else {
            $tdtitle .= "<br />" . __("user") . ": <b>{$user}</b>";
        }
        $tdtitle .= "</td>";
        echo $tdtitle;
        print "<td>" . $rk->keywords . "</td>\n";
        #		print "<td>".$rk->weight."</td>\n";
        print "<td>" . etruel_iif($rk->active == 1, "Yes", "No") . "</td>\n";
        print "<td>" . $rk->impressions . "</td>\n";
        print "<td>" . $rk->clicks . "</td>\n";
        print "<td>" . number_format($rk->clicks / ($rk->impressions + 1) * 100, 1) . " %</td>\n";
        print "<td>" . $rk->credits . "</td>\n";
        if (etruel_check_user_role('administrator')) {
            print "<td>{$user}</th>";
        }
        if (etruel_check_user_role('administrator') || $rk->user == $user_login || $user == $user_login) {
            print "<td><a class='adaction' title='edit' onclick=\"" . $editform . "\"><img src='" . plugin_dir_url(__FILE__) . "files/edit.gif'></a>";
            $url = plugin_dir_url(__FILE__) . "adremove.php?id={$rk->id}";
            print "<a class='adaction' href={$url} onclick=\"return confirm(" . __('Are you sure you want to delete?') . ")\">";
            print "<img src='" . plugin_dir_url(__FILE__) . "files/delete.gif'></a></td>\n";
        } else {
            print "<td><a style='border:0px;' title='' onclick='return false;'><img src='" . plugin_dir_url(__FILE__) . "files/noedit.gif' style='border: 0px solid #AB6400; margin:0; padding:0;'></a> ";
            print "<a onclick=\"return false;\" style='border:0px;'>";
            print "<img src='" . plugin_dir_url(__FILE__) . "files/nodelete.gif' style='border: 0px solid #AB6400; margin:0; padding:0;'></a></td>\n";
        }
        print "</tr>";
    }
    print "</table></div>";
    $nonce = wp_create_nonce('adsave-nonce');
    $imgnonce = wp_create_nonce('adimg-nonce');
    ?>
	<div id="tableform" style="display: <?php 
    echo !$first ? "block" : "none";
    ?>
;">
   	<table><tr>
	<td><div class="wrap"><div id="closefrm" title="Cancel and close">[x]</div><h2><?php 
    echo !$first ? "Add" : "Edit";
    ?>
 Ad</h2>
		<form name="adform" id="adform" method="POST" action="<?php 
    echo plugin_dir_url(__FILE__) . "adsave.php";
    ?>
">
		<input type="hidden" name="id" id="id" value="">
		<table>
			<tr><td>Title</td><td><input type="text" name="title" id="title" value="" size="60"></td></tr>
			<tr><td><label for="scriptcode">Script</label></td><td><input class="checkbox" type="checkbox" name="scriptcode" value="0" id="scriptcode"/> </td></tr> 
			<tr class="isscript"><td>Url</td><td><input type="text" name="url" id="url" value="" size="60"></td></tr>
			<tr><td>*Src</td><td><span class="isscript_src"><input type="text" id="src" name="src" value="" size="60"></span><input type='button' class='button' id='uploadf' value='Upload'></td></tr>
			<tr class="isscript"><td colspan="2" style="font-style:italic;">Ej: http://domain.com/image.jpg|.png|.gif|.swf</td></tr>
			<tr><td>Zones *</td><td><input type="text" name="keywords" id="keywords" value="" size="30"> <?php 
    $zones = array();
    $xzones = get_etruel_AdServe_zones();
    $doSelect = "<select name=\"selectzone\" id='selectzone'>\n";
    $doSelect .= "\t\t\t<option value='0'> </option>\n";
    $jsz = "";
    foreach ($xzones as $rk) {
        $doSelect .= "\t\t\t<option value='{$rk->keywords}' ";
        $doSelect .= ">" . $rk->keywords . "</option>\n";
        $zones[$rk->keywords]['width'] = $rk->width;
        $zones[$rk->keywords]['height'] = $rk->height;
        $jsz .= "\t\t\tjzone['{$rk->keywords}'] =  [ '{$rk->width}' , '{$rk->height}' ];\n";
    }
    $doSelect .= "\t\t\t</select>";
    echo $doSelect;
    ?>
</td></tr>
			<tr><td>Ancho *</td><td><input type="text" name="width" id="width" value=""></td></tr>  			
			<tr><td>*Alto </td><td><input type="text" name="height" id="height" value=""></td></tr>   
			<?php 
    if (etruel_check_user_role('administrator')) {
        ?>
				<tr><td>User</td><td>
				<?php 
        $userobj = get_user_by('login', $user);
        $userid = $userobj->ID;
        etruel_wp_dropdown_users(array('show' => 'user_login', 'name' => 'user', 'selected' => $userid, 'include_selected' => true));
        ?>
</td></tr>
			<?php 
    } else {
        ?>
				<tr><td></td><td><input  type="hidden" name="user" value="<?php 
        echo $user;
        ?>
" id="user"></td></tr>
			<?php 
    }
    ?>
			<tr><td>e-mail</td><td><input type="text" name="email" id="email" value="" size="40"></td></tr>
			<tr><td><input  type="hidden" name="_wpnonce" value="<?php 
    echo $nonce;
    ?>
" id="_wpnonce">
						
			</td></tr>
			<tr><td><input  class="button-primary"type="submit" name="vai" value="Add" id="buttonsave"></td></tr>
		</table>
	</form>
	<div id="uploadform" style="display: none;"><div id="closeupload" title="Cancel and close">[x]</div>
		<form action="<?php 
    echo plugin_dir_url(__FILE__) . "processupload.php";
    ?>
" method="post" enctype="multipart/form-data" id="MyUploadForm">
			<input name="FileInput" id="FileInput" type="file" />
			<input type="submit"  id="submit-btn" value="Upload" />
			<input  type="hidden" name="_imgnonce" value="<?php 
    echo $imgnonce;
    ?>
" id="_imgnonce">
			<img src="<?php 
    echo plugin_dir_url(__FILE__);
    ?>
files/ajax-loader.gif" id="loading-img" style="display:none;" alt="Please Wait"/>
		</form>
		<div id="progressbox" ><div id="progressbar"></div ><div id="statustxt">0%</div></div>
		<div id="output"></div>
	</div>
	
	<script>
		jQuery(function($){
			var jzone = [];
<?php 
    echo $jsz;
    ?>
			$("#selectzone").change(function(){
				 $("#keywords").val( $(this).val() );
				  $("#width").val( jzone[$(this).val()][0] );
				  $("#height").val( jzone[$(this).val()][1] );
			});
		});
	</script>
	</div></td></tr>
	</table>
	</div>
	</div>
<?php 
}