本文整理汇总了PHP中Widget类的典型用法代码示例。如果您正苦于以下问题:PHP Widget类的具体用法?PHP Widget怎么用?PHP Widget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Widget类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param Widget $fieldWidget Field widget
* @param array $config Configuration options
* @param string $config['align'] Alignment mode, either 'left', 'right', 'top' or 'inline'
* (default: 'left')
* @param string $config['help'] Explanatory text shown as a '?' icon.
*/
public function __construct($fieldWidget, array $config = array())
{
// Allow passing positional parameters inside the config array
if (is_array($fieldWidget) && isset($fieldWidget['fieldWidget'])) {
$config = $fieldWidget;
$fieldWidget = $config['fieldWidget'];
}
$hasInputWidget = $fieldWidget instanceof InputWidget;
// Config initialization
$config = array_merge(array('align' => 'left'), $config);
// Parent constructor
parent::__construct($config);
// Properties
$this->fieldWidget = $fieldWidget;
$this->field = new Tag('div');
$this->body = new Tag($hasInputWidget ? 'label' : 'div');
if (isset($config['help'])) {
$this->help = new ButtonWidget(array('classes' => array('oo-ui-fieldLayout-help'), 'framed' => false, 'icon' => 'info', 'title' => $config['help']));
} else {
$this->help = '';
}
// Mixins
$this->mixin(new LabelElement($this, $config));
// Initialization
$this->addClasses(array('oo-ui-fieldLayout'))->appendContent($this->help, $this->body);
$this->body->addClasses(array('oo-ui-fieldLayout-body'));
$this->field->addClasses(array('oo-ui-fieldLayout-field'))->toggleClasses(array('oo-ui-fieldLayout-disable'), $this->fieldWidget->isDisabled())->appendContent($this->fieldWidget);
$this->setAlignment($config['align']);
}
开发者ID:Sedles,项目名称:WikiToLearn,代码行数:36,代码来源:FieldLayout.php
示例2: generateWidgetPosition
/**
* Guess the position of the widget relatively to the positionReference
*
* @param Widget $widget The widget to position
* @param integer $positionReference Id of the parent widget
*
* @return WidgetMap The position of the widget
*/
public function generateWidgetPosition(WidgetMap $widgetMapEntry, $widget, $widgetMap, $positionReference)
{
$position = 1;
$slotId = $widget->getSlot();
if (empty($widgetMap[$slotId])) {
$widgetMapEntry->setPosition($position);
return $widgetMapEntry;
}
$slot = $widgetMap[$slotId];
$referenceWidget = $this->em->getRepository('Victoire\\Bundle\\WidgetBundle\\Entity\\Widget')->findOneById($positionReference);
//If we added a widget just after a parent widget
//The position of the new widget is the one just after the parent widget
if ($referenceWidget && $widget->getView() !== $referenceWidget->getView()) {
$position = 1;
$widgetMapEntry->setPosition($position);
$widgetMapEntry->setPositionReference($positionReference);
} else {
foreach ($slot as $key => $_widgetMap) {
if ($_widgetMap->getWidgetId() === (int) $positionReference) {
$widgetMapEntry->setPosition($_widgetMap->getPosition() + 1);
break;
} elseif (0 === (int) $positionReference) {
$widgetMapEntry->setPosition(1);
}
}
}
return $widgetMapEntry;
}
开发者ID:Atc-it,项目名称:victoire,代码行数:36,代码来源:WidgetMapHelper.php
示例3: buildFromRow
/**
* Build storage facility object from result set row
*
* @param array $row
* @return Widget
*/
public function buildFromRow(array $row)
{
$obj = new Widget();
$obj->setId($row['id']);
$obj->setName($row['name']);
return $obj;
}
开发者ID:ryanhollister,项目名称:sf-problem1,代码行数:13,代码来源:WidgetDataMapper.class.php
示例4: page
function page()
{
global $db, $user, $session, $sites;
/*
* Lets send a test message to the logged in user
$message = new Message();
$message->to(1);
$message->from(0); //0 will be "system";
$message->setSubject('This is a second test message');
$message->setBody("This would be an actual message had this not been a test.");
$message->send();
*/
print "Set site is " . $session->current_site;
?>
<h3>Dashboard</h3>
<section id="widget-grid" class="">
<!-- row -->
<div class="row">
<article class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
<?php
$test = new Widget();
$test->setTitle('My first widget');
$action2 = array('label' => 'Test', 'url' => '/pages/user/users.php', 'class' => 'danger');
$test->setActions($action2);
$actions = array('label' => 'Users', 'subitems' => array(array('label' => 'Users2', 'url' => '/pages/user/users.php'), array('label' => 'Users3', 'url' => '/pages/user/users.php')));
$test->setActions($actions);
$test->render();
$test2 = new Widget();
$test2->setTitle('My second widget');
$headers = array('First Name', 'Last Name');
$data = $db->select('firstname,lastname')->from('users')->limit(10)->fetch();
$test2->addTable($headers, $data);
$test2->render();
print "Cookies<br>";
if (isset($_COOKIE)) {
foreach ($_COOKIE as $name => $value) {
$name = htmlspecialchars($name);
$value = htmlspecialchars($value);
echo "{$name} : {$value} <br />\n";
}
}
?>
</article>
<article class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
<?php
$test3 = new Widget();
$test3->setTitle('My third widget');
$test3->addContent("<p>Sites allowed:</p>" . $user->sites('list'));
$test3->render();
?>
</article>
</div>
</section>
<?php
}
开发者ID:Pioneer-Web-Development,项目名称:MangoV2,代码行数:58,代码来源:dashboard.php
示例5: testExchangeArray
/**
* @dataProvider getData
*/
public function testExchangeArray($data)
{
$model = new Widget();
$out = $model->exchangeArray($data);
$this->assertInternalType('array', $out);
foreach (array('id', 'name', 'description', 'sold', 'price', 'currency') as $c) {
$this->assertArrayHasKey($c, $out);
}
}
开发者ID:roderickti,项目名称:CNChallenge,代码行数:12,代码来源:WidgetTest.php
示例6: widget_create
public function widget_create($tipo)
{
$widget = new Widget();
$widget->nombre = 'Nuevo widget';
$widget->tipo = $tipo;
$widget->cuenta_id = UsuarioBackendSesion::usuario()->cuenta_id;
$widget->save();
redirect($this->input->server('HTTP_REFERER'));
}
开发者ID:chileindica,项目名称:SIMPLE,代码行数:9,代码来源:gestion.php
示例7: hookAddCustomRegexp
/**
* Add the custom regexp "dezimal" to Contao.
*/
public function hookAddCustomRegexp($strRegexp, $varValue, \Widget $objWidget)
{
if ($strRegexp == 'dezimal') {
if (!preg_match('/^\\-?\\d+(,\\d+)?$/', trim($varValue))) {
$objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['digit'], $objWidget->label));
}
return true;
}
return false;
}
开发者ID:bit3,项目名称:contao-deutsche-zahlen,代码行数:13,代码来源:DeutscheZahlen.php
示例8: let
function let(\Widget $widget)
{
$widget->getErrors()->willReturn(array());
$this->beConstructedWith($widget);
if (!class_exists('FrontendTemplate', false)) {
class_alias('spec\\Netzmacht\\Contao\\FormHelper\\FrontendTemplate', 'FrontendTemplate');
}
if (!isset($GLOBALS['TL_FFL'])) {
$GLOBALS['TL_FFL'] = array();
}
}
开发者ID:netzmacht,项目名称:contao-form-helper,代码行数:11,代码来源:ViewSpec.php
示例9: validateVotingEmailFormField
public function validateVotingEmailFormField(\Widget $objWidget, $intId)
{
if (($objForm = \FormModel::findBy('alias', str_replace('auto_', '', $intId))) !== null && $objForm->maxVoteCount) {
// check if a voting from the mail address already exists
$db = \Database::getInstance();
$objEmailCheck = $db->prepare('SELECT * FROM tl_formdata_details fdt INNER JOIN tl_formdata fd ON fdt.pid=fd.id INNER JOIN tl_form f ON fd.form=f.title WHERE fdt.ff_name=? AND fdt.value=? AND f.alias=?')->execute('email', $objWidget->value, $objForm->alias);
if ($objEmailCheck->numRows > 0 && $objEmailCheck->numRows >= $objForm->maxVoteCount) {
$objWidget->addError(sprintf($GLOBALS['TL_LANG']['email_voting']['maxVoteCount'], $objForm->maxVoteCount));
}
}
return $objWidget;
}
开发者ID:heimrichhannot,项目名称:contao-email_voting,代码行数:12,代码来源:EmailVoting.php
示例10: createWidget
protected function createWidget($widgetName, $attributes = array())
{
$o = new Widget($this);
foreach ($attributes as $aname => $avalue) {
$o->setAttribute($aname, $avalue);
}
$o->setAttribute('do', $widgetName);
if (in_array($widgetName, array('textInput', 'button', 'checkBox', 'radioButton', 'fieldsetSwitch'))) {
$this->describeWidgets[] = $o;
}
return $o;
}
开发者ID:SystemEd-Jacob,项目名称:nethgui,代码行数:12,代码来源:Renderer.php
示例11: widget
function widget($args, $instance)
{
extract($args);
$title = apply_filters('widget_title', $instance['title']);
echo $before_widget;
if ($title) {
echo $before_title . $title . $after_title;
}
$gallery = new Widget();
echo $gallery->buildGallery($instance);
echo $after_widget;
}
开发者ID:robjcordes,项目名称:nexnewwp,代码行数:12,代码来源:widget.php
示例12: positiveFloatRegExpHook
public function positiveFloatRegExpHook($strRegexp, $varValue, \Widget $objWidget)
{
if ($strRegexp == 'posfloat') {
if (strpos($varValue, ',') != false) {
$objWidget->addError($GLOBALS['TL_LANG']['ERR']['posFloat']['commaFound']);
}
if (!preg_match('/^\\d+(?:\\.\\d+)?$/', $varValue)) {
$objWidget->addError($GLOBALS['TL_LANG']['ERR']['posFloat']['noFloat']);
}
return true;
}
return false;
}
开发者ID:heimrichhannot,项目名称:contao-haste_plus,代码行数:13,代码来源:Numbers.php
示例13: addWidgets
public function addWidgets()
{
$widgets = $this->twig->getLoader()->searchTemplates('widgets/*.twig');
foreach ($widgets as $template => $name) {
$id = str_replace('/', '\\', substr($template, 1, -5));
$widget = new Widget($id, $name, $template, $this->container, $this->twig, $this->wpWrapper, $this->formManager);
if ($widget->isInternal()) {
$this->internalWidgets[$widget->id_base] = $widget;
} else {
$this->wpWrapper->registerWidget('Neochic\\Woodlets\\_Widgets\\' . $id, $widget);
}
}
}
开发者ID:neochic,项目名称:woodlets,代码行数:13,代码来源:WidgetManager.php
示例14: it_creates_a_view
function it_creates_a_view(\Widget $widget, EventDispatcher $eventDispatcher)
{
$widget->getErrors()->willReturn(array());
$eventDispatcher->dispatch(Events::CREATE_VIEW, Argument::type(self::VIEW_EVENT_CLASS))->shouldBeCalled();
$eventDispatcher->dispatch(Events::CREATE_ELEMENT, Argument::type(self::CREATE_ELEMENT_EVENT_CLASS))->will(function ($args) {
/** @var CreateElementEvent $event */
$event = $args[1];
$event->setElement(new Node('input'));
});
$eventDispatcher->dispatch(Events::PRE_GENERATE_VIEW, Argument::type(self::VIEW_EVENT_CLASS))->shouldBeCalled();
$eventDispatcher->dispatch(Events::GENERATE_VIEW, Argument::type(self::VIEW_EVENT_CLASS))->shouldBeCalled();
$this->createView($widget)->shouldBeAnInstanceOf(self::VIEW_CLASS);
}
开发者ID:netzmacht,项目名称:contao-form-helper,代码行数:13,代码来源:HelperSpec.php
示例15: executePostActionsHook
public function executePostActionsHook($strAction, \DataContainer $dc)
{
if ($strAction == FieldPalette::$strFieldpaletteRefreshAction) {
if (\Input::post('field')) {
\Controller::loadDataContainer($dc->table);
$strName = \Input::post('field');
$arrField = $GLOBALS['TL_DCA'][$dc->table]['fields'][$strName];
// Die if the field does not exist
if (!is_array($arrField)) {
header('HTTP/1.1 400 Bad Request');
die('Bad Request');
}
/** @var \Widget $strClass */
$strClass = $GLOBALS['BE_FFL'][$arrField['inputType']];
// Die if the class is not defined or inputType is not fieldpalette
if ($arrField['inputType'] != 'fieldpalette' || !class_exists($strClass)) {
header('HTTP/1.1 400 Bad Request');
die('Bad Request');
}
$arrData = \Widget::getAttributesFromDca($arrField, $strName, $dc->activeRecord->{$strName}, $strName, $dc->table, $dc);
/** @var \Widget $objWidget */
$objWidget = new $strClass($arrData);
$objWidget->currentRecord = $dc->id;
die(json_encode(array('field' => $strName, 'target' => '#ctrl_' . $strName, 'content' => $objWidget->generate())));
}
header('HTTP/1.1 400 Bad Request');
die('Bad Request');
}
}
开发者ID:heimrichhannot,项目名称:contao-fieldpalette,代码行数:29,代码来源:FieldPaletteHooks.php
示例16: view
function view()
{
$this->_Parent->Page->addStylesheetToHead(URL . '/extensions/members/assets/styles.css', 'screen', 70);
$create_button = Widget::Anchor('Create a New Role', extension_members::baseURL() . 'new/', 'Create a new role', 'create button');
$this->setPageType('table');
$this->appendSubheading('Member Roles ' . $create_button->generate(false));
$aTableHead = array(array('Name', 'col'), array('Members', 'col'));
$roles = $this->_driver->fetchRoles();
$aTableBody = array();
if (!is_array($roles) || empty($roles)) {
$aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None Found.'), 'inactive', NULL, count($aTableHead)))));
} else {
$sectionManager = new SectionManager($this->_Parent);
$section = $sectionManager->fetch($this->_Parent->Database->fetchVar('parent_section', 0, "SELECT `parent_section` FROM `tbl_fields` WHERE `id` = '" . $this->_driver->usernameAndPasswordField() . "' LIMIT 1"));
$bEven = true;
$role_field_name = $this->_Parent->Database->fetchVar('element_name', 0, "SELECT `element_name` FROM `tbl_fields` WHERE `id` = '" . $this->_driver->roleField() . "' LIMIT 1");
foreach ($roles as $role) {
$member_count = $this->_Parent->Database->fetchVar('count', 0, "SELECT COUNT(*) AS `count` FROM `tbl_entries_data_" . $this->_driver->roleField() . "` WHERE `role_id` = '" . $role->id() . "'");
## Setup each cell
$td1 = Widget::TableData(Widget::Anchor($role->name(), extension_members::baseURL() . 'edit/' . $role->id() . '/', NULL, 'content'));
$td2 = Widget::TableData(Widget::Anchor("{$member_count}", URL . '/symphony/publish/' . $section->get('handle') . '/?filter=' . $role_field_name . ':' . $role->id()));
## Add a row to the body array, assigning each cell to the row
$aTableBody[] = Widget::TableRow(array($td1, $td2), $bEven ? 'odd' : NULL);
$bEven = !$bEven;
}
}
$table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody));
$this->Form->appendChild($table);
}
开发者ID:bauhouse,项目名称:sym-spectrum-members,代码行数:29,代码来源:content.roles.php
示例17: view
public function view(SymphonyDOMElement $wrapper, MessageStack $errors)
{
$layout = new Layout();
$left = $layout->createColumn(Layout::SMALL);
$right = $layout->createColumn(Layout::LARGE);
// Essentials --------------------------------------------------------
$fieldset = Widget::Fieldset(__('Essentials'));
// Name:
$label = Widget::Label(__('Name'));
$input = Widget::Input('fields[about][name]', General::sanitize($this->about()->name));
$label->appendChild($input);
if (isset($errors->{'about::name'})) {
$label = Widget::wrapFormElementWithError($label, $errors->{'about::name'});
}
$fieldset->appendChild($label);
$left->appendChild($fieldset);
$fieldset = Widget::Fieldset(__('Content'));
$label = Widget::Label(__('Source XML'));
$input = Widget::Textarea('fields[xml]', $this->parameters()->{'xml'}, array('rows' => '24', 'cols' => '50', 'class' => 'code'));
$label->appendChild($input);
if (isset($errors->{'xml'})) {
$label = Widget::wrapFormElementWithError($label, $errors->{'xml'});
}
$fieldset->appendChild($label);
$right->appendChild($fieldset);
$layout->appendTo($wrapper);
}
开发者ID:brendo,项目名称:symphony-3,代码行数:27,代码来源:class.datasource.php
示例18: __construct
/**
* Constructor
*
*/
function __construct()
{
// Call the Widget constructor
parent::__construct();
// Create a instance to CI
$CI =& get_instance();
}
开发者ID:BsWiM,项目名称:The-Clan-CMS-Project,代码行数:11,代码来源:polls_widget.php
示例19: displaySettingsPanel
public function displaySettingsPanel(&$wrapper, $errors = NULL)
{
parent::displaySettingsPanel($wrapper, $errors);
$sectionManager = new SectionManager($this->_engine);
$sections = $sectionManager->fetch(NULL, 'ASC', 'sortorder');
$options = array();
// iterate over sections to build list of fields
if (is_array($sections) && !empty($sections)) {
foreach ($sections as $section) {
$section_fields = $section->fetchFields();
if (!is_array($section_fields)) {
continue;
}
$fields = array();
foreach ($section_fields as $f) {
// only show select box link fields
if ($f->get('type') == 'selectbox_link') {
$fields[] = array($f->get('id'), $this->get('related_sbl_id') == $f->get('id'), $f->get('label'));
}
}
if (!empty($fields)) {
$options[] = array('label' => $section->get('name'), 'options' => $fields);
}
}
}
$group = new XMLElement('div', NULL, array('class' => 'group'));
$label = Widget::Label(__('Child Select Box Link'));
$label->appendChild(Widget::Select('fields[' . $this->get('sortorder') . '][related_sbl_id]', $options));
if (isset($errors['related_sbl_id'])) {
$group->appendChild(Widget::wrapFormElementWithError($label, $errors['related_sbl_id']));
} else {
$group->appendChild($label);
}
$wrapper->appendChild($group);
}
开发者ID:nickdunn,项目名称:member_replies,代码行数:35,代码来源:field.member_replies.php
示例20: renderFile
/**
* renderFile
* 重写renderFile.可以自由组合参数进行模板输出
* @param string $templateFile
* @param string $var
* @param string $charset
* @access protected
* @return maxed
*/
protected function renderFile($templateFile = '', $var = '', $charset = 'utf-8')
{
//if( empty( $var ) ){
//$var = $this->tVar;
//}
return parent::renderFile($templateFile . 'Widget', $var, $charset);
}
开发者ID:wangping1987,项目名称:dhfriendluck,代码行数:16,代码来源:OddReplayWidget.class.php
注:本文中的Widget类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论