Ejemplo n.º 1
0
 public static function parseInstallManifest($file)
 {
     $xml = WFXMLElement::load($file);
     if (!$xml) {
         return false;
     }
     if ($xml->getName() != 'install' && $xml->getName() != 'extension') {
         return false;
     }
     $data = array('version' => (string) $xml->version, 'name' => (string) $xml->name, 'copyright' => (string) $xml->copyright, 'authorEmail' => (string) $xml->authorEmail, 'authorUrl' => (string) $xml->authorUrl, 'description' => (string) $xml->description, 'author' => (string) $xml->author);
     return $data;
 }
Ejemplo n.º 2
0
 function getTopics($file)
 {
     $result = '';
     if (file_exists($file)) {
         // load xml
         $xml = WFXMLElement::load($file);
         if ($xml) {
             foreach ($xml->help->children() as $topic) {
                 $subtopics = $topic->subtopic;
                 $class = count($subtopics) ? ' class="subtopics"' : '';
                 $key = (string) $topic->attributes()->key;
                 $title = (string) $topic->attributes()->title;
                 $file = (string) $topic->attributes()->file;
                 // if file attribute load file
                 if ($file) {
                     $result .= $this->getTopics(WF_EDITOR . '/' . $file);
                 } else {
                     $result .= '<dd' . $class . ' id="' . $key . '">' . trim(WFText::_($title)) . '</dd>';
                 }
                 if (count($subtopics)) {
                     $result .= '<dl class="hidden">';
                     foreach ($subtopics as $subtopic) {
                         $sub_subtopics = $subtopic->subtopic;
                         // if a file is set load it as sub-subtopics
                         if ($file = (string) $subtopic->attributes()->file) {
                             $result .= '<dd class="subtopics">' . trim(WFText::_((string) $subtopic->attributes()->title)) . '</dd>';
                             $result .= '<dl class="hidden">';
                             $result .= $this->getTopics(WF_EDITOR . '/' . $file);
                             $result .= '</dl>';
                         } else {
                             $id = $subtopic->attributes()->key ? ' id="' . (string) $subtopic->attributes()->key . '"' : '';
                             $class = count($sub_subtopics) ? ' class="subtopics"' : '';
                             $result .= '<dd' . $class . $id . '>' . trim(WFText::_((string) $subtopic->attributes()->title)) . '</dd>';
                             if (count($sub_subtopics)) {
                                 $result .= '<dl class="hidden">';
                                 foreach ($sub_subtopics as $sub_subtopic) {
                                     $result .= '<dd id="' . (string) $sub_subtopic->attributes()->key . '">' . trim(WFText::_((string) $sub_subtopic->attributes()->title)) . '</dd>';
                                 }
                                 $result .= '</dl>';
                             }
                         }
                     }
                     $result .= '</dl>';
                 }
             }
         }
     }
     return $result;
 }
Ejemplo n.º 3
0
 protected static function check($tag)
 {
     $file = JPATH_SITE . '/language/' . $tag . '/' . $tag . '.com_jce.xml';
     if (file_exists($file)) {
         wfimport('admin.classes.xml');
         $xml = WFXMLElement::load($file);
         if ($xml) {
             $version = (string) $xml->attributes()->version;
             if ($version == '2.0') {
                 return true;
             }
         }
     }
     return false;
 }
Ejemplo n.º 4
0
 /**
  * Get Actions from access.xml file
  */
 protected function getActions()
 {
     $file = JPATH_COMPONENT_ADMINISTRATOR . '/access.xml';
     $xml = WFXMLElement::load($file);
     $actions = array();
     if ($xml) {
         // Iterate over the children and add to the actions.
         foreach ($xml->section->children() as $element) {
             if ($element->getName() == 'action') {
                 $actions[] = (object) array('name' => (string) $element['name'], 'title' => (string) $element['title'], 'description' => (string) $element['description']);
             }
         }
     }
     return $actions;
 }
