Ignore:
Timestamp:
Oct 28, 2010, 12:19:44 AM (13 years ago)
Author:
plg
Message:

bug fixed: ability to use a Google Analytics/Piwik javascript code including a
comma.

simpler code, easier to maintain I hope.

change file format from MacOs to Unix line endings.

Location:
extensions/Statistics/admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/Statistics/admin/stat_admin.php

    r3438 r7445  
    44load_language('plugin.lang', STAT_PATH);
    55
    6 
    7 
    8 $conf_statistics = explode("," , $conf['statistics']);
    9 
    10 
     6$conf_statistics = unserialize($conf['statistics']);
    117
    128$template->assign(
     9  array(
     10    'statisticsCONTENT' => $conf_statistics['content'],
     11    'STATITICS_HEADER'  => $conf_statistics['header'] ? 'checked="checked"' : '' ,
     12    'STATISTICS_TAIL'   => $conf_statistics['tail']   ? 'checked="checked"' : '' ,
     13    'STATISTICS_ADMIN'  => $conf_statistics['exclude_admin']  ? 'checked="checked"' : '' ,
     14    'STATISTICS_GUEST'  => $conf_statistics['exclude_guest']  ? 'checked="checked"' : '' ,
     15    )
     16  );
    1317
    14   array(
     18if (isset($_POST['submit']))
     19{
     20  $statistics_content = stripslashes($_POST['statistics_content']);
     21 
     22  $conf_statistics = array(
     23    'content' => $statistics_content,
     24    'header' => isset($_POST['stat_header']),
     25    'tail' => isset($_POST['stat_tail']),
     26    'exclude_admin' => isset($_POST['stat_admin']),
     27    'exclude_guest' => isset($_POST['stat_guest']),
     28    );
    1529
    16    'STATITICS_HEADER' => $conf_statistics[0] == 'on' ? 'checked="checked"' : '' ,
     30  $query = '
     31UPDATE '.CONFIG_TABLE.'
     32  SET value = \''.pwg_db_real_escape_string(serialize($conf_statistics)).'\'
     33  WHERE param = \'statistics\'
     34;';
     35  pwg_query($query);
    1736
    18    'STATISTICS_TAIL' => $conf_statistics[1] == 'on' ? 'checked="checked"' : '' ,
    19 
    20    'STATISTICS_ADMIN' => $conf_statistics[3] == 'on' ? 'checked="checked"' : '' ,
    21 
    22    'STATISTICS_GUEST' => $conf_statistics[4] == 'on' ? 'checked="checked"' : '' ,
    23 
    24                  )
    25 
    26                 );     
    27 
    28 
    29 
    30 $template->assign(array('statisticsCONTENT' => $conf_statistics[2],));
    31 
    32 
    33 
    34 if ( isset($_POST['submit']) )
    35 
    36 {
    37 
    38   $value_header = isset($_POST['stat_header']) ? $_POST['stat_header'] : '' ;
    39 
    40   $value_tail = isset($_POST['stat_tail']) ? $_POST['stat_tail'] : '' ;
    41 
    42   $value_content = isset($_POST['statistics_content']) ? $_POST['statistics_content'] : '' ;
    43 
    44   $value_admin = isset($_POST['stat_admin']) ? $_POST['stat_admin'] : '' ;
    45 
    46   $value_guest = isset($_POST['stat_guest']) ? $_POST['stat_guest'] : '' ;
    47 
    48 
    49 
    50 $query = '
    51 
    52     UPDATE '.CONFIG_TABLE.'
    53 
    54     SET value="'.$value_header. ',' .$value_tail. ',' .$value_content.',' .$value_admin. ',' .$value_guest. '"
    55 
    56     WHERE param="statistics"
    57 
    58     LIMIT 1';
    59 
    60    
    61 
    62  pwg_query($query);
    63 
    64  
    65 array_push($page['infos'], l10n('statistics_save_config'));
    66 
    67 
    68 $template->assign(
    69 
    70   array(
    71 
    72    'STATITICS_HEADER' => $value_header == 'on' ? 'checked="checked"' : '' ,
    73 
    74    'STATISTICS_TAIL' => $value_tail  == 'on' ? 'checked="checked"' : '' ,
    75 
    76    'STATISTICS_ADMIN'=> $value_admin  == 'on' ? 'checked="checked"' : '' ,
    77 
    78    'STATISTICS_GUEST'=> $value_guest  == 'on' ? 'checked="checked"' : '' ,
    79 
    80      )
    81 
    82     ); 
    83 
    84 
    85 
    86 $template->assign(array('statisticsCONTENT' => stripslashes ($value_content))); 
    87 
     37  array_push($page['infos'], l10n('statistics_save_config'));
     38  $template->assign(
     39    array(
     40      'statisticsCONTENT' => $statistics_content,
     41      'STATITICS_HEADER'  => isset($_POST['stat_header']) ? 'checked="checked"' : '' ,
     42      'STATISTICS_TAIL'   => isset($_POST['stat_tail'])   ? 'checked="checked"' : '' ,
     43      'STATISTICS_ADMIN'  => isset($_POST['stat_admin'])  ? 'checked="checked"' : '' ,
     44      'STATISTICS_GUEST'  => isset($_POST['stat_guest'])  ? 'checked="checked"' : '' ,
     45      )
     46    );
    8847}
    8948
    90 
    91 
    9249$template->set_filenames(array('plugin_admin_content' => realpath(STAT_PATH . 'admin/stat_admin.tpl')));
    93 
    9450$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
    9551?>
  • extensions/Statistics/admin/stat_admin.tpl

    r3438 r7445  
    11<div class="titrePage">
    2 
    3         <h2>Statistics</h2>
    4 
     2  <h2>Statistics</h2>
    53</div>
    64
    7 
    8 
    9   <span>{'Howto'|translate}</span>
    10 
    11  
     5<span>{'Howto'|translate}</span>
    126
    137<form action="" method="post" name="form">
    14 
    15   <fieldset>
    16 
    17     <legend>{'statistics_admin'|translate}</legend>
    18 
    19 
    20 
    21    <p>{'statistics_admin_description'|translate}</p>
    22 
    23            <table>
    24 
    25            <tr>
    26 
    27             <td><textarea name="statistics_content" id="statistics_content" rows="10" cols="80">{$statisticsCONTENT}</textarea></td>
    28 
    29            </tr>
    30 
    31            </table>
    32 
    33  
    34 
    35     <table><tr>
    36 
    37       <td><input type="checkbox" name="stat_header" value="on" {$STATITICS_HEADER} />&nbsp;{'stat_header'|translate}&nbsp;&nbsp;&nbsp;
    38 
    39       <input type="checkbox" name="stat_tail" value="on" {$STATISTICS_TAIL} />&nbsp;{'stat_tail'|translate}</td></tr>
    40 
    41        <tr><td>
    42 
    43       <input type="checkbox" name="stat_admin" value="on" {$STATISTICS_ADMIN} />&nbsp;{'stat_admin'|translate}
    44 
    45       </td></tr>
    46 
    47               <tr><td>
    48 
    49        <input type="checkbox" name="stat_guest" value="on" {$STATISTICS_GUEST} />&nbsp;{'stat_guest'|translate}
    50 
    51      </td></tr>
    52 
    53      </table>
    54 
    55       <p><input class="submit" type="submit" name="submit" value="{'Submit'|translate}"/></p>
    56 
    57 </fieldset>
    58 
     8  <p style="margin-bottom:5px;">{'statistics_admin_description'|translate}</p>
     9  <p style="margin:0;"><textarea name="statistics_content" id="statistics_content" rows="10" cols="80">{$statisticsCONTENT}</textarea></p>
     10  <ul style="width:400px;margin:20px auto !important;list-style-type:none;">
     11    <li><label><input type="checkbox" name="stat_header" {$STATITICS_HEADER} /> {'stat_header'|translate}</label></li>
     12    <li><label><input type="checkbox" name="stat_tail" {$STATISTICS_TAIL} /> {'stat_tail'|translate}<label></li>
     13    <li><label><input type="checkbox" name="stat_admin" {$STATISTICS_ADMIN} />&nbsp;{'stat_admin'|translate}<label></li>
     14    <li><label><input type="checkbox" name="stat_guest" {$STATISTICS_GUEST} />&nbsp;{'stat_guest'|translate}<label></li>
     15  </ul>
     16  <p><input class="submit" type="submit" name="submit" value="{'Submit'|translate}"/></p>
    5917</form>
    6018
Note: See TracChangeset for help on using the changeset viewer.