| Project: | Drupal.org CVS applications |
| Component: | Miscellaneous |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (won't fix) |
| Issue tags: | module review |
Issue Summary
Because we consider OpenSource as an exchange of knowledge.We are developing modules that fit the needs of our projects / customer and want to give these modules back to the community.
The first one we want to share is a module called "Silverlight Video". It's a silverlight player for Drupal.
More Information:
Name of module: Silverlight Video
Version: 1.0
Author: Daniel Greitens, Daniel Wissemann
Description:
“Silverlight Video” is a module, that can show wmv videos within a Silverlight player. The module stores every video as a node. Several options can be changed in the administration area. The module works with the templates generated by Expression Encoder, hence the templates are fully customizable with Expression Blend.
Function list:
- New content-type for Silverlight-videos
- Videos can be import from the files directory directly. The module creates a node for every video
- The module works with the templates generated by Expression Encoder
- The templates are fully customizable with Expression Blend
- Several settings can be set in the administration area
Available Seetings:
- Auto load: The video loads automatically when the page has loaded
- Autoplay: The video plays automatically when the page has loaded
- Display Timecode (Effect depends on template)
- Enable cached composition: Enables GPU support for video playback
- Enable captions: Shows captions under the video
- Enable offline: Stores the video locally in the isolated storage of silverlight
- Enable popout: Opens the video in a new window
- Start muted: The video plays in muted mode
- Stretchmode: Enables fullscreen videoplayback
- Width:The width of the video
- Height: The height of the video
Dependencies:
- Upload module
Comments
#1
#2
please don´t use this version
#3
Which should the file to review?
#4
The first file :)
#5
I guess you mean the file attached in comment #1. Thanks for the answer.
#6
<?php'#options' => array(
silverlightvideo_autoload_true => t('TRUE'),
silverlightvideo_autoload_false => t('FALSE'),
),
?>
The array indexes are not strings, or numbers.
<?php'#title' => t('Display Timecode'),
'#default_value' => variable_get('displaytimecode', displaytimecode_false),
?>
Strings used in user interface should have the first word in capital case, and the other words in lower case (with the exception of proper nouns, adjectives derived from proper nouns, and acronyms).
The Drupal variable used doesn't respect the namespace.
<?php$form['silverlightvideo']['general']['startmuted'] = array(
'#type' => 'radios',
'#title' => t('Start muted'),
'#default_value' => variable_get('startmuted', startmuted_false),
'#options' => array(
silverlightvideo_startmuted_true => t('TRUE'),
silverlightvideo_startmuted_false => t('FALSE'),
),
);
?>
Why isn't the code using a checkbox?
<?php// Some constant definitions to make later code clearer
define('silverlightvideo_DO_NOT_DISPLAY', 3);
define('silverlightvideo_DEFAULT_HTML_ALT', 'You are missing a video that should appear here! Perhaps your browser cannot display it, or maybe it did not initialise correctly.');
define('silverlightvideo_DEFAULT_WEIGHT', -0.1);
define('silverlightvideo_DEFAULT_IMPORT_STATUS', 0);
define('silverlightvideo_DEFAULT_PATH', 'silverlightvideos');
define('silverlightvideo_DEFAULT_EXTENSIONS', 'wmv');
?>
See the Drupal coding standards to understand how a module code should be written.
<?php/**
* Implementation of hook_perm
*/
function silverlightvideo_perm() {
return array(
t('administer silverlightvideos'),
t('create silverlightvideos'),
t('edit own silverlightvideos'),
t('edit any silverlightvideo'),
t('delete own silverlightvideos'),
t('delete any silverlightvideo'),
t('import video'),
);
}
?>
The hook should pass the permission strings without to translate them.
<?php$items['admin/settings/silverlightvideo'] = array(
'title' => t('silverlightvideo'),
'description' => t('Set various silverlightvideo node default options.'),
?>
Menu titles, and descriptions are not passed to
t().<?phpdrupal_set_message('New node');
?>
The string is not translated; then, the message seems a debug message that should be removed.
<?php'#description' => $node->silverlightvideo['fid'] ? t('<font color ="red"><b>Current file is %filename. Click "Browse..." to upload a different file.</b></font>', array('%filename' => basename($node->silverlightvideo['filepath']))) : t('Click "Browse..." to select a file to upload.'),
?>
The attribute color is deprecated in favor of CSS styles.
<?php'#type' => 'fieldset',
'#title' => t('Advance settings'),
?>
It should be .
<?phpfunction silverlightvideo_view($node, $teaser = "FALSE", $page = 0) {
?>
$teaseris not a string.<?php
if ($node->type != 'silverlightvideo') {
$error = t('Macro tried to load node @nid which is not a silverlightvideo node .', array('@nid' => $args['nid']));
}
}
// If the initial phase failed display a message and log in watchdog for admin
if ($error) {
//drupal_set_message($error, 'error');
watchdog('silverlightvideo', $error, NULL, WATCHDOG_ERROR);
?>
The second argument of
watchdog()is not correct.<?php
case 'description':
return t('Add silverlight from a silverlightvideo node to your posts using a silverlightvideo node macro.');
break;
case 'process':
foreach(silverlightvideo_get_macros($text) as $unexpanded_macro => $macro) {
$replace = silverlightvideo_content($macro, $format);
$search = '@(<p>)?'.preg_quote($unexpanded_macro).'(</p>)?@';
$text = preg_replace($search, $replace, $text);
}
return $text;
break;
?>
It doesn't seem that the code verify if the user has access to the silverlightvideo node, before to return any data about that node. This is a security issue.
<?php
$silverlightvideo_path = file_create_path(variable_get('silverlightvideo_default_path', silverlightvideo_DEFAULT_PATH));
$silverlightvideo_temp_path = $silverlightvideo_path .'/temp';
// Check if directories exist, create them if not
file_check_directory($silverlightvideo_path, FILE_CREATE_DIRECTORY, 'silverlightvideo_default_path');
?>
The code doesn't seem correct; first it uses
variable_get('silverlightvideo_default_path', silverlightvideo_DEFAULT_PATH), and then'silverlightvideo_default_path'.<?php// Helper function
function _silverlightvideo_directorytoarray($directory, $recursive) {
$array_items = array();
if ($handle = opendir($directory)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if (is_dir($directory. "/" . $file)) {
if ($recursive) {
$array_items = array_merge($array_items, _silverlightvideo_directorytoarray($directory. "/" . $file, $recursive));
}
$file = $directory . "/" . $file;
$array_items[] = preg_replace("/\/\//si", "/", $file);
}
else {
$file = $directory . "/" . $file;
$array_items[] = preg_replace("/\/\//si", "/", $file);
}
}
}
closedir($handle);
}
return $array_items;
}
?>
Why isn't the code using a Drupal function with the same purpose?
<?php
$form['files'] = array('#prefix' => '<ul>', '#suffix' => '</ul>', '#tree' => TRUE);
// array_filter in the call returned only elements with TRUE values
foreach ($files as $file) {
$form['files'][$file] = array('#type' => 'hidden', '#value' => $file, '#prefix' => '<li>', '#suffix' => check_plain(str_replace(file_create_path(variable_get('silverlightvideo_default_path', silverlightvideo_DEFAULT_PATH)).'/', '', $file)) ."</li>\n");
}
?>
Hidden items are not shown in the HTML page; the code is building a list of items that are not visible.
<?php
$node = new stdClass();
$file = new stdClass();
// Omissis.
$node->silverlightvideo['height'] = $info['height'];
$node->silverlightvideo['width'] = $info['width'];
$file->filemime = $info['mime_type'];
// Set a flag to tell silverlightvideo_insert we are adding files via import - currently suppresses file validation
$node->silverlightvideo['import'] = TRUE;
// Prepare the file object
$file->uid = $user->uid;
$file->filename = basename($file_to_import);
$file->filepath = $file_to_import;
$file->status = FILE_STATUS_PERMANENT;
$file->timestamp = time();
$file->filesize = filesize(realpath($file_to_import));
// If we didn't get mime type from earlier attempt we will need to try and guess it from the extension
if (!$file->filemime) {
if (preg_match('@wmv$@i', $file->filename, $matches)) {
$file->filemime = 'Audio-/X-ms-wmv';
}
}
// Write file to the database
drupal_write_record('files', $file);
// Add fid to the silverlightvideo object
$node->silverlightvideo['fid'] = db_last_insert_id('files', 'fid');
// Save the node
node_save($node);
?>
Before to save a node that has been built in memory, the code should allow to third-party modules to add their own data.
<?phpelse {
drupal_set_message(t('Failed to import ').$file_to_import, 'warning');
}
?>
Rather than concatenating two strings, the code should use a placeholder.
<?php'description' => t('Stores details associated with each silverlight file, such as height, width and display mode.'),
?>
Schema descriptions should not be passed to
t()anymore. See system_schema() for an example of what done by Drupal core code.#7
#8
Hello,
In the Attachment is a newer version.
The following Points were fixed:
1.2, 5, 6, 7, 8, 9, 10, 11, 12, 17, 18
#9
#10
<?php
$form['silverlightvideo']['general'] = array(
'#type' => 'fieldset',
'#title' => t('General settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['silverlightvideo_updated']['general'] = array(
'#type' => 'hidden',
'#value' => time(),
);
$form['silverlightvideo']['general']['autoload'] = array(
'#type' => 'radios',
'#title' => t('Auto load'),
'#default_value' => variable_get('autoload', autoload_true),
'#options' => array(
t('TRUE'),t('FALSE'),
),
);
?>
See the Drupal coding standards to understand how a module code should be written.
In particular, see how the code should be formatted, and the part about the namespace respect.
Also, I don't see the definition of the constant
autoload_truein that file, and the file is not including another file.#11
Hello,
I have fixed the formatting of the Quellcode.
I´m tested with the coder module.
Then i have changed the name of the constants.
#12
Hello I am new to the drupal community and have just started learning to use it. I would like to integrate Silverlight into my site and this is the only thing I can find on the website regarding Silverlight. However, since I cannot find this work under the Modules section of this website, it is unclear to me if this is something that can be used now? I see that I could download the attached .zip file (silverlightvideo.zip) but again I am concerned about the status of said code etc.
Thanks,
Dex
#13
#14
#15
Hi all,
after 1,5 months of waiting, I don't understand the current project status.
Is something happening there?
Or are we doing something wrong?
With this module we wanted to say thank you and give something back to the community.
Are you uninterested in our work?
Thanks
maximago
#16
#17
It's a little bit sad...we are developing for the community and don't succeed in making it public. Please just tell us, what is needed to get it public!
#18
The code contains code lines as
variable_get(framerate, ''), which are not correct for two reasons (I have already reported why such lines are not correct).#19
There have not been replies in the last week. I am marking this application as .