Exemplo n.º 1
0
 /**
  * Adds the specified component to the IComponentContainer.
  * @param  IComponent
  * @param  string
  * @param  string
  * @return void
  * @throws InvalidStateException
  */
 public function addComponent(IComponent $component, $name, $insertBefore = NULL)
 {
     parent::addComponent($component, $name, $insertBefore);
     if ($this->currentGroup !== NULL && $component instanceof IFormControl) {
         $this->currentGroup->add($component);
     }
 }
Exemplo n.º 2
0
 /**
  * Data grid column constructor.
  * @param  string  textual caption of column
  * @param  int     maximum number of dislayed characters
  */
 public function __construct($caption = NULL, $maxLength = NULL)
 {
     parent::__construct();
     $this->addComponent(new ComponentContainer(), 'filters');
     $this->header = Html::el();
     $this->cell = Html::el();
     $this->caption = $caption;
     if ($maxLength !== NULL) {
         $this->maxLength = $maxLength;
     }
     $this->monitor('DataGrid');
 }
Exemplo n.º 3
0
 /**
  */
 public function __construct(IComponentContainer $parent = NULL, $name = NULL)
 {
     $this->monitor('Presenter');
     parent::__construct($parent, $name);
 }
Exemplo n.º 4
0
 function __construct(IComponentContainer $parent = NULL, $name = NULL)
 {
     $this->monitor('Nette\\Application\\Presenter');
     parent::__construct($parent, $name);
 }
Exemplo n.º 5
0
 /**
  * Create component container from description.
  *
  * @param \SimpleXMLElement $containerDescription Container description.
  * @param array $externalParams Additional attributes.
  * @return ComponentContainer
  *
  * @throws SystemException ERR_NO_CONTAINER_NAME
  */
 public static function createFromDescription(\SimpleXMLElement $containerDescription, array $externalParams = [])
 {
     $properties['tag'] = $containerDescription->getName();
     $attributes = $containerDescription->attributes();
     if (in_array($containerDescription->getName(), ['page', 'content'])) {
         $properties['name'] = $properties['tag'];
     } elseif (!isset($attributes['name'])) {
         $properties['name'] = uniqid('name_');
     }
     foreach ($attributes as $propertyName => $propertyValue) {
         $properties[(string) $propertyName] = (string) $propertyValue;
     }
     $name = $properties['name'];
     unset($properties['name']);
     $properties = array_merge($properties, $externalParams);
     $value = null;
     $containerDescriptionValue = trim((string) $containerDescription);
     if (!empty($containerDescriptionValue)) {
         $value = $containerDescriptionValue;
     }
     $result = new ComponentContainer($name, $properties, $value);
     foreach ($containerDescription as $blockDescription) {
         if ($c = ComponentManager::createBlockFromDescription($blockDescription, $externalParams)) {
             $result->add($c);
         }
     }
     return $result;
 }
Exemplo n.º 6
0
<h1>Nette\Component iterator test</h1>

<pre>
<?php 
require_once '../../Nette/loader.php';
/*use Nette\Component;*/
/*use Nette\ComponentContainer;*/
/*use Nette\Forms\Button;*/
/*use Nette\Debug;*/
class ComponentX extends Component
{
}
$c = new ComponentContainer(NULL, 'top');
$c->addComponent(new ComponentContainer(), 'one');
$c->addComponent(new ComponentX(), 'two');
$c->addComponent(new Button('label'), 'button1');
$c->getComponent('one')->addComponent(new ComponentX(), 'inner');
$c->getComponent('one')->addComponent(new ComponentContainer(), 'inner2');
$c->getComponent('one')->getComponent('inner2')->addComponent(new Button('label'), 'button2');
echo "Normal:\n";
foreach ($c->getComponents() as $name => $component) {
    echo "{$name} [{$component->class}]\n";
}
echo "\n\n";
echo "Filter:\n";
foreach ($c->getComponents(FALSE, 'Nette\\Forms\\Button') as $name => $component) {
    echo "{$name} [{$component->class}]\n";
}
echo "\n\n";
echo "RecursiveIteratorIterator:\n";
foreach (new RecursiveIteratorIterator($c->getComponents(), 1) as $name => $component) {
Exemplo n.º 7
0
<h1>Nette\Forms naming container test</h1>

<?php 
require_once '../../Nette/loader.php';
/*use Nette\ComponentContainer;*/
/*use Nette\Forms\Form;*/
/*use Nette\Forms\TextInput;*/
/*use Nette\Forms\FormContainer;*/
/*use Nette\Debug;*/
Debug::enable();
$form = new Form();
$form->addText('name', 'Your name:', 35);
$sub = new ComponentContainer($form, 'container');
$sub->addComponent(new TextInput('First line'), 'text1');
$sub->addComponent(new TextInput('Second line'), 'text2');
$sub->addComponent($sub2 = new FormContainer(), 'formCont');
$sub2->addText('name', 'Your name:', 35);
$sub2->addText('age', 'Your age:', 5);
$sub = $form->addContainer('firstperson');
$sub->addText('name', 'Your name:', 35);
$sub->addText('age', 'Your age:', 5);
$sub = $form->addContainer('secondperson');
$sub->addText('name', 'Your name:', 35);
$sub->addText('age', 'Your age:', 5);
$sub->addFile('avatar', 'Picture:');
$form->addText('age', 'Your age:', 5);
$form->addSubmit('submit1', 'Send');
$_SERVER['REQUEST_METHOD'] = 'POST';
$_POST = array('name' => 'jim', 'text1' => 'hello', 'text2' => 'world', 'formCont' => array('name' => 'jack x\\\\y o\\\'connor', 'age' => '23'), 'firstperson' => array('name' => 'david', 'age' => '30'), 'secondperson' => array('name' => 'jim', 'age' => '40'), 'age' => '50');
$_FILES = array('secondperson' => array('name' => array('avatar' => 'license.txt'), 'type' => array('avatar' => 'text/plain'), 'tmp_name' => array('avatar' => 'C:\\PHP\\temp\\php1D5C.tmp'), 'error' => array('avatar' => 0), 'size' => array('avatar' => 3013)));
echo "Submitted?\n";
Exemplo n.º 8
0
$button1->setAttribute('id', 'newbutton');
$button1->setAttribute('value', 'New');
$button1->setAttribute('onclick', "javascript:window.location.href='index.php?op=adduser'");
$button2 =& $form->addElement('submit');
$button2->setAttribute('id', 'deletebutton');
$button2->setAttribute('value', 'Delete');
$button2->setAttribute('class', 'warn');
$button3 =& $form->addElement('backbutton');
$form_op =& $form->addElement('hidden');
$form_op->setAttribute('id', 'op');
$form_op->setAttribute('value', 'deleteuser');
$formcontroller = new FormController($form);
$arr_form = $formcontroller->toTemplate();
//print_r($arr_form);
$smarty->assign("data", $arr_data);
$smarty->assign("form", $arr_form);
$container = new ComponentContainer();
$pager =& $container->addElement('pager');
$pager->id = 'pager';
$pager->uri =& $uri;
$pager->current_page = $curr_page;
$pager->total_pages = $lastpageno;
$controller = new ComponentController($container);
$arr_component = $controller->toTemplate();
//print_r($arr_component);
$smarty->assign("component", $arr_component);
$smarty->assign('OOO_APP_WEB_JS', OOO_APP_WEB_JS);
$smarty->assign('current_tab', $op);
$smarty->assign('page_title', 'Users Admin');
$smarty->assign('maincontent', 'user_list.html');
$smarty->display($view);