Notification - WBB 2.3.6; Fehler

muenchner1989

Kingpui.de
ID: 260017
L
12 Oktober 2006
1.983
121
Finde den Fehler.
Es geht um eine Notification die als "gelesen" makiert werden soll, im ersten code -> Funktioniert es.
Im zweiten -> Funktioniert es nicht, soll es aber!
Belohnung für den Script der Funktionier (Ich hab nun so ziemlich alles durch und kA warum es nicht klappt weil eig. kein fehler drin ist)
Code 1 (Originalcode, funktiniert mit mark_read)

PHP:
<?php
//Kommentare hier rein
?>

<div id='core_menu_mini_menu'>
  <?php
    // Reverse the navigation order (they're floating right)
    $count = count($this->navigation);
    foreach( $this->navigation->getPages() as $item ) $item->setOrder(--$count);
  ?>
  <ul>
    <?php if( $this->viewer->getIdentity()) :?>
    <li id='core_menu_mini_menu_update'>
      <span onclick="toggleUpdatesPulldown(event, this, '4');" style="display: inline-block;" class="updates_pulldown">
        <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',
            )) ?>
          </div>
        </div>
        <a href="javascript:void(0);" id="updates_toggle" <?php if( $this->notificationCount ):?> class="new_updates"<?php endif;?>><?php echo $this->translate(array('%s Update', '%s Updates', $this->notificationCount), $this->locale()->toNumber($this->notificationCount)) ?></a>
      </span>
    </li>
    <?php endif; ?>
    <?php foreach( $this->navigation as $item ): ?>
      <li><?php echo $this->htmlLink($item->getHref(), $this->translate($item->getLabel())) ?></li>
    <?php endforeach; ?>
    <?php if($this->search_check):?>
      <li id="global_search_form_container">
        <form id="global_search_form" action="<?php echo $this->url(array('controller' => 'search'), 'default', true) ?>" method="get">
          <input type='text' class='text suggested' name='query' id='global_search_field' size='20' maxlength='100' alt='<?php echo $this->translate('Search') ?>' />
        </form>
      </li>
    <?php endif;?>
  </ul>
</div>


<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
        }
      }
    });

    if($('notifications_markread_link')){
      $('notifications_markread_link').addEvent('click', function() {
        //$('notifications_markread').setStyle('display', 'none');
        en4.activity.hideNotifications('<?php echo $this->string()->escapeJavascript($this->translate("0 Updates"));?>');
      });
    }

    <?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/hide',
                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();
  };

</script>

Code Nummer 2 Modifiziert (Markieren als gelesen funktioniert NICHT, jedoch auch keine Fehlerausgabe o.ä.)

PHP:
<?php
//Kommentare hier hin
?>
<?php if( $this->viewer()->getIdentity() ): ?>

<div id='core_menu_mini_menu'>
  <?php
    // Reverse the navigation order (they're floating right)
    $count = count($this->navigation);
    foreach( $this->navigation->getPages() as $item ) $item->setOrder(--$count);
  ?>
  <ul>
    <?php if( $this->viewer->getIdentity()) :?>
      <li id='core_menu_mini_menu_update'>
      <span onclick="toggleUpdatesPulldown(event, this, '4');" style="display: inline-block;" class="updates_pulldown">
    <div class="pulldown_contents_wrapper" style="right: 530px; margin-right: 45px; width: 250px; margin-top: 18px; padding-top: 1px; padding-left: 2px; padding-right: 2px;">
    <div class="pulldown_contents" style="margin-right: 15px;"> <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',
            )) ?>
          </div>
        </div>
     <a href="javascript:void(0);" id="updates_toggle"><img style="position: absolute; float: left; margin-right: 5px; right: 807px; top: 7px;" src="application/themes/XXXX/images/notification.png"></a>
 <a href="javascript:void(0);" id="updates_toggle" style="position: absolute; top: -5px; padding: 1px; height: 13px; right: 810px; margin-top: 4px;"<?php if( $this->notificationCount ):?> class="new_updates" style="position: absolute; top: -10px; padding: 4px; height: 13px; right: 800px; margin-top: 9px;"<?php endif;?>><?php echo $this->translate(array($this->notificationCount), $this->locale()->toNumber($this->notificationCount)) ?></a>
 </span>
    </li>
    <?php foreach( $this->navigation as $item ): ?>
      <li><?php echo $this->htmlLink($item->getHref(), $this->translate($item->getLabel())) ?></li>
    <?php endforeach; ?>
    
     <li id='core_menu_mini_menu_account'>
      <span onclick="toggleAccountPulldown(event, this, '4');" style="display: inline-block;" class="account_pulldown">
       <div class="pulldown_contents_wrapper" style="padding-top: 2px; padding-left: 2px; padding-right: 2px; margin-top: 28px; left: 595px;">
         <div class="pulldown_contents">
            <ul class="notifications_menu" id="notifications_menu">
                                                    <li style="padding-top: 5px; height: 50px;">
  <div style="float:left;padding-left: 1px;"><?php echo $this->htmlLink($this->viewer()->getHref(), $this->itemPhoto($this->viewer(), 'thumb.icon')) ?> </div><div style="float:left;padding-left: 20px;"><p style="font-weight: bold; font-size: 13px; padding: 5px 0px 38px 0px;"><?php
    if($this->viewer()->getTitle() == 'admin'){
        echo "<a href='" . $this->url(array('module'=>'admin'), 'default', true) . "'>" . $this->translate('Admin') . "</a>";
    }else{
     echo $this->htmlLink($this->viewer()->getHref(), $this->viewer()->getTitle());
    }
    ?> </div></a></li></p>
