function Example_Ajax() { global $page, $addonRelativeCode; //prepare the page $page->head_js[] = $addonRelativeCode . 'static/02_script.js'; $page->admin_js = true; //get request parameters and execute any commands $string = ''; if (isset($_REQUEST['string'])) { $string = $_REQUEST['string']; } $cmd = common::GetCommand(); switch ($cmd) { case 'randomstring': $string = common::RandomString(10); break; } //display the form echo '<h2>Example Ajax Requests</h2>'; echo '<form method="post" action="' . $page->title . '">'; echo 'Text: <input type="text" name="string" value="' . htmlspecialchars($string) . '" size="30" />'; echo ' <input type="submit" class="gpajax" value="Post Form Asynchronosly" /> '; echo common::Link($page->title, 'Get Random String', 'cmd=randomstring', 'name="gpajax"'); echo '</form>'; //output the $_REQUEST variable echo '<h3>Request</h3>'; echo showArray($_REQUEST); //plugin example navigation gpPlugin::incl('navigation.php'); PluginExampleNavigation(); }
function Example_Map() { global $page, $addonRelativeCode; //add css and js to <head> $page->head .= '<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />'; $page->head .= '<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language=en"></script>'; $page->head .= '<script type="text/javascript" src="' . $addonRelativeCode . '/static/01_script.js"></script>'; //html contents of the page echo '<h2>Display a Google Map With Directions</h2>'; echo '<div id="input">'; echo '<input id="map_address" type="textbox" value="starting point" />'; echo '<input type="button" value="calculate route" id="calc_route_button" />'; echo '</div>'; echo '<div id="directionsPanel" style="float:right;width:300px;"></div>'; echo '<div id="map_canvas" style="width:500px;height:500px;"></div>'; //plugin example navigation gpPlugin::incl('navigation.php'); PluginExampleNavigation(); }
<?php defined('is_running') or die('Not an entry point...'); gpPlugin::incl('SimpleBlogCommon.php', 'require_once'); class SimpleBlogCategories { function SimpleBlogCategories() { global $addonPathData; SimpleBlogCommon::AddCSS(); $gadget_file = $addonPathData . '/gadget_categories.php'; $content = ''; if (file_exists($gadget_file)) { $content = file_get_contents($gadget_file); } //fix edit links if (strpos($content, 'simple_blog_gadget_label')) { new SimpleBlogCommon(); $content = file_get_contents($gadget_file); } if (empty($content)) { return; } echo '<div class="simple_blog_gadget"><div>'; echo '<span class="simple_blog_gadget_label">'; echo gpOutput::GetAddonText('Categories'); echo '</span>'; echo $content; echo '</div></div>'; } }
<?php defined('is_running') or die('Not an entry point...'); gpPlugin::incl('PageProtect.php'); class AdminProtect extends PageProtect { function AdminProtect() { global $gp_menu; $this->PageProtect(); echo '<h2>'; echo common::Link('Admin_Protect', 'Protected Pages'); echo '</h2>'; $cmd = common::GetCommand(); switch ($cmd) { case 'savecontent': $this->SaveContent(); case 'editcontent': $this->EditContent(); return; } echo '<p>'; echo '<b>' . common::Link('Admin_Protect', 'Protected Content', 'cmd=editcontent') . '</b> '; echo 'Edit the content users will see if they navigate to a protected page and aren\'t logged in.'; echo '</p>'; if (!count($this->config['pages'])) { echo '<p>There aren\'t any protected pages.</p>'; return; } echo '<table class="bordered">'; echo '<tr><th>Pages</th><th>Child Pages</th></tr>';
/** * Alias of gpPlugin::incl() */ function inc($file) { return gpPlugin::incl($file); }
function OnTextChange() { gpPlugin::incl('SimpleBlogCommon.php', 'require_once'); new SimpleBlogCommon(); //regenerate the gadget and feed }