18 require_once SQ_CORE_PACKAGE_PATH.
'/designs/design_area/design_area.inc';
46 public function printVar($var, Array $args, $value_prefix=
'', $value_suffix=
'')
52 case 'submit_button' :
53 if ($this->_tmp[
'painting_section'] !=
'login' && $this->_tmp[
'painting_section'] !=
'logout') {
54 trigger_localised_error(
'CORE0178', E_USER_WARNING, $var, $this->
attr(
'id_name'));
59 case 'login_message' :
62 if ($this->_tmp[
'painting_section'] !=
'login') {
63 trigger_localised_error(
'CORE0179', E_USER_WARNING, $var, $this->
attr(
'id_name'));
71 $referer =
'(isset($_POST[\'SQ_LOGIN_REFERER\']) ? $_POST[\'SQ_LOGIN_REFERER\'] : (empty($_SERVER[\'HTTP_REFERER\']) ? \'\' : $_SERVER[\'HTTP_REFERER\']))';
74 case 'login_heading' :
75 echo
'<',
'?php if (!empty($GLOBALS[\'SQ_LOGIN_FORM\'])) { echo ', $this->
_escapeVar(
'$GLOBALS[\'SQ_LOGIN_FORM\'][\'heading\']', $args),
'; } ?',
'>';
78 case 'login_message' :
79 echo
'<',
'?php if (!empty($GLOBALS[\'SQ_LOGIN_FORM\'])) { echo ', $this->
_escapeVar(
'$GLOBALS[\'SQ_LOGIN_FORM\'][\'msg\']', $args),
'; } ?',
'>';
83 echo
'<',
'?php echo ', $this->
_escapeVar($referer, $args),
'; ?',
'>';
89 if ($this->
attr(
'forward_www_vars')) {
90 $qry_str_extra =
'&<'.
'?php echo htmlentities(preg_replace(\'/SQ_ACTION=[^\&]+\&?/\', \'\', $_SERVER[\'QUERY_STRING\'])); ?'.
'>';
94 if ($this->_tmp[
'painting_section'] ==
'login') {
96 <form action="<',
'?php echo $_SERVER[\'PHP_SELF\']; ?',
'>?SQ_ACTION=login'.$qry_str_extra.
'" id="'.$this->
attr(
'id_name').
'_login_prompt" method="post" onsubmit="return checkEntry();">
100 echo
'<form action="<',
'?php echo $_SERVER[\'PHP_SELF\']; ?',
'>?SQ_ACTION=logout'.$qry_str_extra.
'" id="'.$this->
attr(
'id_name').
'_login_prompt" method="post">
101 <input type="hidden" name="SQ_LOGIN_REFERER" value="<',
'?php echo htmlspecialchars('.$referer.
'); ?',
'>" />';
104 if ($this->
attr(
'forward_www_vars')) {
106 // Take all the post vars and whack em in the form - important ones are removed
107 require_once SQ_LIB_PATH.\'/html_form/html_form.inc\';
108 $'.$this->attr(
'id_name').
'_post_vars = $_POST;
109 unset($'.$this->
attr(
'id_name').
'_post_vars[\'SQ_LOGIN_USERNAME\']);
110 unset($'.$this->
attr(
'id_name').
'_post_vars[\'SQ_LOGIN_PASSWORD\']);
111 unset($'.$this->
attr(
'id_name').
'_post_vars[\'SQ_LOGIN_KEY\']);
112 unset($'.$this->
attr(
'id_name').
'_post_vars[\'SQ_LOGIN_REFERER\']);
113 unset($'.$this->
attr(
'id_name').
'_post_vars[\'SQ_ACTION\']);
114 unset($'.$this->
attr(
'id_name').
'_post_vars[\'log_in_out_button\']);
115 var_to_hidden_field($'.$this->
attr(
'id_name').
'_post_vars);
124 <script type="text/javascript"><!--
126 var loginForm = document.forms[\''.$this->attr(
'id_name').
'_login_prompt\'];
127 function checkEntry() {
128 return (loginForm.SQ_LOGIN_USERNAME.value.length > 0 && loginForm.SQ_LOGIN_PASSWORD.value.length > 0);
135 case 'system_messages' :
136 echo
'<',
'?php echo implode(\'<br />\', $GLOBALS[\'SQ_SYSTEM\']->messages()); ?',
'>';
139 case 'username_box' :
140 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
141 $extras =
'onfocus="this.select();"';
142 foreach ($args As $k => $v) {
143 if ($k ==
'size')
continue;
144 $extras .=
' '.$k.
'="'.htmlspecialchars($v).
'"';
146 echo
'<input type="hidden" name="SQ_LOGIN_KEY" value="<',
'?php echo $GLOBALS[\'SQ_SYSTEM\']->generateLoginKey(); ?',
'>" />
147 <input type="hidden" name="SQ_LOGIN_REFERER" value="<',
'?php echo htmlspecialchars('.$referer.
'); ?',
'>" />';
149 text_box(
'SQ_LOGIN_USERNAME',
'', empty($args[
'size']) ? 10 : $args[
'size'], 0, FALSE, $extras);
150 if ($this->
attr(
'give_username_focus')) {
152 <script type="text/javascript"><!--
154 var '.$this->attr(
'id_name').
'_username_box_other_onload = (window.onload) ? window.onload : new Function;
155 function set_'.$this->
attr(
'id_name').
'_username_box_focus() {
156 '.$this->
attr(
'id_name').
'_username_box_other_onload();
157 document.getElementById("'.$this->
attr(
'id_name').
'_login_prompt").elements["SQ_LOGIN_USERNAME"].focus();
159 window.onload = set_'.$this->
attr(
'id_name').
'_username_box_focus;
166 case 'password_box' :
167 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
168 $extras =
'onfocus="this.select();"';
169 foreach ($args As $k => $v) {
170 if ($k ==
'size')
continue;
171 $extras .=
' '.$k.
'="'.htmlspecialchars($v).
'"';
173 password_box(
'SQ_LOGIN_PASSWORD',
'', empty($args[
'size']) ? 10 : $args[
'size'], 0, $extras);
176 case 'submit_button' :
177 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
179 foreach ($args As $k => $v) {
180 if ($k ==
'value')
continue;
181 $extras .=
' '.$k.
'="'.htmlspecialchars($v).
'"';
183 submit_button(
'log_in_out_button', empty($args[
'value']) ? ucfirst($this->_tmp[
'painting_section']) : $args[
'value'],
'', $extras);
187 parent::printVar($var, $args);
215 if (!empty($GLOBALS[\'SQ_LOGIN_FORM\'])) {
216 $'.$this->attr(
'id_name').
'_paint_login = ($GLOBALS[\'SQ_LOGIN_FORM\'][\'paint\'] == \'login\');
218 $'.$this->
attr(
'id_name').
'_paint_login = $GLOBALS[\'SQ_SYSTEM\']->userPublic();
235 switch (array_get_index($element,
'operation')) {
236 case 'login_section':
237 $this->_tmp[
'painting_section'] =
'login';
239 if ($'.$this->attr(
'id_name').
'_paint_login) {
243 foreach ($this->
attr(
'login_contents') as $item) {
244 parent::_printContentItemCode($item);
250 $this->_tmp[
'painting_section'] =
'';
253 case 'logout_section':
254 $this->_tmp[
'painting_section'] =
'logout';
256 if (!$'.$this->attr(
'id_name').
'_paint_login) {
260 foreach ($this->
attr(
'logout_contents') as $item) {
261 parent::_printContentItemCode($item);
265 }//end logout section
267 $this->_tmp[
'painting_section'] =
'';
271 return parent::_printContentItemCode($element);
289 $res = parent::getProtectedAttrs();
290 $res[] =
'login_contents';
291 $res[] =
'logout_contents';