本文整理汇总了PHP中generateUrl函数的典型用法代码示例。如果您正苦于以下问题:PHP generateUrl函数的具体用法?PHP generateUrl怎么用?PHP generateUrl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了generateUrl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: extractRedirect
function extractRedirect()
{
if (isset($_POST['redirect'])) {
return $_POST['redirect'];
}
$redirect = isset($_GET['redirect']) ? $_GET['redirect'] : '';
$redirect = trim($redirect);
if (strlen($redirect) < 1) {
return '';
}
if (strpos($redirect, '#') || strpos($redirect, '&')) {
return $redirect;
}
if (strpos($redirect, '?') === FALSE) {
return urldecode($redirect);
}
$params = array();
$excluded = array('login', 'logout', 'sid', 'redirect', 'login_success');
foreach ($_GET as $k => $v) {
$k = strtolower($k);
if (in_array($k, $excluded) || in_array($v, $excluded)) {
continue;
}
$params[$k] = $v;
}
return generateUrl(urldecode($redirect), $params);
}
示例2: modifierAction
public function modifierAction($id)
{
if ($id === null) {
throw NotFoundHttpException('Article non trouvé ');
}
$message = '';
// entity
$em = $this->getDoctrine()->getManager();
// objet
$article = $em->getRepository('BlogBundle:Article')->find($id);
//$article = new Article();
//form
$form = $this->createForm(new ArticleType(), $article);
$request = $this->get('request');
// condition de validation
if ($request->getMethod() == 'POST') {
// lier le formulaire et la requete
$form->bind($request);
// vérification de la validité des données
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($article);
$em->flush();
$message = 'Article bien enrégistré';
return $this->redirect(generateUrl('BlogBundle:Blog:ajouter.html.twig', array('message' => $message, 'form' => $form->createView(), 'article' => $article)));
}
}
return $this->render('BlogBundle:Blog:modifier.html.twig', array('article' => $article, 'form' => $form->createView()));
}
示例3: generateUrl
/**
* generate a valid and not taken URL
* @return string $url if success, call generateUrl (recursif) if url taken
*/
function generateUrl($pdo, $length = 5, $try = 0)
{
// generate a <20 characters (numerical and alphabetical) string, not present in the DB ex: ajf63
if ($try > $length * $length) {
$length += 1;
$try = 0;
}
$pool = 'abcdefghijklmnopqrstuvwxyz0123456789';
$url = '';
for ($i = 0; $i < $length; $i++) {
$url .= $pool[rand(0, strlen($pool) - 1)];
}
try {
$stmt = $pdo->prepare("SELECT id from note where id = :url");
$stmt->bindParam(':url', $url);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
throw $e->getMessage();
}
if (empty($result)) {
// la requete n'a rien renvoyé donc url pas prise
return $url;
} else {
generateUrl($length, $try + 1);
}
}
示例4: testGenerateUrl
public function testGenerateUrl()
{
// null value
$this->assertEquals(generateUrl(), 'index.php');
// empty value
$this->assertEquals(generateUrl(''), 'index.php');
// credible value
$this->assertEquals(generateUrl("abcd"), 'index.php?p=abcd');
}
示例5: LoadInlineMenu
/**
* @return array
*/
function LoadInlineMenu($SqlConnection, $PageID)
{
$sql = "SELECT inlinemenu_html, inlinemenu_image, inlinemenu_image_thumb, inlinemenu_image_title\r\n\t\t\t\tFROM " . DB_PREFIX . "inlinemenu\r\n\t\t\t\tWHERE page_id = {$PageID}";
$inlinemenu_result = $SqlConnection->SqlQuery($sql);
$replacements = array();
if ($inlinemenu = mysql_fetch_object($inlinemenu_result)) {
if ($inlinemenu->inlinemenu_html != '' || $inlinemenu->inlinemenu_image_thumb != '') {
$replacements['INLINEMENU_TEXT'] = $inlinemenu->inlinemenu_html;
$imageString = '';
if (file_exists($inlinemenu->inlinemenu_image_thumb)) {
list($imageWidth, $imageHeight) = getimagesize($inlinemenu->inlinemenu_image_thumb);
$imageString = "<div class=\"thumb\">\r\n\t<img width=\"{$imageWidth}\" height=\"{$imageHeight}\"src=\"" . generateUrl($inlinemenu->inlinemenu_image_thumb) . "\" title=\"{$inlinemenu->inlinemenu_image_title}\" alt=\"{$inlinemenu->inlinemenu_image_title}\" />\r\n\t<div class=\"description\" title=\"{$inlinemenu->inlinemenu_image_title}\">\r\n\t\t<div class=\"magnify\">\r\n\t\t\t<a href=\"special.php?page=image&file=" . generateUrl(basename($inlinemenu->inlinemenu_image)) . "\" title=\"vergrößern\">\r\n\t\t\t\t<img src=\"img/magnify.png\" title=\"vergrößern\" alt=\"vergrößern\"/>\r\n\t\t\t</a>\r\n\t\t</div>{$inlinemenu->inlinemenu_image_title}\r\n\t</div>\r\n</div>";
}
$replacements['INLINEMENU_IMAGE'] = $imageString;
}
}
return $replacements;
}
示例6: GetPostOrGet
$text = 'Die Seite wurde leider gelöscht. <br />
Falls die Seite dennoch da sein müsste, melden sie sich bitte beim Seitenbetreiber.';
break;
case 'image':
$imageID = GetPostOrGet('id');
$imageFile = GetPostOrGet('file');
if (is_numeric($imageID) || !empty($imageFile)) {
$title = 'Bild';
$condition = 'file_id = ' . $imageID;
if (empty($imageID)) {
$condition = "file_name = '{$imageFile}'";
}
$sql = "SELECT *\r\n\t\t\t\t\tFROM " . DB_PREFIX . "files\r\n\t\t\t\t\tWHERE {$condition}\r\n\t\t\t\t\tLIMIT 1";
$imageResult = $sqlConnection->SqlQuery($sql);
if ($imageData = mysql_fetch_object($imageResult)) {
$text = "<img src=\"" . generateUrl($imageData->file_path) . "\" class=\"pureimage\"/>";
}
}
break;
case 'module':
// Get the name of Module to show
$moduleName = GetPostOrGet('moduleName');
if (file_exists('./modules/' . $moduleName . '/' . $moduleName . '_module.php')) {
include_once './modules/' . $moduleName . '/' . $moduleName . '_module.php';
}
// If the menu is activated it's class should be created
// check if the module-class is already created
if (!isset(${$moduleName})) {
// is the module-class available?
if (class_exists('Module_' . $moduleName)) {
// create a link to the initialisation-function for the module-class
示例7: editerAction
public function editerAction($id = null)
{
// vérification de la validité de l'id
if (!isset($id)) {
//on crée un nouvel acteur
$acteur = new Acteur();
// l'id est null: soit c'est un formulaire vide soit elle a des requete
$em = $this->getDoctrine()->getManager();
//On exécute l'ajout de formulaire
$form = $this->createForm(new ActeurType(), $acteur);
// on recuper la requette en cours
$request = $this->get('request');
//vérifier
if ($request->getMethod() == 'POST') {
$form->bind('request');
if ($form->isValid()) {
$em->persist($acteur);
$em->flush();
return $this->redirect(generateUrl('acteur_list'));
}
}
// s'il n'y a pas de requette donc c'est get
return $this->render('FilmothequeBundle:Acteur:ajouter.html.twig', array('form' => $form->createView()));
} else {
//si le id est valide donc nous sommes dans le cas de la modification
$em = $this->getDoctrine()->getManager();
//il faut recuperer l'id de l'utisateur
$acteur = $em->getRepository('FilmothequeBundle:Acteur')->find($id);
//on recupere les l'id del'acteur du repository
$form = $this->createForm(new ActeurType(), $acteur);
// on requepere la requette
$request = $this->get('request');
// Condition de validation vérifier si la requete est get ou POST
if ($request->getMethod() == 'POST') {
$form->bind($request);
// si le formulaire est valide
if ($form->isValid()) {
//C'est une donnée a enrégistré
$em->persist($acteur);
$em->flush();
return $this->redirect(generateUrl('acteur_list'));
}
}
// si c'est une requete get on fait le modification
return $this->render('FilmothequeBundle:Acteur:ajouter.html.twig', array('id' => $id, 'form' => $form->createView()));
}
}
示例8: MakeImage
//.........这里部分代码省略.........
// go through each parameter
foreach ($parameters as $key => $value) {
// extract the image layout
if (preg_match('~^(' . IMG_DISPLAY_BOX_ONLY . '|' . IMG_DISPLAY_BOX . '|' . IMG_DISPLAY_PICTURE . ')$~', $value)) {
$imageDisplay = $value;
} else {
if (preg_match('~^(thumb|original|big|[0-9]+[Xx][0-9]+|[0-9]+|\\w[0-9]+)$~', $value)) {
$imageSize = $value;
} else {
// its the Title of the picture (it is the last unused parameter)
$imageTitle = $value;
}
}
}
// TODO:
// check if the image isn't saved "local", if it is, download it!
// extern_{$filename}_timestamp.png
// if the file doesn't exists under the given path, try to find it in the database
if (!file_exists($imageUrl)) {
$sql = "SELECT file_path\n\t\t\t\t\t\tFROM " . DB_PREFIX . "files\n\t\t\t\t\t\tWHERE LOWER(file_path) = '" . strtolower($imageUrl) . "'\n\t\t\t\t\t\t\tOR LOWER(file_name) = '" . strtolower(basename($imageUrl)) . "'\n\t\t\t\t\t\tLIMIT 1";
$result = $sqlConnection->SqlQuery($sql);
if ($fileData = mysql_fetch_object($result)) {
$imageUrl = $fileData->file_path;
}
clearstatcache();
// check if the file from the database really exists
if (!file_exists($imageUrl)) {
return "<strong>Bild ("<em>{$imageUrl}</em>") nicht gefunden.</strong>";
}
}
// Resize the image
$image = new ImageConverter($imageUrl);
// convert the 'name-sizes' to 'pixel-sizes'
if ($imageSize == 'thumb') {
$imageSize = 'w180';
} else {
if ($imageSize == 'big') {
$imageSize = '800';
} else {
if ($imageSize == 'original') {
// took the original sizes
$imageWidth = $image->Size[0];
$imageHeight = $image->Size[1];
}
}
}
// 'width-format''
if (preg_match('~^w[0-9]+$~', $imageSize)) {
$imageWidth = substr($imageSize, 1);
// calculate the proporitonal height
$imageHeight = round($image->Size[1] / $image->Size[0] * $imageWidth, 0);
} else {
if (preg_match('~^[0-9]+$~', $imageSize)) {
// look for the longer side and resize it to te given size,
// short the other side proportional to the longer side
$imageWidth = $image->Size[0] > $image->Size[1] ? round($imageSize, 0) : round($image->Size[0] / ($image->Size[1] / $imageSize), 0);
$imageHeight = $image->Size[1] > $image->Size[0] ? round($imageSize, 0) : round($image->Size[1] / ($image->Size[0] / $imageSize), 0);
} else {
if (preg_match('~^([0-9]+)[Xx]([0-9]+)$~', $imageSize, $maches)) {
// took the given sizes
$imageWidth = $maches[1] < $image->Size[0] ? $maches[1] : $image->Size[0];
$imageHeight = $maches[2] < $image->Size[1] ? $maches[2] : $image->Size[1];
}
}
}
$originalUrl = encodeUri($imageUrl);
// str_replace(' ', '%20', basename($imageUrl));
// TODO: don't use the global
global $config;
// check if the image exists already
$thumbnailfolder = $config->Get('thumbnailfolder', 'data/thumbnails/');
if (file_exists($thumbnailfolder . '/' . $imageWidth . 'x' . $imageHeight . '_' . basename($imageUrl))) {
$imageUrl = $thumbnailfolder . '/' . $imageWidth . 'x' . $imageHeight . '_' . basename($imageUrl);
} else {
if ($image->Size[0] >= $imageWidth && $image->Size[1] > $imageHeight || $image->Size[0] > $imageWidth && $image->Size[1] >= $imageHeight) {
$imageUrl = $image->SaveResizedTo($imageWidth, $imageHeight, $thumbnailfolder, $imageWidth . 'x' . $imageHeight . '_');
if ($imageUrl === false) {
return "Not enough memory available!(resize your image!)";
}
} else {
$imageWidth = $image->Size[0];
$imageHeight = $image->Size[1];
}
}
$imageName = generateUrl(basename($image->_file));
$originalUrl = generateUrl($originalUrl);
$imageUrl = generateUrl($imageUrl);
if ($imageDisplay == IMG_DISPLAY_BOX) {
$imageString = "</p>\n\n<div class=\"thumb t" . $ImageAlign . "\">\n\t\t\t\t\t\t<div style=\"width:" . ($imageWidth + 4) . "px\">\n\t\t\t\t\t\t\t<img width=\"{$imageWidth}\" height=\"{$imageHeight}\" src=\"{$imageUrl}\" title=\"{$imageTitle}\" alt=\"{$imageTitle}\" />\n\t\t\t\t\t\t\t<div class=\"description\" title=\"{$imageTitle}\"><div class=\"magnify\"><a href=\"special.php?page=image&file={$imageName}\" title=\"vergrößern\"><img src=\"img/magnify.png\" title=\"vergrößern\" alt=\"vergrößern\"/></a></div>{$imageTitle}</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div><p>\n";
} else {
if ($imageDisplay == IMG_DISPLAY_BOX_ONLY) {
$imageString = "</p>\n\n<div class=\"thumb tbox t" . $ImageAlign . "\">\n\t\t\t\t\t\t<div style=\"width:" . ($imageWidth + 4) . "px\">\n\t\t\t\t\t\t\t<img width=\"{$imageWidth}\" height=\"{$imageHeight}\" src=\"{$imageUrl}\" title=\"{$imageTitle}\" alt=\"{$imageTitle}\" />\n\t\t\t\t\t\t\t<div class=\"magnify\"><a href=\"special.php?page=image&file={$imageName}\" title=\"vergrößern\"><img src=\"img/magnify.png\" title=\"vergrößern\" alt=\"vergrößern\"/></a></div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n<p>";
} else {
if ($imageDisplay == IMG_DISPLAY_PICTURE) {
$imageString = "</p>\n\n<div class=\"thumb tbox t" . $ImageAlign . "\">\n\t\t\t\t\t<img width=\"{$imageWidth}\" height=\"{$imageHeight}\" src=\"{$imageUrl}\" title=\"{$imageTitle}\" alt=\"{$imageTitle}\" />\n\t\t\t\t\t</div><p>";
}
}
}
return "{$imageString}";
}
示例9: generateUrl
<?php
//given vars: $total $todo $inprogress $done
?>
<div class="count-stats">
<a href="<?php
echo generateUrl('listTask');
?>
">
<div class="row text-center">
<div class="count total col-lg-12 container">
<p><?php
echo _t("TOTAL");
?>
<strong><?php
echo $total;
?>
</strong></p>
</div>
</div>
<div class="row text-center">
<div class="count todo col-lg-4 container">
<p><?php
echo _t("TODOLIST");
?>
<strong><?php
echo $todo;
?>
示例10: editerAction
public function editerAction($id = null)
{
// vérification de l'existance de l'id
if (isset($id)) {
// existance de l'id donc on procede a la modification
$em = $this->getDoctrine()->getManager();
// création du formulaire
$form = $this->createForm(new FilmType(), $film);
//recupếration de l'id du repository
$film = $em->getRepository('FilmothequeBundle:Film')->find($id);
// vérification de la requete
$request = $this->get('request');
// vérification si la requete est get ou post
if ($request->getMethod() == 'POST') {
//on lie le formulaire et la requete
$form->bind($request);
// vérification de la validité du formulaire
if ($request->isValid()) {
//on persist
$em->persist($film);
//on flush
$em->flush();
// on fait une redirection
return $this->rediect($this->generateUrl('film_list'));
}
}
return $this->render('FilmothequeBundle:Film:ajouter.html.twig', array('form' => $form->createView(), 'id' => $id));
} else {
// id inexistant
$em = $this->getDoctrine()->getManager();
//instantiation d'un objet
$film = new Film();
//création d'un formulaire
$form = $this->createForm(new FilmType(), $film);
// vérification de la requete
$request->get('request');
//vérification si c'est un get ou post
if ($request->getMehod() == 'POST') {
// on lie le formulaire et la requete
$form->bind($request);
// vérification de la validité du formulaire
if ($form->isValid()) {
$em->persist($film);
// on flush
$em->flush();
// redirection vers les vues liste
return $this->redirect(generateUrl('film_list'));
}
}
return $this->render('FilmothequeBundle:Film:ajouter.html.twig', array('form' => $form->createView()));
}
}
示例11: _t
<h3> <?php
echo _t("EDITTASK");
?>
</h3>
<?php
if ($formError) {
?>
<strong>Bad submit!</strong>
<?php
}
?>
<form class="task-form" action="<?php
echo generateUrl('updateTask') . "&id=" . $id;
?>
" method="post">
<!-- Form -->
<?php
include "views/components/taskForm.php";
?>
<input type="submit" class="btn btn-success" name="submit" value="<?php
echo _t("VALIDATE");
?>
" />
</form>
</div>
<div class="col-md-3">
</div>
示例12: _setImage
/**
* @access private
* @return sring
*/
function _setImage($article_id)
{
if (!is_numeric($article_id)) {
return $this->_homePage();
}
$sql = "SELECT *\r\n\t\t\t\tFROM " . DB_PREFIX . "articles\r\n\t\t\t\tWHERE article_id={$article_id}";
$article_result = $this->_SqlConnection->SqlQuery($sql);
if ($article = mysql_fetch_object($article_result)) {
$out = '';
$sql = "SELECT file_path\r\n\t\t\t\t\tFROM " . DB_PREFIX . "files\r\n\t\t\t\t\tWHERE file_type LIKE 'image/%'\r\n\t\t\t\t\tORDER BY file_name ASC";
$images_result = $this->_SqlConnection->SqlQuery($sql);
$imgmax = 100;
$imgmax2 = 100;
$thumbnailfolder = 'data/thumbnails/';
$out .= "<form action=\"admin.php\" method=\"post\"><div class=\"imagesblock\">\r\n\t\t\t\t<input type=\"hidden\" name=\"page\" value=\"module_articles\"/>\r\n\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"saveImage\"/>\r\n\t\t\t\t<input type=\"hidden\" name=\"article_id\" value=\"{$article_id}\"/>";
while ($imageData = mysql_fetch_object($images_result)) {
$imageUrl = $imageData->file_path;
if (file_exists($imageUrl)) {
$image = new ImageConverter($imageUrl);
$size = $image->CalcSizeByMax($imgmax);
$resizedFileName = $thumbnailfolder . '/' . $size[0] . 'x' . $size[1] . '_' . basename($imageUrl);
if (!file_exists($resizedFileName)) {
$resizedFileName = $image->SaveResizedTo($size[0], $size[1], $thumbnailfolder, $size[0] . 'x' . $size[1] . '_');
}
if (file_exists($resizedFileName) && $resizedFileName !== false) {
$margin_top = round(($imgmax - $size[1]) / 2);
$margin_bottom = $imgmax - $size[1] - $margin_top;
$out .= "<div class=\"imageblock\">\r\n\t\t\t\t\t\t\t<a href=\"" . generateUrl($resizedFileName) . "\">\r\n\t\t\t\t\t\t\t<img style=\"margin-top:" . $margin_top . "px;margin-bottom:" . $margin_bottom . "px;width:" . $size[0] . "px;height:" . $size[1] . "px;\" src=\"" . generateUrl($resizedFileName) . "\" alt=\"" . basename($imageData->file_path) . "\" /></a><br />\r\n\t\t\t\t\t\t<input type=\"radio\" name=\"image_path\" " . ($article->article_image == $imageData->file_path ? 'checked="checked" ' : '') . " value=\"" . $imageData->file_path . "\"/></div>";
}
}
}
$out .= "</div><input type=\"submit\" value=\"" . $this->_Translation->GetTranslation('apply') . "\" class=\"button\"/><a href=\"admin.php?page=module_articles&action=edit&article_id={$article_id}\" class=\"button\">" . $this->_Translation->GetTranslation('back') . "</a></form>";
return $out;
}
}
示例13: _t
<div id="loginModal" class="modal show" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="text-center">ZZTasks - <?php
echo _t("LOGIN");
?>
</h1>
</div>
<div class="modal-body">
<form class="form col-md-12 center-block" action="<?php
echo generateUrl('login');
?>
" method="post">
<div class="form-group">
<input type="text" name="login" class="form-control input-lg" placeholder="<?php
echo _t("USERLOGIN");
?>
" value="<?php
echo getUsername();
?>
" required />
</div>
<div class="form-group">
<input type="password" name="password" class="form-control input-lg" placeholder="<?php
echo _t("USERPASSWORD");
?>
" required />
</div>
<div class="form-group">
示例14: printPageWithoutFooter
/**
* Prints the whole page including form but without the footer.
* Call this function, then call chmodRecursively() which will output some HTML,
* and finally call printFooter();
*/
function printPageWithoutFooter($plugins, $path, $filePermissions, $folderPermissions, $permissionBitSets)
{
global $baseUrl;
?>
<html>
<head>
<title>Gallery Support - Change Filesystem Permissions</title>
<link rel="stylesheet" type="text/css" href="<?php
print $baseUrl;
?>
support.css"/>
<style type="text/css">
</style>
<script type="text/javascript">
var plugins = new Array();
<?php
foreach ($plugins as $pluginId => $isOpenForEdit) {
print "plugins['{$pluginId}'] = {$isOpenForEdit};\n ";
}
?>
function setEditOrSecure(pluginId, formObj) {
if (pluginId == -1) {
formObj.mode.value='';
formObj.open.disabled = true;
formObj.secure.disabled = true;
} else if (plugins[pluginId]) {
formObj.mode.value='secure';
formObj.open.disabled = true;
formObj.secure.disabled = false;
} else {
formObj.mode.value='open';
formObj.open.disabled = false;
formObj.secure.disabled = true;
}
}
function printStatusMessage(message) {
var statusElement = document.getElementById('status');
statusElement.innerHTML = message + "<a href=\"#details\">[details]</a>";
statusElement.style.display = 'block';
}
function printErrorMessage(message) {
var errorElement = document.getElementById('error');
errorElement.innerHTML = message +
"<br/>Note: Please look at the <a href=\"#details\">[details]</a>. " +
"You might be able to change the filesystem permissions of the failed directories " +
"successfully yourself with an FTP program or a command line shell."
errorElement.style.display = 'block';
}
</script>
</head>
<body>
<div id="content">
<div id="title">
<a href="../../">Gallery</a> »
<a href="<?php
generateUrl('index.php');
?>
">Support</a> »
Change Filesystem Permissions
</div>
<h2>
This tool lets you change the filesystem permissions of files and folders owned
by the webserver.
</h2>
<p>
All files and folders in your Gallery storage folder are owned by the
webserver. If you installed Gallery2 by unpacking a .zip or .tar.gz file, then the
gallery2 folder is probably owned by you which means that you can edit the files
directly. However, if you used the preinstaller then your gallery2 directory is
also owned by the webserver. For more information, see the <b><a
href="http://codex.gallery2.org/Gallery2:Security">Gallery Security Guide</a>.</b>
</p>
<!-- Identifyable placeholders such that we can insert our messages during runtime via JS. -->
<div id="error" class="error" style="display: none;">
</div>
<div id="status" class="success" style="display: none;">
</div>
<hr class="faint"/>
<?php
if (!isModulesOrThemesDirWriteable()) {
?>
<h2>
<a href="<?php
generateUrl('index.php?chmod&command=' . CMD_CHMOD_MODULES_AND_THEMES_DIR . '&mode=open');
?>
//.........这里部分代码省略.........
示例15: makeurl
/**
* @NoAdminRequired
*/
public function makeurl()
{
require_once 'shorten/lib/makeurl.php';
return generateUrl();
}