コード例 #1
0
ファイル: Admin.php プロジェクト: burbuja/indefero
 public function usherServerConnections($request, $match)
 {
     $server = $match[1];
     if (!in_array($server, IDF_Scm_Monotone_Usher::getServerList())) {
         throw new Pluf_HTTP_Error404();
     }
     $title = sprintf(__('Open connections for "%s"'), $server);
     $connections = IDF_Scm_Monotone_Usher::getConnectionList($server);
     if (count($connections) == 0) {
         $request->user->setMessage(sprintf(__('no connections for server "%s"'), $server));
         $url = Pluf_HTTP_URL_urlForView('IDF_Views_Admin::usher');
         return new Pluf_HTTP_Response_Redirect($url);
     }
     return Pluf_Shortcuts_RenderToResponse('idf/gadmin/usher/connections.html', array('page_title' => $title, 'server' => $server, 'connections' => $connections), $request);
 }
コード例 #2
0
ファイル: Project.php プロジェクト: burbuja/indefero
 public function adminSource($request, $match)
 {
     $prj = $request->project;
     $title = sprintf(__('%s Source'), (string) $prj);
     $remote_svn = ($request->conf->getVal('scm') == 'svn' and strlen($request->conf->getVal('svn_remote_url')) > 0);
     $extra = array('conf' => $request->conf, 'remote_svn' => $remote_svn);
     if ($request->method == 'POST') {
         $form = new IDF_Form_SourceConf($request->POST, $extra);
         if ($form->isValid()) {
             foreach ($form->cleaned_data as $key => $val) {
                 $request->conf->setVal($key, $val);
             }
             $request->user->setMessage(__('The project source configuration  has been saved.'));
             $url = Pluf_HTTP_URL_urlForView('IDF_Views_Project::adminSource', array($prj->shortname));
             return new Pluf_HTTP_Response_Redirect($url);
         }
     } else {
         $params = array();
         foreach (array('svn_username', 'svn_password', 'webhook_url') as $key) {
             $_val = $request->conf->getVal($key, false);
             if ($_val !== false) {
                 $params[$key] = $_val;
             }
         }
         if (count($params) == 0) {
             $params = null;
             //Nothing in the db, so new form.
         }
         $form = new IDF_Form_SourceConf($params, $extra);
     }
     $scm = $request->conf->getVal('scm', 'git');
     $options = array('git' => __('git'), 'svn' => __('Subversion'), 'mercurial' => __('mercurial'), 'mtn' => __('monotone'));
     $repository_type = $options[$scm];
     return Pluf_Shortcuts_RenderToResponse('idf/admin/source.html', array('remote_svn' => $remote_svn, 'repository_access' => $prj->getRemoteAccessUrl(), 'repository_type' => $repository_type, 'repository_size' => $prj->getRepositorySize(), 'page_title' => $title, 'form' => $form, 'hookkey' => $prj->getPostCommitHookKey()), $request);
 }
