Builds a list of the help sites which can be used in a select option.

@param   string  $pathToXml  Path to an XML file.
@param   string  $selected   Language tag to select (if exists).
@return  array   An array of arrays (text, value, selected).
194747
public static function createSiteList($pathToXml, $selected = null)
	{
		$list = array();
		$xml = false;

		if (!empty($pathToXml))
		{
			// Disable libxml errors and allow to fetch error information as needed
			libxml_use_internal_errors(true);

			// Try to load the XML file
			$xml = simplexml_load_file($pathToXml);
		}

		if (!$xml)
		{
			$option['text']  = 'English (US) hubzero.org';
			$option['value'] = 'http://hubzero.org/documentation';
			$list[] = $option;
		}
		else
		{
			$option = array();

			foreach ($xml->sites->site as $site)
			{
				$option['text']  = (string) $site;
				$option['value'] = (string) $site->attributes()->url;

				$list[] = $option;
			}
		}

		return $list;
	}
532433
private function toXPath($css_selector)
    {
        $xpath = Null;

        try
        {
            $xpath = $this->selector->toXPath($css_selector);
        }
        catch (\Exception $e)
        {
            $this->logger->logError('E003', array($css_selector));
            $this->logger->logError('E000', array($e->getMessage()));
        }

        return $xpath;
    }
1123157
public function getOptionListCategories ($value , $attributes = null , $select = true)
    {
        $options = $this->categoryOption($this->getRootCategories($this->modelType) , $value);
        $attrs = $this->makeAttributesForOption($attributes);
        $newOption = "<option selected value='0'>" . trans('Categories::category.no-parent-category') . " </option>" . $options;
        if ($select == true)
            return "<select $attrs>$newOption</select>";
        else
            return $newOption;
    }
1140351
private static function getSelectOptions($list, $selectedValue) {
        $result = '';

        if ($selectedValue !== null && !is_array($selectedValue)) {
            $selectedValue = array($selectedValue);
        }

        foreach ($list as $item) {
            $itemAttr = array();
            $text = '';

            if ($item instanceof SelectListItem) {
                $text = $item->text;
                $itemAttr['value'] = $item->value;

                if ($item->disabled === true) {
                    $itemAttr['disabled'] = 'disabled';
                }

                if ($selectedValue === null && $item->selected === true) {
                    $itemAttr['selected'] = 'selected';
                }
                elseif ($selectedValue !== null && in_array($item->value, $selectedValue) === true) {
                    $itemAttr['selected'] = 'selected';
                }
            }
            else {
                $text = $item;

                if ($selectedValue !== null && in_array($item, $selectedValue)) {
                    $itemAttr['selected'] = 'selected';
                }
            }

            $attr = self::buildAttributes($itemAttr);

            $result .= '<option' . (!empty($attr) ? ' ' : '') . $attr . '>';
            $result .= htmlspecialchars($text);
            $result .= '</option>';
        }

        return $result;
    }
247460
protected function getSelect()
    {
        $html = '<select>';

        if (is_array($this->window['all'])) {
            $html .= $this->getOptionLinks($this->window['all']);
        }

        $html .= '</select>';

        return $html;
    }
356721
protected function getEditHtmlSelect()
    {
        /** @var AdminBaseHelper $linkedHelper */
        $linkedHelper = $this->getSettings('HELPER');
        $inputSize = (int) $this->getSettings('INPUT_SIZE');
        $windowWidth = (int) $this->getSettings('WINDOW_WIDTH');
        $windowHeight = (int) $this->getSettings('WINDOW_HEIGHT');

        $name = 'FIELDS';
        $key = $this->getCode();

        $entityData = $this->getOrmElementData();

        if (!empty($entityData)) {
            $elementId = $entityData[$linkedHelper::pk()];
            $elementName = $entityData[$this->getSettings('TITLE_FIELD_NAME')] ?
                $entityData[$this->getSettings('TITLE_FIELD_NAME')] :
                Loc::getMessage('IBLOCK_ELEMENT_NOT_FOUND');
        } else {
            $elementId = '';
        }

        $popupUrl = $linkedHelper::getUrl(array_merge(
            array(
                'popup' => 'Y',
                'eltitle' => $this->getSettings('TITLE_FIELD_NAME'),
                'n' => $name,
                'k' => $key
            ),
            $this->getSettings('ADDITIONAL_URL_PARAMS')
        ));

        return '<input name="' . $this->getEditInputName() . '"
                     id="' . $name . '[' . $key . ']"
                     value="' . $elementId . '"
                     size="' . $inputSize . '"
                     type="text">' .
        '<input type="button"
                    value="..." onClick="jsUtils.OpenWindow(\''. $popupUrl . '\', ' . $windowWidth . ', '
        . $windowHeight . ');">' . '&nbsp;<span id="sp_' . md5($name) . '_' . $key . '" >' .
        static::prepareToOutput($elementName)
        . '</span>';
    }
