/** * Dumps content elements */ public function writeContent($packages) { $this->startElement('data'); foreach ($packages as $package) { $mvc = midgardmvc_core::get_instance(); $this->startElement('content'); $this->writeAttribute('details', 'full'); $this->writeElement('id', $package->packageid); $this->writeElement('name', $package->packagetitle); $this->writeElement('version', $package->packageversion); $this->writeElement('description', $package->packagedescription); $this->writeElement('summary', $package->packagesummary); $this->writeElement('homepage', $package->packagehomepageurl); $this->writeElement('created', $package->packagecreated); $this->writeElement('changed', $package->packagerevised); $this->writeElement('score', 20 * $package->statscachedratingvalue); $this->writeElement('x-filename', $package->packagefilename); $this->writeElement('x-license', $package->packagelicense); $this->writeElement('x-arch', $package->repoarch); $this->writeElement('x-project', $package->repoprojectname); $this->writeElement('x-repository', $package->reponame); $this->writeElement('x-os', $package->repoos); $this->writeElement('x-osversion', $package->repoosversion); $this->writeElement('x-ux', $package->repoosux); $this->writeElement('x-licenseid', $package->packagelicenseid); $this->writeElement('x-distributionid', $package->repoosversionid); $this->writeElement('x-dependencyid', $package->repoosuxid); $this->writeElement('x-obsname', $package->packageparent); if (isset($package->roles)) { $this->writeElement('x-roles', $package->roles); } if (isset($package->history)) { $this->writeElement('x-history', $package->history); } $user = com_meego_ocs_utils::get_current_user(); if ($user) { if (com_meego_ocs_utils::user_has_voted($package->packageid, $user->person)) { $this->writeElement('x-rated', 'true'); } else { $this->writeElement('x-rated', 'false'); } } if (isset($package->testing) && $package->testing) { $this->writeElement('x-testing', true); $this->writeElement('x-qa-score', $package->packagescore); if (isset($package->qa)) { $this->writeElement('x-qa', $package->qa); } } $dispatcher = midgardmvc_core::get_instance()->dispatcher; $counter = 0; $_downloadurl = ''; //$package->packageinstallfileurl; foreach ($package->attachments as $attachment) { // check if attachment is YMP (ie. 1 click install file) if ($attachment->mimetype == "text/x-suse-ymp" && !strlen($_downloadurl)) { $_downloadurl = com_meego_ocs_controllers_providers::generate_url($dispatcher->generate_url('attachmentserver_variant', array('guid' => $attachment->guid, 'variant' => '', 'filename' => $attachment->name), '/')); } // check if attachment MIME type is image something if ($attachment->mimetype == "image/png") { $_icon_marker = 'icon.png'; $_screenshot_marker = 'screenshot.png'; // check if the name is *screenshot.png if (strrpos($attachment->name, $_screenshot_marker) !== false) { $counter++; $_screenshoturl = com_meego_ocs_controllers_providers::generate_url($dispatcher->generate_url('attachmentserver_variant', array('guid' => $attachment->guid, 'variant' => 'prop480x300', 'filename' => $attachment->name), '/')); $_smallscreenshoturl = com_meego_ocs_controllers_providers::generate_url($dispatcher->generate_url('attachmentserver_variant', array('guid' => $attachment->guid, 'variant' => 'thumbnail', 'filename' => $attachment->name), '/')); $this->writeElement('previewpic' . $counter, $_screenshoturl); $this->writeElement('smallpreviewpic' . $counter, $_smallscreenshoturl); #if ($counter == 3) #{ # break; #} } // check if the name is *icon.png and generate <icon> elements if (strrpos($attachment->name, $_icon_marker) !== false) { $_iconurl = com_meego_ocs_controllers_providers::generate_url($dispatcher->generate_url('attachmentserver_variant', array('guid' => $attachment->guid, 'variant' => 'icon', 'filename' => $attachment->name), '/')); $iconwidth = $mvc->configuration->attachmentserver_variants['icon']['croppedThumbnail']['width']; $iconheight = $mvc->configuration->attachmentserver_variants['icon']['croppedThumbnail']['height']; $this->startElement('icon'); $this->writeAttribute('width', $iconwidth); $this->writeAttribute('height', $iconheight); $this->text($_iconurl); $this->endElement(); } } } $this->writeElement('comments', $package->comments_count); if (isset($package->commentsurl)) { $this->writeElement('commentspage', $package->commentsurl); } $this->writeElement('downloadname1', $package->packagename); $this->writeElement('downloadlink1', $_downloadurl); $this->endElement(); //content } $this->endElement(); // data }
public function __construct(midgardmvc_core_request $request) { $this->request = $request; $this->user = com_meego_ocs_utils::get_current_user(); $this->mvc = midgardmvc_core::get_instance(); }