The text I want to replace is as follows (it is Sri Lankan Sinhalese).
මහණෙනි, එක් පුද්ගලයක්හුගේ නිෂ්පත්තිය හේතු කොට ගෙන මහත් වූ ප්රඥාචක්ෂුස්හුගේ පහළ වීම වෙයි, මහත් වූ ප්රඥාලෝකයක්හුගේ පහළ වීම වෙයි, මහත් වූ ප්රඥාවභාසයක්හුගේ පහළ වීම වෙයි, අනුත්තරියධර්මයන් සදෙනාගේ පහළ වීම වෙයි, සිවුපිළිසැඹියාවන්ගේ පසක් කිරීම වෙයි, (අටළොස් වැදෑරුම්) අනෙක ධාතුන්ගේ ප්රතිවෙධය වෙයි, (අටළොස් වැදෑරුම්) නානාධාතුන්ගේ ප්රතිවෙධය වෙයි, විද්යාවිමුක්තිඵලයන්ගේ සාක්ෂාත් කිරීම වෙයි, ස්රොතාපත්ති ඵලයාගේ සාක්ෂාත් කිරීම වෙයි, සකෘදාගාමි ඵලයාගේ සාක්ෂාත් කිරීම වෙයි, අනාගාමී ඵලයාගේ සාක්ෂාත් කිරීම වෙයි, අර්හත්ත්ව ඵලයාගේ සාක්ෂාත් කිරීම වෙයි, කවර එක් පුද්ගලයක්හුගේය? යත්: තථාගත අර්හත් සම්යක් සම්බුද්ධයන් වහන්සේගේ ය. මහණෙනි, මේ එක් පුද්ගලයාගේ නිෂ්පත්තියෙන් මහත් වූ ප්රඥාචක්ෂුස්හුගේ පහළ වීම වෙයි, මහත් වූ ප්රඥාලෝකයාගේ පහළ වීම වෙයි, මහත් වූ ප්රඥාවභාසයාගේ පහළ වීම වෙයි, අනුත්තරිය ධර්මයන් සදෙනාගේ පහළ වීම වෙයි, සිවුපිළිසැඹියාවන්ගේ සාක්ෂාත් කිරීම වෙයි, අනෙක ධාතු ප්රතිවෙධය වෙයි, නානාධාතුප්රතිවෙධය වෙයි, විද්යාවිමුක්තිඵලයාගේ සාක්ෂාත් කිරීම වෙයි, ස්රොතාපත්ති ඵලයාගේ සාක්ෂාත් කිරීම වෙයි, සකෘදාගාමි ඵලයාගේ සාක්ෂාත් කිරීම වෙයි, අනාගාමී ඵලයාගේ සාක්ෂාත් කිරීම වෙයි, අර්හත්ත්ව ඵලයාගේ සාක්ෂාත් කිරීම වෙයි.
Need to highlight and add tool tips to some text the result was unexpected as follows. showing transparent blue is the error
the troubled page as an image highlighting the error
the code I use to generate this is
function callback($buffer) {
require_once(ABSPATH . 'wp-config.php');
$connection = mysql_connect($DB_HOST, $DB_USER, $DB_PASSWORD);
mysql_select_db($DB_NAME);
$sql = "SELECT word_name, word_meaning, word_page_id FROM popuptable ORDER BY word_id";
$result = mysql_query($sql) or die(mysql_error());
$keys= array();
$values= array();
$links;
while($row = mysql_fetch_assoc($result)) {
$keys[] = $row["word_name"];
if($row["word_page_id"] != 0){
$links = "<a href='?p=" . $row["word_page_id"] . "'>වැඩිදුරටත්</a>";
}else{
$links = "";
}
$values[] = do_shortcode('[simple_tooltip bubbleposition="center" content="' . $row["word_meaning"] .
' ' . $links . ' "]<span style="color: rgb(51,122,183)">' . $row["word_name"] .
'</span>[/simple_tooltip]');
}
$buffer = str_replace($keys, $values, $buffer);
return $buffer;
}
function buffer_start() {
ob_start("callback");
}
function buffer_end() {
ob_end_flush();
}
add_action('wp_head', 'buffer_start');
add_action('wp_footer', 'buffer_end');
Experts I need your help here. I cannot do this edit directly in word press due to the data entered from several points and loads of tool tips and links are to be generated. So I created a table in my WordPress database and here I am. All of the code is from Stackoverflow and Thank you for that. the troubled page is www.daham.lk
Related
In SharePoint Community site , Category Tile view is showing wrong count of reply. In general Category total replies are 5 but in Category tile view it is showing 3. This behaviour we are able to replicate both in our test and Production environment. We also waited for one day , if this issue related to Crawl but issue still persists.
Please give some suggestions on this.
Thanks,
Sheetal
I had the exact same problem and there was no fix available. In my opinion these counters are updated through event receivers, so this has nothing to do with search crawls.
I solved this by setting the correct fields by code:
First count the topics and replies with this SSOM code
/// <summary>
/// Dictionary: categId, nr disc
/// </summary>
public Dictionary<int, int> CategoryTopicCount
{
get
{
var categoriesDiscussionsCount = new Dictionary<int, int>();
foreach (int categId in Categories)
{
var spquery = new SPQuery();
spquery.Query = ""
+ " <Where>"
+ " <And> "
+ " <IsNull>"
+ " <FieldRef Name='ParentFolderId' />"
+ " </IsNull>"
+ " <Eq>"
+ " <FieldRef Name='CategoriesLookup' LookupId='TRUE' />"
+ " <Value Type='Lookup'>" + categId + "</Value>"
+ " </Eq>"
+ " </And> "
+ " </Where>";
spquery.ViewAttributes = "Scope='RecursiveAll'";
categoriesDiscussionsCount.Add(categId, _discussionList.GetItems(spquery).Count);
}
return categoriesDiscussionsCount;
}
}
/// <summary>
/// Dictionary: categId, nr replies
/// </summary>
public Dictionary<int, int> CategoryReplyCount
{
get
{
var categoriesDiscussionsCount = new Dictionary<int, int>();
foreach (int categId in Categories)
{
//get topics of this category
var spquery = new SPQuery();
spquery.Query = ""
+ " <Where>"
+ " <And> "
+ " <IsNull>"
+ " <FieldRef Name='ParentFolderId' />"
+ " </IsNull>"
+ " <Eq>"
+ " <FieldRef Name='CategoriesLookup' LookupId='TRUE' />"
+ " <Value Type='Lookup'>" + categId + "</Value>"
+ " </Eq>"
+ " </And> "
+ " </Where>";
spquery.ViewAttributes = "Scope='RecursiveAll'";
SPListItemCollection topicsOfThisCategory = _discussionList.GetItems(spquery);
//get nr of replies for each topic of this category
var totalRepliesCategory = 0;
foreach (SPListItem topic in topicsOfThisCategory)
{
var spqueryreplies = new SPQuery();
spqueryreplies.Query = ""
+ " <Where>"
+ " <And> "
+ " <IsNotNull>"
+ " <FieldRef Name='ParentFolderId' />"
+ " </IsNotNull>"
+ " <Eq>"
+ " <FieldRef Name='ParentFolderId' />"
+ " <Value Type='Number'>" + topic.ID + "</Value>"
+ " </Eq>"
+ " </And> "
+ " </Where>";
spqueryreplies.ViewAttributes = "Scope='RecursiveAll'";
totalRepliesCategory += _discussionList.GetItems(spqueryreplies).Count;
}
categoriesDiscussionsCount.Add(categId, totalRepliesCategory);
}
return categoriesDiscussionsCount;
}
}
Then update the counters with this SSOM code:
/// <summary>
/// Update number of topics and replies for each category
/// </summary>
public void UpdateCategoriesCounts()
{
Dictionary<int, int> categoryTopicCount = this.CategoryTopicCount;
Dictionary<int, int> categoryReplyCount = this.CategoryReplyCount;
SPListItemCollection categories = _categoryList.Items;
foreach (SPListItem category in categories)
{
Console.WriteLine("Handling " + category.DisplayName);
int topicCount = category["TopicCount"] == null ? 0 : Convert.ToInt32(category["TopicCount"]);
int replyCount = category["ReplyCount"] == null ? 0 : Convert.ToInt32(category["ReplyCount"]);
Console.WriteLine("Topics: " + categoryTopicCount[category.ID] + " || Replies: " + categoryReplyCount[category.ID]);
_web.AllowUnsafeUpdates = true;
if (categoryTopicCount[category.ID] != topicCount)
category["TopicCount"] = categoryTopicCount[category.ID];
if (categoryReplyCount[category.ID] != replyCount)
category["ReplyCount"] = categoryReplyCount[category.ID];
category.SystemUpdate(false);
_web.AllowUnsafeUpdates = false;
Console.WriteLine("Saved...");
}
Console.WriteLine("Finished");
}
Hope this helps you!
PS: the same problem might occure with the 'my membership'-counters. Here we can also adjust the values through code. Check this: SharePoint 'my membership' webpart counters in community site
I am trying to replace ipp.lib DCT function by using mkl.lib DCT function .
I used following Ipp based API to do DCT:
ippsDCTFwdInitAlloc_32f
ippsDCTFwd_32f
ippsDCTFwdFree_32f
PFB my mkl based DCT sample code :
#include <time.h>
#include <stdlib.h>
#include "mkl.h"
int main(int argc, char* argv[]){
float *dpar;
float *out;
MKL_INT *ipar;
MKL_INT tt_type,stat,n_1,nn;
FILE *fp,*fw,*fonce;
fp = fopen( "D:\\dump\\fileinput.txt","r" );
if(fp == NULL){
cout<<"file not created properly"<<endl;
}
DFTI_DESCRIPTOR_HANDLE handle = 0;
int n = 150; /*Hardcoded to run for my code TODO: going to change after integrating into my main codebase.As I can't attach my full fileinput.txt .So just taken n value = 150 */
nn = (MKL_INT)n;
tt_type = MKL_STAGGERED_COSINE_TRANSFORM;
n_1 = nn + 1 ;
out = (float*)malloc((n+1)*sizeof(float));
dpar= (float*)malloc((5*n_1/2+2)*sizeof(float));
ipar= (MKL_INT*)malloc((128)*sizeof(int));
s_init_trig_transform(&n_1,&tt_type,ipar,dpar,&stat);
for (int srcSize =0 ;srcSize< n ; srcSize++)
{
fscanf(fp,"%f\n",&out[srcSize]);
}
fclose(fp);
if (stat != 0)
{
printf("\n============================================================================\n");
printf("FFTW2MKL FATAL ERROR: MKL TT initialization has failed with status=%d\n",(MKL_INT)stat);
printf("Please refer to the Trigonometric Transform Routines Section of MKL Manual\n");
printf("to find what went wrong...\n");
printf("============================================================================\n");
return NULL;
}
ipar[10] = 1; //nx, that is, the number of intervals along the x-axis, in the Cartesian case.
ipar[14] = n_1; //specifies the internal partitioning of the dpar array.
ipar[15] = 1; //value of ipar[14]+1,Specifies the internal partitioning of the dpar array.
s_commit_trig_transform(out,&handle,ipar,dpar,&stat);
if (stat != 0)
{
printf("\n============================================================================\n");
printf("FFTW2MKL FATAL ERROR: MKL TT commit step has failed with status=%d\n",(MKL_INT)stat);
printf("Please refer to the Trigonometric Transform Routines Section of MKL Manual\n");
printf("to find what went wrong...\n");
printf("============================================================================\n");
return NULL;
}
s_forward_trig_transform(out,&handle,ipar,dpar,&stat);
if (stat != 0)
{
printf("\n============================================================================\n");
printf("FFTW2MKL FATAL ERROR: MKL TT commit step has failed with status=%d\n",(MKL_INT)stat);
printf("Please refer to the Trigonometric Transform Routines Section of MKL Manual\n");
printf("to find what went wrong...\n");
printf("============================================================================\n");
return NULL;
}
free_trig_transform(&handle,ipar,&stat);
printf("\n===== DCT GOT OVER ======== \n");
return 0;
}
But I am not getting the correct output . I am getting confused that whether my implementation is correct or not .
As I don't know How to attach my fileinput.txt,So I put the file content here.
Sorry for that :(
129.000000 128.000000 145.000000 140.000000 102.000000 93.000000 100.000000 97.000000 94.000000 88.000000 58.000000 67.000000
79.000000 62.000000 62.000000 64.000000 63.000000 63.000000 70.000000 80.000000 61.000000 62.000000 63.000000 64.000000
62.000000 78.000000 66.000000 65.000000 68.000000 74.000000 78.000000 66.000000 67.000000 76.000000 67.000000 65.000000
76.000000 83.000000 66.000000 66.000000 65.000000 66.000000 72.000000 80.000000 65.000000 66.000000 69.000000 80.000000
75.000000 66.000000 71.000000 80.000000 69.000000 80.000000 85.000000 70.000000 77.000000 68.000000 67.000000 80.000000
83.000000 69.000000 71.000000 73.000000 69.000000 70.000000 71.000000 71.000000 70.000000 71.000000 88.000000 86.000000
78.000000 78.000000 70.000000 73.000000 81.000000 83.000000 76.000000 75.000000 72.000000 72.000000 73.000000 75.000000
79.000000 76.000000 80.000000 87.000000 84.000000 79.000000 73.000000 72.000000 72.000000 72.000000 73.000000 79.000000
76.000000 74.000000 76.000000 78.000000 76.000000 74.000000 73.000000 76.000000 78.000000 78.000000 73.000000 74.000000
73.000000 72.000000 72.000000 73.000000 75.000000 77.000000 76.000000 75.000000 74.000000 74.000000 75.000000 78.000000
81.000000 78.000000 75.000000 74.000000 74.000000 74.000000 75.000000 77.000000 79.000000 80.000000 81.000000 78.000000
76.000000 75.000000 74.000000 74.000000 74.000000 75.000000 76.000000 76.000000 75.000000 77.000000 78.000000 79.000000
80.000000 79.000000 79.000000 79.000000 78.000000 76.000000 76.000000 76.000000 76.000000 77.000000 77.000000 77.000000
78.000000 80.000000 80.000000 80.000000 80.000000 80.000000 78.000000 78.000000 78.000000 78.000000 78.000000 80.000000
I think you are talking the dpar parameter for these functions.
Actually, they are not used for the computed result. They are just used for store the intermediate sin/cos data that are used in the TT computation.
For the computation function:
d_forward_trig_transform(double f[], DFTI_DESCRIPTOR_HANDLE *handle, MKL_INT ipar[], double dpar[], MKL_INT *stat);
Both the input and output is F[], which is the same size.
for more information You can refer below link :
link here
this is my xml file
<Example>
<text-frame name="SingleLineText 1" id="Text0" wrapping="true" direction="" suppress- empty-lines="false">
<style-ref name="default"/>
<style name="">
<alignment halign="left" valign="top"/>
<text-style text-color="Color 0" position="normal"/>
<font family-name="Times New Roman" size="14" style="Bold Italic"/>
<paragraph-style text-align="left"/>
</style>
<geometry size="absolute" position="absolute">
<location left="35" top="30"/>
<size width="165" height="45"/>
</geometry>
<condition name="" desc="">
<if>
<expression left="record1/#field3" operator="==" right="'1240 CrocoDoc Lane'"/>
<action-list>
<action type="suppress"/>
</action-list>
</if>
</condition>
<paragraph>
<style>
<paragraph-style indent-left="0" indent-right="0" indent-first="0" indent-hanging="0" line-spacing="multiple" line-spacing-at="1.2" text-align="left"/>
</style>
<text>
<style>
<font family-name="Times New Roman" size="14" style="Bold Italic"/>
<text-style text-color="Color 0" highlight="None" position="normal" character-spacing="0" case="normal"/>
</style>
<content><![CDATA[%(record1/#field3)]]></content>
</text>
</paragraph>
</text-frame>
</Example>
and my code to reading and writing is below.
what i want is to reach at the alignment tag using this and make change.. "/Example/text-frame/style/alignment" xpathexpression but its not working
xmlXPathObject * xpathObj = xmlXPathEvalExpression( (xmlChar*)"/Example/text-frame/style/alignment", xpathCtx );
//xmlXPathObject * xpathObj = xmlXPathEvalExpression( (xmlChar*)"/Example/Objects/Pet", xpathCtx );
if ( xpathObj == NULL ) throw "failed to evaluate xpath";
for(int i=0;i<=1; i++)
{
xmlNode *node = NULL;
if ( xpathObj->nodesetval && xpathObj->nodesetval->nodeTab )
{
node = xpathObj->nodesetval->nodeTab[i];
std::cout << "Found the node we want" << std::endl;
}
else
{throw "failed to find the expected node";}
xmlAttr *attr = node->properties;
while ( attr )
{
std::cout << "Attribute name: " << attr->name << " value: " << attr->children->content << std::endl;
attr = attr->next;
}
xmlSetProp( node, (xmlChar*)"age", (xmlChar*)"3" );
}
Basically, my string looks like this:
#"{{attendee.prefix}} {{attendee.firstname}} {{attendee.lastname}}, fwf<br /><span style="font-size:14px;">lalallasgabab {{attendee.weg2g}} {{attendee.5236t2gsg}} {{attendee.ticket_no}} agagawfbeagabs</span>"
I am trying to extract all the string which encapsulated by 2 curly braces:
[ {{attendee.prefix}}, {{attendee.firstname}}, {{attendee.lastname}}, {{attendee.weg2g}}, {{attendee.5236t2gsg}}, {{attendee.ticket_no}} ]
I have tried these regex, but it always return 1 match if not the whole string.
#"(\\{\\{.*\\}\\})" -> return the whole string
#"\\{\\{[^}]*+\\}\\}" -> only match {{attendee.firstname}}
#"\\b\\{\\{[^}]*+\\}\\}\\b" -> only match {{attendee.prefix}}
Here is my code:
NSString *myString = #"{{attendee.prefix}} {{attendee.firstname}} {{attendee.lastname}}, fwf<br /><span style="font-size:14px;">lalallasgabab {{attendee.weg2g}} {{attendee.5236t2gsg}} {{attendee.ticket_no}} agagawfbeagabs</span>"
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:#"\\{\\{[^}]*+\\}\\}" options:NSRegularExpressionCaseInsensitive error:nil];
NSRange visibleTextRange = NSMakeRange(0, myString.length);
NSArray *matches = [regex matchesInString:myString options:NSMatchingAnchored range:visibleTextRange];
for (NSTextCheckingResult *match in matches)
{
NSLog(#"%#: Match - %#", [self class], [myString substringWithRange:match.range]);
}
I have tried using [match rangeAtIndex:index] but still return the same thing, sometime it is out of bound because the match result is only 1.
Appreciate any help here. Thanks.
PS: I am new to Objective-C and RegEx, so pardon this question.
To iterate over all matches like {{this}}, use this:
NSError *error = NULL;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:#"\\{\\{[^}]*\\}\\}" options:0 error:&error];
NSArray *matches = [regex matchesInString:subject options:0 range:NSMakeRange(0, [subject length])];
NSUInteger matchCount = [matches count];
if (matchCount) {
for (NSUInteger matchIdx = 0; matchIdx < matchCount; matchIdx++) {
NSTextCheckingResult *match = [matches objectAtIndex:matchIdx];
NSRange matchRange = [match range];
NSString *result = [subject substringWithRange:matchRange];
}
}
else { // Nah... No matches.
}
I managed to answer my own question, by using different ways of enumerating the result:
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:#"\\{\\{[^}]*+\\}\\}" options:NSRegularExpressionCaseInsensitive error:nil];
NSString *myString = #"{{attendee.prefix}} {{attendee.firstname}} {{attendee.lastname}}, fwf<br /><span style='font-size:14px;'>lalallasgabab {{attendee.weg2g}} {{attendee.5236t2gsg}} {{attendee.ticket_no}} agagawfbeagabs</span>";
[regex enumerateMatchesInString:myString
options:0
range:NSMakeRange(0, [myString length])
usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) {
NSLog(#"%#: Match - %#", [self class], [self.duplicateBody substringWithRange:result.range]);
}];
With the code above, I am able to iterate through each of the matched string, which is exactly what I wanted.
I am using tinyxml to save data input by the user in a c++ console program. I pass a save function an array of structs that look like the following
struct day
{
string name;
string note;
};
I have seven of these, and pass all seven to the save function that looks like the following
void saveData(day dayArr[])
{
TiXmlDeclaration* declaration = new TiXmlDeclaration("1.0", "UTF-8", "no");//Create DTD
TiXmlDocument* doc = new TiXmlDocument;
doc->LinkEndChild(declaration);
TiXmlElement* week = new TiXmlElement("week");
TiXmlElement* day = new TiXmlElement("day");
TiXmlElement* name = new TiXmlElement("name");
TiXmlElement* note = new TiXmlElement("note");
TiXmlElement* tl = new TiXmlElement("tl");
TiXmlElement* ti = new TiXmlElement("ti");
TiXmlText* dayName = new TiXmlText("");
TiXmlText* dayNote = new TiXmlText("");
for(int i=0; i<7; i++)
{
dayName = new TiXmlText(dayArr[i].name.c_str());
dayNote = new TiXmlText(dayArr[i].note.c_str());
name->LinkEndChild(dayName);
note->LinkEndChild(dayNote);
day->LinkEndChild(name);
day->LinkEndChild(note);
}
week->LinkEndChild(day);
doc->LinkEndChild(week);
doc->SaveFile("test.xml");
cout << "SAVED";
}
It writes this to the file
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<week>
<day>
<name>SundayMondayTuesdayWednesdayThursdayFridaySaturday
</name>
<note>
</note>
</day>
</week>
What i need is this
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<week>
<day>
<name>Sunday</name>
<note> </note>
</day>
<day>
<name>Monday</name>
<note>
</note>
</day>
<day>
<name>Tuesday</name>
<note> </note>
</day>
<day>
<name>Wednesday</name>
<note> </note>
</day>
<day>
<name>Thursday</name>
<note> </note>
</day>
<day>
<name>Friday</name>
<note> </note>
</day>
<day>
<name>Saturday</name>
<note> </note>
</day>
</week>
I can't figure out how to create new elements of the day tag. Thanks in advance for any help.
I haven't used TinyXml before but looking at the structure of the code, you need to create the day element inside your for loop and add it to the week element 7 times - once for each day.
Your current code only adds the day element to the week element once at the end - this is reflected in your xml output.
Taking part of your code - maybe something similar to this below. (This may not compile or be exactly correct but should provide the right idea).
TiXmlElement* week = new TiXmlElement("week");
TiXmlElement* name = new TiXmlElement("name");
TiXmlElement* note = new TiXmlElement("note");
TiXmlElement* tl = new TiXmlElement("tl");
TiXmlElement* ti = new TiXmlElement("ti");
TiXmlText* dayName = new TiXmlText("");
TiXmlText* dayNote = new TiXmlText("");
for(int i=0; i<7; i++)
{
TiXmlElement* day = new TiXmlElement("day");
dayName = new TiXmlText(dayArr[i].name.c_str());
dayNote = new TiXmlText(dayArr[i].note.c_str());
name->LinkEndChild(dayName);
note->LinkEndChild(dayNote);
day->LinkEndChild(name);
day->LinkEndChild(note);
week->LinkEndChild(day);
}
doc->LinkEndChild(week);
void saveData(std::vector<day*> vecDay)
{
TiXmlDeclaration* declaration = new TiXmlDeclaration("1.0", "UTF-8", "no");//Create DTD
TiXmlDocument* doc = new TiXmlDocument;
doc->LinkEndChild(declaration);
TiXmlElement* week = new TiXmlElement("week");
for(std::vector<day*>::iterator it = vecDay.begin(); it != vecDay.end(); it++)
{
TiXmlElement* day_ = new TiXmlElement("day");
TiXmlElement* name = new TiXmlElement("name");
TiXmlElement* note = new TiXmlElement("note");
TiXmlElement* tl = new TiXmlElement("tl");
TiXmlElement* ti = new TiXmlElement("ti");
TiXmlText* dayName = new TiXmlText("");
TiXmlText* dayNote = new TiXmlText("");
dayName = new TiXmlText((*it)->name.c_str());
dayNote = new TiXmlText((*it)->note.c_str());
name->LinkEndChild(dayName);
note->LinkEndChild(dayNote);
day_->LinkEndChild(name);
day_->LinkEndChild(note);
week->LinkEndChild(day_);
}
doc->LinkEndChild(week);
doc->SaveFile("test2.xml");
cout << "SAVED" << endl;
}