Generate some random Lorem Ipsum paragraphs

@param int $iNumParagraphs The number of paragraphs to generate

@return string
509766
protected function loremParagraph($iNumParagraphs = 1)
    {
        $aOut     = [];
        $aLengths = [5, 6, 8, 10, 12];

        for ($i = 0; $i < $iNumParagraphs; $i++) {
            $iLength = $aLengths[array_rand($aLengths)];
            $aOut[]  = $this->loremSentence($iLength);
        }

        return implode("\n\n", $aOut);
    }
845624
public function generate($pageCurrent, $totalRows)
    {
        $this->totalRows = $totalRows;
        $this->setPossiblePages();
        $this->setPageCurrent($pageCurrent);

        if ($this->possiblePages < 2) {
            return;
        }

        $pageCurrent = $this->pageCurrent;
        $pagination = $this->getPaginationContainer();

        // previous
        if ($pageCurrent > 1) {
            $pagination['previous'] = $this->getPaginationPage($this->urlBuildPageLink($pageCurrent - 1));
        }
        
        for ($index = 1; $index <= $this->possiblePages; $index ++) {
            $pagination['pages'][$index] = $this->getPaginationPage($this->urlBuildPageLink($index), ($pageCurrent == $index ? true : false));
        }

        // next
        if ($pageCurrent < $this->possiblePages) {
            $pagination['next'] = $this->getPaginationPage($this->urlBuildPageLink($pageCurrent + 1));
        }

        return $pagination;
    }
1142536
public function getPluralForms()
    {
        $header = $this->getHeader(self::HEADER_PLURAL);

        if (!empty($header) &&
            \preg_match('/^nplurals\s*=\s*(\d+)\s*;\s*plural\s*=\s*([^;]+)\s*;$/', $header, $matches)
        ) {
            return [(int) $matches[1], $matches[2]];
        }

        return null;
    }
1283096
def generate_lorem_ipsum(n=5, html=True, min=20, max=100):
    """"""
    from jinja2.constants import LOREM_IPSUM_WORDS
    from random import choice, randrange
    words = LOREM_IPSUM_WORDS.split()
    result = []

    for _ in xrange(n):
        next_capitalized = True
        last_comma = last_fullstop = 0
        word = None
        last = None
        p = []

        # each paragraph contains out of 20 to 100 words.
        for idx, _ in enumerate(xrange(randrange(min, max))):
            while True:
                word = choice(words)
                if word != last:
                    last = word
                    break
            if next_capitalized:
                word = word.capitalize()
                next_capitalized = False
            # add commas
            if idx - randrange(3, 8) > last_comma:
                last_comma = idx
                last_fullstop += 2
                word += ','
            # add end of sentences
            if idx - randrange(10, 20) > last_fullstop:
                last_comma = last_fullstop = idx
                word += '.'
                next_capitalized = True
            p.append(word)

        # ensure that the paragraph ends with a dot.
        p = u' '.join(p)
        if p.endswith(','):
            p = p[:-1] + '.'
        elif not p.endswith('.'):
            p += '.'
        result.append(p)

    if not html:
        return u'\n\n'.join(result)
    return Markup(u'\n'.join(u'<p>%s</p>' % escape(x) for x in result))
215817
public function setIniPath(string $iniPath): string
    {
        $this->iniPath = $iniPath ? '-c ' . $iniPath : '';

        return $this->iniPath;
    }
