public function widget($widget, $instance)
    {
        $title = !empty($instance['title']) ? apply_filters('widget_title', $instance['title']) : '';
        $text = !empty($instance['text']) ? wpautop($instance['text']) : '';
        $button_url = $instance['button_url'];
        $button_text = $instance['button_text'];
        $button_external = !empty($instance['button_external']) ? 1 : 0;
        if (!$title && !$text) {
            return;
        }
        if ($button_url) {
            if ($button_external) {
                $text .= "\n\n" . sprintf('<a href="%s" class="button" rel="external">%s</a>', esc_attr(external_url($button_url)), esc_html($button_text ? $button_text : 'Read More'));
            } else {
                $text .= "\n\n" . sprintf('<a href="%s" class="button">%s</a>', esc_attr($button_url), esc_html($button_text ? $button_text : 'Read More'));
            }
        }
        echo $widget['before_widget'];
        ?>
		<div class="text-widget">
			<?php 
        if ($title) {
            echo $widget['before_title'], esc_html($title), $widget['after_title'];
        }
        ?>

			<div class="text-widget-content widgettext"><?php 
        echo wpautop($text);
        ?>
</div>
		</div>
		<?php 
        echo $widget['after_widget'];
    }
예제 #2
0
 function getCacheData()
 {
     $this->o->append('Default.debug.steps', __CLASS__ . '.' . __FUNCTION__);
     // check memcache for the data.
     $memcache = MemcacheFactory::construct('query_memcache');
     foreach ($this->ids as $id) {
         $memcache_keys[$id] = 'UserStatusBar_' . $id;
     }
     $cache = $memcache->get($memcache_keys);
     // check memcache for which keys we got and which we need.
     $records_found = $records_missing = array();
     foreach ($cache as $mem_cache) {
         $records_found[] = $mem_cache['user_id'];
     }
     // figure out which we still need to get.
     $records_missing = array_diff($records_found, $this->ids);
     if (count($records_missing) == 0 && count($this->ids) == count($cache)) {
         $this->setResponse($cache);
         return TRUE;
     }
     $this->set('missing', $records_missing);
     // we have a few queries to get the correct dataset.
     $dao = DAOFactory::create('users');
     $dao->setWhat("`user_id`, `username`, `user_allow_viewonline`, `user_session_time`, `user_journal_id`, " . "`user_receive_pm`, `user_viewemail`, `user_email`, `user_vend`, `user_website`, `user_icq`, " . "`user_aim`,`user_msnm`, `user_yim`");
     $dao->byIds($records_missing);
     $rs = $dao->execute();
     if (!$rs->isSuccess()) {
         throw new CircuitDatabaseException('Unable to retrieve userdata for statusbar.', $rs);
     }
     $newdata = array();
     while ($row = $rs->fetchRow(DB_ASSOC)) {
         $newdata[$row['user_id']] = $row;
     }
     // also get the home location and house preferences
     $dao = DAOFactory::create('gaiahousing');
     $dao->setWhat("`user_id`, `home_zip`, `home_privacy`");
     $dao->byIds($records_missing);
     $rs = $dao->execute();
     if (!$rs->isSuccess()) {
         throw new CircuitDatabaseException('Unable to retrieve housingdata for statusbar.', $rs);
     }
     while ($row = $rs->fetchRow(DB_ASSOC)) {
         $newdata[$row['user_id']]['home_zip'] = $row['home_zip'];
         $newdata[$row['user_id']]['home_privacy'] = $row['home_privacy'];
     }
     // go through each user';s data and get what's appropriate.
     $me = SC::get('userdata.user_id');
     $cutoff = SC::get('board_config.time_now') - 600;
     foreach ($newdata as $uid => $user) {
         // init the stat array
         $stats = array();
         // online offline status. will get edited later.
         if (isset($user['user_session_time']) && $user['user_session_time'] > $cutoff) {
             $stats['status'] = 'online';
         } else {
             $stats['status'] = 'offline';
         }
         // profile
         $stats['profile_url'] = append_sid("/profile/index.php?view=profile.ShowProfile&amp;item=" . $uid);
         // housing
         if (isset($user['home_zip'])) {
             $stats['home_zip'] = $user['home_zip'];
             $stats['home_privacy'] = $user['home_privacy'];
         }
         // journal
         if (isset($user['user_journal_id'])) {
             $stats['journal_id'] = $user['user_journal_id'];
             $stats['journal_view'] = $user['journal_view'];
         }
         // private messages
         if (isset($user['user_receive_pm'])) {
             $stats['pm_receive'] = $user['user_receive_pm'];
         }
         // guilds
         if (isset($user['user_guild_count'])) {
             $stats['guilds_url'] = append_sid("/guilds/index.php?gmode=search&user_id=" . $uid);
         }
         // store (vend)
         if (isset($user['user_vend'])) {
             $stats['vend_url'] = append_sid('http://' . VEND_SERVER . "/gaia/vend.php?mystore=" . $user_id);
         }
         // trade
         $stats['trade_url'] = append_sid('http://' . BANK_SERVER . "/gaia/bank.php?mode=trade&uid=" . $user_id);
         // www
         if (isset($user['user_website'])) {
             $stats['www_url'] = external_url($user['user_website']);
         }
         // aim
         if (isset($user['user_aim'])) {
             $stats['aim_url'] = 'aim:goim?screenname=' . htmlspecialchars($user['user_aim']) . '&amp;message=FHello+Are+you+there?';
         }
         // icq
         if (isset($user['user_icq'])) {
             $stats['icq_url'] = external_url('http://wwp.icq.com/scripts/search.dll?to=' . htmlspecialchars($user['user_icq']));
         }
         // yim
         if (isset($user['user_yim'])) {
             $stats['yim_url'] = external_url('http://edit.yahoo.com/config/send_webmesg?.target=' . htmlspecialchars($user['user_yim']) . '&amp;.src=pg');
         }
         // msn
         if (isset($user['user_msnm'])) {
             $stats['msnm_url'] = append_sid("/profile/index.php?view=profile.ShowProfile&amp;item=" . $uid);
         }
         // add to memcache and cache
         $memcache->set($memcache_keys[$uid], $stats, MEMCACHE_COMPRESSED, 300);
         $cache[$uid] = $stats;
     }
     // set into the observer for further usage
     $this->set('cachedata', $cache);
     return true;
 }