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


PHP Setup::Configuration方法代码示例

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


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

示例1: ListAllAvailablePreProcessingSteps

 /**
  * Returns all the classes that implment the IPreProcessor interface
  * @return IPreProcessingStep[]
  */
 public function ListAllAvailablePreProcessingSteps()
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::PreProcessing::PreProcessor::ListAllAvailablePreProcessingSteps [Method invoked]", \PEAR_LOG_DEBUG);
     $steps = array();
     $modulesDirectory = \Swiftriver\Core\Setup::Configuration()->ModulesDirectory;
     $dirItterator = new \RecursiveDirectoryIterator($modulesDirectory);
     $iterator = new \RecursiveIteratorIterator($dirItterator, \RecursiveIteratorIterator::SELF_FIRST);
     foreach ($iterator as $file) {
         if ($file->isFile()) {
             $filePath = $file->getPathname();
             if (strpos($filePath, "PreProcessingStep.php")) {
                 try {
                     include_once $filePath;
                     $typeString = "\\Swiftriver\\PreProcessingSteps\\" . $file->getFilename();
                     $type = str_replace(".php", "", $typeString);
                     $object = new $type();
                     if ($object instanceof IPreProcessingStep) {
                         $logger->log("Core::PreProcessing::PreProcessor::ListAllAvailablePreProcessingSteps [Adding type {$type}]", \PEAR_LOG_DEBUG);
                         $object->filePath = str_replace($modulesDirectory, "", $filePath);
                         $object->type = $type;
                         $steps[] = $object;
                     }
                 } catch (\Exception $e) {
                     $logger->log("Core::PreProcessing::PreProcessor::ListAllAvailablePreProcessingSteps [error adding type {$type}]", \PEAR_LOG_DEBUG);
                     $logger->log("Core::PreProcessing::PreProcessor::ListAllAvailablePreProcessingSteps [{$e}]", \PEAR_LOG_ERR);
                     continue;
                 }
             }
         }
     }
     $logger->log("Core::PreProcessing::PreProcessor::ListAllAvailablePreProcessingSteps [Method finished]", \PEAR_LOG_DEBUG);
     return $steps;
 }
开发者ID:katembu,项目名称:Swiftriver,代码行数:38,代码来源:PreProcessor.php

示例2: __construct

 /**
  * Constructor Method
  * @param string $uri
  */
 public function __construct($uri)
 {
     $this->uri = $uri;
     $this->proxy = \Swiftriver\Core\Setup::Configuration()->ProxyServer;
     $this->proxyUsername = \Swiftriver\Core\Setup::Configuration()->ProxyServerUserName;
     $this->proxyPassword = \Swiftriver\Core\Setup::Configuration()->ProxyServerPassword;
 }
开发者ID:ushahidi,项目名称:Swiftriver-2011,代码行数:11,代码来源:ServiceWrapper.php

示例3: Toolbox

 public static function Toolbox()
 {
     //if not the first time this is called
     if (isset(self::$toolbox)) {
         return self::$toolbox;
     }
     //else set up the RedBean toolbox
     require_once \Swiftriver\Core\Setup::Configuration()->ModulesDirectory . "/RedBean/redbean.inc.php";
     //get the url of the url of the db server
     $url = (string) Setup::$Configuration->DataBaseUrl;
     //Get the db username
     $username = (string) Setup::$Configuration->UserName;
     //get the password
     $password = (string) Setup::$Configuration->Password;
     //get the db name
     $database = (string) Setup::$Configuration->Database;
     //set the db type
     $typeofdatabase = "mysql";
     //Assemble a database connection string (DSN)
     $dsn = "{$typeofdatabase}:host={$url};dbname={$database}";
     //Construct a new Red Bean Toolbox, if it has not been set in the mean time
     if (!isset(self::$toolbox)) {
         self::$toolbox = \RedBean_Setup::kickstartDev($dsn, $username, $password);
     }
     //return it
     return self::$toolbox;
 }
开发者ID:surflightroy,项目名称:SwiftriverCore,代码行数:27,代码来源:RedBeanController.php

