示例#1
0
文件: content.php 项目: hamby/SEBLOD
 public static function setValue($text, $fieldname, $value, $old_value = '')
 {
     $res = $text;
     $search = '';
     if ($old_value) {
         $search = CCK_Content::getSyntax($fieldname, $old_value);
     } else {
         $regex = CCK_Content::getRegex_Field($fieldname);
         preg_match($regex, $text, $matches);
         if (count($matches)) {
             $search = $matches[0];
         }
     }
     if ($search) {
         $replace = CCK_Content::getSyntax($fieldname, $value);
         if (strpos($text, $search) !== false) {
             $res = str_replace($search, $replace, $text);
         }
     }
     return $res;
 }