3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2013
35 class CRM_Case_XMLProcessor
{
37 static protected $_xml;
39 static protected $_hookCache = NULL;
41 function retrieve($caseType) {
42 $caseType = self
::mungeCaseType($caseType);
44 if (!CRM_Utils_Array
::value($caseType, self
::$_xml)) {
46 self
::$_xml = array();
49 // first check custom templates directory
51 $config = CRM_Core_Config
::singleton();
52 if (isset($config->customTemplateDir
) &&
53 $config->customTemplateDir
55 // check if the file exists in the custom templates directory
56 $fileName = implode(DIRECTORY_SEPARATOR
,
58 $config->customTemplateDir
,
69 !file_exists($fileName)
71 // check if file exists locally
72 $fileName = implode(DIRECTORY_SEPARATOR
,
73 array(dirname(__FILE__
),
80 if (!file_exists($fileName)) {
81 // check if file exists locally
82 $fileName = implode(DIRECTORY_SEPARATOR
,
83 array(dirname(__FILE__
),
85 'configuration.sample',
91 if (!file_exists($fileName)) {
92 if (self
::$_hookCache === NULL) {
93 self
::$_hookCache = array();
94 CRM_Utils_Hook
::caseTypes(self
::$_hookCache);
96 if (isset(self
::$_hookCache[$caseType], self
::$_hookCache[$caseType]['file'])) {
97 $fileName = self
::$_hookCache[$caseType]['file'];
101 if (!file_exists($fileName)) {
107 $dom = new DomDocument();
108 $dom->load($fileName);
110 self
::$_xml[$caseType] = simplexml_import_dom($dom);
112 return self
::$_xml[$caseType];
115 public static function mungeCaseType($caseType) {
116 // trim all spaces from $caseType
117 $caseType = str_replace('_', ' ', $caseType);
118 $caseType = CRM_Utils_String
::munge(ucwords($caseType), '', 0);
122 function &allActivityTypes($indexName = TRUE, $all = FALSE) {
123 static $activityTypes = NULL;
124 if (!$activityTypes) {
125 $activityTypes = CRM_Case_PseudoConstant
::caseActivityType($indexName, $all);
127 return $activityTypes;
130 function &allRelationshipTypes() {
131 static $relationshipTypes = array();
133 if (!$relationshipTypes) {
134 $relationshipInfo = CRM_Core_PseudoConstant
::relationshipType();
136 $relationshipTypes = array();
137 foreach ($relationshipInfo as $id => $info) {
138 $relationshipTypes[$id] = $info['label_b_a'];
142 return $relationshipTypes;