コード例 #1
0
ファイル: Registry.php プロジェクト: relyd/aidstream
 /**
  *
  * Save the published info in local database.
  * @param $response			The actual response received for the registry.
  * @param Boolen $update	If true the response is saved as an insert operation,
  * 							if false it is saved as an update.
  */
 public function saveRegistryPublishInfo($response, $update = false)
 {
     //Activity
     if (!$this->organisation) {
         $model = new Model_RegistryPublishedData();
         if ($update) {
             $model->updateRegistryPublishInfo($this->file_id, $response);
         } else {
             $model->saveRegistryPublishInfo($this->file_id, $response);
         }
     } else {
         $organisationRegistryModel = new Model_OrganisationRegistryPublishedData();
         if ($update) {
             $organisationRegistryModel->updateRegistryPublishInfo($this->file_id, $response);
         } else {
             $organisationRegistryModel->saveRegistryPublishInfo($this->file_id, $response);
         }
     }
 }
コード例 #2
0
ファイル: AdminController.php プロジェクト: relyd/aidstream
 public function generatePublishedXmlFilesAction()
 {
     $this->_helper->viewRenderer->setNoRender(true);
     $this->_helper->layout()->disableLayout();
     $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
     $xmlPath = $config->public_folder . $config->xml_folder;
     $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><iati-publishers><!-- Generated By AidStream --></iati-publishers>');
     $registryPublishedModel = new Model_RegistryPublishedData();
     $organisationRegistryPublishedModel = new Model_OrganisationRegistryPublishedData();
     $accountModel = new User_Model_DbTable_Account();
     $organisationRegistryPublishedData = $organisationRegistryPublishedModel->getAllOrganisationRegistryPublishedData();
     $registryPublishedData = $registryPublishedModel->getAllRegistryPublishedData();
     // For Activity
     $index = 1;
     foreach ($registryPublishedData as $registryData) {
         $orgName = $accountModel->getOrganisationNameById($registryData->publisher_org_id);
         $orgName = preg_replace('/&/', '&amp;', $orgName);
         if ($index == 1) {
             $registry[$orgName]['publisherId'] = substr($registryData->filename, 0, strrpos($registryData->filename, '-'));
         }
         $registry[$orgName]['activity'][] = $registryData->filename;
     }
     // For Organisation Data
     foreach ($organisationRegistryPublishedData as $registryData) {
         $orgName = $accountModel->getOrganisationNameById($registryData->publisher_org_id);
         $orgName = preg_replace('/&/', '&amp;', $orgName);
         if ($index == 1) {
             $registry[$orgName]['publisherId'] = substr($registryData->filename, 0, strrpos($registryData->filename, '-'));
         }
         $registry[$orgName]['organisation'][] = $registryData->filename;
     }
     ksort($registry);
     foreach ($registry as $publisherName => $information) {
         $iatiPublisher = $xml->addChild('iati-publisher');
         $iatiPublisher->addChild('name', $publisherName);
         $iatiPublisher->addChild('registry-publisher-id', $information['publisherId']);
         $iatiFiles = $iatiPublisher->addChild('iati-files');
         if (isset($information['activity'])) {
             foreach ($information['activity'] as $iatiActivity) {
                 $fileUrl = 'http://aidstream.org/files/xml/' . trim($iatiActivity) . '.xml';
                 $iatiFile = $iatiFiles->addChild('iati-activity', $fileUrl);
             }
         }
         if (isset($information['organisation'])) {
             foreach ($information['organisation'] as $iatiOrganisation) {
                 $fileUrl = 'http://aidstream.org/files/xml/' . trim($iatiOrganisation) . '.xml';
                 $iatiFile = $iatiFiles->addChild('iati-organisation', $fileUrl);
             }
         }
     }
     $fileName = "published-files.xml";
     $fp = fopen($xmlPath . $fileName, 'w');
     fwrite($fp, $xml->asXML());
     fclose($fp);
     if (file_exists($xmlPath . $fileName)) {
         $this->_redirect('/files/xml/' . $fileName);
     }
 }