-
Notifications
You must be signed in to change notification settings - Fork 5
basic statistics - #3 #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 7.x-1.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Implements hook_schema(). | ||
| */ | ||
| * Implements hook_schema(). | ||
| */ | ||
| function shrtr_schema() { | ||
| $schema['shrtr_urls'] = array( | ||
| 'description' => 'Shortened URLs', | ||
|
|
@@ -47,9 +47,15 @@ function shrtr_schema() { | |
| 'description' => 'Enabled', | ||
| 'type' => 'int', | ||
| 'not null' => TRUE, | ||
| 'default' => 1, | ||
| 'default' => 0, | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Erre a változtatásra biztosan szükség van? |
||
| 'length' => 1, | ||
| ), | ||
| 'hits' => array( | ||
| 'description' => 'Hits', | ||
| 'type' => 'int', | ||
| 'not null' => TRUE, | ||
| 'default' => 0, | ||
| ), | ||
| ), | ||
| 'primary key' => array('id'), | ||
| 'unique keys' => array( | ||
|
|
@@ -64,3 +70,18 @@ function shrtr_schema() { | |
| ); | ||
| return $schema; | ||
| } | ||
|
|
||
| /** | ||
| * Creates hit counter field. | ||
| */ | ||
| function shrtr_update_7901() { | ||
| $hits = array( | ||
| 'description' => 'Hits', | ||
| 'type' => 'int', | ||
| 'not null' => TRUE, | ||
| 'default' => 0, | ||
| ); | ||
| db_add_field('shrtr_urls', 'expire', $hits); | ||
|
|
||
| return t('Hit counter field of added to database.'); | ||
| } | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nagyon jó, de fejlesztés közben most nem kell update hook-okat írni, ez azért maradhat :) |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,7 +40,7 @@ function shrtr_menu() { | |
| } | ||
|
|
||
| /** | ||
| * Returns a form array for submit new ULR-s. | ||
| * Returns a form array for submit new URL-s. | ||
| */ | ||
| function shrtr_new_form($form = array(), &$form_state) { | ||
| $form['url'] = array( | ||
|
|
@@ -120,6 +120,7 @@ function shrtr_new_form_submit($form, &$form_state) { | |
| 'uid' => $user->uid, | ||
| 'created' => REQUEST_TIME, | ||
| 'expire' => $expire, | ||
| 'hits' => $hits, | ||
| 'alias' => $alias, | ||
| ); | ||
|
|
||
|
|
@@ -133,12 +134,13 @@ function shrtr_new_form_submit($form, &$form_state) { | |
| */ | ||
| function shrtr_goto($alias) { | ||
| $result = db_select('shrtr_urls', 's') | ||
| ->fields('s', array('url', 'expire')) | ||
| ->fields('s', array('url', 'expire', 'hits')) | ||
| ->condition('alias', $alias) | ||
| ->execute() | ||
| ->fetchAssoc(); | ||
|
|
||
| if ($result['expire'] == 0 || $result['expire'] > REQUEST_TIME) { | ||
| $result['hits']++; | ||
| drupal_goto($result['url']); | ||
| } | ||
| else { | ||
|
|
@@ -178,7 +180,7 @@ function shrtr_list_page() { | |
| ->fields('s') | ||
| ->execute(); | ||
|
|
||
| $header = array(t('ID'), t('User'), t('Original URL'), t('New URL'), t('Subbmitted'), t('Expire time')); | ||
| $header = array(t('ID'), t('User'), t('Original URL'), t('New URL'), t('Submitted'), t('Expire time'), t('Hits')); | ||
| $rows = array(); | ||
|
|
||
| while ($url = $urls->fetchAssoc()) { | ||
|
|
@@ -190,6 +192,7 @@ function shrtr_list_page() { | |
| $row[] = l($new_url, $new_url); | ||
| $row[] = format_date($url['created']); | ||
| $row[] = format_date($url['expire']); | ||
| $row[] = $url['hits']; | ||
| $rows[] = $row; | ||
| } | ||
|
|
||
|
|
@@ -209,7 +212,7 @@ function shrtr_urls_admin() { | |
| ->fields('s') | ||
| ->execute(); | ||
|
|
||
| $header = array(t('ID'), t('Enabled'), t('User'), t('Original URL'), t('New URL'), t('Subbmitted'), t('Expire time')); | ||
| $header = array(t('ID'), t('Enabled'), t('User'), t('Original URL'), t('New URL'), t('Submitted'), t('Expire time'), t('Number of hits')); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Az admin oldalra nem kell feltétlenül a statisztika, de ha már itt van, akkor a sorok közé is be kellene tenni. |
||
| $rows = array(); | ||
| $default = array(); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Azok a szóközök kellenek oda...