]> CyberLeo.Net >> Repos - Github/YOURLS.git/blob - sample-public-front-page.php.txt
Translation API! zomigod. First pass. See Issue 52.
[Github/YOURLS.git] / sample-public-front-page.php.txt
1 <?php\r
2 /* This is an example file for a public interface and a bookmarklet. It\r
3  * is provided so you can build from it and customize to suit your needs.\r
4  * It's not really part of the project. Don't submit feature requests \r
5  * about this file. It's _your_ job to make it what you need it to be :)\r
6  */\r
7 \r
8 // Start YOURLS engine\r
9 require_once( dirname(__FILE__).'/includes/load-yourls.php' );\r
10 \r
11 // Insert <head> markup and all CSS & JS files\r
12 yourls_html_head();\r
13 \r
14 // Display title\r
15 $site = trim( YOURLS_SITE, 'http://' );\r
16 echo "<h1>$site's URL Shortener</h1>\n";\r
17 \r
18 // Display left hand menu\r
19 yourls_html_menu() ;\r
20 \r
21 \r
22 // Part to be executed if FORM has been submitted\r
23 if ( isset( $_REQUEST['url'] ) ) {\r
24 \r
25         $url     = yourls_sanitize_url( $_REQUEST['url'] );\r
26         $keyword = isset( $_REQUEST['keyword'] ) ? yourls_sanitize_keyword( $_REQUEST['keyword'] ): '' ;\r
27         $title   = isset( $_REQUEST['title'] ) ? yourls_sanitize_title( $_REQUEST['title'] ) : '' ;\r
28 \r
29         $return  = yourls_add_new_link( $url, $keyword, $title );\r
30         \r
31         $shorturl = isset( $return['shorturl'] ) ? $return['shorturl'] : '';\r
32         $message  = isset( $return['message'] ) ? $return['message'] : '';\r
33         $title    = isset( $return['title'] ) ? $return['title'] : '';\r
34         \r
35         // Include the Copy box and the Quick Share box\r
36         yourls_share_box( $url, $shorturl, $title );\r
37         \r
38         // Initialize clipboard -- requires js/share.js and js/jquery.zclip.min.js to be properly loaded\r
39         echo <<<JS\r
40         <script>\r
41         init_clipboard();\r
42         </script>\r
43 JS;\r
44 \r
45 // Part to be executed when no form has been submitted\r
46 } else {\r
47 \r
48                 $site = YOURLS_SITE;\r
49 \r
50                 // Display the form\r
51                 echo <<<HTML\r
52                 <h2>Enter a new URL to shorten</h2>\r
53                 <form method="post" action="">\r
54                 <p><label>URL: <input type="text" class="text" name="url" value="http://" size="70" /></label></p>\r
55                 <p><label>Optional custom short URL: $site/<input type="text" class="text" name="keyword" size="8" /></label></p>\r
56                 <p><label>Optional title: <input type="text" class="text" name="title" size="57" /></label></p>\r
57                 <p><input type="submit" class="button primary" value="Shorten" /></p>\r
58                 </form> \r
59 HTML;\r
60 \r
61 }\r
62 \r
63 // Display bookmarklet hint and link\r
64 echo <<<BOOK\r
65         <!-- Example bookmarklet. Be sure to rename the link target from "sample-public-front-page.php" to whatever you'll use (probably index.php) -->\r
66         <h2>Bookmarklet</h2>\r
67         <style>\r
68         #bookmark{display:inline-block; border:1px solid #88c0eb; background:#eee; padding:5px 10px; color:#595441; font-weight:bold; cursor:move; border-radius:5px}\r
69         </style>\r
70         <p>Bookmark this link (drag to bookmark bar) : <a id="bookmark" href="javascript:void(location.href='<?php echo YOURLS_SITE; ?>/sample-public-front-page.php?format=simple&amp;action=shorturl&amp;url='+escape(location.href))">Shorten</a>\r
71 BOOK;\r
72 \r
73 // Display page footer\r
74 yourls_html_footer();   \r