348685
private function selection(string $path) : array
    {
        $modules = $this->getModules($path);
        if (empty($modules)) {
            $this->abort('Aborting, system modules not found.');
        }

        $result[] = $this->in('Please select first related module:', $modules);
        $result[] = $this->in('Please select second related module:', $modules);
        while ('y' === $this->in('Would you like to select more modules?', ['y', 'n'])) {
            $result[] = $this->in('Please select another related module:', $modules);
        }

        return $result;
    }
238436
public function getMarkerObject($xml, $settings)
    {
        return [
            'title' => $this->title,
            'subtitle' => $this->subtitle,
            'latitude' => $this->latitude,
            'longitude' => $this->longitude,
            'html' => $xml->saveXML($this->getHTMLNode($xml, $settings))
        ];
    }
835846
public function getPlayerList($selected)
    {
        $html = '<select>
                <option' . ($selected == '' ? ' selected' : '') . '></option>';

        foreach ($this->championship->fighters as $fighter) {
            $html = $this->addOptionToSelect($selected, $fighter, $html);
        }

        $html .= '</select>';

        return $html;
    }
192940
static function simpleXmlToArray(SimpleXMLElement &$source)
  {
    $res = array();
    $children = false;
    foreach ($source as $key => $value) {
        CPS_Response::simpleXmlToArrayHelper($res, $key, $value, $children);
    }
    if ($source) {
      foreach ($source->children('www.clusterpoint.com') as $key => $value) {
        $newkey = 'cps:' . $key;
        CPS_Response::simpleXmlToArrayHelper($res, $newkey, $value, $children);
      }
    }
    if (!$children)
      return (string)$source;
    return $res;
  }
1255802
function inputListXML( &$listNode, $currentSectionLevel, $listSectionLevel = null, $noParagraphs = true )
    {
        $output = '';
        $tagName = $listNode instanceof DOMNode ? $listNode->nodeName : '';

        switch ( $tagName )
        {
            case 'paragraph' :
            {
                $output .= $this->inputParagraphXML( $listNode,
                                                     $currentSectionLevel,
                                                     $listSectionLevel,
                                                     $noParagraphs );
            }break;

            case 'section' :
            {
                $listSectionLevel += 1;
                $output .= $this->inputSectionXML( $listNode, $currentSectionLevel, $listSectionLevel );
            }break;

            case '#text' :
            {
                //ignore whitespace
            }break;

            default :
            {
                eZDebug::writeError( "Unsupported tag at this level: $tagName", __METHOD__ );
            }break;
        }
        return $output;
    }
494133
protected function createLanguageList($selected = null, $basePath = JPATH_ROOT)
	{
		$list = array();

		$langHelper = new LanguageHelper;
		$langs      = $langHelper->getKnownLanguages($basePath);

		foreach ($langs as $lang => $metadata)
		{
			$option = array();

			$option['text'] = $metadata['name'];
			$option['value'] = $lang;

			if ($selected && $lang == $selected)
			{
				$option['selected'] = 'selected="selected"';
			}

			$list[] = (object) $option;
		}

		return $list;
	}
