コード例 #1
3
 public function __construct($data = null)
 {
     $this->chunk_factory = Inject::the(new SSLChunkFactory());
     $this->data = $data;
     $this->data_len = strlen($data);
 }
コード例 #2
2
ファイル: SSLParser.php プロジェクト: rabyunghwa/sslscrobbler
 /**
  * You should construct the parser with a $dom of the type that you wish to 
  * fill in from the parsed chunks (different DOM types have different parsing
  * semantics for the chunk types). For example, you probably want to use the
  * SSLHistoryDom for reading the history file, as this DOM understands that
  * ADAT chunks are SSLTracks. 
  * 
  * @param SSLDom $dom
  */
 public function __construct(SSLDom $dom = null)
 {
     $this->factory = Inject::the(new SSLRepo());
     if (isset($dom)) {
         $this->dom_prototype = $dom;
     } else {
         $this->dom_prototype = $this->factory->newDom();
     }
 }
コード例 #3
2
 public function __construct($array = array())
 {
     $this->track_factory = Inject::the(new SSLTrackFactory());
     parent::__construct($array);
 }
コード例 #4
1
 public function __construct($filename, DiffMonitor $monitor)
 {
     $factory = Inject::the(new SSLRepo());
     $monitor->setFilename($filename);
     $monitor->setPrototype($factory->newHistoryIndexDom());
     $monitor->setDiffDelegate($this);
 }
コード例 #5
1
 public function tearDown()
 {
     Inject::reset();
 }
コード例 #6
1
ファイル: pi.inject.php プロジェクト: amphibian/pi.inject.php
/*
Inject
============
Description
-----------
Inject allows you to place content inside the opening and closing tags 
of a wysiwyg-generated output block.
Usage
-----
{exp:inject start='{stuff_to_inject}' end='{other_stuff_to_inject}' spacer=' '}{content}{/exp:inject}
Bugs
----
To file bug reports please send email to: <*****@*****.**>
*/
$plugin_info = array('pi_name' => 'Inject', 'pi_version' => '0.2', 'pi_author' => 'Dan Drinkard', 'pi_author_url' => 'http://displayawesome.com/', 'pi_description' => 'Injects markup or template tags into the first opening and last closing tags of a block\'s output', 'pi_usage' => Inject::usage());
class Inject
{
    var $return_data = "";
    function Inject()
    {
        global $TMPL;
        $content = $TMPL->tagdata;
        $inject_start = $TMPL->fetch_param('start');
        $inject_end = $TMPL->fetch_param('end');
        $spc = $TMPL->fetch_param('spacer');
        $pos_start = strpos($content, '>') + 1;
        $pos_end = strrpos($content, '<');
        $start = substr($content, 0, $pos_start);
        $middle = substr($content, $pos_start, $pos_end - $pos_start);
        $end = substr($content, $pos_end);
コード例 #7
1
 public function __construct()
 {
     $this->factory = Inject::the(new SSLRepo());
 }
コード例 #8
1
 protected function post_process($filename)
 {
     echo "post processing {$filename}...\n";
     // Use the caching version via Dependency Injection. This means that all
     // new SSLTracks created using a SSLTrackFactory will get a RuntimeCachingSSLTrack
     // that knows how to ask the cache about expensive lookups (such as getID3 stuff).
     Inject::map('SSLTrackFactory', new SSLTrackCache());
     $ts = new InstantTickSource();
     $hfm = new SSLHistoryFileReplayer($filename);
     $ism = new ImmediateScrobbleModel();
     // deal with PLAYED tracks one by one
     $ts->addTickObserver($hfm);
     $hfm->addExitObserver($ts);
     $hfm->addDiffObserver($ism);
     // get the PluginWrapper that wraps all other plugins.
     $pw = $this->plugin_manager->getObservers();
     // add all of the PluginWrappers to the various places.
     $ts->addTickObserver($pw[0]);
     $hfm->addDiffObserver($pw[0]);
     $ism->addScrobbleObserver($pw[0]);
     $this->plugin_manager->onStart();
     // Tick tick tick. This only returns if a signal is caught
     $ts->startClock($this->sleep);
     $this->plugin_manager->onStop();
 }
コード例 #9
1
 public function __construct($program)
 {
     $this->factory = Inject::the(new XoupRepo());
     $this->subs = $this->parse($program);
 }
コード例 #10
1
ファイル: Inject.php プロジェクト: rabyunghwa/sslscrobbler
 public static function reset()
 {
     self::$substitutions = array();
 }
コード例 #11
0
ファイル: SSLTrack.php プロジェクト: ben-xo/sslscrobbler
 /**
  * Sometimes ScratchLive doesn't supply the length, even when it knows the file.
  * Not sure why; perhaps files that have never been analysed.
  * 
  * So, let's attempt to guess it by analysing the full file.
  */
 protected function guessLengthFromFile()
 {
     $fullpath = $this->getFullpath();
     if (strlen($fullpath) == 0) {
         L::level(L::WARNING) && L::log(L::WARNING, __CLASS__, 'Guessing MP3 length from file failed: full path was empty. Perhaps this entry was manually added?', array());
         return "0:00";
     }
     if (!$this->file_exists($fullpath)) {
         L::level(L::WARNING) && L::log(L::WARNING, __CLASS__, 'Guessing MP3 length from file failed: file not found (%s)', array($fullpath));
         return "0:00";
     }
     $external_factory = Inject::the(new ExternalRepo());
     /* @var $external_factory ExternalFactory */
     $getid3 = $external_factory->newGetID3();
     /* @var $getid3 getid3 */
     $getid3->option_tag_lyrics3 = false;
     $getid3->option_tag_apetag = false;
     $getid3->option_extra_info = true;
     $getid3->encoding = 'UTF-8';
     try {
         $info = $getid3->Analyze($fullpath);
         $playtime = $info['playtime_seconds'];
         if ($playtime) {
             L::level(L::WARNING) && L::log(L::WARNING, __CLASS__, 'Guessed MP3 length %d seconds from file.', array($playtime));
             $minutes = floor($playtime / 60);
             $seconds = $playtime % 60;
             return sprintf("%d:%02d", $minutes, $seconds);
         }
         L::level(L::WARNING) && L::log(L::WARNING, __CLASS__, 'Guessing MP3 length from file failed for an unknown reason. Hmmph.', array());
     } catch (getid3_exception $e) {
         // MP3 couldn't be analyzed.
         L::level(L::WARNING) && L::log(L::WARNING, __CLASS__, 'Guessing MP3 length from file failed: %s', array($e->getMessage()));
     }
     return "0:00";
 }
コード例 #12
0
ファイル: SSLStruct.php プロジェクト: rabyunghwa/sslscrobbler
 public function __construct()
 {
     $this->xoup_factory = Inject::the(new XoupRepo());
 }