CVS edit link for VladRM

Hello,

My name is Vlad Rosca and I am a software developer for Zitec - a Romanian software company.
- http://www.zitec.com/outsourcing-software-romania.html

One of the company's long term projects is VideoPublishing which provides online video publishing solutions for businesses, publishers, video professionals and website owners.
- see http://videopublishing.com/ for more details

Currently I am working on a new Drupal project that requires VideoPublishing integration. As a result I wrote a module to accomplish this task and i would like to contribute it.

The module provides all the basic features we need so far:
1. Global Settings Page - where admins can set
- a default video player (select)
- content types that leverage videopublishing functionality (checkboxes)
- other minor settings (show videos in teasers-on/off, video weight, toggle display of video information)
2. Node specific settings
- select video player
- upload video to videopublishing.com (or provide a video id - video ids are provided by videopublishing.com)

Future development plans:
- videopublishing CCK field
- more extensive mapping of the videopublishing API

Comments

VladRM’s picture

StatusFileSize
new83.39 KB

Hi,

I attached the videopublishing module in zip format.

EDIT: Please use the upload attached to the next comment instead. I made the mistake of uploading the dev version, not the stable one.

VladRM’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new83.38 KB

Please ignore the previous upload and use the one attached to this comment.

avpaderno’s picture

Status: Needs review » Needs work
Issue tags: +Drupal 6.x, +Module review
  1. version = 6.x-1.0
    

    That line should be removed from the file.

  2. function videopublishing_init() {
      module_load_include('inc', 'videopublishing', 'videopublishing_api');
      module_load_include('inc', 'videopublishing', 'videopublishing_forms');
      module_load_include('inc', 'videopublishing', 'videopublishing_helpers');
    }
    

    hook_init() is called only on pages that are not cached; depending on the case, this could cause some problems, especially if the code always needs the code present in the included files.

  3.   if (in_array($node->type, $vp_content_types)) {
        switch ($op) {
          case 'view':
            if (!$a3 || variable_get('videopublishing_show_in_teaser', 0)) {
              $nvs = videopublishing_get_node_videos($node->nid, $node->vid);
        	  if ($nvs) {
                $embed_xml = videopublishing_get_stream_embed_code($nvs[0]['video_id'], $nvs[0]['player_id']);
                $embed_code = '<div class="vp-node-video">'. (string)$embed_xml .'</div>';
                
                if (variable_get('videopublishing_show_video_title', FALSE)) {
                  $info_xml = videopublishing_get_video_info($nvs[0]['video_id']);
                  $vp_title = '<h3 class="vp-node-video-title">'. (string)$info_xml->title .'</h3>';
                } else {
                  $vp_title = '';
                }
                
                $node->content['videopublishing_nodeapi_field'] = array(
                  '#value' => $vp_title . $embed_code,
                  '#weight' => variable_get('videopublishing_field_weight', 10),
                );
              }
    		}
          break;
    

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

  4.       case 'presave':
          break;
    

    If the code is not doing anything when $op is equal to presave, then there is no need to write that code.

  5. /**
     * Implementation of hook_perms().
     * 
     * Displays VideoPublishing specific input fields
     * in the node/add and node/<nid>/edit forms
     */
    function videopublishing_form_alter(&$form, $form_state, $form_id) {
      // ...
    }
    
    It isn't the implementation of hook_perms.
    </li>
    <li>
    <?php
      $schema['videopublishing'] = array(
        'description' => t('The base table for videopublishing.'),
        'fields' => array(
          'nid' => array(
            'description' => t('The primary identifier for a node'),
    

    Schema description should not be passed to t().

  6.   try {
        $factory = new Api_Methods_Factory(API_USER, API_USER_KEY, Api_Methods_Factory::XML_RESPONSE);
        $method = $factory->factory(Api_Methods_Factory::PLAYERS);
        
        $xml_string = $method->getAll();
        $xml = new SimpleXMLElement($xml_string);
        return $xml;
      }
    

    If you are using feature specific of PHP5, then you should declare the dependency of the module from PHP5, as Drupal 6 still support PHP4.

  7.   else {
        // do nothing
      }
    

    If it doesn't do anything, why is the ELSE-statement present?

  8. 	$form['#validate'] []= 'videopublishing_upload_form_validate';
        $form['#submit'] []= 'videopublishing_upload_form_submit';
    

    The name of the functions are not the one defined from the module.

  9.   $ct = explode(',', variable_get('videopublishing_content_types', NULL));
      foreach($ct as $v) {
        $options[$v] = $v;
      }
    

    It would be better to use variable_get('videopublishing_content_types', ''); I am not sure explode() is able to handle NULL.

  10.   $form['videopublishing']['player_id'] = array(
        '#type' => 'select',
        '#title' => t('Select default player'),
        '#default_value' => $default_vp_player_id,
        '#options' => videopublishing_settings_form_get_player_options(),
    	'#description' => t('You can create your own custom players through the Video Publishing GUI. See http://admin.videopublishing.com/players/'),
      );
    

    The options used in a form field should present to the user a translatable string.

  11.     '#description' => t('You can create your own custom players through the Video Publishing GUI. See <a href="http://admin.videopublishing.com/players/'" title="http://admin.videopublishing.com/players/'" rel="nofollow">http://admin.videopublishing.com/players/'</a>),
    

    Use the correct placeholders.

avpaderno’s picture

For the previous point #3, the code doesn't use the correct indentation.

VladRM’s picture

Status: Needs work » Needs review
StatusFileSize
new30.96 KB

Hello,

Thank you for the feedback.

2. hook_init()
- it did cause some problems so i added:

    module_load_include('inc', 'videopublishing', 'videopublishing_helpers');
    drupal_add_js(drupal_get_path('module', 'videopublishing') . '/videopublishing_upload_form.js');

to the hook_nodeapi where the files were required but not included.

Should I completely remove the hook_init() and move the module_load_include(s) to the hook_nodeapi and wherever else they might be needed?

8. "The name of the functions are not the one defined from the module."

    $form['#validate'] []= 'videopublishing_upload_form_validate';
    $form['#submit'] []= 'videopublishing_upload_form_submit';

I'm not sure I understand. The functions mentioned above are defined in videopublishing_forms.inc.

----

The other issues are resolved.
I attached a new version of the module (added functionality and fixed the issues above).

avpaderno’s picture

Status: Needs review » Needs work
  1. If you need to include files, you could put the code that includes them outside any function; in that way, the code will be included when the module is loaded.
  2. What I was trying to say is that the functions are present in a file that is not videopublishing.module; if that file is not being included (see my comment about hook_init()), then the functions are not found.
  3. The coding standards report also which functions should be used from the module; the code is still not following that point.
VladRM’s picture

Status: Needs work » Needs review
StatusFileSize
new32.27 KB

I removed hook_init() and used:

require_once 'videopublishing_api.inc';
require_once 'videopublishing_forms.inc';
require_once 'videopublishing_helpers.inc';

in videopublishing.module instead.

Sorry but I don't understand point 3. from your previous comment (#6). I reread http://drupal.org/coding-standards but did not find anything about 'which functions should be used from the module'.

avpaderno’s picture

Status: Needs review » Needs work
  1. The path used for require_once() is relative to Drupal root directory; therefore the files are not found as they are in the module directory.
    It should be better to use module_load_include().
  2. The coding standards do suggest a category of functions that the modules need to use.
    To notice that the coding standards are not only a book page. At the bottom of the first page you find the links to the child pages; one of the those child pages reports which functions should be used (the page says you should use these replacements when you are programming for Drupal).
VladRM’s picture

StatusFileSize
new32.27 KB

Hello,

1. I used module_load_include() instead of require_once().
2. Replaced the string functions with the drupal wrappers.
--
3. Replaced some tabs with spaces.

VladRM’s picture

Status: Needs work » Needs review

Status->Needs review

avpaderno’s picture

Status: Needs review » Needs work
  1.   t((string)$player->title)
    

    The first argument of t() should be a literal string; differently, the string will not be added in the translation template, and who translates the module would be able to translate that string. Using the Drupal translation system it is not possible to translate dynamically generated strings (if they don't use t() placeholders).

  2. function videopublishing_stream_id_label_mapper($stream_id) {
      $stream_id_map = array(
        1 => t('Standard'),
    	2 => t('Enhanced'),
    	3 => t('HD'),
      );
    

    The indentation character is not correct.

  3. function videopublishing_get_all_video_options($null_option=TRUE) {
      $vids = array();
    

    The code is not formatted as suggested by the coding standards.

  4.   require_once 'modules/node/node.pages.inc';
    
  5. All the content of the directory VideoPublising should be removed.
VladRM’s picture

Status: Needs work » Needs review
StatusFileSize
new32.24 KB

Hello,

I addressed the issues in your previous comment (and a few others I noticed regarding coding standards) but I have a few questions:
@5. Why should I remove the content of the VideoPublising directory?
- it includes the Videopublishing API
The code in videopublishing_api.inc is only a (drupal - videopublishing api) bridge

@4. I used module_load_include() instead. Was this the issue or did I miss the point?

avpaderno’s picture

Status: Needs review » Needs work

The library is available from a third-party site; in that case, it should not included in Drupal.org CVS.

Also, files from other projects should not be committed in Drupal.org CVS; if you would create (in example) a jQuery plugin, you should probably make it available from a different server.

VladRM’s picture

Status: Needs work » Needs review
StatusFileSize
new9.29 KB

Thank you for the info.
I removed the contents of the VideoPublishing subdirectory and added a README.txt file to help users with the install process.

VladRM’s picture

StatusFileSize
new10.04 KB

Module Update:
- videopublishing.info file: changed php = 5 to php = 5.1.2
- videopublishing_api.inc bootstrap (users no longer need the VideoPublishing/config directory or the bootstrap.php file)
- the configuration options were moved to the admin/settings/videopublishing page
- videopublishing_forms.inc modified to accomodate the new config options + a new feature:
- the users may choose between a select list and an autocomplete field for Video ID selection
- README.txt file - small changes to installation instructions and php requirements

avpaderno’s picture

Status: Needs review » Fixed
  1.   define('API_BASE_DIR', dirname(__FILE__) .'/VideoPublishing');
    

    Drupal modules normally use drupal_get_path().

  2. Drupal.org CVS doesn't add directories that don't contain any files; if you want the directory VideoPublishing to appear in CVS (and then in the tarball archive generated by the packaging script), you need to add a file README.txt.
  3. There are some commented code lines that should be removed.

Thank you for your contribution! I am going to update your account.

These are some recommended readings to help with excellent maintainership:

You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, also, for your patience with the review process.
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

I thank all the dedicated reviewers as well.

VladRM’s picture

StatusFileSize
new10 KB

1. Indeed, I replaced it with:

define('API_BASE_DIR', drupal_get_path('module', 'videopublishing') .'/VideoPublishing');

2. I removed the VideoPublishing directory and added the necessary instructions for the users in the README.txt file. Should I add a generic (empty maybe) README.txt file in the VideoPublishing subdirectory so that CVS will add it (and not treat it as an empty directory)?
3. Done
---
4. Bugfix + replaced some tabs with spaces (found them in the .install file)

Thank you very much for your help! I really appreciate it.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mariusilie’s picture

any updates on this module? I submitted some issues on this project. Also, are there any plans on extending this module? because right now it doesn't uses the full API of the videopublishing.com

avpaderno’s picture

Component: Miscellaneous » new project application
Assigned: Unassigned » avpaderno
Issue summary: View changes
Issue tags: -Drupal 6.x