/** * Helper function * * @param object $module * @param object $element * @param integer $level */ protected static function _process($module, $element, $level = 0) { global $warp; if ($level == 0) { $element->attr('class', 'uk-subnav'); } else { $element->addClass('level' . ($level + 1)); } foreach ($element->children('li') as $li) { // is active ? if ($active = $li->attr('data-menu-active')) { $active = ' uk-active'; } // is parent ? $ul = $li->children('ul'); $parent = $ul->length ? ' uk-parent' : null; // set class in li $li->attr('class', sprintf('level%d' . $parent . $active, $level + 1, $li->attr('data-id'))); // set class in a/span foreach ($li->children('a,span') as $child) { // set image if ($image = $li->attr('data-menu-image')) { $child->prepend('<img src="' . $image . '" alt="' . $child->text() . '" /> '); } // set icon if ($icon = $li->attr('data-menu-icon')) { $child->prepend('<i class="' . $icon . '"></i> '); } } // process submenu if ($ul->length) { self::_process($module, $ul->item(0), $level + 1); } } }
/** * Set error * * @param string $error * @param string $message * @return object */ public function error($error = '', $message = null, $verb = null) { $this->setError($error ?: self::ERROR_BAD_ARGUMENT); $this->response->element('request', $this->get('baseURL') . '/oaipmh'); if ($verb) { $this->response->attr('verb', $verb); } $this->response->end()->element('error', $message)->attr('code', $error ?: self::ERROR_BAD_ARGUMENT)->end(); return $this; }
/** * Helper function * * @param object $module * @param object $element * @param integer $level */ protected static function _process($module, $element, $level = 0) { global $warp; // get warp config $config = $warp['config']; if ($level == 0) { $element->attr('class', 'uk-subnav'); } else { $element->addClass('level' . ($level + 1)); } foreach ($element->children('li') as $li) { // is active ? if ($active = $li->attr('data-menu-active')) { $active = ' uk-active'; } // is parent ? $ul = $li->children('ul'); $parent = $ul->length ? ' uk-parent' : null; // set class in li $li->attr('class', sprintf('level%d' . $parent . $active, $level + 1, $li->attr('data-id'))); // add all options that have a name starting with 'data-' foreach ($config->get("menus." . $li->attr('data-id'), array()) as $key => $value) { if (strpos($key, 'data-') === 0) { // add an attribute named like the option itself $li->attr($key, $value); } } // set class in a/span foreach ($li->children('a,span') as $child) { // set image if ($image = $li->attr('data-menu-image')) { $child->prepend('<img class="uk-responsive-height" src="' . $image . '" alt="' . $child->text() . '" /> '); } // set icon if ($icon = $li->attr('data-menu-icon')) { $child->prepend('<i class="' . $icon . '"></i> '); } if ($subtitle = $li->attr('data-menu-subtitle')) { $child->append('<div>' . $subtitle . '</div>'); } } // process submenu if ($ul->length) { self::_process($module, $ul->item(0), $level + 1); } } }
/** * Iterates through all existing formats to match a compatible one for the provided request. * * @param object $request An instance of request. * @param string $type An overriding content type. * @return boolean Returns a compatible format name or `null` if none matched. */ public static function suitable($request, $type = null) { $formats = static::$_formats; if (func_num_args() === 1) { $type = $request->type(); } foreach ($formats as $format => $definition) { if (!in_array($type, $definition['type'], true)) { continue; } foreach ($definition['conditions'] as $key => $value) { switch (true) { case strpos($key, ':'): if ($request->attr($key) !== $value) { continue 2; } break; case $request->is($key) !== $value: continue 2; break; } } return $format; } }