$page = Lightwork::Page(); foreach ($_PARAMS['items'] as $item) { if ($item['alignment'] == $_PARAMS['alignment']) { if (session('rank') >= $item['minrank'] && session('rank') <= $item['maxrank']) { if (isset($page['key']) && $item['key'] == $page['key']) { $item['active'] = true; } else { $item['active'] = false; } if ($item['type'] == 'link') { $item = at($item, ['name']); Template::Draw('menu/link', $item); } else { if ($item['type'] == 'label') { $item = at($item, ['name'], 'tt'); Template::Draw('menu/label', $item); } else { if ($item['type'] == 'dropdown') { $item['active'] = false; if (isset($item['subitems'])) { foreach ($item['subitems'] as $key => $subitem) { if (isset($page['key']) && $subitem['key'] == $page['key']) { $item['active'] = true; $item['subitems'][$key]['active'] = true; } else { $item['subitems'][$key]['active'] = false; } $item['subitems'][$key] = at($item['subitems'][$key], ['name']); } } $item = at($item, ['name']);
if (!$_PARAMS['justified']) { echo 'class="collapse navbar-collapse"'; } ?> > <ul class="nav <?php if ($_PARAMS['justified']) { echo 'nav-justified'; } else { echo 'navbar-nav'; } ?> "> <?php if ($_PARAMS['gototop']) { Template::Draw('menu/gototop'); } $_PARAMS['alignment'] = 'left'; Template::Load('menu/items', $_PARAMS); ?> </ul> <ul class="nav navbar-nav navbar-right"> <?php $_PARAMS['alignment'] = 'right'; Template::Load('menu/items', $_PARAMS); ?> </ul> </div> <?php if (!$_PARAMS['justified']) { echo '</div>';
} if (!is_null($_PARAMS['name'])) { echo '<span class="menu-description">' . $_PARAMS['name'] . '</span>'; } ?> <span class="caret"></span> </a> <ul class="dropdown-menu" role="menu"> <?php if (isset($_PARAMS['subitems'])) { foreach ($_PARAMS['subitems'] as $subitem) { if (session('rank') >= $subitem['minrank'] && session('rank') <= $subitem['maxrank']) { if ($subitem['type'] == 'link') { Template::Draw('menu/subitem', $subitem); } else { if ($subitem['type'] == 'divider') { Template::Draw('menu/divider'); } else { if ($subitem['type'] == 'section') { Template::Draw('menu/section', $subitem); } else { Lightwork::Log('Tried to use incompatible menu type in dropdown: ' . $subitem['type'], Lightwork::LOG_WARN); } } } } } } ?> </ul> </li>
/** * Global exit-on-error function for every handler * * This function will be called whenever one of the handlers (page, script, file, ...) is done and needs to send an error to a user. * * @param mixed $status The status for the error (404, 0, error, ...) * @param string $message The message for the error (FILE_NOT_FOUND, ACCESS_DENIED, ...) */ static function Done($status, $message = null) { if (is_int($status)) { // Check if the status is an integer... http_response_code($status); } // ...and set it as http response code if (self::$request == self::REQUEST_PAGE) { Template::Draw('errors/' . $status, ['status' => $status, 'message' => $message]); // This is a page request - include according error file using the templating engine } else { if (self::$request == self::REQUEST_SCRIPT) { global $_RESPONSE; if ($status == 'ok') { token_invalidate(); } // Invalidate the session token if everything went good set('status', $status); // Set the status in the response if ($message != null) { set('message', t($message)); } // Set the translated response message if (DEBUG) { $output = ob_get_clean(); if ($output) { set('output', $output); } } echo json_encode($_RESPONSE); // Output the json encoded response die; } else { if (self::$request == self::REQUEST_FILE) { self::Initialize($status, $message); // Reinitialize with forced error require WEB_DIR . 'index.php'; // Require the index.php in order to draw a complete page } else { if (self::$request == self::REQUEST_CRONJOB) { echo $message; // Output the message to the CLI... die($status); // ...and set a proper exit code } } } } }
/** * Function used to get a field in this form * * Will prepare the field identified by the given name (if it exists). * This function will not return anything but rather directly draw the element using the template handler. * * @param string $name The name of a field * @param string $data Optional prefill value to use for this field. Will overwrite values given on form initialization and values in database. */ function get($name, $data = null) { if (isset($this->form['fields'][$name])) { if ($this->form['fields'][$name]['array']) { if (isset($this->form['fields'][$name]['index'])) { $this->form['fields'][$name]['index']++; } else { $this->form['fields'][$name]['index'] = 0; } } else { $this->form['fields'][$name]['index'] = ''; } $field = $this->form['fields'][$name]; // Get the field $field['form_identifier'] = $this->form['identifier']; // Apply the form identifier to this field if (!is_null($data)) { $field['prefill'] = $data; } else { if (isset($this->data[$name])) { $field['prefill'] = $this->data[$name]; } else { if (!isset($field['prefill'])) { $field['prefill'] = ''; } } } // ...otherwise we will prefill it empty. $field = at($field, ['name', 'description', 'placeholder', 'prefill']); // Translate this fields name, description, placeholder and prefill using array translate Template::Draw('form/' . $field['type'], $field); // Draw the field type template } }