Ejemplo n.º 1
0
        // Check if the element is blacklisted
        if (in_array($name, $element_blacklist)) {
            continue;
        }
        // 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;
            }
        }
        // If a file with this element name doesn't exist
        if (!file_exists($file_path)) {
            // If the element is not in the sync
            if (!$element_sync->has_element($type, $name)) {
                $properties = $element_helper->get_element_static_file_properties($element, $file_path);
                if ($element->set_properties($properties)) {
                    $file_mod_time = filemtime($file_path);
                    $element_sync->add_element($type, $name, $file_mod_time);
                }
            } else {
                // Remove the element and remove it from the sync if successful
                if ($element->remove()) {
                    $element_sync->remove_element($type, $name);
                }
            }
        }
    }
}
$log_prefix = '[ElementHelper] modTemplateVar: ';
$tv_file_path = MODX_BASE_PATH . $modx->getOption('elementhelper.tv_file_path', null, 'site/elements/template_variables.json');