public function update($only_if_not_modified = true) { if (!$this->path_custom || $this->type != self::OVERRIDDEN) { return true; } $files = $this->getFiles(); $modified = array(); foreach ($files as $f_id => $f) { if (!empty($f['modified'])) { $modified[] = $f_id; break; } } if ($only_if_not_modified && $modified) { return false; } $img_files = array(); foreach ($this->getSettings() as $s) { if (ifset($s['control_type']) == 'image' && !empty($s['value'])) { $img_files[] = $s['value']; } } $source_path = $this->path_original; $target_path = $this->path_custom; $list_files = waFiles::listdir($source_path); $skip_pattern = '/\\.(files\\.md5|cvs|svn|git|php\\d*)$/'; foreach ($list_files as $f) { // ignore files if ($f !== 'build.php') { foreach ((array) $skip_pattern as $pattern) { if (preg_match($pattern, $f)) { continue 2; } } } // ignore image settings and modified if ($f == 'theme.xml' || in_array($f, $img_files) || in_array($f, $modified)) { continue; } try { waFiles::copy($source_path . '/' . $f, $target_path . '/' . $f); } catch (waException $e) { } } if ($this->type == self::OVERRIDDEN) { $theme_original = new waTheme($this->id, $this->app_id, self::ORIGINAL); $this->version = $theme_original->version; foreach ($theme_original->getFiles(true) as $f_id => $f) { if (empty($files[$f_id])) { $this->setFiles(array($f_id => $f)); } } foreach ($theme_original->getSettings('full') as $var => $s) { if (!isset($this->info['settings'][$var])) { $this->info['settings'][$var] = $s; $this->settings[$var]['value'] = ifset($s['value'], ''); $this->changed['settings'][$var] = true; } else { $old_s = $this->info['settings'][$var]; if (ifset($old_s['control_type']) != ifset($s['control_type']) || ifset($old_s['options']) != ifset($s['options'])) { $s['value'] = ifset($old_s['value'], ''); $this->info['settings'][$var] = $s; $this->settings[$var]['value'] = $s['value']; $this->changed['settings'][$var] = true; } } } $this->save(); } return true; }