Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 TO |
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 | |
06b69b18 | 32 | * @copyright CiviCRM LLC (c) 2004-2014 |
6a488035 TO |
33 | * $Id$ |
34 | * | |
35 | */ | |
36 | ||
37 | /** | |
38 | * Page for displaying list of PDF Page Formats | |
39 | */ | |
40 | class CRM_Admin_Page_PdfFormats extends CRM_Core_Page_Basic { | |
41 | ||
96f50de2 CW |
42 | public $useLivePageJS = TRUE; |
43 | ||
6a488035 TO |
44 | /** |
45 | * The action links that we need to display for the browse screen | |
46 | * | |
47 | * @var array | |
48 | * @static | |
49 | */ | |
50 | static $_links = NULL; | |
51 | ||
52 | /** | |
53 | * Get BAO Name | |
54 | * | |
a6c01b45 CW |
55 | * @return string |
56 | * Classname of BAO. | |
6a488035 | 57 | */ |
00be9182 | 58 | public function getBAOName() { |
6a488035 TO |
59 | return 'CRM_Core_BAO_PdfFormat'; |
60 | } | |
61 | ||
62 | /** | |
63 | * Get action Links | |
64 | * | |
a6c01b45 CW |
65 | * @return array |
66 | * (reference) of action links | |
6a488035 | 67 | */ |
00be9182 | 68 | public function &links() { |
6a488035 TO |
69 | if (!(self::$_links)) { |
70 | // helper variable for nicer formatting | |
71 | self::$_links = array( | |
72 | CRM_Core_Action::UPDATE => array( | |
73 | 'name' => ts('Edit'), | |
74 | 'url' => 'civicrm/admin/pdfFormats', | |
75 | 'qs' => 'action=update&id=%%id%%&reset=1', | |
76 | 'title' => ts('Edit PDF Page Format'), | |
77 | ), | |
78 | CRM_Core_Action::DELETE => array( | |
79 | 'name' => ts('Delete'), | |
80 | 'url' => 'civicrm/admin/pdfFormats', | |
81 | 'qs' => 'action=delete&id=%%id%%', | |
82 | 'title' => ts('Delete PDF Page Format'), | |
83 | ), | |
84 | ); | |
85 | } | |
86 | ||
87 | return self::$_links; | |
88 | } | |
89 | ||
90 | /** | |
91 | * Get name of edit form | |
92 | * | |
a6c01b45 CW |
93 | * @return string |
94 | * Classname of edit form. | |
6a488035 | 95 | */ |
00be9182 | 96 | public function editForm() { |
6a488035 TO |
97 | return 'CRM_Admin_Form_PdfFormats'; |
98 | } | |
99 | ||
100 | /** | |
101 | * Get edit form name | |
102 | * | |
a6c01b45 CW |
103 | * @return string |
104 | * name of this page. | |
6a488035 | 105 | */ |
00be9182 | 106 | public function editName() { |
6a488035 TO |
107 | return 'PDF Page Formats'; |
108 | } | |
109 | ||
110 | /** | |
111 | * Get user context. | |
112 | * | |
dd244018 EM |
113 | * @param null $mode |
114 | * | |
a6c01b45 CW |
115 | * @return string |
116 | * user context. | |
6a488035 | 117 | */ |
00be9182 | 118 | public function userContext($mode = NULL) { |
6a488035 TO |
119 | return 'civicrm/admin/pdfFormats'; |
120 | } | |
121 | ||
122 | /** | |
123 | * Browse all PDF Page Formats | |
124 | * | |
dd244018 EM |
125 | * @param null $action |
126 | * | |
6a488035 | 127 | * @return void |
6a488035 TO |
128 | * @static |
129 | */ | |
00be9182 | 130 | public function browse($action = NULL) { |
6a488035 TO |
131 | // Get list of configured PDF Page Formats |
132 | $pdfFormatList = CRM_Core_BAO_PdfFormat::getList(); | |
133 | ||
134 | // Add action links to each of the PDF Page Formats | |
135 | $action = array_sum(array_keys($this->links())); | |
136 | foreach ($pdfFormatList as & $format) { | |
87dab4a4 AH |
137 | $format['action'] = CRM_Core_Action::formLink( |
138 | self::links(), | |
139 | $action, | |
140 | array('id' => $format['id']), | |
141 | ts('more'), | |
142 | FALSE, | |
143 | 'pdfFormat.manage.action', | |
144 | 'PdfFormat', | |
145 | $format['id'] | |
146 | ); | |
6a488035 TO |
147 | } |
148 | ||
149 | // Order Label Formats by weight | |
150 | $returnURL = CRM_Utils_System::url(self::userContext()); | |
151 | CRM_Core_BAO_PdfFormat::addOrder($pdfFormatList, $returnURL); | |
152 | ||
153 | $this->assign('rows', $pdfFormatList); | |
154 | } | |
155 | } |