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