Esempio n. 1
0
 /**
  * Creates the table rows for the pages children recursively
  *
  * @param array $children
  * @param int $depth
  * @return array
  */
 protected function createChildRows($children, $depth = 0, &$i = 0)
 {
     $rows = null;
     $childrenCount = count($children);
     $orderId = 1;
     # Keep track of the order
     foreach ($children as $child) {
         $view = $this->loadView('config/child_row.html');
         $view->assign(array('CHILD' => $child, 'DEPTH' => $depth, 'STYLE' => empty($child['children']) ? zula_odd_even($i) : 'subheading', 'PREFIX' => str_pad('- ', $depth + 1, '-', STR_PAD_LEFT), 'COUNT' => $childrenCount, 'ORDERID' => $orderId));
         ++$i;
         if (empty($child['children'])) {
             $rows .= $view->getOutput();
         } else {
             $childRow = $view->getOutput();
             $childRow .= $this->createChildRows($child['children'], $depth + 4, $i);
             $rows .= $childRow;
         }
         ++$orderId;
     }
     return $rows;
 }
Esempio n. 2
0
    /**
     * Loads the additional module content, such as table forms
     *
     * @return int
     */
    protected function loadAmc()
    {
        $amcTable = '<table>
							<thead>
								<tr>
									<th colspan="2">' . t('Additional content', I18n::_DTD) . '</th>
								</tr>
							</thead>
							<tbody>';
        $htmlLib = new Html('amcForm[%s]');
        $rowFormat = '<tr class="%1$s">
							<td>
								<dl>
									<dt>%2$s</dt>
									<dd>%3$s</dd>
								</dl>
							</td>
							<td class="confcol">%4$s</td>
						  </tr>';
        $i = 0;
        while ($amcElements = Hooks::notify('amc_form_table', Module::getLoading(), $this->formType, $this->contentUrl)) {
            if (isset($amcElements['onSuccess'])) {
                $this->successCallbacks[] = $amcElements['onSuccess'];
            }
            foreach ((array) $amcElements['inputs'] as $input) {
                if (!isset($input['required'])) {
                    $input['required'] = true;
                }
                $inputKey = 'amcForm/' . $input['args'][0];
                if ($this->_input->has('post', $inputKey)) {
                    // Attempt to get the value form the previous form if it failed
                    $input['args'][1] = $this->_input->post($inputKey);
                }
                $amcTable .= sprintf($rowFormat, zula_odd_even($i++), $input['name'], $input['desc'], call_user_func_array(array($htmlLib, $input['type']), $input['args']));
                $this->addElement($inputKey, '', $input['name'], $input['validators'], $input['required']);
            }
        }
        if ($i === 0) {
            $this->assign(array('AMC' => array('TABLE' => '')));
            return 0;
        } else {
            $amcTable .= '</tbody></table>';
            $this->assignHtml(array('AMC' => array('TABLE' => $amcTable)));
            return $i;
        }
    }