示例#1
0
 public static function CopyDirectory($src, $dst)
 {
     $dir = opendir($src);
     @mkdir($dst);
     while (false !== ($file = readdir($dir))) {
         if ($file != '.' && $file != '..') {
             if (is_dir($src . '/' . $file)) {
                 Utilities::CopyDirectory($src . '/' . $file, $dst . '/' . $file);
             } else {
                 copy($src . '/' . $file, $dst . '/' . $file);
             }
         }
     }
     closedir($dir);
 }
示例#2
0
 public static function PublishCommonCSS($site)
 {
     $src = APP_LOCATION . '/site/css';
     $dest = SITES_LOCATION . '/' . $site['FriendlyId'] . '/css';
     // create dir if it doesn't exist
     if (!file_exists($dest)) {
         mkdir($dest, 0755, true);
     }
     // copies a directory
     Utilities::CopyDirectory($src, $dest);
 }
示例#3
0
 public static function PublishCommonCSS($siteUniqId, $root = '../')
 {
     $site = Site::GetBySiteUniqId($siteUniqId);
     $src = $root . 'sites/common/css';
     $dest = $root . 'sites/' . $site['FriendlyId'] . '/css';
     // create dir if it doesn't exist
     if (!file_exists($dest)) {
         mkdir($dest, 0755, true);
     }
     // copies a directory
     Utilities::CopyDirectory($src, $dest);
 }
示例#4
0
 /**
  * @method POST
  */
 function post()
 {
     // get token
     $token = Utilities::ValidateJWTToken();
     // check if token is not null
     if ($token != NULL) {
         // get a reference to the site, user
         $site = Site::GetBySiteId($token->SiteId);
         parse_str($this->request->data, $request);
         // parse request
         // get content
         $locale = $request['locale'];
         // copy default file to new locale
         $src = SITES_LOCATION . '/' . $site['FriendlyId'] . '/locales/' . $site['Language'] . '/';
         $dest = SITES_LOCATION . '/' . $site['FriendlyId'] . '/locales/' . $locale . '/';
         // create libs directory if it does not exist
         if (!file_exists($dest)) {
             mkdir($dest, 0755, true);
         }
         // copy libs directory
         if (file_exists($src)) {
             Utilities::CopyDirectory($src, $dest);
         }
         // return a json response
         return new Tonic\Response(Tonic\Response::OK);
         return $response;
     } else {
         // return an unauthorized exception (401)
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }