phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] calendar/inc class.html.inc.php, 1.6 class.socalendar


From: skwashd
Subject: [Phpgroupware-cvs] calendar/inc class.html.inc.php, 1.6 class.socalendar_sql.inc.php, 1.39
Date: Sun, 4 Dec 2005 10:58:00 +0100

Update of calendar/inc

Modified Files:
     Branch: MAIN
            class.html.inc.php lines: +156 -91
            class.socalendar_sql.inc.php lines: +3 -3

Log Message:
more fixes

====================================================
Index: calendar/inc/class.html.inc.php
diff -u calendar/inc/class.html.inc.php:1.5 calendar/inc/class.html.inc.php:1.6
--- calendar/inc/class.html.inc.php:1.5 Sun May 15 06:57:37 2005
+++ calendar/inc/class.html.inc.php     Sun Dec  4 09:58:15 2005
@@ -14,23 +14,26 @@

 class html
 {
-       var $user_agent,$ua_version;    // 'mozilla','msie','konqueror'
-       var $prefered_img_title;
+       var $user_agent
+       var $ua_version;

+       /**
+       * @constructor
+       */
        function html()
-       {                                                                       
                                                        // should be Ok for all 
HTML 4 compatible browsers
-               if (!eregi('compatible; ([a-z_]+)[/ 
]+([0-9.]+)',$_SERVER['HTTP_USER_AGENT'],$parts))
+       {
+               //This should really be handled in API browser class - not the 
html class
+               if (!eregi('compatible; ([a-z_]+)[/ ]+([0-9.]+)', 
$_SERVER['HTTP_USER_AGENT'],$parts))
                {
-                       
eregi('^([a-z_]+)/([0-9.]+)',$_SERVER['HTTP_USER_AGENT'],$parts);
+                       eregi('^([a-z_]+)/([0-9.]+)', 
$_SERVER['HTTP_USER_AGENT'],$parts);
                }
                list(,$this->user_agent,$this->ua_version) = $parts;
                $this->user_agent = strtolower($this->user_agent);

-               $this->prefered_img_title = $this->user_agent == 'mozilla' && 
$this->ua_version < 5 ? 'ALT' : 'TITLE';
-               //echo "<p>HTTP_USER_AGENT='$GLOBALS[HTTP_USER_AGENT]', 
UserAgent: '$this->user_agent', Version: '$this->ua_version', img_title: 
'$this->prefered_img_title'</p>\n";
+               //echo "<p>HTTP_USER_AGENT='{$_SERVER['HTTP_USER_AGENT']}', 
UserAgent: '{$this->user_agent}', Version: '{$this->ua_version}'</p>\n";
        }

-       /*
+       /**
        * Function:             Allows to show and select one item from an array
        *       Parameters:             $name           string with name of the 
submitted var which holds the key of the selected item form array
        *                                               $key            key(s) 
of already selected item(s) from $arr, eg. '1' or '1,2' or array with keys
@@ -49,7 +52,7 @@
                }
                if (intval($multiple) > 0)
                {
-                       $options .= ' MULTIPLE SIZE="'.intval($multiple).'"';
+                       $options .= ' multiple="multiple" 
size="'.intval($multiple).'"';
                        if (substr($name,-2) != '[]')
                        {
                                $name .= '[]';
@@ -67,7 +70,7 @@

                        if("$k" == "$key" || strstr(",$key,",",$k,"))
                        {
-                               $out .= " SELECTED";
+                               $out .= ' selected="selected"';
                        }
                        $out .= ">" . ($no_lang || $text == '' ? $text : 
lang($text)) . "</option>\n";
                }
@@ -76,11 +79,26 @@
                return $out;
        }

+       /**
+       * Create a xhtml DIV
+       *
+       * @param string $content the content for the DIV
+       * @paeam string $options the html options of the div
+       * @returns string DIV element
+       */
        function div($content,$options='')
        {
-               return "<DIV $options>\n$content</DIV>\n";
+               return "<div $options>\n$content</div>\n";
        }

+       /**
+       * Create a input type="hidden" xhtml form element/s
+       *
+       * @param array $vars the variable names for the form element/ss
+       * @param mixed $value the value for the form element/s
+       * @param bool $ignore_empty should empty values be ignored?
+       * @return string hidden form element
+       */
        function input_hidden($vars,$value='',$ignore_empty=True)
        {
                if (!is_array($vars))
@@ -95,27 +113,48 @@
                        }
                        if (!$ignore_empty || $value && !($name == 'filter' && 
$value == 'none'))       // dont need to send all the empty vars
                        {
-                               $html .= "<INPUT TYPE=\"HIDDEN\" NAME=\"$name\" 
VALUE=\"".htmlspecialchars($value)."\">\n";
+                               $html .= "<input type=\"hidden\" name=\"$name\" 
value=\"".htmlspecialchars($value)."\" />\n";
                        }
                }
                return $html;
        }

+       /**
+       * Create a textarea html form element
+       *
+       * @param string $name the name of the textarea
+       * @param string $value the value for the textarea
+       * @param string optios the html options of the textarea
+       * @returns string textarea element
+       */
        function textarea($name,$value='',$options='' )
        {
-               return "<TEXTAREA name=\"$name\" 
$options>".htmlspecialchars($value)."</TEXTAREA>\n";
+               return "<textarea name=\"$name\" 
$options>".htmlspecialchars($value)."</textarea>\n";
        }

-       function input($name,$value='',$type='',$options='' )
+       /**
+       * Create a generic html form input element
+       *
+       * @param string $name the name of the input element
+       * @param string $value the value for the form element
+       * @param string $type the type of input element to generate
+       * @param string options the html options of the input element
+       * @returns string form input element
+       */
+       function input($name, $value = '', $type = 'text', $options = '')
        {
-               if ($type)
+               if ( strlen($type) )
                {
-                       $type = 'TYPE="'.$type.'"';
+                       $type = 'type="'.$type.'"';
                }
-               return "<INPUT $type NAME=\"$name\" 
VALUE=\"".htmlspecialchars($value)."\" $options>\n";
+               else
+               {
+                       $type = 'type="text"';
+               }
+               return "<input $type name=\"$name\" 
value=\"".htmlspecialchars($value)."\" $options>\n";
        }

-       function 
submit_button($name,$lang,$onClick='',$no_lang=0,$options='',$image='',$app='')
+       function submit_button($name, $lang, $onClick='', $no_lang=0, 
$options='', $image='', $app='')
        {
                if ($image != '')
                {
@@ -124,7 +163,7 @@
                                $image = substr($image,0,strpos($image,'.'));
                        }
                        if (!($path = 
$GLOBALS['phpgw']->common->image($app,$image)) &&
-                           !($path = 
$GLOBALS['phpgw']->common->image('phpgwapi',$image)))
+                               !($path = 
$GLOBALS['phpgw']->common->image('phpgwapi',$image)))
                        {
                                $path = $image;         // name may already 
contain absolut path
                        }
@@ -150,23 +189,23 @@

                // <button> is not working in all cases if ($this->user_agent 
== 'mozilla' && $this->ua_version < 5 || $image)
                {
-                       return $this->input($name,$lang,$image != '' ? 'IMAGE' 
: 'SUBMIT',$options.$image);
+                       return $this->input($name,$lang,$image != '' ? 'image' 
: 'submit',$options.$image);
                }