Ejemplo n.º 5
0
 /**
  * Get a plugin's extensions
  * @param object $plugin
  * @return
  */
 public function getExtensions()
 {
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     $extensions = array();
     // recursively get all extension files
     $files = JFolder::files(WF_EDITOR_EXTENSIONS, '\\.xml$', true, true);
     foreach ($files as $file) {
         $object = new StdClass();
         $object->folder = basename(dirname($file));
         $object->manifest = $file;
         $object->plugins = array();
         $name = basename($file, '.xml');
         $object->name = $name;
         $object->description = '';
         $object->id = $object->folder . '.' . $object->name;
         $xml = WFXMLElement::load($file);
         if ($xml) {
             $plugins = (string) $xml->plugins;
             if ($plugins) {
                 $object->plugins = explode(',', $plugins);
             }
             $object->name = (string) $xml->name;
             $object->title = (string) $xml->name;
             $object->description = (string) $xml->description;
             $object->creationdate = (string) $xml->creationDate;
             $object->author = (string) $xml->author;
             $object->version = (string) $xml->version;
             $object->type = (string) $xml->attributes()->folder;
             $object->authorUrl = (string) $xml->authorUrl;
             $object->folder = (string) $xml->attributes()->folder;
             $object->core = (int) $xml->attributes()->core ? 1 : 0;
             if ($object->core == 0) {
                 // load language
                 $language = JFactory::getLanguage();
                 $language->load('com_jce_' . $object->folder . '_' . $name, JPATH_SITE);
             }
         }
         $object->extension = $name;
         $extensions[] = $object;
     }
     return $extensions;
 }
Ejemplo n.º 6
0
 /**
  * Get additional plugins such as JCE MediaBox etc.
  * @return 
  */
 public function getRelated()
 {
     // Get a database connector
     $db = JFactory::getDBO();
     $params = JComponentHelper::getParams('com_jce');
     // pre-defined array of other plugins
     $related = preg_replace('#(\\w+)#', "'\$1'", $params->get('related_extensions', 'jcemediabox,jceutilities,mediaobject,wfmediabox,wfmediaelement'));
     $query = $db->getQuery(true);
     // Joomla! 2.5
     if (is_object($query)) {
         $query->select(array('extension_id', 'name', 'element', 'folder'))->from('#__extensions')->where(array('type = ' . $db->Quote('plugin'), 'element IN (' . $related . ')'))->order('name');
         // Joomla! 1.5
     } else {
         $query = 'SELECT id, name, element, folder FROM #__plugins WHERE element IN (' . $related . ') ORDER BY name';
     }
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     $language = JFactory::getLanguage();
     $num = count($rows);
     for ($i = 0; $i < $num; $i++) {
         $row = $rows[$i];
         if (defined('JPATH_PLATFORM')) {
             $file = JPATH_PLUGINS . '/' . $row->folder . '/' . $row->element . '/' . $row->element . ".xml";
         } else {
             $file = JPATH_PLUGINS . '/' . $row->folder . '/' . $row->element . ".xml";
         }
         if (isset($row->extension_id)) {
             $row->id = $row->extension_id;
         }
         if (is_file($file)) {
             $xml = WFXMLElement::load($file);
             if ($xml) {
                 $row->title = (string) $xml->name;
                 $row->author = (string) $xml->author;
                 $row->version = (string) $xml->version;
                 $row->creationdate = (string) $xml->creationDate;
                 $row->description = (string) $xml->description;
                 $row->authorUrl = (string) $xml->authorUrl;
             }
         }
         $language->load('plg_' . trim($row->folder) . '_' . trim($row->element), JPATH_ADMINISTRATOR);
         $language->load('plg_' . trim($row->folder) . '_' . trim($row->element), JPATH_SITE);
     }
     //return array_values($rows);
     return $rows;
 }
Ejemplo n.º 7
0
 /**
  * Get default profile data
  * @return $row  Profile table object
  */
 function getDefaultProfile()
 {
     $mainframe = JFactory::getApplication();
     $file = JPATH_COMPONENT . '/models/profiles.xml';
     $xml = WFXMLElement::load($file);
     if ($xml) {
         foreach ($xml->profiles->children() as $profile) {
             if ($profile->attributes()->default) {
                 $row = JTable::getInstance('profiles', 'WFTable');
                 foreach ($profile->children() as $item) {
                     switch ($item->getName()) {
                         case 'rows':
                             $row->rows = (string) $item;
                             break;
                         case 'plugins':
                             $row->plugins = (string) $item;
                             break;
                         default:
                             $key = $item->getName();
                             $row->{$key} = (string) $item;
                             break;
                     }
                 }
                 // reset name and description
                 $row->name = '';
                 $row->description = '';
                 return $row;
             }
         }
     }
     return null;
 }
Ejemplo n.º 8
0
 /**
  * Loads an XML setup file and parses it.
  *
  * @param   string  $path  A path to the XML setup file.
  *
  * @return  object
  * @since   2.2.5
  */
 public function loadSetupFile($path)
 {
     $result = false;
     if ($path) {
         $controls = explode(':', $this->control);
         if ($xml = WFXMLElement::load($path)) {
             $params = $xml;
             // move through tree
             foreach ($controls as $control) {
                 $params = $params->{$control};
             }
             foreach ($params as $param) {
                 $this->setXML($param);
                 $result = true;
             }
         }
     } else {
         $result = true;
     }
     return $result;
 }