示例4: RunWorkflow

 public function RunWorkflow($key)
 {
     $filename = \Swiftriver\Core\Setup::Configuration()->CachingDirectory . "/TwitterStreamingController.go";
     if (!\file_exists($filename)) {
         return parent::FormatReturn('{"IsActive":false}');
     }
     return parent::FormatReturn('{"IsActive":true}');
 }
开发者ID:ushahidi,项目名称:Swiftriver-2011,代码行数:8,代码来源:IsActive.php

示例5: RunWorkflow

 public function RunWorkflow($key)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::ServiceAPI::TwitterStreamingServices::StopTwitterStreamer::RunWorkflow [Method invoked]", \PEAR_LOG_INFO);
     $filename = \Swiftriver\Core\Setup::Configuration()->CachingDirectory . "/TwitterStreamingController.go";
     if (\file_exists($filename)) {
         \unlink($filename);
     }
     $logger->log("Core::ServiceAPI::TwitterStreamingServices::StopTwitterStreamer::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
     return '{"message":"OK"}';
 }
开发者ID:ushahidi,项目名称:Swiftriver-2011,代码行数:11,代码来源:StopTwitterStreamer.php

示例6: ListAllAvailablePreProcessingSteps

 /**
  * Returns all the classes that implment the IPreProcessor interface
  *
  * @return IPreProcessingStep[]
  */
 public function ListAllAvailablePreProcessingSteps()
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::PreProcessing::PreProcessor::ListAllAvailablePreProcessingSteps [Method invoked]", \PEAR_LOG_DEBUG);
     //set up the array to hold the steps
     $steps = array();
     //Get the path of the modules directory
     $modulesDirectory = \Swiftriver\Core\Setup::Configuration()->ModulesDirectory;
     //Create a recursive directory ittorator
     $dirItterator = new \RecursiveDirectoryIterator($modulesDirectory);
     $iterator = new \RecursiveIteratorIterator($dirItterator, \RecursiveIteratorIterator::SELF_FIRST);
     //Itterate over all the files in all the directories
     foreach ($iterator as $file) {
         //If not a file continue
         if (!$file->isFile()) {
             continue;
         }
         //get the full file path
         $filePath = $file->getPathname();
         //If not a pre processing step then continue
         if (!strpos($filePath, "PreProcessingStep.php")) {
             continue;
         }
         try {
             //Include the file
             include_once $filePath;
             //create a type string for the pre processing step
             $typeString = "\\Swiftriver\\PreProcessingSteps\\" . $file->getFilename();
             //remove the .php extension
             $type = str_replace(".php", "", $typeString);
             //instanciate the pre processing step
             $object = new $type();
             //Check that the object implements the IPreProcessingStep
             if (!$object instanceof IPreProcessingStep) {
                 continue;
             }
             $logger->log("Core::PreProcessing::PreProcessor::ListAllAvailablePreProcessingSteps [Adding type {$type}]", \PEAR_LOG_DEBUG);
             //Add the file name to the step element
             $object->filePath = str_replace($modulesDirectory, "", $filePath);
             //Add the type to the step element
             $object->type = $type;
             //Add the object to the array
             $steps[] = $object;
         } catch (\Exception $e) {
             $logger->log("Core::PreProcessing::PreProcessor::ListAllAvailablePreProcessingSteps [error adding type {$type}]", \PEAR_LOG_DEBUG);
             $logger->log("Core::PreProcessing::PreProcessor::ListAllAvailablePreProcessingSteps [{$e}]", \PEAR_LOG_ERR);
             continue;
         }
     }
     $logger->log("Core::PreProcessing::PreProcessor::ListAllAvailablePreProcessingSteps [Method finished]", \PEAR_LOG_DEBUG);
     return $steps;
 }
开发者ID:ushahidi,项目名称:Swiftriver-2011,代码行数:57,代码来源:PreProcessor.php