-               return '<button TYPE="submit" NAME="'.$name.'" 
VALUE="'.$lang.'" '.$options.'>'.
-                       ($image != '' ? "<img$image 
$this->prefered_img_title=\"$lang\"> " : '').
+               return '<button type="submit" name="'.$name.'" 
value="'.$lang.'" '.$options.'>'.
+                       ($image != '' ? "<img$image alt=\"$lang\"> " : '').
                        ($image == '' || $accesskey ? $lang_u : '').'</button>';
        }

-       /*!
-       @function link
-       @abstract creates an absolut link + the query / get-variables
-       @param $url phpgw-relative link, may include query / get-vars
-       @parm $vars query or array ('name' => 'value', ...) with query
-       @example 
link('/index.php?menuaction=infolog.uiinfolog.get_list',array('info_id' => 123))
-       @example  = 
'http://domain/phpgw-path/index.php?menuaction=infolog.uiinfolog.get_list&info_id=123'
-       @result absolut link already run through $phpgw->link
-       */
-       function link($url,$vars='')
+       /**
+        * Creates an absolute URI with optional query string (GET variables)
+        *
+        * @param string $uri phpgw-relative URI, may include query / get-vars
+        * $vars array|string $vars query or array ('name' => 'value', ...) 
with query
+        * 
link('/index.php?menuaction=infolog.uiinfolog.get_list',array('info_id' => 123))
+        *  = 
'http://domain/phpgw-path/index.php?menuaction=infolog.uiinfolog.get_list&info_id=123'
+        * @return string absolute URI ( parsed by $GLOBALS['phpgw']->link )
+        */
+       function link($uri, $vars='')
        {
                if (!is_array($vars))
                {
@@ -177,12 +216,12 @@
                {
                        $vars += explode('&',$v);
                }
-               return $GLOBALS['phpgw']->link($url,$vars);
+               return $GLOBALS['phpgw']->link($uri, $vars);
        }

        function checkbox($name,$value='')
        {
-               return "<input type=\"checkbox\" name=\"$name\" value=\"True\"" 
.($value ? ' checked' : '') . ">\n";
+               return "<input type=\"checkbox\" name=\"$name\" value=\"True\"" 
.($value ? ' checked="checked"' : '') . ">\n";
        }

        function 
form($content,$hidden_vars,$url,$url_vars='',$name='',$options='',$method='POST')
@@ -204,21 +243,20 @@
                        $hidden_vars,$url,$url_vars,$form_name,'',$method);
        }

