本文整理汇总了PHP中Convert::Raw2SQL方法的典型用法代码示例。如果您正苦于以下问题:PHP Convert::Raw2SQL方法的具体用法?PHP Convert::Raw2SQL怎么用?PHP Convert::Raw2SQL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Convert
的用法示例。
在下文中一共展示了Convert::Raw2SQL方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ContentImage
function ContentImage()
{
// Check for image
$img = $this->owner->obj('FeaturedImage');
if ($img && $img->exists()) {
return $img;
}
// else try to get first image tag from article.
$matches = array();
if (preg_match('#<img [^>]*src="([^">]+)"#smi', $this->owner->Content, $matches)) {
if (isset($matches[1])) {
$filename = preg_replace('#_resampled/resizedimage[0-9]+-#smi', '', $matches[1]);
$file = DataObject::get_one('File', 'Filename=\'' . Convert::Raw2SQL($filename) . '\'');
if ($file) {
return $file;
}
}
}
}
示例2: pdf
function pdf()
{
exit("deactivated for now...");
if ($ID = Director::urlParam("ID")) {
if ($invoice = DataObject::get_one("ShopInvoice", "PublicURL = '" . Convert::Raw2SQL($ID) . "'")) {
$this->Invoice = $invoice;
if (!isset($_REQUEST['view'])) {
//generate pdf
require dirname(__FILE__) . '/Thirdparty/html2fpdf/html2fpdf.php';
//to get work HTML2PDF
error_reporting(E_ALL ^ (E_NOTICE | E_DEPRECATED));
$pdf = new HTML2FPDF();
$pdf->AddPage();
$pdfPath = $invoice->generatePDF();
$outputPath = TEMP_FOLDER . "/shopsystem/";
$outputFile = $outputPath . $invoice->PublicURL . ".pdf";
$fp = fopen($pdfPath, "r");
$strContent = fread($fp, filesize($pdfPath));
fclose($fp);
$pdf->WriteHTML($strContent);
$pdf->Output($outputFile);
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="invoice.pdf"');
echo file_get_contents($outputFile);
//PDF file is generated successfully!
exit;
}
if (isset($_REQUEST['remove'])) {
//remove invoice from public by generating a new public url
$invoice->PublicURL = ShopInvoice::generatePublicURL();
$invoice->write();
}
}
}
return array();
}
示例3: doSubmitRecieverForm
function doSubmitRecieverForm($data, $form)
{
$text = $data['Text'];
$text = str_replace(",", ";", $text);
$text = str_replace(";;", "; ;", $text);
if ($lines = explode("\n", $text)) {
$id = (int) $data['ID'];
$str = "";
$firstLine = $lines[0];
$fields = explode(";", $firstLine);
$j = 0;
$table = array();
foreach ($fields as $f) {
$f = strtolower(trim($f));
if ($f == "sex" || $f == "gender" || $f == "geschlecht") {
$table['gender'] = $j;
}
if ($f == "first" || $f == "firstname" || $f == "vorname") {
$table['firstname'] = $j;
}
if ($f == "sur" || $f == "surname" || $f == "nachname") {
$table['surname'] = $j;
}
if ($f == "email" || $f == "mail") {
$table['mail'] = $j;
}
$j++;
}
$i = 0;
foreach ($lines as $line) {
$line = trim($line);
if ($segments = explode(";", $line)) {
$firstname = $surname = $gender = null;
if (isset($table['firstname'])) {
$firstname = Convert::Raw2SQL(trim($segments[$table['firstname']]));
}
if (isset($table['surname'])) {
$surname = Convert::Raw2SQL(trim($segments[$table['surname']]));
}
if (isset($table['gender'])) {
$gender = Convert::Raw2SQL(trim($segments[$table['gender']]));
}
//serach all segments for email
foreach ($segments as $s) {
$email = trim($s);
if (eregi("^[a-z0-9]+([-_\\.]?[a-z0-9])+@[a-z0-9]+([-_\\.]?[a-z0-9])+\\.[a-z]{2,4}", $email)) {
if (!DataObject::get("NewsletterReciever", "NewsletterID = {$id} AND Email LIKE '{$email}'")) {
$i++;
$r = new NewsletterReciever();
$r->FirstName = $firstname;
$r->Surname = $surname;
$r->Gender = $gender;
$r->NewsletterID = $id;
$r->Send = 0;
$r->Email = $email;
$r->write();
$str .= "<strong>" . $r->Email . "</strong> ({$gender} {$firstname} {$surname}) hinzugefügt...<br/>\n";
}
}
}
}
}
$form->sessionMessage($str . "<p>{$i} neu eingetragen</p>", 'good');
}
Director::redirectBack();
}
示例4: tree
/**
* Get the whole tree of a part of the tree via an AJAX request.
*
* @param SS_HTTPRequest $request
* @return string
*/
public function tree(SS_HTTPRequest $request)
{
// Array sourceObject is an explicit list of values - construct a "flat tree"
if (is_array($this->sourceObject)) {
$output = "<ul class=\"tree\">\n";
foreach ($this->sourceObject as $k => $v) {
$output .= '<li id="selector-' . $this->name . '-' . $k . '"><a>' . $v . '</a>';
}
$output .= "</ul>";
return $output;
}
// Regular source specification
$isSubTree = false;
$this->search = Convert::Raw2SQL($request->requestVar('search'));
$ID = is_numeric($request->latestparam('ID')) ? (int) $request->latestparam('ID') : (int) $request->requestVar('ID');
if ($ID && !$request->requestVar('forceFullTree')) {
$obj = DataObject::get_by_id($this->sourceObject, $ID);
$isSubTree = true;
if (!$obj) {
throw new Exception("TreeDropdownField->tree(): the object #{$ID} of type {$this->sourceObject} could not be found");
}
} else {
if ($this->baseID) {
$obj = DataObject::get_by_id($this->sourceObject, $this->baseID);
}
if (!$this->baseID || !$obj) {
$obj = singleton($this->sourceObject);
}
}
// pre-process the tree - search needs to operate globally, not locally as marking filter does
if ($this->search != "") {
$this->populateIDs();
}
if ($this->filterCallback || $this->sourceObject == 'Folder' || $this->search != "") {
$obj->setMarkingFilterFunction(array($this, "filterMarking"));
}
$obj->markPartialTree();
// allow to pass values to be selected within the ajax request
if (isset($_REQUEST['forceValue']) || $this->value) {
$forceValue = isset($_REQUEST['forceValue']) ? $_REQUEST['forceValue'] : $this->value;
if (($values = preg_split('/,\\s*/', $forceValue)) && count($values)) {
foreach ($values as $value) {
if (!$value || $value == 'unchanged') {
continue;
}
$obj->markToExpose($this->objectForKey($value));
}
}
}
$self = $this;
$escapeLabelField = $obj->escapeTypeForField($this->labelField) != 'xml';
$titleFn = function (&$child) use(&$self, $escapeLabelField) {
$keyField = $self->keyField;
$labelField = $self->labelField;
return sprintf('<li id="selector-%s-%s" data-id="%s" class="class-%s %s %s"><a rel="%d">%s</a>', Convert::raw2xml($self->getName()), Convert::raw2xml($child->{$keyField}), Convert::raw2xml($child->{$keyField}), Convert::raw2xml($child->class), Convert::raw2xml($child->markingClasses()), $self->nodeIsDisabled($child) ? 'disabled' : '', (int) $child->ID, $escapeLabelField ? Convert::raw2xml($child->{$labelField}) : $child->{$labelField});
};
// Limit the amount of nodes shown for performance reasons.
// Skip the check if we're filtering the tree, since its not clear how many children will
// match the filter criteria until they're queried (and matched up with previously marked nodes).
$nodeThresholdLeaf = Config::inst()->get('Hierarchy', 'node_threshold_leaf');
if ($nodeThresholdLeaf && !$this->filterCallback && !$this->search) {
$className = $this->sourceObject;
$nodeCountCallback = function ($parent, $numChildren) use($className, $nodeThresholdLeaf) {
if ($className == 'SiteTree' && $parent->ID && $numChildren > $nodeThresholdLeaf) {
return sprintf('<ul><li><span class="item">%s</span></li></ul>', _t('LeftAndMain.TooManyPages', 'Too many pages'));
}
};
} else {
$nodeCountCallback = null;
}
if ($isSubTree) {
$html = $obj->getChildrenAsUL("", $titleFn, null, true, $this->childrenMethod, 'numChildren', true, null, $nodeCountCallback);
return substr(trim($html), 4, -5);
} else {
$html = $obj->getChildrenAsUL('class="tree"', $titleFn, null, true, $this->childrenMethod, 'numChildren', true, null, $nodeCountCallback);
return $html;
}
}
示例5: doSubmitSummaryForm
function doSubmitSummaryForm($data, $form)
{
$session = ShopOrder::orderSession();
$session->Note = Convert::Raw2SQL($data['Note']);
if (!isset($data['TermsAndConditions']) && ShopCheckoutPage::$termsAndConditionsAgreementRequired) {
Director::redirect($this->Link() . "agree_terms_and_conditions");
return array();
}
$session->write();
if ($session->isComplete()) {
$this->redirectToNextStepFrom("summary");
}
return array();
}
示例6: checkForSessionOrCreate
static function checkForSessionOrCreate()
{
if (!($session = Session::get(self::$hashField))) {
//create session
$hash = substr(md5(rand(0, 1000) . time()), 0, 10);
$s = new ShopOrder();
if ($m = Member::currentUser()) {
$s->Member = $m;
}
$s->Hash = $hash;
Session::set(self::$hashField, $hash);
$s->IP = $_SERVER['REMOTE_ADDR'];
$s->Currency = self::getLocalCurrency();
$s->VAT = self::getVATType();
$s->Tax = self::getLocalTax();
$s->write();
//generate ID
// else user_error("Couldn't create ShoppingSession...");
} else {
if (!($s = DataObject::get_one("ShopOrder", "Hash = '" . Convert::Raw2SQL($session) . "' AND Status = 'Unsubmitted'"))) {
$hash = substr(md5(rand(0, 1000) . time()), 0, 10);
$s = new ShopOrder();
if ($m = Member::currentUser()) {
$s->Member = $m;
}
$s->Hash = $hash;
Session::set(self::$hashField, $hash);
$s->IP = $_SERVER['REMOTE_ADDR'];
$s->Currency = self::getLocalCurrency();
$s->VAT = self::getVATType();
$s->Tax = self::getLocalTax();
$s->write();
}
}
//create address fields for shipping+invoicing
//is now done in ShopCheckoutPage --> doSubmitEmailForm
if (!($s->PaymentID > 0)) {
$p = new ShopPayment();
$p->Price = 0;
$p->OrderID = $s->ID;
$p->write();
$s->PaymentID = $p->ID;
}
if (!($s->ShippingID > 0)) {
$d = new ShopShipping();
$d->OrderID = $s->ID;
$d->Price = 0;
$d->write();
$s->ShippingID = $d->ID;
}
//save session
$s->write();
return $s;
}