当前位置: 首页>>代码示例>>PHP>>正文


PHP EB::registry方法代码示例

本文整理汇总了PHP中EB::registry方法的典型用法代码示例。如果您正苦于以下问题:PHP EB::registry方法的具体用法?PHP EB::registry怎么用?PHP EB::registry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EB的用法示例。


在下文中一共展示了EB::registry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getLink

 public static function getLink($type, $id)
 {
     if (empty($type) || empty($id)) {
         return false;
     }
     //prevent jtable is not loading incase overwritten by other component.
     JTable::addIncludePath(EBLOG_TABLES);
     $oauth = EB::table('Oauth');
     $oauth->loadByUser($id, $type);
     $param = EB::registry($oauth->params);
     $screenName = $param->get('screen_name', '');
     $acl = EB::acl($id);
     $rule = 'update_' . $type;
     if (!$acl->get($rule)) {
         return false;
     }
     switch ($type) {
         case 'twitter':
             $link = empty($screenName) ? '' : 'http://twitter.com/' . $screenName;
             break;
         case 'facebook':
             $link = '';
             break;
         case 'linkedin':
             $link = '';
             break;
     }
     return $link;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:29,代码来源:socialshare.php

示例2: onSearch

 /** 1.5 **/
 public function onSearch($text, $phrase = '', $ordering = '', $areas = null)
 {
     $plugin = JPluginHelper::getPlugin('search', 'easyblog');
     $params = EB::registry($plugin->params);
     if (!plgSearchEasyblog::exists()) {
         return array();
     }
     if (is_array($areas)) {
         if (!array_intersect($areas, array_keys(plgSearchEasyblog::onContentSearchAreas()))) {
             return array();
         }
     }
     $text = trim($text);
     if ($text == '') {
         return array();
     }
     $result = plgSearchEasyblog::getResult($text, $phrase, $ordering);
     if (!$result) {
         return array();
     }
     // require_once( EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'router.php' );
     foreach ($result as $row) {
         $row->section = plgSearchEasyblog::getCategory($row->category_id);
         $row->section = JText::sprintf('PLG_EASYBLOG_SEARCH_BLOGS_SECTION', $row->section);
         $row->href = EBR::_('index.php?option=com_easyblog&view=entry&id=' . $row->id);
         $blog = EB::table('Blog');
         $blog->bind($row);
         if ($blog->getImage()) {
             $row->image = $blog->getImage('frontpage');
         }
     }
     return $result;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:34,代码来源:easyblog.php

示例3: getParams

 public function getParams($name = '', $contents = '', $manifestFile, $xpath = false)
 {
     $this->form = new JForm($name);
     if ($xpath == 'params') {
         $xpath = 'config/fields';
     }
     $this->form->loadFile($manifestFile, true, $xpath);
     $config = EB::table('Configs');
     $config->load($name);
     $params = new JRegistry($config->params);
     $registry = EB::registry($contents);
     $this->form->bind($registry->toArray());
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:13,代码来源:form.php

示例4: trigger

 public function trigger($event, &$row)
 {
     $params = EB::registry();
     $limitstart = $this->input->get('limitstart', 0, 'int');
     $dispatcher = JDispatcher::getInstance();
     // Need to make this behave like how Joomla category behaves.
     if (!isset($row->catid)) {
         $row->catid = $row->category_id;
     }
     if (!isset($this->events[$event])) {
         return false;
     }
     $result = $dispatcher->trigger($this->events[$event], array('easyblog.blog', &$row, &$params, $limitstart));
     // Remove unwanted fields.
     unset($row->catid);
     return $result;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:17,代码来源:triggers.php

示例5: getBloggerTheme

 public static function getBloggerTheme()
 {
     $id = EasyBlogRouter::isBloggerMode();
     if (empty($id)) {
         return false;
     }
     $profile = EB::user($id);
     $userparams = EB::registry($profile->params);
     return $userparams->get('theme', false);
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:10,代码来源:easyblog.php

示例6: getItemIdByEntry

 public static function getItemIdByEntry($blogId)
 {
     static $entriesItems = null;
     if (!isset($entriesItems[$blogId])) {
         $db = EasyBlogHelper::db();
         // We need to check against the correct latest entry to be used based on the category this article is in
         $query = 'SELECT ' . $db->nameQuote('id') . ',' . $db->nameQuote('params') . ' FROM ' . $db->nameQuote('#__menu') . 'WHERE ' . $db->nameQuote('link') . '=' . $db->Quote('index.php?option=com_easyblog&view=latest') . 'AND ' . $db->nameQuote('published') . '=' . $db->Quote('1') . EBR::getLanguageQuery();
         $db->setQuery($query);
         $menus = $db->loadObjectList();
         $blog = EB::table('Blog');
         $blog->load($blogId);
         if ($menus) {
             foreach ($menus as $menu) {
                 $params = EB::registry($menu->params);
                 $inclusion = EasyBlogHelper::getCategoryInclusion($params->get('inclusion'));
                 if (empty($inclusion)) {
                     continue;
                 }
                 if (!is_array($inclusion)) {
                     $inclusion = array($inclusion);
                 }
                 if (in_array($blog->category_id, $inclusion)) {
                     $entriesItems[$blogId] = $menu->id;
                 }
             }
         }
         // Test if there is any entry specific view as this will always override the latest above.
         $query = 'SELECT ' . $db->nameQuote('id') . ' FROM ' . $db->nameQuote('#__menu') . ' ' . 'WHERE ' . $db->nameQuote('link') . '=' . $db->Quote('index.php?option=com_easyblog&view=entry&id=' . $blogId) . ' ' . 'AND ' . $db->nameQuote('published') . '=' . $db->Quote('1') . EBR::getLanguageQuery() . ' LIMIT 1';
         $db->setQuery($query);
         $itemid = $db->loadResult();
         if ($itemid) {
             $entriesItems[$blogId] = $itemid;
         } else {
             // this is to check if we used category menu item from this post or not.
             // if yes, we do nothing. if not, we need to update the cache object so that the next checking will
             // not execute sql again.
             if (isset($entriesItems[$blogId])) {
                 return $entriesItems[$blogId];
             } else {
                 $entriesItems[$blogId] = '';
             }
         }
     }
     return $entriesItems[$blogId];
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:45,代码来源:router.php

示例7: save


//.........这里部分代码省略.........
         $mainframe->enqueueMessage($user->getError(), 'error');
         return $this->execute('edit');
     }
     // If updating self, load the new user object into the session
     if (EasyBlogHelper::getJoomlaVersion() <= '1.5') {
         if ($user->get('id') == $my->get('id')) {
             // Get an ACL object
             $acl = JFactory::getACL();
             // Get the user group from the ACL
             $grp = $acl->getAroGroup($user->get('id'));
             // Mark the user as logged in
             $user->set('guest', 0);
             $user->set('aid', 1);
             // Fudge Authors, Editors, Publishers and Super Administrators into the special access group
             if ($acl->is_group_child_of($grp->name, 'Registered') || $acl->is_group_child_of($grp->name, 'Public Backend')) {
                 $user->set('aid', 2);
             }
             // Set the usertype based on the ACL group name
             $user->set('usertype', $grp->name);
             $session = JFactory::getSession();
             $session->set('user', $user);
         }
     } else {
         // Update session data if the current user was updated
         if ($user->get('id') == $my->get('id')) {
             $session = JFactory::getSession();
             $session->set('user', $user);
             // Force load from database
         }
     }
     $post = JRequest::get('post');
     if ($isNew) {
         unset($post['id']);
     }
     $post['permalink'] = $post['user_permalink'];
     unset($post['user_permalink']);
     if (EasyBlogHelper::isSiteAdmin()) {
         $post['description'] = JRequest::getVar('description', '', 'POST', '', JREQUEST_ALLOWRAW);
         $post['biography'] = JRequest::getVar('biography', '', 'POST', '', JREQUEST_ALLOWRAW);
     }
     $blogger = EB::user($user->id);
     $blogger->bind($post);
     $file = JRequest::getVar('Filedata', '', 'Files', 'array');
     if (!empty($file['name'])) {
         $newAvatar = EasyBlogHelper::uploadAvatar($blogger, true);
         $blogger->avatar = $newAvatar;
     }
     //save params
     $userparams = EB::registry();
     // @rule: Save google profile url
     if (isset($post['google_profile_url'])) {
         $userparams->set('google_profile_url', $post['google_profile_url']);
     }
     if (isset($post['show_google_profile_url'])) {
         $userparams->set('show_google_profile_url', $post['show_google_profile_url']);
     }
     $blogger->params = $userparams->toString();
     $blogger->store();
     JTable::addIncludePath(EBLOG_TABLES);
     //save twitter info.
     $twitter = EB::table('Oauth');
     $twitter->loadByUser($user->id, EBLOG_OAUTH_TWITTER);
     $twitter->auto = JRequest::getVar('integrations_twitter_auto');
     $twitter->message = JRequest::getVar('integrations_twitter_message');
     if (!$twitter->store()) {
         $mainframe->enqueueMessage(JText::_('COM_EASYBLOG_INTEGRATIONS_TWITTER_ERROR'), 'error');
     }
     // Map linkedin items
     $linkedin = EB::table('Oauth');
     $linkedin->loadByUser($user->id, EBLOG_OAUTH_LINKEDIN);
     $linkedin->auto = JRequest::getVar('integrations_linkedin_auto');
     $linkedin->message = JRequest::getVar('integrations_linkedin_message');
     $linkedin->private = JRequest::getVar('integrations_linkedin_private');
     if (!$linkedin->store()) {
         $mainframe->enqueueMessage(JText::_('COM_EASYBLOG_INTEGRATIONS_LINKEDIN_ERROR'), 'error');
     }
     // store faebook info
     $facebook = EB::table('Oauth');
     $facebook->loadByUser($user->id, EBLOG_OAUTH_FACEBOOK);
     $facebook->auto = JRequest::getVar('integrations_facebook_auto');
     $facebook->message = '';
     if (!$facebook->store()) {
         $mainframe->enqueueMessage(JText::_('COM_EASYBLOG_INTEGRATIONS_FACEBOOK_FAILED_UPDATE_INFO_ERROR'), 'error');
     }
     if ($config->get('integration_google_adsense_enable')) {
         // Store adsense data
         $adsense = EB::table('Adsense');
         $adsense->load($user->id);
         $adsense->code = $post['adsense_code'];
         $adsense->display = $post['adsense_display'];
         $adsense->published = $post['adsense_published'];
         $adsense->store();
     }
     // Store feedburner data
     $feedburner = EB::table('Feedburner');
     $feedburner->load($user->id);
     $feedburner->url = $post['feedburner_url'];
     $feedburner->store();
     $this->_saveSuccess($user->id);
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:101,代码来源:user.php

示例8: latest

 /**
  * Displays the latest entry on the site using the entry view
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function latest()
 {
     // Fetch the latest blog entry
     $model = EB::model('Blog');
     // Get the current active menu's properties.
     $app = JFactory::getApplication();
     $menu = $app->getMenu()->getActive();
     $inclusion = '';
     if (is_object($menu)) {
         $params = EB::registry($menu->params);
         $inclusion = EB::getCategoryInclusion($params->get('inclusion'));
     }
     $items = $model->getBlogsBy('latest', 0, '', 1, EBLOG_FILTER_PUBLISHED, null, true, array(), false, false, true, array(), $inclusion);
     if (is_array($items) && !empty($items)) {
         JRequest::setVar('id', $items[0]->id);
         return $this->display();
     }
     echo JText::_('COM_EASYBLOG_NO_BLOG_ENTRY');
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:27,代码来源:view.html.php

示例9: grant

 /**
  * This will be a callback from the oauth client.
  * @param	null
  * @return	null
  **/
 public function grant()
 {
     $type = JRequest::getCmd('type');
     $userId = JRequest::getVar('id');
     $mainframe = JFactory::getApplication();
     $config = EasyBlogHelper::getConfig();
     $key = $config->get('integrations_' . $type . '_api_key');
     $secret = $config->get('integrations_' . $type . '_secret_key');
     $my = JFactory::getUser($userId);
     $redirect = JRequest::getVar('redirect', '');
     $redirectUri = !empty($redirect) ? '&redirect=' . $redirect : '';
     // @task: Let's see if caller wants us to go to any specific location or not.
     if (!empty($redirect)) {
         $redirect = base64_decode($redirect);
     }
     if (!EasyBlogHelper::isLoggedIn()) {
         $mainframe->enqueueMessage(JText::_('COM_EASYBLOG_YOU_MUST_LOGIN_FIRST'), 'error');
         $this->setRedirect(JRoute::_('index.php?option=com_easyblog&view=users', false));
         return;
     }
     $oauth = EB::table('Oauth');
     $loaded = $oauth->loadByUser($my->id, $type);
     $denied = JRequest::getVar('denied', '');
     $call = JRequest::getWord('call');
     $callUri = !empty($call) ? '&call=' . $call . '&id=' . $my->id : '&id=' . $my->id;
     if (!empty($denied)) {
         $oauth->delete();
         $mainframe->enqueueMessage(JText::_('COM_EASYBLOG_OAUTH_DENIED_ERROR'), 'error');
         $redirect = JRoute::_('index.php?option=com_easyblog&view=users', false);
         $this->setRedirect($redirect, false);
         return;
     }
     if (!$loaded) {
         $mainframe->enqueueMessage(JText::_('COM_EASYBLOG_OAUTH_UNABLE_TO_LOCATE_RECORD'), 'error');
         $redirect = JRoute::_('index.php?option=com_easyblog&view=users', false);
         $this->setRedirect($redirect, false);
         return;
     }
     $request = EB::registry($oauth->request_token);
     $callback = rtrim(JURI::root(), '/') . '/administrator/index.php?option=com_easyblog&c=oauth&task=grant&type=' . $type . $redirect . $callUri;
     $consumer = EasyBlogOauthHelper::getConsumer($type, $key, $secret, $callback);
     $verifier = $consumer->getVerifier();
     if (empty($verifier)) {
         // Since there is a problem with the oauth authentication, we need to delete the existing record.
         $oauth->delete();
         JError::raiseError(500, JText::_('COM_EASYBLOG_INVALID_VERIFIER_CODE'));
     }
     $access = $consumer->getAccess($request->get('token'), $request->get('secret'), $verifier);
     if (!$access || empty($access->token) || empty($access->secret)) {
         // Since there is a problem with the oauth authentication, we need to delete the existing record.
         $oauth->delete();
         $mainframe->enqueueMessage(JText::_('COM_EASYBLOG_OAUTH_ACCESS_TOKEN_ERROR'), 'error');
         $this->setRedirect($redirect, false);
         return;
     }
     $param = EB::registry();
     $param->set('token', $access->token);
     $param->set('secret', $access->secret);
     if (isset($access->expires)) {
         $param->set('expires', $access->expires);
     }
     $oauth->access_token = $param->toString();
     $oauth->params = $access->params;
     $oauth->store();
     $mainframe->enqueueMessage(JText::_('Application revoked successfully.'));
     $url = JRoute::_('index.php?option=com_easyblog&c=user&id=' . $my->id . '&task=edit', false);
     if (!empty($redirect)) {
         $url = $redirect;
     }
     // @task: Let's see if the oauth client
     if (!empty($call)) {
         $consumer->{$call}();
     } else {
         $this->setRedirect($url);
     }
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:81,代码来源:oauth.php

示例10: grant

 /**
  * Responsible to receive the incoming redirection from the respective oauth sites
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return	
  */
 public function grant()
 {
     // Ensure that the user is logged in
     EB::requireLogin();
     // Default redirect url
     $return = EBR::_('index.php?option=com_easyblog&view=dashboard&layout=profile', false);
     // Get the client
     $client = $this->input->get('client', '', 'cmd');
     // Get the redirection url
     $redirect = $this->input->get('redirect', '', 'default');
     // Get the redirection url
     $redirectUri = !empty($redirect) ? '&redirect=' . $redirect : '';
     // Let's see if caller wants us to go to any specific location or not.
     if ($redirect) {
         $redirect = base64_decode($redirect);
     }
     // Load the oauth object
     $table = EB::table('OAuth');
     $table->loadByUser($this->my->id, $client);
     if (!$table->id) {
         $this->info->set('COM_EASYBLOG_OAUTH_UNABLE_TO_LOCATE_RECORD', 'error');
         return $this->app->redirect($return);
     }
     // Detect if there's any errors
     $denied = $this->input->get('denied', '', 'default');
     // When there's an error, delete the oauth data
     if ($denied) {
         $table->delete();
         $this->info->set('COM_EASYBLOG_OAUTH_DENIED_ERROR', 'error');
         return $this->app->redirect($return);
     }
     // Get the request token
     $request = json_decode($table->request_token);
     // Get the callback url
     $callback = EBR::getRoutedURL('index.php?option=com_easyblog&task=oauth.grant&client=' . $client . $redirect, false, true);
     // Get the client
     $consumer = EB::oauth()->getClient($client);
     $consumer->setCallback($callback);
     // Get the verifier
     $verifier = $consumer->getVerifier();
     if (!$verifier) {
         $table->delete();
         return $this->app->redirect($return);
     }
     // Get the access token
     $consumer->setRequestToken($request->token, $request->secret);
     $access = $consumer->getAccess($verifier);
     // Since there is a problem with the oauth authentication, we need to delete the existing record.
     if (!$access || !$access->token || !$access->secret) {
         $table->delete();
         $this->info->set('COM_EASYBLOG_OAUTH_ACCESS_TOKEN_ERROR', 'error');
         return $this->app->redirect($return);
     }
     // Once we have the token, we need to map it back
     $params = EB::registry();
     $params->set('token', $access->token);
     $params->set('secret', $access->secret);
     // Set the expiration date
     if (isset($access->expires)) {
         $table->expires = $access->expires;
     }
     $table->access_token = $params->toString();
     $table->params = $access->params;
     // Store the oauth table now
     $table->store();
     $this->info->set(JText::sprintf('COM_EASYBLOG_OAUTH_SUCCESS_' . strtoupper($client)), 'success');
     echo '<script type="text/javascript">window.opener.doneLogin();window.close();</script>';
     exit;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:77,代码来源:oauth.php

示例11: getLimit

 /**
  * Retrieves the limit for pagination
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return	
  */
 public static function getLimit($key = 'listlength')
 {
     $app = JFactory::getApplication();
     $default = EB::getJConfig()->get('list_limit');
     if ($app->isAdmin()) {
         return $default;
     }
     // Get the active menu
     $menu = $app->getMenu()->getActive();
     $limit = -2;
     // Get the pagination limit from the menu parameters
     if (is_object($menu)) {
         $params = EB::registry($menu->params);
         $limit = $params->get('limit', '-2');
     }
     // If there is no pagination limit set on the menu, try to use the limit from EasyBlog's settings
     if ($limit == '-2') {
         $config = EB::config();
         $index = 'layout_pagination_' . $key;
         if ($key == 'listlength') {
             $index = 'layout_listlength';
         }
         $limit = $config->get($index);
     }
     // Revert to joomla's pagination if configured to inherit from Joomla
     if ($limit == '0' || $limit == '-1' || $limit == '-2') {
         $limit = $default;
     }
     return $limit;
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:38,代码来源:pagination.php

示例12: getCommentCount

 /**
  * Retrieves the comment count for the post
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function getCommentCount($post)
 {
     static $counter = array();
     if (isset($counter[$post->id])) {
         return $counter[$post->id];
     }
     $adapter = false;
     // If configured to display multiple comments, we can't display the counter
     if ($this->config->get('main_comment_multiple')) {
         $counter[$post->id] = false;
         return false;
     }
     // @Livefyre comments
     if ($this->config->get('comment_livefyre')) {
         return false;
     }
     // @Intense debate comments
     if ($this->config->get('intensedebate')) {
         $counter[$post->id] = false;
         return false;
     }
     // @RSComments
     if ($this->config->get('comment_rscomments')) {
         return false;
     }
     // @FB Comments
     if ($this->config->get('comment_facebook')) {
         return false;
     }
     // easyblog builtin comment
     if ($this->config->get('comment_easyblog', 1)) {
         $adapter = $this->getAdapter('easyblog');
     }
     // @Komento
     if ($this->config->get('comment_komento')) {
         $adapter = $this->getAdapter('komento');
     }
     // @EasySocial
     if ($this->config->get('comment_easysocial')) {
         $adapter = $this->getAdapter('easysocial');
     }
     // @Compojoom Comments
     if ($this->config->get('comment_compojoom')) {
         $adapter = $this->getAdapter('cjcomment');
     }
     // @Disqus comments
     if ($this->config->get('comment_disqus')) {
         $adapter = $this->getAdapter('disqus');
     }
     // @JComment comments
     if ($this->config->get('comment_jcomments')) {
         $adapter = $this->getAdapter('jcomments');
     }
     if ($adapter) {
         $counter[$post->id] = $adapter->getCount($post);
         return $counter[$post->id];
     }
     // Let's allow the plugin to also trigger the comment count.
     $params = EB::registry();
     $result = EB::triggerEvent('easyblog.commentCount', $post, $params, 0);
     // Get the count
     $count = trim(implode(' ', $result));
     if (!empty($count)) {
         $counter[$post->id] = $count;
     } else {
         $counter[$post->id] = 0;
     }
     return $counter[$post->id];
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:77,代码来源:comment.php

示例13: getAccessTokenValue

 /**
  * Retrieves a key value from the access token object.
  */
 public function getAccessTokenValue($key)
 {
     $param = EB::registry($this->access_token);
     return $param->get($key);
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:8,代码来源:oauth.php

示例14: setAccess

 public function setAccess($access)
 {
     $access = EB::registry($access);
     return parent::setTokenAccess(array('oauth_token' => $access->get('token'), 'oauth_token_secret' => $access->get('secret')));
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:5,代码来源:client.php

示例15: import

 /**
  * Allows caller to import posts from twitter
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function import()
 {
     $key = $this->config->get('integrations_twitter_api_key');
     $secret = $this->config->get('integrations_twitter_secret_key');
     // Ensure that the settings is enabled
     if (!$this->config->get('integrations_twitter_microblog')) {
         // TODO: Turn this into language string.
         return EB::exception('Twitter import has been disabled.', EASYBLOG_MSG_ERROR);
     }
     // Get a list of hashtags
     $hashtags = $this->config->get('integrations_twitter_microblog_hashes');
     // If there are no hashtags, skip this
     if (!$hashtags) {
         // TODO: Turn this into language string.
         return EB::exception('No hashtags provided to search. Skipping this.', EASYBLOG_MSG_INFO);
     }
     $hashtags = explode(',', $hashtags);
     $total = count($hashtags);
     // Get the list of accounts
     $model = EB::model('OAuth');
     $accounts = $model->getTwitterAccounts();
     if (!$accounts) {
         return EB::exception('No Twitter accounts associated on the site. Skipping this', EASYBLOG_MSG_INFO);
     }
     // Get the default category to save the tweets into
     $categoryId = $this->config->get('integrations_twitter_microblog_category');
     // Default state of the post
     $published = $this->config->get('integrations_twitter_microblog_publish');
     // Determines if the post should be available on the frontpage
     $frontpage = $this->config->get('integrations_twitter_microblog_frontpage');
     // Determines the total number of items imported
     $total = 0;
     // Go through each twitter accounts and search for the tags
     foreach ($accounts as $account) {
         $params = EB::registry($account->params);
         $screen = $params->get('screen_name');
         // If we can't get the screen name, do not try to process it.
         if (!$screen) {
             continue;
         }
         // Get the twitter consumer
         $consumer = EB::oauth()->getClient('Twitter');
         $consumer->setAccess($account->access_token);
         // Get the last tweet that has been imported so we don't try to search for anything prior to that
         $lastImport = $model->getLastTweetImport($account->id);
         // Prepare the search params
         $tweets = $consumer->search($hashtags, $lastImport);
         if (!$tweets) {
             return EB::exception('No tweets found. Skipping this.', EASYBLOG_MSG_INFO);
         }
         foreach ($tweets as $tweet) {
             $data = array();
             $data['title'] = JString::substr($tweet->text, 0, 20) . JText::_('COM_EASYBLOG_ELLIPSES');
             $data['posttype'] = EBLOG_MICROBLOG_TWITTER;
             $data['created_by'] = $account->user_id;
             $data['created'] = EB::date()->toSql();
             $data['modified'] = EB::date()->toSql();
             $data['publish_up'] = EB::date()->toSql();
             $data['intro'] = $tweet->text;
             $data['published'] = $published;
             $data['frontpage'] = $frontpage;
             $data['source_id'] = '0';
             $data['source_type'] = EASYBLOG_POST_SOURCE_SITEWIDE;
             $data['category_id'] = $categoryId;
             $data['categories'] = array($categoryId);
             // we need to set this as legacy post as the post did not go through composer.
             $data['doctype'] = EASYBLOG_POST_DOCTYPE_LEGACY;
             $post = EB::post();
             $createOption = array('overrideDoctType' => 'legacy', 'checkAcl' => false, 'overrideAuthorId' => $account->user_id);
             $post->create($createOption);
             // binding
             $post->bind($data);
             $saveOptions = array('applyDateOffset' => false, 'validateData' => false, 'useAuthorAsRevisionOwner' => true, 'checkAcl' => false, 'overrideAuthorId' => $account->user_id);
             // Save the post now
             try {
                 $post->save($saveOptions);
             } catch (EasyBlogException $exception) {
                 return $exception;
             }
             // We need to save some of these tweets
             $adapter = EB::quickpost()->getAdapter('twitter');
             if ($adapter) {
                 $adapter->saveAsset($post->id, 'screen_name', $tweet->user->screen_name);
                 $adapter->saveAsset($post->id, 'created_at', $tweet->created_at);
             }
             // Create a new history record
             $history = EB::table('TwitterMicroBlog');
             $history->id_str = $tweet->id_str;
             $history->post_id = $post->id;
             $history->oauth_id = $account->id;
             $history->created = $post->created;
             $history->tweet_author = $screen;
//.........这里部分代码省略.........
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:101,代码来源:twitter.php


注:本文中的EB::registry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。