Esempio n. 1
0
 /**
  * Makes a copy of the file source to dest. Returns TRUE on success or FALSE on failure
  * @param string $source source file or directory
  * @param string $destination destination
  */
 public static function copy($source, $destination)
 {
     if (preg_match("/cvs\$/", strtolower($source))) {
         return true;
     }
     if (is_dir($source)) {
         if (!mkdir($destination)) {
             return false;
         } else {
             $res = true;
             if ($dh = opendir($source)) {
                 while (($file_or_directory = readdir($dh)) !== false) {
                     if ($file_or_directory != '.' && $file_or_directory != '..') {
                         if (!SJB_Filesystem::copy($source . '/' . $file_or_directory, $destination . '/' . $file_or_directory)) {
                             $res = false;
                         }
                     }
                 }
                 closedir($dh);
             }
             return $res;
         }
     } else {
         if (copy($source, $destination)) {
             $old = umask(0);
             chmod($destination, 0777);
             umask($old);
             return true;
         }
         return false;
     }
 }
Esempio n. 2
0
 function copyEntireTheme($copiedThemeName, $newThemeName)
 {
     $newThemePath = SJB_TemplatePathManager::getAbsoluteThemePath($copiedThemeName);
     $copiedThemePath = SJB_TemplatePathManager::getAbsoluteThemePath($newThemeName);
     SJB_Filesystem::copy($newThemePath, $copiedThemePath);
     SJB_Filesystem::mkpath(SJB_TemplatePathManager::getAbsoluteThemeCachePath($newThemeName));
     $themeFields = SJB_FormBuilderManager::getFieldsByTheme($copiedThemeName);
     foreach ($themeFields as $themeField) {
         SJB_FormBuilderManager::insertField($newThemeName, $themeField);
     }
     $screenFile = $copiedThemePath . "main/images/{$copiedThemeName}.png";
     $newScreenFile = $copiedThemePath . "main/images/{$newThemeName}.png";
     if (file_exists($screenFile)) {
         rename($screenFile, $newScreenFile);
     }
     $listingTypes = SJB_ListingTypeDBManager::getAllListingTypesInfo();
     foreach ($listingTypes as $listingType) {
         SJB_Settings::addSetting("display_layout_{$listingType['id']}_{$newThemeName}", SJB_Settings::getSettingByName("display_layout_{$listingType['id']}_{$copiedThemeName}"));
     }
 }