htmlspeciachars for menu

If you would like to check the status of a language, volunteer to do a translation, or highlight or correct a problem in one of the existing language files then post here.
Post Reply
Kushnirenko
Posts: 17
Joined: Mon Jun 25, 2007 6:29 pm

htmlspeciachars for menu

Post by Kushnirenko »

In russian translation drop-down menus are not displayed correctly. For example menus to choose scale of image or speed of display. There is a solution to use function htmlspecialchars instead of htmlentities.

Are there any objections to that? If none how should I organise a patch?
Kushnirenko
Posts: 17
Joined: Mon Jun 25, 2007 6:29 pm

patch included

Post by Kushnirenko »

I did not find a way to post patch on Wiki page. So I place it here. It fixes russian language drop-down menus, that are translated, but displayed in wrong characters. It is usual problem with languages, that have more than one coding table.

Code: Select all

*** /home/kushnir/devel/zm/usr/share/zoneminder/zm_funcs.php    2007-06-12 01:07:00.000000000 +0400
--- ./zm_funcs.php      2007-09-06 17:28:15.000000000 +0400
*************** function buildSelect( $name, $contents, 
*** 523,529 ****
        foreach ( $contents as $content_value => $content_text )
        {
  ?>
! <option value="<?= $content_value ?>"<?php if ( $value == $content_value ) { echo ($_SESSION['format']=="html")?' selected':' selected="selected"'; } ?>><?= htmlentities($content_text) ?></option>
  <?php
        }
  ?>
--- 523,529 ----
        foreach ( $contents as $content_value => $content_text )
        {
  ?>
! <option value="<?= $content_value ?>"<?php if ( $value == $content_value ) { echo ($_SESSION['format']=="html")?' selected':' selected="selected"'; } ?>><?= htmlspecialchars($content_text) ?></option>
  <?php
        }
  ?>
*** /home/kushnir/devel/zm/usr/share/zoneminder/zm_html_view_controlpreset.php 2007-06-12 01:07:00.000000000 +0400
--- ./zm_html_view_controlpreset.php    2007-09-06 17:38:32.000000000 +0400
*************** for ( $i = 1; $i <= $monitor['NumPresets
*** 47,53 ****
        $presets[$i] = "$zmSlangPreset $i";
        if ( $labels[$i] )
      {
!         $presets[$i] .= " (".htmlentities(addslashes($labels[$i])).")";
      }
  }
  ?>
--- 47,53 ----
        $presets[$i] = "$zmSlangPreset $i";
        if ( $labels[$i] )
      {
!         $presets[$i] .= " (".htmlspecialchars(addslashes($labels[$i])).")";
      }
  }
  ?>
*************** var labels = new Array();
*** 71,77 ****
  foreach ( $labels as $index=>$label )
  {
  ?>
! labels[<?= $index ?>] = "<?= htmlentities(addslashes($label)) ?>";
  <?php
  }
  ?>
--- 71,77 ----
  foreach ( $labels as $index=>$label )
  {
  ?>
! labels[<?= $index ?>] = "<?= htmlspecialchars(addslashes($label)) ?>";
  <?php
  }
  ?>
*** /home/kushnir/devel/zm/usr/share/zoneminder/zm_html_view_event.php  2007-06-12 01:07:01.000000000 +0400
--- ./zm_html_view_event.php    2007-09-06 17:39:03.000000000 +0400
*************** if ( $mode == "stream" )
*** 205,211 ****
  <td><table border="0" cellspacing="1" cellpadding="2" width="100%" style="background: #666699">
  <tr style="background: #ffffff">
  <td class="text" align="center"><span title="<?= $zmSlangId ?>"><?= $event['Id'] ?></span></td>
! <td class="text" align="center"><span title="<?= $event['Notes']?htmlentities($event['Notes']):$zmSlangAttrCause ?>"><?= htmlentities($event['Cause']) ?></span></td>
  <td class="text" align="center"><span title="<?= $zmSlangTime ?>"><?= strftime( STRF_FMT_DATETIME_SHORT, strtotime($event['StartTime'] ) ) ?></span></td>
  <td class="text" align="center"><span title="<?= $zmSlangDuration ?>"><?= $event['Length']."s" ?></span></td>
  <td class="text" align="center"><span title="<?= $zmSlangAttrFrames."/".$zmSlangAttrAlarmFrames ?>"><?= $event['Frames'] ?>/<?= $event['AlarmFrames'] ?></span></td>
--- 205,211 ----
  <td><table border="0" cellspacing="1" cellpadding="2" width="100%" style="background: #666699">
  <tr style="background: #ffffff">
  <td class="text" align="center"><span title="<?= $zmSlangId ?>"><?= $event['Id'] ?></span></td>
! <td class="text" align="center"><span title="<?= $event['Notes']?htmlspecialchars($event['Notes']):$zmSlangAttrCause ?>"><?= htmlspecialchars($event['Cause']) ?></span></td>
  <td class="text" align="center"><span title="<?= $zmSlangTime ?>"><?= strftime( STRF_FMT_DATETIME_SHORT, strtotime($event['StartTime'] ) ) ?></span></td>
  <td class="text" align="center"><span title="<?= $zmSlangDuration ?>"><?= $event['Length']."s" ?></span></td>
  <td class="text" align="center"><span title="<?= $zmSlangAttrFrames."/".$zmSlangAttrAlarmFrames ?>"><?= $event['Frames'] ?>/<?= $event['AlarmFrames'] ?></span></td>
*** /home/kushnir/devel/zm/usr/share/zoneminder/zm_html_view_monitorpreset.php 2007-06-12 01:07:01.000000000 +0400
--- ./zm_html_view_monitorpreset.php    2007-09-06 17:39:17.000000000 +0400
*************** $presets = array();
*** 30,36 ****
  $presets[0] = $zmSlangChoosePreset;
  while ( $preset = mysql_fetch_assoc( $result ) )
  {
!       $presets[$preset['Id']] = htmlentities( $preset['Name'] );
  }
  mysql_free_result( $result );
  
--- 30,36 ----
  $presets[0] = $zmSlangChoosePreset;
  while ( $preset = mysql_fetch_assoc( $result ) )
  {
!       $presets[$preset['Id']] = htmlspecialchars( $preset['Name'] );
  }
  mysql_free_result( $result );
  
*** /home/kushnir/devel/zm/usr/share/zoneminder/zm_html_view_monitorselect.php 2007-06-12 01:07:01.000000000 +0400
--- ./zm_html_view_monitorselect.php    2007-09-06 17:39:30.000000000 +0400
*************** foreach ( $monitors as $monitor )
*** 95,101 ****
        if ( visibleMonitor( $monitor['Id'] ) )
        {
  ?>
! <option value="<?= $monitor['Id'] ?>"><?= htmlentities($monitor['Name']) ?></option>
  <?php
        }
  }
