本文整理匯總了PHP中Element::insert方法的典型用法代碼示例。如果您正苦於以下問題:PHP Element::insert方法的具體用法?PHP Element::insert怎麽用?PHP Element::insert使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Element
的用法示例。
在下文中一共展示了Element::insert方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1:
function &insert(&$obj)
{
if (is_a($obj, 'Inline') && !$this->noPara) {
$obj =& $obj->toPara();
}
return parent::insert($obj);
}
示例2: setup_tv_template_access
/**
* Sets up all template access for a template variable
*
* @param integer $tv_id
* @param array $templates
*
* @return boolean
*/
public function setup_tv_template_access($tv_id, $templates)
{
$template_collection = $this->modx->getCollection('modTemplate');
// Remove all tv access for each template
foreach ($template_collection as $template) {
$template = Element::insert($template);
if (!$this->remove_template_access($tv_id, $template->get_property('id'))) {
return false;
}
}
// Give access to all templates if the first name is *
if ($templates[0] === '*') {
foreach ($template_collection as $template) {
$template = Element::insert($template);
if ($template) {
if (!$this->add_template_access($tv_id, $template->get_property('id'))) {
return false;
}
}
}
} else {
foreach ($templates as $template_name) {
$template = Element::get($this->modx, 'modTemplate', $template_name);
// If the template exists add access to the tv
if ($template) {
if (!$this->add_template_access($tv_id, $template->get_property('id'))) {
return false;
}
}
}
}
return true;
}
示例3: foreach
if (count($flagged_tvs) > 0) {
$updated_tvs = $tvs;
foreach ($flagged_tvs as $i) {
unset($updated_tvs[$i]);
}
// Update the template variable file and remove the tvs from the sync if successfull
if ($element_helper->update_tv_file($updated_tvs)) {
foreach ($flagged_tvs as $i) {
$element_sync->remove_element('modTemplateVar', $tvs[$i]->name);
}
}
}
// Process the template variable elements
foreach ($modx->getCollection('modTemplateVar') as $element_object) {
// Check if the tv exists in the template variables file
$element = Element::insert($element_object);
$name = $element->get_property('name');
$category_id = $element->get_property('category');
$tv_file_has_tv = false;
// Check if the element has a category and is whitelisted
if ($category_id !== 0) {
$category = Element::get($modx, 'modCategory', $category_id);
if (!in_array($category->get_property('name'), $category_whitelist)) {
continue;
}
}
// Loop through the tvs to check if it exists in the template variables file
foreach ($tvs as $i => $tv) {
if ($tv->name === $name) {
$tv_file_has_tv = true;
}