示例7: GetAndParse

 /**
  * Implementation of IParser::GetAndParse
  * @param \Swiftriver\Core\ObjectModel\Channel $channel
  * @param datetime $lassucess
  */
 public function GetAndParse($channel)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::Modules::SiSPS::Parsers::FeedsParser::GetAndParse [Method invoked]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Modules::SiSPS::Parsers::FeedsParser::GetAndParse [START: Extracting required parameters]", \PEAR_LOG_DEBUG);
     //Extract the required variables
     $feedUrl = "";
     switch ($channel->subType) {
         case "Wordpress Blog":
             $feedUrl = $channel->parameters["BlogUrl"];
             $feedUrl = rtrim($feedUrl, "/") . "/?feed=atom";
             break;
         case "Blogger Blog":
             $feedUrl = $channel->parameters["BlogUrl"];
             $feedUrl = rtrim($feedUrl, "/") . "/feeds/posts/default";
             break;
         case "Tumblr Blog":
             $feedUrl = $channel->parameters["BlogUrl"];
             $feedUrl = rtrim($feedUrl, "/") . "/api/read";
             break;
         case "News Feeds":
             $feedUrl = $channel->parameters["feedUrl"];
             break;
     }
     if (!isset($feedUrl) || $feedUrl == "") {
         $logger->log("Core::Modules::SiSPS::Parsers::FeedsParser::GetAndParse [the parameter 'feedUrl' was not supplied. Returning null]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Modules::SiSPS::Parsers::FeedsParser::GetAndParse [Method finished]", \PEAR_LOG_DEBUG);
         return null;
     }
     $logger->log("Core::Modules::SiSPS::Parsers::FeedsParser::GetAndParse [END: Extracting required parameters]", \PEAR_LOG_DEBUG);
     //Include the Simple Pie Framework to get and parse feeds
     $config = \Swiftriver\Core\Setup::Configuration();
     $contentItems = null;
     switch ($channel->subType) {
         case "Wordpress Blog":
             $contentItems = $this->GetSimplePieContentEntries($channel, $config, $logger, $feedUrl);
             break;
         case "Blogger Blog":
             $contentItems = $this->GetSimplePieContentEntries($channel, $config, $logger, $feedUrl);
             break;
         case "Tumblr Blog":
             $contentItems = $this->GetXMLContentEntries($channel, $config, $logger, $feedUrl);
             break;
         case "News Feeds":
             $contentItems = $this->GetSimplePieContentEntries($channel, $config, $logger, $feedUrl);
             break;
     }
     //return the content array
     return $contentItems;
 }
开发者ID:ushahidi,项目名称:Swiftriver-2011,代码行数:55,代码来源:FeedsParser.php

示例8: RunWorkflow

 public function RunWorkflow($key)
 {
     $filename = \Swiftriver\Core\Setup::Configuration()->CachingDirectory . "/TwitterStreamingController.tmp";
     if (!\file_exists($filename)) {
         return parent::FormatMessage("no config");
     }
     $fp = fopen($filename, "r+");
     $line = fread($fp, filesize($filename));
     fclose($fp);
     $parts = explode("|", $line);
     $object->TwitterUsername = $parts[0];
     $object->TwitterPassword = $parts[1];
     $object->SearchTerms = explode("~", $parts[2]);
     return parent::FormatReturn(\json_encode($object));
 }
开发者ID:ushahidi,项目名称:Swiftriver-2011,代码行数:15,代码来源:GetTwitterStreamConfig.php

示例9: GetAndParse

 /**
  * Implementation of IParser::GetAndParse
  * @param string[][] $parameters
  * Required Parameter Values =
  *  'feedUrl' = The url to the RSS feed
  */
 public function GetAndParse($parameters)
 {
     //Extract the required variables
     $feedUrl = $parameters["feedUrl"];
     if (!isset($feedUrl) || $feedUrl == "") {
         return null;
     }
     //Create the source that will be used by all the content items
     //Passing in the feed uri which can be used to uniquly
     //identify the source of the content
     $source = new \Swiftriver\Core\ObjectModel\Source($feedUrl);
     //Include the Simple Pie Framework to get and parse feeds
     $config = \Swiftriver\Core\Setup::Configuration();
     include_once $config->ModulesDirectory . "/SimplePie/simplepie.inc";
     //Construct a new SimplePie Parsaer
     $feed = new \SimplePie();
     //Set the caching directory
     $feed->set_cache_location($config->CachingDirectory);
     //Pass the feed URL to the SImplePie object
     $feed->set_feed_url($feedUrl);
     //Run the SimplePie
     $feed->init();
     //Create the Content array
     $contentItems = array();
     //Loop throught the Feed Items
     foreach ($feed->get_items() as $feedItem) {
         //Extract all the relevant feedItem info
         $id = \Swiftriver\Core\ObjectModel\Content::GenerateUniqueId();
         $title = $feedItem->get_title();
         $description = $feedItem->get_description();
         $contentLink = $feedItem->get_permalink();
         //Create a new Content item
         $item = new \Swiftriver\Core\ObjectModel\Content();
         //Fill the COntenty Item
         $item->SetId($id);
         $item->SetTitle($title);
         $item->SetLink($contentLink);
         $item->SetText(array($description));
         $item->SetSource($source);
         //Add the item to the Content array
         $contentItems[] = $item;
     }
     //return the content array
     return $contentItems;
 }
