本文整理匯總了PHP中eZContentClassAttribute::content方法的典型用法代碼示例。如果您正苦於以下問題:PHP eZContentClassAttribute::content方法的具體用法?PHP eZContentClassAttribute::content怎麽用?PHP eZContentClassAttribute::content使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類eZContentClassAttribute
的用法示例。
在下文中一共展示了eZContentClassAttribute::content方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: customClassAttributeHTTPAction
/**
* Executes a custom action for a class attribute which was defined on the web page.
*
* @param eZHTTPTool $http
* @param string $action
* @param eZContentClassAttribute $classAttribute
*/
public function customClassAttributeHTTPAction($http, $action, $classAttribute)
{
$id = $classAttribute->attribute('id');
$base = "ContentClass";
$content = $classAttribute->content();
$customActionVarName = "CustomActionButton";
$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'];
}
//.........這裏部分代碼省略.........