Mercurial > defr > drupal > ad
comparison ad.module @ 8:32c1a7d9e1fa ad tip
maj module ad en 2.1
| author | sly | 
|---|---|
| date | Fri, 11 Sep 2009 11:10:20 +0000 | 
| parents | 6aeff3329e01 | 
| children | 
   comparison
  equal
  deleted
  inserted
  replaced
| 7:6aeff3329e01 | 8:32c1a7d9e1fa | 
|---|---|
| 1 <?php | 1 <?php | 
| 2 // $Id: ad.module,v 1.2.2.29.2.83.2.16.2.23 2009/07/06 21:47:49 jeremy Exp $ | 2 // $Id: ad.module,v 1.2.2.29.2.83.2.16.2.26 2009/08/05 00:13:36 jeremy Exp $ | 
| 3 | 3 | 
| 4 /** | 4 /** | 
| 5 * @file | 5 * @file | 
| 6 * An advertising system for Drupal powered websites. | 6 * An advertising system for Drupal powered websites. | 
| 7 * | 7 * | 
| 183 } | 183 } | 
| 184 break; | 184 break; | 
| 185 } | 185 } | 
| 186 | 186 | 
| 187 if (user_access('show advertisements')) { | 187 if (user_access('show advertisements')) { | 
| 188 if (isset($options['div']) && $options['div'] !== FALSE) { | 188 return theme('ad_display', $group, $output, $options['ad_display']); | 
| 189 return theme('ad_display', $group, $output, $options['ad_display']); | |
| 190 } | |
| 191 else { | |
| 192 return theme('ad_display', $group, $output, 'raw'); | |
| 193 } | |
| 194 } | 189 } | 
| 195 else { | 190 else { | 
| 196 return theme('ad_display', 'none', "<!-- Enable 'show advertisements' permission if you wish to display ads here. -->"); | 191 return theme('ad_display', 'none', "<!-- Enable 'show advertisements' permission if you wish to display ads here. -->"); | 
| 197 } | 192 } | 
| 198 } | 193 } | 
| 597 '#type' => 'textfield', | 592 '#type' => 'textfield', | 
| 598 '#title' => t('Title'), | 593 '#title' => t('Title'), | 
| 599 '#required' => TRUE, | 594 '#required' => TRUE, | 
| 600 '#default_value' => isset($node->title) ? $node->title : '', | 595 '#default_value' => isset($node->title) ? $node->title : '', | 
| 601 ); | 596 ); | 
| 602 $form['body_filter']['body'] = array( | 597 if ($type->has_body) { | 
| 603 '#type' => 'textarea', | 598 $form['body_filter']['body'] = array( | 
| 604 '#title' => t('Description'), | 599 '#type' => 'textarea', | 
| 605 '#default_value' => isset($node->body) ? $node->body : '', | 600 '#title' => t('Description'), | 
| 606 '#rows' => 3 | 601 '#default_value' => isset($node->body) ? $node->body : '', | 
| 607 ); | 602 '#rows' => 3 | 
| 603 ); | |
| 604 } | |
| 608 $form['body_filter']['format'] = filter_form($node->format); | 605 $form['body_filter']['format'] = filter_form($node->format); | 
| 609 | 606 | 
| 610 // determine the current ad type | 607 // determine the current ad type | 
| 611 if (!isset($adtype)) { | 608 if (!isset($adtype)) { | 
| 612 $adtypes = ad_get_types(); | 609 $adtypes = ad_get_types(); | 
| 613 if (sizeof($adtypes) == 1) { | 610 if (count($adtypes) == 1) { | 
| 614 $adtype = key($adtypes); | 611 $adtype = key($adtypes); | 
| 615 } | 612 } | 
| 616 else if (!sizeof($adtypes)) { | 613 else if (!count($adtypes)) { | 
| 617 drupal_set_message(t('At least one ad type module must be enabled before you can create advertisements. For example, try <a href="!url">enabling</a> the ad_text or ad_image module.', array('!url' => url('admin/build/modules'))), 'error'); | 614 drupal_set_message(t('At least one ad type module must be enabled before you can create advertisements. For example, try <a href="!url">enabling</a> the ad_text or ad_image module.', array('!url' => url('admin/build/modules'))), 'error'); | 
| 618 } | 615 } | 
| 619 } | 616 } | 
| 620 | 617 | 
| 621 // display ad type switch | 618 // display ad type switch | 
| 622 if (!isset($node->adtype) || isset($node->adtype_select)) { | 619 if ((!isset($node->adtype) || isset($node->adtype_select)) && | 
| 620 count($adtypes) >1) { | |
| 623 $adtypes = array(0 => '---'); | 621 $adtypes = array(0 => '---'); | 
| 624 $adtypes += ad_get_types('name'); | 622 $adtypes += ad_get_types('name'); | 
| 625 $form['select'] = array( | 623 $form['select'] = array( | 
| 626 '#type' => 'fieldset', | 624 '#type' => 'fieldset', | 
| 627 '#title' => t('Select Ad type'), | 625 '#title' => t('Select Ad type'), | 
| 644 'wrapper' => 'adtype-ahah-wrapper', | 642 'wrapper' => 'adtype-ahah-wrapper', | 
| 645 ), | 643 ), | 
| 646 ); | 644 ); | 
| 647 } | 645 } | 
| 648 // display type-specific options | 646 // display type-specific options | 
| 649 if (isset($node->adtype) && $node->adtype) { | 647 if ((isset($node->adtype) && $node->adtype) || count($adtypes) == 1) { | 
| 650 if (isset($node->adtype_select) && $node->adtype_select && ($node->adtype_select != $node->adtype)) { | 648 if (isset($node->adtype_select) && $node->adtype_select && ($node->adtype_select != $node->adtype)) { | 
| 651 $node->adtype = $node->adtype_select; | 649 $node->adtype = $node->adtype_select; | 
| 650 } | |
| 651 if (count($adtypes) == 1) { | |
| 652 $node->adtype = $adtype; | |
| 652 } | 653 } | 
| 653 ad_form_add_adtype_elements($form, $node->adtype, $node); | 654 ad_form_add_adtype_elements($form, $node->adtype, $node); | 
| 654 // add ahah wrapper | 655 // add ahah wrapper | 
| 655 $form['adtype_elements']['#prefix'] = '<div id="adtype-ahah-wrapper">'; | 656 $form['adtype_elements']['#prefix'] = '<div id="adtype-ahah-wrapper">'; | 
| 656 $form['adtype_elements']['#suffix'] = '</div>'; | 657 $form['adtype_elements']['#suffix'] = '</div>'; | 
