本文整理汇总了PHP中Property::setDataFromEditmode方法的典型用法代码示例。如果您正苦于以下问题:PHP Property::setDataFromEditmode方法的具体用法?PHP Property::setDataFromEditmode怎么用?PHP Property::setDataFromEditmode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Property
的用法示例。
在下文中一共展示了Property::setDataFromEditmode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addPropertiesToDocument
protected function addPropertiesToDocument(Document $document)
{
// properties
if ($this->_getParam("properties")) {
$properties = array();
// assign inherited properties
foreach ($document->getProperties() as $p) {
if ($p->isInherited()) {
$properties[$p->getName()] = $p;
}
}
$propertiesData = Zend_Json::decode($this->_getParam("properties"));
if (is_array($propertiesData)) {
foreach ($propertiesData as $propertyName => $propertyData) {
$value = $propertyData["data"];
try {
$property = new Property();
$property->setType($propertyData["type"]);
$property->setName($propertyName);
$property->setCtype("document");
$property->setDataFromEditmode($value);
$property->setInheritable($propertyData["inheritable"]);
$properties[$propertyName] = $property;
} catch (Exception $e) {
Logger::warning("Can't add " . $propertyName . " to document " . $document->getFullPath());
}
}
}
if ($document->isAllowed("properties")) {
$document->setProperties($properties);
}
}
// force loading of properties
$document->getProperties();
}
示例2: saveAction
public function saveAction()
{
$success = false;
if ($this->_getParam("id")) {
$asset = Asset::getById($this->_getParam("id"));
if ($asset->isAllowed("publish")) {
// properties
if ($this->_getParam("properties")) {
$properties = array();
$propertiesData = Zend_Json::decode($this->_getParam("properties"));
if (is_array($propertiesData)) {
foreach ($propertiesData as $propertyName => $propertyData) {
$value = $propertyData["data"];
try {
$property = new Property();
$property->setType($propertyData["type"]);
$property->setName($propertyName);
$property->setCtype("asset");
$property->setDataFromEditmode($value);
$property->setInheritable($propertyData["inheritable"]);
$properties[$propertyName] = $property;
} catch (Exception $e) {
Logger::err("Can't add " . $propertyName . " to asset " . $asset->getFullPath());
}
}
$asset->setProperties($properties);
}
}
// scheduled tasks
if ($this->_getParam("scheduler")) {
$tasks = array();
$tasksData = Zend_Json::decode($this->_getParam("scheduler"));
if (!empty($tasksData)) {
foreach ($tasksData as $taskData) {
$taskData["date"] = strtotime($taskData["date"] . " " . $taskData["time"]);
$task = new Schedule_Task($taskData);
$tasks[] = $task;
}
}
$asset->setScheduledTasks($tasks);
}
if ($this->_getParam("data")) {
$asset->setData($this->_getParam("data"));
}
$asset->setUserModification($this->getUser()->getId());
try {
$asset->save();
$asset->getData();
$success = true;
} catch (Exception $e) {
$this->_helper->json(array("success" => false, "message" => $e->getMessage()));
}
} else {
Logger::debug("prevented save asset because of missing permissions ");
}
$this->_helper->json(array("success" => $success));
}
$this->_helper->json(false);
}
示例3: assignPropertiesFromEditmode
protected function assignPropertiesFromEditmode($object)
{
if ($this->_getParam("properties")) {
$properties = array();
// assign inherited properties
foreach ($object->getProperties() as $p) {
if ($p->isInherited()) {
$properties[$p->getName()] = $p;
}
}
$propertiesData = Zend_Json::decode($this->_getParam("properties"));
if (is_array($propertiesData)) {
foreach ($propertiesData as $propertyName => $propertyData) {
$value = $propertyData["data"];
try {
$property = new Property();
$property->setType($propertyData["type"]);
$property->setName($propertyName);
$property->setCtype("object");
$property->setDataFromEditmode($value);
$property->setInheritable($propertyData["inheritable"]);
$properties[$propertyName] = $property;
} catch (Exception $e) {
Logger::err("Can't add " . $propertyName . " to object " . $object->getFullPath());
}
}
}
$object->setProperties($properties);
}
return $object;
}
示例4: getRandomProperties
/**
* @param string $ctype
*
* @return array
*/
protected function getRandomProperties($ctype)
{
$document = $this->createRandomDocument("snippet");
$asset = $this->createRandomAssetImage();
$object = $this->createRandomObject("unittest");
$properties = array();
// object property
$property = new Property();
$property->setType("object");
$property->setName("object");
$property->setCtype($ctype);
$property->setDataFromEditmode($object->getFullPath());
$property->setInheritable(true);
$properties["object"] = $property;
// document property
$property = new Property();
$property->setType("document");
$property->setName("document");
$property->setCtype($ctype);
$property->setDataFromEditmode($document->getFullPath());
$property->setInheritable(true);
$properties["document"] = $property;
// asset property
$property = new Property();
$property->setType("asset");
$property->setName("asset");
$property->setCtype($ctype);
$property->setDataFromEditmode($asset->getFullPath());
$property->setInheritable(true);
$properties["asset"] = $property;
// text property
$property = new Property();
$property->setType("text");
$property->setName("text");
$property->setCtype($ctype);
$property->setDataFromEditmode("hallo property");
$property->setInheritable(true);
$properties["text"] = $property;
// bool property
$property = new Property();
$property->setType("bool");
$property->setName("bool");
$property->setCtype($ctype);
$property->setDataFromEditmode(true);
$property->setInheritable(true);
$properties["bool"] = $property;
// date property
$property = new Property();
$property->setType("date");
$property->setName("date");
$property->setCtype($ctype);
$property->setDataFromEditmode(new Zend_Date());
$property->setInheritable(true);
$properties["date"] = $property;
return $properties;
}