if ($current_element['user_id'] == $effective_user) { // handle template change if (isset($_POST['change_template_id'])) { if ($_POST['change_template_id'] != $_POST['current_template_id']) { $new_template_id = $cash_admin->requestAndStore(array('cash_request_type' => 'element', 'cash_action' => 'setelementtemplate', 'element_id' => $request_parameters[0], 'template_id' => $_POST['change_template_id'])); if ($new_template_id) { if ($_POST['current_template_id'] > 0) { // delete old custom templates $cash_admin->requestAndStore(array('cash_request_type' => 'system', 'cash_action' => 'deletetemplate', 'template_id' => $_POST['current_template_id'])); } $cash_admin->page_data['template_id'] = $_POST['change_template_id']; } } } // deal with templates $embed_templates = AdminHelper::echoTemplateOptions('embed', $cash_admin->page_data['template_id']); $cash_admin->page_data['template_options'] = $embed_templates; if ($cash_admin->page_data['template_id'] >= 0) { $cash_admin->page_data['custom_template'] = true; } $analytics = $cash_admin->requestAndStore(array('cash_request_type' => 'element', 'cash_action' => 'getanalytics', 'analtyics_type' => 'elementbasics', 'element_id' => $request_parameters[0], 'user_id' => $cash_admin->effective_user_id)); $cash_admin->page_data['total_views'] = 0; if (is_array($analytics['payload'])) { $cash_admin->page_data['total_views'] = CASHSystem::formatCount($analytics['payload']['total']); $methods_array = array(); $locations_array = array(); foreach ($analytics['payload']['methods'] as $method => $total) { $methods_string = array('direct', 'api_public', 'api_key', 'api_fullauth'); $methods_translation = array('direct (embedded on this site)', 'api_public (shared to another site)', 'api_key (shared to another site)', 'api_fullauth (another site with your API credentials)'); $methods_array[] = array('access_method' => str_replace($methods_string, $methods_translation, $method), 'total' => $total); }