Merge remote-tracking branch 'upstream/4.4' into 4.4-4.5-2014-10-14-11-16-10
[civicrm-core.git] / CRM / Admin / Page / PdfFormats.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
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-2014
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
42 public $useLivePageJS = TRUE;
43
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 *
55 * @return string Classname of BAO.
56 */
57 function getBAOName() {
58 return 'CRM_Core_BAO_PdfFormat';
59 }
60
61 /**
62 * Get action Links
63 *
64 * @return array (reference) of action links
65 */
66 function &links() {
67 if (!(self::$_links)) {
68 // helper variable for nicer formatting
69 self::$_links = array(
70 CRM_Core_Action::UPDATE => array(
71 'name' => ts('Edit'),
72 'url' => 'civicrm/admin/pdfFormats',
73 'qs' => 'action=update&id=%%id%%&reset=1',
74 'title' => ts('Edit PDF Page Format'),
75 ),
76 CRM_Core_Action::DELETE => array(
77 'name' => ts('Delete'),
78 'url' => 'civicrm/admin/pdfFormats',
79 'qs' => 'action=delete&id=%%id%%',
80 'title' => ts('Delete PDF Page Format'),
81 ),
82 );
83 }
84
85 return self::$_links;
86 }
87
88 /**
89 * Get name of edit form
90 *
91 * @return string Classname of edit form.
92 */
93 function editForm() {
94 return 'CRM_Admin_Form_PdfFormats';
95 }
96
97 /**
98 * Get edit form name
99 *
100 * @return string name of this page.
101 */
102 function editName() {
103 return 'PDF Page Formats';
104 }
105
106 /**
107 * Get user context.
108 *
109 * @param null $mode
110 *
111 * @return string user context.
112 */
113 function userContext($mode = NULL) {
114 return 'civicrm/admin/pdfFormats';
115 }
116
117 /**
118 * Browse all PDF Page Formats
119 *
120 * @param null $action
121 *
122 * @return void
123 * @access public
124 * @static
125 */
126 function browse($action = NULL) {
127 // Get list of configured PDF Page Formats
128 $pdfFormatList = CRM_Core_BAO_PdfFormat::getList();
129
130 // Add action links to each of the PDF Page Formats
131 $action = array_sum(array_keys($this->links()));
132 foreach ($pdfFormatList as & $format) {
133 $format['action'] = CRM_Core_Action::formLink(
134 self::links(),
135 $action,
136 array('id' => $format['id']),
137 ts('more'),
138 FALSE,
139 'pdfFormat.manage.action',
140 'PdfFormat',
141 $format['id']
142 );
143 }
144
145 // Order Label Formats by weight
146 $returnURL = CRM_Utils_System::url(self::userContext());
147 CRM_Core_BAO_PdfFormat::addOrder($pdfFormatList, $returnURL);
148
149 $this->assign('rows', $pdfFormatList);
150 }
151 }
152