Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
7e9e8871 | 4 | | CiviCRM version 4.7 | |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 27 | */ |
6a488035 TO |
28 | |
29 | /** | |
30 | * | |
31 | * @package CRM | |
0f03f337 | 32 | * @copyright CiviCRM LLC (c) 2004-2017 |
6a488035 TO |
33 | */ |
34 | ||
35 | /** | |
ce064e4f | 36 | * Page for displaying list of Label Formats. |
6a488035 TO |
37 | */ |
38 | class CRM_Admin_Page_LabelFormats extends CRM_Core_Page_Basic { | |
39 | ||
96f50de2 CW |
40 | public $useLivePageJS = TRUE; |
41 | ||
6a488035 | 42 | /** |
eceb18cc | 43 | * The action links that we need to display for the browse screen. |
6a488035 TO |
44 | * |
45 | * @var array | |
6a488035 TO |
46 | */ |
47 | static $_links = NULL; | |
48 | ||
49 | /** | |
eceb18cc | 50 | * Get BAO Name. |
6a488035 | 51 | * |
a6c01b45 CW |
52 | * @return string |
53 | * Classname of BAO. | |
6a488035 | 54 | */ |
00be9182 | 55 | public function getBAOName() { |
6a488035 TO |
56 | return 'CRM_Core_BAO_LabelFormat'; |
57 | } | |
58 | ||
59 | /** | |
eceb18cc | 60 | * Get action Links. |
6a488035 | 61 | * |
a6c01b45 CW |
62 | * @return array |
63 | * (reference) of action links | |
6a488035 | 64 | */ |
00be9182 | 65 | public function &links() { |
6a488035 TO |
66 | if (!(self::$_links)) { |
67 | // helper variable for nicer formatting | |
68 | self::$_links = array( | |
69 | CRM_Core_Action::UPDATE => array( | |
70 | 'name' => ts('Edit'), | |
71 | 'url' => 'civicrm/admin/labelFormats', | |
eaf5045f | 72 | 'qs' => 'action=update&id=%%id%%&group=%%group%%&reset=1', |
6a488035 TO |
73 | 'title' => ts('Edit Label Format'), |
74 | ), | |
75 | CRM_Core_Action::COPY => array( | |
76 | 'name' => ts('Copy'), | |
77 | 'url' => 'civicrm/admin/labelFormats', | |
eaf5045f | 78 | 'qs' => 'action=copy&id=%%id%%&group=%%group%%&reset=1', |
6a488035 TO |
79 | 'title' => ts('Copy Label Format'), |
80 | ), | |
81 | CRM_Core_Action::DELETE => array( | |
82 | 'name' => ts('Delete'), | |
83 | 'url' => 'civicrm/admin/labelFormats', | |
eaf5045f | 84 | 'qs' => 'action=delete&id=%%id%%&group=%%group%%&reset=1', |
6a488035 TO |
85 | 'title' => ts('Delete Label Format'), |
86 | ), | |
87 | ); | |
88 | } | |
89 | ||
90 | return self::$_links; | |
91 | } | |
92 | ||
93 | /** | |
eceb18cc | 94 | * Get name of edit form. |
6a488035 | 95 | * |
a6c01b45 CW |
96 | * @return string |
97 | * Classname of edit form. | |
6a488035 | 98 | */ |
00be9182 | 99 | public function editForm() { |
6a488035 TO |
100 | return 'CRM_Admin_Form_LabelFormats'; |
101 | } | |
102 | ||
103 | /** | |
eceb18cc | 104 | * Get edit form name. |
6a488035 | 105 | * |
a6c01b45 CW |
106 | * @return string |
107 | * name of this page. | |
6a488035 | 108 | */ |
00be9182 | 109 | public function editName() { |
6a488035 TO |
110 | return 'Mailing Label Formats'; |
111 | } | |
112 | ||
113 | /** | |
114 | * Get user context. | |
115 | * | |
fd31fa4c EM |
116 | * @param null $mode |
117 | * | |
a6c01b45 CW |
118 | * @return string |
119 | * user context. | |
6a488035 | 120 | */ |
00be9182 | 121 | public function userContext($mode = NULL) { |
6a488035 TO |
122 | return 'civicrm/admin/labelFormats'; |
123 | } | |
124 | ||
125 | /** | |
126 | * Browse all Label Format settings. | |
127 | * | |
dd244018 | 128 | * @param null $action |
6a488035 | 129 | */ |
00be9182 | 130 | public function browse($action = NULL) { |
6a488035 | 131 | // Get list of configured Label Formats |
02fc859b TO |
132 | $labelFormatList = CRM_Core_BAO_LabelFormat::getList(); |
133 | $nameFormatList = CRM_Core_BAO_LabelFormat::getList(FALSE, 'name_badge'); | |
6a488035 TO |
134 | |
135 | // Add action links to each of the Label Formats | |
136 | foreach ($labelFormatList as & $format) { | |
137 | $action = array_sum(array_keys($this->links())); | |
a7488080 | 138 | if (!empty($format['is_reserved'])) { |
6a488035 TO |
139 | $action -= CRM_Core_Action::DELETE; |
140 | } | |
252708df KJ |
141 | |
142 | $format['groupName'] = ts('Mailing Label'); | |
eaf5045f | 143 | $format['action'] = CRM_Core_Action::formLink(self::links(), $action, |
87dab4a4 AH |
144 | array('id' => $format['id'], 'group' => 'label_format'), |
145 | ts('more'), | |
146 | FALSE, | |
147 | 'labelFormat.manage.action', | |
148 | 'LabelFormat', | |
149 | $format['id'] | |
150 | ); | |
6a488035 TO |
151 | } |
152 | ||
eaf5045f KJ |
153 | // Add action links to each of the Label Formats |
154 | foreach ($nameFormatList as & $format) { | |
252708df | 155 | $format['groupName'] = ts('Name Badge'); |
eaf5045f KJ |
156 | } |
157 | ||
158 | $labelFormatList = array_merge($labelFormatList, $nameFormatList); | |
159 | ||
6a488035 TO |
160 | // Order Label Formats by weight |
161 | $returnURL = CRM_Utils_System::url(self::userContext()); | |
162 | CRM_Core_BAO_LabelFormat::addOrder($labelFormatList, $returnURL); | |
163 | ||
164 | $this->assign('rows', $labelFormatList); | |
165 | } | |
96025800 | 166 | |
6a488035 | 167 | } |