/** * Modifies URL. * * @access public * @param array $mod The array of parameters to modify, e.g. array('p' => 1) * @since 3.0 * */ function modify($mod) { if ($mod == "") { return ""; } global $_SERVER; $url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $_SERVER['QUERY_STRING'] = ZUrl::remove_qs_key($_SERVER['QUERY_STRING'], "id"); $query = explode("&", $_SERVER['QUERY_STRING']); if (!$_SERVER['QUERY_STRING']) { $queryStart = "?"; } else { $queryStart = "&"; } /** modify/delete data **/ foreach ($query as $q) { @(list($key, $value) = explode("=", $q)); if (array_key_exists($key, $mod)) { if ($mod[$key]) { $url = preg_replace('/\\?' . $key . '=' . $value . '/', '?' . $key . '=' . $mod[$key], $url); $url = preg_replace('/&' . $key . '=' . $value . '/', '&' . $key . '=' . $mod[$key], $url); } else { $url = preg_replace('/&?' . $key . '=' . $value . '/', '', $url); } } } /** add new data **/ foreach ($mod as $key => $value) { if ($value && !preg_match('/' . $key . '=/', $url)) { $url .= $queryStart . $key . '=' . $value; } } return $url; }
/** * Shows the page browser control. * * @access public * @param integer $items_per_page The count of items per page. * @param integer $items_total The total count of items. * @param integer $max_pages_visible The maximum visible count of pages in browser control. * @since 3.0 * */ function control($items_per_page = 5, $items_total = 0, $max_pages_visible = 10) { global $_GET, $SANITIZER, $CONFIG; $page_selected = $SANITIZER->sanitize(@$_GET["p"]); if (empty($page_selected)) { $page_selected = 1; } $part_first = 1; $part_last = ceil($items_total / $items_per_page); if ($part_first < 1) { $part_first = 1; } if ($part_last > ceil($items_total / $items_per_page)) { $part_last = ceil($items_total / $items_per_page); } $s = ""; if ($part_last > 1) { $s .= "<table>"; $s .= "<tr>"; if ($page_selected > $part_first || $part_first > 1) { $s .= "<td nowrap><a class='color3-fore-color' style='padding-left: 4px; padding-right: 4px;' href='" . ZUrl::modify(array('p' => $page_selected - 1)) . "'><strong>" . JText::_("Previous") . "</strong></a></td>"; } for ($n = $part_first; $n <= $part_last; $n++) { if ($n < $page_selected - floor($max_pages_visible) / 2) { } else { if ($n > $page_selected + floor($max_pages_visible) / 2) { } else { if ($page_selected == $n) { $s .= "<td nowrap><a class='color3-fore-color' style='padding-left: 4px; padding-right: 4px;' href='" . ZUrl::modify(array('p' => $n)) . "'>[{$n}]</a></td>"; } else { $s .= "<td nowrap><a class='color3-fore-color' style='padding-left: 4px; padding-right: 4px;' href='" . ZUrl::modify(array('p' => $n)) . "'>{$n}</a></td>"; } } } } if ($page_selected < $part_last) { $s .= "<td nowrap><a class='color3-fore-color' style='padding-left: 4px; padding-right: 4px;' href='" . ZUrl::modify(array('p' => $page_selected + 1)) . "'><strong>" . JText::_("Next") . "</strong></a></td>"; } else { $s .= "<td nowrap> </td>"; } $s .= "</tr>"; $s .= "</table>"; } echo $s; }
/** * Shows a link to the context sensitive help topic. * * @access private * @param string $context_id The identifier of the help topic * @since 3.0 * */ function context_link($context_id) { return "<sup><small><a href='" . ZUrl::modify(array('help' => $context_id)) . "'>?</a></small></sup>"; }
public function &open($a_url) { switch (gettype($a_url)) { case 'string': $url = new ZUrl($a_url); $this->m_sheme = $url->scheme(); $this->m_address = $url->host(); $this->m_login = $url->user(); $this->m_password = $url->pass(); $this->m_database = $url->path(); $this->m_port = $url->port(); break; case 'array': if (isset($a_url['scheme'])) { $this->m_sheme = $a_url['scheme']; } if (isset($a_url['driver'])) { $this->m_sheme = $a_url['driver']; } if (isset($a_url['adapter'])) { $this->m_sheme = $a_url['adapter']; } if (isset($a_url['host'])) { $this->m_address = $a_url['host']; } if (isset($a_url['address'])) { $this->m_address = $a_url['address']; } if (isset($a_url['port'])) { $this->m_port = $a_url['port']; } if (isset($a_url['user'])) { $this->m_login = $a_url['user']; } if (isset($a_url['login'])) { $this->m_login = $a_url['login']; } if (isset($a_url['pass'])) { $this->m_password = $a_url['pass']; } if (isset($a_url['password'])) { $this->m_password = $a_url['password']; } if (isset($a_url['path'])) { $this->m_database = $a_url['path']; } if (isset($a_url['database'])) { $this->m_database = $a_url['database']; } break; case 'object': if ($a_url instanceof ZUrl) { $this->open($a_url->getData()); } else { $this->open(get_object_vars($a_url)); } return $this; } if ($this->m_sheme) { $adapter_class = 'Z' . $this->m_sheme . 'DatabaseAdapter'; $adapter = new $adapter_class($this); if (!$adapter || !$adapter instanceof ZDatabaseAdapter) { throw new ZDatabaseException('Bad ZDatabaseAdapter sheme given: ' . $this->m_sheme); } $this->setAdapter($adapter); $this->getAdapter()->connect($this->m_address, $this->m_login, $this->m_password); if ($this->m_database) { $this->m_database = str_replace('/', '', $this->m_database); $this->getAdapter()->selectDatabase($this->m_db_prefix . $this->m_database . $this->m_db_suffix); } } else { throw new ZDatabaseException('Bad scheme given ' . $this->m_sheme); } return $this; }