예제 #1
0
 public function testGetCorePackages()
 {
     $packages = LocoPackage::get_core_packages();
     $this->assertCount(5, $packages);
     $this->assertArrayHasKey('', $packages);
     $this->assertArrayHasKey('ms', $packages);
     $this->assertArrayHasKey('admin', $packages);
     $this->assertArrayHasKey('admin-network', $packages);
     $this->assertArrayHasKey('continents-cities', $packages);
 }
예제 #2
0
/**
 * Admin ajax include that syncs PO or POT file with sources
 */
DOING_AJAX or die;
if (empty($path) || !isset($name) || empty($type)) {
    throw new Exception(Loco::__('Invalid data posted to server'), 422);
}
// path is allowed to not exist yet
if ('/' !== $path[0]) {
    $path = WP_CONTENT_DIR . '/' . $path;
}
// but package must exist so we can get POT or source
/* @var $package LocoPackage */
loco_require('loco-packages', 'loco-locales');
$package = LocoPackage::get($name, $type);
if (!$package) {
    throw new Exception(sprintf(Loco::__('Package not found called %s'), $name), 404);
}
while (true) {
    // If file we're syncing is POT, we can only sync from sources
    if (!LocoAdmin::is_pot($path)) {
        // if a POT file exists, sync from that
        $domain = LocoAdmin::resolve_file_domain($path) or $domain = $package->get_domain();
        if ($pot_path = $package->get_pot($domain)) {
            $exp = LocoAdmin::parse_po($pot_path);
            if (!$exp || 1 === count($exp) && '' === $exp[0]['source']) {
                // throw new Exception( Loco::__('POT file is empty').' - '.basename($pot_path) );
                // fall through to try source code
            } else {
                $pot = basename($pot_path);
예제 #3
0
 /**
  * Generate a link to check file permissions on a packge
  */
 public static function fscheck_link(LocoPackage $package, $domain = '', $label)
 {
     if (!$domain) {
         $domain = $package->get_domain();
     }
     $url = self::uri($package->get_query() + array('fscheck' => $domain ? $domain : $package->get_domain()));
     return '<a href="' . Loco::html($url) . '">' . Loco::html($label) . '</a>';
 }
예제 #4
0
 public function get_pot($domain = '')
 {
     if (($parent = $this->get_parent()) && ($pot = $parent->get_pot($domain))) {
         return $pot;
     }
     return parent::get_pot($domain);
 }
예제 #5
0
 /**
  * @depends testLocoPluginPackage
  */
 public function testLocoPluginPackageOriginalHeaders(LocoPackage $package)
 {
     $this->assertSame(Loco::NS, $package->get_original('TextDomain'));
 }