本文整理汇总了PHP中CustomFields::addCustomField方法的典型用法代码示例。如果您正苦于以下问题:PHP CustomFields::addCustomField方法的具体用法?PHP CustomFields::addCustomField怎么用?PHP CustomFields::addCustomField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CustomFields
的用法示例。
在下文中一共展示了CustomFields::addCustomField方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CustomFields
/**
* checks if the fields already exist and if not, creates them
*/
function _createFields()
{
$customFields = new CustomFields();
$blogFields = $customFields->getBlogCustomFields($this->_blogInfo->getId());
// check if the checkbox fields exists
if (!array_key_exists("password_protected", $blogFields)) {
_debug("creating password field!");
$protectedField = new CustomField("password_protected", $this->_locale->tr("password_protected_help"), CUSTOM_FIELD_CHECKBOX, $this->_blogInfo->getId());
$customFields->addCustomField($protectedField);
} else {
_debug("enabling! password field!");
$protectedField = $blogFields["password_protected"];
$protectedField->setHidden(false);
$customFields->updateCustomField($protectedField);
}
// check if the field for the password exists
if (!array_key_exists("password_field", $blogFields)) {
_debug("creating pass-word field!");
$passwordField = new CustomField("password_field", $this->_locale->tr("password_field_help"), CUSTOM_FIELD_TEXTBOX, $this->_blogInfo->getId());
$customFields->addCustomField($passwordField);
} else {
_debug("enabling! pass-word field!");
$passwordField = $blogFields["password_field"];
$passwordField->setHidden(false);
$customFields->updateCustomField($passwordField);
}
return true;
}
示例2: perform
/**
* Carries out the specified action
*/
function perform()
{
// fetch the data
$this->_fieldName = Textfilter::filterAllHTML($this->_request->getValue("fieldName"));
$this->_fieldDescription = Textfilter::filterAllHTML($this->_request->getValue("fieldDescription"));
$this->_fieldType = $this->_request->getValue("fieldType");
$this->_fieldSearchable = (int) ($this->_request->getValue("fieldSearchable") != "");
$this->_fieldHidden = (int) ($this->_request->getValue("fieldHidden") != "");
$fields = new CustomFields();
// build the new custom field
$customField = new CustomField($this->_fieldName, $this->_fieldDescription, $this->_fieldType, $this->_blogInfo->getId(), $this->_fieldHidden, $this->_fieldSearchable);
// throw the pre-event
$this->notifyEvent(EVENT_PRE_CUSTOM_FIELD_ADD, array("field" => &$customField));
$result = $fields->addCustomField($customField);
if (!$result) {
$this->_view = new AdminCustomFieldsListView($this->_blogInfo);
$this->_view->setErrorMessage($this->_locale->tr("error_adding_custom_field"));
} else {
$this->_view = new AdminCustomFieldsListView($this->_blogInfo);
$this->_view->setSuccessMessage($this->_locale->pr("custom_field_added_ok", $customField->getName()));
// throw the post-event if all went fine
$this->notifyEvent(EVENT_POST_CUSTOM_FIELD_ADD, array("field" => &$customField));
}
$this->setCommonData();
return true;
}