$lang['video_like'] = 'Like';
$lang['video_dislike'] = 'Dislike';
+$lang['video_show_more'] = 'Show more';
+$lang['video_show_less'] = 'Show less';
+
$lang['video_comment'] = 'Comment';
$lang['video_title_comment'] = 'Comment';
$lang['video_title_all_comments'] = 'All Comments';
--- /dev/null
+<?php
+
+/**
+ * CodeIgniter style sessions.
+ *
+ * @package OpenID
+ */
+class Auth_Yadis_CISession extends Auth_Yadis_PHPSession {
+
+ protected $ci = NULL;
+
+ public function __construct()
+ {
+ $this->ci =& get_instance();
+ $this->ci->load->library('session');
+ }
+
+ /**
+ * Set a session key/value pair.
+ *
+ * @param string $name The name of the session key to add.
+ * @param string $value The value to add to the session.
+ */
+ function set($name, $value)
+ {
+ $this->ci->session->set_userdata($name, $value);
+ }
+
+ /**
+ * Get a key's value from the session.
+ *
+ * @param string $name The name of the key to retrieve.
+ * @param string $default The optional value to return if the key
+ * is not found in the session.
+ * @return string $result The key's value in the session or
+ * $default if it isn't found.
+ */
+ function get($name, $default=NULL)
+ {
+ $value = $this->ci->session->userdata($name);
+ if ($value !== FALSE)
+ {
+ return $value;
+ }
+ else
+ {
+ return $default;
+ }
+ }
+
+ /**
+ * Remove a key/value pair from the session.
+ *
+ * @param string $name The name of the key to remove.
+ */
+ function del($name)
+ {
+ $this->ci->session->unset_userdata($name);
+ }
+
+ /**
+ * Return the contents of the session in array form.
+ */
+ function contents()
+ {
+ return $this->ci->session->all_userdata();
+ }
+}
+?>
require_once "Auth/OpenID/SReg.php";
require_once "Auth/OpenID/AX.php";
require_once "Auth/OpenID/PAPE.php";
+ require_once "Auth/extensions.php";
}
function set_sreg($enable, $required = NULL, $optional = NULL, $policy = NULL)
}
$store = new Auth_OpenID_FileStore($this->storePath);
- $consumer = new Auth_OpenID_Consumer($store);
+ $consumer = new Auth_OpenID_Consumer($store,
+ new Auth_Yadis_CISession());
return $consumer;
}
{
$sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($op_response);
$ax_resp = Auth_OpenID_AX_FetchResponse::fromSuccessResponse($op_response);
+
+ if ($ax_resp)
+ {
+ $ax_email = $ax_resp->get('http://axschema.org/contact/email');
+ $ax_first_name = $ax_resp->get(
+ 'http://axschema.org/namePerson/first');
+ $ax_last_name = $ax_resp->get('http://axschema.org/namePerson/last');
+ $ax_country = $ax_resp->get('http://axschema.org/contact/country');
+ }
+ else
+ {
+ $ax_email = '';
+ $ax_first_name = '';
+ $ax_last_name = '';
+ $ax_country = '';
+ }
+
+ if ($sreg_resp)
+ {
+ $sreg_email = $sreg_resp->get('email', '');
+ $sreg_fullname = $sreg_resp->get('fullname', '');
+ $sreg_nickname = $sreg_resp->get('nickname', '');
+ $sreg_country = $sreg_resp->get('country', '');
+ $sreg_dob = $sreg_resp->get('dob', NULL);
+ }
+ else
+ {
+ $sreg_email = $sreg_fullname = $sreg_nickname = $sreg_country = '';
+ $sreg_dob = NULL;
+ }
// E-mail
- $email = $ax_resp->get('http://axschema.org/contact/email');
- if (empty($email) || is_a($email, 'Auth_OpenID_AX_Error'))
- $data['email'] = $sreg_resp->get('email', '');
+ if (empty($ax_email) || is_a($ax_email, 'Auth_OpenID_AX_Error'))
+ $data['email'] = $sreg_email;
else
- $data['email'] = $email[0];
+ $data['email'] = $ax_email[0];
+ $data['email'] = strtolower($data['email']);
// First Name
- $first_name = $ax_resp->get('http://axschema.org/namePerson/first');
- if (empty($first_name) || is_a($first_name, 'Auth_OpenID_AX_Error'))
+ if (empty($ax_first_name)
+ || is_a($ax_first_name, 'Auth_OpenID_AX_Error'))
$data['first_name'] = '';
else
- $data['first_name'] = $first_name[0];
+ $data['first_name'] = $ax_first_name[0];
// Sur Name
- $last_name = $ax_resp->get('http://axschema.org/namePerson/last');
- if (empty($last_name) || is_a($last_name, 'Auth_OpenID_AX_Error'))
+ if (empty($ax_last_name) || is_a($ax_last_name, 'Auth_OpenID_AX_Error'))
$data['last_name'] = '';
else
- $data['last_name'] = $last_name[0];
+ $data['last_name'] = $ax_last_name[0];
// First Name and Last Name
if (empty($data['first_name']) || empty($data['last_name']))
{
- $fullname = $sreg_resp->get('fullname');
-
- if ($fullname)
+ if ($sreg_fullname)
{
if (empty($data['first_name']))
$data['first_name'] = substr(
- $fullname, 0, strrpos($fullname, ' '));
+ $sreg_fullname, 0, strrpos($sreg_fullname, ' '));
if (empty($data['last_name']))
$data['last_name'] = substr(
- $fullname, strrpos($fullname, ' ') + 1);
+ $sreg_fullname, strrpos($sreg_fullname, ' ') + 1);
}
}
// Username
- $data['username'] = $sreg_resp->get('nickname');
+ $data['username'] = $sreg_nickname;
if (!$data['username'])
{
+ // Generate username from email
if (!empty($data['email']))
{
- $data['email'] = strtolower($data['email']);
$data['username'] = substr($data['email'],
0, strpos($data['email'], '@'));
$data['username'] = preg_replace(array('/[^a-z0-9\._]*/'),
array(''), $data['username']);
}
+ // Generate username from first name and sur name
else if(!empty($data['first_name']) || !empty($data['last_name']))
{
$data['username'] = $data['first_name'] . '_'
. $data['last_name'];
}
+ // Generate a random username
else
$data['username'] = $this->gen_username();
}
+ // Limit username to 24 characters because a prefix of 8 characters
+ // will be added: 'autogen_'.
$data['username'] = substr($data['username'], 0, 24);
+ // Append a random character to the username each time it still exists.
if ($this->get_userdata($data['username']))
{
$chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
$data['username'] .= $chars[ mt_rand(0, $len_chars - 1) ];
} while($this->get_userdata($data['username']));
}
+ // Usernames autogenerated have 'autogen_' prefix and can be changed
+ // by the user from the account section. After this process it cannot
+ // be changed anymore.
$data['username'] = 'autogen_' . $data['username'];
// Country
- $country = $ax_resp->get('http://axschema.org/contact/country');
- if (empty($country) || is_a($country, 'Auth_OpenID_AX_Error'))
- $data['country'] = $sreg_resp->get('country', '');
+ if (empty($ax_country) || is_a($ax_country, 'Auth_OpenID_AX_Error'))
+ $data['country'] = $sreg_country;
else
- $data['country'] = $country[0];
+ $data['country'] = $ax_country[0];
// Birth Date
- $data['birth_date'] = $sreg_resp->get('dob', NULL);
+ $data['birth_date'] = $sreg_dob;
// OpenID
$data['auth_src'] = 'openid';
-// print_r($data);
-
if (!$this->register($data, $op_response->getDisplayIdentifier()))
return FALSE;
public function get_video($id, $name = NULL)
{
$this->load->helper('video');
+ $this->load->helper('text');
$query = $this->db->query("SELECT v.*, u.username
FROM `videos` v, `users` u
// Thumbnails
$video['thumbs'] = $this->get_thumbs($video['name'], $video['thumbs_count']);
+ // Shorted description
+ $video['shorted_description'] = character_limiter(
+ $video['description'], 128);
+
return $video;
}
$(function() {
$('.login-openid')
.click(function() {
+ var op = $(this).data('op');
var openId;
- console.log($(this).data('op'));
-
- switch ($(this).data('op'))
+ switch (op)
{
case 'google':
openId = 'https://www.google.com/accounts/o8/id';
document.close();
});
})
- .button();
+ .each(function() {
+ var op = $(this).data('op');
+
+ $(this)
+ .button({
+ icons: {
+ primary: 'ui-icon-' + op
+ }
+ });
+ });
});
</script>
\ No newline at end of file
function updateCommentCharsLeft($textarea)
{
- $('#comment-chars-left').html('' + (512 - $textarea.val().length));
+
}
$(function() {
function(data) {
$('#video-comments').html(data);
});
+ $('#comment').val('');
});
$('.pagination')
});
$('#comment')
- .keydown(function(event) {
- updateCommentCharsLeft($(this));
+ .bind('keyup paste drop change', function(event) {
+ $textarea = $(this);
- if ($(this).val().length == 513)
- $(this).val($(this).val().substring(0, 512));
- })
- .change(function() {
- updateCommentCharsLeft($(this));
+ if ($textarea.val().length >= 513)
+ $textarea.val($textarea.val().substring(0, 512));
+
+ $('#comment-chars-left').html('' + (512 - $textarea.val().length));
+ console.log(event.type);
});
});
</script>
\ No newline at end of file
</div>
</div>
- <div id="video-description"><?php echo $video['description'] ?></div>
+ <div id="video-shorted-description" class="video-description"><?php echo $video['shorted_description'] ?></div>
- <dl id="video-category">
- <dt><?php echo ucwords($this->lang->line('ui_category'))
- . ': ' ?></dt>
- <dd><?php echo $video['category_title'] ?></dd>
- </dl>
-
- <dl id="video-tags">
- <dt><?php echo ucwords($this->lang->line('ui_tags')). ': ' ?></dt>
- <dd><?php if (isset($video['tags'])):
- foreach ($video['tags'] as $tag => $score): ?>
- <a href="<?php echo site_url('catalog/search/'. $tag) ?>" class="video-tag">
- <?php echo "$tag " // TODO print score in future ?>
- </a>
- <?php endforeach; endif ?></dd>
- </dl>
-
- <dl id="video-torrents">
- <dt><?php echo $this->lang->line('ui_download_torrents') ?>: </dt>
- <?php foreach ($video['assets'] as $asset): ?>
- <dd><a href="<?php echo $asset['src'] ?>"><?php echo $asset['def'] ?></a></dd>
- <?php endforeach ?>
- </dl>
+ <div id="video-info-details">
+ <div id="video-description" class="video-description"><?php echo $video['description'] ?></div>
+
+ <dl id="video-category">
+ <dt><?php echo ucwords($this->lang->line('ui_category'))
+ . ': ' ?></dt>
+ <dd><?php echo $video['category_title'] ?></dd>
+ </dl>
+
+ <dl id="video-tags">
+ <dt><?php echo ucwords($this->lang->line('ui_tags')). ': ' ?></dt>
+ <dd><?php if (isset($video['tags'])):
+ foreach ($video['tags'] as $tag => $score): ?>
+ <a href="<?php echo site_url('catalog/search/'. $tag) ?>" class="video-tag">
+ <?php echo "$tag " // TODO print score in future ?>
+ </a>
+ <?php endforeach; endif ?></dd>
+ </dl>
+
+ <dl id="video-torrents">
+ <dt><?php echo $this->lang->line('ui_download_torrents') ?>: </dt>
+ <?php foreach ($video['assets'] as $asset): ?>
+ <dd><a href="<?php echo $asset['src'] ?>"><?php echo $asset['def'] ?></a></dd>
+ <?php endforeach ?>
+ </dl>
+
+ <dl id="video-license">
+ <dt><?php echo ucwords($this->lang->line('ui_license')).': ' ?></dt>
+ <dd><?php echo $video['license'] ?></dd>
+ </dl>
+ </div>
- <dl id="video-license">
- <dt><?php echo ucwords($this->lang->line('ui_license')).': ' ?></dt>
- <dd><?php echo $video['license'] ?></dd>
- </dl>
+ <a id="a-show-info-details" data-val="more" href="#"><?php echo $this->lang->line('video_show_more') ?></a>
</div>
<div id="video-comments"><?php echo $comments ?></div>
alert('<?php echo $this->lang->line('ui_msg_login_restriction') ?>');
})
.button();
+
+ $('#video-info-details').hide();
+
+ $('#a-show-info-details')
+// .button({
+// icons: {
+// primary: 'ui-icon-triangle-1-s'
+// },
+// text: false
+// })
+ .click(function(event) {
+ event.preventDefault(true);
+ $('#video-shorted-description').toggle();
+ $('#video-info-details').fadeToggle();
+
+ //console.log($(this).button('option', 'icons'));
+ if ($(this).data('val') == 'more')
+ {
+ $(this).data('val', 'less');
+ $(this).html('<?php echo $this->lang->line('video_show_less') ?>');
+ }
+ else
+ {
+ $(this).data('val', 'more');
+ $(this).html('<?php echo $this->lang->line('video_show_more') ?>');
+ }
+ });
});
</script>
\ No newline at end of file
word-spacing: 0.5em;
margin-bottom: 0.5em;
}
+
+.ui-icon-google
+{
+ background-image: url("/img/icon-google.png") !important;
+}
+.ui-icon-yahoo
+{
+ background-image: url("/img/icon-yahoo.png") !important;
+}
+.ui-icon-myopenid
+{
+ background-image: url("/img/icon-myopenid.png") !important;
+}
\ No newline at end of file
margin-left: 1em;
}
+#a-show-info-details
+{
+/* display: block;
+ text-align: center;*/
+}
+
#video-upload-info, #video-popularity
{
font-size: 0.8em;
line-height: 150%;
}
-#video-description
+.video-description
{
margin-top: 1em;
margin-bottom: 0.5em;
_createSwarmPlayerInstall: function() {
var widget = this;
+ var msg;
if (widget.options.error == 'none')
{
+ '</div>'
+ '</div>');
- var msg = 'SwarmPlayer ' + widget.options.msg[widget.options.error];
+ msg = 'SwarmPlayer ' + widget.options.msg[widget.options.error];
$('#install-swarmplayer-msg').html(msg);
}
else
+ '</div>'
+ '</div>');
- var msg = 'SwarmPlayer ' + widget.options.msg[widget.options.error];
+ msg = 'SwarmPlayer ' + widget.options.msg[widget.options.error];
$('#install-swarmplayer-msg').html(msg);
}