Esempio n. 1
0
 /**
  * Verlinkt einen Artikel dynamisch mit der Suche �ber die �bergebenen Schl�sselw�rter
  *
  * @param    string     $strHighlight
  * @param    string     $strSource
  * @param    integer    $intCount
  * @return   string
  * @author   Marco Enders <*****@*****.**>
  * @author   Thorsten Rinne <*****@*****.**>
  */
 public function setRelationLinks($strHighlight, $strSource, $intCount = 0)
 {
     global $in_content;
     $x = 0;
     $arrMatch = array();
     PMF_String::preg_match_all('/(<a[^<>]*?>.*?<\\/a>)|(<.*?>)/is', $strSource, $arrMatch);
     $strSource = PMF_String::preg_replace('/(<a[^<>]*?>.*?<\\/a>)|(<.*?>)/is', '~+*# replaced html #*+~', $strSource);
     $x = $x + PMF_String::preg_match('/(' . preg_quote($strHighlight) . ')/ims', $strSource);
     $strSource = PMF_String::preg_replace('/(' . preg_quote($strHighlight) . ')/ims', '<a href="index.php?action=search&search=' . $strHighlight . '" title="Insgesamt ' . $intCount . ' Artikel zu diesem Schlagwort (' . $strHighlight . ') vorhanden. Jetzt danach suchen..." class="relation">$1</a>', $strSource);
     foreach ($arrMatch[0] as $html) {
         $strSource = PMF_String::preg_replace('/' . preg_quote('~+*# replaced html #*+~') . '/', $html, $strSource, 1);
     }
     if ($x == 0) {
         $in_content = false;
     } else {
         $in_content = true;
     }
     return $strSource;
 }
Esempio n. 2
0
 /**
  * This function reads the block
  *
  * @param  string $tpl Block to read
  * 
  * @return string
  */
 private function _readBlocks($tpl)
 {
     $tmpBlocks = array();
     // read all blocks into $tmpBlocks
     PMF_String::preg_match_all('/\\[([[:alpha:]]+)\\]\\s*[\\W\\w\\s\\{\\}\\<\\>\\=\\"\\/]*?\\s*\\[\\/\\1\\]/', $tpl, $tmpBlocks);
     $unblocked = $tpl;
     if (isset($tmpBlocks)) {
         $blockCount = count($tmpBlocks[0]);
         for ($i = 0; $i < $blockCount; $i++) {
             $name = '';
             //find block name
             PMF_String::preg_match('/\\[.+\\]/', $tmpBlocks[0][$i], $name);
             $name = PMF_String::preg_replace('/[\\[\\[\\/\\]]/', '', $name);
             //remove block tags from block
             $res = str_replace('[' . $name[0] . ']', '', $tmpBlocks[0][$i]);
             $res = str_replace('[/' . $name[0] . ']', '', $res);
             $tplBlocks[$name[0]] = $res;
             //unblocked content
             $unblocked = str_replace($tplBlocks[$name[0]], '', $unblocked);
             $unblocked = str_replace('[' . $name[0] . ']', '', $unblocked);
             $unblocked = str_replace('[/' . $name[0] . ']', '', $unblocked);
         }
         $hits = array();
         PMF_String::preg_match_all('/\\{.+?\\}/', $unblocked, $hits);
         $tplBlocks['unblocked'] = $hits[0];
     } else {
         // no blocks defined
         $tplBlocks = $tpl;
     }
     return $tplBlocks;
 }
Esempio n. 3
0
 /**
  * 
  * Match a regexp globally
  * @param string $pattern
  * @param string $subject
  * @param array &$matches
  * @param int $flags
  * @param int $offset
  * 
  * @return int
  */
 public static function preg_match_all($pattern, $subject, &$matches = null, $flags = 0, $offset = 0)
 {
     return self::$instance->preg_match_all($pattern, $subject, $matches, $flags, $offset);
 }
Esempio n. 4
0
 /**
  * Align the prefix of the table name used in the PMF backup file,
  * from the (old) value of the system upon which the backup was performed
  * to the (new) prefix of the system upon which the backup will be restored.
  * This alignment will be perfomed ONLY upon those given SQL queries starting
  * with the given pattern.
  *
  * @param string $query
  * @param string $startPattern
  * @param string $oldValue
  * @param string $newValue
  * 
  * @return  string
  */
 private static function alignTablePrefixByPattern($query, $startPattern, $oldValue, $newValue)
 {
     $return = $query;
     $matches = [];
     PMF_String::preg_match_all("/^" . $startPattern . "\\s+(\\w+)(\\s+|\$)/i", $query, $matches);
     if (isset($matches[1][0])) {
         $oldTableFullName = $matches[1][0];
         $newTableFullName = $newValue . PMF_String::substr($oldTableFullName, PMF_String::strlen($oldValue));
         $return = str_replace($oldTableFullName, $newTableFullName, $query);
     }
     return $return;
 }