コード例 #3
0
ファイル: Issue.php プロジェクト: Br3nda/indefero
 public function listLabel($request, $match)
 {
     $prj = $request->project;
     $tag = Pluf_Shortcuts_GetObjectOr404('IDF_Tag', $match[2]);
     $status = $match[3];
     if ($tag->project != $prj->id or !in_array($status, array('open', 'closed'))) {
         throw new Pluf_HTTP_Error404();
     }
     if ($status == 'open') {
         $title = sprintf(__('%1$s Issues with Label %2$s'), (string) $prj, (string) $tag);
     } else {
         $title = sprintf(__('%1$s Closed Issues with Label %2$s'), (string) $prj, (string) $tag);
     }
     // Get stats about the open/closed issues having this tag.
     $open = $prj->getIssueCountByStatus('open', $tag);
     $closed = $prj->getIssueCountByStatus('closed', $tag);
     // Paginator to paginate the issues
     $pag = new Pluf_Paginator(new IDF_Issue());
     $pag->model_view = 'join_tags';
     $pag->class = 'recent-issues';
     $pag->item_extra_props = array('project_m' => $prj, 'shortname' => $prj->shortname, 'current_user' => $request->user);
     $pag->summary = sprintf(__('This table shows the issues with label %s.'), (string) $tag);
     $otags = $prj->getTagIdsByStatus($status);
     if (count($otags) == 0) {
         $otags[] = 0;
     }
     $pag->forced_where = new Pluf_SQL('project=%s AND idf_tag_id=%s AND status IN (' . implode(', ', $otags) . ')', array($prj->id, $tag->id));
     $pag->action = array('IDF_Views_Issue::listLabel', array($prj->shortname, $tag->id, $status));
     $pag->sort_order = array('modif_dtime', 'ASC');
     // will be reverted
     $pag->sort_reverse_order = array('modif_dtime');
     $pag->sort_link_title = true;
     $pag->extra_classes = array('a-c', '', 'a-c', '');
     $list_display = array('id' => __('Id'), array('summary', 'IDF_Views_Issue_SummaryAndLabels', __('Summary')), array('status', 'IDF_Views_Issue_ShowStatus', __('Status')), array('modif_dtime', 'Pluf_Paginator_DateAgo', __('Last Updated')));
     $pag->configure($list_display, array(), array('id', 'status', 'modif_dtime'));
     $pag->items_per_page = 10;
     $pag->no_results_text = __('No issues were found.');
     $pag->setFromRequest($request);
     if ($open + $closed > 0) {
         $completion = sprintf('%01.0f%%', 100 * $closed / ((double) $open + $closed));
     } else {
         $completion = false;
     }
     return Pluf_Shortcuts_RenderToResponse('idf/issues/by-label.html', array('project' => $prj, 'completion' => $completion, 'page_title' => $title, 'open' => $open, 'label' => $tag, 'closed' => $closed, 'issues' => $pag), $request);
 }
コード例 #4
0
ファイル: Source.php プロジェクト: Br3nda/indefero
 /**
  * Should only be called through self::tree
  */
 public function viewFile($request, $match, $extra)
 {
     $title = sprintf(__('%1$s %2$s Source Tree'), (string) $request->project, $this->getScmType($request));
     $scm = IDF_Scm::get($request->project);
     $branches = $extra['branches'];
     $tags = $extra['tags'];
     $commit = $extra['commit'];
     $request_file = $extra['request_file'];
     $request_file_info = $extra['request_file_info'];
     $bc = self::makeBreadCrumb($request->project, $commit, $request_file_info->fullpath);
     $page_title = $bc . ' - ' . $title;
     $cobject = $scm->getCommit($commit);
     $in_branches = $scm->inBranches($commit, $request_file);
     $in_tags = $scm->inTags($commit, '');
     // try to find the previous level if it exists.
     $prev = explode('/', $request_file);
     $l = array_pop($prev);
     $previous = substr($request_file, 0, -strlen($l . ' '));
     $scmConf = $request->conf->getVal('scm', 'git');
     $props = $scm->getProperties($commit, $request_file);
     $content = self::highLight($extra['mime'], $scm->getFile($request_file_info));
     return Pluf_Shortcuts_RenderToResponse('idf/source/' . $scmConf . '/file.html', array('page_title' => $page_title, 'title' => $title, 'breadcrumb' => $bc, 'file' => $content, 'commit' => $commit, 'cobject' => $cobject, 'fullpath' => $request_file, 'efullpath' => IDF_Scm::smartEncode($request_file), 'base' => $request_file_info->file, 'prev' => $previous, 'tree_in' => $in_branches, 'branches' => $branches, 'tags' => $tags, 'tags_in' => $in_tags, 'props' => $props), $request);
 }
コード例 #5
0
ファイル: User.php プロジェクト: burbuja/indefero
 /**
  * Public profile of a user.
  */
 public function view($request, $match)
 {
     $sql = new Pluf_SQL('login=%s', array($match[1]));
     $users = Pluf::factory('Pluf_User')->getList(array('filter' => $sql->gen()));
     if (count($users) != 1 or !$users[0]->active) {
         throw new Pluf_HTTP_Error404();
     }
     $user = $users[0];
     $user_data = IDF_UserData::factory($user);
     return Pluf_Shortcuts_RenderToResponse('idf/user/public.html', array('page_title' => (string) $user, 'member' => $user, 'user_data' => $user_data), $request);
 }
