function updateJson() { $extensionData = ExtensionData::get(); $count = 0; if ($extensionData && !empty($extensionData)) { $count = 0; foreach ($extensionData as $extension) { // Include only Approved extensions if ($extension->Accepted == '1') { $json = new JsonHandler($extension->Url); $jsonData = $json->cloneJson(); $updateJson = $json->UpdateJson(); if (array_key_exists('ExtensionID', $updateJson)) { $id = $updateJson['ExtensionID']; $deleteVersion = $json->deleteVersionData($id); if ($deleteVersion) { $saveVersion = $json->saveVersionData($id); if ($saveVersion) { echo "<br>{$extension->Name} is updated <br>"; } } } else { throw new InvalidArgumentException("{$extension->Name} could not updated <br />"); } $count++; } } echo "<br><br><strong>{$count} Repositories processed...</strong><br>"; } else { throw new InvalidArgumentException('No Extension found...'); } }
/** * The form handler. */ public function submitUrl($data, $form) { $url = $data['Url']; if (empty($url)) { $form->sessionMessage(_t('ExtensionHolderPage.BADURL', 'Please enter URL'), 'bad'); return $this->redirectBack(); } elseif (substr($url, 0, 4) != "http" && substr($url, 0, 3) != "git") { $form->sessionMessage(_t('ExtensionHolderPage.BADURL', "Please enter valid 'HTTP' or 'GIT Read-only' URL "), 'bad'); return $this->redirectBack(); } elseif (substr($url, 0, 4) == "git@") { $form->sessionMessage(_t('ExtensionHolderPage.BADURL', "'SSH' URL is not allowed, Please enter valid 'HTTP' or 'GIT Read-only' URL"), 'bad'); return $this->redirectBack(); } $json = new JsonHandler($url); $jsonData = $json->cloneJson(); if (!array_key_exists('ErrorMsg', $jsonData)) { $this->latestReleasePackage = $jsonData['LatestRelease']; if ($this->isNewExtension($url)) { $saveJson = $json->saveJson(); if (!array_key_exists('ErrorMsg', $saveJson)) { $id = $saveJson['ExtensionID']; $saveVersion = $json->saveVersionData($id); if ($saveVersion) { $this->extensionType = ExtensionData::get()->byID($id)->Type; $this->extensionName = ExtensionData::get()->byID($id)->Name; $this->mailData = array('ExtensionType' => $this->extensionType, 'ExtensionName' => $this->extensionName, 'SubmittedByName' => Member::currentUser()->Name, 'SubmittedByEmail' => Member::currentUser()->Email, 'ReviewAtUrl' => Director::absoluteBaseURL() . 'admin/extensions/ExtensionData/EditForm/field/ExtensionData/item/' . $id . '/edit', 'DetailPageLink' => Director::absoluteBaseURL() . strtolower($this->extensionType) . '/show/' . $id, 'Subject' => 'New ' . $this->extensionType . " '" . $this->extensionName . "' " . ' Submitted'); $this->sendMailtoAdmin(); $form->sessionMessage(_t('ExtensionHolderPage.THANKSFORSUBMITTING', 'Thank you for submitting "' . $this->extensionName . '" ' . $this->extensionType), 'good'); return $this->redirectBack(); } } else { $form->sessionMessage(_t('ExtensionHolderPage.PROBLEMINSAVING', "We are unable to save Extension info, the parser reports: {$saveJson['ErrorMsg']} Please Re-check format of you composer.json file."), 'bad'); return $this->redirectBack(); } } else { $updateJson = $json->updateJson(); if (!array_key_exists('ErrorMsg', $updateJson)) { $id = $updateJson['ExtensionID']; $deleteVersion = $json->deleteVersionData($id); if ($deleteVersion) { $saveVersion = $json->saveVersionData($id); if ($saveVersion) { $this->extensionType = ExtensionData::get()->byID($id)->Type; $this->extensionName = ExtensionData::get()->byID($id)->Name; $this->mailData = array('ExtensionType' => $this->extensionType, 'ExtensionName' => $this->extensionName, 'SubmittedByName' => Member::currentUser()->Name, 'SubmittedByEmail' => Member::currentUser()->Email, 'ReviewAtUrl' => Director::absoluteBaseURL() . 'admin/extensions/ExtensionData/EditForm/field/ExtensionData/item/' . $id . '/edit', 'DetailPageLink' => Director::absoluteBaseURL() . strtolower($this->extensionType) . '/show/' . $id, 'Subject' => $this->extensionType . " '" . $this->extensionName . "' " . ' Updated'); $this->sendMailtoAdmin(); $form->sessionMessage(_t('ExtensionHolderPageExtensionHolderPage.THANKSFORUPDATING', 'Thank you for Updating your "' . $this->extensionName . '" ' . $this->extensionType), 'good'); return $this->redirectBack(); } } else { $form->sessionMessage(_t('ExtensionHolderPage.PROBLEMINSAVING', 'Something went wrong we are not able to save versions of submitted extension '), 'bad'); return $this->redirectBack(); } } else { $form->sessionMessage(_t('ExtensionHolderPage.PROBLEMINUPDATING', "We had problems parsing your composer.json file, the parser reports: {$updateJson['ErrorMsg']} Please read our extension Submission Guide for more details and submit url again"), 'bad'); return $this->redirectBack(); } } } else { $form->sessionMessage(_t('ExtensionHolderPage.NOJSON', "We had problems parsing your composer.json file, the parser reports: {$jsonData['ErrorMsg']} Please read our extension Submission Guide for more details and submit url again"), 'bad'); return $this->redirectBack(); } }