开发者ID:surflightroy,项目名称:SwiftriverCore,代码行数:51,代码来源:RSSParser.php

示例10: checkFilterPredicates

 public function checkFilterPredicates()
 {
     $filename = \Swiftriver\Core\Setup::Configuration()->CachingDirectory . "/TwitterStreamingController.go";
     if (!\file_exists($filename)) {
         parent::disconnect();
     }
     $sec = (int) date('s');
     //this is called every 5 secs so to give us a break we ease off in the last 30 seconds of every minute
     if ($sec > 30) {
         return;
     }
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $queueFiles = glob($this->queueDir . '/phirehose-queue*.queue');
     $logger->log("Core::Modules::TwitterStreamingSearchClient Found " . count($queueFiles) . " queue files.", \PEAR_LOG_DEBUG);
     foreach ($queueFiles as $queueFile) {
         $this->processQueueFile($queueFile);
     }
 }
开发者ID:ushahidi,项目名称:Swiftriver-2011,代码行数:18,代码来源:TwitterStreamingSearchClient.php

示例11: PreProcessContent

 public function PreProcessContent($content)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::PreProcessing::PreProcessor::PreProcessContent [Method invoked]", \PEAR_LOG_DEBUG);
     $modulesDirectory = \Swiftriver\Core\Setup::Configuration()->ModulesDirectory;
     $configuration = \Swiftriver\Core\Setup::Configuration();
     if (isset($this->preProcessingSteps) && count($this->preProcessingSteps) > 0) {
         foreach ($this->preProcessingSteps as $preProcessingStep) {
             //Get the class name from config
             $className = $preProcessingStep->className;
             //get the file path from config
             $filePath = $modulesDirectory . $preProcessingStep->filePath;
             $logger->log("Core::PreProcessing::PreProcessor::PreProcessContent [START: Including pre processor: {$filePath}]", \PEAR_LOG_DEBUG);
             //Include the file
             include_once $filePath;
             $logger->log("Core::PreProcessing::PreProcessor::PreProcessContent [END: Including pre processor: {$filePath}]", \PEAR_LOG_DEBUG);
             $logger->log("Core::PreProcessing::PreProcessor::PreProcessContent [START: Instanciating pre processor: {$className}]", \PEAR_LOG_DEBUG);
             try {
                 //Instanciate the pre processor
                 $preProcessor = new $className();
             } catch (\Exception $e) {
                 $message = $e->getMessage();
                 $logger->log("Core::PreProcessing::PreProcessor::PreProcessContent [{$message}]", \PEAR_LOG_ERR);
                 $logger->log("Core::PreProcessing::PreProcessor::PreProcessContent [Unable to run PreProcessing for preprocessor {$className}]", \PEAR_LOG_ERR);
             }
             $logger->log("Core::PreProcessing::PreProcessor::PreProcessContent [END: Instanciating pre processor: {$className}]", \PEAR_LOG_DEBUG);
             $logger->log("Core::PreProcessing::PreProcessor::PreProcessContent [START: Run PreProcessing for {$className}]", \PEAR_LOG_DEBUG);
             try {
                 //Run the preocess method on the pre processor
                 $content = $preProcessor->Process($content, $configuration, $logger);
             } catch (\Exception $e) {
                 $message = $e->getMessage();
                 $logger->log("Core::PreProcessing::PreProcessor::PreProcessContent [{$message}]", \PEAR_LOG_ERR);
                 $logger->log("Core::PreProcessing::PreProcessor::PreProcessContent [Unable to run PreProcessing for preprocessor {$className}]", \PEAR_LOG_ERR);
             }
             $logger->log("Core::PreProcessing::PreProcessor::PreProcessContent [END: Run PreProcessing for {$className}]", \PEAR_LOG_DEBUG);
         }
     } else {
         $logger->log("Core::PreProcessing::PreProcessor::PreProcessContent [No PreProcessing Steps found to run]", \PEAR_LOG_DEBUG);
     }
     $logger->log("Core::PreProcessing::PreProcessor::PreProcessContent [Method finished]", \PEAR_LOG_DEBUG);
     //Return the content
     return $content;
 }
