本文整理汇总了PHP中Widget类的典型用法代码示例。如果您正苦于以下问题:PHP Widget类的具体用法?PHP Widget怎么用?PHP Widget使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Widget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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']);
}
示例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;
}
示例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;
}
示例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
}
示例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);
}
}
示例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'));
}
示例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;
}
示例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();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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);
}
示例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');
}
}