本文整理匯總了PHP中eZContentClassAttribute::setContent方法的典型用法代碼示例。如果您正苦於以下問題:PHP eZContentClassAttribute::setContent方法的具體用法?PHP eZContentClassAttribute::setContent怎麽用?PHP eZContentClassAttribute::setContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類eZContentClassAttribute
的用法示例。
在下文中一共展示了eZContentClassAttribute::setContent方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: customClassAttributeHTTPAction
//.........這裏部分代碼省略.........
$customActionKeyName = "{$id}_{$action}";
$idArrayName = join('_', array($base, 'sckenhancedselection_id', $id));
$idArray = array();
if ($http->hasPostVariable($idArrayName)) {
$idArray = $http->postVariable($idArrayName);
}
switch ($action) {
case 'new_option':
$maxID = 0;
foreach ($content['options'] as $option) {
if (intval($option['id']) > $maxID) {
$maxID = intval($option['id']);
}
}
$maxID++;
$content['options'][] = array('id' => $maxID, 'name' => '', 'identifier' => '', 'priority' => 1);
break;
case 'remove_optionlist':
$removeArrayName = join('_', array($base, "sckenhancedselection_remove", $id));
if ($http->hasPostVariable($removeArrayName)) {
$removeArray = $http->postVariable($removeArrayName);
foreach ($removeArray as $removeID) {
unset($idArray[$removeID]);
unset($content['options'][$removeID]);
}
}
break;
case 'move_up':
$customActionVar = $http->postVariable($customActionVarName);
// This is where the user clicked
$customActionValue = $customActionVar[$customActionKeyName];
// Up == swap selected row with the one above
// Or: Move the row above below the selected one
$this->swapRows($customActionValue - 1, $customActionValue, $content, $idArray);
break;
case 'move_down':
$customActionVar = $http->postVariable($customActionVarName);
// This is where the user clicked
$customActionValue = $customActionVar[$customActionKeyName];
// Down == swap selected row with the one below
// Or: Move the selected row below the one below
$this->swapRows($customActionValue, $customActionValue + 1, $content, $idArray);
break;
case 'sort_optionlist':
$sortName = join('_', array($base, 'sckenhancedselection_sort_order', $id));
if ($http->hasPostVariable($sortName)) {
$sort = $http->postVariable($sortName);
$sortArray = array();
$sortOrder = SORT_ASC;
$sortType = SORT_STRING;
$numericSorts = array('prior');
if (strpos($sort, '_') !== false) {
list($type, $ranking) = explode('_', $sort);
$currentOptions = $content['options'];
if ($ranking === 'desc') {
$sortOrder = SORT_DESC;
}
if (in_array($type, $numericSorts)) {
$sortType = SORT_NUMERIC;
}
// Use POST priorities instead of the stored ones
// Otherwise you have to store new priorities before you can sort
$priorityArray = array();
if ($type == 'prior') {
$priorityArray = $http->postVariable(join('_', array($base, 'sckenhancedselection_priority', $id)));
}
foreach (array_keys($currentOptions) as $key) {
$option = $currentOptions[$key];
switch ($type) {
case 'prior':
if (isset($priorityArray[$option['id']])) {
$option['priority'] = $priorityArray[$option['id']];
}
$sortArray[] = $option['priority'];
break;
case 'alpha':
default:
$sortArray[] = $option['name'];
break;
}
unset($option);
}
array_multisort($sortArray, $sortOrder, $sortType, $currentOptions);
$idArray = array();
foreach ($currentOptions as $option) {
$idArray[] = $option['id'];
}
$content['options'] = $currentOptions;
} else {
eZDebug::writeError("Unknown sort value. Please use the form type_order (ex. alpha_asc)", "SckEnhancedSelectionType");
}
}
break;
default:
eZDebug::writeError("Unknown class HTTP action: {$action}", "SckEnhancedSelectionType");
}
$classAttribute->setContent($content);
$classAttribute->store();
$http->setPostVariable($idArrayName, $idArray);
}
示例2: fetchClassAttributeHTTPInput
/**
* Fetches class attribute HTTP input and stores it
*
* @param eZHTTPTool $http
* @param string $base
* @param eZContentClassAttribute $attribute
*
* @return bool
*/
function fetchClassAttributeHTTPInput($http, $base, $attribute)
{
$base;
// Just for phpcs
if ($http->hasPostVariable("ContentClass_novaseometas_keyvalue_{$attribute->attribute('id')}")) {
$metasKv = $http->postVariable("ContentClass_novaseometas_keyvalue_{$attribute->attribute('id')}");
$attribute->setContent($metasKv);
}
return true;
}