Esempio n. 1
0
 private function update()
 {
     $sites = ORM::factory('site')->find_all();
     foreach ($sites as $site) {
         # $theme_dir = $this->assets->themes_dir();
         $theme_dir = DATAPATH . "{$site->subdomain}/themes";
         $themes = Jdirectory::contents($theme_dir, 'root', 'list_dir');
         foreach ($themes as $theme) {
             $tool_dir = "{$theme_dir}/{$theme}/tools";
             if (!is_dir($tool_dir)) {
                 continue;
             }
             $toolnames = Jdirectory::contents($tool_dir, 'root', 'list_dir');
             foreach ($toolnames as $toolname) {
                 $created = "{$theme_dir}/{$theme}/tools/{$toolname}/_created";
                 if (!is_dir($created)) {
                     continue;
                 }
                 $instances = Jdirectory::contents($created, 'root', 'list_dir');
                 foreach ($instances as $instance) {
                     $path = "{$theme_dir}/{$theme}/tools/{$toolname}/_created/{$instance}";
                     if (is_dir($path)) {
                         rename($path, "{$theme_dir}/{$theme}/tools/{$toolname}/{$instance}");
                     }
                 }
                 if (is_dir($created)) {
                     rmdir($created);
                 }
             }
         }
     }
     echo 'done';
     die;
     echo kohana::debug($themes);
     die;
 }
Esempio n. 2
0
 public function delete()
 {
     if (!isset($_GET['dir'])) {
         $_GET['dir'] = '';
     }
     $dir = self::validate_dir($_GET['dir']);
     if (empty($_POST['json'])) {
         die('nothing sent');
     }
     $json = self::validate_json($_POST['json']);
     foreach ($json as $asset) {
         $ext = strrchr($asset->name, '.');
         $full_path = "{$dir}/{$asset->name}";
         if (is_dir($full_path)) {
             if ('_tmb' == $asset->name) {
                 die('Cannot delete this folder.');
             }
             Jdirectory::remove($full_path);
         } elseif (file_exists($full_path)) {
             if (unlink($full_path)) {
                 if (array_key_exists($ext, $this->image_types)) {
                     # get and recurse the _tmb directory.
                     $thumb_dirs = Jdirectory::contents("{$dir}/_tmb/", 'root', 'list_dir');
                     foreach ($thumb_dirs as $tmb_dir) {
                         if (file_exists("{$dir}/_tmb/{$tmb_dir}/{$asset->name}")) {
                             unlink("{$dir}/_tmb/{$tmb_dir}/{$asset->name}");
                         }
                     }
                 }
             }
         }
     }
     die('Assets deleted');
 }
Esempio n. 3
0
 public function edit($type = NULL)
 {
     if ('safe_mode' == $this->theme) {
         die('You are in safe-mode. Cannot edit this theme.');
     }
     $allowed = array('stylesheets', 'templates');
     if (!in_array($type, $allowed)) {
         die('invalid type');
     }
     $primary = new View("theme/{$type}");
     $theme_path = $this->assets->themes_dir($this->theme);
     switch ($type) {
         case 'templates':
             $primary->templates = Jdirectory::contents("{$theme_path}/templates", 'root');
             $primary->contents = file_exists("{$theme_path}/templates/master.html") ? file_get_contents("{$theme_path}/templates/master.html") : 'master.html not found';
             break;
         case 'stylesheets':
             $primary->css_files = Jdirectory::contents("{$theme_path}/css");
             $primary->contents = file_exists("{$theme_path}/css/global.sass") ? file_get_contents("{$theme_path}/css/global.sass") : 'global.sass not found';
             break;
         default:
             die('Invalid type');
     }
     die($primary);
 }