pierre@1: nid; pierre@1: $values['title'] = $node->title; pierre@1: $values['description'] = $node->body; pierre@1: $values['log_message'] = $node->log; pierre@1: $values['type'] = $node->adtype; pierre@1: $values['status'] = $node->adstatus; pierre@1: $values['url'] = url('node/'. $node->nid, array('absolute' => TRUE)); pierre@1: $values['redirect'] = url($node->redirect, array('absolute' => TRUE)); pierre@1: $values['comments'] = $node->comment_count; pierre@1: pierre@1: if (isset($node->notification)) { pierre@1: $values['event'] = $node->notification->event; pierre@1: $values['frequency'] = t(strtolower($notifications[$node->notification->event]), array('@when' => format_interval($node->notification->delay))); pierre@1: } pierre@1: pierre@1: $values['created_small'] = format_date($node->created, 'small'); pierre@1: $values['created_medium'] = format_date($node->created, 'medium'); pierre@1: $values['created_large'] = format_date($node->created, 'large'); pierre@1: $values['activated_small'] = $node->activated ? format_date($node->activated, 'small') : t('never'); pierre@1: $values['activated_medium'] = $node->activated ? format_date($node->activated, 'medium') : t('never'); pierre@1: $values['activated_large'] = $node->activated ? format_date($node->activated, 'large') : t('never'); pierre@1: $values['expired_small'] = $node->expired ? format_date($node->expired, 'small') : t('never'); pierre@1: $values['expired_medium'] = $node->expired ? format_date($node->expired, 'medium') : t('never'); pierre@1: $values['expired_large'] = $node->expired ? format_date($node->expired, 'large') : t('never'); pierre@1: $values['autoactivate_small'] = $node->autoactivate ? format_date($node->autoactivate, 'small') : t('never'); pierre@1: $values['autoactivate_medium'] = $node->autoactivate ? format_date($node->autoactivate, 'medium') : t('never'); pierre@1: $values['autoactivate_large'] = $node->autoactivate ? format_date($node->autoactivate, 'large') : t('never'); pierre@1: $values['autoexpire_small'] = $node->autoexpire ? format_date($node->autoexpire, 'small') : t('never'); pierre@1: $values['autoexpire_medium'] = $node->autoexpire ? format_date($node->autoexpire, 'medium') : t('never'); pierre@1: $values['autoexpire_large'] = $node->autoexpire ? format_date($node->autoexpire, 'large') : t('never'); pierre@1: pierre@1: $statistics = ad_statistics($node->nid); pierre@1: // maximums pierre@1: $values['max_impressions'] = $node->maxviews; pierre@1: $values['max_clicks'] = $node->maxclicks; pierre@1: // global statistics pierre@1: $values['global_impressions'] = isset($statistics['global']) && !empty($statistics['global']) ? $statistics['global']['views'] : 0; pierre@1: $values['global_clicks'] = isset($statistics['global']) && !empty($statistics['global']) ? $statistics['global']['clicks'] : 0; pierre@1: // last year statistics pierre@1: $values['last_year_impressions'] = isset($statistics['last_year']) && !empty($statistics['last_year']) ? $statistics['last_year']['views'] : 0; pierre@1: $values['last_year_clicks'] = isset($statistics['last_year']) && !empty($statistics['last_year']) ? $statistics['last_year']['clicks'] : 0; pierre@1: // this year statistics pierre@1: $values['this_year_impressions'] = isset($statistics['this_year']) && !empty($statistics['this_year']) ? $statistics['this_year']['views'] : 0; pierre@1: $values['this_year_clicks'] = isset($statistics['this_year']) && !empty($statistics['this_year']) ? $statistics['this_year']['clicks'] : 0; pierre@1: // last month statistics pierre@1: $values['last_month_impressions'] = isset($statistics['last_month']) && !empty($statistics['last_month']) ? $statistics['last_month']['views'] : 0; pierre@1: $values['last_month_clicks'] = isset($statistics['last_month']) && !empty($statistics['last_month']) ? $statistics['last_month']['clicks'] : 0; pierre@1: // this month statistics pierre@1: $values['this_month_impressions'] = isset($statistics['this_month']) && !empty($statistics['this_month']) ? $statistics['this_month']['views'] : 0; pierre@1: $values['this_month_clicks'] = isset($statistics['this_month']) && !empty($statistics['this_month']) ? $statistics['this_month']['clicks'] : 0; pierre@1: // yesterday statistics pierre@1: $values['yesterday_impressions'] = isset($statistics['yesterday']) && !empty($statistics['yesterday']) ? $statistics['yesterday']['views'] : 0; pierre@1: $values['yesterday_clicks'] = isset($statistics['yesterday']) && !empty($statistics['yesterday']) ? $statistics['yesterday']['clicks'] : 0; pierre@1: // today statistics pierre@1: $values['today_impressions'] = isset($statistics['today']) && !empty($statistics['today']) ? $statistics['today']['views'] : 0; pierre@1: $values['today_clicks'] = isset($statistics['today']) && !empty($statistics['today']) ? $statistics['today']['clicks'] : 0; pierre@1: // last hour statistics pierre@1: $values['last_hour_impressions'] = isset($statistics['last_hour']) && !empty($statistics['last_hour']) ? $statistics['last_hour']['views'] : 0; pierre@1: $values['last_hour_clicks'] = isset($statistics['last_hour']) && !empty($statistics['last_hour']) ? $statistics['last_hour']['clicks'] : 0; pierre@1: // this hour statistics pierre@1: $values['this_hour_impressions'] = isset($statistics['this_hour']) && !empty($statistics['this_hour']) ? $statistics['this_hour']['views'] : 0; pierre@1: $values['this_hour_clicks'] = isset($statistics['this_hour']) && !empty($statistics['this_hour']) ? $statistics['this_hour']['clicks'] : 0; pierre@1: } pierre@1: break; pierre@1: case 'ad_owner': pierre@1: if (isset($object) && is_object($object)) { pierre@1: $owner = $object; pierre@1: $values['owner_name'] = $owner->name; pierre@1: $values['owner_mail'] = $owner->mail; pierre@1: $values['owner_uid'] = $owner->uid; pierre@1: } pierre@1: break; pierre@1: } pierre@1: return $values; pierre@1: } pierre@1: pierre@1: /** pierre@1: * Implementation of hook_token_list(). pierre@1: */ pierre@1: function ad_token_list($type = 'all') { pierre@1: if ($type == 'ad' || $type == 'all') { pierre@1: $tokens['ad']['aid'] = t('The ID of the advertisement.'); pierre@1: $tokens['ad']['type'] = t('The type of ad.'); pierre@1: $tokens['ad']['status'] = t('The status of the ad.'); pierre@1: $tokens['ad']['url'] = t('The url of the advertisement.'); pierre@1: $tokens['ad']['redirect'] = t('The redirection url of the advertisement.'); pierre@1: $tokens['ad']['event'] = t('The type of event that has triggered this notification.'); pierre@1: $tokens['ad']['frequency'] = t('A complete sentence describing the frequency this notification will be sent.'); pierre@1: $tokens['ad']['title'] = t('The title of the advertisement.'); pierre@1: $tokens['ad']['comments'] = t('The number of comments attached to the advertisement.'); pierre@1: pierre@1: $tokens['ad']['created_small'] = t('"Small" date format of when the advertisement was created.'); pierre@1: $tokens['ad']['created_medium'] = t('"Medium" date format of when the advertisement was created.'); pierre@1: $tokens['ad']['created_large'] = t('"Large" date format of when the advertisement was created.'); pierre@1: $tokens['ad']['activated_small'] = t('"Small" date format when the advertisement was activated.'); pierre@1: $tokens['ad']['activated_medium'] = t('"Medium" date format of when the advertisement was activated.'); pierre@1: $tokens['ad']['activated_large'] = t('"Large" date format of when the advertisement was activated.'); pierre@1: $tokens['ad']['expired_small'] = t('"Small" date format of when the advertisement was expired.'); pierre@1: $tokens['ad']['expired_medium'] = t('"Medium" date format of when the advertisement was expired.'); pierre@1: $tokens['ad']['expired_large'] = t('"Large" date format of when the advertisement was expired.'); pierre@1: $tokens['ad']['autoactivate_small'] = t('"Small" date format of when the advertisement was automatically activated.'); pierre@1: $tokens['ad']['autoactivate_medium'] = t('"Medium" date format of when the advertisement was automatically activated.'); pierre@1: $tokens['ad']['autoactivate_large'] = t('"Large" date format of when the advertisement was automatically activated.'); pierre@1: $tokens['ad']['autoexpire_small'] = t('"Small" date format of when the advertisement was automatically expired.'); pierre@1: $tokens['ad']['autoexpire_medium'] = t('"Medium" date format of when the advertisement was automatically expired.'); pierre@1: $tokens['ad']['autoexpire_large'] = t('"Large" date format of when the advertisement was automatically expired.'); pierre@1: pierre@1: $tokens['ad']['max_impressions'] = t('The maximum number of times this advertisement is allowed to be viewed.'); pierre@1: $tokens['ad']['max_clicks'] = t('The maximum number of times this advertisement is allowed to be clicked.'); pierre@1: $tokens['ad']['global_impressions'] = t('All time impression statistics'); pierre@1: $tokens['ad']['global_clicks'] = t('All time click statistics.'); pierre@1: $tokens['ad']['last_year_impressions'] = t('Ad impressions last year.'); pierre@1: $tokens['ad']['last_year_clicks'] = t('Ad clicks last year.'); pierre@1: $tokens['ad']['this_year_impressions'] = t('Ad impressions this year.'); pierre@1: $tokens['ad']['this_year_clicks'] = t('Ad clicks this year.'); pierre@1: $tokens['ad']['last_month_impressions'] = t('Ad impressions last month.'); pierre@1: $tokens['ad']['last_month_clicks'] = t('Ad clicks this month.'); pierre@1: $tokens['ad']['this_month_impressions'] = t('Ad impressions this month.'); pierre@1: $tokens['ad']['this_month_clicks'] = t('Ad clicks this month.'); pierre@1: $tokens['ad']['yesterday_impressions'] = t('Ad impressions yesterday.'); pierre@1: $tokens['ad']['yesterday_clicks'] = t('Ad clicks yesterday.'); pierre@1: $tokens['ad']['today_impressions'] = t('Ad impressions today.'); pierre@1: $tokens['ad']['today_clicks'] = t('Ad clicks today.'); pierre@1: $tokens['ad']['last_hour_impressions'] = t('Ad impressions last hour.'); pierre@1: $tokens['ad']['last_hour_clicks'] = t('Ad clicks this hour.'); pierre@1: $tokens['ad']['this_hour_impressions'] = t('Ad impressions this hour.'); pierre@1: $tokens['ad']['this_hour_clicks'] = t('Ad clicks this hour.'); pierre@1: } pierre@1: if ($type == 'ad' || $type == 'all') { pierre@1: $tokens['Ad owner']['owner_name'] = t('The username of the ad owner.'); pierre@1: $tokens['Ad owner']['owner_mail'] = t('The email address of the ad owner.'); pierre@1: $tokens['Ad owner']['owner_uid'] = t('The user ID of the ad owner.'); pierre@1: } pierre@1: return $tokens; pierre@1: }