コード例 #6
0
ファイル: Admin.php プロジェクト: Br3nda/indefero
 public function userCreate($request, $match)
 {
     $params = array('request' => $request);
     if ($request->method == 'POST') {
         $form = new IDF_Form_Admin_UserCreate($request->POST, $params);
         if ($form->isValid()) {
             $cuser = $form->save();
             $request->user->setMessage(sprintf(__('The user %s has been created.'), (string) $cuser));
             $url = Pluf_HTTP_URL_urlForView('IDF_Views_Admin::users');
             return new Pluf_HTTP_Response_Redirect($url);
         }
     } else {
         $form = new IDF_Form_Admin_UserCreate(null, $params);
     }
     $title = __('Add User');
     return Pluf_Shortcuts_RenderToResponse('idf/gadmin/users/create.html', array('page_title' => $title, 'form' => $form), $request);
 }
コード例 #7
0
ファイル: Views.php プロジェクト: burbuja/pluf
 /**
  * Delete an object (Part of the CRUD series).
  *
  * The minimal extra parameter is the model class name. The list
  * of extra parameters is:
  *
  * 'model' - Class name string, required.
  *
  * 'post_delete_redirect' - View to redirect after saving, required.
  *
  * 'id' - Index in the match to fin the id of the object to delete (1)
  * 
  * 'login_required' - Do we require login (false)
  *
  * 'template' - Template to use ('"model class"_confirm_delete.html')
  *
  * 'post_delete_redirect_keys' - Which keys of the model to pass to
  *                             the view (array())
  *
  * 'extra_context' - Array of key/values to be added to the
  *                   context (array())
  * 
  * @param Pluf_HTTP_Request Request object
  * @param array Match
  * @param array Extra parameters
  * @return Pluf_HTTP_Response Response object (can be a redirect)
  */
 public function deleteObject($request, $match, $p)
 {
     if (isset($p['login_required']) && true == $p['login_required']) {
         if ($request->user->isAnonymous()) {
             return new Pluf_HTTP_Response_RedirectToLogin($request);
         }
     }
     if (!isset($p['model'])) {
         throw new Exception('The model class was not provided in the parameters.');
     }
     // Set the default
     $id = isset($p['id']) ? $match[$p['id']] : $match[1];
     $model = $p['model'];
     $context = isset($p['extra_context']) ? $p['extra_context'] : array();
     $template = isset($p['template']) ? $p['template'] : strtolower($model) . '_confirm_delete.html';
     $post_delete_keys = isset($p['post_delete_redirect_keys']) ? $p['post_delete_redirect_keys'] : array();
     $object = Pluf_Shortcuts_GetObjectOr404($model, $id);
     if ($request->method == 'POST') {
         $object->delete();
         if (isset($p['post_delete_redirect'])) {
             $url = Pluf_HTTP_URL_urlForView($p['post_delete_redirect'], $post_delete_keys);
         } else {
             throw new Exception('No URL to redirect to from generic delete view.');
         }
         if (!$request->user->isAnonymous()) {
             $request->user->setMessage(sprintf(__('The %s was deleted successfully.'), $object->_a['verbose']));
         }
         return new Pluf_HTTP_Response_Redirect($url);
     }
     return Pluf_Shortcuts_RenderToResponse($template, array_merge($context, array('object' => $object)), $request);
 }
コード例 #8
0
ファイル: Views.php プロジェクト: burbuja/pluf
 public function funnel($request, $match)
 {
     $periods = array('yesterday' => __('Yesterday'), 'today' => __('Today'), '7days' => __('Last 7 days'), 'all' => __('All time'));
     $period = 'today';
     $nperiod = $periods[$period];
     if (isset($request->REQUEST['p']) and isset($periods[$request->REQUEST['p']])) {
         $period = $request->REQUEST['p'];
         $nperiod = $periods[$request->REQUEST['p']];
     }
     $props = Pluf_AB_Funnel::getFunnelProps($match[1], $period);
     $prop = null;
     if (isset($request->REQUEST['prop']) and in_array($request->REQUEST['prop'], array_keys($props))) {
         $prop = $request->REQUEST['prop'];
     }
     $stats = Pluf_AB_Funnel::getStats($match[1], $period, $prop);
     return Pluf_Shortcuts_RenderToResponse('pluf/ab/funnel.html', array('stats' => $stats, 'funnel' => $match[1], 'nperiod' => $nperiod, 'period' => $period, 'props' => $props, 'prop' => $prop), $request);
 }