835261
public function grabHeaders(Toc &$toc, &$dom, $add_id = true, $max_depth = 3, $min_level = 1){
		$headers = [];
		$max_depth = max(1, min($max_depth, 6));
		$min_level = max(1, $min_level);
		$xpath = new \DOMXPath($dom);

		$query = sprintf("//*[%s]", implode(' or ', array_map(function($depth){
			return sprintf("name()='h%d'", $depth);
		}, range($min_level, $max_depth))));
		$counter = 0;
		foreach( $xpath->query($query) as $header ){
			$counter++;
			/** @var \DomElement $header */
			$tag_level = intval(preg_replace('/[^0-9]/u', '', $header->tagName));
			if( $header->hasAttribute('id') ){
				$header_id = (string)$header->getAttribute('id');
			}else{
				$header_id = sprintf('header%d-%03d', $tag_level, $counter);
				if( $add_id ){
					$header->setAttribute('id', $header_id);
				}
			}
			$headers[$header_id] = [
				'level' => $tag_level,
			    'content' => $header->textContent,
			    'children' => []
			];
		}
		if( !$headers ){
			return [];
		}
		$arranged = [];
		foreach( $headers as $key => $header ){
			if( !$this->digToc($key, $header, $arranged) ){
				$arranged[$key] = $header;
			}
		}
		$this->recursiveToc($toc, $toc->link, $arranged);
		return $toc;
	}
557738
public function responseToArray($xml)
    {
        $doc = new \DOMDocument();
        $doc->loadXML($xml);
        $out = $this->nodeToArray($doc->documentElement);

        return $out['Response'];
    }
1067701
public function getSectionUrls(string $section, array $criteria = [], $siteId = null): array
    {
        $criteria = array_merge([
            'section' => $section,
            'status' => 'enabled',
        ], $criteria);

        return $this->getElementUrls(Entry::class, $criteria, $siteId);
    }
423903
protected function buildXml()
    {
        if (empty($_POST['CKFinderCommand']) || $_POST['CKFinderCommand'] != 'true') {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
        }

        if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_RENAME)) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
        }

        if (!isset($_GET["fileName"])) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
        }
        if (!isset($_GET["newFileName"])) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
        }

        $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
        $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_GET["fileName"]);
        $newFileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_GET["newFileName"]);

        $oRenamedFileNode = new Ckfinder_Connector_Utils_XmlNode("RenamedFile");
        $this->_connectorNode->addChild($oRenamedFileNode);
        $oRenamedFileNode->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($fileName));

        $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
        if (!$resourceTypeInfo->checkExtension($newFileName)) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION);
        }

        if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) || $resourceTypeInfo->checkIsHiddenFile($fileName)) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
        }

        if (!CKFinder_Connector_Utils_FileSystem::checkFileName($newFileName) || $resourceTypeInfo->checkIsHiddenFile($newFileName)) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
        }

        if (!$resourceTypeInfo->checkExtension($fileName, false)) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
        }

        if ($_config->forceAscii()) {
            $newFileName = CKFinder_Connector_Utils_FileSystem::convertToAscii($newFileName);
        }

        $filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName);
        $newFilePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $newFileName);

        $bMoved = false;

        if (!file_exists($filePath)) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);
        }

        if (!is_writable(dirname($newFilePath))) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
        }

        if (!is_writable($filePath)) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
        }

        if (file_exists($newFilePath)) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST);
        }

        $bMoved = @rename($filePath, $newFilePath);

        if (!$bMoved) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNKNOWN, "File " . CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($fileName) . "has not been renamed");
        } else {
            $oRenamedFileNode->addAttribute("newName", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($newFileName));

            $thumbPath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getThumbsServerPath(), $fileName);
            CKFinder_Connector_Utils_FileSystem::unlink($thumbPath);
        }
    }
511639
protected function get_selected_options($returntexts = true) {

        $method = 'getHtml';
        if ($returntexts === false) {
            $method = 'getValue';
        }

        // Is the select multiple?
        $multiple = $this->field->hasAttribute('multiple');

        $selectedoptions = array(); // To accumulate found selected options.

        // Driver returns the values as an array or as a string depending
        // on whether multiple options are selected or not.
        $values = $this->field->getValue();
        if (!is_array($values)) {
            $values = array($values);
        }

        // Get all the options in the select and extract their value/text pairs.
        $alloptions = $this->field->findAll('xpath', '//option');
        foreach ($alloptions as $option) {
            // Is it selected?
            if (in_array($option->getValue(), $values)) {
                if ($multiple) {
                    // If the select is multiple, text commas must be encoded.
                    $selectedoptions[] = trim(str_replace(',', '\,', $option->{$method}()));
                } else {
                    $selectedoptions[] = trim($option->{$method}());
                }
            }
        }

        return implode(', ', $selectedoptions);
    }