context.plugins.inc 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. <?php
  2. /**
  3. * Context registry.
  4. */
  5. function _context_context_registry() {
  6. $registry = array();
  7. $registry['conditions'] = array(
  8. 'context' => array(
  9. 'title' => t('Context (any)'),
  10. 'description' => t('Set this context on the basis of other active contexts. Put each context on a separate line. The condition will pass if <em>any</em> of the contexts are active. You can use the <code>*</code> character (asterisk) as a wildcard and the <code>~</code> character (tilde) to prevent this context from activating if the listed context is active. Other contexts which use context conditions can not be used to exclude this context from activating.'),
  11. 'plugin' => 'context_condition_context',
  12. ),
  13. 'context_all' => array(
  14. 'title' => t('Context (all)'),
  15. 'description' => t('Set this context on the basis of other active contexts. Put each context on a separate line. The condition will pass only if <em>all</em> of the contexts are active. You can use the <code>*</code> character (asterisk) as a wildcard and the <code>~</code> character (tilde) to prevent this context from activating if the listed context is active. Other contexts which use context conditions can not be used to exclude this context from activating.'),
  16. 'plugin' => 'context_condition_context_all',
  17. ),
  18. 'node' => array(
  19. 'title' => t('Node type'),
  20. 'description' => t('Set this context when viewing a node page or using the add/edit form of one of these content types.'),
  21. 'plugin' => 'context_condition_node',
  22. ),
  23. 'sitewide' => array(
  24. 'title' => t('Sitewide context'),
  25. 'description' => t('Should this context always be set? If <strong>true</strong>, this context will be active across your entire site.'),
  26. 'plugin' => 'context_condition_sitewide',
  27. ),
  28. 'default' => array(
  29. 'title' => t('Default context'),
  30. 'description' => t('This context will be set if no other context is active except sitewide contexts.'),
  31. 'plugin' => 'context_condition_default',
  32. ),
  33. 'path' => array(
  34. 'title' => t('Path'),
  35. 'description' => t('Set this context when any of the paths above match the page path. Put each path on a separate line. You can use the <code>*</code> character (asterisk) as a wildcard and the <code>~</code> character (tilde) to exclude one or more paths. Use &lt;front&gt; for the site front page.'),
  36. 'plugin' => 'context_condition_path',
  37. ),
  38. 'query_string' => array(
  39. 'title' => t('Query String'),
  40. 'description' => t('Set this context when any of the query strings above match the page query string. Put each query string on a separate line. You can use the "*" character as a wildcard and <code>~</code> to exclude one or more query strings.'),
  41. 'plugin' => 'context_condition_query_string',
  42. ),
  43. 'user' => array(
  44. 'title' => t('User role'),
  45. 'description' => t('Set this context when the current user has one of the selected role(s).'),
  46. 'plugin' => 'context_condition_user',
  47. ),
  48. 'user_page' => array(
  49. 'title' => t('User page'),
  50. 'description' => t('Set this context when viewing a user page.'),
  51. 'plugin' => 'context_condition_user_page',
  52. ),
  53. );
  54. if (module_exists('menu')) {
  55. $registry['conditions']['menu'] = array(
  56. 'title' => t('Menu'),
  57. 'description' => t('Set this context when any of the selected menu items belong to the current active menu trail.'),
  58. 'plugin' => 'context_condition_menu',
  59. );
  60. }
  61. if (module_exists('views')) {
  62. $registry['conditions']['views'] = array(
  63. 'title' => t('Views'),
  64. 'description' => t('Set this context when displaying the page of one of these views.'),
  65. 'plugin' => 'context_condition_views',
  66. );
  67. }
  68. if (module_exists('book')) {
  69. $registry['conditions']['book'] = array(
  70. 'title' => t('Book'),
  71. 'description' => t('Set this context when a node in the selected book is viewed.'),
  72. 'plugin' => 'context_condition_book',
  73. );
  74. $registry['conditions']['bookroot'] = array(
  75. 'title' => t('Book root'),
  76. 'description' => t('Set this context when viewing a node whose root book is of the selected type.'),
  77. 'plugin' => 'context_condition_bookroot',
  78. );
  79. }
  80. if (module_exists('locale')) {
  81. $registry['conditions']['language'] = array(
  82. 'title' => t('Language'),
  83. 'description' => t('Set this context when viewing the site in the selected language.'),
  84. 'plugin' => 'context_condition_language',
  85. );
  86. }
  87. if (module_exists('taxonomy')) {
  88. $registry['conditions']['node_taxonomy'] = array(
  89. 'title' => t('Taxonomy'),
  90. 'description' => t('Set this context when viewing a node with the selected taxonomy terms.'),
  91. 'plugin' => 'context_condition_node_taxonomy',
  92. );
  93. $registry['conditions']['taxonomy_term'] = array(
  94. 'title' => t('Taxonomy term'),
  95. 'description' => t('Set this context when viewing a taxonomy term page.'),
  96. 'plugin' => 'context_condition_taxonomy_term',
  97. );
  98. }
  99. $registry['reactions'] = array(
  100. 'block' => array(
  101. 'title' => t('Blocks'),
  102. 'description' => t('Control block visibility using context.'),
  103. 'plugin' => 'context_reaction_block',
  104. ),
  105. 'region' => array(
  106. 'title' => t('Regions'),
  107. 'description' => t('Control Region visiblity using context.'),
  108. 'plugin' => 'context_reaction_region',
  109. ),
  110. 'breadcrumb' => array(
  111. 'title' => t('Breadcrumb'),
  112. 'description' => t('Set the breadcrumb trail to the selected menu item.'),
  113. 'plugin' => 'context_reaction_breadcrumb',
  114. ),
  115. 'template_suggestions' => array(
  116. 'title' => t('Template suggestions'),
  117. 'description' => t('Add template suggestions using context.'),
  118. 'plugin' => 'context_reaction_template_suggestions',
  119. ),
  120. 'theme' => array(
  121. 'title' => t('Theme Page'),
  122. 'description' => t('Control page theme variables using context.'),
  123. 'plugin' => 'context_reaction_theme',
  124. ),
  125. 'theme_html' => array(
  126. 'title' => t('Theme HTML'),
  127. 'description' => t('Control HTML theme variables using context.'),
  128. 'plugin' => 'context_reaction_theme_html',
  129. ),
  130. 'debug' => array(
  131. 'title' => t('Debug'),
  132. 'description' => t('Debug output reaction for SimpleTest.'),
  133. 'plugin' => 'context_reaction_debug',
  134. ),
  135. );
  136. if (module_exists('menu')) {
  137. $registry['reactions']['menu'] = array(
  138. 'title' => t('Menu'),
  139. 'description' => t('Control menu active class using context.'),
  140. 'plugin' => 'context_reaction_menu',
  141. );
  142. }
  143. if (module_exists('css_injector')) {
  144. $registry['reactions']['css_injector'] = array(
  145. 'title' => t('CSS Injector'),
  146. 'description' => t('Inject the selected css when this context is set.'),
  147. 'plugin' => 'context_reaction_css_injector',
  148. );
  149. }
  150. return $registry;
  151. }
  152. /**
  153. * Context plugins.
  154. */
  155. function _context_context_plugins() {
  156. $plugins = array();
  157. /**
  158. * Conditions.
  159. */
  160. $plugins['context_condition'] = array(
  161. 'handler' => array(
  162. 'path' => drupal_get_path('module', 'context') . '/plugins',
  163. 'file' => 'context_condition.inc',
  164. 'class' => 'context_condition',
  165. ),
  166. );
  167. $plugins['context_condition_context'] = array(
  168. 'handler' => array(
  169. 'path' => drupal_get_path('module', 'context') . '/plugins',
  170. 'file' => 'context_condition_context.inc',
  171. 'class' => 'context_condition_context',
  172. 'parent' => 'context_condition_path',
  173. ),
  174. );
  175. $plugins['context_condition_context_all'] = array(
  176. 'handler' => array(
  177. 'path' => drupal_get_path('module', 'context') . '/plugins',
  178. 'file' => 'context_condition_context_all.inc',
  179. 'class' => 'context_condition_context_all',
  180. 'parent' => 'context_condition_path',
  181. ),
  182. );
  183. $plugins['context_condition_node'] = array(
  184. 'handler' => array(
  185. 'path' => drupal_get_path('module', 'context') . '/plugins',
  186. 'file' => 'context_condition_node.inc',
  187. 'class' => 'context_condition_node',
  188. 'parent' => 'context_condition',
  189. ),
  190. );
  191. $plugins['context_condition_sitewide'] = array(
  192. 'handler' => array(
  193. 'path' => drupal_get_path('module', 'context') . '/plugins',
  194. 'file' => 'context_condition_sitewide.inc',
  195. 'class' => 'context_condition_sitewide',
  196. 'parent' => 'context_condition',
  197. ),
  198. );
  199. $plugins['context_condition_default'] = array(
  200. 'handler' => array(
  201. 'path' => drupal_get_path('module', 'context') . '/plugins',
  202. 'file' => 'context_condition_default.inc',
  203. 'class' => 'context_condition_default',
  204. 'parent' => 'context_condition',
  205. ),
  206. );
  207. $plugins['context_condition_path'] = array(
  208. 'handler' => array(
  209. 'path' => drupal_get_path('module', 'context') . '/plugins',
  210. 'file' => 'context_condition_path.inc',
  211. 'class' => 'context_condition_path',
  212. 'parent' => 'context_condition',
  213. ),
  214. );
  215. $plugins['context_condition_query_string'] = array(
  216. 'handler' => array(
  217. 'path' => drupal_get_path('module', 'context') .'/plugins',
  218. 'file' => 'context_condition_query_string.inc',
  219. 'class' => 'context_condition_query_string',
  220. 'parent' => 'context_condition_path',
  221. ),
  222. );
  223. $plugins['context_condition_user'] = array(
  224. 'handler' => array(
  225. 'path' => drupal_get_path('module', 'context') . '/plugins',
  226. 'file' => 'context_condition_user.inc',
  227. 'class' => 'context_condition_user',
  228. 'parent' => 'context_condition',
  229. ),
  230. );
  231. $plugins['context_condition_user_page'] = array(
  232. 'handler' => array(
  233. 'path' => drupal_get_path('module', 'context') . '/plugins',
  234. 'file' => 'context_condition_user_page.inc',
  235. 'class' => 'context_condition_user_page',
  236. 'parent' => 'context_condition',
  237. ),
  238. );
  239. $plugins['context_condition_menu'] = array(
  240. 'handler' => array(
  241. 'path' => drupal_get_path('module', 'context') . '/plugins',
  242. 'file' => 'context_condition_menu.inc',
  243. 'class' => 'context_condition_menu',
  244. 'parent' => 'context_condition',
  245. ),
  246. );
  247. if (module_exists('taxonomy')) {
  248. $plugins['context_condition_node_taxonomy'] = array(
  249. 'handler' => array(
  250. 'path' => drupal_get_path('module', 'context') . '/plugins',
  251. 'file' => 'context_condition_node_taxonomy.inc',
  252. 'class' => 'context_condition_node_taxonomy',
  253. 'parent' => 'context_condition_node',
  254. ),
  255. );
  256. $plugins['context_condition_taxonomy_term'] = array(
  257. 'handler' => array(
  258. 'path' => drupal_get_path('module', 'context') . '/plugins',
  259. 'file' => 'context_condition_taxonomy_term.inc',
  260. 'class' => 'context_condition_taxonomy_term',
  261. 'parent' => 'context_condition',
  262. ),
  263. );
  264. }
  265. if (module_exists('locale')) {
  266. $plugins['context_condition_language'] = array(
  267. 'handler' => array(
  268. 'path' => drupal_get_path('module', 'context') . '/plugins',
  269. 'file' => 'context_condition_language.inc',
  270. 'class' => 'context_condition_language',
  271. 'parent' => 'context_condition',
  272. ),
  273. );
  274. }
  275. if (module_exists('book')) {
  276. $plugins['context_condition_book'] = array(
  277. 'handler' => array(
  278. 'path' => drupal_get_path('module', 'context') . '/plugins',
  279. 'file' => 'context_condition_book.inc',
  280. 'class' => 'context_condition_book',
  281. 'parent' => 'context_condition',
  282. ),
  283. );
  284. $plugins['context_condition_bookroot'] = array(
  285. 'handler' => array(
  286. 'path' => drupal_get_path('module', 'context') . '/plugins',
  287. 'file' => 'context_condition_bookroot.inc',
  288. 'class' => 'context_condition_bookroot',
  289. 'parent' => 'context_condition_node',
  290. ),
  291. );
  292. }
  293. if (module_exists('views')) {
  294. $plugins['context_condition_views'] = array(
  295. 'handler' => array(
  296. 'path' => drupal_get_path('module', 'context') . '/plugins',
  297. 'file' => 'context_condition_views.inc',
  298. 'class' => 'context_condition_views',
  299. 'parent' => 'context_condition',
  300. ),
  301. );
  302. }
  303. /**
  304. * Reactions.
  305. */
  306. $plugins['context_reaction'] = array(
  307. 'handler' => array(
  308. 'path' => drupal_get_path('module', 'context') . '/plugins',
  309. 'file' => 'context_reaction.inc',
  310. 'class' => 'context_reaction',
  311. ),
  312. );
  313. $plugins['context_reaction_block'] = array(
  314. 'handler' => array(
  315. 'path' => drupal_get_path('module', 'context') . '/plugins',
  316. 'file' => 'context_reaction_block.inc',
  317. 'class' => 'context_reaction_block',
  318. 'parent' => 'context_reaction',
  319. ),
  320. );
  321. $plugins['context_reaction_region'] = array(
  322. 'handler' => array(
  323. 'path' => drupal_get_path('module', 'context') . '/plugins',
  324. 'file' => 'context_reaction_region.inc',
  325. 'class' => 'context_reaction_region',
  326. 'parent' => 'context_reaction',
  327. ),
  328. );
  329. $plugins['context_reaction_breadcrumb'] = array(
  330. 'handler' => array(
  331. 'path' => drupal_get_path('module', 'context') . '/plugins',
  332. 'file' => 'context_reaction_breadcrumb.inc',
  333. 'class' => 'context_reaction_breadcrumb',
  334. 'parent' => 'context_reaction_menu',
  335. ),
  336. );
  337. $plugins['context_reaction_template_suggestions'] = array(
  338. 'handler' => array(
  339. 'path' => drupal_get_path('module', 'context') . '/plugins',
  340. 'file' => 'context_reaction_template_suggestions.inc',
  341. 'class' => 'context_reaction_template_suggestions',
  342. 'parent' => 'context_reaction',
  343. ),
  344. );
  345. $plugins['context_reaction_menu'] = array(
  346. 'handler' => array(
  347. 'path' => drupal_get_path('module', 'context') . '/plugins',
  348. 'file' => 'context_reaction_menu.inc',
  349. 'class' => 'context_reaction_menu',
  350. 'parent' => 'context_reaction',
  351. ),
  352. );
  353. $plugins['context_reaction_theme'] = array(
  354. 'handler' => array(
  355. 'path' => drupal_get_path('module', 'context') . '/plugins',
  356. 'file' => 'context_reaction_theme.inc',
  357. 'class' => 'context_reaction_theme',
  358. 'parent' => 'context_reaction',
  359. ),
  360. );
  361. $plugins['context_reaction_theme_html'] = array(
  362. 'handler' => array(
  363. 'path' => drupal_get_path('module', 'context') . '/plugins',
  364. 'file' => 'context_reaction_theme_html.inc',
  365. 'class' => 'context_reaction_theme_html',
  366. 'parent' => 'context_reaction_theme',
  367. ),
  368. );
  369. $plugins['context_reaction_debug'] = array(
  370. 'handler' => array(
  371. 'path' => drupal_get_path('module', 'context') . '/plugins',
  372. 'file' => 'context_reaction_debug.inc',
  373. 'class' => 'context_reaction_debug',
  374. 'parent' => 'context_reaction',
  375. ),
  376. );
  377. if (module_exists('css_injector')) {
  378. $plugins['context_reaction_css_injector'] = array(
  379. 'handler' => array(
  380. 'path' => drupal_get_path('module', 'context') . '/plugins',
  381. 'file' => 'context_reaction_css_injector.inc',
  382. 'class' => 'context_reaction_css_injector',
  383. 'parent' => 'context_reaction',
  384. ),
  385. );
  386. }
  387. return $plugins;
  388. }