Mai 11, 2010
Powerscript in Wordpress Highlighten
Wenn ihr selber Blogs betreibt wo, öfter mal Quellcode auftaucht, kann ich euch dieses Plugin ans Herz legen. Für alle gängigen Sprachen wird Highlighting angeboten und für alles Andere (wie z.B. Powerscipt) muss man halt ein bischen erweitern.
Download
Hier gibts meine Brush-Datei um das Highlighting zu erweitern
Installation
- Datei in das Verzeichnis /wp-content/plugins/syntax-highlighter-and-code-prettifier/scripts auf eurem Server uploaden
- In der Datei syntax-highlighter-and-code-prettifier/syntax-highlighter.php die Zeile
<script type="text/javascript" src="<?php echo $current_path; ?>scripts/shBrushPowerbuilder.js"></script>
einfügen (vor der Zeile <script type=”text/javascript”> und hinter den Standardscripten).
Anwenden
Wenn man jetzt einen Block highlighten möchte, verwendet man dazu folgende Syntax (Editor im HTML-Modus) <pre class=”brush: powerbuilder”>Code</pre>.
Hier kann man das ganze mal in freier Wildbahn betrachen
OLEObject adoRecordset
String ls_DNSDomain, ls_Query, ls_Name
String ls_Type, ls_Value
String ls_Colname[], ls_Coltype[], ls_Date, ls_Time
Long ll_nextrow, ll_Value
Integer li_rc, li_col, li_max
DateTime ldt_Value
this.Reset()
// Setup ADO objects
li_rc = adoCommand.ConnectToNewObject("ADODB.Command")
If of_ConnectError(li_rc, "ADODB.Command") Then
Return -1
End If
li_rc = adoConnection.ConnectToNewObject("ADODB.Connection")
If of_ConnectError(li_rc, "ADODB.Connection") Then
Return -1
End If
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open("Active Directory Provider")
adoCommand.ActiveConnection = adoConnection
// Determine the domain
li_rc = adoRootDSE.ConnectToObject("LDAP://RootDSE")
If of_ConnectError(li_rc, "ADODB.Connection") Then
Return -1
End If
ls_DNSDomain = adoRootDSE.Get("defaultNamingContext")
// Construct the SQL syntax query
ls_Query = "SELECT "
li_max = Integer(this.Object.DataWindow.Column.Count)
For li_col = 1 To li_max
ls_Name = this.Describe("#" + String(li_col) + ".Name")
ls_Type = Left(this.Describe(ls_Name + ".ColType"), 5)
If li_col = li_max Then
ls_Query += ls_Name + " "
Else
ls_Query += ls_Name + ", "
End If
ls_Colname[li_col] = ls_Name
ls_Coltype[li_col] = ls_Type
Next
ls_Query += "FROM 'LDAP://" + ls_DNSDomain + "' "
ls_Query += "WHERE " + as_where
try
// Run the query
adoCommand.CommandText = ls_Query
adoRecordset = adoCommand.Execute
// Enumerate the resulting recordset
Do Until adoRecordset.EOF
// Copy values from recordset to datastore
ll_nextrow = this.InsertRow(0)
For li_col = 1 To li_max
ls_Name = ls_Colname[li_col]
choose case ls_Coltype[li_col]
case "char("
// string value
ls_Value = String(adoRecordset.Fields(ls_Name).Value)
this.SetItem(ll_nextrow, ls_Name, ls_Value)
case "numbe"
// numeric value
ll_Value = Long(adoRecordset.Fields(ls_Name).Value)
this.SetItem(ll_nextrow, ls_Name, ll_Value)
case "datet"
// datetime value
ls_Value = String(adoRecordset.Fields(ls_Name).Value)
ls_Date = Left(ls_Value, Pos(ls_Value, " ") - 1)
ls_Time = Mid(ls_Value, Pos(ls_Value, " ") + 1)
ldt_Value = DateTime(Date(ls_Date), Time(ls_Time))
this.SetItem(ll_nextrow, ls_Name, ldt_Value)
end choose
Next
// Move to the next record in the recordset
adoRecordset.MoveNext
Loop
// Close the connection
adoRecordset.Close
catch ( oleruntimeerror orte )
MessageBox("OLERuntimeError", orte.Text)
end try
// Close the connection
adoConnection.Close
// Apply any filter or sort
this.Filter()
this.Sort()
Return this.RowCount()
[...] Dieser Eintrag wurde auf Twitter von devbar.de erwähnt. devbar.de sagte: Powerscript in Wordpress Highlighten #powerbuilder #wordpress http://bit.ly/cFOCSo [...]
Warum nicht einfach Geshi nehmen? Jeder nimmt doch Geshi.
Ah, cool. Aber Powerscript gibt es da leider auch nicht. Sieht aber besser aus
http://qbnz.com/highlighter/