<ul>
<li>
                                                    <li><a href="./members/edit/profile" style="padding-top: 20px; padding-right:110px;">Edit My Profile</a></li></a>
                                                    <li><a href="./members/edit/photo" style="padding-top: 5px; padding-bottom: 5px; padding-right:110px;">Change Picture</a></li>
                                                    <li><a href="./members/settings/general" style="padding-top: 5px; padding-bottom: 5px; padding-right:110px;">Account Settings</a></li>
                                                    <li><a href="./members/settings/privacy" style="padding-top: 5px; padding-bottom: 5px; padding-right:110px;">Privacy Settings</a></li>
                                                    <li><a href="#" style="padding-top: 5px; padding-bottom: 5px; padding-right:160px;">Help</a></li>
                                                    <li><a href="<?php echo $this->url(array('controller' => 'logout'), 'default', true) ;?>" style="padding-top: 5px; padding-bottom: 3px; padding-right:155px;">Logout</a></li>

                                                </ul>

             </ul>
                  </div>
          </div>
        <a href="javascript:void(0);" id="account_toggle"><font color="#FFFFFF" style="text-transform: capitalize;">Account</font>  <img src='application/themes/XXXX/images/arrow2.png'></a>
      </span>
    </li>
    <?php endif; ?>
    <?php if($this->search_check):?>
      <li id="global_search_form_container">
        <form id="global_search_form" action="<?php echo $this->url(array('controller' => 'search'), 'default', true) ?>" method="get">
          <input type='text' class='text suggested' name='query' id='global_search_field' size='20' maxlength='100' alt='<?php echo $this->translate('Search') ?>' />
        </form>
      </li>
    <?php endif;?>
  </ul>
</div>

<div id="xxx"><ul><li><a href="./messages/inbox"><img style="position: absolute; float: left; margin-right: 5px; right: 833px; top: 17px;" src="application/themes/xxxx/images/message.png"></a>
</li><li><a href="./activity/notifications"><img style="position: absolute; float: left; margin-right: 5px; right: 859px; top: 17px;" src="application/themes/xxxxx/images/friend.png"></a>
</li><li><a href="./"><img style="position: absolute; float: left; margin-right: 5px; right: 880px; top: 13px;" src="application/themes/xxxx/images/logo.png"></a>
</li></ul>
</div>

<script type='text/javascript'>
  var notificationUpdater;

  en4.core.runonce.add(function(){
    new OverText($('global_search_field'), {
      poll: true,
      pollInterval: 500
    });

    if($('notifications_markread_link')){
      $('notifications_markread_link').addEvent('click', function() {
        //$('notifications_markread').setStyle('display', 'none');
       ('<?php echo $this->string()->escapeJavascript($this->translate(""));?>');
      });
    }
    
  <?php if ($this->updateSettings && $this->viewer->getIdentity()): ?>
    <?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() {
    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();
  };

</script>
 
 <script type='text/javascript'>
 
  var toggleAccountPulldown = function(event, element, user_id) {
    if( element.className=='account_pulldown' ) {
      element.className= 'account_pulldown_active';
      showNotifications();
    } else {
      element.className='account_pulldown';
    }
  }

</script>
<?php endif; ?>

<?php if( !$this->viewer->getIdentity()) :?>
 <div><a href="./"><img style="position: absolute; float: left; margin-right: 5px; right: 880px; top: 13px;" src="application/themes/XXXX/images/logo.png"></a>
</div>
<?php endif; ?>

Wer helfen kann bekommt Lose dafür; Danke.