-       /*!
-       @function table
-       @abstracts creates table from array with rows
-       @discussion abstract the html stuff
-       @param $rows array with rows, each row is an array of the cols
-       @param $options options for the table-tag
-       @example $rows = array ( '1'  => array( 1 => 'cell1', '.1' => 
'colspan=3',
-       @example                                2 => 'cell2', 3 => 'cell3', 
'.3' => 'width="10%"' ),
-       @example                 '.1' => 'BGCOLOR="#0000FF"' );
-       @example table($rows,'WIDTH="100%"') = '<table WIDTH="100%"><tr><td 
colspan=3>cell1</td><td>cell2</td><td width="10%">cell3</td></tr></table>'
-       @result string with html-code of the table
-       */
+       /**
+        * creates table from array with rows
+        * abstract the html stuff
+        * @param $rows array with rows, each row is an array of the cols
+        * @param $options options for the table-tag
+        * $rows = array ( '1'  => array( 1 => 'cell1', '.1' => 'colspan=3',
+        *                                2 => 'cell2', 3 => 'cell3', '.3' => 
'width="10%"' ),
+        *                 '.1' => 'BGCOLOR="#0000FF"' );
+        * table($rows,'WIDTH="100%"') = '<table WIDTH="100%"><tr><td 
colspan=3>cell1</td><td>cell2</td><td width="10%">cell3</td></tr></table>'
+        * @return string with html-code of the table
+        */
        function table($rows,$options = '',$no_table_tr=False)
        {
-               $html = $no_table_tr ? '' : "<TABLE $options>\n";
+               $html = $no_table_tr ? '' : "<table $options>\n";

                foreach($rows as $key => $row)
                {
@@ -226,7 +264,7 @@
                        {
                                continue;                                       
// parameter
                        }
-                       $html .= $no_table_tr && $key == 1 ? '' : "\t<TR 
".$rows['.'.$key].">\n";
+                       $html .= $no_table_tr && $key == 1 ? '' : "\t<tr 
".$rows['.'.$key].">\n";

                        foreach($row as $key => $cell)
                        {
@@ -234,8 +272,8 @@
                                {
                                        continue;                               
// parameter
                                }
-                               $table_pos = strpos($cell,'<TABLE');
-                               $td_pos = strpos($cell,'<TD');
+                               $table_pos = strpos($cell,'<table');
+                               $td_pos = strpos($cell,'<td');
                                if ($td_pos !== False && ($table_pos === False 
|| $td_pos < $table_pos))
                                {
                                        $html .= $cell;
@@ -245,9 +283,9 @@
                                        $html .= "\t\t<TD 
".$row['.'.$key].">$cell</TD>\n";
                                }
                        }
-                       $html .= "\t</TR>\n";
+                       $html .= "\t</tr>\n";
                }
-               $html .= "</TABLE>\n";
+               $html .= "</table>\n";

                if ($no_table_tr)
                {
@@ -271,7 +309,7 @@
        {
                if (strstr($name,'.') === False)
                {
-                       $name .= '.gif';
+                       $name .= '.png';
                }
                if (!($path = $GLOBALS['phpgw']->common->image($app,$name)))
                {
@@ -283,9 +321,9 @@
                }
                if ($title)
                {
-                       $options .= " 
$this->prefered_img_title=\"".htmlspecialchars($title).'"';
+                       $options .= " alt=\"".htmlspecialchars($title).'"';
                }
-               return "<IMG SRC=\"$path\" $options>";
+               return "<img src=\"$path\" $options />";
        }

        function a_href( $content,$url,$vars='',$options='')
@@ -304,33 +342,44 @@

        function bold($content)
        {
-               return '<b>'.$content.'</b>';
+               return "<strong>{$content}</strong>";
        }

        function italic($content)
        {
-               return '<i>'.$content.'</i>';
+               return "<em>{$content}</em>";
        }

+       //FIXME Deprecated Tag! use div with hr class? &nbsp; 1px high and 
$width wide? - skwashd nov2005
        function hr($width,$options='')
        {
                if ($width)
-                       $options .= " WIDTH=$width";
+               {
+                       $options .= " width=\"$width\"";
+               }
                return "<hr $options>\n";
        }

-       /*!
-       @function formatOptions
-       @abstract formats option-string for most of the above functions
-       @param $options String (or Array) with option-values eg. '100%,,1'
-       @param $names String (or Array) with the option-names eg. 
'WIDTH,HEIGHT,BORDER'
-       @example formatOptions('100%,,1','WIDTH,HEIGHT,BORDER') = ' 
WIDTH="100%" BORDER="1"'
-       @result option string
-       */
-       function formatOptions($options,$names)
+       /**
+        * formats option-string for most of the above functions
+        *
+        * @internal TODO look at if we still need this - most of this should 
be handled by CSS - skwashd nov2005
+        * @param $options String (or Array) with option-values eg. '100%,,1'
+        * @param $names String (or Array) with the option-names eg. 
'WIDTH,HEIGHT,BORDER'
+        * formatOptions('100%,,1','WIDTH,HEIGHT,BORDER') = ' WIDTH="100%" 
BORDER="1"'
+        * @return option string
+        */
+       function formatOptions($options, $names)
        {
-               if (!is_array($options)) $options = explode(',',$options);
-               if (!is_array($names))   $names   = explode(',',$names);
+               if (!is_array($options))
+               {
+                       $options = explode(',',$options);
+               }
+
+               if (!is_array($names))
+               {
+                       $names   = explode(',',$names);
+               }

                while (list($n,$val) = each($options))
                        if ($val != '' && $names[$n] != '')
@@ -339,44 +388,60 @@
                return $html;
        }

-       /*!
-       @function themeStyles
-       @abstract returns simple stylesheet (incl. <STYLE> tags) for nextmatch 
row-colors
-       @result the classes 'th' = nextmatch header, 'row_on'+'row_off' = 
alternating rows
-       */
+       /**
+        * Create the required CSS style definitiokn in a style tag beeded for 
nextmatch row-colors
+        *
+        * @return the classes 'th' = nextmatch header, 'row_on'+'row_off' = 
alternating rows
+        */
        function themeStyles()
        {
                return $this->style($this->theme2css());
        }

-       /*!
-       @function theme2css
-       @abstract returns simple stylesheet for nextmatch row-colors
-       @result the classes 'th' = nextmatch header, 'row_on'+'row_off' = 
alternating rows
-       */
+       /**
+        * returns simple stylesheet for nextmatch row-colors
+        *
+        * @deprecated
+        * @internal FIXME As we are moving to full CSS this is redundant and 
should be dropped! - skwashd nov2005
+        *
+        * @return the classes 'th' = nextmatch header, 'row_on'+'row_off' = 
alternating rows
+        */
        function theme2css()
        {
                return
-                       ".th { background: 
".$GLOBALS['phpgw_info']['theme']['th_bg']."; font-weight: bold; }\n".
-                       ".row_on,.th_bright { background: 
".$GLOBALS['phpgw_info']['theme']['row_on']."; }\n".
-                       ".row_off { background: 
".$GLOBALS['phpgw_info']['theme']['row_off']."; }\n";
+                       ".th { background-color: 
{$GLOBALS['phpgw_info']['theme']['th_bg']}; font-weight: bold; }\n".
+                       ".row_on,.th_bright { background-color: 
{$GLOBALS['phpgw_info']['theme']['row_on']}; }\n".
+                       ".row_off { background-color: 
{$GLOBALS['phpgw_info']['theme']['row_off']}; }\n";
        }

