本文整理汇总了PHP中WFXMLHelper类的典型用法代码示例。如果您正苦于以下问题:PHP WFXMLHelper类的具体用法?PHP WFXMLHelper怎么用?PHP WFXMLHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WFXMLHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchElement
public function fetchElement($name, $value, &$node, $control_name)
{
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
$language = JFactory::getLanguage();
// create a unique id
$id = preg_replace('#([^a-z0-9_-]+)#i', '', $control_name . 'filesystem' . $name);
// add javascript if element has parameters
if ((string) $node->attributes()->parameters) {
$document = JFactory::getDocument();
$document->addCustomTag('<script type="text/javascript">$jce.Parameter.add("#' . $id . '", "filesystem");</script>');
}
// path to directory
$path = WF_EDITOR_EXTENSIONS . '/filesystem';
$filter = '\\.xml$';
$files = JFolder::files($path, $filter, false, true);
$options = array();
if (!$node->attributes('exclude_default')) {
$options[] = JHTML::_('select.option', '', WFText::_('WF_OPTION_NOT_SET'));
}
if (is_array($files)) {
foreach ($files as $file) {
// load language file
$language->load('com_jce_filesystem_' . basename($file, '.xml'), JPATH_SITE);
$xml = WFXMLHelper::parseInstallManifest($file);
$options[] = JHTML::_('select.option', basename($file, '.xml'), WFText::_($xml['name']));
}
}
return JHTML::_('select.genericlist', $options, '' . $control_name . '[filesystem][' . $name . ']', 'class="inputbox"', 'value', 'text', $value, $id);
}
示例2: fetchElement
public function fetchElement($name, $value, &$node, $control_name)
{
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
$language = JFactory::getLanguage();
// create a unique id
$id = preg_replace('#([^a-z0-9_-]+)#i', '', $control_name . 'filesystem' . $name);
$attribs = array('class="parameter-nested-parent"');
// path to directory
$path = WF_EDITOR_EXTENSIONS . '/filesystem';
$filter = '\\.xml$';
$files = JFolder::files($path, $filter, false, true, array('build.xml'));
$options = array();
if ((bool) $node->attributes()->exclude_default === false) {
$options[] = JHTML::_('select.option', '', WFText::_('WF_OPTION_NOT_SET'));
}
if (is_array($files)) {
foreach ($files as $file) {
// load language file
$language->load('com_jce_filesystem_' . basename($file, '.xml'), JPATH_SITE);
$xml = WFXMLHelper::parseInstallManifest($file);
$options[] = JHTML::_('select.option', basename($file, '.xml'), WFText::_($xml['name']));
}
}
// if a group is specified, setup to be an object
if ((string) $node->attributes()->group) {
$name = $control_name . '[filesystem][' . $name . ']';
} else {
$name = $control_name . '[filesystem]';
}
return JHTML::_('select.genericlist', $options, $name, implode(' ', $attribs), 'value', 'text', $value, $id);
}
示例3: getVersion
/**
* Get the current version
* @return Version
*/
public function getVersion()
{
$xml = WFXMLHelper::parseInstallManifest(JPATH_ADMINISTRATOR . '/components/com_jce/jce.xml');
// return cleaned version number or date
$version = preg_replace('/[^0-9a-z]/i', '', $xml['version']);
if (!$version) {
return date('Y-m-d', strtotime('today'));
}
return $version;
}
示例4: checkVersion
function checkVersion()
{
$file = JPATH_PLUGINS . '/system/jcemediabox.xml';
if (!is_file($file)) {
$file = JPATH_PLUGINS . '/system' . 'jcemediabox/jcemediabox.xml';
}
$required = $this->get('_requires');
if ($xml = WFXMLHelper::parseInstallManifest($file)) {
if (version_compare($xml['version'], (int) $required, '<')) {
echo '<p class="required">' . WFText::sprintf('WF_POPUPS_JCEMEDIABOX_VERSION_ERROR', $required) . '</p>';
}
}
}
示例5: fetchElement
public function fetchElement($name, $value, &$node, $control_name)
{
jimport('joomla.filesystem.folder');
// path to images directory
$path = WF_EDITOR . '/extensions/mediaplayer';
$files = JFolder::files($path, '\\.xml', false, true, array('build.xml'));
$attribs = array('class="parameter-nested-parent"');
$language = JFactory::getLanguage();
// create unique id
$id = preg_replace('#([^a-z0-9_-]+)#i', '', $control_name . 'mediaplayer' . $name);
$options = array();
$options[] = JHTML::_('select.option', 'none', WFText::_('WF_OPTION_NONE'));
if (is_array($files)) {
foreach ($files as $file) {
// load language file
$language->load('com_jce_' . $name . '_' . basename($file, '.xml'), JPATH_SITE);
$xml = WFXMLHelper::parseInstallManifest($file);
$options[] = JHTML::_('select.option', basename($file, '.xml'), WFText::_($xml['name']));
}
}
return JHTML::_('select.genericlist', $options, '' . $control_name . '[mediaplayer][' . $name . ']', implode(' ', $attribs), 'value', 'text', $value, $id);
}
示例6: getVersions
/**
* Get extension versions
* @return Array
*/
public function getVersions()
{
$db = JFactory::getDBO();
$versions = array('joomla' => array(), 'jce' => array());
// Get Component xml
$com_xml = WFXMLHelper::parseInstallManifest(JPATH_ADMINISTRATOR . '/components/com_jce/jce.xml');
// set component version
$versions['joomla']['com_jce'] = $com_xml['version'];
// get mediabox version
$mediabox_xml_file = WF_JOOMLA15 ? JPATH_PLUGINS . '/system/jcemediabox.xml' : JPATH_PLUGINS . '/system/jcemediabox/jcemediabox.xml';
// set mediabox version
if (file_exists($mediabox_xml_file)) {
$mediabox_xml = WFXMLHelper::parseInstallManifest($mediabox_xml_file);
$versions['joomla']['plg_jcemediabox'] = $mediabox_xml['version'];
}
wfimport('admin.models.plugins');
$model = new WFModelPlugins();
// get all plugins
$plugins = $model->getPlugins();
// get all extensions
$extensions = $model->getExtensions();
foreach ($plugins as $plugin) {
if ($plugin->core == 0) {
$file = WF_EDITOR_PLUGINS . '/' . $plugin->name . '/' . $plugin->name . '.xml';
$xml = WFXMLHelper::parseInstallManifest($file);
$versions['jce']['jce_' . $plugin->name] = $xml['version'];
}
}
foreach ($extensions as $extension) {
if ($extension->core == 0) {
$file = WF_EDITOR_EXTENSIONS . '/' . $extension->folder . '/' . $extension->extension . '.xml';
$xml = WFXMLHelper::parseInstallManifest($file);
$versions['jce']['jce_' . $extension->folder . '_' . $extension->extension] = $xml['version'];
}
}
return $versions;
}
示例7: getLanguages
public function getLanguages()
{
// Get the site languages
$base = JLanguage::getLanguagePath(JPATH_SITE);
$dirs = JFolder::folders($base);
for ($i = 0; $i < count($dirs); $i++) {
$lang = new stdClass();
$lang->folder = $dirs[$i];
$lang->baseDir = $base;
$languages[] = $lang;
}
$rows = array();
foreach ($languages as $language) {
$files = JFolder::files($language->baseDir . '/' . $language->folder, '\\.(com_jce)\\.xml$');
foreach ($files as $file) {
$data = WFXMLHelper::parseInstallManifest($language->baseDir . '/' . $language->folder . '/' . $file);
$row = new StdClass();
$row->language = $language->folder;
if ($row->language == 'en-GB') {
$row->cbd = 'disabled="disabled"';
$row->style = ' style="color:#999999;"';
} else {
$row->cbd = '';
$row->style = '';
}
// If we didn't get valid data from the xml file, move on...
if (!is_array($data)) {
continue;
}
// Populate the row from the xml meta file
foreach ($data as $key => $value) {
$row->{$key} = $value;
}
$rows[] = $row;
}
}
return $rows;
}
示例8: getVersion
function getVersion()
{
$xml = WFXMLHelper::parseInstallManifest(JPATH_ADMINISTRATOR . '/components/com_jce/jce.xml');
return $xml['version'];
}
示例9: getPluginVersion
protected function getPluginVersion() {
$manifest = WF_EDITOR_PLUGIN . '/' . $this->get('name') . '.xml';
$version = '';
if (is_file($manifest)) {
$xml = WFXMLHelper::parseInstallManifest($manifest);
if ($xml && isset($xml['version'])) {
$version = $xml['version'];
}
}
if ($version) {
$version = preg_replace('#[^a-z0-9]+#i', '', $version);
}
return $version;
}
示例10: uninstall
/**
* Uninstall method
*
* @access public
* @param string $tag The tag of the language to uninstall
* @return mixed Return value for uninstall method in component uninstall file
*/
function uninstall($tag)
{
// Set defaults
$this->parent->set('name', $tag);
$this->parent->set('version', '');
// Clean tag
$tag = trim($tag);
$path = JPATH_SITE . '/language/' . $tag;
if (!JFolder::exists($path)) {
JError::raiseWarning(100, WFText::_('WF_INSTALLER_LANGUAGE_UNINSTALL') . ' : ' . WFText::_('WF_INSTALLER_LANGUAGE_PATH_EMPTY'));
return false;
}
// Because JCE languages don't have their own folders we cannot use the standard method of finding an installation manifest
$manifest = $path . '/' . $tag . '.com_jce.xml';
if (file_exists($manifest)) {
$xml = WFXMLHelper::getXML($manifest);
if (!$xml) {
JError::raiseWarning(100, WFText::_('WF_INSTALLER_LANGUAGE_UNINSTALL') . ' : ' . WFText::_('WF_INSTALLER_MANIFEST_INVALID'));
}
$this->setManifest($xml);
// Set the installation target paths
$this->parent->setPath('extension_site', $path);
$this->parent->setPath('extension_administrator', JPATH_ADMINISTRATOR . "/language/" . $tag);
if (!$this->parent->removeFiles($this->get('site'))) {
JError::raiseWarning(100, WFText::_('WF_INSTALLER_LANGUAGE_UNINSTALL') . ' : ' . WFText::_('WF_INSTALL_DELETE_FILES_ERROR'));
return false;
}
if (!$this->parent->removeFiles($this->get('administration'), 1)) {
JError::raiseWarning(100, WFText::_('WF_INSTALLER_LANGUAGE_UNINSTALL') . ' : ' . WFText::_('WF_INSTALL_DELETE_FILES_ERROR'));
return false;
}
$this->parent->setPath('extension_site', JPATH_COMPONENT_SITE . '/editor/tiny_mce');
if (!$this->parent->removeFiles($this->get('tinymce'))) {
JError::raiseWarning(100, WFText::_('WF_INSTALLER_LANGUAGE_UNINSTALL') . ' : ' . WFText::_('WF_INSTALL_DELETE_FILES_ERROR'));
return false;
}
JFile::delete($manifest);
} else {
JError::raiseWarning(100, WFText::_('WF_INSTALLER_LANGUAGE_UNINSTALL') . ' : ' . WFText::_('WF_INSTALLER_MANIFEST_ERROR'));
return false;
}
return true;
}
示例11: uninstall
/**
* Uninstall method
*
* @access public
* @param int $id The id of the extension to uninstall
* @return boolean True on success
*/
public function uninstall($id)
{
// Initialize variables
$retval = true;
$id = explode('.', $id);
if (count($id) < 2) {
JError::raiseWarning(100, WFText::_('WF_INSTALLER_EXTENSION_UNINSTALL') . ' : ' . WFText::_('WF_INSTALLER_EXTENSION_FIELD_EMPTY'));
return false;
}
$folder = '';
$extension = '';
if (count($id) > 2) {
$plugin = $id[0];
$folder = $id[1];
$extension = $id[2];
} else {
$plugin = null;
$folder = $id[0];
$extension = $id[1];
}
$this->parent->set('name', $extension);
// Get the extension folder so we can properly build the plugin path
if (trim($extension) == '') {
JError::raiseWarning(100, WFText::_('WF_INSTALLER_EXTENSION_UNINSTALL') . ' : ' . WFText::_('WF_INSTALLER_EXTENSION_FIELD_EMPTY'));
return false;
}
if ($plugin) {
// Set the plugin root path
$this->parent->setPath('extension_root', JPATH_COMPONENT_SITE . DS . 'editor' . DS . 'tiny_mce' . DS . 'plugins' . DS . $plugin . DS . 'extensions' . DS . $folder);
} else {
$this->parent->setPath('extension_root', JPATH_COMPONENT_SITE . DS . 'editor' . DS . 'extensions' . DS . $folder);
}
$manifest = $this->parent->getPath('extension_root') . DS . $extension . '.xml';
if (file_exists($manifest)) {
$xml = WFXMLHelper::getXML($manifest);
if (!$this->setManifest($xml)) {
JError::raiseWarning(100, WFText::_('WF_INSTALLER_EXTENSION_UNINSTALL') . ' : ' . WFText::_('WF_INSTALLER_MANIFEST_INVALID'));
}
$this->parent->set('name', WFText::_($this->get('name')));
$this->parent->set('version', $this->get('version'));
$this->parent->set('message', $this->get('description'));
// can't remove a core plugin
if ($this->get('core') == 1) {
JError::raiseWarning(100, WFText::_('WF_INSTALLER_EXTENSION_UNINSTALL') . ' : ' . JText::sprintf('WF_INSTALLER_WARNCOREEXTENSION', WFText::_($this->get('name'))));
return false;
}
// Remove the extension files
$this->parent->removeFiles($this->get('files'), -1);
// Remove all media and languages as well
$this->parent->removeFiles($this->get('languages'), 0);
$this->parent->removeFiles($this->get('media'), 0);
JFile::delete($manifest);
} else {
JError::raiseWarning(100, WFText::_('WF_INSTALLER_EXTENSION_UNINSTALL') . ' : ' . WFText::_('WF_INSTALLER_CUSTOM_UNINSTALL_ERROR'));
return false;
}
return $retval;
}
示例12: uninstall
/**
* Uninstall method
*
* @access public
* @param string $name The name of the plugin to uninstall
* @return boolean True on success
*/
public function uninstall($name)
{
// Initialize variables
$row = null;
$retval = true;
$db = $this->parent->getDBO();
$parts = explode('.', $name);
// get name
$name = array_pop($parts);
// get type eg: plugin or extension
$type = array_shift($parts);
$this->parent->set('name', $name);
// Load the language file
$language = JFactory::getLanguage();
switch ($type) {
case 'plugin':
// create $path
$path = JPATH_COMPONENT_SITE . '/editor/tiny_mce/plugins/' . $name;
// load language file
$language->load('com_jce_' . $name, JPATH_SITE);
break;
case 'extension':
$parts[] = $name;
$path = dirname(JPATH_COMPONENT_SITE . '/editor/extensions/' . implode('/', $parts));
// load language file
$language->load('com_jce_' . trim(implode('_', $parts)), JPATH_SITE);
break;
}
// Set the plugin root path
$this->parent->setPath('extension_root', $path);
// set manifest path
$manifest = $this->parent->getPath('extension_root') . '/' . $name . '.xml';
if (file_exists($manifest)) {
$xml = WFXMLHelper::getXML($manifest);
if (!$xml) {
JError::raiseWarning(100, WFText::_('WF_INSTALLER_PLUGIN_UNINSTALL') . ' : ' . WFText::_('WF_INSTALLER_MANIFEST_INVALID'));
}
$this->parent->set('name', (string) $xml->name);
$this->parent->set('version', (string) $xml->version);
$this->parent->set('message', (string) $xml->description);
// can't remove a core plugin
if ((int) $xml->attributes()->core == 1) {
JError::raiseWarning(100, WFText::_('WF_INSTALLER_PLUGIN_UNINSTALL') . ' : ' . JText::sprintf('WF_INSTALLER_WARNCOREPLUGIN', WFText::_((string) $xml->name)));
return false;
}
if ($type == 'extension') {
$this->parent->removeFiles($xml->files, -1);
JFile::delete($manifest);
}
// Remove all media and languages as well
$this->parent->removeFiles($xml->languages, 0);
$this->parent->removeFiles($xml->media, 0);
/**
* ---------------------------------------------------------------------------------------------
* Custom Uninstallation Script Section
* ---------------------------------------------------------------------------------------------
*/
// Now lets load the uninstall file if there is one and execute the uninstall function if it exists.
$uninstall = (string) $xml->children('uninstall.script');
if ($uninstall) {
// Element exists, does the file exist?
if (is_file($this->parent->getPath('extension_root') . '/' . $uninstall)) {
ob_start();
ob_implicit_flush(false);
require_once $this->parent->getPath('extension_root') . '/' . $uninstall;
if (function_exists('com_uninstall')) {
if (com_uninstall() === false) {
JError::raiseWarning(100, WFText::_('WF_INSTALLER_PLUGIN_UNINSTALL') . ' : ' . WFText::_('WF_INSTALLER_CUSTOM_UNINSTALL_ERROR'));
$retval = false;
}
}
$msg = ob_get_contents();
ob_end_clean();
if ($msg != '') {
$this->parent->set('extension.message', $msg);
}
}
}
// remove form profile
if ($xml->icon) {
$plugin = new StdClass();
$plugin->name = (string) $xml->plugin;
$plugin->icon = (string) $xml->icon;
$plugin->path = $this->parent->getPath('extension_root');
wfimport('admin.models.plugins');
$model = new WFModelPlugins();
$model->postInstall('uninstall', $plugin, $this);
}
} else {
JError::raiseWarning(100, WFText::_('WF_INSTALLER_PLUGIN_UNINSTALL') . ' : ' . WFText::_('WF_INSTALLER_MANIFEST_ERROR'));
$retval = false;
}
// set plugin path
//.........这里部分代码省略.........
示例13: uninstall
/**
* Uninstall method
*
* @access public
* @param string $name The name of the plugin to uninstall
* @return boolean True on success
*/
public function uninstall($name)
{
// Initialize variables
$row = null;
$retval = true;
$db = $this->parent->getDBO();
$this->parent->set('name', $name);
// Set the plugin root path
$this->parent->setPath('extension_root', JPATH_COMPONENT_SITE . DS . 'editor' . DS . 'tiny_mce' . DS . 'plugins' . DS . $name);
$manifest = $this->parent->getPath('extension_root') . DS . $name . '.xml';
// Load the language file
$language = JFactory::getLanguage();
$language->load('com_jce_' . trim($name), JPATH_SITE);
if (file_exists($manifest)) {
$xml = WFXMLHelper::getXML($manifest);
if (!$this->setManifest($xml)) {
JError::raiseWarning(100, WFText::_('WF_INSTALLER_PLUGIN_UNINSTALL') . ' : ' . WFText::_('WF_INSTALLER_MANIFEST_INVALID'));
}
$this->parent->set('name', $this->get('name'));
$this->parent->set('version', $this->get('version'));
$this->parent->set('message', $this->get('description'));
// can't remove a core plugin
if ($this->get('core') == 1) {
JError::raiseWarning(100, WFText::_('WF_INSTALLER_PLUGIN_UNINSTALL') . ' : ' . JText::sprintf('WF_INSTALLER_WARNCOREPLUGIN', WFText::_($this->get('name'))));
return false;
}
// Remove all media and languages as well
$this->parent->removeFiles($this->get('languages'), 0);
$this->parent->removeFiles($this->get('media'), 0);
/**
* ---------------------------------------------------------------------------------------------
* Custom Uninstallation Script Section
* ---------------------------------------------------------------------------------------------
*/
// Now lets load the uninstall file if there is one and execute the uninstall function if it exists.
$uninstall = $this->get('uninstall.script');
if ($uninstall) {
// Element exists, does the file exist?
if (is_file($this->parent->getPath('extension_root') . DS . $uninstall)) {
ob_start();
ob_implicit_flush(false);
require_once $this->parent->getPath('extension_root') . DS . $uninstall;
if (function_exists('com_uninstall')) {
if (com_uninstall() === false) {
JError::raiseWarning(100, WFText::_('WF_INSTALLER_PLUGIN_UNINSTALL') . ' : ' . WFText::_('WF_INSTALLER_CUSTOM_UNINSTALL_ERROR'));
$retval = false;
}
}
$msg = ob_get_contents();
ob_end_clean();
if ($msg != '') {
$this->parent->set('extension.message', $msg);
}
}
}
// Remove from Groups
JTable::addIncludePath(WF_ADMINISTRATOR . DS . 'groups');
$rows = JTable::getInstance('profiles', 'WFTable');
$query = 'SELECT id, name, plugins, rows' . ' FROM #__wf_profiles';
$db->setQuery($query);
$profiles = $db->loadObjectList();
foreach ($profiles as $profile) {
$plugins = explode(',', $profile->plugins);
// Existence check
if (in_array($this->get('plugin'), $plugins)) {
// Load tables
$rows->load($profile->id);
// Remove from plugins list
foreach ($plugins as $k => $v) {
if ($this->get('plugin') == $v) {
unset($plugins[$k]);
}
}
$rows->plugins = implode(',', $plugins);
// Remove from rows
if ($this->get('icon')) {
$lists = array();
foreach (explode(';', $profile->rows) as $list) {
$icons = explode(',', $list);
foreach ($icons as $k => $v) {
if ($this->get('plugin') == $v) {
unset($icons[$k]);
}
}
$lists[] = implode(',', $icons);
}
$rows->rows = implode(';', $lists);
}
if (!$rows->store()) {
JError::raiseWarning(100, WFText::_('WF_INSTALLER_PLUGIN_UNINSTALL') . ' : ' . JText::sprintf('WF_INSTALLER_REMOVE_FROM_GROUP_ERROR', $prows->name));
}
}
}
//.........这里部分代码省略.........
示例14: execute
public function execute()
{
WFToken::checkToken() or die('Access to this resource is restricted');
// JSON request or upload action
if ($this->isRequest()) {
$request = WFRequest::getInstance();
$request->process();
} else {
$wf = WFEditor::getInstance();
$version = $this->getVersion();
$name = $this->getName();
// process javascript languages
if (JRequest::getWord('task') == 'loadlanguages') {
wfimport('admin.classes.language');
$parser = new WFLanguageParser(array('plugins' => array($name), 'sections' => array('dlg', $name . '_dlg', 'colorpicker'), 'mode' => 'plugin'));
$data = $parser->load();
$parser->output($data);
}
// load core language
WFLanguage::load('com_jce', JPATH_ADMINISTRATOR);
// Load Plugin language
WFLanguage::load('com_jce_' . trim($this->getName()));
// set default plugin version
$plugin_version = '';
$manifest = WF_EDITOR_PLUGIN . '/' . $name . '.xml';
if (is_file($manifest)) {
$xml = WFXMLHelper::parseInstallManifest($manifest);
if ($xml && isset($xml['version'])) {
$plugin_version = $xml['version'];
}
}
// add plugin version
if ($plugin_version) {
$version .= '-' . preg_replace('#[^a-z0-9]+#i', '', $plugin_version);
}
// create the document
$document = WFDocument::getInstance(array('version' => $version, 'title' => WFText::_('WF_' . strtoupper($this->getName() . '_TITLE')), 'name' => $name, 'language' => WFLanguage::getTag(), 'direction' => WFLanguage::getDir(), 'compress_javascript' => $this->getParam('editor.compress_javascript', 0), 'compress_css' => $this->getParam('editor.compress_css', 0)));
// set standalone mode
$document->set('standalone', JRequest::getInt('standalone', 0));
// create display
$this->display();
// ini language
$document->addScript(array('index.php?option=com_jce&view=editor&' . $document->getQueryString(array('task' => 'loadlanguages', 'lang' => WFLanguage::getCode()))), 'joomla');
// pack assets if required
$document->pack(true, $this->getParam('editor.compress_gzip', 0));
// get the view
$view = $this->getView();
// set body output
$document->setBody($view->loadTemplate());
// render document
$document->render();
}
}
示例15: checkLanguage
protected function checkLanguage($tag)
{
$file = JPATH_SITE . DS . 'language' . DS . $tag . DS . $tag . '.com_jce.xml';
if (file_exists($file)) {
wfimport('admin.helpers.xml');
$xml = WFXMLHelper::getXML($file);
if ($xml) {
$version = WFXMLHelper::getAttribute($xml, 'version');
if ($version == '2.0') {
return true;
}
}
}
return false;
}