Permalink
Browse files

Fix new code and ditch old code

  • Loading branch information...
1 parent e535458 commit 8a445e91ed8ae5685ca5678cd6eda1a02cf3cb3c @eyedol committed Feb 3, 2012
View
36 controllers/admin/adsense_settings.php
@@ -35,17 +35,9 @@ public function index()
$form = array
(
'adsense_pub_id' => '',
- 'adsense_custom_channel' => '',
- 'adsense_border' => 0,
+ 'adsense_ad_slot' => '',
'adsense_size' => 0,
- 'adsense_bg_color' => '',
- 'adsense_border_color' => '',
- 'adsense_bg_color' => '',
- 'adsense_text_color' => '',
- 'adsense_link_color' => '',
- 'adsense_uri_color' => '',
'adsense_ad_placement' => 0,
- 'adsense_ad_type' => 0,
);
$errors = $form;
@@ -62,27 +54,22 @@ public function index()
//add validation rules
$post->add_rules('adsense_pub_id', 'required');
+ $post->add_rules('adsense_ad_slot', 'required');
//passed validation test.
if($post->validate())
{
- //everything is okay!
- $form = arr::overwrite($form,$post->as_array());
$adsense_settings = ORM::factory('adsense_settings',1);
$adsense_settings->ad_pub_id = $post->adsense_pub_id;
- $adsense_settings->ad_channel = $post->adsense_custom_channel;
+ $adsense_settings->ad_slot = $post->adsense_ad_slot;
$adsense_settings->ad_size = $post->adsense_size;
- $adsense_settings->ad_border = $post->adsense_border;
- $adsense_settings->ad_border_color = $post->adsense_border_color;
- $adsense_settings->ad_bg_color = $post->adsense_bg_color;
- $adsense_settings->ad_link_color = $post->adsense_link_color;
- $adsense_settings->ad_text_color = $post->adsense_text_color;
- $adsense_settings->ad_uri_color = $post->adsense_uri_color;
$adsense_settings->ad_placement = $post->adsense_ad_placement;
- $adsense_settings->ad_type = $post->adsense_ad_type;
//save new record
$adsense_settings->save();
+ //everything is okay!
+ $form = arr::overwrite($form,$post->as_array());
+ $form_saved = TRUE;
}
else
{
@@ -100,20 +87,11 @@ public function index()
// retrieve current settings.
$adsense_settings = ORM::factory('adsense_settings',1);
$form['adsense_pub_id'] = $adsense_settings->ad_pub_id;
- $form['adsense_custom_channel'] = $adsense_settings->ad_channel;
- $form['adsense_border'] = $adsense_settings->ad_border;
+ $form['adsense_ad_slot'] = $adsense_settings->ad_slot;
$form['adsense_size'] = $adsense_settings->ad_size;
- $form['adsense_border_color'] = $adsense_settings->ad_border_color;
- $form['adsense_bg_color'] = $adsense_settings->ad_bg_color;
- $form['adsense_link_color'] = $adsense_settings->ad_link_color;
- $form['adsense_text_color'] = $adsense_settings->ad_text_color;
- $form['adsense_uri_color'] = $adsense_settings->ad_uri_color;
$form['adsense_ad_placement'] = $adsense_settings->ad_placement;
- $form['adsense_ad_type'] = $adsense_settings->ad_type;
}
//enable color picker javascript library
- $this->template->colorpicker_enabled = TRUE;
- $this->template->js = new View('admin/adsense_settings_js');
$this->template->content->settings_form->ad_sizes = Kohana::config('adsense.ad_sizes');
$this->template->content->settings_form->form = $form;
$this->template->content->settings_form->errors = $errors;
View
19 hooks/adsense.php
@@ -89,28 +89,13 @@ public function _place_adsense()
{
$ad_settings = ORM::factory('adsense_settings',1);
$size = $ad_settings->ad_size;
- $w_h = explode('x',$size);
- $ui_features ="rc:0";
- if ($ad_settings->ad_border == 'rounded')
- {
- $ui_features ="rc:6";
- }
-
+ $w_h = explode('x',$size);
$adsense_code = '<script type="text/javascript"><!--
';
$adsense_code .= ' google_ad_client = "ca-'.$ad_settings->ad_pub_id.'";
+ google_ad_slot = "'.$ad_settings->ad_slot.'";
google_ad_width = '.$w_h[0].';
google_ad_height = '.$w_h[1].';
- google_ad_type = "'.$ad_settings->ad_type.'";
- google_ad_format = "'.$size.'_as";
- google_ad_channel ="'.$ad_settings->ad_channel.'";
- google_color_border = "'.$ad_settings->ad_border_color.'";
- google_color_link = "'.$ad_settings->ad_link_color.'";
- google_color_bg = "'.$ad_settings->ad_bg_color.'";
- google_color_text = "'.$ad_settings->ad_text_color.'";
- google_color_url = "'.$ad_settings->ad_uri_color.'";
- google_ui_features = "'.$ui_features.'";
-
//-->
</script>
<script type="text/javascript"
View
27 i18n/en_US/adsense.php
@@ -3,26 +3,13 @@
(
'settings' => 'Adsense Settings',
'id' => 'Adsense Publisher ID',
- 'id_tip' => 'To display ads from Google Adsense it\'s required to enter your Adsense Publisher ID. Your ID can be found in your Adsense panel on the \'Home\' tab and in the sidebar \'Account Settings\'.',
- 'custom_channel' => 'Custom Channels (Optional)',
- 'custom_channel_tip' => 'Allows you to define groups of ads for better tracking.',
'google_adsense' => 'Google Adsense',
- 'display_settings' => 'Display Settings',
+ 'id_tip' => 'To display ads from Google Adsense it\'s required to enter your Adsense Publisher ID. Your ID can be found in your Adsense panel on the \'Home\' tab and in the sidebar \'Account Settings\'.',
+ 'ad_slot' => 'Ad Slot ID',
+ 'ad_slot_tip' => 'Your google adsense slot ID',
+ 'ad_slot_desc' => 'You can find the ad slot ID at your Google adsense manager. Go to <a href="https://www.google.com/adsense">https://www.google.com/adsense/</a>. Then go to \'My ads\' -> ID. Eg. 7543616762 ',
'ad_placement' => 'Ad Placement',
- 'ad_type' => 'Ad Type',
- 'colors' => 'Colors',
'ad_size' => 'Ad Size',
- 'ad_border' => 'Border',
- 'border_color' => 'Border Color',
- 'background_color' => 'Background Color',
- 'link_color' => 'Link Color',
- 'text_color' => 'Text Color',
- 'uri_color' => 'Uri Color',
- 'normal' => 'Normal',
- 'rounded' => 'Rounded',
- 'type_image' => 'Image',
- 'type_text' => 'Text',
- 'type_text_image' => 'Text & Image',
'placement_header' => 'Main Header',
'placement_sidebar' => 'Main Sidebar',
'placement_footer' => 'Main Footer',
@@ -45,5 +32,11 @@
'ad_size_vertical_large' => '180 x 90 - Vertical Large',
'ad_size_vertical_medium' => '160 x 90 - Vertical Medium',
'ad_size_vertical_small' => '120 x 90 - Vertical Small',
+ 'adsense_ad_slot' => array(
+ 'required' => 'The Slot ID is required'
+ ),
+ 'adsense_pub_id' => array(
+ 'required' => 'The Pub ID is required'
+ )
);
?>
View
22 libraries/Adsense_Install.php
@@ -33,33 +33,21 @@ public function run_install()
$this->db->query("
CREATE TABLE IF NOT EXISTS `".$this->table."` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
- `ad_border` varchar(15) DEFAULT NULL,
`ad_pub_id` varchar(25) NOT NULL,
- `ad_channel` varchar(25) DEFAULT NULL,
+ `ad_slot` varchar(25) DEFAULT NULL,
`ad_size` varchar(15) NOT NULL,
- `ad_type` varchar(25) DEFAULT NULL,
`ad_placement` int(11) NOT NULL,
- `ad_border_color` varchar(15) DEFAULT NULL,
- `ad_text_color` varchar(15) DEFAULT NULL,
- `ad_bg_color` varchar(15) DEFAULT NULL,
- `ad_link_color` varchar(15) DEFAULT NULL,
- `ad_uri_color` varchar(15) DEFAULT NULL,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`)
) ENGINE=MyISAM;
");
if ($this->db->count_records($this->table) == 0) {
//populate with default values
$this->db->query("INSERT INTO `".$this->table."` (
- `id`, `ad_border`, `ad_pub_id`, `ad_channel`, `ad_size`,
- `ad_type`,
- `ad_placement`, `ad_border_color`, `ad_text_color`,
- `ad_bg_color`,
- `ad_link_color`, `ad_uri_color`) VALUES
-
- (1, 'normal', 'pub-0000000000000000', '', '300x250', 'text', 2,
- 'f0f0f0', '000000', 'f0f0f0', '426cb7', '426cb7');
+ `id`,`ad_pub_id`, `ad_slot`, `ad_size`,
+ `ad_placement`) VALUES
+ (1, 'pub-0000000000000000', '7543616762', '300x250',2);
");
}
}
View
60 views/admin/adsense_settings.php
@@ -41,59 +41,21 @@
</div>
<span>Eg: pub-4268725654361605</span>
<div class="row">
- <h4><a href="#" class="tooltip" title="<?php echo Kohana::lang('adsense.custom_channel_tip');?>">
- <?php echo Kohana::lang('adsense.custom_channel')?></a>
+ <h4><a href="#" class="tooltip" title="<?php echo Kohana::lang('adsense.ad_slot_tip');?>">
+ <?php echo Kohana::lang('adsense.ad_slot')?></a>
</h4>
- <?php print form::input('adsense_custom_channel',
- $form['adsense_custom_channel']);?>
- </div>
- </p>
- <p class="display-settings">
- <h3><?php echo Kohana::lang('adsense.display_settings');?></h3>
- <div class="row">
- <h4><?php echo Kohana::lang('adsense.ad_border') ?></a>
- </h4>
- <?php print form::dropdown('adsense_border',
- array('normal' => Kohana::lang('adsense.normal'),
- 'rounded'=>Kohana::lang('adsense.rounded')),$form['adsense_border']);?>
+ <?php print form::input('adsense_ad_slot',
+ $form['adsense_ad_slot']);?>
</div>
+ <span><?php echo Kohana::lang('adsense.ad_slot_desc') ?></span>
<div class="row">
<h4>
<?php echo Kohana::lang('adsense.ad_size')?>
</h4>
<?php print form::dropdown('adsense_size',
$ad_sizes,$form['adsense_size']);?>
</div>
- <div class="row">
- <h4>
- <?php echo Kohana::lang('adsense.border_color')?>
- </h4>
- <?php print form::input('adsense_border_color',$form['adsense_border_color']);?>
- </div>
- <div class="row">
- <h4>
- <?php echo Kohana::lang('adsense.background_color')?>
- </h4>
- <?php print form::input('adsense_bg_color',$form['adsense_bg_color']);?>
- </div>
- <div class="row">
- <h4>
- <?php echo Kohana::lang('adsense.link_color')?>
- </h4>
- <?php print form::input('adsense_link_color',$form['adsense_link_color']);?>
- </div>
- <div class="row">
- <h4>
- <?php echo Kohana::lang('adsense.text_color')?>
- </h4>
- <?php print form::input('adsense_text_color',$form['adsense_text_color']);?>
- </div>
- <div class="row">
- <h4>
- <?php echo Kohana::lang('adsense.uri_color')?>
- </h4>
- <?php print form::input('adsense_uri_color',$form['adsense_uri_color']);?>
- </div>
+
<div class="row">
<h4>
<?php echo Kohana::lang('adsense.ad_placement')?>
@@ -104,13 +66,5 @@
'3' => Kohana::lang('adsense.placement_footer'),
'4'=> Kohana::lang('adsense.placement_in_report')),$form['adsense_ad_placement']);?>
</div>
-
- <div class="row">
- <h4>
- <?php echo Kohana::lang('adsense.ad_type')?>
- </h4>
- <?php print form::dropdown('adsense_ad_type',
- Kohana::config('adsense.ad_type'),$form['adsense_ad_type']);?>
- </div>
</p>
- </div>
+</div>
View
79 views/admin/adsense_settings_js.php
@@ -1,79 +0,0 @@
-$(document).ready(function() {
- $('#adsense_border_color').ColorPicker({
- onSubmit: function(hsb, hex, rgb) {
- $('#adsense_border_color').val(hex);
- },
- onChange: function(hsb, hex, rgb) {
- $('#adsense_border_color').val(hex);
- },
- onBeforeShow: function () {
- $(this).ColorPickerSetColor(this.value);
- }
- })
- .bind('keyup', function(){
- $(this).ColorPickerSetColor(this.value);
- });
-
- $('#adsense_bg_color').ColorPicker({
- onSubmit: function(hsb, hex, rgb) {
- $('#adsense_bg_color').val(hex);
- },
- onChange: function(hsb, hex, rgb) {
- $('#adsense_bg_color').val(hex);
- },
- onBeforeShow: function () {
- $(this).ColorPickerSetColor(this.value);
- }
- })
- .bind('keyup', function(){
- $(this).ColorPickerSetColor(this.value);
- });
-
- $('#adsense_link_color').ColorPicker({
- onSubmit: function(hsb, hex, rgb) {
- $('#adsense_link_color').val(hex);
- },
- onChange: function(hsb, hex, rgb) {
- $('#adsense_link_color').val(hex);
- },
- onBeforeShow: function () {
- $(this).ColorPickerSetColor(this.value);
- }
- })
- .bind('keyup', function(){
- $(this).ColorPickerSetColor(this.value);
- });
-
- $('#adsense_text_color').ColorPicker({
- onSubmit: function(hsb, hex, rgb) {
- $('#adsense_text_color').val(hex);
- },
- onChange: function(hsb, hex, rgb) {
- $('#adsense_text_color').val(hex);
- },
- onBeforeShow: function () {
- $(this).ColorPickerSetColor(this.value);
- }
- })
- .bind('keyup', function(){
- $(this).ColorPickerSetColor(this.value);
- });
-
- $('#adsense_uri_color').ColorPicker({
- onSubmit: function(hsb, hex, rgb) {
- $('#adsense_uri_color').val(hex);
- },
- onChange: function(hsb, hex, rgb) {
- $('#adsense_uri_color').val(hex);
- },
- onBeforeShow: function () {
- $(this).ColorPickerSetColor(this.value);
- }
- })
- .bind('keyup', function(){
- $(this).ColorPickerSetColor(this.value);
- });
-
-
-});
-

0 comments on commit 8a445e9

Please sign in to comment.