plugins.inc

  1. cis7 sites/all/modules/ulmus/ctools/includes/plugins.inc
  2. cis7 sites/all/modules/ulmus/views/includes/plugins.inc
  3. cis7 sites/all/themes/ulmus/adaptivetheme/at_core/inc/plugins.inc
  4. cle7 sites/all/modules/ulmus/ctools/includes/plugins.inc
  5. cle7 sites/all/modules/ulmus/views/includes/plugins.inc
  6. cle7 sites/all/themes/ulmus/adaptivetheme/at_core/inc/plugins.inc
  7. ecd7 sites/all/modules/ulmus/ctools/includes/plugins.inc
  8. ecd7 sites/all/themes/ulmus/adaptivetheme/at_core/inc/plugins.inc
  9. ecd7 sites/all/modules/ulmus/views/includes/plugins.inc
  10. elmsmedia7 sites/all/modules/ulmus/ctools/includes/plugins.inc
  11. elmsmedia7 sites/all/modules/ulmus/views/includes/plugins.inc
  12. elmsmedia7 sites/all/themes/ulmus/adaptivetheme/at_core/inc/plugins.inc
  13. harmony7 sites/all/themes/ulmus/adaptivetheme/at_core/inc/plugins.inc
  14. harmony7 sites/all/modules/ulmus/views/includes/plugins.inc
  15. harmony7 sites/all/modules/ulmus/ctools/includes/plugins.inc
  16. icor7 sites/all/modules/ulmus/ctools/includes/plugins.inc
  17. icor7 sites/all/themes/ulmus/adaptivetheme/at_core/inc/plugins.inc
  18. icor7 sites/all/modules/ulmus/views/includes/plugins.inc
  19. meedjum_blog7 sites/all/modules/ulmus/views/includes/plugins.inc
  20. meedjum_blog7 sites/all/themes/ulmus/adaptivetheme/at_core/inc/plugins.inc
  21. meedjum_blog7 sites/all/modules/ulmus/ctools/includes/plugins.inc
  22. mooc7 sites/all/modules/ulmus/views/includes/plugins.inc
  23. mooc7 sites/all/themes/ulmus/adaptivetheme/at_core/inc/plugins.inc
  24. mooc7 sites/all/modules/ulmus/ctools/includes/plugins.inc

AT's liteweight plugin sub-system.

Functions

Namesort descending Description
at_get_plugins Find and return all plugins.
at_get_plugins_files Returns all files for plugins of a particular type. This is called from at_load_plugins(), cannot be cached else it will return stale data at some point.
at_get_plugins_paths Return the paths to all plugin providers plugin directories, this usually means themes - both base themes and sub-themes that include plugin directory declarations in their info files.
at_load_plugins Extract plugin data structures.
gpanel_regions Return an array of standard gpanel regions. Not really part of the plugin system and can't recall why I put it here :/
page_layout Base config for page layout builder. This is used in at_core.submit.responsive.inc to help retrieve the form values for each device groups layout. Not really part of the plugin system and can't recall why I put it here :/
responsive_page_layouts_data_structure Return Page layout data structures. This returns the full data structures for all page layout plugins. Because this can be a lot of data and appears to be computationally expensive to get it is cached in the cache table.
responsive_page_layouts_device_group_options Return option arrays for forms. Returns the options for radio lists in the page layout settings in the appearance theme settings.
responsive_panels_data_structure Return Panels layout data structures. This returns the full data structures for all Panels layout plugins. Because this can be a lot of data and appears to be computationally expensive to get it is cached in the cache table.
responsive_plugins_admin_css Return all the admin css files for a plugin type. Used primarly to theme the icons for each layout method.

File

