aboutsummaryrefslogtreecommitdiff
path: root/start.php
diff options
context:
space:
mode:
authorSem <sembrestels@riseup.net>2012-04-17 23:54:30 -0700
committerSem <sembrestels@riseup.net>2012-04-17 23:54:30 -0700
commita613b944015fd82f97a15392c0de0e7df104706d (patch)
tree5022ba0160427bec07cf9fdf337ef8161e4071b9 /start.php
parentf1a0a4d5aa28753620552df9d5e88bd983d0aca4 (diff)
parent4af120de2bd0fe2046795346a40102f00fbe5479 (diff)
downloadelgg-a613b944015fd82f97a15392c0de0e7df104706d.tar.gz
elgg-a613b944015fd82f97a15392c0de0e7df104706d.tar.bz2
Merge pull request #1 from mrclay/master
Partial rewrite
Diffstat (limited to 'start.php')
-rw-r--r--start.php102
1 files changed, 85 insertions, 17 deletions
diff --git a/start.php b/start.php
index 07ec618a0..77bf0a7bc 100644
--- a/start.php
+++ b/start.php
@@ -61,6 +61,9 @@ function videolist_init() {
// register for embed
elgg_register_plugin_hook_handler('embed_get_sections', 'all', 'videolist_embed_get_sections');
elgg_register_plugin_hook_handler('embed_get_items', 'videolist', 'videolist_embed_get_items');
+
+ // handle URLs without scheme
+ elgg_register_plugin_hook_handler('videolist:preprocess', 'url', 'videolist_preprocess_url');
// Register actions
$actions_path = elgg_get_plugins_path() . "videolist/actions/videolist";
@@ -128,6 +131,12 @@ function videolist_page_handler($page) {
/**
* Add a menu item to the user ownerblock
+ *
+ * @param string $hook
+ * @param string $type
+ * @param array $return
+ * @param array $params
+ * @return array
*/
function videolist_owner_block_menu($hook, $type, $return, $params) {
if (elgg_instanceof($params['entity'], 'user')) {
@@ -145,6 +154,10 @@ function videolist_owner_block_menu($hook, $type, $return, $params) {
return $return;
}
+/**
+ * @param ElggObject $videolist_item
+ * @return string
+ */
function videolist_url($videolist_item) {
$guid = $videolist_item->guid;
$title = elgg_get_friendly_title($videolist_item->title);
@@ -154,6 +167,9 @@ function videolist_url($videolist_item) {
/**
* Event handler for videolist
*
+ * @param string $event
+ * @param string $object_type
+ * @param ElggObject $object
*/
function videolist_object_notifications($event, $object_type, $object) {
static $flag;
@@ -177,11 +193,11 @@ function videolist_object_notifications($event, $object_type, $object) {
* Intercepts the notification on an event of new video being created and prevents a notification from going out
* (because one will be sent on the annotation)
*
- * @param unknown_type $hook
- * @param unknown_type $entity_type
- * @param unknown_type $returnvalue
- * @param unknown_type $params
- * @return unknown
+ * @param string $hook
+ * @param string $entity_type
+ * @param array $returnvalue
+ * @param array $params
+ * @return bool
*/
function videolist_object_notifications_intercept($hook, $entity_type, $returnvalue, $params) {
if (isset($params)) {
@@ -198,10 +214,11 @@ function videolist_object_notifications_intercept($hook, $entity_type, $returnva
/**
* Register videolist as an embed type.
*
- * @param unknown_type $hook
- * @param unknown_type $type
- * @param unknown_type $value
- * @param unknown_type $params
+ * @param string $hook
+ * @param string $type
+ * @param array $value
+ * @param array $params
+ * @return array
*/
function videolist_embed_get_sections($hook, $type, $value, $params) {
$value['videolist'] = array(
@@ -216,14 +233,15 @@ function videolist_embed_get_sections($hook, $type, $value, $params) {
/**
* Return a list of videos for embedding
*
- * @param unknown_type $hook
- * @param unknown_type $type
- * @param unknown_type $value
- * @param unknown_type $params
+ * @param string $hook
+ * @param string $type
+ * @param array $value
+ * @param array $params
+ * @return array
*/
function videolist_embed_get_items($hook, $type, $value, $params) {
$options = array(
- 'owner_guid' => get_loggedin_userid(),
+ 'owner_guid' => elgg_get_logged_in_user_guid(),
'type_subtype_pair' => array('object' => 'videolist_item'),
'count' => TRUE
);
@@ -245,13 +263,18 @@ function videolist_embed_get_items($hook, $type, $value, $params) {
/**
* Override the default entity icon for videoslist items
*
+ * @param string $hook
+ * @param string $type
+ * @param string $returnvalue
+ * @param array $params
* @return string Relative URL
*/
function videolist_icon_url_override($hook, $type, $returnvalue, $params) {
$videolist_item = $params['entity'];
- $size = $params['size'];
-
- if($videolist_item->getSubtype() != 'videolist_item'){
+ /* @var ElggObject $videolist_item */
+ $size = $params['size'];
+
+ if($videolist_item->getSubtype() != 'videolist_item'){
return $returnvalue;
}
@@ -266,6 +289,51 @@ function videolist_icon_url_override($hook, $type, $returnvalue, $params) {
}
/**
+ * @param ElggObject $videolist_item
+ * @return array
+ */
+function videolist_get_video_dimensions(ElggObject $videolist_item) {
+ $dimensions = array(
+ 'width' => 600,
+ 'height' => 400,
+ );
+ $params['entity'] = $videolist_item;
+ $params['videotype'] = $videolist_item->videotype;
+ $dimensions = elgg_trigger_plugin_hook(
+ 'videolist:setdimensions',
+ $params['videotype'],
+ $params,
+ $dimensions);
+ if (! is_array($dimensions)) {
+ $dimensions = array();
+ }
+ if (empty($dimensions['width']) || ! is_numeric($dimensions['width'])) {
+ $dimensions['width'] = 600;
+ }
+ if (empty($dimensions['height']) || ! is_numeric($dimensions['height'])) {
+ $dimensions['height'] = 400;
+ }
+ return $dimensions;
+}
+
+/**
+ * Prepend HTTP scheme if missing
+ * @param string $hook
+ * @param string $type
+ * @param string $returnvalue
+ * @param array $params
+ * @return string
+ */
+function videolist_preprocess_url($hook, $type, $returnvalue, $params) {
+ $parsed = parse_url($returnvalue);
+ if (empty($parsed['host']) && ! empty($parsed['path']) && $parsed['path'][0] !== '/') {
+ // user probably forgot scheme
+ $returnvalue = 'http://' . $returnvalue;
+ }
+ return $returnvalue;
+}
+
+/**
* Process upgrades for the videolist plugin
*/
function videolist_run_upgrades() {