public function executeList() { $rss = $this->getRequestParameter('rss'); $object = $this->getRequestParameter('object'); $output = ''; $title = Tools::get('name'); $link = Tools::get('url'); $description = Tools::get('rss_desc'); $offset = $this->getRequestParameter('offset'); $limit = $this->getRequestParameter('limit'); if ($object == 'application') { $title .= ' - Applications'; $user_id = $this->getRequestParameter('user_id'); if ($this->getRequestParameter('user_name')) { $user_id = User::getByName($this->getRequestParameter('user_name'))->getId(); } $q = new Doctrine_Query(); $q = $q->select('a.*')->from('Application a'); if ($user_id) { $q = $q->addWhere('user_id = ?', array($user_id)); } $q = $q->addWhere('approved = ?', array(true)); $q = $q->orderby('updated_at desc'); if ($limit) { $q->limit($limit); } if ($offset) { $q->offset($offset); } $applications = $q->execute(); if (!$rss) { $output .= '<applications count="' . $applications->count() . '">'; } foreach ($applications as $application) { $output .= $application->getXML($rss); } if (!$rss) { $output .= '</applications>'; } } elseif ($object == 'comment') { $title .= ' - Comments'; $user_id = $this->getRequestParameter('user_id'); if ($this->getRequestParameter('user_name')) { $user_id = User::getByName($this->getRequestParameter('user_name'))->getId(); } $application_id = $this->getRequestParameter('application_id'); $module_id = $this->getRequestParameter('module_id'); $theme_id = $this->getRequestParameter('theme_id'); $q = new Doctrine_Query(); $q = $q->select('c.*')->from('Comment c'); if ($user_id) { $q = $q->addWhere('user_id = ?', array($user_id)); } if ($application_id) { $q = $q->addWhere('application_id = ?', array($application_id)); } if ($module_id) { $q = $q->addWhere('madule_id = ?', array($module_id)); } if ($theme_id) { $q = $q->addWhere('theme_id = ?', array($theme_id)); } $q = $q->orderby('updated_at desc'); if ($limit) { $q->limit($limit); } if ($offset) { $q->offset($offset); } $comments = $q->execute(); if (!$rss) { $output .= '<comments count="' . $comments->count() . '">'; } foreach ($comments as $comment) { $output .= $comment->getXML($rss); } if (!$rss) { $output .= '</comments>'; } } elseif ($object == 'module') { $title .= ' - Modules'; $application_id = $this->getRequestParameter('application_id'); $user_id = $this->getRequestParameter('user_id'); if ($this->getRequestParameter('user_name')) { $user_id = User::getByName($this->getRequestParameter('user_name'))->getId(); } $q = new Doctrine_Query(); $q = $q->select('m.*')->from('Madule m'); if ($application_id) { $q = $q->addWhere('application_id = ?', array($application_id)); } if ($user_id) { $q = $q->addWhere('user_id = ?', array($user_id)); } $q = $q->addWhere('approved = ?', array(true)); $q = $q->orderby('updated_at desc'); if ($limit) { $q->limit($limit); } if ($offset) { $q->offset($offset); } $modules = $q->execute(); if (!$rss) { $output .= '<modules count="' . $modules->count() . '">'; } foreach ($modules as $module) { $output .= $module->getXML($rss); } if (!$rss) { $output .= '</modules>'; } } elseif ($object == 'theme') { $title .= ' - Themes'; $user_id = $this->getRequestParameter('user_id'); if ($this->getRequestParameter('user_name')) { $user_id = User::getByName($this->getRequestParameter('user_name'))->getId(); } $theme_group_id = $this->getRequestParameter('theme_group_id'); if ($this->getRequestParameter('theme_group_title')) { $theme_group_id = ThemeGroup::getByTitle($this->getRequestParameter('theme_group_title'))->getId(); } if ($this->getRequestParameter('theme_group_name')) { $theme_group_id = ThemeGroup::getByName($this->getRequestParameter('theme_group_name'))->getId(); } $application_id = $this->getRequestParameter('application_id'); $module_id = $this->getRequestParameter('module_id'); $q = new Doctrine_Query(); $q = $q->select('t.*')->from('Theme t'); if ($application_id) { $q = $q->addWhere('t.id IN (SELECT ttg.theme_id from ThemeThemeGroup ttg where ttg.theme_group_id IN ' . '(SELECT ag.theme_group_id FROM ApplicationThemeGroup ag where ag.application_id = ?))', array($application_id)); } elseif ($module_id) { $q = $q->addWhere('t.id IN (SELECT ttg.theme_id from ThemeThemeGroup ttg where ttg.theme_group_id IN ' . '(SELECT mg.theme_group_id FROM MaduleThemeGroup mg where mg.madule_id = ?))', array($module_id)); } elseif ($theme_group_id) { $q = $q->innerJoin('t.ThemeThemeGroups ttg')->addWhere('ttg.theme_group_id = ?', array($theme_group_id)); } if ($user_id) { $q = $q->addWhere('user_id = ?', array($user_id)); } $q = $q->addWhere('approved = ?', array(true)); $q = $q->orderby('updated_at desc'); if ($limit) { $q->limit($limit); } if ($offset) { $q->offset($offset); } $themes = $q->execute(); if (!$rss) { $output .= '<themes count="' . $themes->count() . '">'; } foreach ($themes as $theme) { $output .= $theme->getXML($rss); } if (!$rss) { $output .= '</themes>'; } } elseif ($object == 'theme_group') { $title .= ' - Theme Groups'; $theme_id = $this->getRequestParameter('theme_id'); $q = new Doctrine_Query(); $q = $q->select('t.*')->from('ThemeGroup t'); if ($theme_id) { $q = $q->innerJoin('t.ThemeThemeGroups ttg')->addWhere('ttg.theme_id = ? and t.known = ?', array($theme_id, true)); } $q = $q->orderby('updated_at desc'); if ($limit) { $q->limit($limit); } if ($offset) { $q->offset($offset); } $themeGroups = $q->execute(); if (!$rss) { $output .= '<theme_groups count="' . $themeGroups->count() . '">'; } foreach ($themeGroups as $themeGroup) { $output .= $themeGroup->getXML($rss); } if (!$rss) { $output .= '</theme_groups>'; } } elseif ($object == 'user') { $title .= ' - Users'; $q = new Doctrine_Query(); $q = $q->select('u.*')->from('User u')->orderby('updated_at desc'); if ($limit) { $q->limit($limit); } if ($offset) { $q->offset($offset); } $users = $q->execute(); if (!$rss) { $output .= '<users count="' . $users->count() . '">'; } foreach ($users as $user) { $output .= $user->getXML($rss); } if (!$rss) { $output .= '</users>'; } } if ($rss) { $this->output = '<rss version="2.0">' . '<channel>' . '<title>' . $title . '</title>' . '<link>' . $link . '</link>' . '<description>' . $description . '</description>' . '<generator>' . $title . '</generator>' . $output . '</channel>' . '</rss>'; } else { $this->output = '<rsp stat="ok">' . $output . '</rsp>'; } $this->setTemplate('index'); }