开发者ID:jgosier,项目名称:ushahidi_swift,代码行数:44,代码来源:PreProcessor.php

示例12: RaiseAndDistributeEvent

 public function RaiseAndDistributeEvent($event)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::EventDistribution::EventDistributor [Method invoked]", \PEAR_LOG_DEBUG);
     $modulesDirectory = \Swiftriver\Core\Setup::Configuration()->ModulesDirectory;
     $configuration = \Swiftriver\Core\Setup::Configuration();
     if (isset($this->eventHandlers) && count($this->eventHandlers) > 0) {
         foreach ($this->eventHandlers as $eventHandler) {
             //Get the class name from config
             $className = $eventHandler->className;
             //get the file path from config
             $filePath = $modulesDirectory . $eventHandler->filePath;
             $logger->log("Core::EventDistribution::EventDistributor::RaiseAndDistributeEvent [START: Including event handler: {$filePath}]", \PEAR_LOG_DEBUG);
             //Include the file
             include_once $filePath;
             $logger->log("Core::EventDistribution::EventDistributor::RaiseAndDistributeEvent [END: Including event handler: {$filePath}]", \PEAR_LOG_DEBUG);
             $logger->log("Core::EventDistribution::EventDistributor::RaiseAndDistributeEvent [START: Instanciating event handler: {$className}]", \PEAR_LOG_DEBUG);
             try {
                 //Instanciate the event handlerr
                 $handler = new $className();
             } catch (\Exception $e) {
                 $message = $e->getMessage();
                 $logger->log("Core::EventDistribution::EventDistributor::RaiseAndDistributeEvent [{$message}]", \PEAR_LOG_ERR);
                 $logger->log("Core::EventDistribution::EventDistributor::RaiseAndDistributeEvent [Unable to run event distribution for event handler: {$className}]", \PEAR_LOG_ERR);
             }
             $logger->log("Core::EventDistribution::EventDistributor::RaiseAndDistributeEvent [END: Instanciating event handler: {$className}]", \PEAR_LOG_DEBUG);
             $logger->log("Core::EventDistribution::EventDistributor::RaiseAndDistributeEvent [START: Run event distribution for {$className}]", \PEAR_LOG_DEBUG);
             try {
                 //Run the handle event method
                 $handler->HandleEvent($event, $configuration, $logger);
             } catch (\Exception $e) {
                 $message = $e->getMessage();
                 $logger->log("Core::EventDistribution::EventDistributor::RaiseAndDistributeEvent [{$message}]", \PEAR_LOG_ERR);
                 $logger->log("Core::EventDistribution::EventDistributor::RaiseAndDistributeEvent [Unable to run event distribution for event handler: {$className}]", \PEAR_LOG_ERR);
             }
             $logger->log("Core::EventDistribution::EventDistributor::RaiseAndDistributeEvent [END: Run event distribution for {$className}]", \PEAR_LOG_DEBUG);
         }
     } else {
         $logger->log("Core::EventDistribution::EventDistributor::RaiseAndDistributeEvent [No event handlers found to run]", \PEAR_LOG_DEBUG);
     }
     $logger->log("Core::EventDistribution::EventDistributor::RaiseAndDistributeEvent [Method finished]", \PEAR_LOG_DEBUG);
 }
开发者ID:jgosier,项目名称:ushahidi_swift,代码行数:42,代码来源:EventDistributor.php

