/** * функция по умолчанию * * @return ничего не возвращает */ public function index() { $this->load->model('groups', '', TRUE); $this->groups->end_fl_status(); if (is_null($this->id_campaign)) { if (is_null($this->id_group)) { $usercode = type_to_str($this->user_id, 'textcode'); $node = 'user' . $usercode; $startitem = "show_campaigns('{$usercode}');"; } else { $node = 'group' . $this->id_group; $id_campaign_type = $this->groups->group_type(type_cast($this->id_group, 'textcode')); $startitem = "show_ads('{$this->id_group}', '', '{$id_campaign_type}');"; } } else { $node = 'camp' . $this->id_campaign; $id_campaign = type_cast($this->id_campaign, 'textcode'); $id_campaign_type = $this->groups->campaign_type($id_campaign); $startitem = "show_groups('{$this->id_campaign}', '{$id_campaign_type}');"; } $vars = array('TREE' => $this->groups->get_html_tree($this->user_id, $this->user_name), 'TABLE' => 'table', 'STARTITEM' => $startitem, 'NODE' => $node, 'TAB' => $this->tab, 'NUMBERFORMAT' => get_number_format()); $vars['PLUGIN_COLOR_HINT'] = implode($this->plugins->run('get_colors_hint_html', $this)); $vars['PLUGIN_JS_FUNCTIONS'] = implode($this->plugins->run('get_js_functions_html', $this)); $plugin_controller = ''; foreach ($this->plugins->run('get_controller', $this) as $controllers) { foreach ($controllers as $id_campaign_type => $return_value) { $plugin_controller .= " case '{$id_campaign_type}': return {$return_value}; "; } } $vars['PLUGIN_CONTROLLER'] = $plugin_controller; $this->_set_content($this->parser->parse('advertiser/manage_ads/template.html', $vars, TRUE)); $this->_display(); }
public function index() { //$this->get_current_step(uri_string()); $this->setCurrentStep(uri_string()); $code = $this->input->post('id'); $id_campaign = type_cast($code, 'textcode'); $this->load->model('languages'); $this->load->model('countries'); $this->load->model('campaigns', '', TRUE); $this->load->model('schedule', '', TRUE); $info = $this->campaigns->info($id_campaign); if ('cpm_flatrate' == $info['id_campaign_type']) { $this->content['CPM_FLATRATE'] = array(array()); } else { $this->content['CPM_FLATRATE'] = array(); } //Рекламодатель может выбирать для рекламы только те страны, которые не заблокированы в системе? тогда get_list(array('filter' => 'enabled')) $this->targeting_all_list->countries = $this->countries->get_list(array('filter' => 'enabled')); $this->targeting_all_list->languages = $this->languages->get_list(array('filter' => 'enabled')); $tmp = $this->campaigns->get_list(array('id_advertiser' => $this->user_id)); $campaigns_list[''] = __("Select campaign to load targeting from"); foreach ($tmp as $key => $value) { $campaigns_list[type_to_str($key, 'textcode')] = type_to_str($value, 'encode'); } unset($tmp); $campaign = type_to_str($this->campaigns->name(type_cast($code, 'textcode')), 'encode'); $form = array("id" => $code, "name" => "name_date_form", "view" => "advertiser/manage_ads/campaigns/create_step_main.html", 'redirect' => 'advertiser/edit_campaign/success', 'REVIEW_MODE' => false, "vars" => array('CAMPAIGN_SCHEME' => $this->load->view('advertiser/manage_ads/campaigns/campaign_scheme.html', '', TRUE), 'NUMBERFORMAT' => get_number_format(), 'TIME_HOURS_FORMAT' => substr_count(get_time_format(), 'A') > 0 ? '12' : '24', 'TARGETING_ALL_LIST' => json_encode($this->targeting_all_list), 'CAMPAIGNS_LIST' => json_encode($campaigns_list), 'TIMEZONE' => sprintf(__("Scheduling runs at server time. Server is set for <b>%s</b> time zone. At the moment server time is <b>%s</b>."), gmdate('T') . date('P'), date('H:i')), 'PROGRESS_BAR' => '<h1><a href="<%SITEURL%><%INDEXPAGE%>advertiser/manage_ads">' . __('Manage Ads') . ' </a> → ' . __('Edit Campaign') . ': <span class="green i">„' . $campaign . '“</span></h1>'), "fields" => array("campaign_name" => array("display_name" => __("Campaign Name"), "id_field_type" => "string", "form_field_type" => "text", "validation_rules" => "required", "max" => 50), "targeting" => array("id_field_type" => "string", "form_field_type" => "hidden", "validation_rules" => "required"), "schedule" => array("id_field_type" => "string", "form_field_type" => "hidden", "validation_rules" => "required"), "id_targeting_group" => array("id_field_type" => "string", "form_field_type" => "hidden", "validation_rules" => "required"), "id_targeting_group_temp" => array("id_field_type" => "string", "form_field_type" => "hidden", "validation_rules" => "required"), "targeting_type" => array("id_field_type" => "string", "form_field_type" => "hidden", "validation_rules" => "required"))); $content = $this->form->get_form_content('modify', $form, $this->input, $this); $this->_set_content($content); $this->_display(); }
/** * Отображение формы задания названия группы в кампании * * @param string $campaign_type тип создаваемой кампании */ public function index($campaign_type) { $error_message = ''; $this->review_mode = $this->input->post('review_mode'); $this->new_campaign->init_storage($this->id_xml); $this->set_campaign_type($campaign_type); $this->setCurrentStep(uri_string()); if (count($this->new_campaign->get_sites_channels(array('status' => 'old'))) + count($this->new_campaign->get_sites_channels(array('status' => 'new'))) == 0) { $this->next_step = uri_string(); $error_message = __('At least one Site/Channel is required'); } $cost = $this->new_campaign->get_sites_channels_new_cost(); $ballance = $this->entity->ballance($this->user_id); $temp = $cost - $ballance; if ($temp > 0) { $this->next_step = uri_string(); $error_message = __('You can not create a new campaign, because you have insufficient funds in the account. Make a deposit and then try again.'); } if (is_null($this->next_step)) { $this->next_step = $this->get_next_step_controller(); } $form = array("id" => $campaign_type, "name" => "set_pricing_form", "vars" => array('REVIEW_MODE' => $this->review_mode, 'HIDE_OLD_SITES_CHANNELS' => $this->hide_old_sites_channels ? 'style="display:none;"' : '', 'NUMBERFORMAT' => get_number_format(), 'MONEYFORMAT' => get_money_format(), 'CAMPAIGN_TYPE' => $campaign_type, 'ERROR_MESSAGE' => '' != $error_message ? $this->parser->parse('advertiser/manage_ads/campaigns/creation/set_pricing/error.html', array('ERROR' => $error_message), FALSE) : '', 'CAMPAIGN_SCHEME' => $this->load->view('advertiser/manage_ads/campaigns/campaign_scheme.html', '', TRUE)), "view" => "advertiser/manage_ads/campaigns/creation/set_pricing/body.html", "redirect" => $this->next_step, "fields" => array("daily_impressions" => array("display_name" => __("Daily Impressions"), "id_field_type" => "string", "form_field_type" => "text", "validation_rules" => "positive|integer"))); $content = $this->form->get_form_content('modify', $form, $this->input, $this); $this->_set_content($content); $this->_display(); }
public function index($campaign_type) { $this->load->model('languages'); $this->load->model('countries'); $this->load->model('campaigns'); if ('cpm_flatrate' == $campaign_type) { $this->content['CPM_FLATRATE'] = array(array()); } else { $this->content['CPM_FLATRATE'] = array(); } $add_site_channel = $this->session->userdata('add_site_channel'); if (FALSE !== $add_site_channel) { $this->load->model('site'); $add_site_channel = json_decode($add_site_channel); if ($campaign_type == $add_site_channel->program_type) { switch ($add_site_channel->program_type) { case 'cpc': $id_site = type_cast($add_site_channel->site_code, 'textcode'); $site_info = $this->site->get_info($id_site); if (!is_null($site_info)) { $this->_set_notification(sprintf(__('Site „%s (%s)“ choosed by you in Site Directory will be added on „Select Sites“ step'), type_to_str($site_info->name, 'encode'), $site_info->url)); } break; case 'cpm_flatrate': $this->load->model('channel'); $id_site = type_cast($add_site_channel->site_code, 'textcode'); $id_channel = type_cast($add_site_channel->channel_code, 'textcode'); $site_info = $this->site->get_info($id_site); $channel_info = $this->channel->get_info($id_channel); if (!is_null($site_info) && !is_null($channel_info)) { $this->load->model('sites_channels'); $site_channel_info = $this->sites_channels->get_id_site_channel($id_site, $id_channel); if (!is_null($site_channel_info)) { $this->_set_notification(sprintf(__('Channel „%s“ at site „%s (%s)“ choosed by you in Site Directory will be added on „Select Sites/Channels“ step'), type_to_str($channel_info->name, 'encode'), type_to_str($site_info->name, 'encode'), $site_info->url)); } } break; } } } //Рекламодатель может выбирать для рекламы только те страны, которые не заблокированы в системе? тогда get_list(array('filter' => 'enabled')) $this->targeting_all_list->countries = $this->countries->get_list(array('filter' => 'enabled')); $this->targeting_all_list->languages = $this->languages->get_list(array('filter' => 'enabled')); $this->set_campaign_type($campaign_type); //$this->get_current_step(uri_string()); $this->setCurrentStep(uri_string()); $tmp = $this->campaigns->get_list(array('id_advertiser' => $this->user_id)); $this->review_mode = $this->input->post('review_mode'); if ($this->review_mode) { $form_caption = __('Edit Campaign'); } else { $form_caption = __('Create Campaign'); } $form = array("id" => $campaign_type, "name" => "name_date_form", "view" => "advertiser/manage_ads/campaigns/create_step_main.html", "redirect" => $this->get_next_step_controller(), "vars" => array('TARGETING_ALL_LIST' => json_encode($this->targeting_all_list), 'NUMBERFORMAT' => get_number_format(), 'TIME_HOURS_FORMAT' => substr_count(get_time_format(), 'A') > 0 ? '12' : '24', 'FORM_CAPTION' => $form_caption, 'REVIEW_MODE' => $this->review_mode, 'TIMEZONE' => sprintf(__("Scheduling runs at server time. Server is set for <b>%s</b> time zone. At the moment server time is <b>%s</b>."), gmdate('T') . date('P'), date('H:i')), 'CAMPAIGN_SCHEME' => $this->load->view('advertiser/manage_ads/campaigns/campaign_scheme.html', '', TRUE)), "fields" => array("campaign_name" => array("display_name" => __("Campaign Name"), "id_field_type" => "string", "form_field_type" => "text", "validation_rules" => "required", "max" => 50), "targeting" => array("id_field_type" => "string", "form_field_type" => "hidden"), "schedule" => array("id_field_type" => "string", "form_field_type" => "hidden", "validation_rules" => "required"), "id_targeting_group" => array("id_field_type" => "string", "form_field_type" => "hidden", "validation_rules" => "required"), "id_targeting_group_temp" => array("id_field_type" => "string", "form_field_type" => "hidden", "validation_rules" => "required"), "targeting_type" => array("id_field_type" => "string", "form_field_type" => "hidden", "validation_rules" => "required"))); $content = $this->form->get_form_content('modify', $form, $this->input, $this); $this->_set_content($content); $this->_display(); }
/** * показывает форму для изменения платежного шлюза * * @param $id - идентификатор редактируемой новости, если null - создание новости * @return ничего не возвращает */ public function index($id = null) { if (!is_null($id)) { $this->payment_gateway_id = $id; $this->info = $this->payment_gateways->get_edit_info($id); } else { redirect('admin/manage_payment_gateways'); } $form = array("name" => 'edit_payment_gateway_form', "id" => $this->payment_gateway_id, "vars" => array('ACCOUNT_ID_1_TITLE' => $this->info->account_id_1_title, 'ACCOUNT_ID_2_TITLE' => $this->info->account_id_2_title, 'ACCOUNT_ID_3_TITLE' => $this->info->account_id_3_title, 'GATEWAY_NAME' => $this->payment_gateways->get_name($this->payment_gateway_id), 'MONEYFORMAT' => get_money_format(), 'NUMBERFORMAT' => get_number_format()), "view" => "admin/settings/manage_payment_gateways/edit.html", "redirect" => 'admin/edit_payment_gateways/edit_complete', 'kill' => array($this->info->use_textarea ? 'useinput' : 'usetextarea'), "fields" => array("account_id1" => array("display_name" => __($this->info->account_id_1_title), "id_field_type" => "string", "form_field_type" => "text", "validation_rules" => $this->info->validation_rules_1), "used_for" => array("display_name" => __("Used For"), "id_field_type" => "string", "form_field_type" => "select", "validation_rules" => "required"), "fund_comm" => array("display_name" => __("Fund Commission"), "id_field_type" => "integer", "form_field_type" => "text", "validation_rules" => "integer|non_negative"), "withdraw_comm" => array("display_name" => __("Withdraw Commission"), "id_field_type" => "integer", "form_field_type" => "text", "validation_rules" => "float|non_negative"), "minimal_payment" => array("display_name" => __("Minimal payment"), "id_field_type" => "float", "form_field_type" => "text", "validation_rules" => "float[2]|non_negative"))); if ($this->publishers_is_enabled) { switch ($this->info->possibility_mode) { case 'deposit': $form['fields']['used_for']['options'] = array('deposit' => __('Deposit')); $form['fields']['used_for']['default'] = 'deposit'; break; case 'withdraw': $form['fields']['used_for']['options'] = array('withdraw' => __('Withdraw')); $form['fields']['used_for']['default'] = 'withdraw'; break; case 'all': $form['fields']['used_for']['options'] = array('deposit' => __('Deposit'), 'withdraw' => __('Withdraw'), 'both' => __('Deposit & Withdraw')); $form['fields']['used_for']['default'] = 'both'; } } else { $form['fields']['used_for']['options'] = array('deposit' => __('Deposit')); $form['fields']['used_for']['default'] = 'deposit'; } if ($this->info->use_account_id_2) { $form['fields']['account_id2'] = array("display_name" => __($this->info->account_id_2_title), "id_field_type" => "string", "form_field_type" => "text", "validation_rules" => $this->info->validation_rules_2); $form['vars']['ACCOUNT_ID_2_VISIBLE'] = ''; if ($this->info->max_2) { $form['fields']['account_id2']['max'] = $this->info->max_2; } } else { $form['vars']['ACCOUNT_ID_2_VISIBLE'] = 'style="display:none"'; } if ($this->info->use_account_id_3) { $form['fields']['account_id3'] = array("display_name" => __($this->info->account_id_3_title), "id_field_type" => "string", "form_field_type" => "text", "validation_rules" => $this->info->validation_rules_3); $form['vars']['ACCOUNT_ID_3_VISIBLE'] = ''; if ($this->info->max_3) { $form['fields']['account_id3']['max'] = $this->info->max_3; } } else { $form['vars']['ACCOUNT_ID_3_VISIBLE'] = 'style="display:none"'; } if ($this->info->max_1) { $form['fields']['account_id1']['max'] = $this->info->max_1; } $this->_set_content($this->form->get_form_content("modify", $form, $this->input, $this)); $this->_display(); }
/** * Отображение формы выбора сайтов/каналов группы в кампании * * @param string $campaign_type тип создаваемой кампании */ public function index($campaign_type) { $this->set_campaign_type($campaign_type); $this->setCurrentStep(uri_string()); $this->review_mode = $this->input->post('review_mode'); $add_site_channel = $this->session->userdata('add_site_channel'); if (FALSE !== $add_site_channel) { $add_site_channel = json_decode($add_site_channel); if ('cpm_flatrate' == $add_site_channel->program_type) { $id_site = type_cast($add_site_channel->site_code, 'textcode'); $id_channel = type_cast($add_site_channel->channel_code, 'textcode'); $site_info = $this->site->get_info($id_site); $channel_info = $this->channel->get_info($id_channel); if (!is_null($site_info) && !is_null($channel_info)) { $this->load->model('sites_channels'); $site_channel_info = $this->sites_channels->get_id_site_channel($id_site, $id_channel); if (!is_null($site_channel_info)) { $this->load->model('channel_program'); $default_program = $this->channel_program->get_default_program(array('id_site_channel' => $site_channel_info->id_site_channel)); if (!is_null($default_program)) { $this->new_campaign->init_storage($this->id_xml); $this->new_campaign->add_site_channel(array('id_site_channel' => $site_channel_info->id_site_channel, 'id_program' => $default_program['id_program'], 'cost' => $default_program['cost'], 'volume' => $default_program['volume'], 'ad_type' => $default_program['ad_type'], 'is_autorenew' => 'false'), FALSE); //не перезаписывать настройки ранее добавленного сайта-канала $this->new_campaign->save_data(); $this->_set_notification(sprintf(__('Channel „%s“ at site „%s (%s)“ choosed by you in Site Directory was successfully appended to „Recently added channels“ list'), type_to_str($channel_info->name, 'encode'), type_to_str($site_info->name, 'encode'), $site_info->url)); } else { $this->_set_notification(sprintf(__('Due to error channel „%s“ at site „%s (%s)“ choosed by you in Site Directory was not appended to „Recently added channels“ list'), type_to_str($channel_info->name, 'encode'), type_to_str($site_info->name, 'encode'), $site_info->url), 'error'); } } else { $this->_set_notification(sprintf(__('Due to error channel „%s“ at site „%s (%s)“ choosed by you in Site Directory was not appended to „Recently added channels“ list'), type_to_str($channel_info->name, 'encode'), type_to_str($site_info->name, 'encode'), $site_info->url), 'error'); } } } $this->session->unset_userdata('add_site_channel'); } $categories_tree = $this->category_model->get_html_tree(); $form_data = array('name' => 'choose_sites_channels_form', 'view' => 'advertiser/manage_ads/campaigns/creation/step_choose_sites_channels/body.html', 'redirect' => $this->get_next_step_controller(), 'vars' => array('REVIEW_MODE' => $this->review_mode, 'NEXT_STEP_CONTROLLER' => $this->get_next_step_controller(), 'HIDE_OLD_SITES_CHANNELS' => $this->hide_old_sites_channels ? 'style="display:none;"' : '', 'CATEGORIES_TREE' => $categories_tree, 'MONEYFORMAT' => get_money_format(), 'NUMBERFORMAT' => get_number_format(), 'CAMPAIGN_SCHEME' => $this->load->view('advertiser/manage_ads/campaigns/campaign_scheme.html', '', TRUE)), "fields" => array("dummy" => array("id_field_type" => "hidden", "form_field_type" => "text"))); $content = $this->form->get_form_content('create', $form_data, $this->input, $this); $this->_set_content($content); $this->_display(); }
/** * функция по умолчанию, отображает формы для внесения платежей * * @return ничего не возвращает */ public function index() { $LOG =& load_class('Log'); $LOG->write_log('ERROR', 'Add Funds Index'); $this->_set_title(implode(self::TITLE_SEP, array(__("Advertiser"), __("Add Funds")))); $this->_set_help_index("advertiser_add_funds"); $this->load->model('payment_gateways', '', TRUE); // $list = $this->payment_gateways->get_list(array('name' => TRUE, 'filter' => 'enabled')); $list = $this->payment_gateways->get_list(array('fields' => array('id_gateway', 'name', 'fund_comm', 'minimal_payment'), 'filter' => 'enabled', 'deposit' => 'true')); $forms = ''; $options = ''; $this->load->library("form"); $select_id = $this->input->post('id'); if (is_array($list)) { $row = current($list); include APPPATH . "controllers/common/gateways/paypal.php"; if (!isset($this->content['paypalNEEDAGREE'])) { $this->content['paypalNEEDAGREE'] = ''; } } $vars = array('GATEWAYFORMS' => $forms, 'LIST' => $options, 'MONEYFORMAT' => get_money_format(), 'NUMBERFORMAT' => get_number_format()); $this->_set_content($this->parser->parse('advertiser/add_funds/form.html', $vars, TRUE)); $this->_display(); }
/** * Отображение формы выбора сайтов/каналов группы в кампании * * @param string $campaign_type тип создаваемой кампании */ public function index($campaign_type) { $this->set_campaign_type($campaign_type); $this->setCurrentStep(uri_string()); $this->review_mode = $this->input->post('review_mode'); $this->new_campaign->init_storage($this->id_xml); $add_site_channel = $this->session->userdata('add_site_channel'); if (FALSE !== $add_site_channel) { $add_site_channel = json_decode($add_site_channel); if ('cpc' == $add_site_channel->program_type) { $id_site = type_cast($add_site_channel->site_code, 'textcode'); $site_info = $this->site->get_info($id_site); if (!is_null($site_info)) { if (FALSE != $this->new_campaign->add_site($id_site)) { $places = $this->new_campaign->get_places(); if (false !== ($index = array_search('allsites', $places))) { unset($places[$index]); } if (!in_array('sites', $places)) { $places[] = 'sites'; } $this->new_campaign->set_places($places); $this->new_campaign->save_data(); $this->_set_notification(sprintf(__('Site „%s (%s)“ choosed by you in Site Directory was successfully appended to „Added Sites“ list'), type_to_str($site_info->name, 'encode'), $site_info->url)); } else { $this->_set_notification(sprintf(__('Due to error site „%s (%s)“ choosed by you in Site Directory was not appended to „Added Sites“ list'), type_to_str($site_info->name, 'encode'), $site_info->url), 'error'); } } } $this->session->unset_userdata('add_site_channel'); } $categories_tree = $this->category_model->get_html_tree(); if (is_null($this->next_step)) { $hide_navbar = false; $this->next_step = $this->get_next_step_controller(); } else { $hide_navbar = true; } $form_data = array('id' => $campaign_type, 'name' => 'select_sites_form', 'view' => 'advertiser/manage_ads/campaigns/creation/select_sites/body.html', 'redirect' => $this->next_step, 'vars' => array('REVIEW_MODE' => $this->review_mode, 'CATEGORIES_TREE' => $categories_tree, 'MONEYFORMAT' => get_money_format(), 'NUMBERFORMAT' => get_number_format()), "fields" => array("dummy" => array("id_field_type" => "hidden", "form_field_type" => "text"), "sites_range" => array("id_field_type" => "string", "form_field_type" => "radio"))); if ($hide_navbar) { $form_data['vars']['PROGRESS_BAR'] = ''; } $places = $this->new_campaign->get_places(); $all_places = array_merge(array('allsites'), $this->plugins->run('getPlace', $this)); /* * По умолчанию places установлено как allsites, * но нужно поставить все галочки на этой странице, * поэтому если в плэйсах только оллсайт - убираем его и * заполняем всеми доступными местами */ if ((!isset($this->edit_step) || !$this->edit_step) && count($places) == 1 && in_array('allsites', $places)) { $places = $all_places; $this->new_campaign->set_places($places); $this->new_campaign->save_data(); } $sites = $this->new_campaign->get_sites(); $sites_count = count($sites); $plugin_places = $this->plugins->run('getPlaceHtml', $this); $plugin_places_html = implode($plugin_places); $this->places_count = count($plugin_places) + 1; $allplaces = count($places) == count($all_places) && $sites_count == 0 ? 'true' : 'false'; $content = $this->form->get_form_content('modify', $form_data, $this->input, $this); $content = str_replace('<%PLUGINPLACES%>', $plugin_places_html, $content); $content = str_replace('<%YOUR_BID_VALUE%>', type_to_str($this->new_campaign->get_default_bid('text'), 'float'), $content); $content = str_replace('<%YOUR_BID_IMAGE_VALUE%>', type_to_str($this->new_campaign->get_default_bid('image'), 'float'), $content); $content = str_replace('<%SITESCHECKED%>', in_array('sites', $places) || in_array('allsites', $places) ? 'checked="checked"' : '', $content); $content = str_replace('<%SEARCHESCHECKED%>', in_array('searches', $places) ? 'checked="checked"' : '', $content); /* PLUGINS */ $content = str_replace('<%DOMAINSCHECKED%>', in_array('domains', $places) || $this->checkAllPlace($places) ? 'checked="checked"' : '', $content); $content = str_replace('<%INTEXTCHECKED%>', in_array('intext', $places) || $this->checkAllPlace($places) ? 'checked="checked"' : '', $content); $content = str_replace('<%ALLSITESCHECKED%>', $sites_count ? '' : 'checked="checked"', $content); $content = str_replace('<%CHOOSEDSITESCHECKED%>', $sites_count ? 'checked="checked"' : '', $content); $content = str_replace('<%ALLPLACES%>', $allplaces, $content); // есть ли сайты $network_sites = $this->new_campaign->get_sites(); $content = str_replace('<%HAVESITES_NETWORK%>', count($network_sites) ? 'true' : 'false', $content); $content = str_replace('<%HAVESITES_NETWORK_QTY%>', count($network_sites), $content); $content = str_replace('<%HAVESITES_INTEXT%>', 'false', $content); $content = str_replace('<%HAVESITES_INTEXT_QTY%>', 0, $content); $daily_budget = $this->new_campaign->get_daily_budget(); if (is_null($daily_budget)) { $daily_budget = __('undefined'); } else { $daily_budget = type_to_str($daily_budget, 'float'); } $this->_set_content($content); $this->_display(); }
/** * Отображение страницы с предпросмотром созданных объявлений * * @param string $campaign_type тип создаваемой кампании */ public function index($campaign_type) { $tmp = $this->campaigns->get_list(array('id_advertiser' => $this->user_id)); $campaigns_list[''] = __("Select campaign to load targeting from"); foreach ($tmp as $key => $value) { $campaigns_list[type_to_str($key, 'textcode')] = type_to_str($value, 'encode'); } //Рекламодатель может выбирать для рекламы только те страны, которые не заблокированы в системе? тогда get_list(array('filter' => 'enabled')) $this->targeting_all_list->countries = $this->countries->get_list(array('filter' => 'enabled')); $error_message = ''; $this->set_campaign_type($campaign_type); $this->setCurrentStep(uri_string()); if (!$this->input->post('confirm_creation')) { $targeting_id = $this->new_campaign->get_targeting(); $targeting_id_temp = $this->new_campaign->get_targeting(true); $this->targeting_groups->copy($targeting_id, $targeting_id_temp); } //изменение типа таргетинга в случае необходимости $this->set_targeting_type(); $this->new_campaign->init_storage($this->id_xml); $ads_list = $this->new_campaign->get_ads_list(); $ads_preview = ''; $this->db->select('cs.*, ft.name title_font_name, ft2.name text_font_name, ft3.name url_font_name', false); $this->db->from('color_schemes cs'); $this->db->join('fonts ft', 'ft.id_font = cs.title_id_font'); $this->db->join('fonts ft2', 'ft2.id_font = cs.text_id_font'); $this->db->join('fonts ft3', 'ft3.id_font = cs.url_id_font'); $query = $this->db->get(); $row = $query->row(); foreach ($ads_list as $ad_id => $ad) { if ('text' == $ad->ad_type) { if ('cpa' != $campaign_type) { $ad_preview = $this->parser->parse('common/text_ad_example.html', array('TITLE' => type_to_str($ad->title, 'encode'), 'DESCRIPTION' => type_to_str($ad->description1, 'encode'), 'DESCRIPTION2' => type_to_str($ad->description2, 'encode'), 'DISPLAY_URL' => $ad->display_url, 'DESTINATION_URL' => $ad->destination_protocol . "://" . $ad->destination_url, 'BACKGROUND_COLOR' => $row->background_color, 'BORDER_COLOR' => $row->border_color, 'TITLE_COLOR' => $row->title_color, 'TITLE_FONT_NAME' => $row->title_font_name, 'TITLE_FONT_SIZE' => $row->title_font_size, 'TITLE_FONT_STYLE' => $row->title_font_style, 'TITLE_FONT_WEIGHT' => $row->title_font_weight, 'TEXT_COLOR' => $row->text_color, 'TEXT_FONT_NAME' => $row->text_font_name, 'TEXT_FONT_SIZE' => $row->text_font_size, 'TEXT_FONT_STYLE' => $row->text_font_style, 'TEXT_FONT_WEIGHT' => $row->text_font_weight, 'URL_COLOR' => $row->url_color, 'URL_FONT_NAME' => $row->url_font_name, 'URL_FONT_SIZE' => $row->url_font_size, 'URL_FONT_STYLE' => $row->url_font_style, 'URL_FONT_WEIGHT' => $row->url_font_weight), FALSE); } else { $ad_preview = $this->parser->parse('common/text_ad_cpa_example.html', array('TITLE' => type_to_str($ad->title, 'encode'), 'QUESTION' => type_to_str($ad->description1, 'encode'), 'QUESTION2' => type_to_str($ad->description2, 'encode'), 'EMAIL_TITLE' => $ad->email_title), FALSE); } } elseif ('image' == $ad->ad_type) { list($img_w, $img_h, $type, $attr) = getimagesize($this->config->item('path_to_campaign_creation_images') . $ad->image_id); if (13 == $type) { //Для флэша используем специальный шаблон $ad_preview = $this->parser->parse('common/image_ad_swf_example.html', array('TITLE' => type_to_str($ad->title, 'encode'), 'ID_IMAGE' => $ad->image_id, 'ID_SWF_CONTAINER' => str_replace('.', '', $ad->image_id), 'IMG_W' => $img_w, 'IMG_H' => $img_h, 'BGCOLOR' => $ad->bgcolor, 'DISPLAY_URL' => $ad->display_url, 'DESTINATION_URL' => $ad->destination_protocol . "://" . $ad->destination_url), FALSE); } else { $ad_preview = $this->parser->parse('common/image_ad_example.html', array('TITLE' => type_to_str($ad->title, 'encode'), 'ID_IMAGE' => $ad->image_id, 'DISPLAY_URL' => $ad->display_url, 'DESTINATION_URL' => $ad->destination_protocol . "://" . $ad->destination_url), FALSE); } } $ads_preview .= $this->parser->parse('advertiser/manage_ads/campaigns/creation/review_selections/ad_box.html', array('AD_PREVIEW' => $ad_preview, 'AD_ID' => $ad_id), FALSE); } $campaign_main_info = $this->new_campaign->get_name_date(); //определение настроек таргетинга $targeting_info = new Campaign_Targeting(); $id_targeting = $this->new_campaign->get_targeting(true); $targeting_type = $this->new_campaign->get_targeting_type(); $targeting_group_countries = $this->targeting_groups->get_group_list($id_targeting, 'countries'); foreach ($targeting_group_countries as $country) { $targeting_info->countries[] = $country['value']; } if (0 == count($targeting_info->countries)) { foreach ($this->targeting_all_list->countries as $iso => $country) { $targeting_info->countries[] = $iso; } } $group_name = $this->new_campaign->get_group_name(); $schedule = $this->new_campaign->get_schedule(); if ('cpm_flatrate' == $campaign_type) { $added_sites_channels = $this->new_campaign->get_sites_channels(array('status' => 'all')); $added_sites_channels_ids = array(); foreach ($added_sites_channels as $key => $value) { $added_sites_channels_ids[] = $key; } if (count($added_sites_channels_ids) > 0) { $this->load->model('channel'); $params = array('fields' => 'id_site_channel, channels.ad_type, channels.name as channel_name,' . ' sites.url as site_url, sites.name as site_name, sites.id_site,' . ' channels.id_channel, dimensions.name as dimension_name, channels.id_dimension,' . ' dimensions.width, dimensions.height', 'disable_site_ordering' => true, 'order_by' => 'site_url', 'order_direction' => 'asc', 'site_channel_id_filter' => $added_sites_channels_ids); $sites_channels_array = $this->channel->get_sites_channels($params); } else { $error_message = __("At least one channel must be added to campaign."); $sites_channels_array = array(); } $this->table_builder->clear(); $this->table_builder->insert_empty_cells = false; $data_rows_conut = sizeof($sites_channels_array); $this->table_builder->add_attribute('class', 'xTable'); $this->table_builder->set_cell_content(0, 0, __('Site')); $this->table_builder->set_cell_content(0, 1, __('Channel')); $this->table_builder->add_row_attribute(0, 'class', 'th'); $this->table_builder->add_col_attribute(0, 'class', 'simpleTitle'); $this->table_builder->add_col_attribute(1, 'class', 'simpleTitle'); $row_counter = 0; for ($i = 0; $i < $data_rows_conut; $i++) { $row_counter++; $this->table_builder->set_cell_content($row_counter, 0, type_to_str($sites_channels_array[$i]['site_name'], 'encode') . ' (<a target="_blank" href="http://' . $sites_channels_array[$i]['site_url'] . '">' . $sites_channels_array[$i]['site_url'] . '</a>)'); $this->table_builder->set_cell_content($row_counter, 1, type_to_str($sites_channels_array[$i]['channel_name'], 'encode')); } if (0 == $data_rows_conut) { $this->table_builder->set_cell_content(1, 0, __('Records not found')); $this->table_builder->cell(1, 0)->add_attribute('colspan', 2); $this->table_builder->cell(1, 0)->add_attribute('class', 'nodata'); } $channels_table = $this->table_builder->get_html(); // Проверяем, все ли нормально у кампании? $error_message = $this->new_campaign->check_ads(); if ('' == $error_message && $this->input->post('confirm_creation')) { $id_campaign = $this->create_campaign('cpm_flatrate'); if (is_numeric($id_campaign)) { redirect('advertiser/manage_ads/campaign/' . type_to_str($id_campaign, 'textcode')); return; } $error_message = $id_campaign; } $data = array('ERROR_MESSAGE' => '' != $error_message ? $this->parser->parse('advertiser/manage_ads/campaigns/creation/review_selections/error.html', array('ERROR' => $error_message), FALSE) : '', 'CAMPAIGN_NAME' => htmlentities($campaign_main_info['name'], ENT_COMPAT, "utf-8"), 'TARGETING_INFO' => json_encode($targeting_info), 'SCHEDULE' => json_encode($schedule), 'TARGETING_ALL_LIST' => json_encode($this->targeting_all_list), 'CAMPAIGNS_LIST' => json_encode($campaigns_list), 'GROUP_NAME' => htmlentities($group_name, ENT_COMPAT, "utf-8"), 'CAMPAIGN_COST' => type_to_str($this->new_campaign->get_campaign_cost(), 'money'), 'ACTIVE_TARGETING_TYPE' => $targeting_type, 'CHANNELS_PREVIEW' => $channels_table, 'EDIT_CAMP_MAIN_URL' => 'advertiser/create_campaign_step_main/index/cpm_flatrate', 'EDIT_GROUP_MAIN_URL' => 'advertiser/create_campaign_step_group_name/index/cpm_flatrate', 'EDIT_SITES_CHANNELS_URL' => 'advertiser/create_campaign_step_choose_sites_channels/index/cpm_flatrate', 'EDIT_SET_PRICING_URL' => 'advertiser/create_campaign_step_set_pricing/index/cpm_flatrate', 'EDIT_AD_URL' => 'advertiser/create_campaign_step_create_ad/index/cpm_flatrate', 'ADS_PREVIEW' => $ads_preview, 'CAMPAIGN_SCHEME' => $this->load->view('advertiser/manage_ads/campaigns/campaign_scheme.html', '', TRUE), 'NUMBERFORMAT' => get_number_format(), 'TARGETING_GROUP_ID_ENCODED' => type_to_str($id_targeting, 'textcode'), 'TIMEZONE' => sprintf(__("Scheduling runs at server time. Server is set for <b>%s</b> time zone. At the moment server time is <b>%s</b>."), gmdate('T') . date('P'), date('H:i')), 'TIME_HOURS_FORMAT' => substr_count(get_time_format(), 'A') > 0 ? '12' : '24'); $this->_set_content($this->parser->parse('advertiser/manage_ads/campaigns/creation/review_selections/body.html', $data, FALSE)); } $this->_display(); }
/** * показывает форму для изменения канала или его создания * * @param $id_channel - идентификатор канала * @param $program_type - тип программы * @return ничего не возвращает */ private function manage($id_channel = null, $program_type = null, $id_program = null) { $error_flag = false; $error_message = ''; if (!is_null($id_program)) { //Пробуем запустить процесс редактирования прайса $program_owner = $this->channel_program->get_program_owner($id_program); if (!$error_flag && is_numeric($program_owner) && $this->user_id != $program_owner) { $error_message = 'Access denied'; $error_flag = true; } $info = $this->channel_program->get_info($id_program); if (!$error_flag && is_null($info)) { $error_message = 'Channel program is not found!'; $error_flag = true; } if (!is_null($info)) { $id_channel = $info->id_channel; $program_type = $info->program_type; $mode = "modify"; $this->program_id = $id_program; } } else { //Проверка прав на создание прайса в канале if (!$error_flag && $this->user_id != $this->channel->get_channel_owner($id_channel)) { $error_message = 'Access denied'; $error_flag = true; } if (!$error_flag && !in_array($program_type, $this->supported_program_types)) { $error_message = 'Unsupported program type'; $error_flag = true; } $mode = "create"; } if ($error_flag) { $data = array('MESSAGE' => __($error_message), 'REDIRECT' => $this->site_url . $this->index_page . $this->role . '/manage_sites_channels'); $content = $this->parser->parse('common/errorbox.html', $data, FALSE); $this->_set_content($content); $this->_display(); return; } $channel_info = $this->channel->get_info($id_channel); $channel_info->ad_type = explode(',', $channel_info->ad_type); switch ($program_type) { case 'CPM': switch ($mode) { case 'create': $form_title = __('Create CPM prices for channel'); break; case 'modify': $form_title = __('Edit CPM prices for channel'); break; } $volume_title = 'Impressions'; break; case 'Flat_Rate': switch ($mode) { case 'create': $form_title = __('Create Flat Rate prices for channel'); break; case 'modify': $form_title = __('Edit Flat Rate prices for channel'); break; } $program_type = 'flat_rate'; $volume_title = 'Days'; break; } $this->ad_type = $channel_info->ad_type; $form = array("id" => $this->program_id, "name" => "channel_program_form", "view" => "common/manage_channel_prices/channel_program_form.html", "vars" => array('AD_TYPE' => json_encode($this->ad_type), 'FORM_TITLE' => $form_title, 'VOLUME_TITLE' => type_to_str($volume_title, 'encode'), 'ID_CHANNEL' => $id_channel, 'CHANNEL_NAME' => type_to_str($channel_info->name, 'encode')), "fields" => array("title" => array("display_name" => __("Title"), "id_field_type" => "string", "form_field_type" => "text", "validation_rules" => "required", "max" => 35), "volume" => array("display_name" => __($volume_title), "id_field_type" => "string", "form_field_type" => "text", "validation_rules" => "trim|required|integer|positive", "max" => 9), "type" => array("id_field_type" => "string", "form_field_type" => "hidden", "validation_rules" => "required", "default" => $program_type), "id_channel" => array("id_field_type" => "int", "form_field_type" => "hidden", "validation_rules" => "required|integer", "default" => $id_channel))); $adTypeLabels = array(); if (in_array(Sppc_Channel::AD_TYPE_TEXT, $channel_info->ad_type)) { $form['fields']['cost_text'] = array("display_name" => __("Cost Text Ad"), "id_field_type" => "float", "form_field_type" => "text", "validation_rules" => "required|float[2]|positive"); $adTypeLabels[] = __('Text'); $form['vars']['COST_IMAGE_AD_TEXT'] = ''; } if (in_array(Sppc_Channel::AD_TYPE_IMAGE, $channel_info->ad_type)) { $form['fields']['cost_image'] = array("display_name" => __("Cost Image Only Ad"), "id_field_type" => "float", "form_field_type" => "text", "validation_rules" => "required|float[2]|positive"); if (in_array(Sppc_Channel::AD_TYPE_TEXT, $channel_info->ad_type)) { $form['fields']['cost_image']['validation_rules'] = null; } $adTypeLabels[] = __('Image'); $form['vars']['COST_IMAGE_AD_TEXT'] = __('Cost Image Only Ad'); } switch ($mode) { case 'create': $form['vars']['APPLY_BTN_CAPTION'] = __("Create"); $form['redirect'] = $this->role . "/edit_channel_program/create_complete/" . $id_channel; break; case 'modify': $form['vars']['APPLY_BTN_CAPTION'] = __("Save"); $form['redirect'] = $this->role . "/edit_channel_program/edit_complete/" . $id_channel; break; } if (!in_array(Sppc_Channel::AD_TYPE_TEXT, $channel_info->ad_type)) { $this->max_ad_slots = 1; $slotsPreview = 'slots_' . $channel_info->id_dimension . '_1'; } else { $this->max_ad_slots = $channel_info->max_ad_slots; $slotsPreview = 'slots_' . $channel_info->id_dimension; } $form['vars']['AD_TYPE_STRING'] = implode(', ', $adTypeLabels); $form['vars']['AD_TYPE'] = json_encode($channel_info->ad_type); $form['vars']['CHANNEL_DIMENSIONS'] = $channel_info->width . '×' . $channel_info->height; $form['vars']['DIMENSION_NAME'] = $channel_info->dimension_name; $form['vars']['ID_DIMENSION'] = $channel_info->id_dimension; $form['vars']['SLOTS_PREVIEW'] = $slotsPreview; $form['vars']['MAX_AD_SLOTS'] = $this->max_ad_slots; $form['vars']['MONEYFORMAT'] = get_money_format(); $form['vars']['NUMBERFORMAT'] = get_number_format(); $this->_set_content($this->form->get_form_content($mode, $form, $this->input, $this)); $this->_display(); }
/** * показывает форму для изменения канала или его создания * * @param $id_channel - идентификатор редактируемого канала, если null - создание канала * @param $id_site - идентификатор сайта, для которого создается /редактируется канал * @return ничего не возвращает */ public function index() { $this->session->unset_userdata(get_class($this) . '_id_channel'); $site = null; $channel = null; $id_site = $this->input->post('id_site'); $id_channel = $this->input->post('id_channel'); $error_flag = false; $error_message = ''; $categories_tree = $this->category_model->get_html_tree(); if ($id_site !== false) { $siteModel = new Sppc_SiteModel(); $site = $siteModel->findObjectById($id_site); } if ($id_channel) { $this->channel_id = $id_channel; $channelModel = new Sppc_ChannelModel(); $channel = $channelModel->findObjectById($id_channel); if ($this->user_id != $this->channel->get_channel_owner($id_channel)) { $error_message = 'Access denied'; $error_flag = true; } $mode = "modify"; } else { if (is_null($site)) { $error_message = 'Site is not specified!'; $error_flag = true; } if (!$error_flag && $this->user_id != $site->getIdEntityPublisher()) { $error_message = 'Access denied'; $error_flag = true; } $mode = "create"; } if ($error_flag) { $data = array('MESSAGE' => __($error_message), 'REDIRECT' => $this->site_url . $this->index_page . $this->role . '/manage_sites_channels'); $content = $this->parser->parse('common/errorbox.html', $data, FALSE); $this->_set_content($content); $this->_display(); return NULL; } $available_dimensions = $this->dimension->get_list(array('name')); $dimensions_info = $this->dimension->get_list_all(); $max_ad_slots_info = array(); foreach ($dimensions_info as $dimension_info) { $max_ad_slots_info[$dimension_info['id_dimension']] = $dimension_info['max_ad_slots']; } if (false !== $this->input->post('categories')) { $categoryModel = new Sppc_CategoryModel(); $selectedCategories = $categoryModel->find(explode(',', $this->input->post('categories'))); } else { $selectedCategories = is_null($channel) ? array() : $channel->getCategories(); } $this->form_data = array("id" => $this->channel_id, "name" => "channel_form", "vars" => array('MAX_AD_SLOTS_INFO' => json_encode($max_ad_slots_info), 'NUMBERFORMAT' => get_number_format(), 'CATEGORY_SELECTOR' => render_category_selector_field($selectedCategories, 'categories', 'select_category_btn', 'selected_categories'), 'CATEGORIES_TREE' => $categories_tree, 'CHANNEL_ID' => is_null($channel) ? 'new' : type_to_str($channel->getId(), 'textcode')), "view" => $this->views_paths['channel_form'], "fields" => array("name" => array("display_name" => __("Channel Name"), "id_field_type" => "string", "form_field_type" => "text", 'validation_rules' => "trim|required", "max" => 35), "description" => array("display_name" => __("Channel Description"), "id_field_type" => "string", "form_field_type" => "textarea", "validation_rules" => "trim|required", "max" => 300), "category" => array("display_name" => __("Category"), "id_field_type" => "int", "form_field_type" => "hidden", "validation_rules" => "required"), 'ad_sources_advertisers' => array('display_name' => __('Ad Sources'), 'id_field_type' => 'bool', 'form_field_type' => 'checkbox', 'default' => 'true'), 'ad_sources_xml_feeds' => array('display_name' => __('Ad Sources'), 'id_field_type' => 'bool', 'form_field_type' => 'checkbox', 'default' => 'true', 'validation_rules' => $this->input->post('ad_sources_advertisers') != "true" ? "required" : ""), "ad_type_text" => array("display_name" => __("Ad Type"), "id_field_type" => "string", "form_field_type" => "checkbox", "default" => "text"), "ad_type_image" => array("display_name" => __("Ad Type"), "id_field_type" => "string", "form_field_type" => "checkbox", "default" => "", 'validation_rules' => $this->input->post('ad_type_text') != "text" ? "required" : ""), "format" => array("display_name" => __("Format"), "id_field_type" => "string", "form_field_type" => "select", "params" => array('fields' => 'id_dimension, name, orientation'), "options" => array('' => __('Select Channel Image format')), "validation_rules" => "required"), "channel_type" => array("display_name" => __("Channel Type"), "id_field_type" => "string", "form_field_type" => "radio", "default" => "contextual"), "id_channel" => array("display_name" => __("ID channel"), "id_field_type" => "string", "form_field_type" => "hidden", "default" => $id_channel), "ad_settings" => array("display_name" => __("Ad Settings"), "id_field_type" => "string", "form_field_type" => "radio", "validation_rules" => "required", "default" => "blank"), "tag_code" => array("display_name" => __("Html tag"), "id_field_type" => "string", "form_field_type" => "textarea", "validation_rules" => $this->input->post('ad_settings') == "tag" ? "required" : ""), "blank_color" => array("display_name" => __("Ad Settings Blank Color"), "id_field_type" => "string", "form_field_type" => "text", "default" => "", "validation_rules" => $this->input->post('ad_settings') == "blank_color" ? "required" : ""))); if (null !== $site) { $this->form_data['fields']['category']['default'] = $site->getCategory(); } $this->form_data['vars']['ID_CHANNEL'] = $this->channel_id; if ($this->input->post('redirect_after_save')) { $this->form_data['redirect'] = $this->input->post('redirect_after_save'); } switch ($mode) { case 'create': $this->form_data['fields']['format']['options'] = array_merge($this->form_data['fields']['format']['options'], $available_dimensions); $this->form_data['vars']['DISABLED_AD_TYPE'] = ''; $this->form_data['vars']['DISABLED_AD_TYPE_RADIO'] = ''; $this->form_data['vars']['APPLY_BTN_CAPTION'] = "Create"; $this->form_data['vars']['CURRENT_CHANNEL_NAME'] = ''; $this->form_data['vars']['CURRENT_CHANNEL_FORMAT'] = ''; $this->form_data['vars']['HIDE_AD_TYPE_CHANGE'] = ''; $this->form_data['vars']['HIDE_AD_TYPE_DISPLAY'] = 'style="display:none;"'; if (!array_key_exists('redirect', $this->form_data)) { $this->form_data['redirect'] = "/" . $this->role . "/edit_channel/create_complete"; } if (!is_null($site)) { $this->form_data['vars']['FORM_TITLE'] = __("Create channel for site") . ': <span class="green i">„' . type_to_str($site->getName(), 'encode') . ' (' . $site->getUrl() . ')“</span>'; $this->form_data['fields']['id_site'] = array("display_name" => __("ID Site"), "id_field_type" => "string", "form_field_type" => "hidden", "default" => $id_site); } else { $this->form_data['vars']['FORM_TITLE'] = __("Create channel"); } break; case 'modify': $channelAdTypes = array(); if ($channel->isAdTypeAllowed(Sppc_Channel::AD_TYPE_TEXT)) { $channelAdTypes[] = __("Text"); } if ($channel->isAdTypeAllowed(Sppc_Channel::AD_TYPE_IMAGE)) { $channelAdTypes[] = __("Image"); } $this->form_data['fields']['format']['options'] = $available_dimensions; $this->form_data['vars']['CURRENT_CHANNEL_AD_TYPE'] = implode(', ', $channelAdTypes); $this->form_data['vars']['DISABLED_AD_TYPE'] = 'readonly="true"'; $this->form_data['vars']['DISABLED_AD_TYPE_RADIO'] = 'onclick="return restoreOldAdType(this);"'; $this->form_data['vars']['APPLY_BTN_CAPTION'] = "Save"; $this->form_data['vars']['CURRENT_CHANNEL_NAME'] = '„' . type_to_str($channel->getName(), 'encode') . '“'; $this->form_data['vars']['HIDE_AD_TYPE_CHANGE'] = 'style="display:none;"'; $this->form_data['vars']['HIDE_AD_TYPE_DISPLAY'] = ''; if (!array_key_exists('redirect', $this->form_data)) { $this->form_data['redirect'] = "/" . $this->role . "/edit_channel/edit_complete"; } $this->form_data['vars']['FORM_TITLE'] = __("Edit channel") . ':'; break; } // print_r($this->form_data); $this->_set_content($this->form->get_form_content($mode, $this->form_data, $this->input, $this)); $this->_display(); return ''; }