Ejemplo n.º 1
0
 /**
  * Gets the EmoticonCollection instance associated with this EmoticonHook.
  *
  * @return EmoticonCollection A EmoticonCollection instance
  */
 public function getEmoticonCollection()
 {
     if (null !== $this->collection) {
         return $this->collection;
     }
     $this->collection = new EmoticonCollection();
     // Convert a default decoda emoticons array to an EmoticonCollection
     $collection = new EmoticonCollection();
     if (!$this->getEmoticons()) {
         if (null === $this->getParser()) {
             $this->setParser(new Decoda());
         }
         $this->startup();
     }
     foreach ($this->getEmoticons() as $name => $smilies) {
         $emoticon = new Emoticon();
         foreach ($smilies as $smiley) {
             $emoticon->setSmiley($smiley);
         }
         $collection->add($name, $emoticon);
     }
     $this->collection->addCollection($collection);
     if (null !== $this->options['resource']) {
         $subCollection = $this->loader->load($this->options['resource'], $this->options['resource_type']);
         $this->collection->addCollection($subCollection);
     }
     $this->resolveParameters($this->collection);
     return $this->collection;
 }
Ejemplo n.º 2
0
 /**
  * Gets the EmoticonCollection instance associated with this EmoticonHook.
  *
  * @return EmoticonCollection A EmoticonCollection instance
  */
 public function getEmoticonCollection()
 {
     if (null !== $this->collection) {
         return $this->collection;
     }
     $this->collection = new EmoticonCollection();
     if (null === $this->_parser) {
         // Gets default decoda emoticons ($this->_emoticons)
         parent::setParser(new Decoda());
     }
     // Convert a default decoda emoticons array to an EmoticonCollection
     $collection = new EmoticonCollection();
     foreach ($this->_emoticons as $name => $smilies) {
         $emoticon = new Emoticon();
         foreach ($smilies as $smiley) {
             $emoticon->setSmiley($smiley);
         }
         $collection->add($name, $emoticon);
     }
     foreach ($this->getParser()->getPaths() as $path) {
         if (!file_exists($path . '/emoticons.json')) {
             continue;
         }
         $collection->addResource(new FileResource($path . '/emoticons.json'));
     }
     $this->collection->addCollection($collection);
     if (null !== $this->options['resource']) {
         $subCollection = $this->loader->load($this->options['resource'], $this->options['resource_type']);
         $this->collection->addCollection($subCollection);
     }
     $this->resolveParameters($this->collection);
     return $this->collection;
 }
Ejemplo n.º 3
0
 /**
  * Parses all imports.
  *
  * @param EmoticonCollection $collection
  * @param array              $content
  * @param string             $file
  */
 private function parseImports(EmoticonCollection $collection, $content, $file)
 {
     if (!isset($content['imports'])) {
         return;
     }
     foreach ($content['imports'] as $import) {
         $this->setCurrentDir(dirname($file));
         $subCollection = $this->import($import['resource'], null, isset($import['ignore_errors']) ? (bool) $import['ignore_errors'] : false, $file);
         $collection->addCollection($subCollection);
     }
 }