Index: css/yandex_metrics.css
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- css/yandex_metrics.css	(revision )
+++ css/yandex_metrics.css	(revision )
@@ -0,0 +1,3 @@
+.ym-counter {
+    clear: both;
+}
\ No newline at end of file
Index: yandex_metrics.module
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
<+><?php\n/**\n * @file\n *   The main code of Yandex.Metrics Counter module.\n */\n\n/**\n * Remove counter from all administrative pages, see http://drupal.org/node/34970.\n */\ndefine('YANDEX_METRICS_PAGES', \"admin\\nadmin/*\\nbatch\\nnode/add*\\nnode/*/*\\nuser/*/*\");\n\n/**\n * Implementation of hook_permission().\n */\n\nfunction yandex_metrics_permission() {\n  return array(\n    'administer Yandex.Metrics settings' => array(\n      'title' => t('Administer Yandex.Metrics Settings')\n    ),\n  );\n}\n\n/**\n * Implementation of hook_menu().\n */\nfunction yandex_metrics_menu() {\n\n  $items['admin/config/system/yandex_metrics'] = array(\n    'access arguments' => array('administer Yandex.Metrics settings'),\n    'page callback'   => 'drupal_get_form',\n    'page arguments'  => array('yandex_metrics_main_settings'),\n    'title'           => 'Yandex.Metrics',\n    'type' => MENU_NORMAL_ITEM,\n    'description'       => 'Integrate your site with Yandex.Metrics service.'\n  );\n  $items['admin/config/system/yandex_metrics/counter'] = array(\n    'access arguments' => array('administer Yandex.Metrics settings'),\n    'page callback'   => 'drupal_get_form',\n    'page arguments'  => array('yandex_metrics_main_settings'),\n    'title'           => 'Counter Code',\n    'type' => MENU_DEFAULT_LOCAL_TASK,\n    'weight' => 1\n  );\n\n  return $items;\n}\n\n/**\n * The main module settings form.\n */\nfunction yandex_metrics_main_settings() {\n\n  $form['yandex_metrics_counter_code'] = array(\n    '#default_value' => variable_get('yandex_metrics_counter_code', ''),\n    '#title' => t('Counter Code'),\n    '#type' => 'textarea',\n    '#rows' => 10,\n    '#description' => t('Paste Yandex.Metrics counter code for your site here.')\n  );\n\n  $form['visibility'] = array(\n    '#type' => 'fieldset',\n    '#title' => t('Page specific tracking settings'),\n    '#collapsible' => TRUE,\n    '#collapsed' => TRUE,\n  );\n\n  $visibility = variable_get('yandex_metrics_visibility', 0);\n  $options = array(\n    t('Add to every page except the listed pages.'), \n    t('Add to the listed pages only.')\n  );\n  $form['visibility']['yandex_metrics_visibility'] = array(\n    '#type' => 'radios',\n    '#title' => t('Add code to specific pages'),\n    '#options' => $options,\n    '#default_value' => $visibility,\n  );\n  \n  $pages = variable_get('yandex_metrics_pages', YANDEX_METRICS_PAGES);\n  $description = t(\"Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.\", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>'));\n  $form['visibility']['yandex_metrics_pages'] = array(\n    '#type' => 'textarea',\n    '#title' => t('Pages'),\n    '#default_value' => $pages,\n    '#description' => $description,\n    '#wysiwyg' => FALSE,\n    '#rows' => 10,\n  );\n\n  // Render the role overview.\n  $form['role_visibility'] = array(\n    '#type' => 'fieldset',\n    '#title' => t('Role specific tracking settings'),\n    '#collapsible' => TRUE,\n    '#collapsed' => TRUE,\n  );\n\n  $form['role_visibility']['yandex_metrics_visibility_roles'] = array(\n    '#type' => 'radios',\n    '#title' => t('Add tracking for specific roles'),\n    '#options' => array(\n      t('Add to the selected roles only'),\n      t('Add to every role except the selected ones'),\n    ),\n    '#default_value' => variable_get('yandex_metrics_visibility_roles', 0),\n  );\n\n  $roles = user_roles();\n  $role_options = array();\n  foreach ($roles as $rid => $name) {\n    $role_options[$rid] = $name;\n  }\n  $form['role_visibility']['yandex_metrics_roles'] = array(\n    '#type' => 'checkboxes',\n    '#title' => t('Roles'),\n    '#default_value' => variable_get('yandex_metrics_roles', array()),\n    '#options' => $role_options,\n    '#description' => t('If none of the roles are selected, all users will be tracked. If a user has any of the roles checked, that user will be tracked (or excluded, depending on the setting above).'),\n  );\n\n  $authorisation_token = variable_get('yandex_metrics_auth_token', '');\n  $form['save'] = array(\n    '#type' => 'submit',\n    '#value' => !empty($authorisation_token) ? t('Save') : t('Save & Continue'),\n  );\n\n  return $form;\n}\n\n/**\n * Implementation of hook_submit for yandex_metrics_main_settings form.\n * @param array $form\n * @param array $form_state\n */\nfunction yandex_metrics_main_settings_submit($form, &$form_state) {\n\n  $counter_code = $form_state['values']['yandex_metrics_counter_code'];\n  $visibility = $form_state['values']['yandex_metrics_visibility'];\n  $pages = $form_state['values']['yandex_metrics_pages'];\n  $visibility_roles = $form_state['values']['yandex_metrics_visibility_roles'];\n  $roles = $form_state['values']['yandex_metrics_roles'];\n\n  variable_set('yandex_metrics_counter_code', $counter_code);\n  variable_set('yandex_metrics_visibility', $visibility);\n  variable_set('yandex_metrics_pages', $pages);\n  variable_set('yandex_metrics_visibility_roles', $visibility_roles);\n  variable_set('yandex_metrics_roles', $roles);\n\n  drupal_set_message(t(\"The Counter Code settings has been saved successfully.\"));\n}\n\n/**\n * Implementation of hook_page_build().\n * Adds Yandex.Metrics counter code to the site footer.\n * See http://drupal.org/node/224333#hook_footer\n */\nfunction yandex_metrics_page_build(&$page) {\n  $yandex_metrics_counter_code = variable_get('yandex_metrics_counter_code', '');\n\n  if (!empty($yandex_metrics_counter_code) && yandex_metrics_show_counter() && yandex_metrics_show_counter_for_role()) {\n    $page['page_bottom']['yandex_metrics'] = array(\n      '#type' => 'markup',\n      '#markup' => '<div style=\"clear:both;\">' . $yandex_metrics_counter_code . '</div>'\n    );\n  }\n}\n\n/**\n * Returns FALSE if we need to disable counter on page.\n * @return bool\n */\nfunction yandex_metrics_show_counter() {\n  $pages = variable_get('yandex_metrics_pages', YANDEX_METRICS_PAGES);\n  $visibility = variable_get('yandex_metrics_visibility', 0);\n\n  $urls_equal = FALSE;\n  if (!empty($pages)) {\n\n    $pages_in_lowcase = drupal_strtolower($pages);\n    $current_path = drupal_strtolower(drupal_get_path_alias($_GET['q']));\n    // Compare internal and path alias.\n    $path_match = drupal_match_path($current_path, $pages_in_lowcase);\n    \n    if ($path_match) {\n\n      $urls_equal = TRUE;\n    } \n    else {\n      // If path alias doesn't equal with $_GET['q'] then compare internal and $_GET['q'].\n      $path_match = drupal_match_path($_GET['q'], $pages_in_lowcase);\n      if (($current_path != $_GET['q']) && $path_match) {\n\n         $urls_equal = TRUE;\n      }\n    }\n  }\n\n  if (!$visibility && $urls_equal) {\n    return FALSE;\n  } \n  elseif (!$visibility && !$urls_equal) {\n    return TRUE;\n  } \n  elseif ($visibility && $urls_equal) {\n    return TRUE;\n  } \n  elseif ($visibility && !$urls_equal) {\n    return FALSE;\n  }\n}\n\n/**\n * Returns FALSE if we need to disable counter for role.\n * @return bool\n */\nfunction yandex_metrics_show_counter_for_role() {\n  global $user;\n\n  $visibility = variable_get('yandex_metrics_visibility_roles', 0);\n  $enabled = $visibility;\n  $roles = variable_get('yandex_metrics_roles', array());\n\n  if (array_sum($roles) > 0) {\n    // One or more roles are selected.\n    foreach (array_keys($user->roles) as $rid) {\n      // Is the current user a member of one of these roles?\n      if (isset($roles[$rid]) && $rid == $roles[$rid]) {\n        // Current user is a member of a role that should be tracked/excluded from tracking.\n        $enabled = !$visibility;\n        break;\n      }\n    }\n  }\n  else {\n    // No role is selected for tracking, therefore all roles should be tracked.\n    $enabled = TRUE;\n  }\n\n  return $enabled;\n}\n\n/**\n * Implementation of hook_help.\n */\nfunction yandex_metrics_help($path, $arg) {\n  switch ($path) {\n    case 'admin/help#yandex_metrics':\n      $output = '';\n      $output .= '<h3>' . t('About the module') . '</h3>';\n      $output .= '<p>' . t('The <a href=\"@yandex_metrika\" target=\"_blank\">Yandex.Metrics</a> service is European alternative of Google Analytics. This is a free tool that helps you to increase the conversion rate of your site.', array('@yandex_metrika' => 'http://metrika.yandex.ru/')) . '</p>';\n      $output .= '<p>' . t('The Yandex.Metrics Counter module allows to install <a href=\"@yandex_metrika\" target=\"_blank\">Yandex.Metrics</a> counter code on the site pages.', array('@yandex_metrika' => 'http://metrika.yandex.ru/')) . '</p>';\n      $output .= '<h3>' . t('Usage') . '</h3>';\n      $output .= '<dl>';\n      $output .= '<dt>' . t('Installing counter') . '</dt>';\n      $output .= '<dd>' . t('Yandex.Metrics counter is JavaScript code that monitors user behavior on your website. You should <a href=\"@create_counter\" target=\"_blank\">create</a> and <a href=\"@install_counter\">install</a> the counter to work with Yandex.Metrics service.', array('@create_counter' => 'http://metrika.yandex.ru/', '@install_counter' => url('admin/config/system/yandex_metrics'))) . '</dd>';\n      $output .= '</dl>';\n      return $output;\n    case 'admin/config/system/yandex_metrics':\n      $output = '<p>' . t('Yandex.Metrics counter is JavaScript code that monitors user behavior on your website. You should <a href=\"@create_counter\" target=\"_blank\">create</a> and install the counter code to work with Yandex.Metrics service.', array('@create_counter' => 'http://metrika.yandex.ru/')) . '</p>';\n      return $output;\n  }\n}\n
===================================================================
--- yandex_metrics.module	(revision 88191352e064fa3d0d83f580fe6799db7bdae3d6)
+++ yandex_metrics.module	(revision )
@@ -160,9 +160,11 @@
   $yandex_metrics_counter_code = variable_get('yandex_metrics_counter_code', '');
 
   if (!empty($yandex_metrics_counter_code) && yandex_metrics_show_counter() && yandex_metrics_show_counter_for_role()) {
+    $path = drupal_get_path('module', 'yandex_metrics');
+    drupal_add_css($path . '/css/yandex_metrics.css');
     $page['page_bottom']['yandex_metrics'] = array(
       '#type' => 'markup',
-      '#markup' => '<div style="clear:both;">' . $yandex_metrics_counter_code . '</div>'
+      '#markup' => '<div class="ym-counter">' . $yandex_metrics_counter_code . '</div>'
     );
   }
 }
