Changeset ce988a0 in github


Ignore:
Timestamp:
Feb 9, 2011 5:33:26 AM (2 years ago)
Author:
thomascube <thomas@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
ea23df6
Parents:
829cbfe8
Message:

Always generate valid DOM identifiers using html_identifier() write original identifier string to rel attribute where possible

Location:
program
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • program/include/main.inc

    ra77cf22 rce988a0  
    742742 
    743743/** 
     744 * Convert the given string into a valid HTML identifier 
     745 * Same functionality as done in app.js with this.identifier_expr 
     746 * 
     747 */ 
     748function html_identifier($str) 
     749{ 
     750  return asciiwords($str, true, '_'); 
     751} 
     752 
     753/** 
    744754 * Remove single and double quotes from given string 
    745755 * 
     
    792802    { 
    793803      $zebra_class = $c % 2 ? 'even' : 'odd'; 
    794       $table->add_row(array('id' => 'rcmrow' . $sql_arr[$id_col], 'class' => $zebra_class)); 
     804      $table->add_row(array('id' => 'rcmrow' . html_identifier($sql_arr[$id_col]), 'class' => $zebra_class)); 
    795805 
    796806      // format each col 
     
    809819        $zebra_class .= ' '.$row_data['class']; 
    810820 
    811       $table->add_row(array('id' => 'rcmrow' . $row_data[$id_col], 'class' => $zebra_class)); 
     821      $table->add_row(array('id' => 'rcmrow' . html_identifier($row_data[$id_col]), 'class' => $zebra_class)); 
    812822 
    813823      // format each col 
     
    14881498 
    14891499    // make folder name safe for ids and class names 
    1490     $folder_id = asciiwords($folder['id'], true, '_'); 
     1500    $folder_id = html_identifier($folder['id']); 
    14911501    $classes = array('mailbox'); 
    14921502 
     
    15231533      'href' => rcmail_url('', array('_mbox' => $folder['id'])), 
    15241534      'onclick' => sprintf("return %s.command('list','%s',this)", JS_OBJECT_NAME, $js_name), 
     1535      'rel' => $folder['id'], 
    15251536      'title' => $title, 
    15261537    ); 
  • program/js/app.js

    r07b95dc rce988a0  
    37823782  this.update_contact_row = function(cid, cols_arr, newcid) 
    37833783  { 
     3784    cid = String(cid).replace(this.identifier_expr, '_'); 
     3785    newcid = String(newcid).replace(this.identifier_expr, '_'); 
     3786 
    37843787    var row; 
    37853788    if (this.contact_list.rows[cid] && (row = this.contact_list.rows[cid].obj)) { 
     
    38143817      row = document.createElement('tr'); 
    38153818 
    3816     row.id = 'rcmrow'+cid; 
     3819    row.id = 'rcmrow'+String(cid).replace(this.identifier_expr, '_'); 
    38173820    row.className = 'contact '+(even ? 'even' : 'odd'); 
    38183821 
  • program/steps/addressbook/func.inc

    r29aab5a rce988a0  
    121121        'id' => 'rcmli%s', 'class' => 'addressbook %s'), 
    122122        html::a(array('href' => '%s', 
     123            'rel' => '%s', 
    123124            'onclick' => "return ".JS_OBJECT_NAME.".command('list','%s',this)"), '%s')); 
    124125 
     
    130131        $id = strval($source['id'] ? $source['id'] : $j); 
    131132        $js_id = JQ($id); 
    132         $dom_id = preg_replace('/[^a-z0-9\-_]/i', '_', $id); 
    133         $out .= sprintf($line_templ, $dom_id, ($current === $id ? 'selected' : ''), 
     133        $out .= sprintf($line_templ, 
     134            html_identifier($id), 
     135            ($current === $id ? 'selected' : ''), 
    134136            Q(rcmail_url(null, array('_source' => $id))), 
     137            $source['id'], 
    135138            $js_id, (!empty($source['name']) ? Q($source['name']) : Q($id))); 
    136139 
     
    159162            'id' => 'rcmliG%s', 'class' => 'contactgroup'), 
    160163            html::a(array('href' => '#', 
     164                'rel' => '%s:%s', 
    161165                'onclick' => "return ".JS_OBJECT_NAME.".command('listgroup',{'source':'%s','id':'%s'},this)"), '%s')); 
    162166 
    163167        $jsdata = array(); 
    164168        foreach ($groups as $group) { 
    165             $args['out'] .= sprintf($line_templ, asciiwords($args['source'] . $group['ID'], true, '_'), $args['source'], $group['ID'], Q($group['name'])); 
     169            $args['out'] .= sprintf($line_templ, 
     170                html_identifier($args['source'] . $group['ID']), 
     171                $args['source'], $group['ID'], 
     172                $args['source'], $group['ID'], Q($group['name']) 
     173            ); 
    166174            $args['jsdata']['G'.$args['source'].$group['ID']] = array( 
    167175                'source' => $args['source'], 'id' => $group['ID'], 
  • program/steps/addressbook/save.inc

    r07b95dc rce988a0  
    250250 
    251251    rcmail_js_contacts_list($result, 'parent.'); 
    252     $OUTPUT->command('parent.contact_list.select', $insert_id); 
     252    $OUTPUT->command('parent.contact_list.select', html_identifier($insert_id)); 
    253253 
    254254    // update record count display 
Note: See TracChangeset for help on using the changeset viewer.