Пример #1
0
 function retrieve($caseType)
 {
     require_once 'CRM/Utils/String.php';
     require_once 'CRM/Utils/Array.php';
     // trim all spaces from $caseType
     $caseType = str_replace('_', ' ', $caseType);
     $caseType = CRM_Utils_String::munge(ucwords($caseType), '', 0);
     if (!CRM_Utils_Array::value($caseType, self::$_xml)) {
         if (!self::$_xml) {
             self::$_xml = array();
         }
         // first check custom templates directory
         $fileName = null;
         $config = CRM_Core_Config::singleton();
         if (isset($config->customTemplateDir) && $config->customTemplateDir) {
             // check if the file exists in the custom templates directory
             $fileName = implode(DIRECTORY_SEPARATOR, array($config->customTemplateDir, 'CRM', 'Case', 'xml', 'configuration', "{$caseType}.xml"));
         }
         if (!$fileName || !file_exists($fileName)) {
             // check if file exists locally
             $fileName = implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), 'xml', 'configuration', "{$caseType}.xml"));
             if (!file_exists($fileName)) {
                 return false;
             }
         }
         // read xml file
         $dom = DomDocument::load($fileName);
         $dom->xinclude();
         self::$_xml[$caseType] = simplexml_import_dom($dom);
     }
     return self::$_xml[$caseType];
 }
Пример #2
0
 function retrieve($caseType)
 {
     $caseType = self::mungeCaseType($caseType);
     if (!CRM_Utils_Array::value($caseType, self::$_xml)) {
         if (!self::$_xml) {
             self::$_xml = array();
         }
         // first check custom templates directory
         $fileName = NULL;
         $config = CRM_Core_Config::singleton();
         if (isset($config->customTemplateDir) && $config->customTemplateDir) {
             // check if the file exists in the custom templates directory
             $fileName = implode(DIRECTORY_SEPARATOR, array($config->customTemplateDir, 'CRM', 'Case', 'xml', 'configuration', "{$caseType}.xml"));
         }
         if (!$fileName || !file_exists($fileName)) {
             // check if file exists locally
             $fileName = implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), 'xml', 'configuration', "{$caseType}.xml"));
             if (!file_exists($fileName)) {
                 // check if file exists locally
                 $fileName = implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), 'xml', 'configuration.sample', "{$caseType}.xml"));
             }
             if (!file_exists($fileName)) {
                 if (self::$_hookCache === NULL) {
                     self::$_hookCache = array();
                     CRM_Utils_Hook::caseTypes(self::$_hookCache);
                 }
                 if (isset(self::$_hookCache[$caseType], self::$_hookCache[$caseType]['file'])) {
                     $fileName = self::$_hookCache[$caseType]['file'];
                 }
             }
             if (!file_exists($fileName)) {
                 return FALSE;
             }
         }
         // read xml file
         $dom = new DomDocument();
         $dom->load($fileName);
         $dom->xinclude();
         self::$_xml[$caseType] = simplexml_import_dom($dom);
     }
     return self::$_xml[$caseType];
 }
Пример #3
0
 function retrieve($caseType)
 {
     require_once 'CRM/Utils/String.php';
     require_once 'CRM/Utils/Array.php';
     // trim all spaces from $caseType
     $caseType = str_replace('_', ' ', $caseType);
     $caseType = CRM_Utils_String::munge(ucwords($caseType), '', 0);
     if (!CRM_Utils_Array::value($caseType, self::$_xml)) {
         if (!self::$_xml) {
             self::$_xml = array();
         }
         // ensure that the file exists
         $fileName = implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), 'xml', 'configuration', "{$caseType}.xml"));
         if (!file_exists($fileName)) {
             return false;
         }
         // read xml file
         $dom = DomDocument::load($fileName);
         $dom->xinclude();
         self::$_xml[$caseType] = simplexml_import_dom($dom);
     }
     return self::$_xml[$caseType];
 }