コード例 #9
0
ファイル: Review.php プロジェクト: burbuja/indefero
 public function view($request, $match)
 {
     $prj = $request->project;
     $review = Pluf_Shortcuts_GetObjectOr404('IDF_Review', $match[2]);
     $prj->inOr404($review);
     $url = Pluf_HTTP_URL_urlForView('IDF_Views_Review::view', array($prj->shortname, $review->id));
     $title = Pluf_Template::markSafe(sprintf(__('Review <a href="%s">%d</a>: %s'), $url, $review->id, $review->summary));
     $patches = $review->get_patches_list();
     $patch = $patches[0];
     $diff = new IDF_Diff(file_get_contents(Pluf::f('upload_issue_path') . '/' . $patch->patch));
     $diff->parse();
     // The form to submit comments is based on the files in the
     // diff
     if ($request->method == 'POST' and !$request->user->isAnonymous()) {
         $form = new IDF_Form_ReviewFileComment($request->POST, array('files' => $diff->files, 'user' => $request->user, 'patch' => $patch, 'project' => $prj));
         if ($form->isValid()) {
             $review_comment = $form->save();
             $review = $patch->get_review();
             $urlr = Pluf_HTTP_URL_urlForView('IDF_Views_Review::view', array($prj->shortname, $review->id));
             $request->user->setMessage(sprintf(__('Your <a href="%s">code review %d</a> has been published.'), $urlr, $review->id));
             $url = Pluf_HTTP_URL_urlForView('IDF_Views_Review::index', array($prj->shortname));
             $review_comment->notify($request->conf);
             return new Pluf_HTTP_Response_Redirect($url);
         }
     } else {
         $form = new IDF_Form_ReviewFileComment(null, array('files' => $diff->files, 'user' => $request->user, 'project' => $prj, 'patch' => $patch));
     }
     $scm = IDF_Scm::get($request->project);
     $files = array();
     $reviewers = array();
     foreach ($diff->files as $filename => $def) {
         $fileinfo = $scm->getPathInfo($filename, $patch->get_commit()->scm_id);
         $sql = new Pluf_SQL('cfile=%s', array($filename));
         $cts = $patch->getFileComments(array('filter' => $sql->gen(), 'order' => 'creation_dtime ASC'));
         foreach ($cts as $ct) {
             $reviewers[] = $ct->get_comment()->get_submitter();
         }
         if (count($def['chunks'])) {
             $orig_file = $fileinfo ? $scm->getFile($fileinfo) : '';
             $files[$filename] = array($diff->fileCompare($orig_file, $def, $filename), $form->f->{md5($filename)}, $cts);
         } else {
             $files[$filename] = array('', $form->f->{md5($filename)}, $cts);
         }
     }
     $reviewers = Pluf_Model_RemoveDuplicates($reviewers);
     return Pluf_Shortcuts_RenderToResponse('idf/review/view.html', array_merge(array('page_title' => $title, 'review' => $review, 'files' => $files, 'diff' => $diff, 'patch' => $patch, 'comments' => $patch->get_comments_list(array('sort' => 'id ASC')), 'form' => $form, 'reviewers' => $reviewers), IDF_Views_Issue::autoCompleteArrays($prj)), $request);
 }
