Import from SVN (r45945, r596)
[civicrm-core.git] / CRM / Admin / Page / PdfFormats.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright (C) 2011 Marty Wright |
7 | Licensed to CiviCRM under the Academic Free License version 3.0. |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
10 | |
11 | CiviCRM is free software; you can copy, modify, and distribute it |
12 | under the terms of the GNU Affero General Public License |
13 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | |
15 | CiviCRM is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. |
19 | |
20 | You should have received a copy of the GNU Affero General Public |
21 | License and the CiviCRM Licensing Exception along |
22 | with this program; if not, contact CiviCRM LLC |
23 | at info[AT]civicrm[DOT]org. If you have questions about the |
24 | GNU Affero General Public License or the licensing of CiviCRM, |
25 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
26 +--------------------------------------------------------------------+
27*/
28
29/**
30 *
31 * @package CRM
32 * @copyright CiviCRM LLC (c) 2004-2013
33 * $Id$
34 *
35 */
36
37/**
38 * Page for displaying list of PDF Page Formats
39 */
40class CRM_Admin_Page_PdfFormats extends CRM_Core_Page_Basic {
41
42 /**
43 * The action links that we need to display for the browse screen
44 *
45 * @var array
46 * @static
47 */
48 static $_links = NULL;
49
50 /**
51 * Get BAO Name
52 *
53 * @return string Classname of BAO.
54 */
55 function getBAOName() {
56 return 'CRM_Core_BAO_PdfFormat';
57 }
58
59 /**
60 * Get action Links
61 *
62 * @return array (reference) of action links
63 */
64 function &links() {
65 if (!(self::$_links)) {
66 // helper variable for nicer formatting
67 self::$_links = array(
68 CRM_Core_Action::UPDATE => array(
69 'name' => ts('Edit'),
70 'url' => 'civicrm/admin/pdfFormats',
71 'qs' => 'action=update&id=%%id%%&reset=1',
72 'title' => ts('Edit PDF Page Format'),
73 ),
74 CRM_Core_Action::DELETE => array(
75 'name' => ts('Delete'),
76 'url' => 'civicrm/admin/pdfFormats',
77 'qs' => 'action=delete&id=%%id%%',
78 'title' => ts('Delete PDF Page Format'),
79 ),
80 );
81 }
82
83 return self::$_links;
84 }
85
86 /**
87 * Get name of edit form
88 *
89 * @return string Classname of edit form.
90 */
91 function editForm() {
92 return 'CRM_Admin_Form_PdfFormats';
93 }
94
95 /**
96 * Get edit form name
97 *
98 * @return string name of this page.
99 */
100 function editName() {
101 return 'PDF Page Formats';
102 }
103
104 /**
105 * Get user context.
106 *
107 * @return string user context.
108 */
109 function userContext($mode = NULL) {
110 return 'civicrm/admin/pdfFormats';
111 }
112
113 /**
114 * Browse all PDF Page Formats
115 *
116 * @return void
117 * @access public
118 * @static
119 */
120 function browse($action = NULL) {
121 // Get list of configured PDF Page Formats
122 $pdfFormatList = CRM_Core_BAO_PdfFormat::getList();
123
124 // Add action links to each of the PDF Page Formats
125 $action = array_sum(array_keys($this->links()));
126 foreach ($pdfFormatList as & $format) {
127 $format['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $format['id']));
128 }
129
130 // Order Label Formats by weight
131 $returnURL = CRM_Utils_System::url(self::userContext());
132 CRM_Core_BAO_PdfFormat::addOrder($pdfFormatList, $returnURL);
133
134 $this->assign('rows', $pdfFormatList);
135 }
136}
137