419437
public function generateGraph()
	{
		// set the image size
		$im = @ImageCreate( $this->getOption( 'width' ), $this->getOption( 'height' ) );
		extract( $this->getOptions() );
		$imageColorBackground	= $this->setColor( $im, $this->getOption( "color_background" ) );			//  set Background Color
		$imageColorBars			= $this->setColor( $im, $this->getOption( "color_bars" ) );					//  set Color of Y-Axis Labels
		$imageColorDash			= $this->setColor( $im, $this->getOption( "color_dash" ) );					//  set Color of dashed Lines
//		$imageColorText			= $this->setColor( $im, $this->getOption( "color_text" ) );					//  set Color of Text
		$imageColorTitle		= $this->setColor( $im, $this->getOption( "color_title" ) );				//  set Color of Title Text
		if( $this->getOption( 'transparent' ) )
			ImageColorTransparent( $im, $imageColorBackground );											//  set Background Transparency
		$this->drawOutlines( $im, $imageColorBars );														//  draw Outlines of Graph Image
		// in case no maximum scale has been provided, calculate the maximum value reached by any of the lines
		if( !isset( $maxValue ) )
		{
			$maxValue	= 0;
			for( $g=0; $g<count( $this->graphs ); $g++ )
				$maxValue	= max( $maxValue, max( $this->graphs[$g]['values'] ) );
	//		if( isset( $maxAdjust ) )
	//			$maxValue	+= $maxAdjust; // so that it doesn't touch the upper margin
		}

		// determine the maximum height available for drawing
		// draw the horizontal dotted "guidelines"
		$ratio	= floor( $this->getOption( 'height' ) - $this->getOption( 'padding_top' ) - $this->getOption( 'padding_bottom' ) ) / $this->getOption( 'horizontal_bars' );
		for( $i=0; $i<$this->getOption( 'horizontal_bars' ); $i++ )
		{
			$height	= $this->getOption( 'padding_top' ) + $i * $ratio;
			if( $i )
				ImageDashedLine( $im, $this->getOption( 'padding_left' ), $height, $this->getOption( 'width' ) - $this->getOption( 'padding_right' ), $height, $imageColorDash );
			// write proper values next to the horizontal guidelines, based on their number and max value
			// FIXME: a more general approach; ability to place them on either side for example
			ImageString( $im, 1, $this->getOption( 'width' ) - $this->getOption( 'padding_left' ) - 30, $height - 3, floor( ( $this->getOption( 'horizontal_bars' ) - $i ) * $maxValue / $this->getOption( 'horizontal_bars' ) ), $imageColorTitle );
		}
		// draw the vertical dotted guidelines; these depend on how much data you have
		// FIXME: make it possible to draw only the Nth line
		$ratio	= floor( $this->getOption( 'width' ) - $this->getOption( 'padding_left' ) - $this->getOption( 'padding_right' ) ) / ( count( $this->labels ) - 1 );
		for( $i=0; $i<count( $this->labels ); $i++ )
		{
			if( $i<count( $this->labels ) -2 )
			{
				$width	=$this->getOption( 'padding_left' ) + ( $i + 1 ) * $ratio;
				ImageDashedLine( $im, $width, $this->getOption( 'padding_top' ), $width, $this->getOption( 'height' ) - $this->getOption( 'padding_bottom' ), $imageColorDash );
			}
			$width	= $this->getOption( 'padding_left' ) + $i * $ratio;
			// write the labels for each value
			ImageString( $im, 1, $width + $this->getOption( 'label_adjust_x' ), $this->getOption( 'height' ) + $this->getOption( 'label_adjust_y' ), $this->labels[$i], $imageColorTitle );
		}
		// actually output the graphs
		$this->drawGraphs( $im, $maxValue, $ratio );

		// write the title
		ImageString( $im, $this->getOption( 'title_font' ), $this->getOption( 'title_x' ), $this->getOption( 'title_y' ), $this->getOption( 'title_text' ), $imageColorTitle );
		return $im;
	}
456673
protected function getInvoiceSourceReferenceList(array $invoiceSources)
    {
        $result = array();
        foreach ($invoiceSources as $invoiceSource) {
            $result[] = $invoiceSource->getReference();
        }
        return '{' . implode(',', $result) . '}';
    }
881793
public static function get($initArgs = array())
    {
        if (get_class(Core\Config::getHTMLInstance()) == 'Xiphe\HTML') {
            return Core\Config::getHTMLInstance();
        } elseif (get_class($GLOBALS['HTML']) == 'Xiphe\HTML') {
            return $GLOBALS['HTML'];
        } else {
            return new HTML($initArgs);
        }
    }
1214646
private function organizeQueryParameters($inParameters = null)
    {
        $ctypeParameters = [];
        $metaParameters = [];
        if (is_array($inParameters)) {
            foreach ($inParameters as $key => $value) {
                if (in_array($key, ['page', 'limit', 'offset', 'returnsingle', 'printquery', 'paging', 'order'])) {
                    $metaParameters[$key] = $value;
                } else {
                    $ctypeParameters[$key] = $value;
                }
            }
        }

        return [$metaParameters, $ctypeParameters];
    }
1081147
public function Paragraphs($minVal = 1, $maxVal = null)
    {
        list($min, $max) = $this->resolveMinMax($minVal, $maxVal, 5);
        $paragraphs = rand($min, $max);
        $faker = $this->getFaker();
        $i = 0;
        $html = "";
        while ($i < $paragraphs) {
            $html .= "<p>".$faker->paragraph(rand(2, 6))."</p>";
            $i++;
        }

        return DBField::create_field("HTMLText", $html);
    }
885356
public function render()
    {
        if ($this->hasParagraphs()) {
            foreach ($this->paragraphs as $paragraph) {
                $this->childNodes->push($paragraph);
            }
        }

        return parent::render();
    }
