CodeIgniter: Ability to add HTML attributes to a table row such as class or id

It is annoying that CodeIgniter’s HTML Table class does not support the ability to add attributes to the table rows such as classes, ids and data-attr. Using something like the Twitter BootStrap you may be wanting to add classes to the rows so that you can style rows that are success, errors or warnings.

I decided that this is crazy and that the rows should work the same as the cells. I have posted two options on GitHub to overcome the problem:

  1. Extend the Table class -> https://github.com/dalehurley/codeigniter-table-rows -> add MY_Table.php to application/libraries folder
  2. Replace the Table class -> https://github.com/EllisLab/CodeIgniter/pull/2540 -> replace CI_Table.php in system/libraries folder (please comment and push for this to be pulled)
  3. Despite which solution you chose you can add the HTML attributes to the table row using 1 of two methods:

        $rows[]=array('data'=>$row, 'class'=>'warning');
        echo $this->table->generate($rows);
    

    or

        $this->table->add_row(array('data'=>$row, 'class'=>'warning'));
    

    So you may want to do something like:

        $this->load->library('table');
        foreach($people as $person)
        {
            $row_data=array($person->given_name,$person->family_name,$person->city);
            $this->table->add_row(array('data'=>$row_data, 'class'=>$person->status));
        }
        $this->table->set_heading(array('Given name','Family Name', 'City'));
        echo $this->table->generate($rows);
    
    Advertisements

PHP Multi-thread Asynchronous Process Manager

PHP Multi-thread Asynchronous Process Manager

I have been build some background apps recently which need to do a lot of repetitions (think 100,000 times the same task which takes about 0.25 to 1 second to execute, of which most of it is waiting for the remote server to respond). Since these are daily and are not that server intensive it made sense to run them concurrently so instead of taking the good part of the day it just takes a few hours. I noticed on the proc_open page there was a very nice solution by Matou Havlena of havlena.net.

Continue reading “PHP Multi-thread Asynchronous Process Manager”

Password Hashing – With some smart salt

Password Hashing – With some smart salt

Basic hashing of passwords is poor. LinkedIn should have expected that one day that their password list would be stolen and when that happened it should have been hashed better so a standard dictionary could not reverse the passwords. Tthe LinkedIn passwords were leaked all over internet and with the help of crowd-sourced hackers the passwords were easily reversed back from SHA-1 hashes substrings to the plain text passwords. With tools like John the Ripper social hackers like Francois Pesce was able to reverse over 2 million LinkedIn passwords.

Continue reading “Password Hashing – With some smart salt”