本文整理汇总了PHP中RGFormsModel::is_unique_title方法的典型用法代码示例。如果您正苦于以下问题:PHP RGFormsModel::is_unique_title方法的具体用法?PHP RGFormsModel::is_unique_title怎么用?PHP RGFormsModel::is_unique_title使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RGFormsModel
的用法示例。
在下文中一共展示了RGFormsModel::is_unique_title方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: import_xml
public static function import_xml($xmlstr, &$forms = null)
{
require_once 'xml.php';
$options = array('page' => array('unserialize_as_array' => true), 'form' => array('unserialize_as_array' => true), 'field' => array('unserialize_as_array' => true), 'rule' => array('unserialize_as_array' => true), 'choice' => array('unserialize_as_array' => true), 'input' => array('unserialize_as_array' => true), 'routing_item' => array('unserialize_as_array' => true), 'creditCard' => array('unserialize_as_array' => true), 'routin' => array('unserialize_as_array' => true), 'confirmation' => array('unserialize_as_array' => true), 'notification' => array('unserialize_as_array' => true));
$options = apply_filters('gform_import_form_xml_options', $options);
$xml = new RGXML($options);
$forms = $xml->unserialize($xmlstr);
if (!$forms) {
return 0;
} else {
if (version_compare($forms['version'], self::$min_import_version, '<')) {
return -1;
}
}
//Error. XML version is not compatible with current Gravity Forms version
//cleaning up generated object
self::cleanup($forms);
foreach ($forms as $key => &$form) {
$title = $form['title'];
$count = 2;
while (!RGFormsModel::is_unique_title($title)) {
$title = $form['title'] . "({$count})";
$count++;
}
//inserting form
$form_id = RGFormsModel::insert_form($title);
//updating form meta
$form['title'] = $title;
$form['id'] = $form_id;
$form = GFFormsModel::trim_form_meta_values($form);
if (isset($form['confirmations'])) {
$form['confirmations'] = self::set_property_as_key($form['confirmations'], 'id');
$form['confirmations'] = GFFormsModel::trim_conditional_logic_values($form['confirmations'], $form);
GFFormsModel::update_form_meta($form_id, $form['confirmations'], 'confirmations');
unset($form['confirmations']);
}
if (isset($form['notifications'])) {
$form['notifications'] = self::set_property_as_key($form['notifications'], 'id');
$form['notifications'] = GFFormsModel::trim_conditional_logic_values($form['notifications'], $form);
GFFormsModel::update_form_meta($form_id, $form['notifications'], 'notifications');
unset($form['notifications']);
}
RGFormsModel::update_form_meta($form_id, $form);
}
return sizeof($forms);
}
示例2: import_file
public static function import_file($filepath)
{
$xmlstr = file_get_contents($filepath);
require_once "xml.php";
$options = array("page" => array("unserialize_as_array" => true), "form" => array("unserialize_as_array" => true), "field" => array("unserialize_as_array" => true), "rule" => array("unserialize_as_array" => true), "choice" => array("unserialize_as_array" => true), "input" => array("unserialize_as_array" => true), "routing_item" => array("unserialize_as_array" => true), "routin" => array("unserialize_as_array" => true));
$xml = new RGXML($options);
$forms = $xml->unserialize($xmlstr);
if (!$forms) {
return 0;
} else {
if (version_compare($forms["version"], self::$min_import_version, "<")) {
return -1;
}
}
//Error. XML version is not compatible with current Gravity Forms version
//cleaning up generated object
self::cleanup($forms);
foreach ($forms as $key => $form) {
$title = $form["title"];
$count = 2;
while (!RGFormsModel::is_unique_title($title)) {
$title = $form["title"] . "({$count})";
$count++;
}
//inserting form
$form_id = RGFormsModel::insert_form($title);
//updating form meta
$form["title"] = $title;
$form["id"] = $form_id;
RGFormsModel::update_form_meta($form_id, $form);
}
return sizeof($forms);
}
示例3: import_file
public static function import_file($filepath, &$forms = null)
{
$xmlstr = file_get_contents($filepath);
require_once "xml.php";
$options = array("page" => array("unserialize_as_array" => true), "form" => array("unserialize_as_array" => true), "field" => array("unserialize_as_array" => true), "rule" => array("unserialize_as_array" => true), "choice" => array("unserialize_as_array" => true), "input" => array("unserialize_as_array" => true), "routing_item" => array("unserialize_as_array" => true), "creditCard" => array("unserialize_as_array" => true), "routin" => array("unserialize_as_array" => true), "confirmation" => array("unserialize_as_array" => true), "notification" => array("unserialize_as_array" => true));
$options = apply_filters('gform_import_form_xml_options', $options);
$xml = new RGXML($options);
$forms = $xml->unserialize($xmlstr);
if (!$forms) {
return 0;
} else {
if (version_compare($forms["version"], self::$min_import_version, "<")) {
return -1;
}
}
//Error. XML version is not compatible with current Gravity Forms version
//cleaning up generated object
self::cleanup($forms);
foreach ($forms as $key => &$form) {
$title = $form["title"];
$count = 2;
while (!RGFormsModel::is_unique_title($title)) {
$title = $form["title"] . "({$count})";
$count++;
}
//inserting form
$form_id = RGFormsModel::insert_form($title);
//updating form meta
$form["title"] = $title;
$form["id"] = $form_id;
$form = GFFormsModel::trim_form_meta_values($form);
if (isset($form['confirmations'])) {
$form['confirmations'] = self::set_property_as_key($form['confirmations'], 'id');
$form['confirmations'] = GFFormsModel::trim_conditional_logic_values($form['confirmations'], $form);
GFFormsModel::update_form_meta($form_id, $form['confirmations'], 'confirmations');
unset($form['confirmations']);
}
if (isset($form['notifications'])) {
$form['notifications'] = self::set_property_as_key($form['notifications'], 'id');
$form['notifications'] = GFFormsModel::trim_conditional_logic_values($form['notifications'], $form);
GFFormsModel::update_form_meta($form_id, $form['notifications'], 'notifications');
unset($form['notifications']);
}
RGFormsModel::update_form_meta($form_id, $form);
}
return sizeof($forms);
}
示例4: add_form
/**
* Adds a new form using the given Form object. Warning, little checking is done to make sure it's a valid Form object.
*
* @since 1.8
* @access public
* @static
*
* @param array $form_meta The Form object
*
* @return mixed Either the new Form ID or a WP_Error instance
*/
public static function add_form($form_meta)
{
global $wpdb;
if (!$form_meta || !is_array($form_meta)) {
return new WP_Error("invalid", __("Invalid form object", "gravityforms"));
}
if (rgar($form_meta, "title") == "") {
return new WP_Error("missing_title", __("The form title is missing", "gravityforms"));
}
//Making sure title is not duplicate
$title = $form_meta["title"];
$count = 2;
while (!RGFormsModel::is_unique_title($title)) {
$title = $form_meta["title"] . "({$count})";
$count++;
}
//inserting form
$form_id = RGFormsModel::insert_form($title);
//updating form meta
$form_meta["title"] = $title;
//updating object's id property
$form_meta["id"] = $form_id;
if (isset($form_meta['confirmations'])) {
$form_meta['confirmations'] = self::set_property_as_key($form_meta['confirmations'], 'id');
GFFormsModel::update_form_meta($form_id, $form_meta['confirmations'], 'confirmations');
unset($form_meta['confirmations']);
}
if (isset($form_meta['notifications'])) {
$form_meta['notifications'] = self::set_property_as_key($form_meta['notifications'], 'id');
GFFormsModel::update_form_meta($form_id, $form_meta['notifications'], 'notifications');
unset($form_meta['notifications']);
}
//updating form meta
$result = GFFormsModel::update_form_meta($form_id, $form_meta);
if (false === $result) {
return new WP_Error("insert_form_error", __("There was a problem while inserting the form", "gravityforms"), $wpdb->last_error);
}
return $form_id;
}
示例5: generateForm
public static function generateForm()
{
if (class_exists('GFAPI')) {
$thankyouPage = get_page_by_path('events/thank-you', OBJECT, 'page');
$form = array('labelPlacement' => 'top_label', 'useCurrentUserAsAuthor' => '1', 'title' => self::$formTitle, 'descriptionPlacement' => 'below', 'button' => array('type' => 'text', 'text' => 'Submit'), 'fields' => array(array('id' => '1', 'isRequired' => '1', 'size' => 'medium', 'type' => 'name', 'nameFormat' => 'simple', 'label' => 'First Name'), array('id' => '2', 'isRequired' => '1', 'size' => 'medium', 'type' => 'name', 'nameFormat' => 'simple', 'label' => 'Last Name'), array('id' => '3', 'isRequired' => '1', 'size' => 'medium', 'type' => 'email', 'label' => 'Email'), array('id' => '4', 'isRequired' => '1', 'size' => 'medium', 'type' => 'phone', 'phoneFormat' => 'standard', 'label' => 'Phone'), array('id' => '5', 'isRequired' => '1', 'size' => 'medium', 'type' => 'select', 'label' => 'Number Attending', 'choices' => array(array('text' => '1', 'value' => '1'), array('text' => '2', 'value' => '2'), array('text' => '3', 'value' => '3'), array('text' => '4', 'value' => '4'), array('text' => '5', 'value' => '5'), array('text' => '6', 'value' => '6'), array('text' => '7', 'value' => '7'), array('text' => '8', 'value' => '8'))), array('id' => '6', 'size' => 'medium', 'type' => 'hidden', 'defaultValue' => '{embed_post:post_title}', 'label' => 'Event Name'), array('id' => '7', 'size' => 'medium', 'type' => 'hidden', 'defaultValue' => '{embed_post:ID}', 'label' => 'Event Post ID'), array('id' => '8', 'size' => 'medium', 'type' => 'hidden', 'defaultValue' => '{custom_field:_EventStartDate}', 'label' => 'Event Start Date'), array('id' => '9', 'size' => 'medium', 'type' => 'hidden', 'defaultValue' => '{custom_field:_EventEndDate}', 'label' => 'Event End Date'), array('id' => '10', 'size' => 'medium', 'type' => 'hidden', 'defaultValue' => '{custom_field:_EventRecurrence}', 'label' => 'Event Recurrence'), array('id' => '11', 'size' => 'medium', 'type' => 'hidden', 'defaultValue' => '{custom_field:_EventAllDay}', 'label' => 'All Day Event'), array('id' => '90', 'size' => 'medium', 'type' => 'hidden', 'defaultValue' => '', 'label' => 'Event Formatted Date'), array('id' => '91', 'size' => 'medium', 'type' => 'hidden', 'defaultValue' => '', 'label' => 'Event Formatted Time')), 'cssClass' => 'contact-form-gfec-form', 'enableHoneypot' => '1', 'confirmations' => array(array('id' => '5316355c6c8c1', 'isDefault' => '1', 'type' => 'page', 'name' => 'Default Confirmation', 'pageId' => $thankyouPage->ID, 'queryString' => 'eventID={post_id:7}')), 'notifications' => array(array('id' => '53163750d13d3', 'to' => '3', 'name' => 'RSVP', 'event' => 'form_submission', 'toType' => 'field', 'subject' => 'Thank You for Registering for (Event Name:5} - {Event Date:6}', 'message' => '{all_fields}', 'from' => '{admin_email}', 'fromName' => get_bloginfo('name'))));
if (RGFormsModel::is_unique_title($form['title'])) {
$form_id = RGFormsModel::insert_form($form['title']);
$form["id"] = $form_id;
GFFormsModel::trim_form_meta_values($form);
if (isset($form['confirmations'])) {
$form['confirmations'] = GFExport::set_property_as_key($form['confirmations'], 'id');
$form['confirmations'] = GFFormsModel::trim_conditional_logic_values($form['confirmations'], $form);
GFFormsModel::update_form_meta($form_id, $form['confirmations'], 'confirmations');
unset($form['confirmations']);
}
if (isset($form['notifications'])) {
$form['notifications'] = GFExport::set_property_as_key($form['notifications'], 'id');
$form['notifications'] = GFFormsModel::trim_conditional_logic_values($form['notifications'], $form);
GFFormsModel::update_form_meta($form_id, $form['notifications'], 'notifications');
unset($form['notifications']);
}
RGFormsModel::update_form_meta($form_id, $form);
}
}
}