diff scald_dailymotion.module @ 4:fd5fb845d0bc

Add an auto-import admin screen
author Franck Deroche <franck@defr.org>
date Mon, 19 Jul 2010 14:46:20 +0200
parents 2a63a6e15166
children f0e59759c605
line wrap: on
line diff
--- a/scald_dailymotion.module	Mon Jul 19 14:45:25 2010 +0200
+++ b/scald_dailymotion.module	Mon Jul 19 14:46:20 2010 +0200
@@ -1,4 +1,9 @@
 <?php
+// $Id$
+/**
+ * @file
+ *   Defines a DailyMotion provider for Scald.
+ */
 define('DAILYMOTION_RSS', 'http://www.dailymotion.com/rss/');
 define('NS_MEDIA',              'http://search.yahoo.com/mrss');
 define('NS_DM',                 'http://www.dailymotion.com/dmrss');
@@ -42,11 +47,51 @@
     'scald_dailymotion_player' => array(
       'arguments' => array('video' => NULL, 'thumbnail' => NULL),
       'template' => 'scald_dailymotion_player'
+    ),
+    'scald_dailymotion_imports_table' => array(
+      'arguments' => array('form' => NULL),
+      'file' => 'scald_dailymotion.admin.inc'
     )
   );
 }
 
 /**
+ * Implements hook_perm.
+ */
+function scald_dailymotion_perm() {
+  return array('administer dailymotion imports');
+}
+
+/**
+ * Implements hook_cron.
+ */
+function scald_dailymotion_cron() {
+  $imports = variable_get('scald_dailymotion_imports', array());
+  foreach ($imports as $import) {
+    $items = scald_dailymotion_feed($import['type'], $import['value']);
+    foreach ($items as $item) {
+      scald_dailymotion_register($item);
+    }
+  }
+}
+
+/**
+ * Implements hook_menu.
+ */
+function scald_dailymotion_menu() {
+  $items = array();
+  $items['admin/settings/scald_dailymotion'] = array(
+    'title' => 'DailyMotion imports',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('scald_dailymotion_imports_form'),
+    'access arguments' => array('administer dailymotion imports'),
+    'description' => 'Configure the videos that should be automatically imported from DailyMotion',
+    'file' => 'scald_dailymotion.admin.inc'
+  );
+  return $items;
+}
+
+/**
  * Creates an atom based on a DailyMotion video id or an object
  * containing the video informations..
  * @param $video