示例13: __construct

 public function __construct($modulesDirectory = null)
 {
     if ($modulesDirectory == null) {
         $modulesDirectory = \Swiftriver\Core\Setup::Configuration()->ModulesDirectory;
     }
     $this->preProcessingSteps = array();
     $dirItterator = new \RecursiveDirectoryIterator($modulesDirectory);
     $iterator = new \RecursiveIteratorIterator($dirItterator, \RecursiveIteratorIterator::SELF_FIRST);
     foreach ($iterator as $file) {
         if ($file->isFile()) {
             $filePath = $file->getPathname();
             if (strpos($filePath, "PreProcessingStep")) {
                 include_once $filePath;
                 $className = str_replace(".php", "", $file->getFilename());
                 $className = "\\Swiftriver\\PreProcessingSteps\\" . $className;
                 $this->preProcessingSteps[] = new $className();
             }
         }
     }
 }
开发者ID:surflightroy,项目名称:SwiftriverCore,代码行数:20,代码来源:PreProcessor.php

示例14: RunWorkflow

 public function RunWorkflow($json, $key)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::ServiceAPI::TwitterStreamingServices::StartTwitterStreamer::RunWorkflow [Method invoked]", \PEAR_LOG_INFO);
     $parameters = parent::ParseTwitterStreamingStartParametersFromJson($json);
     if (!isset($parameters)) {
         $logger->log("Core::ServiceAPI::TwitterStreamingServices::StartTwitterStreamer::RunWorkflow [ERROR: Method ParseTwitterStreamingStartParametersFromJson returned null]", \PEAR_LOG_DEBUG);
         parent::FormatErrorMessage("There was an error in the JSON supplied, please consult the API documentation and try again.");
     }
     //create a channel for the streamed content
     $channelJson = '{"id":"TWITTERSTREAM","type":"Twitter Stream","subType":"Filter","name":"Twitter Stream","active":false}';
     $channel = \Swiftriver\Core\ObjectModel\ObjectFactories\ChannelFactory::CreateChannelFromJSON($channelJson);
     $channelRepository = new \Swiftriver\Core\DAL\Repositories\ChannelRepository();
     $channelRepository->SaveChannels(array($channel));
     $filename = \Swiftriver\Core\Setup::Configuration()->CachingDirectory . "/TwitterStreamingController.tmp";
     $fp = \fopen($filename, "w");
     $done = false;
     while (!$done) {
         if (\flock($fp, \LOCK_EX)) {
             $searchArray = "";
             foreach ($parameters["SearchTerms"] as $term) {
                 $searchArray .= $term . "~";
             }
             $searchArray = \rtrim($searchArray, '~');
             \fwrite($fp, $parameters["TwitterUsername"] . "|" . $parameters["TwitterPassword"] . "|" . $searchArray);
             \flock($fp, \LOCK_UN);
             $done = true;
         } else {
             \sleep(1);
         }
     }
     \fclose($fp);
     $command = "php " . \dirname(__FILE__) . "/../../Modules/Phirehose/starttwitterstreamer.php";
     $this->execInBackground($command);
     $logger->log("Core::ServiceAPI::TwitterStreamingServices::StartTwitterStreamer::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
     return;
 }
开发者ID:ushahidi,项目名称:Swiftriver-2011,代码行数:37,代码来源:StartTwitterStreamer.php

