Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/storage/PhabricatorRepositoryURI.php
Show First 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | public function getRepositoryURIBuiltinKey() { | ||||
if (!$this->getBuiltinProtocol()) { | if (!$this->getBuiltinProtocol()) { | ||||
return null; | return null; | ||||
} | } | ||||
$parts = array( | $parts = array( | ||||
$this->getBuiltinProtocol(), | $this->getBuiltinProtocol(), | ||||
$this->getBuiltinIdentifier(), | $this->getBuiltinIdentifier(), | ||||
); | ); | ||||
return implode('.', $parts); | return implode('.', $parts); | ||||
} | } | ||||
public function isBuiltin() { | public function isBuiltin() { | ||||
return (bool)$this->getBuiltinProtocol(); | return (bool)$this->getBuiltinProtocol(); | ||||
} | } | ||||
public function getEffectiveDisplayType() { | public function getEffectiveDisplayType() { | ||||
$display = $this->getDisplayType(); | $display = $this->getDisplayType(); | ||||
if ($display != self::IO_DEFAULT) { | if ($display != self::IO_DEFAULT) { | ||||
return $display; | return $display; | ||||
} | } | ||||
return $this->getDefaultDisplayType(); | |||||
} | |||||
public function getDefaultDisplayType() { | |||||
switch ($this->getEffectiveIOType()) { | switch ($this->getEffectiveIOType()) { | ||||
case self::IO_MIRROR: | case self::IO_MIRROR: | ||||
case self::IO_OBSERVE: | case self::IO_OBSERVE: | ||||
return self::DISPLAY_NEVER; | return self::DISPLAY_NEVER; | ||||
case self::IO_NONE: | case self::IO_NONE: | ||||
if ($this->isBuiltin()) { | if ($this->isBuiltin()) { | ||||
return self::DISPLAY_NEVER; | return self::DISPLAY_NEVER; | ||||
} else { | } else { | ||||
Show All 32 Lines | switch ($this->getEffectiveIOType()) { | ||||
if ($this_identifier < $best_identifier) { | if ($this_identifier < $best_identifier) { | ||||
return self::DISPLAY_NEVER; | return self::DISPLAY_NEVER; | ||||
} | } | ||||
} | } | ||||
return self::DISPLAY_ALWAYS; | return self::DISPLAY_ALWAYS; | ||||
} | } | ||||
return self::DISPLAY_NEVER; | |||||
} | } | ||||
public function getEffectiveIOType() { | public function getEffectiveIOType() { | ||||
$io = $this->getIoType(); | $io = $this->getIoType(); | ||||
if ($io != self::IO_DEFAULT) { | if ($io != self::IO_DEFAULT) { | ||||
return $io; | return $io; | ||||
} | } | ||||
return $this->getDefaultIOType(); | |||||
} | |||||
public function getDefaultIOType() { | |||||
if ($this->isBuiltin()) { | if ($this->isBuiltin()) { | ||||
$repository = $this->getRepository(); | $repository = $this->getRepository(); | ||||
$other_uris = $repository->getURIs(); | $other_uris = $repository->getURIs(); | ||||
$any_observe = false; | $any_observe = false; | ||||
foreach ($other_uris as $other_uri) { | foreach ($other_uris as $other_uri) { | ||||
if ($other_uri->getIoType() == self::IO_OBSERVE) { | if ($other_uri->getIoType() == self::IO_OBSERVE) { | ||||
$any_observe = true; | $any_observe = true; | ||||
▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | switch ($this->getBuiltinIdentifier()) { | ||||
return "/source/{$short_name}{$suffix}"; | return "/source/{$short_name}{$suffix}"; | ||||
case self::BUILTIN_IDENTIFIER_CALLSIGN: | case self::BUILTIN_IDENTIFIER_CALLSIGN: | ||||
return "/diffusion/{$callsign}/{$clone_name}{$suffix}"; | return "/diffusion/{$callsign}/{$clone_name}{$suffix}"; | ||||
default: | default: | ||||
return null; | return null; | ||||
} | } | ||||
} | } | ||||
public function getViewURI() { | |||||
$id = $this->getID(); | |||||
return $this->getRepository()->getPathURI("uri/view/{$id}/"); | |||||
} | |||||
public function getEditURI() { | |||||
$id = $this->getID(); | |||||
return $this->getRepository()->getPathURI("uri/edit/{$id}/"); | |||||
} | |||||
public function getAvailableIOTypeOptions() { | |||||
$options = array( | |||||
self::IO_DEFAULT, | |||||
self::IO_NONE, | |||||
); | |||||
if ($this->isBuiltin()) { | |||||
$options[] = self::IO_READ; | |||||
$options[] = self::IO_WRITE; | |||||
} else { | |||||
$options[] = self::IO_OBSERVE; | |||||
$options[] = self::IO_MIRROR; | |||||
} | |||||
$map = array(); | |||||
$io_map = self::getIOTypeMap(); | |||||
foreach ($options as $option) { | |||||
$spec = idx($io_map, $option, array()); | |||||
$label = idx($spec, 'label', $option); | |||||
$short = idx($spec, 'short'); | |||||
$name = pht('%s: %s', $label, $short); | |||||
$map[$option] = $name; | |||||
} | |||||
return $map; | |||||
} | |||||
public function getAvailableDisplayTypeOptions() { | |||||
$options = array( | |||||
self::DISPLAY_DEFAULT, | |||||
self::DISPLAY_ALWAYS, | |||||
self::DISPLAY_NEVER, | |||||
); | |||||
$map = array(); | |||||
$display_map = self::getDisplayTypeMap(); | |||||
foreach ($options as $option) { | |||||
$spec = idx($display_map, $option, array()); | |||||
$label = idx($spec, 'label', $option); | |||||
$short = idx($spec, 'short'); | |||||
$name = pht('%s: %s', $label, $short); | |||||
$map[$option] = $name; | |||||
} | |||||
return $map; | |||||
} | |||||
public static function getIOTypeMap() { | |||||
return array( | |||||
self::IO_DEFAULT => array( | |||||
'label' => pht('Default'), | |||||
'short' => pht('Use default behavior.'), | |||||
), | |||||
self::IO_OBSERVE => array( | |||||
'icon' => 'fa-download', | |||||
'color' => 'green', | |||||
'label' => pht('Observe'), | |||||
'note' => pht( | |||||
'Phabricator will observe changes to this URI and copy them.'), | |||||
'short' => pht('Copy from a remote.'), | |||||
), | |||||
self::IO_MIRROR => array( | |||||
'icon' => 'fa-upload', | |||||
'color' => 'green', | |||||
'label' => pht('Mirror'), | |||||
'note' => pht( | |||||
'Phabricator will push a copy of any changes to this URI.'), | |||||
'short' => pht('Push a copy to a remote.'), | |||||
), | |||||
self::IO_NONE => array( | |||||
'icon' => 'fa-times', | |||||
'color' => 'grey', | |||||
'label' => pht('No I/O'), | |||||
'note' => pht( | |||||
'Phabricator will not push or pull any changes to this URI.'), | |||||
'short' => pht('Do not perform any I/O.'), | |||||
), | |||||
self::IO_READ => array( | |||||
'icon' => 'fa-folder', | |||||
'color' => 'blue', | |||||
'label' => pht('Read Only'), | |||||
'note' => pht( | |||||
'Phabricator will serve a read-only copy of the repository from '. | |||||
'this URI.'), | |||||
'short' => pht('Serve repository in read-only mode.'), | |||||
), | |||||
self::IO_READWRITE => array( | |||||
'icon' => 'fa-folder-open', | |||||
'color' => 'blue', | |||||
'label' => pht('Read/Write'), | |||||
'note' => pht( | |||||
'Phabricator will serve a read/write copy of the repository from '. | |||||
'this URI.'), | |||||
'short' => pht('Serve repository in read/write mode.'), | |||||
), | |||||
); | |||||
} | |||||
public static function getDisplayTypeMap() { | |||||
return array( | |||||
self::DISPLAY_DEFAULT => array( | |||||
'label' => pht('Default'), | |||||
'short' => pht('Use default behavior.'), | |||||
), | |||||
self::DISPLAY_ALWAYS => array( | |||||
'icon' => 'fa-eye', | |||||
'color' => 'green', | |||||
'label' => pht('Visible'), | |||||
'note' => pht('This URI will be shown to users as a clone URI.'), | |||||
'short' => pht('Show as a clone URI.'), | |||||
), | |||||
self::DISPLAY_NEVER => array( | |||||
'icon' => 'fa-eye-slash', | |||||
'color' => 'grey', | |||||
'label' => pht('Hidden'), | |||||
'note' => pht( | |||||
'This URI will be hidden from users.'), | |||||
'short' => pht('Do not show as a clone URI.'), | |||||
), | |||||
); | |||||
} | |||||
/* -( PhabricatorApplicationTransactionInterface )------------------------- */ | /* -( PhabricatorApplicationTransactionInterface )------------------------- */ | ||||
public function getApplicationTransactionEditor() { | public function getApplicationTransactionEditor() { | ||||
return new DiffusionURIEditor(); | return new DiffusionURIEditor(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines |