本文整理汇总了PHP中CustomFields类的典型用法代码示例。如果您正苦于以下问题:PHP CustomFields类的具体用法?PHP CustomFields怎么用?PHP CustomFields使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CustomFields类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: saveCustomField
/**
* Save CustomFields
* @param CustomFields $customFields
* @returns boolean
* @throws DaoException, DataDuplicationException
*/
public function saveCustomField(CustomFields $customFields)
{
try {
$q = Doctrine_Query::create()->from('CustomFields c')->where('c.name = ?', $customFields->name)->andWhere('c.field_num <> ?', $customFields->field_num);
$freeNum = null;
if (empty($customFields->field_num)) {
$q = Doctrine_Query::create()->select('c.field_num')->from('CustomFields c')->orderBy('field_num');
$fieldNumbers = $q->execute(array(), Doctrine::HYDRATE_SCALAR);
$count = count($fieldNumbers);
$i = 1;
foreach ($fieldNumbers as $num) {
if ($num['c_field_num'] > $i) {
$freeNum = $i;
break;
}
$i++;
if ($i > 10) {
break;
}
}
if (empty($freeNum) && $i <= 10) {
$freeNum = $i;
}
$customFields->field_num = $freeNum;
}
if (!empty($customFields->field_num)) {
$customFields->save();
}
return $customFields;
// return true;
} catch (Doctrine_Exception $e) {
throw new DaoException($e->getMessage());
}
}
示例3: perform
/**
* Carries out the specified action
*/
function perform()
{
// fetch the field information
$this->_fieldId = $this->_request->getValue("fieldId");
$fields = new CustomFields();
$field = $fields->getCustomField($this->_fieldId);
// show an error if we couldn't fetch the link
if (!$field) {
$this->_view = new AdminCustomFieldsListView($this->_blogInfo);
$this->_view->setErrorMessage($this->_locale->tr("error_fetching_custom_field"));
} else {
// fire the field loaded event, in case any plugin wants to do anything with it...
$this->notifyEvent(EVENT_CUSTOM_FIELD_LOADED, array("field" => &$field));
$this->_view = new AdminTemplatedView($this->_blogInfo, "editcustomfield");
$this->_view->setValue("fieldName", $field->getName());
$this->_view->setValue("fieldDescription", $field->getDescription());
$this->_view->setValue("fieldId", $field->getId());
$this->_view->setValue("fieldType", $field->getType());
$this->_view->setValue("fieldSearchable", true);
$this->_view->setValue("fieldHidden", $field->isHidden());
}
$this->setCommonData();
// better to return true if everything fine
return true;
}
示例4: render
/**
* load the fields and pass them to the view
*/
function render()
{
// load the custom fields that have been defined so far
$customFields = new CustomFields();
$blogFields = $customFields->getBlogCustomFields($this->_blogInfo->getId(), true, $this->_page, DEFAULT_ITEMS_PER_PAGE);
$this->notifyEvent(EVENT_CUSTOM_FIELDS_LOADED, array("fields" => &$blogFields));
// and the total number of them too
$numBlogFields = $customFields->getNumBlogCustomFields($this->_blogInfo->getId());
// create the pager
$pager = new Pager("?op=blogCustomFields&page=", $this->_page, $numBlogFields, DEFAULT_ITEMS_PER_PAGE);
// and show them
$this->setValue("fields", $blogFields);
$this->setValue("pager", $pager);
return parent::render();
}
示例5: getCustomFieldValueByFieldId
/**
* returns the right CustomFieldValuexxx object but this method can be used
* in those occasions when we know the fieldId but we do not know its type so what we need to do
* is first load the field definition and then work on creating the right object type
*
* @param fieldId
* @param row An array
* @see getCustomFieldValueObject
*/
function getCustomFieldValueByFieldId($fieldId, $row)
{
// load the field definition first
$customFields = new CustomFields();
$customField = $customFields->getCustomField($fieldId);
if (!$customField) {
return false;
}
// if everything went fine, then continue
$row["field_id"] = $fieldId;
$row["field_type"] = $customField->getType();
$row["field_description"] = $customField->getDescription();
$row["field_name"] = $customField->getName();
$fieldValueObject = CustomFieldValueFactory::getCustomFieldValueObject($row);
return $fieldValueObject;
}
示例6: render
function render()
{
// fetch the categories
$categories = new ArticleCategories();
$blogSettings = $this->_blogInfo->getSettings();
$categoriesOrder = $blogSettings->getValue("categories_order");
$blogCategories = $categories->getBlogCategories($this->_blogInfo->getId(), false, $categoriesOrder);
// get some stuff for the time stamp of the post, which is changeable now
//$t = new Timestamp();
$t = Timestamp::getBlogDate($this->_blogInfo);
//$t->toUTC();
//
// changes to make plog store its dates with the time difference already
// applied, instead of applying it dynamically
//
$config =& Config::getConfig();
/*if( $config->getValue( "time_difference_calculation" == TIME_DIFFERENCE_CALCULATION_STATIC ) {
$blogSettings = $this->_blogInfo->getSettings();
$difference = $blogSettings->getValue( "time_offset" );
$t->setDate( Timestamp::getDateWithOffset( $t->getDate(), $difference ), DATE_FORMAT_TIMESTAMP );
}*/
// fetch the custom fields, if any, but not including the ones that have been set to "hidden"...
$customFields = new CustomFields();
$blogFields = $customFields->getBlogCustomFields($this->_blogInfo->getId(), false);
// and put everything in the template
$locale = $this->_blogInfo->getLocale();
$this->setValue("commentsEnabled", $blogSettings->getValue("comments_enabled"));
$this->setValue("categories", $blogCategories);
$this->setValue("today", $t);
$this->setValue("months", $locale->getMonthNames());
$this->setValue("days", $locale->getDayNamesShort());
$this->setValue("years", Timestamp::getYears());
$this->setValue("hours", Timestamp::getAllHours());
$this->setValue("minutes", Timestamp::getAllMinutes());
$this->setValue("customfields", $blogFields);
$this->setValue("poststatus", ArticleStatus::getStatusList());
$this->setValue("sendPings", $config->getValue("send_xmlrpc_pings_enabled_by_default", true));
$this->setValue("xmlRpcPingEnabled", $config->getValue("xmlrpc_ping_enabled", false));
$this->setValue("autoSaveNewDraftsTimeMillis", $config->getValue("autosave_new_drafts_time_millis"));
$this->setValue("xmlHttpRequestSupportEnabled", $config->getValue("save_drafts_via_xmlhttprequest_enabled"));
$this->setValue("postDateTime", $t->getDay() . "/" . $t->getMonth() . "/" . $t->getYear() . " " . $t->getHour() . ":" . $t->getMinutes());
parent::render();
}
示例7: _updateFields
/**
* checks if the fields already exist and if so, disables them (sets them to be "hidden")
*/
function _updateFields()
{
$customFields = new CustomFields();
$blogFields = $customFields->getBlogCustomFields($this->_blogInfo->getId());
// check if the checkbox fields exists
if (array_key_exists("password_protected", $blogFields)) {
_debug("hiding! password field!");
$protectedField = $blogFields["password_protected"];
$protectedField->setHidden(true);
$customFields->updateCustomField($protectedField);
}
// check if the field for the password exists
if (array_key_exists("password_field", $blogFields)) {
_debug("hiding! pass-word field!");
$passwordField = $blogFields["password_field"];
$passwordField->setHidden(true);
$customFields->updateCustomField($passwordField);
}
return true;
}
示例8: execute
/**
* Delete custom fields
* @param $request
* @return unknown_type
*/
public function execute($request)
{
$admin = $this->getUser()->hasCredential(Auth::ADMIN_ROLE);
if (!$admin) {
$this->forward("auth", "unauthorized");
return;
}
$form = new CustomFieldForm(array(), array(), true);
$customFieldsService = $this->getCustomFieldService();
if ($request->isMethod('post')) {
$form->bind($request->getParameter($form->getName()));
if ($form->isValid()) {
$fieldNum = $form->getValue('field_num');
$customField = null;
if (isset($fieldNum)) {
$customField = $customFieldsService->readCustomField($fieldNum);
}
if (empty($customField)) {
$customField = new CustomFields();
}
$customField->setName($form->getValue('name'));
$customField->setType($form->getValue('type'));
$customField->setScreen($form->getValue('screen'));
$customField->setExtraData($form->getValue('extra_data'));
$customFieldsService->saveCustomField($customField);
$this->getUser()->setFlash('templateMessage', array('success', __(TopLevelMessages::SAVE_SUCCESS)));
}
}
$this->redirect('pim/listCustomFields');
}
示例9: _deleteFields
/**
* @private
*/
function _deleteFields()
{
// otherwise, go through all the selected fields and remove them one by one,
// also removing the rows that contain the values
$customFields = new CustomFields();
$errorMessage = "";
$successMessage = "";
$totalOk = 0;
$this->_view = new AdminCustomFieldsListView($this->_blogInfo);
foreach ($this->_fieldIds as $fieldId) {
$field = $customFields->getCustomField($fieldId);
if ($field) {
// fire the pre-event
$this->notifyEvent(EVENT_PRE_CUSTOM_FIELD_DELETE, array("field" => &$field));
$result = $customFields->removeCustomField($fieldId);
if ($result) {
$totalOk++;
if ($totalOk > 1) {
$successMessage = $this->_locale->pr("fields_deleted_ok", $totalOk);
} else {
$successMessage = $this->_locale->pr("field_deleted_ok", $field->getName());
}
// fire the post-event
$this->notifyEvent(EVENT_POST_CUSTOM_FIELD_DELETE, array("field" => &$field));
} else {
$errorMessage .= $this->_locale->pr("error_deleting_field", $field->getName()) . "<br/>";
}
} else {
$errorMessage .= $this->_locale->pr("error_deleting_field2", $fieldId) . "<br/>";
}
}
if ($errorMessage != "") {
$this->_view->setErrorMessage($errorMessage);
}
if ($successMessage != "") {
$this->_view->setSuccessMessage($successMessage);
}
$this->setCommonData();
return true;
}
示例10: perform
/**
* Carries out the specified action
*/
function perform()
{
// fetch the fields from the request
$this->_fieldId = $this->_request->getValue("fieldId");
$this->_fieldName = Textfilter::filterAllHTML($this->_request->getValue("fieldName"));
$this->_fieldDescription = Textfilter::filterAllHTML($this->_request->getValue("fieldDescription"));
$this->_fieldType = $this->_request->getValue("fieldType");
$this->_fieldSearchable = $this->_request->getValue("fieldSearchable");
$this->_fieldHidden = $this->_request->getValue("fieldHidden");
// and start to update the field
$fields = new CustomFields();
$field = $fields->getCustomField($this->_fieldId);
// view that we're going to use for all different flows...
$this->_view = new AdminCustomFieldsListView($this->_blogInfo);
// field couldn't be loaded...
if (!$field) {
$this->_view->setErrorMessage($this->_locale->tr("error_updating_custom_field"));
return false;
}
// ...update its information...
$field->setName($this->_fieldName);
$field->setDescription($this->_fieldDescription);
$field->setType($this->_fieldType);
$field->setHidden($this->_fieldHidden);
// fire the pre-event
$this->notifyEvent(EVENT_PRE_CUSTOM_FIELD_UPDATE, array("field" => &$field));
// ...and finally the data in the database
$result = $fields->updateCustomField($field);
// check the result
if (!$result) {
$this->_view->setErrorMessage($this->_locale->tr("error_updating_custom_field"));
} else {
$this->_view->setSuccessMessage($this->_locale->pr("custom_field_updated_ok", $field->getName()));
// fire the post-event
$this->notifyEvent(EVENT_POST_CUSTOM_FIELD_UPDATE, array("field" => &$field));
}
$this->setCommonData();
return true;
}
示例11: parseEditData
function parseEditData($postArr)
{
$field = new CustomFields();
if (isset($postArr['txtId'])) {
$field->setFieldNumber(trim($postArr['txtId']));
$field->setName(trim($postArr['txtFieldName']));
$field->setFieldType(trim($postArr['cmbFieldType']));
if ($field->getFieldType() == CustomFields::FIELD_TYPE_SELECT) {
$field->setExtraData(trim($postArr['txtExtra']));
}
}
return $field;
}
示例12: _install
public function _install()
{
$this->db->where('name', 'digital_products')->update('components', array('autoload' => '1', 'enabled' => '1'));
$field = new CustomFields();
$field->setEntity('Product')->setIsActive(true)->setname('dplink')->setfLabel('Link to digital content')->settypeId(3);
$field->save();
ShopCore::app()->SSettings->set('DPLinkCFID', $field->getId());
/** We recomend to use http://ellislab.com/codeigniter/user-guide/database/forge.html */
/**
$this->load->dbforge();
$fields = array(
'id' => array('type' => 'INT', 'constraint' => 11, 'auto_increment' => TRUE,),
'name' => array('type' => 'VARCHAR', 'constraint' => 50,),
'value' => array('type' => 'VARCHAR', 'constraint' => 100,)
);
$this->dbforge->add_key('id', TRUE);
$this->dbforge->add_field($fields);
$this->dbforge->create_table('mod_empty', TRUE);
*/
/**
*/
}
示例13: testSaveCustomField
/**
* Testing saveCustomField
*/
public function testSaveCustomField()
{
foreach ($this->testCases['CustomFields'] as $k => $v) {
$customFields = new CustomFields();
$customFields->setFieldNum($v['field_num']);
$customFields->setName($v['name']);
$customFields->setType($v['type']);
$customFields->setExtraData($v['extra_data']);
$result = $this->customFieldsDao->saveCustomField($customFields);
$this->assertTrue($result);
}
}
示例14: testReadCustomField
/**
* Testing readCustomField
*/
public function testReadCustomField()
{
foreach ($this->testCases['CustomFields'] as $k => $v) {
$customFields = new CustomFields();
$customFields->setFieldNum($v['field_num']);
$customFields->setName($v['name']);
$customFields->setType($v['type']);
$customFields->setExtraData($v['extra_data']);
$this->customFieldsDao = $this->getMock('CustomFieldsDao');
$this->customFieldsDao->expects($this->once())->method('readCustomField')->will($this->returnValue($customFields));
$this->customFieldsService->setCustomFieldsDao($this->customFieldsDao);
$result = $this->customFieldsService->readCustomField($v['field_num']);
$this->assertTrue($result instanceof CustomFields);
}
}
示例15: updateCustomField
/**
* Actualizar campo personalizado
*
* @return bool
*/
public function updateCustomField()
{
$curField = self::getCustomFields($this->_id, true);
$query = 'UPDATE customFieldsDef SET ' . 'customfielddef_module = :module, ' . 'customfielddef_field = :field ' . 'WHERE customfielddef_id= :id LIMIT 1';
$data['module'] = $this->_module;
$data['field'] = serialize($this);
$data['id'] = $this->_id;
$queryRes = DB::getQuery($query, __FUNCTION__, $data);
if ($queryRes && $curField->customfielddef_module !== $this->_module) {
$queryRes = CustomFields::updateCustomFieldModule($this->_module, $this->_id);
}
return $queryRes;
}