Beispiel #1
0
 public function downloadXmlAction()
 {
     $name = $this->_getParam('name');
     $identity = Zend_Auth::getInstance()->getIdentity();
     $obj = new Iati_Core_Xml();
     if ($name == 'Activity') {
         $wepModel = new Model_Wep();
         $activities = $wepModel->listAll('iati_activities', 'account_id', $identity->account_id);
         $activities_id = $activities[0]['id'];
         $activityArray = $wepModel->listAll('iati_activity', 'activities_id', $activities_id);
         $index = 0;
         foreach ($activityArray as $key => $activity) {
             $activity_array[$index] = $activity['id'];
             $index++;
         }
         $xmlOutput = $obj->generateXml($name, $activity_array);
         $filename = 'iati_activity';
     } elseif ($name == 'Organisation') {
         $organisationModelObj = new Model_Organisation();
         $organisationId = $organisationModelObj->checkOrganisationPresent($identity->account_id);
         $organisationIds = explode(',', $organisationId);
         $xmlOutput = $obj->generateXml($name, $organisationIds);
         $filename = 'iati_organisation_data';
     } else {
         exit('Invalid name for download.');
     }
     header('Content-Type: text/xml');
     header('Content-Disposition: attachment;filename=' . $filename . '.xml');
     echo $xmlOutput;
     exit;
 }
Beispiel #2
0
 /**
  * 
  * Creates xml file using Iati_Core_Xml and saves them to local directory.
  * @param Array $activities	Array of activities to be published.
  */
 public function saveActivityXml($activitiesIdArray)
 {
     $file = strtolower($this->publisherId);
     if ($this->segmented) {
         $file .= "-" . strtolower($this->recipient);
     } else {
         $file .= "-activities";
     }
     $file = preg_replace('/ /', '_', $file);
     $file = preg_replace('/,/', '', $file);
     $fileName = $file . ".xml";
     $obj = new Iati_Core_Xml();
     $fp = fopen($this->filePath . $fileName, 'w');
     fwrite($fp, $obj->generateXml('Activity', $activitiesIdArray));
     fclose($fp);
     return $fileName;
 }