Exemplo n.º 1
0
 public static final function webalize($s, $charlist = NULL)
 {
     $s = TexyUtf::utf2ascii($s);
     $s = strtolower($s);
     $s = preg_replace('#[^a-z0-9' . preg_quote($charlist, '#') . ']+#', '-', $s);
     $s = trim($s, '-');
     return $s;
 }
 /**
  * Returns named reference.
  *
  * @param  string  reference name
  * @return TexyLink reference descriptor (or FALSE)
  */
 public function getReference($name)
 {
     $name = TexyUtf::strtolower($name);
     if (isset($this->references[$name])) {
         return clone $this->references[$name];
     } else {
         $pos = strpos($name, '?');
         if ($pos === FALSE) {
             $pos = strpos($name, '#');
         }
         if ($pos !== FALSE) {
             // try to extract ?... #... part
             $name2 = substr($name, 0, $pos);
             if (isset($this->references[$name2])) {
                 $link = clone $this->references[$name2];
                 $link->URL .= substr($name, $pos);
                 return $link;
             }
         }
     }
     return FALSE;
 }
Exemplo n.º 3
0
 /**
  * Returns named reference.
  *
  * @param  string  reference name
  * @return TexyImage  reference descriptor (or FALSE)
  */
 public function getReference($name)
 {
     $name = TexyUtf::strtolower($name);
     if (isset($this->references[$name])) {
         return clone $this->references[$name];
     }
     return FALSE;
 }
Exemplo n.º 4
0
 /**
  * Adds new named reference.
  *
  * @param  string  reference name
  * @param  TexyLink
  *
  * @return void
  */
 public function addReference($name, TexyLink $link)
 {
     $link->name = TexyUtf::strtolower($name);
     $this->references[$link->name] = $link;
 }
Exemplo n.º 5
0
 /**
  * Converts DOM structure to pure text.
  *
  * @return string
  */
 public function toText()
 {
     if (!$this->DOM) {
         throw new InvalidStateException('Call $texy->process() first.');
     }
     return TexyUtf::utfTo($this->DOM->toText($this), $this->encoding);
 }
 /**
  * Adds new named reference to image.
  *
  * @param  string  reference name
  * @param  TexyImage
  *
  * @return void
  */
 public function addReference($name, TexyImage $image)
 {
     $image->name = TexyUtf::strtolower($name);
     $this->references[$image->name] = $image;
 }