sites/all/themes/ulmus/adaptivetheme/at_core/inc/plugins.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * AT's liteweight plugin sub-system.
  5. */
  6. /**
  7. * Find and return all plugins.
  8. *
  9. * This will search all base themes and the active theme for "plugins" in their
  10. * info files, and return all plugins directories. Info file entries must
  11. * follow the Panels plugin structure i.e.:
  12. * - "plugins[plugin_type][type] = path/to/plugins"
  13. * For example for AT page layouts we use:
  14. * - "plugins[page_layout][layout] = layouts/core"
  15. *
  16. * @param $theme_name, usually the active theme.
  17. */
  18. function at_get_plugins($theme_name) {
  19. $plugins = &drupal_static(__FUNCTION__, array());
  20. if (empty($plugins)) {
  21. if ($plugins_cache = cache_get('at_get_plugins_plugins')) {
  22. $plugins = $plugins_cache->data;
  23. }
  24. else {
  25. $plugins_list = array();
  26. $themes_info = at_get_info_trail($theme_name);
  27. // Look for and get all the plugins
  28. if (!empty($themes_info)) {
  29. foreach ($themes_info as $this_theme => $theme_info) {
  30. foreach ($theme_info as $info) {
  31. if (array_key_exists('plugins', $info)) {
  32. foreach ($info['plugins'] as $plugin_type => $types) {
  33. $plugins_list[$this_theme][$plugin_type] = $types;
  34. }
  35. }
  36. }
  37. }
  38. $plugins = $plugins_list;
  39. }
  40. }
  41. cache_set('at_get_plugins_plugins', $plugins, 'cache');
  42. }
  43. return $plugins;
  44. }
  45. /**
  46. * Return the paths to all plugin providers plugin directories, this usually
  47. * means themes - both base themes and sub-themes that include plugin directory
  48. * declarations in their info files.
  49. *
  50. * @param $theme_name, ususally the active theme.
  51. */
  52. function at_get_plugins_paths($theme_name) {
  53. $provider_paths = array();
  54. $plugins_list = at_get_plugins($theme_name);
  55. foreach ($plugins_list as $plugin_provider => $provider) {
  56. foreach ($provider as $plugin_type => $types) {
  57. foreach ($types as $type => $path) {
  58. $provider_path = drupal_get_path('theme', $plugin_provider) . '/' . $path;
  59. $provider_paths[$plugin_provider][$plugin_type][$type] = $provider_path;
  60. }
  61. }
  62. }
  63. return $provider_paths;
  64. }
  65. /**
  66. * Returns all files for plugins of a particular type.
  67. * This is called from at_load_plugins(), cannot be cached else it will return
  68. * stale data at some point.
  69. *
  70. * @param $theme_name
  71. */
  72. function at_get_plugins_files($theme_name) {
  73. $plugins_files = array();
  74. $plugins_list = at_get_plugins($theme_name);
  75. $extension = 'inc';
  76. foreach ($plugins_list as $plugin_provider => $provider) {
  77. foreach ($provider as $plugin_type => $types) {
  78. foreach ($types as $type => $path) {
  79. $provider_path = drupal_get_path('theme', $plugin_provider) . '/' . $path;
  80. $plugins_files[$plugin_provider][$plugin_type][$type] = file_scan_directory($provider_path, '/\.' . $extension . '$/', array('key' => 'name'));
  81. }
  82. }
  83. }
  84. return $plugins_files;
  85. }
  86. /**
  87. * Extract plugin data structures.
  88. *
  89. * In essence what this does is return the data strutures (arrays) for all
  90. * plugins of a particular type. As of now only two types are used by AT, being
  91. * "panels" and "page_layout". This is hard to cache because it takes the
  92. * $plugin_type parameter, so everything else that calls this is heavily cached
  93. * instead. It does support an "everything else" plugin type, whatever that is.
  94. *
  95. * @param $theme_name, usually the active theme.
  96. * @param $plugin_type, the plugin type you need to return, usually one of
  97. * "panels" or "page_layout".
  98. */
  99. function at_load_plugins($theme_name, $plugin_type) {
  100. $plugin_data_structures = array();
  101. $plugins_list = at_get_plugins_files($theme_name);
  102. $plugins_array = array();
  103. foreach ($plugins_list as $plugin_provider => $plugin_types) {
  104. $plugin_providers[] = $plugin_provider;
  105. foreach ($plugin_types as $type => $plugins) {
  106. if ($type === $plugin_type) {
  107. foreach ($plugins as $ptypes => $plugin) {
  108. $plugins_array[$plugin_provider][$type] = $plugin;
  109. }
  110. }
  111. }
  112. }
  113. $plugin_files = array();
  114. foreach ($plugins_array as $provider => $types) {
  115. foreach ($types as $key => $value) {
  116. $plugin_files = array_merge_recursive($plugin_files, $value);
  117. }
  118. }
  119. foreach ($plugin_files as $file_data) {
  120. include_once(DRUPAL_ROOT . '/' . $file_data->uri);
  121. // panels
  122. if ($plugin_type === 'panels') {
  123. foreach ($plugin_providers as $provider) {
  124. $identifiers[$provider] = $provider . '_' . $file_data->name . '_panels_layouts';
  125. }
  126. foreach ($identifiers as $identifier) {
  127. $panels_function = $identifier;
  128. if (function_exists($panels_function)) {
  129. $plugin_data_structures[] = $panels_function();
  130. }
  131. }
  132. }
  133. // page_layout
  134. if ($plugin_type === 'page_layout') {
  135. $identifier = $file_data->name;
  136. $page_layout_function = $identifier;
  137. if (function_exists($page_layout_function)) {
  138. $plugin_data_structures[] = $page_layout_function();
  139. }
  140. }
  141. // everything else
  142. elseif ($plugin_type !== 'panels' && $plugin_type !== 'page_layout') {
  143. $identifier = $file_data->name;
  144. $function = $identifier;
  145. if (function_exists($function)) {
  146. $plugin_data_structures[] = $function();
  147. }
  148. else {
  149. drupal_set_message(t('You defined an existing plugin type but no functions exists that match. If you are using Panels then you must use the "function method" in your plugins, see AT Cores panel layout plugins for examples.'), 'error');
  150. }
  151. }
  152. }
  153. if (empty($plugin_data_structures)) {
  154. return;
  155. }
  156. return $plugin_data_structures;
  157. }
  158. /**
  159. * Return Page layout data structures.
  160. * This returns the full data structures for all page layout plugins. Because
  161. * this can be a lot of data and appears to be computationally expensive to get
  162. * it is cached in the cache table.
  163. *
  164. * @param $theme_name, the active theme.
  165. */
  166. function responsive_page_layouts_data_structure($theme_name = NULL) {
  167. // Use the passed in theme_name, else grab it from the global variable
  168. if ($theme_name == NULL) {
  169. global $theme_key;
  170. $theme_name = $theme_key;
  171. }
  172. $page_data_structure = &drupal_static(__FUNCTION__, array());
  173. if (empty($page_data_structure)) {
  174. if ($cache = cache_get('at_page_layouts_data_structure') && !empty($cache->data)) {
  175. $page_data_structure = $cache->data;
  176. }
  177. else {
  178. $data_structure = at_load_plugins($theme_name, $plugin_type = 'page_layout');
  179. foreach ($data_structure as $plugin => $datum) {
  180. foreach ($datum as $method => $layout) {
  181. $page_data_structure[$method] = $layout;
  182. }
  183. }
  184. cache_set('at_page_layouts_data_structure', $page_data_structure, 'cache');
  185. }
  186. }
  187. return $page_data_structure;
  188. }
  189. /**
  190. * Return Panels layout data structures.
  191. * This returns the full data structures for all Panels layout plugins. Because
  192. * this can be a lot of data and appears to be computationally expensive to get
  193. * it is cached in the cache table.
  194. */
  195. function responsive_panels_data_structure() {
  196. global $theme_key;
  197. $theme_name = $theme_key;
  198. $panels_data_structure = &drupal_static(__FUNCTION__, array());
  199. if (empty($panels_data_structure)) {
  200. if ($cache = cache_get('at_panels_data_structure')) {
  201. $panels_data_structure = $cache->data;
  202. }
  203. else {
  204. $data_structure = at_load_plugins($theme_name, $plugin_type = 'panels');
  205. // If this theme doesn't define any Panels layouts, use those
  206. // provided by at_core.
  207. if (empty($data_structure)) {
  208. $data_structure = at_load_plugins('adaptivetheme', $plugin_type = 'panels');
  209. }
  210. foreach ($data_structure as $plugin => $datum) {
  211. foreach ($datum as $key => $value) {
  212. $type = $value['type'];
  213. $panels_data_structure[$type][] = $datum;
  214. }
  215. }
  216. cache_set('at_panels_data_structure', $panels_data_structure, 'cache');
  217. }
  218. }
  219. return $panels_data_structure;
  220. }
  221. /**
  222. * Return option arrays for forms.
  223. * Returns the options for radio lists in the page layout settings in the
  224. * appearance theme settings.
  225. *
  226. * @param $theme_name
  227. */
  228. function responsive_page_layouts_device_group_options($theme_name) {
  229. $device_group_options = &drupal_static(__FUNCTION__, array());
  230. if (empty($device_group_options)) {
  231. $layout_methods = responsive_page_layouts_data_structure();
  232. foreach ($layout_methods as $method => $values) {
  233. foreach ($values as $key => $value) {
  234. if ($key == 'device_groups') {
  235. $method_values[$method] = $value;
  236. }
  237. }
  238. }
  239. foreach ($method_values as $this_method => $these_values) {
  240. foreach ($these_values as $k => $dv) {
  241. $device_group_options[$dv][] = $this_method;
  242. }
  243. }
  244. }
  245. return $device_group_options;
  246. }
  247. /**
  248. * Return all the admin css files for a plugin type.
  249. * Used primarly to theme the icons for each layout method.
  250. *
  251. * @param $theme_name
  252. * @param $plugin_type
  253. * TODO: add options for other plugin types, e.g. an "everything else" option.
  254. */
  255. function responsive_plugins_admin_css($theme_name, $plugin_type) {
  256. $admin_css_files = array();
  257. $plugin_paths = at_get_plugins_paths($theme_name);
  258. foreach ($plugin_paths as $providers => $provided_types) {
  259. foreach ($provided_types as $provider => $type_path) {
  260. if ($provider === $plugin_type) {
  261. $admin_css_paths[$providers] = $type_path;
  262. }
  263. }
  264. }
  265. if ($plugin_type === 'panels') {
  266. $rpl = responsive_panels_data_structure();
  267. foreach ($rpl as $group => $layouts) {
  268. foreach ($layouts as $layout) {
  269. foreach ($layout as $layout_key => $value) {
  270. if (isset($value['admin css'])) {
  271. $css_files[$layout_key] = $value['admin css'];
  272. }
  273. }
  274. }
  275. }
  276. }
  277. // I have been lazy here, in fact only the three_col_grail layout sets
  278. // an admin css file and returns all the CSS for all page layouts.
  279. if ($plugin_type === 'page_layout') {
  280. $rpl = responsive_page_layouts_data_structure();
  281. foreach ($rpl as $layout_method => $value) {
  282. if (isset($value['admin css'])) {
  283. $css_files[$layout_method] = $value['admin css'];
  284. }
  285. }
  286. }
  287. foreach ($admin_css_paths as $admin_css => $paths) {
  288. foreach ($paths as $path) {
  289. foreach ($css_files as $method_key => $file_name) {
  290. if ($method_key !== 'one') {
  291. $admin_css_files[] = $path . '/' . $method_key . '/' . $file_name;
  292. }
  293. }
  294. }
  295. }
  296. if (!isset($rpl)) {
  297. return; // fail quietly
  298. }
  299. return $admin_css_files;
  300. }
  301. /**
  302. * Base config for page layout builder.
  303. * This is used in at_core.submit.responsive.inc to help retrieve the form
  304. * values for each device groups layout. Not really part of the plugin
  305. * system and can't recall why I put it here :/
  306. */
  307. function page_layout() {
  308. $variables_array = array(
  309. 'layout',
  310. 'media_query',
  311. 'page_width',
  312. 'page_unit',
  313. 'sidebar_first',
  314. 'sidebar_second',
  315. 'sidebar_unit',
  316. );
  317. return $variables_array;
  318. }
  319. /**
  320. * Return an array of standard gpanel regions. Not really part of the plugin
  321. * system and can't recall why I put it here :/
  322. */
  323. function gpanel_regions() {
  324. $gpanel_regions_array = &drupal_static(__FUNCTION__, array());
  325. if (empty($gpanel_regions_array)) {
  326. $gpanel_regions_array = array(
  327. 'one' => array(
  328. 'title' => t('One column'),
  329. 'regions' => array(
  330. 'one_main',
  331. ),
  332. ),
  333. 'two_brick' => array(
  334. 'title' => t('AT Two column brick'),
  335. 'regions' => array(
  336. 'two_brick_top',
  337. 'two_brick_left_above',
  338. 'two_brick_right_above',
  339. 'two_brick_middle',
  340. 'two_brick_left_below',
  341. 'two_brick_right_below',
  342. 'two_brick_bottom',
  343. ),
  344. ),
  345. 'two_66_33' => array(
  346. 'title' => t('AT Two column 66/33'),
  347. 'regions' => array(
  348. 'two_66_33_top',
  349. 'two_66_33_first',
  350. 'two_66_33_second',
  351. 'two_66_33_bottom',
  352. ),
  353. ),
  354. 'two_33_66' => array(
  355. 'title' => t('AT Two column 33/66'),
  356. 'regions' => array(
  357. 'two_33_66_top',
  358. 'two_33_66_first',
  359. 'two_33_66_second',
  360. 'two_33_66_bottom',
  361. ),
  362. ),
  363. 'two_50' => array(
  364. 'title' => t('AT Two column 50/50'),
  365. 'regions' => array(
  366. 'two_50_top',
  367. 'two_50_first',
  368. 'two_50_second',
  369. 'two_50_bottom',
  370. ),
  371. ),
  372. 'three_inset_right' => array(
  373. 'title' => t('AT Inset right'),
  374. 'regions' => array(
  375. 'three_inset_right_sidebar',
  376. 'three_inset_right_top',
  377. 'three_inset_right_middle',
  378. 'three_inset_right_inset',
  379. 'three_inset_right_bottom',
  380. ),
  381. ),
  382. 'three_inset_left' => array(
  383. 'title' => t('AT Inset left'),
  384. 'regions' => array(
  385. 'three_inset_left_sidebar',
  386. 'three_inset_left_top',
  387. 'three_inset_left_middle',
  388. 'three_inset_left_inset',
  389. 'three_inset_left_bottom',
  390. ),
  391. ),
  392. 'three_50_25_25' => array(
  393. 'title' => t('AT Three column 50/25/25'),
  394. 'regions' => array(
  395. 'three_50_25_25_top',
  396. 'three_50_25_25_first',
  397. 'three_50_25_25_second',
  398. 'three_50_25_25_third',
  399. 'three_50_25_25_bottom',
  400. ),
  401. ),
  402. 'three_3x33' => array(
  403. 'title' => t('AT Three column 3x33'),
  404. 'regions' => array(
  405. 'three_33_top',
  406. 'three_33_first',
  407. 'three_33_second',
  408. 'three_33_third',
  409. 'three_33_bottom',
  410. ),
  411. ),
  412. 'three_25_50_25' => array(
  413. 'title' => t('AT Three column 25/50/25'),
  414. 'regions' => array(
  415. 'three_25_50_25_top',
  416. 'three_25_50_25_first',
  417. 'three_25_50_25_second',
  418. 'three_25_50_25_third',
  419. 'three_25_50_25_bottom',
  420. ),
  421. ),
  422. 'three_25_25_50' => array(
  423. 'title' => t('AT Three column 25/25/50'),
  424. 'regions' => array(
  425. 'three_25_25_50_top',
  426. 'three_25_25_50_first',
  427. 'three_25_25_50_second',
  428. 'three_25_25_50_third',
  429. 'three_25_25_50_bottom',
  430. ),
  431. ),
  432. 'four_4x25' => array(
  433. 'title' => t('AT Four column 4x25'),
  434. 'regions' => array(
  435. 'four_first',
  436. 'four_second',
  437. 'four_third',
  438. 'four_fourth',
  439. ),
  440. ),
  441. 'five_5x20' => array(
  442. 'title' => t('AT Five column 5x20'),
  443. 'regions' => array(
  444. 'five_first',
  445. 'five_second',
  446. 'five_third',
  447. 'five_fourth',
  448. 'five_fifth',
  449. ),
  450. ),
  451. 'six_6x16' => array(
  452. 'title' => t('AT Six column 6x16'),
  453. 'regions' => array(
  454. 'six_first',
  455. 'six_second',
  456. 'six_third',
  457. 'six_fourth',
  458. 'six_fifth',
  459. 'six_sixth',
  460. ),
  461. ),
  462. );
  463. }
  464. return $gpanel_regions_array;
  465. }
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.