--- 95,101 ----
        if ( visibleMonitor( $monitor['Id'] ) )
        {
  ?>
! <option value="<?= $monitor['Id'] ?>"><?= htmlspecialchars($monitor['Name']) ?></option>
  <?php
        }
  }
*** /home/kushnir/devel/zm/usr/share/zoneminder/zm_html_view_optionhelp.php    2007-06-12 01:07:01.000000000 +0400
--- ./zm_html_view_optionhelp.php       2007-09-06 17:39:46.000000000 +0400
*************** function closeWindow()
*** 38,44 ****
  <table border="0" cellspacing="0" cellpadding="4" width="96%">
  <tr><td align="right" class="text"><a href="javascript: closeWindow();"><?= $zmSlangClose ?></a></td></tr>
  <tr><td align="left" class="smallhead"><?= $option ?></td></tr>
! <tr><td class="text"><p class="text" align="justify"><?= htmlentities($option_help_text) ?></p></td></tr>
  </table>
  </body>
  </html>
--- 38,44 ----
  <table border="0" cellspacing="0" cellpadding="4" width="96%">
  <tr><td align="right" class="text"><a href="javascript: closeWindow();"><?= $zmSlangClose ?></a></td></tr>
  <tr><td align="left" class="smallhead"><?= $option ?></td></tr>