109871
private function generateSnippets()
    {
        if ($this->snippetsGenerated) {
            return null;
        }

        $snippetsSet = array();
        foreach ($this->undefinedSteps as $i => $undefinedStep) {
            $snippet = $this->generateSnippet($undefinedStep->getEnvironment(), $undefinedStep->getStep());

            if (!$snippet) {
                continue;
            }

            if (!isset($snippetsSet[$snippet->getHash()])) {
                $snippetsSet[$snippet->getHash()] = array();
            }

            $snippetsSet[$snippet->getHash()][] = $snippet;
            unset($this->undefinedSteps[$i]);
        }

        $this->snippets = array_values(
            array_map(
                function (array $snippets) {
                    return new AggregateSnippet($snippets);
                },
                $snippetsSet
            )
        );
        $this->undefinedSteps = array_values($this->undefinedSteps);
        $this->snippetsGenerated = true;
    }
765144
public function totalGivennames(...$params): string
    {
        $query = DB::table('name')
            ->where('n_file', '=', $this->tree->id());

        if (empty($params)) {
            // Count number of distinct given names.
            $query
                ->distinct()
                ->where('n_givn', '<>', '@P.N.')
                ->whereNotNull('n_givn');
        } else {
            // Count number of occurences of specific given names.
            $query->whereIn('n_givn', $params);
        }

        $count = $query->count('n_givn');

        return I18N::number($count);
    }
1242353
public function paragraphs($paragraph_count = 12) {
    $output = '';
    for ($i = 1; $i <= $paragraph_count; $i++) {
      $output .= $this->sentences(mt_rand(20, 60)) ."\n\n";
    }
    return $output;
  }
304799
public function getSPARQL( $includePrefixes = true ) {
		if ( !is_bool( $includePrefixes ) ) {
			throw new InvalidArgumentException( '$includePrefixes has to be a bool' );
		}

		$this->usageValidator->validate();

		$sparql = $includePrefixes ? $this->prefixBuilder->getSPARQL() : '';
		// @todo throw an exception instead of defaulting to SELECT?
		$sparql .= $this->queryForm ?: 'SELECT';
		$sparql .= ' ' . $this->uniqueness . $this->formatSelects() . ' WHERE';
		$sparql .= ' {' . $this->graphBuilder->getSPARQL() . ' }';
		$sparql .= $this->modifierBuilder->getSPARQL();

		return $sparql;
	}
