本文整理汇总了PHP中XMLElement::getNumberOfChildren方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLElement::getNumberOfChildren方法的具体用法?PHP XMLElement::getNumberOfChildren怎么用?PHP XMLElement::getNumberOfChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLElement
的用法示例。
在下文中一共展示了XMLElement::getNumberOfChildren方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: viewSuccess
protected function viewSuccess()
{
$symphonyUrl = URL . '/' . Symphony::Configuration()->get('admin-path', 'symphony');
$this->Form->setAttribute('action', $symphonyUrl);
$div = new XMLElement('div');
$div->appendChild(new XMLElement('h2', __('The floor is yours')));
$div->appendChild(new XMLElement('p', __('Thanks for taking the quick, yet epic installation journey with us. It’s now your turn to shine!')));
$this->Form->appendChild($div);
$ul = new XMLElement('ul');
foreach ($this->_params['disabled-extensions'] as $handle) {
$ul->appendChild(new XMLElement('li', '<code>' . $handle . '</code>'));
}
if ($ul->getNumberOfChildren() !== 0) {
$this->Form->appendChild(new XMLElement('p', __('Looks like the following extensions couldn’t be enabled and must be manually installed. It’s a minor setback in our otherwise prosperous future together.')));
$this->Form->appendChild($ul);
}
$this->Form->appendChild(new XMLElement('p', __('I think you and I will achieve great things together. Just one last thing: how about we remove the %s folder and secure the safety of our relationship?', array('<code>' . basename(INSTALL) . '</code>'))));
$submit = new XMLElement('div', null, array('class' => 'submit'));
$submit->appendChild(Widget::Input('submit', __('Okay, now take me to the login page'), 'submit'));
$this->Form->appendChild($submit);
}
示例2: adjustIndex
//.........这里部分代码省略.........
$idsArr = explode(',', $rule[1]);
foreach ($idsArr as $idExpr) {
$a = explode('-', trim($idExpr));
if (count($a) == 1) {
// Regular ID
$filteredIDs[] = $a[0];
} elseif (count($a) == 2) {
// Range
$from = $a[0];
$to = $a[1];
if ($to >= $from) {
for ($i = $from; $i <= $to; $i++) {
$filteredIDs[] = $i;
}
}
}
}
switch ($action) {
case 'show':
// Only show the given ids. Well that's easy:
$ids = $filteredIDs;
break;
case 'hide':
// Remove the filtered ids from the ids-array:
$ids = array_diff($ids, $filteredIDs);
break;
}
}
}
// Now, check each table row:
$newContents = new XMLElement('div', null, $context['oPage']->Contents->getAttributes());
foreach ($context['oPage']->Contents->getChildren() as $contentsChild) {
if ($contentsChild->getName() == 'form') {
$newForm = new XMLElement('form', null, $contentsChild->getAttributes());
foreach ($contentsChild->getChildren() as $formChild) {
// only show entries created by this author, or which are allowed by the filter:
if ($formChild->getName() == 'table' && ($rules['own_entries'] == 1 || $rules['use_filter'] == 1)) {
$newTable = new XMLElement('table', null, $formChild->getAttributes());
foreach ($formChild->getChildren() as $tableChild) {
if ($tableChild->getName() == 'tbody') {
$newTableBody = new XMLElement('tbody', null, $tableChild->getAttributes());
foreach ($tableChild->getChildren() as $tableRow) {
// Check the ID:
$id = explode('-', $tableRow->getAttribute('id'));
if (in_array($id[1], $ids)) {
$newTableBody->appendChild($tableRow);
}
}
$newTable->appendChild($newTableBody);
} else {
$newTable->appendChild($tableChild);
}
}
$newForm->appendChild($newTable);
} elseif ($formChild->getName() == 'div' && $formChild->getAttribute('class') == 'actions') {
// Only proceed if you can either edit or delete. Otherwise it would have much sense to have an apply-button here...
if ($rules['delete'] == 1 || $rules['edit'] == 1) {
$child = self::findChildren($formChild, 'select');
$child = $child[0];
$newSelect = new XMLElement('select', null, $child->getAttributes());
foreach ($child->getChildren() as $selectChild) {
// See if delete is allowed:
if ($selectChild->getAttribute('value') == 'delete' && $rules['delete'] == 1) {
$newSelect->appendChild($selectChild);
} elseif ($selectChild->getName() == 'optgroup' && $rules['edit'] == 1) {
// Check if the field that is edited is not a hidden field, because then editing is not allowed:
$optGroupChildren = $selectChild->getChildren();
if (!empty($optGroupChildren)) {
$value = $optGroupChildren[0]->getAttribute('value');
$a = explode('-', str_replace('toggle-', '', $value));
if (!in_array($a[0], $hiddenFields)) {
$newSelect->appendChild($selectChild);
}
}
} elseif ($selectChild->getName() == 'option' && $selectChild->getAttribute('value') != 'delete' && ($rules['edit'] == 1 || $rules['delete'] == 1)) {
$newSelect->appendChild($selectChild);
}
}
// if the new select has only one entry,
// it is the dummy entry and we can discard it
if ($newSelect->getNumberOfChildren() > 1) {
self::replaceChild($formChild, $newSelect);
$newForm->appendChild($formChild);
}
}
} else {
$newForm->appendChild($formChild);
}
}
$newContents->appendChild($newForm);
$context['oPage']->Form = $newForm;
} else {
$newContents->appendChild($contentsChild);
}
}
$context['oPage']->Contents = $newContents;
}
}
}
}