CVS edit link for web2make

Web2make is web development company working in Drupal. We have developed many modules for our clients and we plan to contribute them back to Drupal. First module to present is a Excelfield. This module creates new CCK field type called Excelfield. It allows for uploading MS Excel (.xls) files and uses PHPExcelReader source code from (http://sourceforge.net/projects/phpexcelreader) to parse and display content in a node. In future we plan to expand this module to parse and store data in a database.

Comments

web2make’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new17.22 KB

Module uploaded

avpaderno’s picture

Issue tags: +Module review
avpaderno’s picture

Status: Needs review » Needs work
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_0.txt.  If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.

Files available from third-party sites should not be included in Drupal.org CVS.
In Drupal.org CVS the only accepted files are the ones licensed under GPL license v2+; compatible licenses are not accepted.

web2make’s picture

StatusFileSize
new6.04 KB

Licensed code removed.

avpaderno’s picture

See the Drupal coding standards to understand how a module code should be written.

You should add a file INSTALL.txt, explaining that the user needs to download two files, where to download them from, and where to copy them.

web2make’s picture

I modified code to apply to standards. Also I added a Readme file to explain installation and usage of a module. Please review it.

Regards

web2make’s picture

Status: Needs work » Needs review
StatusFileSize
new6.42 KB

Forget to attach a code!

avpaderno’s picture

Status: Needs review » Needs work
$output.= "
function change_tabs(sheet)
{
    //alert('sheet_tab_' + sheet);
    for(i=0;i<" . count($data->sheets) . ";i++)
    {
        document.getElementById('sheet_tab_' + i).className = 'tab_base';
    }
    document.getElementById('table_loader_div').innerHTML=sheet_HTML[sheet];
    document.getElementById('sheet_tab_' + sheet).className = 'tab_loaded';

}
</SCRIPT>";

The JavaScript code is not using any jQuery functions to handle the HTML elements.

function make_alpha_from_numbers($number)
{
    $numeric = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    if($number<strlen($numeric))
    {
        return $numeric[$number];
    }
    else
    {
        $dev_by = floor($number/strlen($numeric));
        return "" . make_alpha_from_numbers($dev_by-1) . make_alpha_from_numbers($number-($dev_by*strlen($numeric)));
    }
}

See the Drupal coding standards to understand how a module code should be written.

web2make’s picture

Status: Needs work » Needs review
StatusFileSize
new17.61 KB

Jquery added, and some code changes. Please review.

sreynen’s picture

You're still not following Drupal coding standards. Coder can point out specific problems, but you should really read the link kiamlaluno keeps suggesting to get a good understanding of Drupal coding standards. In addition to the standards, you're violating an important guideline from JavaScript in Drupal:

"All pages should be perfectly functional without scripts."

That's not really Drupal-specific at all, just best practice on the web in general. Putting your HTML in the HTML document rather than the JavaScript will also allow you to validate it, which will reveal a lot of validation errors.

avpaderno’s picture

Status: Needs review » Needs work

I am changing the status as per previous comment.

web2make’s picture

Status: Needs work » Needs review
StatusFileSize
new5.98 KB

Thanks for the comments Sreyen. Didnt now about Coder, it is very useful!
Now coder shows zero errors, and I removed Javascript for now. Please review again :)

avpaderno’s picture

Status: Needs review » Needs work
  1. function excelfield_init() {
      // If FileField is not available, immediately disable videofield.
      if (!module_exists('filefield')) {
        module_disable(array('excelfield'));
        drupal_set_message(t('The excelfield module has been disabled. The <a href="http://drupal.org/project/filefield">FileField module</a> needs to be installed for it to work properly.'));
        return;
      }
    
      module_load_include('inc', 'excelfield', 'excelfield_widget');
    }
    

    That code is not necessary; the module declares its dependency from the other module, and it cannot be enabled if the other module is not enabled too.

  2. function excelfield_widget_info() {
      return array(
        'excelfield_widget' => array(
          'label' => t('Excel Upload'),
          'field types' => array('filefield'),
          'multiple values' => CONTENT_HANDLE_CORE,
          'callbacks' => array('default value' => CONTENT_CALLBACK_CUSTOM),
          'description' => t('Widget for uploading MS Excel.'),
        ),
      );
    }
    <
    

    Implemented hooks should be declared to be hooks, as it has been already done with the others.

  3.   error_reporting(E_ALL ^ E_NOTICE);
    

    Debugging lines should be removed; the level of the error reporting is already set by Drupal at bootstrap, and modules don't have a reason to change it. If you would use a Drupal development snapshot (which allows to see even the E_NOTICE warnings), the module would interfere with a feature of Drupal that one is supposed to see; sometimes the development snapshot is installed because it allows to see also those warning notices that a module should never produce.

  4.     for ($i=0; $i<$data->sheets[$sheet]['numCols'] && ($i<=$max_cols || $max_cols==0); $i++) {
            $table_output[$sheet] .= "<TD CLASS='table_sub_heading' ALIGN=CENTER>" . _excelfield_make_alpha_from_numbers($i) . "</TD>";
        }
    

    The HTML output is supposed to be XHTML; the output of the theme function is not well formed XHTML (see <TD CLASS='table_sub_heading' ALIGN=CENTER>). For a reference of the differences between HTML 4 and XHTML 1.0, see http://www.w3.org/TR/xhtml1/.

web2make’s picture

Status: Needs work » Needs review
StatusFileSize
new5.7 KB

1. Removed, however I copied this code from imagefield and videofield module as reference on how to create CCK widget.

2. My mistake, forget it!

3. Yes, you are correct. I removed this and some other debuging lines as they are useless within Drupal.

4. I removed Align=center as this should be in CSS, also I added quatations to other properties (rowspan, colspan,...) and removed nobr tags. I think thats it!

avpaderno’s picture

Status: Needs review » Needs work

The output still is not well formed XHTML.
Check how the FOR-statements are writting; they should be written as for ($i = 12; $i < 23, $i++) { (the name of the variables is not the point, of course).

web2make’s picture

Status: Needs work » Needs review
StatusFileSize
new5.7 KB

XHTML now passes validation on http://validator.w3.org/check

atheneus’s picture

External libraries should really be placed in sites/all/libraries or sites//libraries. I suggest using the Libraries API to allow easier management/sharing of external libs (see: http://drupal.org/project/libraries).

excelfield_formatter.inc: line 89

The use of return t($output) is an extraneous function call since $output contains dynamically generated text wrapped in markup. There's no way this output can be caught and translated. Just return $output

I'm concerned there are no calls to check_plain() or check_markup() in this code when you are accepting uploaded documents from an untrusted source. You use nl2br(htmlentities(...)) where you should be using check_markup() to apply filters on output text.

atheneus’s picture

Status: Needs review » Needs work
avpaderno’s picture

Status: Needs work » Closed (won't fix)

There have not been replies from the OP in the past 7 days. I am marking this report as won't fix.