pike.git / lib / modules / String.pmod / HTML.pmod

version» Context lines:

pike.git/lib/modules/String.pmod/HTML.pmod:78:   //! @example   //! function cb = lambda(int x, int y, string bgcolor, string contents) {   //! if(y%2) return "<td bgcolor='#aaaaff'>"+contents+"</td>";   //! return "<td bgcolor='"+bgcolor+"'>"+contents+"</td>";   //! }   //! simple_obox(my_rows, "#0000a0", 0, "1", "3", cb);   //!   //! @seealso   //! @[pad_rows]   string simple_obox( array(array(string)) rows, -  void|string frame_color, void|string cell_color, +  void|string frame_color, string cell_color="#ffffff",    void|string width, void|string padding,    void|function(int,int,string,string:string) cell_callback )   {    .Buffer res = .Buffer(); -  if(!cell_color) cell_color = "#ffffff"; +     if(cell_callback) {    foreach(rows; int y; array(string) row) {    res->add("<tr>");    foreach(row; int x; string cell)    res->add( cell_callback(x, y, cell_color, cell) );    res->add("</tr>");    }    }    else    foreach(rows, array(string) row) {    res->add("<tr>");    foreach(row, string cell)    res->add("<td bgcolor='", cell_color, "'>", cell, "</td>");    res->add("</tr>");    }       return wrap_simple_obox((string)res, frame_color, width, padding);   }    - private string wrap_simple_obox( string rows, void|string frame_color, -  void|string width, void|string padding ) { -  if(!frame_color) frame_color = "#000000"; + private string wrap_simple_obox( string rows, string frame_color="#000000", +  string width="1", string padding="3" ) {    return "<table bgcolor='" + frame_color + "' cellspacing='0' cellpadding='0' border='0'><tr><td>\n" -  "<table bgcolor='" + frame_color + "' cellspacing='" + (width||"1") + "' cellpadding='" + -  (padding||"3") + "' border='0'>\n" + rows + "</table></td></tr></table>"; +  "<table bgcolor='" + frame_color + "' cellspacing='" + width + "' cellpadding='" + +  padding + "' border='0'>\n" + rows + "</table></td></tr></table>";   }      //! Pads out the rows in a array of rows to equal length. The new elements in   //! the rows will have the value provided in @[padding], or "&nbsp;". - array(array(string)) pad_rows( array(array(string)) rows, void|string padding ) { + array(array(string)) pad_rows( array(array(string)) rows, string padding="&nbsp;" ) {    int m = max( @map(rows, sizeof) ); -  if(!padding) padding = "&nbsp;"; +     for(int i; i<sizeof(rows); i++)    if(sizeof(rows[i])<m)    rows[i] = rows[i] + allocate(m-sizeof(rows[i]), padding);    return rows;   }      //! Provides the same functionality as the @[simple_obox] function,   //! in a "streaming" way. The real gain is different addtition methods   //! as well as the possibility to change the cell callback at any time.   //!