Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
content_type_markdown_prefs.inc
1 <?php
18 require_once SQ_LIB_PATH.'/config/prefs.inc';
19 require_once SQ_ATTRIBUTES_PATH.'/css_dimension/css_dimension.inc';
20 
33 {
34 
35  var $pref_vars = Array (
36  'SQ_MARKDOWN_SIZE' => Array(
37  'name' => 'cms_ct_markdown_pref_editor_size',
38  'description' => 'This preference allows you to change the size of the Markdown editor',
39  'default' => Array('width' => '70em', 'height' => '20em'),
40  'protected' => FALSE,
41  ),
42  );
43  var $css_dimension_width;
44  var $css_dimension_height;
45 
46 
51  function __construct($pref_file='')
52  {
53  $this->Prefs($pref_file);
54  $this->css_dimension_width = new Asset_Attribute_CSS_Dimension();
55  $this->css_dimension_height = new Asset_Attribute_CSS_Dimension();
56 
57  }//end constructor
58 
59 
70  function paintBackend(&$o, $have_lock, $pref=NULL)
71  {
72  $is_root = $GLOBALS['SQ_SYSTEM']->userRoot();
73  $is_admin = ($is_root || $GLOBALS['SQ_SYSTEM']->userSystemAdmin());
74  if (is_null($pref) || $pref == 'SQ_MARKDOWN_SIZE') {
75  if (is_null($pref)) {
76  $o->openField(translate($this->pref_vars['SQ_MARKDOWN_SIZE']['name']));
77  }
78  $markdown_size = $this->pref_vars['SQ_MARKDOWN_SIZE']['default'];
79  ?>
80  <table class="sq-backend-table" style="width: 350px;">
81  <tr>
82  <td class="sq-backend-table-header" nowrap="nowrap"><?php echo translate('width') ?></td>
83  <td class="sq-backend-table-cell" style="width: 100%;">
84  <?php
85  if ($have_lock && $is_admin) {
86  $this->css_dimension_width->paint('markdown_width', $have_lock, $markdown_size['width']);
87  } else {
88  echo $markdown_size['width'];
89  }
90  ?>
91  </td>
92  </tr>
93  <tr>
94  <td class="sq-backend-table-header" nowrap="nowrap"><?php echo translate('height') ?></td>
95  <td class="sq-backend-table-cell" style="width: 100%;">
96  <?php
97  if ($have_lock && $is_admin) {
98  $this->css_dimension_height->paint('markdown_height', $have_lock, $markdown_size['height']);
99  } else {
100  echo $markdown_size['height'];
101  }
102  ?>
103  </td>
104  </tr>
105  </table>
106  <?php
107  if (is_null($pref)) $o->closeField();
108  }//end if
109 
110  return TRUE;
111 
112  }//end paintBackend()
113 
114 
125  function processBackend($o, $have_lock, $pref=NULL)
126  {
127  $is_root = $GLOBALS['SQ_SYSTEM']->userRoot();
128  $is_admin = ($is_root || $GLOBALS['SQ_SYSTEM']->userSystemAdmin());
129  if (!$is_admin) return FALSE;
130 
131  if (isset($_POST['markdown_width']) && isset($_POST['markdown_height'])) {
132  $this->css_dimension_width->process('markdown_width');
133  $this->css_dimension_height->process('markdown_height');
134  $this->pref_vars['SQ_MARKDOWN_SIZE']['default']['width'] = $this->css_dimension_width->getContent();
135  $this->pref_vars['SQ_MARKDOWN_SIZE']['default']['height'] = $this->css_dimension_height->getContent();
136  return TRUE;
137  }
138  return FALSE;
139 
140  }//end processBackend()
141 
142 
143 }//end class
144 
145 ?>