/** inheritdoc */ public static function displayForm($value, &$settings, $model) { $class = get_called_class(); $settings = static::settings($settings); $include_label = isset($settings['label']) ? $settings['label'] : true; $required = isset($settings['required']) ? $settings['required'] : false; $errors = $model->getErrorsForField($settings['mapping']['fieldName']); $has_errors = count($errors) > 0; $input_attributes = isset($settings['input_attributes']) ? $settings['input_attributes'] : array('class' => 'input-xxlarge form-control'); if (!isset($input_attributes['id'])) { $input_attributes['id'] = 'form_' . $settings['mapping']['fieldName']; } $attributes = array('class' => 'controls control-group' . ($has_errors ? ' error' : '') . ' field-type-' . $class::type($settings)); $label_text = $settings['title'] . ($required ? ' *' : ''); // Build the input $input = '<input type="text" name="' . $settings['mapping']['fieldName'] . '" ' . array_to_attr($input_attributes) . ' value="' . \Security::htmlentities(strval($value), ENT_QUOTES) . '" />'; // Build the label $label = !$include_label ? '' : \Form::label($label_text . ($has_errors ? ' - ' . $errors[0] : ''), $settings['mapping']['fieldName'], array('class' => 'item-label')); // Wrap it in an input group $input = html_tag('div', array('class' => 'input-append'), $input . html_tag('span', array('class' => 'add-on'), ' ')); // Don't wrap the input if wrap is set to false if (isset($settings['wrap']) && $settings['wrap'] === false) { return $label . $input; } return html_tag('div', $attributes, $label . $input); }
protected function initContent() { $this->setTitle('Client'); $error = $this->getAction()->getError(); $data = $this->getAction()->getData(); $html = ''; if ($error) { $html .= html_tag('div', array('class' => 'alert alert-error'), $error['info']); } if (!isset($data['info'])) { return $html; } $info = $data['info']; $displayInfo = $info['uaData']['displayInfo']; $this->setSubTitle('#' . $info['id']); $html .= '<h3>Information</h3>' . '<div class="row">' . '<div class="span2">' . BrowserInfo::buildIconHtml($displayInfo) . '</div>' . '<div class="span10">' . '<table class="table table-striped">' . '<tbody>' . '<tr><th>Name</th><td>' . html_tag('a', array('href' => $info['viewUrl']), $info['name']) . '</td></tr>' . '<tr><th>UA ID</th><td>' . '<code>' . htmlspecialchars($info['uaID']) . '</code>' . '<tr><th>User-Agent</th><td>' . '<tt>' . htmlspecialchars($info['uaRaw']) . '</tt>' . '</td></tr>' . '<tr><th>Session age</th><td>' . number_format(intval($info['sessionAge'])) . 's' . '</td></tr>' . '<tr><th>Connected</th><td>' . self::getPrettyDateHtml($info, 'connected') . '</td></tr>' . '<tr><th>Last ping</th><td>' . self::getPrettyDateHtml($info, 'pinged') . '</td></tr>' . '</tbody></table>' . '</div>' . '</div>'; $html .= '<h3>Log</h3>'; if (!$data['results']) { $html .= '<div class="alert alert-info">Client has no run log.</div>'; } else { $html .= '<table class="table table-striped">' . '<thead><tr><th>Result</th><th>Project</th></th><th>Run</th><th>Status</th>' . '<tbody>'; foreach ($data['results'] as $run) { $html .= '<tr>' . '<td>' . html_tag('a', array('href' => $run['viewUrl']), '#' . $run['id']) . '</td>' . '<td>' . ($run['project'] ? html_tag('a', array('href' => $run['project']['viewUrl']), $run['project']['display_title']) : '-') . '</td>' . '<td>' . ($run['job'] && $run['run'] ? html_tag('a', array('href' => $run['job']['viewUrl']), $run['job']['nameText'] . ' / ' . $run['run']['name']) : '<em>Job has been deleted</em>') . '</td>' . JobPage::getJobStatusHtmlCell($run['status']) . '</tr>'; } $html .= '</tbody></table>'; } return $html; }
/** * Renders the field's form element for editing in the admin site */ public static function displayForm($value, &$settings, $model) { $class = get_called_class(); $settings = static::settings($settings); $include_label = isset($settings['label']) ? $settings['label'] : true; $required = isset($settings['required']) ? $settings['required'] : false; $errors = $model->getErrorsForField($settings['mapping']['fieldName']); $has_errors = count($errors) > 0; $input_attributes = isset($settings['input_attributes']) ? $settings['input_attributes'] : array('class' => 'input-xxlarge'); if (!isset($input_attributes['id'])) { $input_attributes['id'] = 'form_' . $settings['mapping']['fieldName']; } $attributes = array('class' => 'controls control-group' . ($has_errors ? ' error' : '') . ' field-type-' . $class::type($settings)); $label_text = $settings['title'] . ($required ? ' *' : ''); if (empty($value)) { $value = substr(\Security::generate_token(), 0, 16); } // Description? $description = isset($settings['description']) ? '<span class="help-block">' . $settings['description'] . '</span>' : ''; // Build the input $input = '<input type="text" name="' . $settings['mapping']['fieldName'] . '" ' . array_to_attr($input_attributes) . ' value="' . \Security::htmlentities(strval($value), ENT_QUOTES) . '" />'; // Build the label $label = !$include_label ? '' : html_tag('label', array('class' => 'item-label', 'for' => $settings['mapping']['fieldName']), $label_text . ($has_errors ? ' - ' . $errors[0] : '')); // Don't wrap the input if wrap is set to false if (isset($settings['wrap']) && $settings['wrap'] === false) { return $label . $input; } return html_tag('div', $attributes, $label . $description . $input); }
protected function initContent() { $request = $this->getContext()->getRequest(); $this->setTitle("Job name"); if ($request->getSessionData("auth") !== "yes") { $html = html_tag("div", array("class" => "alert alert-error"), "You must be authenticated in order to add a job."); return $html; } $this->bodyScripts[] = swarmpath("js/AddDevBoxJob.js"); $this->bodyScripts[] = swarmpath("js/bootstrap-tooltip.js"); $this->bodyScripts[] = swarmpath("js/bootstrap-popover.js"); $this->bodyScripts[] = swarmpath("js/bootstrap-button.js"); $this->bodyScripts[] = swarmpath("js/json2.js"); $this->styleSheets[] = swarmpath("css/AddDevBoxJob.css"); $html = ""; $error = $this->getAction()->getError(); $data = $this->getAction()->getData(); if ($request->wasPosted()) { if ($error) { $html .= html_tag("div", array("class" => "alert alert-error"), $error["info"]); } elseif ($data && isset($data["id"])) { $html .= '<div class="alert alert-success">' . '<strong><a href="' . htmlspecialchars(swarmpath("job/{$data["id"]}")) . '">Job ' . $data["id"] . '</a> has been created!</strong><br>' . $data["runTotal"] . ' runs have been scheduled to be ran in ' . $data["uaTotal"] . ' different browsers.<br><br>' . '<a class="btn btn-primary btn-small" href="' . htmlspecialchars(swarmpath("job/{$data["id"]}")) . '">continue to job page »</a>' . '</div>'; } } if ($data && isset($data["id"])) { $jobId = $data["id"]; header("X-TestSwarm-JobId: {$jobId}", true); } $html .= $this->getAddjobFormHtml(); return $html; }
protected function initContent() { $request = $this->getContext()->getRequest(); $resultsID = $request->getInt('item'); $this->setTitle('Run result'); $this->setRobots('noindex,nofollow'); $this->bodyScripts[] = swarmpath('js/result.js'); $error = $this->getAction()->getError(); $data = $this->getAction()->getData(); $html = ''; if ($error) { $html .= html_tag('div', array('class' => 'alert alert-error'), $error['info']); return $html; } $this->setSubTitle('#' . $data['info']['id']); if ($data['job']) { $html = '<p><em>' . html_tag_open('a', array('href' => $data['job']['url'], 'title' => 'Back to Job #' . $data['job']['id'])) . '« Back to Job #' . $data['job']['id'] . '</a>' . '</em></p>'; } else { $html = '<p><em>Run #' . $data['info']['runID'] . ' has been deleted. Job info unavailable.</em></p>'; } if ($data['otherRuns']) { $html .= '<table class="table table-bordered swarm-results"><thead>' . JobPage::getUaHtmlHeader($data['otherRuns']['userAgents']) . '</thead><tbody>' . JobPage::getUaRunsHtmlRows($data['otherRuns']['runs'], $data['otherRuns']['userAgents']) . '</tbody></table>'; } $html .= '<h3>Information</h3>' . '<table class="table table-striped">' . '<tbody>' . '<tr><th>Run</th><td>' . ($data['job'] ? html_tag('a', array('href' => $data['job']['url']), 'Job #' . $data['job']['id']) . ' / ' : '') . 'Run #' . htmlspecialchars($data['info']['runID']) . '</td></tr>' . '<tr><th>Client</th><td>' . html_tag('a', array('href' => $data['client']['viewUrl']), 'Client #' . $data['info']['clientID']) . ' / ' . htmlspecialchars($data['client']['name']) . '</td></tr>' . '<tr><th>UA ID</th><td>' . '<code>' . htmlspecialchars($data['client']['uaID']) . '</code>' . '<tr><th>User-Agent</th><td>' . '<tt>' . htmlspecialchars($data['client']['uaRaw']) . '</tt>' . '</td></tr>' . '<tr><th>Run time</th><td>' . (isset($data['info']['runTime']) ? number_format(intval($data['info']['runTime'])) . 's' : '?') . '</td></tr>' . '<tr><th>Status</th><td>' . htmlspecialchars($data['info']['status']) . '</td></tr>' . '<tr><th>Started</th><td>' . self::getPrettyDateHtml($data['info'], 'started') . '</td></tr>' . (isset($data['info']['savedLocalFormatted']) ? '<tr><th>Saved</th><td>' . self::getPrettyDateHtml($data['info'], 'saved') . '</td></tr>' : '') . '</tbody></table>'; $html .= '<h3>Results</h3>' . '<p class="swarm-toollinks">' . html_tag('a', array('href' => swarmpath('index.php') . '?' . http_build_query(array('action' => 'result', 'item' => $data['info']['id'], 'raw' => '')), 'target' => '_blank', 'class' => 'swarm-popuplink'), 'Open in new window') . '</p>' . html_tag('iframe', array('src' => swarmpath('index.php') . '?' . http_build_query(array('action' => 'result', 'item' => $data['info']['id'], 'raw' => '')), 'width' => '100%', 'class' => 'swarm-result-frame')); return $html; }
/** @return bool: Whether the current user was found in the swarm */ public function getBrowsersOnlineHtml() { $conf = $this->getContext()->getConf(); $db = $this->getContext()->getDB(); $browserInfo = $this->getContext()->getBrowserInfo(); $data = $this->getAction()->getData(); $html = ''; $itemsPerRow = 6; $browsersHtml = '<h2>State of the Swarm</h2>'; $browserItemCount = 0; foreach ($data['userAgents'] as $uaID => $userAgent) { $isCurr = $uaID == $browserInfo->getSwarmUaID(); $displayInfo = $userAgent['data']['displayInfo']; $item = '' . '<div class="span2">' . '<div class="well well-swarm-icon' . ($isCurr ? ' alert-info' : '') . '">' . html_tag('div', array('class' => $displayInfo['class'], 'title' => $displayInfo['title'])) . '<br>' . html_tag_open('span', array('class' => 'label swarm-browsername')) . $displayInfo['labelHtml'] . '</span>' . '<br>' . html_tag('span', array('class' => 'swarm-onlineclients ' . ($userAgent["stats"]["onlineClients"] > 0 ? "badge" : ($userAgent['stats']['pendingRuns'] > 0 ? 'badge badge-important' : 'badge')), "title" => $userAgent["stats"]["onlineClients"] . ' clients online'), $userAgent["stats"]["onlineClients"]) . html_tag("span", array("class" => "swarm-pendingruns " . ($userAgent["stats"]["pendingRuns"] > 0 ? $userAgent["stats"]["onlineClients"] > 0 ? "badge badge-info" : "badge badge-warning" : "badge badge-success")), $userAgent["stats"]["pendingRuns"] . ' runs') . ($userAgent["stats"]["pendingReRuns"] > 0 ? ' ' . html_tag("span", array("class" => "swarm-pendingreruns " . ($userAgent["stats"]["onlineClients"] > 0 ? "badge badge-info" : "badge badge-warning")), $userAgent["stats"]["pendingReRuns"] . ' re-runs') : "") . '</div>' . '</div>'; // Properly close and start new rows if ($browserItemCount % $itemsPerRow === 0) { $browsersHtml .= '<div class="row">'; } $browserItemCount += 1; $browsersHtml .= $item; if ($browserItemCount % $itemsPerRow === 0) { $browsersHtml .= '</div><!--/.row -->'; } } // Close un-even items rows if ($browserItemCount % $itemsPerRow !== 0) { $browsersHtml .= '</div><!--/.row -->'; } if ($browserItemCount === 0) { $browsersHtml .= '<p><em>This swarm is empty!</em></p>'; } $html .= $browsersHtml; return $html; }
/** @inheritdoc */ public static function displayForm($value, &$settings, $model) { // No point in ever showing this field if lang isn't enabled if (!\CMF::$lang_enabled) { return ''; } \Lang::load('languages', true, 'en', true, true); $settings = static::settings($settings); $include_label = isset($settings['label']) ? $settings['label'] : true; $required = isset($settings['required']) ? $settings['required'] : false; $errors = $model->getErrorsForField($settings['mapping']['fieldName']); $has_errors = count($errors) > 0; $input_attributes = isset($settings['input_attributes']) ? $settings['input_attributes'] : array('class' => 'input-xxlarge'); if ($settings['active_only']) { $options = array_map(function ($lang) { return \Arr::get(\Lang::$lines, 'en.languages.' . $lang['code'], \Lang::get('admin.errors.language.name_not_found')); }, \CMF\Model\Language::select('item.code', 'item', 'item.code')->orderBy('item.pos', 'ASC')->where('item.visible = true')->getQuery()->getArrayResult()); } else { $options = \Arr::get(\Lang::$lines, 'en.languages', array()); } // Whether to allow an empty option if (isset($settings['mapping']['nullable']) && $settings['mapping']['nullable'] && !$required && $settings['allow_empty']) { $options = array('' => '') + $options; } $label = !$include_label ? '' : \Form::label($settings['title'] . ($required ? ' *' : '') . ($has_errors ? ' - ' . $errors[0] : ''), $settings['mapping']['fieldName'], array('class' => 'item-label')); $input = \Form::select($settings['mapping']['fieldName'], $value, $options, $input_attributes); if (isset($settings['wrap']) && $settings['wrap'] === false) { return $label . $input; } return html_tag('div', array('class' => 'controls control-group' . ($has_errors ? ' error' : '')), $label . $input); }
protected function initContent() { $request = $this->getContext()->getRequest(); $resultsID = $request->getInt('item'); $this->setTitle('Run result'); $this->setRobots('noindex,nofollow'); $this->bodyScripts[] = swarmpath('js/result.js'); $error = $this->getAction()->getError(); $data = $this->getAction()->getData(); $html = ''; if ($error) { $html .= html_tag('div', array('class' => 'alert alert-error'), $error['info']); return $html; } $this->setSubTitle('#' . $data['resultInfo']['id']); if ($data['job']) { $html = '<p><em>' . html_tag_open('a', array('href' => $data['job']['url'], 'title' => 'Back to Job #' . $data['job']['id'])) . '« Back to Job #' . $data['job']['id'] . '</a>' . '</em></p>'; } else { $html = '<p><em>Run #' . $data['resultInfo']['runID'] . ' has been deleted. Job info unavailable.</em></p>'; } if ($data['otherRuns']) { $html .= '<table class="table table-bordered swarm-results"><thead>' . JobPage::getUaHtmlHeader($data['otherRuns']['userAgents']) . '</thead><tbody>' . JobPage::getUaRunsHtmlRows($data['otherRuns']['runs'], $data['otherRuns']['userAgents']) . '</tbody></table>'; } $html .= '<h3>Information</h3>' . '<table class="table table-striped">' . '<colgroup><col class="span2"/><col/></colgroup>' . '<tbody>' . '<tr><th>Run</th><td>' . ($data['job'] ? html_tag('a', array('href' => $data['job']['url']), 'Job #' . $data['job']['id']) . ' / ' : '') . 'Run #' . htmlspecialchars($data['resultInfo']['runID']) . '</td></tr>' . '<tr><th>Client</th><td>' . html_tag('a', array('href' => $data['client']['userUrl']), $data['client']['userName']) . ' / Client #' . htmlspecialchars($data['resultInfo']['clientID']) . '</td></tr>' . ($data['client']['deviceName'] !== null ? '<tr><th>Device name</th><td>' . $data['client']['deviceName'] . ' / ' . html_tag('a', array('target' => '_blank', 'href' => 'http://wiki.blinkbox.local/wiki/index.php?profile=default&search=' . htmlspecialchars($data['client']['deviceName'])), 'search for ' . $data['client']['deviceName'] . ' on blinkbox wiki') . '</td></tr>' : '') . '<tr><th>User-Agent</th><td>' . '<code>' . htmlspecialchars($data['client']['uaID']) . '</code><br/>' . 'Raw: <br><code>' . htmlspecialchars($data['client']['userAgent']) . '</code><br/>' . html_tag('a', array('target' => '_blank', 'href' => 'http://wiki.blinkbox.local/wiki/index.php?profile=default&search=' . htmlspecialchars($data['client']['userAgent'])), 'search for this user agent on blinkbox wiki') . '</td></tr>' . '<tr><th>Run time</th><td>' . (isset($data['resultInfo']['runTime']) ? number_format(intval($data['resultInfo']['runTime'])) . 's' : '?') . '</td></tr>' . '<tr><th>Status</th><td>' . htmlspecialchars($data['resultInfo']['status']) . '</td></tr>' . '<tr><th>Total</th><td>' . htmlspecialchars($data['resultInfo']['total']) . '</td></tr>' . '<tr><th>Fail</th><td>' . htmlspecialchars($data['resultInfo']['fail']) . '</td></tr>' . '<tr><th>Error</th><td>' . htmlspecialchars($data['resultInfo']['error']) . '</td></tr>' . '<tr><th>Started</th><td>' . self::getPrettyDateHtml($data['resultInfo'], 'started') . '</td></tr>' . (isset($data['resultInfo']['savedLocalFormatted']) ? '<tr><th>Saved</th><td>' . self::getPrettyDateHtml($data['resultInfo'], 'saved') . '</td></tr>' : '') . '<tr><th>Results size</th><td>' . 'compressed: ' . self::formatBytes($data['resultInfo']['reportHtmlCompressedSize']) . ' / uncompressed: ' . self::formatBytes($data['resultInfo']['reportHtmlSize']) . ' / ratio: ' . $data['resultInfo']['reportHtmlCompressionRatio'] . '%' . '</td></tr>' . '</tbody></table>'; $html .= '<h3>Results</h3>' . '<p class="swarm-toollinks">' . html_tag('a', array('href' => swarmpath('index.php') . '?' . http_build_query(array('action' => 'result', 'item' => $data['resultInfo']['id'], 'raw' => '')), 'target' => '_blank', 'class' => 'swarm-popuplink'), 'Open in new window') . '</p>' . html_tag('iframe', array('src' => swarmpath('index.php') . '?' . http_build_query(array('action' => 'result', 'item' => $data['resultInfo']['id'], 'raw' => '')), 'width' => '100%', 'class' => 'swarm-result-frame')); return $html; }
public static function displayForm($value, &$settings, $model) { $settings = static::settings($settings); if (!is_array($value)) { $value = array(); } // Search input or $searchInput = \Form::input($settings['mapping']['fieldName'] . '[search]', null, array('class' => 'input input-xxlarge search-input', 'placeholder' => \Lang::get('admin.common.map_search_placeholder'))); $searchButton = \Form::button('mapsearch', \Lang::get('admin.verbs.search'), array('class' => 'btn btn-primary')); $searchInput = html_tag('div', array('class' => 'form form-inline search-form'), $searchInput . $searchButton); // Hidden inputs $latInput = \Form::hidden($settings['mapping']['fieldName'] . '[lat]', \Arr::get($value, 'lat'), array('class' => 'lat')); $lngInput = \Form::hidden($settings['mapping']['fieldName'] . '[lng]', \Arr::get($value, 'lng'), array('class' => 'lng')); $zoomInput = \Form::hidden($settings['mapping']['fieldName'] . '[zoom]', \Arr::get($value, 'zoom'), array('class' => 'zoom')); // Other elements $required = isset($settings['required']) ? $settings['required'] : false; $label_text = $settings['title'] . ($required ? ' *' : ''); $label = \Form::label($label_text); $mapDiv = html_tag('div', array('class' => 'map', 'id' => \Inflector::friendly_title($settings['mapping']['fieldName'], '-', true) . '-bing-map'), ' '); // Check that we have an API key if (empty($settings['api_key'])) { $content = $label . '<div class="well"><p>' . \Lang::get('admin.bing.api_key_not_set') . '</p></div>'; } else { $content = $label . $searchInput . $latInput . $lngInput . $zoomInput . $mapDiv; } $content = html_tag('div', array('class' => 'controls control-group field-type-bing-map', 'data-field-name' => $settings['mapping']['fieldName']), $content); return array('content' => $content, 'js_data' => $settings); }
/** @return bool: Whether the current user was found in the swarm */ public function getBrowsersOnlineHtml() { $conf = $this->getContext()->getConf(); $db = $this->getContext()->getDB(); $browserInfo = $this->getContext()->getBrowserInfo(); $data = $this->getAction()->getData(); $html = ''; $itemsPerRow = 6; $browsersHtml = '<h2>Browsers</h2>'; $browserItemCount = 0; foreach ($data["userAgents"] as $uaID => $userAgent) { if (!in_array($uaID, $conf->browserSets->default)) { continue; } $isCurr = $uaID == $browserInfo->getSwarmUaID(); $item = '' . '<div class="span2">' . '<div class="well well-small swarm-browseronline' . ($isCurr ? " alert-info" : "") . '">' . html_tag("img", array("src" => swarmpath("img/" . $userAgent["data"]["displayicon"] . ".sm.png"), "class" => "swarm-browsericon", "alt" => "", "title" => $userAgent["data"]["displaytitle"])) . '<br>' . html_tag("span", array("class" => "badge swarm-browsername"), $userAgent["data"]["displaytitle"]) . '<br>' . html_tag("span", array("class" => "swarm-onlineclients " . ($userAgent["stats"]["onlineClients"] > 0 ? "badge" : ($userAgent['stats']['pendingRuns'] > 0 ? 'badge badge-important' : 'badge')), "title" => $userAgent["stats"]["onlineClients"] . ' clients online'), $userAgent["stats"]["onlineClients"]) . html_tag("span", array("class" => "swarm-pendingruns " . ($userAgent["stats"]["pendingRuns"] > 0 ? $userAgent["stats"]["onlineClients"] > 0 ? "label label-info" : "label label-warning" : "label label-success")), $userAgent["stats"]["pendingRuns"] . ' pending runs') . ($userAgent["stats"]["pendingReRuns"] > 0 ? '<br>' . html_tag("span", array("class" => "swarm-pendingreruns " . ($userAgent["stats"]["onlineClients"] > 0 ? "label label-info" : "label label-warning")), $userAgent["stats"]["pendingReRuns"] . ' pending re-runs') : "") . '</div>' . '</div>'; // Properly close and start new rows if ($browserItemCount % $itemsPerRow === 0) { $browsersHtml .= '<div class="row">'; } $browserItemCount += 1; $browsersHtml .= $item; if ($browserItemCount % $itemsPerRow === 0) { $browsersHtml .= '</div><!--/.row -->'; } } // Close un-even items rows if ($browserItemCount % $itemsPerRow !== 0) { $browsersHtml .= '</div><!--/.row -->'; } $html .= $browsersHtml; return $html; }
/** * Render Header * * Renders the header of a column * * @access public * @param Spark\Grid_Column_Header Header * @return Spark\Grid_Column_Renderer_Interface */ public function render_header(\Grid_Column_Header $header) { // Build a checkbox $checkbox = \Form::checkbox(null, 1, array('targets' => ($name = $header->get_column()->get_name()) ? $name : $header->get_column()->get_identifier() . '[]')); // Set the rendered value $header->set_rendered_value(html_tag('span', array('class' => 'header-checkbox'), $checkbox)); return $this; }
/** * Generates a html title tag * * @static * @access public * @param string $content page title * @return string */ public static function title($content = '') { $title = \Config::get('app.site_name'); if (!empty($content) and is_string($content)) { $title = sprintf('%s — %s', $content, $title); } return html_tag('title', array(), $title); }
public static function get_search($class, $col, $val) { $params = array('type' => 'text', 'name' => 'list_search[' . $col . ']'); if ($val) { $params['value'] = $val; } return html_tag('input', $params); }
public function item_view() { $value = $this->item->{$this->field}; $class = str_replace('\\', '', $this->class); $id = $this->item->id ? $this->item->id : 'new'; $format = $this->def('format', false); return html_tag('input', array('value' => $value ? date($format ? $format : \Config::get('date_format', 'm/d/Y'), $value) : '', 'type' => 'text', 'class' => 'datepicker', 'name' => "item_field[{$class}][{$id}][{$this->field}]")); }
function abook_take_options() { global $abook_take_verify; echo '<tr>' . html_tag('td', _("Address Book Take:"), 'right', '', 'nowrap') . "\n" . '<td><input name="abook_take_abook_take_verify" type="checkbox"'; if (isset($abook_take_verify) && $abook_take_verify) { echo ' checked'; } echo ' /> ' . _("Try to verify addresses") . "</td></tr>\n"; }
function bug_report_options() { global $bug_report_visible; echo '<tr>' . html_tag('td', _("Bug Reports:"), 'right', '', 'nowrap') . "\n" . '<td><input name="bug_report_bug_report_visible" type=checkbox'; if ($bug_report_visible) { echo ' checked'; } echo ' /> ' . _("Show button in toolbar") . "</td></tr>\n"; }
/** * Creates an html image tag * * Sets the alt atribute to filename of it is not supplied. * * @param string the source * @param array the attributes array * @return string the image tag */ public static function img($src, $attr = array()) { if (!preg_match('#^(\\w+://)# i', $src)) { //$src = \Uri::base(false).$src; } $attr['src'] = '/gr/public/phpthumb/phpThumb.php?src=' . $src . '&w=120&h=120&zc=1'; $attr['alt'] = isset($attr['alt']) ? $attr['alt'] : pathinfo($src, PATHINFO_FILENAME); return html_tag('img', $attr); }
/** * Creates an html image tag * * Sets the alt atribute to filename of it is not supplied. * DocumentRoot 以下の絶対パスを返すように改修 * * @param string the source * @param array the attributes array * @return string the image tag */ public static function img($src, $attr = array(), $is_absolute_url = false) { if (!preg_match('#^(\\w+://)# i', $src)) { $src = Site_Util::get_media_uri($src, $is_absolute_url); } $attr['src'] = $src; $attr['alt'] = isset($attr['alt']) ? $attr['alt'] : pathinfo($src, PATHINFO_FILENAME); return html_tag('img', $attr); }
/** inheritdoc */ public static function displayForm($value, &$settings, $model) { $settings = static::settings($settings); $include_label = isset($settings['label']) ? $settings['label'] : true; $required = isset($settings['required']) ? $settings['required'] : false; $errors = $model->getErrorsForField($settings['mapping']['fieldName']); $has_errors = count($errors) > 0; // Check stylesSet URL $stylesSet = \Arr::get($settings, 'stylesSet'); if (!empty($stylesSet) && substr($stylesSet, 0, 1) == '/') { // Add an absolute URL to the start $settings['stylesSet'] = rtrim(\Uri::base(false), '/') . $stylesSet; } // Add ckeditor to the class for the field $input_attributes = isset($settings['input_attributes']) ? $settings['input_attributes'] : array('class' => 'input-xxlarge'); $input_attributes['class'] = $input_attributes['class'] . " ckeditor-cmf"; $label = !$include_label ? '' : \Form::label($settings['title'] . ($required ? ' *' : '') . ($has_errors ? ' - ' . $errors[0] : ''), $settings['mapping']['fieldName'], array('class' => 'item-label')); $input = \Form::textarea($settings['mapping']['fieldName'], strval($value), $input_attributes); // Set up required information for any links specified if (isset($settings['links']) && is_array($settings['links'])) { $links = array(); foreach ($settings['links'] as $link_type => $link) { if (!class_exists($link_type)) { continue; } $link['table_name'] = \CMF\Admin::getTableForClass($link_type); $link['singular'] = $link_type::singular(); $link['plural'] = $link_type::plural(); $link['icon'] = $link_type::icon(); $links[$link_type] = $link; } $settings['links'] = $links; } if (isset($settings['stylesSet'])) { if (file_exists(DOCROOT . ltrim($settings['stylesSet'], '/'))) { $settings['stylesSet'] = 'default:' . \Uri::base(false) . ltrim($settings['stylesSet'], '/'); } else { unset($settings['stylesSet']); } } if (isset($settings['contentsCss'])) { if (strpos($settings['contentsCss'], '.php') === false && !file_exists(DOCROOT . ltrim($settings['contentsCss'], '/'))) { unset($settings['contentsCss']); } } // Return only the field and label if no wrap is required if (isset($settings['wrap']) && $settings['wrap'] === false) { return $label . $input; } // Return the widget if (isset($settings['widget']) && $settings['widget'] === true) { return array('assets' => array(), 'content' => $input, 'widget' => true, 'widget_title' => $settings['title'], 'widget_icon' => 'align-left', 'js_data' => $settings); } // Return the normal field return array('assets' => array(), 'content' => html_tag('div', array('class' => 'control-group ' . ($has_errors ? ' error' : '')), $label . $input), 'widget' => false, 'js_data' => $settings); }
public function item_view() { $class = str_replace('\\', '', $this->class); $fieldname = "item_field[{$class}][" . ($this->item->id ? $this->item->id : 'new') . "][{$this->field}]"; $value = $this->item->{$this->field} ? $this->item->{$this->field} : ''; if ($this->def('textarea')) { return html_tag('textarea', array('name' => $fieldname, 'rows' => $this->def('rows', 20), 'cols' => $this->def('cols', 50)), $value); } return html_tag('input', array('name' => $fieldname, 'type' => 'text', 'value' => $value)); }
public function item_view() { $class = str_replace('\\', '', $this->class); $id = $this->item->id ? $this->item->id : 'new'; $args = array('type' => 'checkbox', 'name' => "item_field[{$class}][{$id}][{$this->field}]"); if ($this->item->{$this->field}) { $args['checked'] = '1'; } return html_tag('input', $args); }
/** * Add fortune options * @access private */ function fortune_options() { global $fortune_visible; echo "<tr>" . html_tag('td', _("Fortunes:"), 'right', '', 'nowrap') . "\n"; echo '<td><input name="fortune_fortune_visible" type="checkbox"'; if ($fortune_visible) { echo ' checked="checked"'; } echo " /> " . _("Show fortunes at top of mailbox") . "</td></tr>\n"; }
/** inheritdoc */ public static function displayForm($value, &$settings, $model) { $id = isset($value) ? $value->id : ''; $settings = static::settings($settings); $settings['cid'] = 'field_' . md5($settings['mapping']['fieldName'] . static::type()); $required = isset($settings['required']) ? $settings['required'] : false; $include_label = isset($settings['label']) ? $settings['label'] : true; $target_class = $settings['mapping']['targetEntity']; $target_table = \CMF\Admin::getTableForClass($target_class); $target_prop = $settings['mapping']['isOwningSide'] === true ? $settings['mapping']['inversedBy'] : $settings['mapping']['mappedBy']; if (empty($target_prop) || is_null($model->id)) { $target_prop = false; } $add_link = \Uri::create('/admin/' . $target_table . '/create?_mode=inline&_cid=' . $settings['cid'] . ($target_prop !== false ? '&' . $target_prop . '=' . $model->id : '')); $options = $target_class::options(\Arr::get($settings, 'filters', array()), array(), null, null, null, is_array($settings['select2']), \Arr::get($settings, 'group_by')); $has_controls = $settings['create'] !== false; // Description? $description = isset($settings['description']) ? '<span class="help-block">' . $settings['description'] . '</span>' : ''; if ($settings['allow_empty']) { $options = array('' => '') + $options; } $errors = $model->getErrorsForField($settings['mapping']['fieldName']); $has_errors = count($errors) > 0; $input_attributes = $settings['input_attributes']; $label = !$include_label ? '' : \Form::label($settings['title'] . ($required ? ' *' : '') . ($has_errors ? ' - ' . $errors[0] : ''), $settings['mapping']['fieldName'], array('class' => 'item-label')); $add_link = html_tag('a', array('href' => $add_link, 'class' => 'btn btn-mini btn-create'), '<i class="fa fa-plus"></i> create ' . strtolower($target_class::singular())); // Permissions $settings['can_edit'] = \CMF\Auth::can('edit', $target_class); $settings['can_create'] = \CMF\Auth::can('create', $target_class) && $settings['can_edit']; $settings['create'] = $settings['create'] && $settings['can_create']; $settings['edit'] = $settings['edit'] && $settings['can_edit']; if ($settings['create'] === false) { $add_link = " "; } $controls_top = html_tag('div', array('class' => 'controls-top'), $add_link); if (is_array($settings['select2'])) { $input_attributes['class'] .= 'input-xxlarge select2'; $input = \Form::select($settings['mapping']['fieldName'], $id, $options, $input_attributes); $settings['select2']['placeholder'] = 'click to select ' . strtolower($target_class::singular()) . '...'; $settings['select2']['target_table'] = $target_table; // Permissions $settings['select2']['create'] = $settings['create']; $settings['select2']['edit'] = $settings['edit']; if (!$required) { $settings['select2']['allowClear'] = true; } return array('content' => html_tag('div', array('class' => 'controls control-group' . ($has_controls ? ' field-with-controls' : '') . ($has_errors ? ' error' : ''), 'id' => $settings['cid']), $label . $description . $input . $controls_top) . '<div class="clear"><!-- --></div>', 'widget' => false, 'assets' => array('css' => array('/admin/assets/select2/select2.css'), 'js' => array('/admin/assets/select2/select2.min.js', '/admin/assets/js/fields/select2.js')), 'js_data' => $settings['select2']); } $input_attributes['class'] .= ' input-xxlarge'; $input = \Form::select($settings['mapping']['fieldName'], $id, $options, $input_attributes); if (isset($settings['wrap']) && $settings['wrap'] === false) { return $label . $input; } return html_tag('div', array('class' => 'controls control-group' . ($has_controls ? ' field-with-controls' : '') . ($has_errors ? ' error' : ''), 'id' => $settings['cid']), $label . $description . $input . $controls_top) . '<div class="clear"><!-- --></div>'; }
/** * Renders the field's form element for editing in the admin site * @see \Admin::getFieldSettings() * @param mixed $value The current value of the property, if there is one * @param array $settings Field settings, created through \Admin::getFieldSettings() * @param object $model The model, if it is being edited. * @return string The form control */ public static function displayForm($value, &$settings, $model) { $class = get_called_class(); $settings = static::settings($settings); $include_label = isset($settings['label']) ? $settings['label'] : true; $required = isset($settings['required']) ? $settings['required'] : false; $errors = $model->getErrorsForField($settings['mapping']['fieldName']); $has_errors = count($errors) > 0; $input_attributes = isset($settings['input_attributes']) ? $settings['input_attributes'] : array('class' => 'input-xxlarge'); $input_attributes['class'] .= ' form_' . $settings['mapping']['fieldName']; $attributes = array('class' => 'controls control-group' . ($has_errors ? ' error' : '') . ' field-type-' . $class::type($settings)); $label_text = $settings['title'] . ($required ? ' *' : ''); // Translation? if (\CMF::$lang_enabled && !\CMF::langIsDefault() && isset($settings['mapping']['columnName']) && $model->isTranslatable($settings['mapping']['columnName'])) { // If there is no translation if (!$model->hasTranslation($settings['mapping']['columnName'])) { $attributes['class'] .= ' no-translation'; $input_attributes['class'] .= ' no-translation'; $label_text = '<img class="lang-flag" src="' . \Uri::create('/admin/assets/img/lang/' . \CMF::defaultLang() . '.png') . '" /> ' . $label_text; } else { $label_text = '<img class="lang-flag" src="' . \Uri::create('/admin/assets/img/lang/' . \CMF::lang() . '.png') . '" /> ' . $label_text; } } // Description? $description = isset($settings['description']) ? '<span class="help-block">' . $settings['description'] . '</span>' : ''; // Build the input $input = '<input type="text" name="' . $settings['mapping']['fieldName'] . '[place_name]" ' . array_to_attr($input_attributes) . ' value="' . \Security::htmlentities(strval($value['place_name']), ENT_QUOTES) . '" />'; $input .= '<input type="hidden" data-ref="place-id" name="' . $settings['mapping']['fieldName'] . '[place_id]" ' . array_to_attr($input_attributes) . ' value="' . \Security::htmlentities(strval($value['place_id']), ENT_QUOTES) . '" />'; $input .= '<input type="hidden" data-ref="address_components" name="' . $settings['mapping']['fieldName'] . '[address_components]" ' . array_to_attr($input_attributes) . ' value="' . \Security::htmlentities(strval($value['address_components']), ENT_QUOTES) . '" />'; // Build the label $label = !$include_label ? '' : html_tag('label', array('class' => 'item-label', 'for' => $settings['mapping']['fieldName']), $label_text . ($has_errors ? ' - ' . $errors[0] : '')); // Prepend or append things... if (isset($settings['prepend'])) { $input = html_tag('div', array('class' => 'input-prepend'), html_tag('span', array('class' => 'add-on'), $settings['prepend']) . $input); } if (isset($settings['append'])) { $input = html_tag('div', array('class' => 'input-append'), $input . html_tag('span', array('class' => 'add-on'), $settings['append'])); } // Don't wrap the input if wrap is set to false if (isset($settings['wrap']) && $settings['wrap'] === false) { return $label . $input; } // Add the 'keep updated' control if the field has a template if (isset($settings['template']) && !empty($settings['template'])) { $attributes['class'] .= ' field-with-controls field-with-template'; $auto_update_setting = 'settings[' . $settings['mapping']['fieldName'] . '][auto_update]'; $auto_update_content = \Form::hidden($auto_update_setting, '0', array()) . html_tag('label', array('class' => 'checkbox auto-update-label'), \Form::checkbox($auto_update_setting, '1', \Arr::get($settings, 'auto_update', true), array('class' => 'auto-update')) . strtolower(\Lang::get('admin.common.auto_update'))); $auto_update = html_tag('div', array('class' => 'controls-top'), $auto_update_content); $label .= $auto_update; return array('content' => html_tag('div', $attributes, $label . $description . $input) . '<div class="clear"><!-- --></div>', 'widget' => false, 'assets' => array('js' => array('/admin/assets/js/twig.min.js', '/admin/assets/js/fields/template.js')), 'js_data' => $settings); } return html_tag('div', $attributes, $label . $description . $input); }
/** * Adds second layer of calendar links to upper menu * @return void */ function calendar_header() { global $color, $year, $day, $month; echo html_tag('table', '', '', $color[0], 'border="0" width="100%" cellspacing="0" cellpadding="2"') . html_tag('tr') . html_tag('td', '', 'left', '', 'width="100%"'); displayInternalLink("plugins/calendar/calendar.php?year={$year}&month={$month}", _("Month View"), "right"); echo " \n"; displayInternalLink("plugins/calendar/day.php?year={$year}&month={$month}&day={$day}", _("Day View"), "right"); echo " \n"; // displayInternalLink("plugins/calendar/event_create.php?year=$year&month=$month&day=$day",_("Add Event"),"right"); // echo " \n"; echo '</td></tr>'; }
protected function initContent() { $request = $this->getContext()->getRequest(); $this->setTitle("Signup"); $html = '<form action="' . swarmpath("signup") . '" method="post">' . '<fieldset>' . '<legend>Signup</legend>'; $error = $this->getAction()->getError(); if ($request->wasPosted() && $error) { $html .= html_tag('div', array('class' => 'alert alert-error'), $error['info']); } $html .= '<p>Create an account. If you already have an account you may <a href="' . swarmpath("login") . '">login here</a>.</p>' . '<label>Username: <input type="text" name="username" maxlength="255"></label><br>' . '<label>Password: <input type="password" name="password"></label><br>' . '<input type="submit" value="Signup" class="btn btn-primary">' . '</fieldset></form>'; return $html; }
/** * This function prints out an option page row. */ function print_optionpages_row($leftopt, $rightopt = false) { global $color; if ($rightopt) { $rightopt_name = html_tag('td', '<a href="' . $rightopt['url'] . '">' . $rightopt['name'] . '</a>', 'left', $color[9], 'valign="top" width="49%"'); $rightopt_desc = html_tag('td', $rightopt['desc'], 'left', $color[0], 'valign="top" width="49%"'); } else { $rightopt_name = html_tag('td', ' ', 'left', $color[4], 'valign="top" width="49%"'); $rightopt_desc = html_tag('td', ' ', 'left', $color[4], 'valign="top" width="49%"'); } echo html_tag('table', "\n" . html_tag('tr', "\n" . html_tag('td', "\n" . html_tag('table', "\n" . html_tag('tr', "\n" . html_tag('td', '<a href="' . $leftopt['url'] . '">' . $leftopt['name'] . '</a>', 'left', $color[9], 'valign="top" width="49%"') . html_tag('td', ' ', 'left', $color[4], 'valign="top" width="2%"') . "\n" . $rightopt_name) . "\n" . html_tag('tr', "\n" . html_tag('td', $leftopt['desc'], 'left', $color[0], 'valign="top" width="49%"') . html_tag('td', ' ', 'left', $color[4], 'valign="top" width="2%"') . "\n" . $rightopt_desc), '', '', 'width="100%" cellpadding="2" cellspacing="0" border="0"'), 'left', '', 'valign="top"')), '', $color[4], 'width="100%" cellpadding="0" cellspacing="5" border="0"'); }
protected function initContent() { $request = $this->getContext()->getRequest(); $this->setTitle("Login"); $html = '<form action="' . swarmpath("login") . '" method="post" class="form-horizontal">' . '<fieldset>' . '<legend>Login</legend>'; $error = $this->getAction()->getError(); if ($request->wasPosted() && $error) { $html .= html_tag('div', array('class' => 'alert alert-error'), $error['info']); } $html .= '<div class="well">' . '<p>Login for projects. Projects can only be created by swarm operators.</p>' . '<div class="control-group">' . '<label class="control-label" for="form-projectID">Project ID</label>' . '<div class="controls">' . '<input type="text" name="projectID" required id="form-projectID" value="' . htmlspecialchars($request->getVal("projectID")) . '">' . '</div>' . '</div><div class="control-group">' . '<label class="control-label" for="form-projectPassword">Project password</label>' . '<div class="controls">' . '<input type="password" name="projectPassword" required id="form-projectPassword">' . '</div>' . '</div>' . '</div><div class="form-actions">' . '<input type="submit" value="Login" class="btn btn-primary">' . '</div>'; $html .= '</fieldset></form>'; return $html; }
/** inheritdoc */ public static function displayForm($value, &$settings, $model) { $include_label = isset($settings['label']) ? $settings['label'] : true; $errors = $model->getErrorsForField($settings['mapping']['fieldName']); $has_errors = count($errors) > 0; $attributes = array('class' => 'controls control-group' . ($has_errors ? ' error' : '')); $label = !$include_label ? '' : \Form::label($settings['title'] . ($has_errors ? ' - ' . $errors[0] : ''), $settings['mapping']['fieldName']); $input = $value instanceof \CMF\Model\Base ? strval($value->display()) : strval($value); if (isset($settings['wrap']) && $settings['wrap'] === false) { return $label . $input; } return html_tag('div', $attributes, $label . $input); }
/** * Adds second layer of calendar links to upper menu * @return void */ function calendar_header() { global $color, $year, $day, $month; // FIXME: Don't echo HTML from core. This whole function should probably be moved into a template file echo html_tag('table', '', '', $color[0], 'border="0" width="100%" cellspacing="0" cellpadding="2"') . html_tag('tr') . html_tag('td', '', 'left', '', 'width="100%"'); echo makeInternalLink("plugins/calendar/calendar.php?year={$year}&month={$month}", _("Month View"), "right"); echo " \n"; echo makeInternalLink("plugins/calendar/day.php?year={$year}&month={$month}&day={$day}", _("Day View"), "right"); echo " \n"; // echo makeInternalLink("plugins/calendar/event_create.php?year=$year&month=$month&day=$day",_("Add Event"),"right"); // echo " \n"; echo '</td></tr>'; }