+ if (!is_numeric($remainder)) {
+ return false;
+ }
+ try {
+ $repo = new Repository();
+ $repo->loadById($remainder);
+ } catch (\Exception $e) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Convert an array of git urls to local URLs if possible and serialize them
+ * into a simple array.
+ *
+ * @param array $arGitUrls Array of array of urls. Main key is the title of
+ * the URL array.
+ *
+ * @return array Key is the git clone URL, value the title of the remote
+ */
+ protected function localizeGitUrls($arGitUrls)
+ {
+ $pub = $pri = null;
+ if (isset($GLOBALS['phorkie']['cfg']['git']['public'])) {
+ $pub = $GLOBALS['phorkie']['cfg']['git']['public'];
+ }
+ if (isset($GLOBALS['phorkie']['cfg']['git']['private'])) {
+ $pri = $GLOBALS['phorkie']['cfg']['git']['private'];
+ }
+
+ $arRemoteCloneUrls = array();
+ foreach ($arGitUrls as $remoteTitle => $arUrls) {
+ foreach ($arUrls as $remoteCloneUrl) {
+ if ($pub !== null
+ && substr($remoteCloneUrl, 0, strlen($pub)) == $pub
+ && substr($remoteCloneUrl, -4) == '.git'
+ ) {
+ $id = substr($remoteCloneUrl, strlen($pub), -4);
+ $repo = new Repository();
+ try {
+ $repo->loadById($id);
+ $arRemoteCloneUrls[$repo->gitDir] = $remoteTitle;
+ } catch (Exception $e) {
+ }
+ } else if ($pri !== null
+ && substr($remoteCloneUrl, 0, strlen($pri)) == $pri
+ && substr($remoteCloneUrl, -4) == '.git'
+ ) {
+ $id = substr($remoteCloneUrl, strlen($pri), -4);
+ $repo = new Repository();
+ try {
+ $repo->loadById($id);
+ $arRemoteCloneUrls[$repo->gitDir] = $remoteTitle;
+ } catch (Exception $e) {
+ }
+ } else {
+ $arRemoteCloneUrls[$remoteCloneUrl] = $remoteTitle;
+ }
+ }
+ }
+ return $arRemoteCloneUrls;