name = $name; if(!file_exists($this->getPath())) { throw new \Box_Exception('Theme ":name" does not exists', array(':name'=>$name)); } } public function getName() { return $this->name; } public function isAdminAreaTheme() { return (strpos($this->name, 'admin_') !== false); } public function isAssetsPathWritable() { return is_writable($this->getPathAssets()); } public function getSnippets() { $path = $this->getPathHtml(); $snippets = glob($path .DIRECTORY_SEPARATOR. 'snippet_*.phtml'); $result = array(); foreach($snippets as $snippet) { $result[basename($snippet)] = str_replace('snippet_','', pathinfo($snippet, PATHINFO_FILENAME)); } return $result; } public function getUploadedAssets() { $assets_folder = $this->getPathAssets(); $files = $this->getSettingsPageFiles(); $uploaded = array(); foreach($files as $file) { if(file_exists($assets_folder .DIRECTORY_SEPARATOR. $file)) { $uploaded[] = array( 'name' => $file, 'url' => $this->getUrl().'/assets/'.$file, ); } } return $uploaded; } private function getSettingsPageFiles() { $str = $this->getSettingsPageHtml(); if(empty($str)) { return array(); } $dom = new \DOMDocument(); $dom->loadHTML($str); $xpath = new \DOMXPath($dom); $nodes = $xpath->query("//input[@type='file']/@name"); $files = array(); foreach($nodes as $node) { $files[] = $node->textContent; } return $files; } /** * @return string */ public function getSettingsPageHtml() { $spp = $this->getPathConfig() .DIRECTORY_SEPARATOR. 'settings.html'; if(!file_exists($spp)) { error_log('Theme '. $this->getName() .' does not have settings page'); return ''; } $settings_page = file_get_contents($spp); $settings_page = $this->strip_tags_content($settings_page, '