本文整理汇总了PHP中CValue类的典型用法代码示例。如果您正苦于以下问题:PHP CValue类的具体用法?PHP CValue怎么用?PHP CValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getHtmlValue
/**
* @see parent::getHtmlValue()
*/
function getHtmlValue($object, $smarty = null, $params = array())
{
$value = $object->{$this->fieldName};
// Empty value: no paragraph
if (!$value) {
return "";
}
// Truncate case: no breakers but inline bullets instead
if ($truncate = CValue::read($params, "truncate")) {
$value = CMbString::truncate($value, $truncate === true ? null : $truncate);
$value = CMbString::nl2bull($value);
return CMbString::htmlSpecialChars($value);
}
// Markdown case: full delegation
if ($this->markdown) {
// In order to prevent from double escaping
$content = CMbString::markdown(html_entity_decode($value));
return "<div class='markdown'>{$content}</div>";
}
// Standard case: breakers and paragraph enhancers
$text = "";
$value = str_replace(array("\r\n", "\r"), "\n", $value);
$paragraphs = preg_split("/\n{2,}/", $value);
foreach ($paragraphs as $_paragraph) {
if (!empty($_paragraph)) {
$_paragraph = nl2br(CMbString::htmlSpecialChars($_paragraph));
$text .= "<p>{$_paragraph}</p>";
}
}
return $text;
}
示例2: getValue
/**
* @see parent::getValue()
*/
function getValue($object, $smarty = null, $params = array())
{
include_once $smarty->_get_plugin_filepath('modifier', 'date_format');
$propValue = $object->{$this->fieldName};
$format = CValue::first(@$params["format"], CAppUI::conf("time"));
return $propValue ? smarty_modifier_date_format($propValue, $format) : "";
}
示例3: doStore
/**
* Store
*
* @return void
*/
function doStore()
{
// keep track of former values for fieldModified below
$obj = $this->_obj;
$old = $obj->loadOldObject();
if ($msg = $obj->store()) {
CAppUI::setMsg($msg, UI_MSG_ERROR);
if ($this->redirectError) {
CAppUI::redirect($this->redirectError);
}
} else {
// Keep trace for redirections
CValue::setSession($this->objectKey, $obj->_id);
// Insert new group and function permission
if ($obj->fieldModified("function_id") || !$old->_id) {
$obj->insFunctionPermission();
$obj->insGroupPermission();
}
// Message
CAppUI::setMsg($old->_id ? $this->modifyMsg : $this->createMsg, UI_MSG_OK);
// Redirection
if ($this->redirectStore) {
CAppUI::redirect($this->redirectStore);
}
}
}
示例4: checkProtection
/**
* Check anti-CSRF protection
*/
static function checkProtection()
{
if (!CAppUI::conf("csrf_protection") || strtoupper($_SERVER['REQUEST_METHOD']) != 'POST') {
return;
}
if (!isset($_POST["csrf"])) {
CAppUI::setMsg("CCSRF-no_token", UI_MSG_ERROR);
return;
}
if (array_key_exists($_POST['csrf'], $_SESSION["tokens"])) {
$token = $_SESSION['tokens'][$_POST['csrf']];
if ($token["lifetime"] >= time()) {
foreach ($token["fields"] as $_field => $_value) {
if (CValue::read($_POST, $_field) != $_value) {
CAppUI::setMsg("CCSRF-form_corrupted", UI_MSG_ERROR);
unset($_SESSION['tokens'][$_POST['csrf']]);
return;
}
}
//mbTrace("Le jeton est accepté !");
unset($_SESSION['tokens'][$_POST['csrf']]);
} else {
CAppUI::setMsg("CCSRF-token_outdated", UI_MSG_ERROR);
unset($_SESSION['tokens'][$_POST['csrf']]);
}
return;
}
CAppUI::setMsg("CCSRF-token_does_not_exist", UI_MSG_ERROR);
return;
}
示例5: doDelete
function doDelete()
{
parent::doDelete();
$dialog = CValue::post("dialog");
if ($dialog) {
$this->redirectDelete .= "&name=" . $this->_obj->nom . "&firstName=" . $this->_obj->prenom . "&id=0";
}
}
示例6: doStore
/**
* @see parent::doStore()
*/
function doStore()
{
if (isset($_FILES['attachment'])) {
$mail_id = CValue::post('mail_id');
$mail = new CUserMail();
$mail->load($mail_id);
$files = array();
foreach ($_FILES['attachment']['error'] as $key => $file_error) {
if (isset($_FILES['attachment']['name'][$key])) {
$files[] = array('name' => $_FILES['attachment']['name'][$key], 'tmp_name' => $_FILES['attachment']['tmp_name'][$key], 'error' => $_FILES['attachment']['error'][$key], 'size' => $_FILES['attachment']['size'][$key]);
}
}
foreach ($files as $_key => $_file) {
if ($_file['error'] == UPLOAD_ERR_NO_FILE) {
continue;
}
if ($_file['error'] != 0) {
CAppUI::setMsg(CAppUI::tr("CFile-msg-upload-error-" . $_file["error"]), UI_MSG_ERROR);
continue;
}
$attachment = new CMailAttachments();
$attachment->name = $_file['name'];
$content_type = mime_content_type($_file['tmp_name']);
$attachment->type = $attachment->getTypeInt($content_type);
$attachment->bytes = $_file['size'];
$attachment->mail_id = $mail_id;
$content_type = explode('/', $content_type);
$attachment->subtype = strtoupper($content_type[1]);
$attachment->disposition = 'ATTACHMENT';
$attachment->extension = substr(strrchr($attachment->name, '.'), 1);
$attachment->part = $mail->countBackRefs('mail_attachments') + 1;
$attachment->store();
$file = new CFile();
$file->setObject($attachment);
$file->author_id = CAppUI::$user->_id;
$file->file_name = $attachment->name;
$file->file_date = CMbDT::dateTime();
$file->fillFields();
$file->updateFormFields();
$file->doc_size = $attachment->bytes;
$file->file_type = mime_content_type($_file['tmp_name']);
$file->moveFile($_file, true);
if ($msg = $file->store()) {
CAppUI::setMsg(CAppUI::tr('CMailAttachments-error-upload-file') . ':' . CAppUI::tr($msg), UI_MSG_ERROR);
CApp::rip();
}
$attachment->file_id = $file->_id;
if ($msg = $attachment->store()) {
CAppUI::setMsg($msg, UI_MSG_ERROR);
CApp::rip();
}
}
CAppUI::setMsg('CMailAttachments-msg-added', UI_MSG_OK);
} else {
parent::doStore();
}
}
示例7: getValue
/**
* @see parent::getValue()
*/
function getValue($object, $smarty = null, $params = array())
{
if ($smarty) {
include_once $smarty->_get_plugin_filepath('modifier', 'date_format');
}
$propValue = $object->{$this->fieldName};
$format = CValue::first(@$params["format"], CAppUI::conf("date"));
return $propValue && $propValue != "0000-00-00" ? $this->progressive ? $this->progressiveFormat($propValue) : smarty_modifier_date_format($propValue, $format) : "";
// TODO: test and use strftime($format, strtotime($propValue)) instead of smarty
}
示例8: updateFormFields
/**
* @see parent::updateFormFields()
*/
function updateFormFields()
{
$this->_query_params_get = $get = json_decode($this->query_params_get, true);
$this->_query_params_post = $post = json_decode($this->query_params_post, true);
$this->_session_data = $session = json_decode($this->session_data, true);
$get = is_array($get) ? $get : array();
$post = is_array($post) ? $post : array();
$this->_module = CValue::first(CMbArray::extract($get, "m"), CMbArray::extract($post, "m"));
$this->_action = CValue::first(CMbArray::extract($get, "tab"), CMbArray::extract($get, "a"), CMbArray::extract($post, "dosql"));
}
示例9: redirect
/**
* Redirect to the last page
*
* @return void
*/
function redirect()
{
if (CValue::post("ajax")) {
echo CAppUI::getMsg();
CApp::rip();
}
$m = CValue::post("m");
$tab = CValue::post("tab");
CAppUI::redirect("m={$m}&tab={$tab}");
}
示例10: doStore
function doStore()
{
parent::doStore();
$dialog = CValue::post("dialog");
$isNew = !CValue::post("patient_id");
$patient_id = $this->_obj->patient_id;
if ($isNew) {
$this->redirectStore .= "&patient_id={$patient_id}&created={$patient_id}";
} elseif ($dialog) {
$this->redirectStore .= "&name=" . $this->_obj->nom . "&firstname=" . $this->_obj->prenom;
}
}
示例11: doBind
function doBind()
{
$this->ajax = CValue::post("ajax");
$this->suppressHeaders = CValue::post("suppressHeaders");
$this->callBack = CValue::post("callback");
unset($_POST["ajax"]);
unset($_POST["suppressHeaders"]);
unset($_POST["callback"]);
// Object binding
$this->_obj->bind($_POST["suivi"]);
$this->_old->load($this->_obj->_id);
}
示例12: run
/**
* Run test
*
* @param string $code Event code
* @param CCnStep $step Step
*
* @throws CMbException
*
* @return void
*/
static function run($code, CCnStep $step)
{
$receiver = $step->_ref_test->loadRefPartner()->loadReceiverHL7v2();
if ($receiver) {
CValue::setSessionAbs("cn_receiver_guid", $receiver->_guid);
}
$transaction = str_replace("-", "", $step->transaction);
if (!$transaction) {
throw new CMbException("CIHETestCase-no_transaction");
}
call_user_func(array("C{$transaction}Test", "test{$code}"), $step);
}
示例13: toMB
function toMB($value, CHL7v2Field $field)
{
$parsed = $this->parseHL7($value, $field);
// empty value
if ($parsed === "") {
return "";
}
// invalid value
if ($parsed === false) {
return;
}
return CValue::read($parsed, "hour", "00") . ":" . CValue::read($parsed, "minute", "00") . ":" . CValue::read($parsed, "second", "00");
}
示例14: toHL7
function toHL7($value, CHL7v2Field $field)
{
$parsed = $this->parseMB($value, $field);
// empty value
if ($parsed === "") {
return "";
}
// invalid value
if ($parsed === false) {
return;
}
return CValue::read($parsed, "year") . (CValue::read($parsed, "month") === "00" ? "" : CValue::read($parsed, "month")) . (CValue::read($parsed, "day") === "00" ? "" : CValue::read($parsed, "day")) . CValue::read($parsed, "hour") . CValue::read($parsed, "minute") . CValue::read($parsed, "second");
}
示例15: toMB
function toMB($value, CHL7v2Field $field)
{
$parsed = $this->parseHL7($value, $field);
// empty value
if ($parsed === "") {
return "";
}
// invalid value
if ($parsed === false) {
return;
}
return CValue::read($parsed, "year") . "-" . CValue::read($parsed, "month", "00") . "-" . CValue::read($parsed, "day", "00");
}