+       /**
+       * Create and populate a html style tag
+       *
+       * @param string $styles the styles to be contained within the style tag
+       * @returns a html style tag
+       */
        function style($styles)
        {
-               return $styles ? "<STYLE 
type=\"text/css\">\n<!--\n$styles\n-->\n</STYLE>" : '';
+               return $styles ? "<style 
type=\"text/css\">\n<!--\n$styles\n-->\n</style>" : '';
        }

-       function label($content,$id='',$accesskey='',$options='')
+       /**
+       * Create a label for a html form input element
+       *
+       * @internal TODO add the ability to highlight the shortcut key - 
skwashd nov2005
+       * @param string $content the contents of the label
+       * @param string $id the unique ID for the label
+       * @param string $accesskey the keyboard shortcut for the label
+       * @param string $options the html options for the label
+       * @return string the label as html
+       */
+       function label($content, $id, $accesskey='', $options='')
        {
-               if ($id != '')
-               {
-                       $id = " FOR=\"$id\"";
-               }
+               $id = " for=\"$id\"";
                if ($accesskey != '')
                {
-                       $accesskey = " ACCESSKEY=\"$accesskey\"";
+                       $accesskey = " accesskey=\"$accesskey\"";
                }
-               return "<LABEL$id$accesskey $options>$content</LABEL>";
+               return "<label$id$accesskey $options>$content</label>";
        }
 }

====================================================
Index: calendar/inc/class.socalendar_sql.inc.php
diff -u calendar/inc/class.socalendar_sql.inc.php:1.38 
calendar/inc/class.socalendar_sql.inc.php:1.39
--- calendar/inc/class.socalendar_sql.inc.php:1.38      Fri Nov 18 11:40:45 2005
+++ calendar/inc/class.socalendar_sql.inc.php   Sun Dec  4 09:58:15 2005
@@ -573,9 +573,9 @@
                if($event['id'] == 0)
                {
                        $this->stream->query('INSERT INTO phpgw_cal(title, 
owner, priority, is_public, category) '
-                               . 
"values('','".$this->stream->db_addslashes($event['title'])
+                               . 
"VALUES('".$this->stream->db_addslashes($event['title'])
                                . 
"',{$event['owner']},{$event['priority']},{$event['public']},"
-                               . "{$event['category']})",__LINE__,__FILE__);
+                               . "'{$event['category']}')",__LINE__,__FILE__);
                        $event['id'] = 
$this->stream->get_last_insert_id('phpgw_cal','cal_id');
                }







reply via email to

[Prev in Thread] Current Thread [Next in Thread]