/** * @todo: docs */ public function get_search(array $args) { $this->data['search'] = ''; $query = $this->request->get_query(); if (isset($query['q']) && !empty($query['q'])) { $this->data['search'] = $query['q']; $this->data['packages'] = array(); $packages = $this->search_packages($query); if (count($packages) == 1) { $package = $packages[0]; // Relocate to package directly $this->mvc->head->relocate($this->mvc->dispatcher->generate_url('apps_by_name', array('os' => $package->repoos, 'version' => $package->repoosversion, 'ux' => $package->repoosux, 'basecategory' => self::determine_base_category($package), 'packagename' => $package->packagename), $this->request)); } else { if (count($packages) > 1) { foreach ($packages as $package) { if (isset($this->data['packages'][$package->packagename])) { continue; } $package->localurl = $this->mvc->dispatcher->generate_url('apps_by_name', array('os' => $package->repoos, 'version' => $package->repoosversion, 'ux' => $package->repoosux, 'basecategory' => self::determine_base_category($package), 'packagename' => $package->packagename), $this->request); $this->data['packages'][$package->packagename] = $package; } } } } $qb = com_meego_repository::new_query_builder(); //TODO: add constraints for arch or release. $this->data['repositories'] = $qb->execute(); }
/** * */ public function get_repository(array $args) { $qb = com_meego_repository::new_query_builder(); $qb->add_constraint('disabledownload', '=', false); if (isset($args['project'])) { $qbproject = com_meego_project::new_query_builder(); $qbproject->add_constraint('name', '=', $args['project']); $projects = $qbproject->execute(); if (count($projects)) { $qb->add_constraint('project', '=', $projects[0]->id); } $this->data['projectname'] = $args['project']; } if (isset($args['repository'])) { $qb->add_constraint('name', '=', $args['repository']); } if (isset($args['arch'])) { $qb->add_constraint('arch', '=', $args['arch']); } $repositories = $qb->execute(); if (count($repositories) == 0) { throw new midgardmvc_exception_notfound("Repository not found"); } $this->data['repository'] = $repositories[0]; $this->data['packages'] = array(); $storage = new midgard_query_storage('com_meego_package'); $q = new midgard_query_select($storage); $qc = new midgard_query_constraint(new midgard_query_property('repository', $storage), '=', new midgard_query_value($this->data['repository']->id)); $q->set_constraint($qc); $q->add_order(new midgard_query_property('name', $storage), SORT_ASC); $q->execute(); $packages = $q->list_objects(); // by default noone can manage workflows $this->request->set_data_item('manage_workflows', false); $cnt = 0; foreach ($packages as $package) { // by default there are no posted forms $package->posts = false; ++$cnt % 2 == 0 ? $package->rawclass = 'even' : ($package->rawclass = 'odd'); if (empty($package->title)) { $package->title = $package->name; } $package->localurl = $this->mvc->dispatcher->generate_url('package_instance', array('package' => $package->name, 'version' => $package->version, 'project' => $args['project'], 'repository' => $this->data['repository']->name, 'arch' => $this->data['repository']->arch), $this->request); // see if packages in this repo have forms submitted $storage = new midgard_query_storage('com_meego_package_forms_posted'); $q = new midgard_query_select($storage); $q->set_constraint(new midgard_query_constraint(new midgard_query_property('packageguid'), '=', new midgard_query_value($package->guid))); $q->execute(); // todo: what happens if a package has posts from many different // or workflows if ($q->get_results_count()) { $_url = $this->mvc->dispatcher->generate_url('package_posted_forms', array('package' => $package->guid), 'com_meego_packages'); $package->posts = $_url; } $this->data['packages'][] = $package; } $user = $this->mvc->authentication->get_user(); if ($user) { if ($user->is_admin()) { // admins can manage and create new workflows $this->request->set_data_item('manage_workflows', true); $this->request->set_data_item('create_form_url', $this->mvc->dispatcher->generate_url('form_create', array('parent' => $this->data['repository']->guid), 'midgardmvc_ui_forms')); } // get a list of forms $forms = null; $storage = new midgard_query_storage('midgardmvc_ui_forms_form'); $q = new midgard_query_select($storage); $q->set_constraint(new midgard_query_constraint(new midgard_query_property('parent'), '=', new midgard_query_value($this->data['repository']->guid))); $q->execute(); $items = $q->list_objects(); foreach ($items as $item) { $form = $item; $form->edit_url = $this->mvc->dispatcher->generate_url('form_update', array('form' => $item->guid), 'midgardmvc_ui_forms'); $forms[] = $form; } $this->request->set_data_item('forms', $forms); } }