PHP 定制小部件区域
function the_widgets_init() {
if ( !function_exists('register_sidebars') )
return;
register_sidebar(array(
'name' => __('Home sidebar', "wpbakery.com"),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div><div class="clear">&nbsp;</div>',
'before_title' => '<h2 class="widget_title">',
'after_title' => '</h2>',
));
}
add_action( 'init', 'the_widgets_init' );
C# C#将货币转换为双倍
double val = Convert.ToDouble(Double.Parse("$123,456.98", System.Globalization.NumberStyles.Currency));
// val = 123456.98
JavaScript 将javascript对象递归输出到div。
function outputData() {
var ob = propertyBox.getObject();
$("#output").html("");
var outputText = "<ul>";
outputText += _outputRecursive(ob, "");
outputText += "</ul>";
$("#output").html(outputText);
}
function _outputRecursive(ob, text) {
var text2 = text;
for (var prop in ob) {
if (!ob.hasOwnProperty(prop)) {
continue;
}
text2 += "<li>";
var val = ob[prop];
if (val instanceof Object && !(val instanceof Array)) {
text2 += "<b>" + prop + "</b>";
text2 += "<ul>" + _outputRecursive(val, "") + "</ul>";
}
else {
if (val instanceof Array) {
val = $.toJSON(val); // convert to string
}
text2 += "<b>" + prop + "</b>: " + val;
}
text2 += "</li>";
}
return text2;
}
HTML Lorem Ipsum
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque placerat nulla vel odio porta ut commodo massa dapibus. Sed eget nisl vel diam pellentesque condimentum porta sed velit. Donec scelerisque ante ac ligula molestie hendrerit. Etiam gravida suscipit massa, eu cursus nisl lacinia non. Donec non leo dui. Nulla accumsan magna eget enim ultricies commodo. Ut a tempus quam. In hac habitasse platea dictumst. Maecenas et leo sem. Sed eu mi vel tortor imperdiet congue. Vestibulum elementum commodo libero, et vehicula libero venenatis eu. Donec sollicitudin odio quis erat tristique vitae aliquam risus adipiscing. Integer rhoncus, est at porttitor varius, magna erat condimentum mauris, non hendrerit augue enim ut lorem. Praesent pretium neque eget risus ultricies posuere.
Maecenas vitae fringilla urna. Aenean pharetra egestas ullamcorper. Proin fringilla blandit ultrices. Nulla facilisi. Fusce posuere gravida nisi, in egestas nulla lobortis et. Quisque suscipit gravida purus a pulvinar. Nullam ligula turpis, posuere in sollicitudin eu, sagittis eu orci. Proin non leo non purus hendrerit malesuada eu porttitor mi. Donec elit odio, dictum mattis tristique non, vulputate a ipsum. Vivamus mollis egestas elementum.
Nam laoreet bibendum odio sit amet molestie. Sed ultricies dolor vel orci ultricies ut elementum nisi faucibus. Duis pulvinar nisl sed neque mattis non sodales leo fringilla. Phasellus lobortis dapibus orci, sit amet cursus orci tincidunt at. Vivamus facilisis scelerisque lectus sit amet adipiscing. Duis scelerisque lorem in nisl posuere pellentesque. Nam a risus in arcu cursus volutpat. Vestibulum sollicitudin tortor nec diam gravida adipiscing. Proin nec neque id orci aliquam condimentum id vel est. Nulla facilisi. Sed tempor laoreet scelerisque. Proin semper sapien sit amet lectus elementum imperdiet. In commodo, diam at accumsan sollicitudin, sapien massa porttitor magna, a hendrerit ipsum magna quis odio. Integer consequat malesuada vehicula.
Aliquam feugiat augue sit amet eros ornare egestas. Curabitur at odio ligula. Quisque vel turpis sem. Suspendisse dignissim fermentum sollicitudin. Aliquam molestie suscipit diam vestibulum consequat. Proin in dui ut lacus dapibus posuere. Curabitur viverra ornare lorem, accumsan porttitor leo ultrices quis. Curabitur sit amet risus quis ipsum congue vehicula non ut metus. Nulla sodales convallis facilisis. Aliquam erat volutpat. Aliquam vulputate condimentum elit, vel condimentum leo ultrices et.
Praesent tincidunt dui sit amet nulla placerat tempor. Vestibulum ac sodales orci. Quisque molestie arcu eget tortor iaculis sit amet interdum tortor ullamcorper. Etiam imperdiet eros odio, a tincidunt enim. Maecenas dolor diam, ornare in aliquet eu, laoreet sed massa. Curabitur a erat vel ipsum tincidunt luctus vitae at enim. Duis molestie, erat eget interdum vulputate, odio massa interdum tortor, ac laoreet nibh metus quis ante. Sed viverra feugiat ante ac posuere. Aenean vel blandit odio. Vivamus pulvinar sodales felis, a elementum erat tristique malesuada. Proin lectus risus, lacinia nec pulvinar non, rutrum non enim. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aliquam non ipsum dolor. In tristique ante dapibus elit adipiscing a euismod mi tristique. Curabitur id auctor risus.
PHP 更新用户会话
foreach($this->data['User'] as $key=>$value) $this->Session->write('Auth.User.'.$key,$value);
jQuery 顺畅滚动
/* Smooth Scroll
========================================== */
$(function(){
$('a[href^=#]:not(a[href$=#]):not(#topInformation ul.navi li a)').click(function(){
var href= this.hash;
var $target = $(href == '#_top' ? 'body' : href);
if($target.size()){
var top = $target.offset().top;
$($.browser.safari ? 'body' : 'html').animate({scrollTop:top}, 500, 'swing');
}
return false;
});
});
Groovy Groovy Swing Explorer文件删除处理程序
import java.awt.datatransfer.*;
import java.awt.dnd.*;
public class TFileDropHandler
{
// TFileDropHandler.groovy
// Laurence Toenjes - 2010-08-18
// Based on 1999 example from Cay Horstmann found at
// http://java.itags.org/java-core-gui-apis/33457/
// dropped files closure example: { files -> println files };
def TFileDropHandler( aSwingControl, Closure a_onDroppedFiles )
{ // ctor
def dropTarget = new DropTarget( aSwingControl, new TFileDropTargetListener( a_onDroppedFiles ) )
aSwingControl.setDropTarget( dropTarget )
}
// --------------------------------------------------------
class TFileDropTargetListener implements DropTargetListener
{
def Closure onDroppedFiles = null // our callback event
public TFileDropTargetListener( a_onDroppedFiles ) { // ctor
onDroppedFiles = a_onDroppedFiles }
public void dragEnter(DropTargetDragEvent event) {}
public void dragExit(DropTargetEvent event) {}
public void dropActionChanged(DropTargetDragEvent event) {}
public void dragOver(DropTargetDragEvent event) {
// provide visual feedback
event.acceptDrag(DnDConstants.ACTION_COPY);
}
public void drop(DropTargetDropEvent event) {
if ( (event.getSourceActions() & DnDConstants.ACTION_COPY) != 0 ) {
event.acceptDrop(DnDConstants.ACTION_COPY);
}
else {
event.rejectDrop();
return; // !!!!!!!!!!!!!!!!!!!!!
}
Transferable transferable = event.getTransferable();
DataFlavor[] flavors = event.getCurrentDataFlavors();
for (int i = 0; i < flavors.length; i++) {
DataFlavor dataFlavor = flavors[i];
try {
// file flavor
if ( dataFlavor.equals( DataFlavor.javaFileListFlavor ) ) {
java.util.List fileList = (java.util.List) transferable.getTransferData(dataFlavor);
def files = []
fileList.each { files << it }
this?.onDroppedFiles( files )
event.dropComplete(true);
return;
}
}
catch(Exception e) {
event.dropComplete(false);
return;
}
} // end for
event.dropComplete(false);
} // end drop
}
// --------------------------------------------------------
public static void main(String[] args) {
// simple example
def f = new javax.swing.JFrame()
f.setDefaultCloseOperation( javax.swing.JFrame.EXIT_ON_CLOSE )
f.size = [400,300]
def ta = new javax.swing.JTextArea()
f.add( ta )
new TFileDropHandler( ta, { files ->
files.each {
ta.append("${it}\n")
println it
}
} )
f.show()
}
}
MySQL 嵌套循环与游标在过程中
DROP PROCEDURE IF EXISTS createQueenslandWards;
DELIMITER //
CREATE PROCEDURE createQueenslandWards()
BEGIN
DECLARE done INT DEFAULT 0;
DECLARE wardName varchar(255);
DECLARE Lang varchar(255);
DECLARE Lat varchar(255);
DECLARE cursorWard CURSOR FOR SELECT DISTINCT `ward` FROM `regions` WHERE `territory` = 'QLD';
DECLARE cursorLangLat CURSOR FOR SELECT `centroid_y`, `centroid_x` FROM `regions` WHERE `ward` = wardName;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN cursorWard;
REPEAT
FETCH cursorWard INTO wardName;
IF NOT done THEN
OPEN cursorLanglat;
block2: BEGIN
DECLARE doneLangLat INT DEFAULT 0;
DECLARE firstLang varchar(255) DEFAULT '';
DECLARE firstLat varchar(255) DEFAULT '';
DECLARE i int DEFAULT 1;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET doneLangLat = 1;
REPEAT
FETCH cursorLangLat INTO Lang, Lat;
IF i == 1 THEN
SET firstLang = Lang;
SET firstLat = Lat;
END IF;
INSERT INTO `points` SET `coordinates` = GeomFromText(CONCAT('POINT(', Lang, ' ', Lat ,')')), `type` = wardName, to_text = CONCAT(Lang, ',', Lat), `description` = 'Queensland territory';
SET i = i + 1;
UNTIL doneLangLat END REPEAT;
INSERT INTO `points` SET `coordinates` = GeomFromText(CONCAT('POINT(', firstLang, ' ', firstLat ,')')), `type` = wardName, to_text = CONCAT(firstLang, ',', firstLat), `description` = 'Queensland territory';
END block2;
CLOSE cursorLangLat;
END IF;
UNTIL done END REPEAT;
CLOSE cursorWard;
END//
DELIMITER ;
CALL createQueenslandWards();
MySQL 使用空间扩展
DROP TABLE IF EXISTS `points`;
CREATE TABLE `points` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`coordinates` point NOT NULL,
`type` varchar(20) DEFAULT 'click',
`to_text` varchar(255) DEFAULT '',
`description` text DEFAULT '',
PRIMARY KEY (`id`),
SPATIAL KEY `coordinates` (`coordinates`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `polygons`;
CREATE TABLE `polygons` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`polygon_data` polygon NOT NULL,
`type` varchar(20) DEFAULT 'click',
`description` varchar(255) DEFAULT '',
PRIMARY KEY (`id`),
SPATIAL KEY `polygon_data` (`polygon_data`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
INSERT INTO `points` SET `coordinates` = GeomFromText('POINT(-16.88866 138.164063)') , type = 'QLD', to_text = '-16.88866 138.164063', `description` = 'Queensland border'; # First/Last point
INSERT INTO `points` SET `coordinates` = GeomFromText('POINT(-25.972532 138.186035)'), type = 'QLD', to_text = '-25.972532 138.186035', `description` = 'Queensland border';
INSERT INTO `points` SET `coordinates` = GeomFromText('POINT(-25.972532 141.262207)'), type = 'QLD', to_text = '-25.972532 141.262207', `description` = 'Queensland border';
INSERT INTO `points` SET `coordinates` = GeomFromText('POINT(-28.897268 141.262207)'), type = 'QLD', to_text = '-28.897268 141.262207', `description` = 'Queensland border';
INSERT INTO `points` SET `coordinates` = GeomFromText('POINT(-28.820292 148.952637)'), type = 'QLD', to_text = '-28.820292 148.952637', `description` = 'Queensland border';
INSERT INTO `points` SET `coordinates` = GeomFromText('POINT(-28.279873 150.270996)'), type = 'QLD', to_text = '-28.279873 150.270996', `description` = 'Queensland border';
INSERT INTO `points` SET `coordinates` = GeomFromText('POINT(-28.704722 151.501465)'), type = 'QLD', to_text = '-28.704722 151.501465', `description` = 'Queensland border';
INSERT INTO `points` SET `coordinates` = GeomFromText('POINT(-28.550429 153.391113)'), type = 'QLD', to_text = '-28.550429 153.391113', `description` = 'Queensland border';
INSERT INTO `points` SET `coordinates` = GeomFromText('POINT(-22.97323 150.534668)') , type = 'QLD', to_text = '-22.97323 150.534668', `description` = 'Queensland border';
INSERT INTO `points` SET `coordinates` = GeomFromText('POINT(-18.994263 146.052246)'), type = 'QLD', to_text = '-18.994263 146.052246', `description` = 'Queensland border';
INSERT INTO `points` SET `coordinates` = GeomFromText('POINT(-14.705467 144.470215)'), type = 'QLD', to_text = '-14.705467 144.470215', `description` = 'Queensland border';
INSERT INTO `points` SET `coordinates` = GeomFromText('POINT(-14.620439 143.635254)'), type = 'QLD', to_text = '-14.620439 143.635254', `description` = 'Queensland border';
INSERT INTO `points` SET `coordinates` = GeomFromText('POINT(-11.280414 142.536621)'), type = 'QLD', to_text = '-11.280414 142.536621', `description` = 'Queensland border';
INSERT INTO `points` SET `coordinates` = GeomFromText('POINT(-16.988152 141.350098)'), type = 'QLD', to_text = '-16.988152 141.350098', `description` = 'Queensland border';
INSERT INTO `points` SET `coordinates` = GeomFromText('POINT(-18.03585 140.251465)') , type = 'QLD', to_text = '-18.03585 140.251465', `description` = 'Queensland border';
INSERT INTO `points` SET `coordinates` = GeomFromText('POINT(-16.88866 138.164063)') , type = 'QLD', to_text = '-16.88866 138.164063', `description` = 'Queensland border'; # First/Last point
INSERT INTO `points` SET `coordinates` = GeomFromText('POINT(-19.367813 141.04248)') , type = 'QLD_AREA_1', to_text = '-19.367813,141.04248', `description` = 'Queensland block/1';
INSERT INTO `points` SET `coordinates` = GeomFromText('POINT(-25.100192 141.306152)') , type = 'QLD_AREA_1', to_text = '-25.100192,141.306152', `description` = 'Queensland block/1';
INSERT INTO `points` SET `coordinates` = GeomFromText('POINT(-22.97323 150.534668)') , type = 'QLD_AREA_1', to_text = '-22.97323,150.534668', `description` = 'Queensland block/1';
INSERT INTO `points` SET `coordinates` = GeomFromText('POINT(-18.994263 146.052246)') , type = 'QLD_AREA_1', to_text = '-18.994263,146.052246', `description` = 'Queensland block/1';
INSERT INTO `points` SET `coordinates` = GeomFromText('POINT(-19.367813 141.04248)') , type = 'QLD_AREA_1', to_text = '-19.367813,141.04248', `description` = 'Queensland block/1';
INSERT INTO `points` SET `coordinates` = GeomFromText('POINT(-21.646536 143.217773)') , type = 'click', to_text = '-21.646536,143.217773', `description` = 'QLD, IN!';
INSERT INTO `points` SET `coordinates` = GeomFromText('POINT(-20.662941 134.165039)') , type = 'click', to_text = '-20.662941,134.165039', `description` = 'Northern territory, OUT!';
INSERT INTO `points` SET `coordinates` = GeomFromText('POINT(-27.867569 144.008789)') , type = 'click', to_text = '-27.867569,144.008789', `description` = 'QLD, IN!';
INSERT INTO `points` SET `coordinates` = GeomFromText('POINT(50.068658 14.430542)') , type = 'click', to_text = '50.068658,14.430542', `description` = 'Europe/prague, OUT!';
-- PROCEDURE THAT CREATES QLD MAP POLYGON
DROP PROCEDURE IF EXISTS createPolygon;
DELIMITER //
CREATE PROCEDURE createPolygon(IN `pointType` VARCHAR(50))
BEGIN
DECLARE pointIdStart int;
DECLARE pointIdEnd int;
DECLARE polygonData text DEFAULT '';
DECLARE polygonToInsert polygon;
DECLARE coord text DEFAULT '';
SET pointIdStart = (SELECT MIN(`id`) as `id` FROM `points` WHERE `type` = pointType LIMIT 1);
SET pointIdEnd = (SELECT MAX(`id`) as `id` FROM `points` WHERE `type` = pointType LIMIT 1);
WHILE pointIdStart <= pointIdEnd DO
SET coord = (SELECT `to_text` FROM `points` WHERE `type` = pointType AND `id` = pointIdStart LIMIT 1);
SET coord = REPLACE(coord, ',', ' ');
SET polygonData = concat(coord, ',', polygonData);
SET pointIdStart = pointIdStart + 1;
END WHILE;
SET polygonToInsert = GeomFromText(CONCAT('POLYGON((', SUBSTR(polygonData, 1, CHAR_LENGTH(polygonData) - 1) , '))'));
INSERT INTO `polygons` SET `polygon_data` = polygonToInsert, `type` = pointType, `description` = '';
END//
DELIMITER ;
CALL createPolygon('QLD');
CALL createPolygon('QLD_AREA_1');
/**
* FUNCTION THAT CHECKS WHETHER coordinate IS WITHIN polygon
* @param VARCHAR(50) Lat,Lng
* @param VARCHAR(50) Name/Type of polygon
*/
DROP FUNCTION IF EXISTS checkCoordinatesInPolygon;
DELIMITER //
CREATE FUNCTION checkCoordinatesInPolygon(`coordinates` VARCHAR(50),`polygonType` VARCHAR(50)) RETURNS int
BEGIN
DECLARE polygonData polygon;
SET polygonData = (SELECT polygon_data FROM `polygons` WHERE `type` = polygonType LIMIT 1);
SET coordinates = REPLACE(coordinates, ',', ' ');
RETURN (SELECT contains(polygonData, GeomFromText(CONCAT('POINT(', coordinates ,')'))) LIMIT 1);
END//
DELIMITER ;
SELECT checkCoordinatesInPolygon('-20.730086,144.470215', 'QLD_AREA_1'), checkCoordinatesInPolygon('-22.97323,139.680176', 'QLD_AREA_1'), checkCoordinatesInPolygon('-21.386249,143.986816', 'QLD_AREA_1');
TYPO3 内容元素mit Typoscript RECORD einbinden
temp.banner = COA
temp.banner.5 = RECORDS
temp.banner.5 {
tables = tt_content
source = 26
dontCheckPid = 1
}