HTML:
<?php
function cutStringuser($str,$limit)
{
if(strlen($str)<=$limit)
{
return $str;
}
else{
$arrStr = explode(" ",$str);
if(count($arrStr)==1){
return strip_tags(substr($str, 0, 20));
}
if(count($arrStr)>=3){
$newLimit = $arrStr[0] . " " . $arrStr[1] . " " . $arrStr[2];
$n=2;
}else if(count($arrStr)==2){
$newLimit = $arrStr[0] . " " . $arrStr[1];
$n = 1;
}
if(strlen($newLimit)<=$limit-2){
$newStr = $newLimit . "..";
return $newStr;
}else{
$newLimit = $arrStr[0];
for($i=1; $i<$n; $i++){
$newLimit = $newLimit . " " . $arrStr[$i];
}
if(strlen($newLimit)<=$limit-2){
$newStr = $newLimit . "..";
return $newStr;
}else{
$newStr = $arrStr[0] . "..";
if(strlen($newStr)<= $limit-2){
return $newStr;
}else{
return strip_tags(substr($newStr, 0, 20));
}
}
}
}
}
?>
<script language="javascript" type='text/javascript'>
function search_focus()
{
var textbox=document.getElementById('query');
if (textbox.value == '<?php echo $this->translate("Search"); ?>')
{
textbox.value='';
textbox.style.color='#000000';
}
}
function search_blur()
{
var textbox=document.getElementById('query');
if (textbox.value=="")
{
textbox.value='<?php echo $this->translate("Search"); ?>';
textbox.style.color="#cccccc";
}
}
function username_focus()
{
var textbox=document.getElementById('email');
if (textbox.value == '<?php echo $this->translate("Email Address"); ?>')
{
textbox.value='';
textbox.style.color='#000000';
}
}
function username_blur()
{
var textbox=document.getElementById('email');
if (textbox.value=="")
{
textbox.value='<?php echo $this->translate("Email Address"); ?>';
textbox.style.color="#cccccc";
}
}
function pass_focus()
{
var textbox=document.getElementById('password');
if (textbox.value == '<?php echo $this->translate("Password"); ?>')
{
textbox.value='';
textbox.style.color='#000000';
}
}
function pass_blur()
{
var textbox=document.getElementById('password');
if (textbox.value=="")
{
textbox.value='<?php echo $this->translate("Password"); ?>';
textbox.style.color="#cccccc";
}
}
</script>
<?php
// Reverse the navigation order (they're floating right)
$count = count($this->navigation);
foreach( $this->navigation->getPages() as $item ) $item->setOrder(--$count);
// echo "<span style='color: red'>" . $this->viewer()->getIdentity() . "</span>";
$route = array('route'=>'user_logout', 'action'=>'logout');
$viewer = $this->viewer();
?>
<?php
if( $viewer && $viewer->getIdentity() ) {
?>
<div id='core_menu_mini_menu'>
<?php echo $this->htmlLink($route, "<img src='" . $this->baseUrl('/application/themes/youface/images/logo_login.gif') . "' id='logo' />"); ?>
<div class="fixie">
<ul class="top_search">
<li>
<span onclick="toggleUpdatesPulldown(event, this, '4');" class="updates_pulldown">
<?php
echo "<img src ='" . $this->baseUrl('/application/themes/youface/images/notification_icon.gif') . "'/>";
?>
<?php if( $this->notificationCount ):?>
<span class="counter" id="count_noti"><?php echo $this->notificationCount; ?></span>
<?php endif;
?>
<span style="display: none;" id="updates_toggle"></span>
<div class="pulldown_contents_wrapper">
<div class="pulldown_contents">
<ul class="notifications_menu" id="notifications_menu">
<div class="notifications_loading" id="notifications_loading">
<img src='application/modules/Core/externals/images/loading.gif' style='float:left; margin-right: 5px;' />
<?php echo $this->translate("Loading ...") ?>
</div>
</ul>
</div>
<div class="pulldown_options">
<?php echo $this->htmlLink(array('route' => 'default', 'module' => 'activity', 'controller' => 'notifications'),
$this->translate('View All Updates'),
array('id' => 'notifications_viewall_link')) ?>
<?php echo $this->htmlLink('javascript:void(0);', $this->translate('Mark All Read'), array(
'id' => 'notifications_markread_link',
'onclick' => 'markallread()'
)) ?>
</div>
</div>
</span>
</li>
<?php
foreach( $this->navigation as $item ):
if(strpos($item->getHref(),"messages") > 0)
{
$messg = explode(" ",$item->getLabel());
if(count($messg)==2)
{
$mess = explode("(",$messg[1]);
$mes = explode(")",$mess[1]);
}
?>
<li>
<?php
echo "<a href='" . $item->getHref() . "' title='" . $this->translate($item->getLabel()). "'><img src ='" . $this->baseUrl('/application/themes/youface/images/message_icon.gif') . "' />";
?>
<?php if(isset($mes[0]) && $mes[0] > 0): ?>
<span class="counter"><?php echo $mes[0]; ?></span>
<?php
endif;
echo "</a>";
?>
</li>
<?php } ?>
<?php endforeach; ?>
<li class="friend_request">
<?php
$requestcount = 0;
$requests = Engine_Api::_()->getDbtable('notifications', 'activity')->getRequestCountsByType($this->viewer);
if (is_array($requests))
foreach( $requests as $request ):
$requestcount += $request['count'];
endforeach;
$retext = "<img alt = '" . $this->translate("Friend request") . "' title = '" . $this->translate("Friend request") . "' src ='" . $this->baseUrl('/application/themes/youface/images/request_icon.gif')."' />";
if ($requestcount > 0)
$retext .= '<span class="counter">'.$requestcount.'</span>';
echo $this->htmlLink(array('route' => 'default', 'module' => 'activity', 'controller' => 'notifications'), $retext);
?>
</li>
<li class ="yf_search_form">
<form id="global_search_form" action="<?php echo $this->url(array('controller' => 'search'), 'default', true) ?>" method="get">
<div class="text_form_search">
<input class="text_search" id="query" name="query" type="text" alt="" value="<?php echo $this->translate('Search'); ?>" size="20" onblur="search_blur()" onfocus="search_focus()" />
</div>
</form>
</li>
</ul>
<div class="menu_mini_signout">
<ul class="viewmore_setting">
<?php foreach( $this->navigation as $item ): ?>
<li><?php echo $this->htmlLink($item->getHref(), $this->translate($item->getLabel())) ?></li>
<?php endforeach; ?>
</ul>
</div>
</div>
</div>
<?php
}
?>
<?php
if(!$viewer || !$viewer->getIdentity() ) {
?>
<div id='core_menu_mini_menu_notlogin'>
<?php echo $this->htmlLink($route, "<img src='" . $this->baseUrl('/application/themes/youface/images/logo.gif') . "' id='logo' />"); ?>
<div class ="fixie">
<ul class="loginform">
<form action="<?php echo $this->url(array('controller' => 'login'), 'default', true)?>" method="POST">
<div class="user_pass">
<!-- Facebook Connect -->
<?php if($this->fbLoginEnabled): ?>
<div class ="fb_connect"> <?php echo $this->fblogin; ?> </div>
<?php else: ?>
<?php endif; ?>
<!-- Facebook Connect End -->
<input class="text_login" type="text" name="email" id="email" value="<?php echo $this->translate('Email Address'); ?>" tabindex="1" onblur="username_blur()" onfocus="username_focus()" />
<input type="password" name="password" id="password" tabindex="2" class="text_login" value="<?php echo $this->translate('Password'); ?>" required="required" onblur="pass_blur()" onfocus="pass_focus()" />
<input class="button_login" type="submit" tabindex="4" value="<?php echo $this->translate('Login'); ?>" />
</div>
<div class="remember">
<input id="remember" type="checkbox" name="remember" value="1" tabindex="3" />
<label for="remember"><?php echo $this->translate("Remember Me"); ?></label>
<span class="forgot_pass">
<a href="<?php echo $this->url(array('module'=>'user','controller' => 'auth','action'=>'forgot'), 'default', true) ;?>"><?php echo $this->translate('Forgot Password?');?></a>
</span>
</div>
</form>
</li>
</ul>
</div>
</div>
<?php }?>
<script type='text/javascript'>
var notificationUpdater;
en4.core.runonce.add(function(){
new OverText($('global_search_field'), {
poll: true,
pollInterval: 500,
positionOptions: {
position: ( en4.orientation == 'rtl' ? 'upperRight' : 'upperLeft' ),
edge: ( en4.orientation == 'rtl' ? 'upperRight' : 'upperLeft' ),
offset: {
x: ( en4.orientation == 'rtl' ? -4 : 4 ),
y: 2
}
}
});
<?php if ($this->updateSettings && $this->viewer->getIdentity()): ?>
notificationUpdater = new NotificationUpdateHandler({
'delay' : <?php echo $this->updateSettings;?>
});
notificationUpdater.start();
window._notificationUpdater = notificationUpdater;
<?php endif;?>
});
var toggleUpdatesPulldown = function(event, element, user_id) {
if( element.className=='updates_pulldown' ) {
element.className= 'updates_pulldown_active';
showNotifications();
} else {
element.className='updates_pulldown';
}
}
var showNotifications = function() {
en4.activity.updateNotifications();
new Request.HTML({
'url' : en4.core.baseUrl + 'activity/notifications/pulldown',
'data' : {
'format' : 'html',
'page' : 1
},
'onComplete' : function(responseTree, responseElements, responseHTML, responseJavaScript) {
if(responseHTML){
// hide loading icon
if($('notifications_loading')) $('notifications_loading').setStyle('display', 'none');
$('notifications_menu').innerHTML = responseHTML;
$('notifications_menu').addEvent('click', function(event){
event.stop(); //Prevents the browser from following the link.
var current_link = event.target;
var notification_li = $(current_link).getParent('li');
// if this is true, then the user clicked on the li element itself
if (notification_li.id == 'core_menu_mini_menu_update') notification_li = current_link;
var forward_link;
if(current_link.get('href')){
forward_link = current_link.get('href');
}
else{
forward_link = $(current_link).getElements('a:last-child').get('href');
}
if(notification_li.get('class')=='notifications_unread'){
notification_li.removeClass('notifications_unread');
en4.core.request.send(new Request.JSON({
url : en4.core.baseUrl + 'activity/notifications/markread',
data : {
format : 'json',
'actionid' : notification_li.get('value')
},
onSuccess : window.location = forward_link
}));
}
else window.location = forward_link;
});
}
else $('notifications_loading').innerHTML = '<?php echo $this->string()->escapeJavascript($this->translate("You have no new updates."));?>';
}
}).send();
};
function markallread()
{
$("count_noti").innerHTML = "0";
en4.activity.hideNotifications('<?php echo $this->string()->escapeJavascript($this->translate("0"));?>');
$("count_noti").style.display = "none";
}
en4.core.runonce.add(function(){
new OverText($('global_search_field'), {
poll: true,
pollInterval: 500
});
});
function switchto(q){
if (q){
document.getElementById('passwordtext').style.display="none";
document.getElementById('password').style.display="inline";
document.getElementById('password').focus();
} else {
document.getElementById('password').style.display="none";
document.getElementById('passwordtext').style.display="inline";
}
}
function myKeyPressed(e){
e = e || window.event;
var unicode=e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
if (unicode == 13){
document.frmlogin.submit();
}
}
</script>