Exemple #1
0
 public static function findFields($paths, $dest = '')
 {
     if (count($paths)) {
         foreach ($paths as $path) {
             if (!JFile::exists($path)) {
                 continue;
             }
             $data = JFile::read($path);
             $ext = JFile::getExt($path);
             $names = '';
             if ($ext == 'xml') {
                 $regex = '#construction=\\"([a-z0-9_]*)\\"#';
                 preg_match_all($regex, $data, $matches);
                 if (count($matches[1])) {
                     $names = '"' . implode('","', $matches[1]) . '"';
                 }
             } else {
                 $regex = '#(JCckDev::renderForm\\(|JCckDev::getForm\\(|JCckDev::get\\() ?(\\$cck\\[)?\'([a-z0-9_]*)\'#';
                 preg_match_all($regex, $data, $matches);
                 if (count($matches[3])) {
                     $names = '"' . implode('","', $matches[3]) . '"';
                 }
             }
             if ($names != '') {
                 $fields = JCckDatabase::loadObjectList('SELECT a.* FROM #__cck_core_fields AS a WHERE a.name IN (' . $names . ') AND a.id >= 5000');
                 if ($dest) {
                     CCK_Export::exportFields($dest, $fields);
                 } else {
                     return $fields;
                 }
             }
         }
     }
 }