! <tr><td class="text"><p class="text" align="justify"><?= htmlspecialchars($option_help_text) ?></p></td></tr>
  </table>
  </body>
  </html>
*** /home/kushnir/devel/zm/usr/share/zoneminder/zm_html_view_options.php       2007-06-12 01:07:01.000000000 +0400
--- ./zm_html_view_options.php  2007-09-06 17:39:57.000000000 +0400
*************** else
*** 231,237 ****
  ?>
  <tr>
  <td align="left" class="text"><?= $value['Name'] ?></td>
! <td align="left" class="text"><?= htmlentities($option_prompt_text) ?> (<a href="javascript: newWindow( '<?= $PHP_SELF ?>?view=optionhelp&option=<?= $value['Name'] ?>', 'zmOptionHelp', <?= $jws['optionhelp']['w'] ?>, <?= $jws['optionhelp']['h'] ?>);">?</a>)</td>
  <?php
                if ( $value['Type'] == "boolean" )
                {
--- 231,237 ----
  ?>
  <tr>
  <td align="left" class="text"><?= $value['Name'] ?></td>
! <td align="left" class="text"><?= htmlspecialchars($option_prompt_text) ?> (<a href="javascript: newWindow( '<?= $PHP_SELF ?>?view=optionhelp&option=<?= $value['Name'] ?>', 'zmOptionHelp', <?= $jws['optionhelp']['w'] ?>, <?= $jws['optionhelp']['h'] ?>);">?</a>)</td>
  <?php
                if ( $value['Type'] == "boolean" )
                {
*************** else
*** 253,259 ****
                                foreach ( $options as $option )
                                {
  ?>
! <option value="<?= $option ?>"<?php if ( $value['Value'] == $option ) { echo " selected"; } ?>><?= htmlentities($option) ?></option>
  <?php
                                }
  ?>
--- 253,259 ----
                                foreach ( $options as $option )
                                {
  ?>
! <option value="<?= $option ?>"<?php if ( $value['Value'] == $option ) { echo " selected"; } ?>><?= htmlspecialchars($option) ?></option>
  <?php
                                }
  ?>
*** /home/kushnir/devel/zm/usr/share/zoneminder/zm_html_view_timeline.php      2007-06-12 01:07:01.000000000 +0400
--- ./zm_html_view_timeline.php 2007-09-06 17:40:04.000000000 +0400
*************** function getSlotLoadImageBehaviour( $slo
*** 780,787 ****
                "<br>".$slot['event']['Name'].($slot_frame?("(".$slot_frame.")"):"").
                "<br>".strftime( STRF_FMT_DATETIME_SHORT, strtotime($slot['event']['StartTime']) ).
                " - ".$slot['event']['Length']."s".
!               "<br>".htmlentities($slot['event']['Cause']).
!               (!empty($slot['event']['Notes'])?("<br>".preg_replace( "/\n/", "<br>", htmlentities($slot['event']['Notes']))):"").
                (!empty($slot['event']['Archived'])?("<br>".$zmSlangArchived):"");
        if ( $slot['event']['Archived'] )
                $annotation .= "</em>";
--- 780,787 ----
                "<br>".$slot['event']['Name'].($slot_frame?("(".$slot_frame.")"):"").
                "<br>".strftime( STRF_FMT_DATETIME_SHORT, strtotime($slot['event']['StartTime']) ).
                " - ".$slot['event']['Length']."s".
!               "<br>".htmlspecialchars($slot['event']['Cause']).
!               (!empty($slot['event']['Notes'])?("<br>".preg_replace( "/\n/", "<br>", htmlspecialchars($slot['event']['Notes']))):"").
                (!empty($slot['event']['Archived'])?("<br>".$zmSlangArchived):"");
        if ( $slot['event']['Archived'] )
                $annotation .= "</em>";

Post Reply