SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/views/ajax/add_addon.php

  1. <?php
  2. /*
  3.  * kate: tab-width 4; indent-width 4; space-indent on; word-wrap off; word-wrap-column 120;
  4.  * :tabSize=4:indentSize=4:noTabs=true:wrap=false:maxLineLen=120:mode=php:
  5.  *
  6.  * Copyright (C) 2015 Karmabunny Pty Ltd.
  7.  *
  8.  * This file is a part of SproutCMS.
  9.  *
  10.  * SproutCMS is free software: you can redistribute it and/or modify it under the terms
  11.  * of the GNU General Public License as published by the Free Software Foundation, either
  12.  * version 3 of the License, or (at your option) any later version.
  13.  *
  14.  * For more information, visit <http://getsproutcms.com>.
  15.  */
  16.  
  17. use Sprout\Helpers\Enc;
  18. ?>
  19. <style>
  20. .add-widget-list {
  21. max-height: 500px;
  22. overflow-y: auto;
  23. }
  24. .add-widget-list .widget {
  25. padding: 10px;
  26. background: #f8f8f8;
  27. margin: 15px;
  28. min-height: 32px;
  29. }
  30. .add-widget-list .button {
  31. float: right;
  32. margin-left: 20px;
  33. }
  34. .add-widget-list .na-msg {
  35. margin-top: 10px;
  36. color: #964D4D;
  37. }
  38. </style>
  39.  
  40. <script>
  41. $(document).ready(function() {
  42. $('.add-widget-list .button').click(function() {
  43. var $widget = $(this).closest('.widget');
  44. $('#wl-<?php echo Enc::js($field_name); ?>').trigger('add-widget', [$widget.attr('data-name'), $widget.find('b').text()]);
  45. $(document).trigger('close.facebox');
  46. });
  47. });
  48. </script>
  49.  
  50.  
  51. <h3>Choose addon</h3>
  52. <p>What type of addon would you like to add?</p>
  53.  
  54. <div class="add-widget-list">
  55. <?php
  56. foreach ($widgets as $row) {
  57. list($name, $eng_name, $desc, $not_available) = $row;
  58.  
  59. echo '<div data-name="', Enc::html($name), '" class="widget">';
  60.  
  61. if (!$not_available) {
  62. echo '<input type="button" class="button" value="Add this">';
  63. }
  64.  
  65. echo '<p><b>', Enc::html($eng_name), '</b></p>';
  66.  
  67. if ($desc) {
  68. echo '<div class="desc">', Enc::html($desc), '</div>';
  69. }
  70.  
  71. if ($not_available) {
  72. echo '<div class="na-msg">', Enc::html($not_available), '</div>';
  73. }
  74.  
  75. echo '</div>';
  76. echo PHP_EOL;
  77. }
  78. ?>
  79. </div>
  80.