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 Label Formats | |
39 | */ | |
40 | class CRM_Admin_Page_LabelFormats 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_LabelFormat'; |
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/labelFormats', | |
eaf5045f | 75 | 'qs' => 'action=update&id=%%id%%&group=%%group%%&reset=1', |
6a488035 TO |
76 | 'title' => ts('Edit Label Format'), |
77 | ), | |
78 | CRM_Core_Action::COPY => array( | |
79 | 'name' => ts('Copy'), | |
80 | 'url' => 'civicrm/admin/labelFormats', | |
eaf5045f | 81 | 'qs' => 'action=copy&id=%%id%%&group=%%group%%&reset=1', |
6a488035 TO |
82 | 'title' => ts('Copy Label Format'), |
83 | ), | |
84 | CRM_Core_Action::DELETE => array( | |
85 | 'name' => ts('Delete'), | |
86 | 'url' => 'civicrm/admin/labelFormats', | |
eaf5045f | 87 | 'qs' => 'action=delete&id=%%id%%&group=%%group%%&reset=1', |
6a488035 TO |
88 | 'title' => ts('Delete Label Format'), |
89 | ), | |
90 | ); | |
91 | } | |
92 | ||
93 | return self::$_links; | |
94 | } | |
95 | ||
96 | /** | |
97 | * Get name of edit form | |
98 | * | |
a6c01b45 CW |
99 | * @return string |
100 | * Classname of edit form. | |
6a488035 | 101 | */ |
00be9182 | 102 | public function editForm() { |
6a488035 TO |
103 | return 'CRM_Admin_Form_LabelFormats'; |
104 | } | |
105 | ||
106 | /** | |
107 | * Get edit form name | |
108 | * | |
a6c01b45 CW |
109 | * @return string |
110 | * name of this page. | |
6a488035 | 111 | */ |
00be9182 | 112 | public function editName() { |
6a488035 TO |
113 | return 'Mailing Label Formats'; |
114 | } | |
115 | ||
116 | /** | |
117 | * Get user context. | |
118 | * | |
fd31fa4c EM |
119 | * @param null $mode |
120 | * | |
a6c01b45 CW |
121 | * @return string |
122 | * user context. | |
6a488035 | 123 | */ |
00be9182 | 124 | public function userContext($mode = NULL) { |
6a488035 TO |
125 | return 'civicrm/admin/labelFormats'; |
126 | } | |
127 | ||
128 | /** | |
129 | * Browse all Label Format settings. | |
130 | * | |
dd244018 EM |
131 | * @param null $action |
132 | * | |
6a488035 | 133 | * @return void |
6a488035 TO |
134 | * @static |
135 | */ | |
00be9182 | 136 | public function browse($action = NULL) { |
6a488035 | 137 | // Get list of configured Label Formats |
02fc859b TO |
138 | $labelFormatList = CRM_Core_BAO_LabelFormat::getList(); |
139 | $nameFormatList = CRM_Core_BAO_LabelFormat::getList(FALSE, 'name_badge'); | |
6a488035 TO |
140 | |
141 | // Add action links to each of the Label Formats | |
142 | foreach ($labelFormatList as & $format) { | |
143 | $action = array_sum(array_keys($this->links())); | |
a7488080 | 144 | if (!empty($format['is_reserved'])) { |
6a488035 TO |
145 | $action -= CRM_Core_Action::DELETE; |
146 | } | |
252708df KJ |
147 | |
148 | $format['groupName'] = ts('Mailing Label'); | |
eaf5045f | 149 | $format['action'] = CRM_Core_Action::formLink(self::links(), $action, |
87dab4a4 AH |
150 | array('id' => $format['id'], 'group' => 'label_format'), |
151 | ts('more'), | |
152 | FALSE, | |
153 | 'labelFormat.manage.action', | |
154 | 'LabelFormat', | |
155 | $format['id'] | |
156 | ); | |
6a488035 TO |
157 | } |
158 | ||
eaf5045f KJ |
159 | // Add action links to each of the Label Formats |
160 | foreach ($nameFormatList as & $format) { | |
252708df | 161 | $format['groupName'] = ts('Name Badge'); |
eaf5045f KJ |
162 | } |
163 | ||
164 | $labelFormatList = array_merge($labelFormatList, $nameFormatList); | |
165 | ||
6a488035 TO |
166 | // Order Label Formats by weight |
167 | $returnURL = CRM_Utils_System::url(self::userContext()); | |
168 | CRM_Core_BAO_LabelFormat::addOrder($labelFormatList, $returnURL); | |
169 | ||
170 | $this->assign('rows', $labelFormatList); | |
171 | } | |
172 | } |