<?php /** * Download tests for all installed packages. */ $dir = scandir(TYPEF_SOURCE_DIR . '/packages'); foreach ($dir as $file) { if (substr($file, 0, 1) != '.' && pathinfo($file, PATHINFO_EXTENSION) == 'xml') { $package = pathinfo($file, PATHINFO_FILENAME); $xml = Pagemill_SimpleXmlElement::LoadFile(TYPEF_SOURCE_DIR . "/packages/{$file}"); $version = $xml['version']; // Ignore packages without tests (required for backwards compatibility) $buffer = @file_get_contents(TYPEF_PROVIDER . '/download/' . $package . '-' . $version . '-test.tar.gz'); if ($buffer) { echo "Installing tests for {$package}\n"; file_put_contents('test.tar.gz', $buffer); exec('tar -zxvf test.tar.gz'); exec('rm test.tar.gz'); } } }
public static function StylesheetsFor($template, $uri = null) { $stylesheets = array(); $tmplXml = Pagemill_SimpleXmlElement::LoadFile(Typeframe_Skin::TemplatePath($template, $uri)); if (strpos($tmplXml->asXml(), '<pm:html') !== false) { if (is_null($uri)) { $skin = self::Current(); } else { $skin = self::At($uri); } $skinXml = Pagemill_SimpleXmlElement::LoadFile(TYPEF_DIR . '/skins/' . $skin . '/skin.html'); self::_GetStylesheetsFromElement($skinXml, $stylesheets); } self::_GetStylesheetsFromElement($tmplXml, $stylesheets); return $stylesheets; }
<?php /** * Check for customized files in packages * Syntax: compare-local [package] */ if (empty($argv[2])) { echo "No package specified.\n"; exit; } $xml = Pagemill_SimpleXmlElement::LoadFile(TYPEF_SOURCE_DIR . '/packages/' . $argv[2] . '.xml'); foreach ($xml->file as $file) { if (file_exists(TYPEF_DIR . "/{$file}")) { $md5 = md5_file(TYPEF_DIR . "/{$file}"); if ($md5 != "{$file['md5']}") { echo "Local version of {$file} is different.\n"; } } else { echo "Local version of {$file} does not exist.\n"; } }
/** * Download package dependencies from the specified package in a temporary isntallation directory. * @param string $directory The temporary directory. * @param string $package The name of the package. * @param array $dependencies An array of package names that have already been downloaded. */ private static function _GetDependencies($directory, $package, &$dependencies) { if (!file_exists("{$directory}/source/packages/{$package}.xml")) { $buffer = self::_DownloadToBuffer(TYPEF_PROVIDER . '/download/newest?package=' . $package); $tarball = "{$directory}/{$package}.tar.gz"; file_put_contents($tarball, $buffer); exec('tar --directory=' . $directory . ' -zxf ' . $tarball); exec('rm ' . $tarball); } $xml = Pagemill_SimpleXmlElement::LoadFile("{$directory}/source/packages/{$package}.xml"); foreach ($xml->require as $require) { $require = trim("{$require}"); if (!in_array($require, $dependencies)) { $dependencies[] = $require; if (file_exists(TYPEF_SOURCE_DIR . "/packages/{$require}.xml")) { // Dependency is already installed. Check if a newer version // is available. $installedXml = Pagemill_SimpleXmlElement::LoadFile(TYPEF_SOURCE_DIR . "/packages/{$require}.xml"); $latest = self::_DownloadToBuffer(TYPEF_PROVIDER . '/newest?package=' . $require); if (self::EnumerateVersion($installedXml['version']) >= self::EnumerateVersion($latest)) { continue; } } $buffer = self::_DownloadToBuffer(TYPEF_PROVIDER . '/download/newest?package=' . $require); $tarball = "{$directory}/{$require}.tar.gz"; file_put_contents($tarball, $buffer); exec('tar --directory=' . $directory . ' -zxf ' . $tarball, $output); exec('rm ' . $tarball); self::_GetDependencies($directory, $require, $dependencies); } } }
private static function _InsertSelector($element, $skin) { static $ignore = array('if', 'loop', 'insert', 'codeblock'); $selector = ''; $current = $element; while ($current) { if ($current->getName() == 'body') { break; } if (!in_array($current->getName(), $ignore)) { $class = trim("{$current['class']}"); $id = trim("{$current['id']}"); $part = $current->getName(); if ($id) { $part .= '#' . $id; } if ($class) { $class = preg_replace('/ +/', '.', $class); $part .= '.' . $class; } $selector = $part . ' ' . $selector; } $stack = $current->xpath('parent::*'); if (count($stack)) { $current = array_pop($stack); } else { $current = null; } } $skinXml = Pagemill_SimpleXmlElement::LoadFile(TYPEF_DIR . '/skins/' . $skin . '/skin.html'); $xpath = $skinXml->xpath('//pm:import[@name=\'body\']'); if (count($xpath)) { $current = $xpath[0]; $stack = $current->xpath('parent::*'); while (count($stack)) { $current = array_pop($stack); if ($current->getName() == 'body' || $current->getName == 'html') { break; } if (!in_array($current->getName(), $ignore)) { $id = ''; $class = ''; if ($current['id']) { $id = '#' . $current['id']; } if ($current['class']) { $class = '.' . preg_replace('/ +/', '.', $class); } //if ($id || $class) { $selector = $current->getName() . $id . $class . ' ' . $selector; //} } $stack = $current->xpath('parent::*'); } } // Selectors should never contain Pagemill expressions if (strpos($selector, '@{') !== false) { $selector = ''; } return trim($selector); }