15577
public function getHtmlFormulaireParcours($params = array())
    {
        $html                = "";
        $bbCode              = new bbCodeObject();
        $recherche           = new archiRecherche();
        $idParcours          = 0;
        $libelleParcours     = "";
        $titre               = "Ajout d'un parcours";
        $formAction          = $this->creerUrl('ajouterParcours', 'adminListeParcours', array());
        $checkedActif        = false;
        $dateAjout           = date("d/m/Y");
        $commentaireParcours = "";
        $idSource            = "0";
        $libelleSource       = "";
        if (isset($this->variablesGet['archiIdParcours']) && $this->variablesGet['archiIdParcours']!='') {
            $d                   = new dateObject();
            $titre               = "Modification d'un parcours";
            $idParcours          = $this->variablesGet['archiIdParcours'];
            $reqParcours         = "
            SELECT p.idParcours as idParcours,p.libelleParcours as libelleParcours,p.isActif as isActif,p.dateAjoutParcours as dateAjoutParcours,p.commentaireParcours as commentaireParcours,
                    s.nom as nomSource, tp.nom as nomTypeSource, s.idSource as idSource
            FROM parcoursArt p
            LEFT JOIN source s ON s.idSource = p.idSource
            LEFT JOIN typeSource tp ON tp.idTypeSource = s.idTypeSource
            WHERE p.idParcours = '".$idParcours."'";
            $resParcours         = $this->connexionBdd->requete($reqParcours);
            $fetchParcours       = mysql_fetch_assoc($resParcours);
            $libelleParcours     = $fetchParcours['libelleParcours'];
            $commentaireParcours = $fetchParcours['commentaireParcours'];
            $libelleSource       = stripslashes($fetchParcours['nomSource']." (".$fetchParcours['nomTypeSource'].")");
            $idSource            = $fetchParcours['idSource'];
            $dateAjout           = $d->toFrenchAffichage($fetchParcours['dateAjoutParcours']);
            if ($fetchParcours['isActif']==1) {
                $checkedActif = true;
            }
            $formAction = $this->creerUrl('modifierParcours', 'adminListeParcours', array());
        }
        $html        .= "<h1>$titre</h1>";
        $arrayBBCode  = $bbCode->getBoutonsMiseEnFormeTextArea(array('formName'=>'formParcours', 'fieldName'=>'commentaireParcours'));
        //coords
        $reqListeEtapes              = "SELECT idEvenementGroupeAdresse FROM etapesParcoursArt WHERE idParcours = '".$idParcours."'";
        $resListeEtapes              = $this->connexionBdd->requete($reqListeEtapes);
        $a = new archiAdresse();
        while ($fetchListeEtapes = mysql_fetch_assoc($resListeEtapes)) {
            $coords=$a->getCoordonneesFrom($fetchListeEtapes['idEvenementGroupeAdresse'], 'idEvenementGroupeAdresse');
            $points[]=$coords["latitude"].", ".$coords["longitude"];
        }
        $html.="<br/><br/>";
        include_once "includes/class.polylineEncoder.php";
        foreach ($points as $key => $point) {
            $points[$key] = explode(',', $point);
        }

        $encoder = new PolylineEncoder();
        @$polyline = $encoder->encode($points);
        $reqTrace              = "SELECT trace, levels FROM `parcoursArt` WHERE `idParcours` = ".mysql_escape_string($idParcours);
        $resTrace              = $this->connexionBdd->requete($reqTrace);
        $trace = mysql_fetch_assoc($resTrace);
        //
        $configFields = array(
            'idParcours'=>array('libelle'=>'idParcours', 'type'=>'hidden', 'error'=>'', 'value'=>'', 'default'=>$idParcours, 'htmlCode'=>''),
            'dateAjoutParcours'=>array('libelle'=>'date ajout', 'type'=>'date', 'error'=>'', 'value'=>'', 'default'=>$dateAjout, 'htmlCode'=>'', 'withDatePicker'=>true),
            'isActif'=>array('libelle'=>'est actif', 'type'=>'singleCheckBox', 'error'=>'', 'value'=>'', 'default'=>'', 'htmlCode'=>'', 'isChecked'=>$checkedActif, 'forceValueTo'=>'1'),
            'libelleParcours'=>array('libelle'=>'libelle', 'type'=>'text', 'error'=>'', 'value'=>'', 'default'=>$libelleParcours, 'htmlCode'=>"style='width:300px;'"),
            'commentaireParcours'=>array('libelle'=>'commentaire', 'type'=>'bigText', 'error'=>'', 'value'=>'', 'default'=>$commentaireParcours, 'htmlCode'=>"style='width:400px;height:200px;'", 'htmlCodeBeforeField'=>$arrayBBCode['boutonsHTML'], 'htmlCode2'=>$arrayBBCode['divAndJsAfterForm']),
            'idSourcetxt'=>array('libelle'=>'source', 'type'=>'text', 'error'=>'', 'value'=>'', 'default'=>$libelleSource, 'htmlCode'=>'', 'htmlCode2'=>"<input type='button' name='choixSource' onclick=\"document.getElementById('calqueSource').style.top=(getScrollHeight()+150)+'px';document.getElementById('calqueSource').style.display='block';document.getElementById('paramChampsAppelantSource').value='idSource';\" value='Choisir'>"),
            'idSource'=>array('libelle'=>'idSource', 'type'=>'hidden', 'error'=>'', 'value'=>'', 'default'=>$idSource, 'htmlCode'=>""),
            "polyline"=>array("libelle"=>_("Liste des coordonnées")." ("._("à utiliser avec")." <a href='https://developers.google.com/maps/documentation/utilities/polylineutility'>Interactive Polyline Encoder</a>)", "type"=>"text", "default"=>$polyline->points, "htmlCode"=>"readonly onclick='this.select();'", "error"=>""),
            "levels"=>array("libelle"=>_("Niveaux"), "type"=>"text", "default"=>$polyline->levels, "htmlCode"=>"readonly onclick='this.select();'", "error"=>""),
            "trace"=>array("libelle"=>_("Coordonnées détaillées"), "type"=>"text", "default"=>$trace["trace"], "htmlCode"=>"", "error"=>""),
            "newLevels"=>array("libelle"=>_("Niveaux détaillés"), "type"=>"text", "default"=>$trace["levels"], "htmlCode"=>"", "error"=>"")
        );
        $configForm   = array('fields'=>$configFields, 'formAction'=>$formAction, 'formName'=>'formParcours');
        $f            = new formGenerator();
        $html        .= $f->afficherFromArray($configForm);
        $this->addToJsHeader($recherche->getPopupChoixSource('ajoutModifParcoursAdmin'));
        
        
        return $html;
    }
634146
public function getAllParagraphs()
    {
        $strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '/paragraphs';
        $signedURI = Utils::sign($strURI);

        $responseStream = Utils::processCommand($signedURI, 'GET','');

        $json = json_decode($responseStream);

        if ($json->Code == 200) {
            return $json->Paragraphs->ParagraphLinkList;
        }
        
        AsposeApp::getLogger()->warning('Error occured, http 200 code was not found.', array(
            'json-code' => $json->Code,
        ));
        return false;
    }