Merge pull request #4648 from totten/master-civimail-misc
[civicrm-core.git] / xml / templates / listAll.tpl
CommitLineData
6b5ff8c9
ARW
1<?php
2
3/*
4 +--------------------------------------------------------------------+
811982aa 5 | CiviCRM version 4.5 |
6b5ff8c9 6 +--------------------------------------------------------------------+
811982aa 7 | Copyright CiviCRM LLC (c) 2004-2014 |
6b5ff8c9
ARW
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
811982aa 32 * @copyright CiviCRM LLC (c) 2004-2014
6b5ff8c9
ARW
33 * $Id$
34 *
35 */
36
4d1d7aca 37class CRM_Core_DAO_AllCoreTables {ldelim}
6b5ff8c9 38
fed67e4d
TO
39 static private $tables = null;
40 static private $daoToClass = null;
41
95a90cba 42 static private function init($fresh = FALSE) {ldelim}
fed67e4d 43 static $init = FALSE;
95a90cba 44 if ($init && !$fresh) return;
fed67e4d
TO
45
46 $entityTypes = array(
6b5ff8c9 47{foreach from=$tables key=tableName item=table}
fed67e4d
TO
48 '{$table.className}' => array(
49 'name' => '{$table.objectName}',
50 'class' => '{$table.className}',
51 'table' => '{$tableName}',
52 ),
53{/foreach}
54 );
6b5ff8c9 55
fed67e4d 56 CRM_Utils_Hook::entityTypes($entityTypes);
58d8ecd0 57
fed67e4d
TO
58 self::$tables = array();
59 self::$daoToClass = array();
60 foreach ($entityTypes as $entityType) {ldelim}
61 self::registerEntityType($entityType['name'], $entityType['class'], $entityType['table']);
62 {rdelim}
6b5ff8c9 63
fed67e4d
TO
64 $init = TRUE;
65 {rdelim}
66
67 static private function registerEntityType($daoName, $className, $tableName) {ldelim}
68 self::$daoToClass[$daoName] = $className;
69 self::$tables[$tableName] = $className;
70 {rdelim}
71
72 static public function tables() {ldelim}
73 self::init();
6b5ff8c9
ARW
74 return self::$tables;
75 {rdelim}
76
fed67e4d
TO
77 static public function daoToClass() {ldelim}
78 self::init();
79 return self::$daoToClass;
80 {rdelim}
81
82 static public function getCoreTables() {ldelim}
83 return self::tables();
84 {rdelim}
85
6b5ff8c9 86 static public function isCoreTable($tableName) {ldelim}
fed67e4d 87 return FALSE !== array_search($tableName, self::tables());
6b5ff8c9
ARW
88 {rdelim}
89
a6c6fe56
TO
90 static public function getCanonicalClassName($className) {ldelim}
91 return str_replace('_BAO_', '_DAO_', $className);
92 {rdelim}
93
439a6148 94 static public function getClasses() {ldelim}
fed67e4d 95 return array_values(self::daoToClass());
439a6148
TO
96 {rdelim}
97
98 static public function getClassForTable($tableName) {ldelim}
fed67e4d 99 return CRM_Utils_Array::value($tableName, self::tables());
439a6148
TO
100 {rdelim}
101
6b5ff8c9 102 static public function getFullName($daoName) {ldelim}
fed67e4d 103 return CRM_Utils_Array::value($daoName, self::daoToClass());
6b5ff8c9
ARW
104 {rdelim}
105
edc091f1 106 static public function getBriefName($className) {ldelim}
fed67e4d 107 return CRM_Utils_Array::value($className, array_flip(self::daoToClass()));
edc091f1
ARW
108 {rdelim}
109
a6c6fe56
TO
110 /**
111 * @param string $className DAO or BAO name
112 * @return string|FALSE SQL table name
113 */
114 static public function getTableForClass($className) {ldelim}
115 return array_search(self::getCanonicalClassName($className), self::tables());
116 {rdelim}
117
95a90cba
N
118 static public function reinitializeCache($fresh = FALSE) {ldelim}
119 self::init($fresh);
120 {rdelim}
a6c6fe56 121
6b5ff8c9 122{rdelim}