示例15: GetForTwitterAccount

 /**
  * User the twitter RSS call to follow the tweets of a given
  * twitter user.
  * 
  * @param \Swiftriver\Core\ObjectModel\Source $source 
  * @return \Swiftriver\Core\ObjectModel\Content[]
  */
 private function GetForTwitterAccount($channel)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::Modules::SiSPS::Parsers::TwitterParser::GetForTwitterAccount [Method invoked]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Modules::SiSPS::Parsers::TwitterParser::GetForTwitterAccount [START: Extracting required parameters]", \PEAR_LOG_DEBUG);
     //Extract the required variables
     $TwitterAccount = $channel->parameters["TwitterAccount"];
     if (!isset($TwitterAccount) || $TwitterAccount == "") {
         $logger->log("Core::Modules::SiSPS::Parsers::TwitterParser::GetForTwitterAccount [the parapeter 'TwitterAccount' was not supplued. Returning null]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Modules::SiSPS::Parsers::TwitterParser::GetForTwitterAccount [Method finished]", \PEAR_LOG_DEBUG);
         return null;
     }
     $logger->log("Core::Modules::SiSPS::Parsers::TwitterParser::GetForTwitterAccount [END: Extracting required parameters]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Modules::SiSPS::Parsers::TwitterParser::GetForTwitterAccount [START: Including the SimplePie module]", \PEAR_LOG_DEBUG);
     //Include the Simple Pie Framework to get and parse feeds
     $config = \Swiftriver\Core\Setup::Configuration();
     include_once $config->ModulesDirectory . "/SimplePie/simplepie.inc";
     $logger->log("Core::Modules::SiSPS::Parsers::TwitterParser::GetForTwitterAccount [END: Including the SimplePie module]", \PEAR_LOG_DEBUG);
     //Construct a new SimplePie Parsaer
     $feed = new \SimplePie();
     //Get the cach directory
     $cacheDirectory = $config->CachingDirectory;
     $logger->log("Core::Modules::SiSPS::Parsers::TwitterParser::GetForTwitterAccount [Setting the caching directory to {$cacheDirectory}]", \PEAR_LOG_DEBUG);
     //Set the caching directory
     $feed->set_cache_location($cacheDirectory);
     //Twitter url combined with the account name passed to this feed.
     $TwitterUrl = "http://twitter.com/statuses/user_timeline/" . $TwitterAccount . ".rss";
     //Pass the feed URL to the SImplePie object
     $feed->set_feed_url($TwitterUrl);
     $logger->log("Core::Modules::SiSPS::Parsers::TwitterParser::GetForTwitterAccount [Setting the feed url to {$TwitterUrl}]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Modules::SiSPS::Parsers::TwitterParser::GetForTwitterAccount [Initilising the feed]", \PEAR_LOG_DEBUG);
     $feed->enable_cache(false);
     //Run the SimplePie
     $feed->init();
     //Create the Content array
     $contentItems = array();
     $logger->log("Core::Modules::SiSPS::Parsers::TwitterParser::GetForTwitterAccount [START: Parsing feed items]", \PEAR_LOG_DEBUG);
     $tweets = $feed->get_items();
     if (!$tweets || $tweets == null || !is_array($tweets) || count($tweets) < 1) {
         $logger->log("Core::Modules::SiSPS::Parsers::TwitterParser::GetForTwitterAccount [No feeditems recovered from the feed]", \PEAR_LOG_DEBUG);
     }
     //Loop throught the Feed Items
     foreach ($tweets as $tweet) {
         //Extract the date of the content
         $contentdate = strtotime($tweet->get_date('c'));
         if (isset($channel->lastSuccess) && is_numeric($channel->lastSuccess) && isset($contentdate) && is_numeric($contentdate)) {
             if ($contentdate < $channel->lastSuccess) {
                 $textContentDate = date("c", $contentdate);
                 $textlastSuccess = date("c", $channel->lastSuccess);
                 $logger->log("Core::Modules::SiSPS::Parsers::TwitterParser::GetForTwitterAccount [Skipped feed item as date {$textContentDate} less than last sucessful run ({$textlastSuccess})]", \PEAR_LOG_DEBUG);
                 continue;
             }
         }
         $logger->log("Core::Modules::SiSPS::Parsers::TwitterParser::GetForTwitterAccount [Adding feed item]", \PEAR_LOG_DEBUG);
         //Extract all the relevant feedItem info
         $item = $this->ParseTweetFromATOMItem($tweet, $channel);
         //Add the item to the Content array
         $contentItems[] = $item;
     }
     $logger->log("Core::Modules::SiSPS::Parsers::TwitterParser::GetForTwitterAccount [END: Parsing feed items]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Modules::SiSPS::Parsers::TwitterParser::GetForTwitterAccount [Method finished]", \PEAR_LOG_DEBUG);
     //return the content array
     return $contentItems;
 }
开发者ID:ushahidi,项目名称:Swiftriver-2011,代码行数:71,代码来源:TwitterParser.php


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