本文整理汇总了PHP中Nette\Utils\Html::el方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::el方法的具体用法?PHP Html::el怎么用?PHP Html::el使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Utils\Html
的用法示例。
在下文中一共展示了Html::el方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createGrid
protected function createGrid()
{
$grid = $this->createPreparedGrid();
$grid->setModel($this->getModel());
$grid->addColumnNumber('id', 'ID')->setSortable()->setFilterNumber();
$grid->addColumnText('username', 'Přihlašovací jméno')->setSortable()->setDefaultSort('asc')->setFilterText();
$grid->addColumnText('name', 'Jméno')->setSortable()->setFilterText();
$grid->addColumnText('surname', 'Příjmení')->setSortable()->setFilterText();
$grid->addColumnText('email', 'Email')->setCustomRender(function ($row) {
if (Strings::length($row->email) <= 0) {
return '';
}
return Html::el('a')->setText($row->email)->href('mailto:' . $row->email);
})->setSortable()->setFilterText()->setColumn('user.email');
$section = $grid->addColumnText('section', 'Sekce');
$this->helpers->setupAsMultirecord($section, function ($row) {
$selection = $this->sectionFacade->all();
$this->userFilter->filterId($selection, $row->id, ':user_has_section');
$selection->select("section.id,section.name");
return $selection->fetchPairs('id', 'name');
});
$role = $grid->addColumnText('role', 'Role');
$this->helpers->setupAsMultirecord($role, function ($row) {
$selection = $this->roleFacade->all();
$this->userFilter->filterId($selection, $row->id, ':user_has_role');
$selection->select("role.code,role.name");
return $selection->fetchPairs('code', 'name');
});
$this->helpers->addEditAction($grid);
$this->helpers->addDeleteEvent($grid, $this->deleteRow, function ($row) {
return $row->surname . ' ' . $row->name;
});
return $grid;
}
示例2: render
/**
* Render row item into template
* @param Row $row
* @return mixed
*/
public function render(Row $row)
{
/**
* Renderer function may be used
*/
if ($renderer = $this->getRenderer()) {
if (!$renderer->getConditionCallback()) {
return call_user_func_array($renderer->getCallback(), [$row->getItem()]);
}
if (call_user_func_array($this->getRenderer(), [$row->getItem()])) {
return call_user_func_array($renderer->getCallback(), [$row->getItem()]);
}
}
$a = Html::el('a')->href($this->grid->getPresenter()->link($this->href, $this->getItemParams($row)));
if ($this->icon) {
$a->add(Html::el('span')->class(DataGrid::$icon_prefix . $this->icon));
if (strlen($this->name)) {
$a->add(' ');
}
}
$a->add($this->name);
if ($this->title) {
$a->title($this->title);
}
if ($this->class) {
$a->class($this->class);
}
if ($confirm = $this->getConfirm($row)) {
$a->data('confirm', $confirm);
}
return $a;
}
示例3: traverse
public function traverse()
{
// roots are pages labeled by active labels
$roots = $this->getRoots();
$topLevelContainer = $this->getRenderer()->createTopLevelContainer();
// dump($this->label);
// die();
$descendantsParams = array('lang' => $this->getLang(), 'labelId' => $this->label['label_id'], 'entityConfig' => $this->getEntityConfig(), 'groupName' => $this->getGroupName(), 'searchGhosts' => $this->canSearchGhosts(), 'states' => $this->getAcceptedStates(), 'searchAllTimeZones' => $this->canSearchAllTimeZones(), 'orderDirection' => $this->getOrderDirection(), 'limit' => $this->getLimit(), 'sortingCallback' => $this->getSortingCallback());
if (!empty($roots)) {
$rel = 0;
foreach ($roots as $root) {
$descendants = $root->getDescendants($descendantsParams);
if (count($descendants) > 0) {
$horizontalLevel = 1;
$regionElement = NULL;
foreach ($descendants as $descendant) {
$firstInRegion = FALSE;
if ($descendant->_ext_region['key'] != $this->lastRegion) {
$firstInRegion = TRUE;
$this->lastRegion = $descendant->_ext_region['key'];
}
if ($firstInRegion) {
$element = \Nette\Utils\Html::el('div');
$element->class = 'region r' . $rel++;
$regionElement = $topLevelContainer->add($element);
}
$this->getRenderer()->renderMenuItem($descendant, $descendantsParams, $element, 1, $horizontalLevel++, FALSE, $firstInRegion);
}
}
}
}
return $topLevelContainer;
}
示例4: create
/**
* Formular pre editaciu udajov
* @param boolean $admin
* @param array $druh
* @return Nette\Application\UI\Form
*/
public function create($admin, $druh, $ur_reg)
{
$this->ur_reg = $ur_reg;
$form = new Form();
$form->addProtection();
$form->addGroup();
$form->addHidden('id');
$form->addHidden('id_udaje_typ');
if ($admin) {
$form->addText('nazov', 'Názov prvku:', 20, 20)->addRule(Form::MIN_LENGTH, 'Názov musí mať spoň %d znaky!', 2)->setAttribute('class', 'heading')->setRequired('Názov musí byť zadaný!');
$form->addText('comment', 'Komentár k hodnote :', 90, 255)->addRule(Form::MIN_LENGTH, 'Komentár musí mať spoň %d znaky!', 2)->setRequired('Komentár musí byť zadaný!');
} else {
$form->addHidden('nazov');
$form->addHidden('comment');
}
$form->addText('text', 'Hodnota prvku:', 90, 255)->setRequired('Hodnota prvku musí byť zadaná!');
if ($admin) {
$form->addCheckbox('spravca', ' Povolená zmena pre správcu')->setDefaultValue(1);
$form->addCheckbox("druh_null", " Hodnota druhu je NULL")->setDefaultValue(1)->addCondition(Form::EQUAL, TRUE)->toggle("druh", FALSE);
$form->addGroup()->setOption('container', Html::el('fieldset')->id("druh"));
$form->addSelect('id_druh', 'Druhová skupina pre nastavenia:', $druh)->setDefaultValue(1);
$form->setCurrentGroup(NULL);
示例5: create
/**
* @param string $name
* @param Selection $selection
* @return Grid
* @throws GridNotExistsException
*/
public function create($name, Selection $selection)
{
$className = '\\App\\AdminModule\\Grid\\' . $name;
if (!class_exists($className)) {
throw new GridNotExistsException("Grid class {$className} does not exist!");
}
if ($this->presenter === NULL) {
throw new InvalidArgumentException('Presenter must be set!');
}
/** @var Grid $grid */
$grid = new $className($this->db, $selection);
$grid->setDefaultPerPage(100);
$grid->setModel($selection)->setTranslator(new FileTranslator('cs'));
$grid->addActionHref('edit', '')->setIcon('pencil');
$grid->addActionHref('hide', 'Skrýt')->setCustomRender(function ($row) {
$icon = Html::el('i');
$button = Html::el('a')->href($this->presenter->link('hide!', $row->id))->title('Skrýt');
if (isset($row->visible)) {
$icon->class('fa fa-eye');
if ($row->visible) {
$button->class('btn btn-default btn-xs btn-mini');
} else {
$button->class('btn btn-danger btn-xs btn-mini');
}
$button->setHtml($icon);
} else {
$button->style('display: none');
}
return $button;
});
$grid->addActionHref('delete', '', 'delete!')->setIcon('times')->setConfirm('Opravdu smazat?');
return $grid;
}
示例6: __construct
public function __construct(IContainer $parent = NULL, $name = NULL)
{
parent::__construct($name, $parent);
$this->elementPrototype = Html::el('table');
// Setup table
$this->setup();
}
示例7: createComponentCarouselGrid
public function createComponentCarouselGrid($name)
{
$grid = new \Ublaboo\DataGrid\DataGrid($this, $name);
$test = $this->database->table("carousel")->order("sorted");
$grid->setDataSource($test);
$grid->setSortable(true);
$grid->addGroupAction('Smazat')->onSelect[] = [$this, 'handleDelete'];
$grid->addColumnText('title', 'dictionary.main.Title')->setRenderer(function ($item) {
if ($item->title == '') {
$title = \Nette\Utils\Html::el('a')->href('/admin/appearance/carousel-detail/' . $item->id)->setText('- nemá název - ');
} else {
$title = \Nette\Utils\Html::el('a')->href('/admin/appearance/carousel-detail/' . $item->id)->setText($item->title);
}
return $title;
});
$grid->addColumnText('test', 'dictionary.main.Image')->setRenderer(function ($item) {
if ($item->image == '') {
$fileImage = '';
} else {
$fileImage = \Nette\Utils\Html::el('img', array('style' => 'max-height: 130px;'))->src('/images/carousel/' . $item->image);
}
return $fileImage;
});
$grid->setTranslator($this->presenter->translator);
}
示例8: __construct
/**
* @param string label
*/
public function __construct($label = NULL)
{
parent::__construct($label);
$this->control->type = 'checkbox';
$this->wrapper = Nette\Utils\Html::el();
$this->setOption('type', 'checkbox');
}
示例9: getControl
function getControl()
{
// create input element
$el = parent::getControl();
$el->addAttributes(array('class' => 'form-control'));
// converts datetime value into php format
// $TODO
if ($this->multidate && is_array($this->value)) {
$pom = [];
foreach ($this->value as $v) {
if ($v !== NULL) {
array_push($pom, $v->format($this->toPhpDateTimeFormat($this->dateTimeFormat)));
}
}
$value = implode($this->multidateSeparator, $pom);
} else {
$value = $this->value ? $this->value->format($this->toPhpDateTimeFormat($this->dateTimeFormat)) : NULL;
}
$el->value = $value;
// generate field group
$group = Utils\Html::el('div')->addHtml($el);
if ($this->inline) {
$el->addAttributes(array('style' => 'display:none;'));
$group->addHtml(Utils\Html::el('div'));
} else {
$group->addHtml(Utils\Html::el('span')->class('input-group-addon')->addHtml(Utils\Html::el('span')->class($this->getIco())));
}
$group->addAttributes(['data-vojtys-forms-datepicker' => '', 'class' => 'input-group date', 'data-locale' => $this->getLanguage(), 'data-settings' => $this->getControlSettings()]);
return $group;
}
示例10: createComponentUserEventsGrid
public function createComponentUserEventsGrid($name)
{
$eventTypes = [null => null] + EventType::getOptions();
$partyTypes = [null => null] + EventParticipationType::getOptions();
$grid = new Grid($this, $name);
$grid->setModel($this->eventService->getUserEventsDataSource($this->getUser()->getIdentity()));
$grid->setPrimaryKey("id");
$grid->setTranslator($this->getTranslator());
$grid->addColumnText('title', 'eventsModule.grid.title')->setCustomRender($this->titleRender)->setTruncate(20)->setSortable()->setFilterText();
$headerTitle = $grid->getColumn('title')->headerPrototype;
$headerTitle->class[] = 'center';
$headerTitle->style["width"] = "20%";
$grid->addColumnText('eventType', "eventsModule.grid.type")->setCustomRender($this->typeRender)->setSortable()->setFilterSelect($eventTypes);
$headerType = $grid->getColumn('eventType')->headerPrototype;
$headerType->class[] = 'center';
$grid->addColumnDate('takePlaceSince', 'eventsModule.grid.takeSince', self::DATETIME_FORMAT)->setCustomRender($this->sinceRender)->setSortable();
$headerSince = $grid->getColumn('takePlaceSince')->headerPrototype;
$headerSince->class[] = 'center';
$grid->addColumnDate('takePlaceTill', 'eventsModule.grid.takeTill', self::DATETIME_FORMAT)->setCustomRender($this->tillRender)->setSortable();
$headerTill = $grid->getColumn('takePlaceTill')->headerPrototype;
$headerTill->class[] = 'center';
$grid->addColumnText("type", "eventsModule.participation.type")->setCustomRender($this->partyTypeRender)->setSortable()->setFilterSelect($partyTypes);
$headerPart = $grid->getColumn('type')->headerPrototype;
$headerPart->class[] = 'center';
$grid->addActionHref("goto", "", "goToEvent")->setIcon("eye-open")->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("eventsModule.grid.view")]));
$grid->setFilterRenderType($this->filterRenderType);
return $grid;
}
示例11: renderFormEnd
/**
* Renders form end.
*
* @return string
*/
public static function renderFormEnd(Form $form)
{
$s = '';
if (strcasecmp($form->getMethod(), 'get') === 0) {
$url = explode('?', $form->getElementPrototype()->action, 2);
if (isset($url[1])) {
foreach (preg_split('#[;&]#', $url[1]) as $param) {
$parts = explode('=', $param, 2);
$name = urldecode($parts[0]);
if (!isset($form[$name])) {
$s .= Nette\Utils\Html::el('input', array('type' => 'hidden', 'name' => $name, 'value' => urldecode($parts[1])));
}
}
}
}
foreach ($form->getComponents(true, 'Nette\\Forms\\Controls\\HiddenField') as $control) {
if (!$control->getOption('rendered')) {
$s .= $control->getControl();
}
}
if (iterator_count($form->getComponents(true, 'Nette\\Forms\\Controls\\TextInput')) < 2) {
$s .= '<!--[if IE]><input type=IEbug disabled style="display:none"><![endif]-->';
}
echo ($s ? "<div>{$s}</div>\n" : '') . $form->getElementPrototype()->endTag() . "\n";
}
示例12: registerCss
/**
* @param string $shortPath
* @return \Nette\Utils\Html
*/
public function registerCss($shortPath)
{
if (!in_array($shortPath, $this->loadedCss)) {
$this->loadedCss[] = $shortPath;
return \Nette\Utils\Html::el('link')->rel('stylesheet')->type('text/css')->href($this->resourcesDir . $shortPath);
}
}
示例13: setFooterText
/**
* @param string|Html|NULL $footerText
*/
public function setFooterText($footerText = NULL)
{
if (!$footerText instanceof Html) {
$footerText = Html::el(NULL, $footerText);
}
$this->footerText = $footerText;
}
示例14: createComponentGrid
protected function createComponentGrid($name)
{
$grid = new Grid($this, $name);
$repository = $this->database->getRepository('App\\Models\\Doctrine\\Entities\\User');
$model = new \Grido\DataSources\Doctrine($repository->createQueryBuilder('a')->addSelect('c')->innerJoin('a.country', 'c'), array('country' => 'c.title'));
// Map country column to the title of the Country entity
$grid->model = $model;
$grid->addColumnText('firstname', 'Firstname')->setFilterText()->setSuggestion();
$grid->addColumnText('surname', 'Surname')->setSortable()->setFilterText()->setSuggestion();
$grid->addColumnText('gender', 'Gender')->setSortable()->cellPrototype->class[] = 'center';
$grid->addColumnDate('birthday', 'Birthday', \Grido\Components\Columns\Date::FORMAT_TEXT)->setSortable()->setFilterDate()->setCondition($grid->birthdayFilterCondition);
$grid->getColumn('birthday')->cellPrototype->class[] = 'center';
$grid->addColumnText('country', 'Country')->setSortable()->setCustomRender(function ($item) {
$baseUri = $this->getBaseUri();
$img = Html::el('img')->src("{$baseUri}/img/flags/{$item->country_code}.gif");
return "{$img} {$item->country}";
})->setFilterText()->setSuggestion();
$grid->addColumnText('card', 'Card')->setSortable()->setColumn('cctype')->setReplacement(array('MasterCard' => Html::el('b')->setText('MasterCard')))->cellPrototype->class[] = 'center';
$grid->addColumnEmail('emailaddress', 'Email')->setSortable()->setFilterText();
$grid->getColumn('emailaddress')->cellPrototype->class[] = 'center';
$grid->addColumnText('centimeters', 'Height')->setSortable()->setFilterNumber();
$grid->getColumn('centimeters')->cellPrototype->class[] = 'center';
$grid->addFilterSelect('gender', 'Gender', array('' => '', 'female' => 'female', 'male' => 'male'));
$grid->addFilterSelect('card', 'Card', array('' => '', 'MasterCard' => 'MasterCard', 'Visa' => 'Visa'))->setColumn('cctype');
$grid->addFilterCheck('preferred', 'Only preferred girls :)')->setCondition(array(TRUE => array(array('gender', 'AND', 'centimeters'), array('= ?', '>= ?'), array('female', 170))));
$grid->addActionHref('edit', 'Edit')->setIcon('pencil');
$grid->addActionHref('delete', 'Delete')->setIcon('trash')->setConfirm(function ($item) {
return "Are you sure you want to delete {$item->firstname} {$item->surname}?";
});
$operation = array('print' => 'Print', 'delete' => 'Delete');
$grid->setOperation($operation, $this->handleOperations)->setConfirm('delete', 'Are you sure you want to delete %i items?');
$grid->filterRenderType = $this->filterRenderType;
$grid->setExport();
}
示例15: getControl
public function getControl()
{
$control = Html::el('div');
$control->id = $this->getHtmlId();
//$this->value = $this->value != null ? $this->value : $this->defaultValue;
$slider = Html::el('div');
$slider->class('slider');
$slider->{'data-min'} = $this->min;
$slider->{'data-max'} = $this->max;
$slider->{'data-value'} = $this->value;
$slider->{'data-step'} = $this->increment;
$slider->{'data-units'} = $this->units;
$slider->{'data-linkedinput'} = $this->linkedInput;
$input = Html::el('input')->type('hidden')->value($this->value / 100);
$input->name = $this->getHtmlName('value');
$input->id = $this->getHtmlId() . '-value';
$control->{'data-inputid'} = '#' . $input->id;
if (isset($this->linkedElement)) {
$slider->{'data-linkedelement'} = $this->linkedElement;
$slider->{'data-linkedproperty'} = $this->linkedProperty;
}
$valuePreview = Html::el('span');
$valuePreview->id = $this->getHtmlId() . '-preview';
$valuePreview->setText($this->value . $this->units);
$slider->{'data-previewelement'} = '#' . $valuePreview->id;
$control->add($slider);
$control->add($input);
$control->add($valuePreview);
return $control;
}