コード例 #10
0
ファイル: Download.php プロジェクト: burbuja/indefero
 public function listLabel($request, $match)
 {
     $prj = $request->project;
     $tag = Pluf_Shortcuts_GetObjectOr404('IDF_Tag', $match[2]);
     $prj->inOr404($tag);
     $title = sprintf(__('%1$s Downloads with Label %2$s'), (string) $prj, (string) $tag);
     // Paginator to paginate the downloads
     $ptags = self::getDownloadTags($prj);
     $dtag = array_pop($ptags);
     // The last tag is the deprecated tag.
     $pag = new Pluf_Paginator(new IDF_Upload());
     $pag->model_view = 'join_tags';
     $pag->class = 'recent-issues';
     $pag->item_extra_props = array('project_m' => $prj, 'shortname' => $prj->shortname);
     $pag->summary = sprintf(__('This table shows the downloads with label %s.'), (string) $tag);
     $pag->forced_where = new Pluf_SQL('project=%s AND idf_tag_id=%s', array($prj->id, $tag->id));
     $pag->action = array('IDF_Views_Download::listLabel', array($prj->shortname, $tag->id));
     $pag->edit_action = array('IDF_Views_Download::view', 'shortname', 'id');
     $list_display = array('file' => __('File'), array('summary', 'IDF_Views_Download_SummaryAndLabels', __('Summary')), array('filesize', 'IDF_Views_Download_Size', __('Size')), array('creation_dtime', 'Pluf_Paginator_DateYMD', __('Uploaded')));
     $pag->configure($list_display, array(), array('file', 'filesize', 'creation_dtime'));
     $pag->items_per_page = 10;
     $pag->no_results_text = __('No downloads were found.');
     $pag->sort_order = array('creation_dtime', 'DESC');
     $pag->setFromRequest($request);
     $tags = $prj->getTagCloud('downloads');
     return Pluf_Shortcuts_RenderToResponse('idf/downloads/index.html', array('page_title' => $title, 'label' => $tag, 'downloads' => $pag, 'tags' => $tags, 'dlabel' => $dtag), $request);
 }
コード例 #11
0
ファイル: Views.php プロジェクト: burbuja/pluf
 /**
  * Display the addList page of the application.
  *
  * @param Pluf_HTTP_Request Request object
  * @param array Matches against the regex of the dispatcher
  * @return Pluf_HTTP_Response or can throw Exception
  */
 public function addList($request, $match)
 {
     // The workflow of the addition of an item is simple
     // If the request of GET method a form is displayed
     // If it is a POST method, the form is submitted and the
     // content is proceeded to create the new list.
     // We create a Todo_List item as we are creating one here
     $list = new Todo_List();
     if ($request->method == 'POST') {
         // We create the form bounded to the data submitted.
         $form = new Todo_Form_List($request->POST);
         if ($form->isValid()) {
             // If no errors, we can save the Todo_List from the data
             $list->setFromFormData($form->cleaned_data);
             $list->create();
             // We redirect the user to the page of the Todo_List
             $url = Pluf_HTTP_URL_urlForView('Todo_Views::viewList', array($list->id));
             return new Pluf_HTTP_Response_Redirect($url);
         }
     } else {
         $form = new Todo_Form_List();
     }
     return Pluf_Shortcuts_RenderToResponse('todo/list/add.html', array('page_title' => 'Add a Todo List', 'form' => $form));
 }
コード例 #12
0
ファイル: Views.php プロジェクト: Br3nda/indefero
 /**
  * API FAQ.
  */
 public function faqApi($request, $match)
 {
     $title = __('InDefero API (Application Programming Interface)');
     $projects = self::getProjects($request->user);
     return Pluf_Shortcuts_RenderToResponse('idf/faq-api.html', array('page_title' => $title, 'projects' => $projects), $request);
 }
コード例 #13
0
ファイル: Wiki.php プロジェクト: burbuja/indefero
 public function delete($request, $match)
 {
     $prj = $request->project;
     $page = Pluf_Shortcuts_GetObjectOr404('IDF_WikiPage', $match[2]);
     $prj->inOr404($page);
     $params = array('page' => $page);
     if ($request->method == 'POST') {
         $form = new IDF_Form_WikiDelete($request->POST, $params);
         if ($form->isValid()) {
             $form->save();
             $request->user->setMessage(__('The documentation page has been deleted.'));
             $url = Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::index', array($prj->shortname));
             return new Pluf_HTTP_Response_Redirect($url);
         }
     } else {
         $form = new IDF_Form_WikiDelete(null, $params);
     }
     $title = sprintf(__('Delete Page %s'), $page->title);
     $revision = $page->get_current_revision();
     $false = Pluf_DB_BooleanToDb(false, $page->getDbConnection());
     $revs = $page->get_revisions_list(array('order' => 'creation_dtime DESC', 'filter' => 'is_head=' . $false));
     return Pluf_Shortcuts_RenderToResponse('idf/wiki/deletepage.html', array('page_title' => $title, 'page' => $page, 'form' => $form, 'rev' => $revision, 'revs' => $revs, 'tags' => $page->get_tags_list()), $request);
 }