Exemplo n.º 1
0
 /**
  * Responds to requests to POST /lorem
  */
 public function postGenerate(Request $request)
 {
     // Validate the request data
     // quantity refers to how many paragraphs/sentences/or words to generate
     $this->validate($request, ['quantity' => 'required|integer|min:1|max:99']);
     $quantity = $request->input('quantity');
     $lorem_type = $request->input('lorem_type');
     //instantiate a new Generator object using the Badcow LoremIpsum pkg
     $generator = new \Badcow\LoremIpsum\Generator();
     //lorem type is a numeric value 1-3 that corresponds with paragraph,
     //sentences, or words
     switch ($lorem_type) {
         case 1:
             $text = $generator->getParagraphs($quantity);
             break;
         case 2:
             $text = $generator->getSentences($quantity);
             break;
         case 3:
             $text = $generator->getRandomWords($quantity);
             break;
         default:
             $text = $generator->getParagraphs($quantity);
             break;
     }
     return view('lorem.generate')->with('quantity', $quantity)->with('lorem_type', $lorem_type)->with('text', $text);
     //return $request;
     //$generator = new Generator();
     //$paragraphs = $generator->getParagraphs($title);
     //echo implode('<p>', $paragraphs);
     //$sentences = $generator->getSentences($title);
     //echo implode('<p>', $sentences);
     //$words = $generator->getRandomWords($title);
     //echo implode('<p>', $words);
 }
Exemplo n.º 2
0
 public function postIndex(Request $request)
 {
     $this->validate($request, ['paragraphs' => 'required|numeric|min:1|max:12']);
     $numParas = $request->input('paragraphs');
     $generator = new \Badcow\LoremIpsum\Generator();
     $paragraphs = $generator->getParagraphs($numParas);
     return view('loremipsum')->with('paragraphs', $paragraphs)->with('numParas', $numParas);
 }
Exemplo n.º 3
0
 public function generator(Request $request)
 {
     $num = $request->input('paragraphs');
     $generator = new \Badcow\LoremIpsum\Generator();
     $paragraphs = $generator->getParagraphs($num);
     //return view('lorem')->with('paragraphs', $paragraphs);
     return View('lorem')->with('paragraphs', $paragraphs);
 }
Exemplo n.º 4
0
 public function setText()
 {
     $generator = new Badcow\LoremIpsum\Generator();
     switch ($lorem_type) {
         case 1:
             $text = $generator->getParagraphs($quantity);
             break;
         case 2:
             $text = $generator->getSentences($quantity);
             break;
         case 3:
             $text = $generator->getRandomWords($quantity);
             break;
         default:
             $paragraphs = $generator->getParagraphs($quantity);
             break;
     }
 }
Exemplo n.º 5
0
 public function postCreate()
 {
     if ($_POST['numParagraphs'] < 1 || $_POST['numParagraphs'] > 100) {
         return view('errors.inputCheck');
     }
     //instantiate a Lorem Ipsum generator from the package
     $generator = new \Badcow\LoremIpsum\Generator();
     //generate the paragraphs using the generator
     $paragraphs = $generator->getParagraphs($_POST['numParagraphs']);
     return view('loremipsum.show')->with('paragraphs', $paragraphs);
 }
Exemplo n.º 6
0
 /**
  * Responds to requests to POST /lorem_ipsum
  */
 public function postNumParas(Request $request)
 {
     $numParagraphs = $request->input('numParagraphs');
     /* Validation to make sure the input is between 0 and 99 and is an integer */
     $this->validate($request, ['numParagraphs' => 'required|integer|max:99|min:0']);
     /* This is the LoremIpsum generator package function installed for the project */
     $generator = new \Badcow\LoremIpsum\Generator();
     $paragraphs = $generator->getParagraphs($numParagraphs);
     /* Sending back the numparagraphs as well so it can be re-entered in the input field after the post */
     return view('LIGen.paras')->with('paragraphs', $paragraphs)->with('numParagraphs', $numParagraphs);
 }
Exemplo n.º 7
0
 public function postLoremIpsum(Request $request)
 {
     $generator = new \Badcow\LoremIpsum\Generator();
     /* Initiate the loremIpsum generator from package */
     $selector = "lorem";
     /* Variable to pass back to the view to retain user's last options */
     /* Create text using the generator, number of paragraphs from user's POST */
     $num_paragraphs = $request->input("lorem_num_par");
     $loremIpsumText = $generator->getParagraphs($num_paragraphs);
     /* Display home view with generated lorem ipsum and user's last preferences */
     return view("home")->with("textData", $loremIpsumText)->with("selector", $selector);
 }
Exemplo n.º 8
0
function displayParagraphs($count)
{
    $result = '';
    // object is created
    $generator = new Badcow\LoremIpsum\Generator();
    $paragraphs = $generator->getParagraphs($count);
    // loop to create user requested number of paragraphs
    for ($i = 0; $i < $count; $i++) {
        $result .= "<p>" . $paragraphs[$i] . "</p>";
    }
    return $result;
}
Exemplo n.º 9
0
 function postLoremIpsum(Request $request)
 {
     //validate the noParagrahs input field
     $this->validate($request, ['noParagrahs' => 'required|numeric|between:1,99']);
     //greats a loremIpsum object
     $generator = new \Badcow\LoremIpsum\Generator();
     $paragraphs = '';
     //tests to see if noParagrahs is set
     if ($request->has('noParagrahs')) {
         //gets the loremIpsum as an array
         $paragraphs = $generator->getParagraphs($request->input('noParagrahs'));
     }
     //converts the array to a string and returns it with the array
     return view('layouts.loremIpsum')->with('loremContent', implode('<p>', $paragraphs));
 }
Exemplo n.º 10
0
 public function postText(Request $request)
 {
     $paragraphs = $request->input('paragraphs');
     $generator = new \Badcow\LoremIpsum\Generator();
     $paragraphs = $generator->getParagraphs($paragraphs);
     return view('loremipsum.loremipsum_generated')->with('paragraphs', $paragraphs);
     /* return view('loremipsum.loremipsum');
     		
     		$how_many = ($_POST['paragraphs']);
     			
     		$this->validate($request, [
     		'population' => 'required|numeric',
     		]);
     		
     		//create paragraphs	
     				
     		 */
     //dd ($request->all());
 }
Exemplo n.º 11
0
@section('content')
  <h1>Lorem Ipsum Generator</h1>
  <h3>How many paragraphs do you want?</h3>
  <form method="POST" actions="/loremipsum">
      <input type="hidden" value="{{ csrf_token() }}" name="_token">
      <fieldset>
        <label for="paragraphs"><h4>Paragraphs (1-50):</h4></label>
        <input type="text" id="paragraphs" name="paragraphs" value={{ $paragraphs or '2' }}>
      </fieldset>
      <button type="submit" class="btn btn-success">Generate Paragraphs</button><hr>
  </form>


  @if(count($errors) > 0)
    @foreach ($errors->all() as $error)
      <h3><span class="label label-danger">{{ $error }}</span></h3>
    @endforeach
  @endif


  @if ($_SERVER['REQUEST_METHOD'] == 'POST')
    <?php 
$generator = new Badcow\LoremIpsum\Generator();
$text = $generator->getParagraphs($paragraphs);
echo implode('<p>', $text);
?>
  @endif
	<hr>
  <h4><a href='/'>Back to home page</a></h4>
	@stop
Exemplo n.º 12
0
					{{ Form::text('paragraphs_number', '3') }}
					{{ Form::label('paragraphs_max', '(Max: 99)') }} <br/>
					{{ Form::submit('Generate') }}
					{{ Form::reset('Reset') }}
				{{ Form::close() }}
			</div>
			<div  style="float:right; width:70%; border-left: dashed 1px; padding-left:10px">
				<?php 
if (isset($values['paragraphs_number'])) {
    if (is_numeric($values['paragraphs_number'])) {
        $num = intval($values['paragraphs_number']);
        if ($num <= 99 && $num > 0) {
            print "<b>RESULTS</b>";
            print "<br>";
            $generator = new Badcow\LoremIpsum\Generator();
            $paragraphs = $generator->getParagraphs($num);
            echo implode('<p>', $paragraphs);
        } else {
            if ($num <= 0) {
                echo '<font color="red">Error: Number must be greater than 0!</font>';
            } else {
                echo '<font color="red">Error: Number must be less than 99!</font>';
            }
        }
    } else {
        echo '<font color="red">Error: Must be a valid numeric!</font>';
    }
}
?>
			</div>
		</div>
Exemplo n.º 13
0
 public function postIpsum(Request $request)
 {
     $generator = new \Badcow\LoremIpsum\Generator();
     $result = $generator->getParagraphs($request->input('numberofp'));
     return view('pages.loremipsum')->with("result", $result);
 }
Exemplo n.º 14
0
    <header>
          <label id="text1">
            <img
              src='/images/friendly_dog_2.jpg'
              style=''
              alt='Friendly Dog'>
          Developer's Best Friend
          </label>

    </header>

    <section>
      <?php 
$generator = new Badcow\LoremIpsum\Generator();
$paragraphs = $generator->getParagraphs(5);
echo implode('<p>', $paragraphs);
?>
    </section>

    <footer>
        &copy; {{ date('Y') }}
    </footer>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

    {{-- Yield any page specific JS files or anything else you might want at the end of the body --}}
    @yield('body')

</body>
</html>
Exemplo n.º 15
0
            {{ csrf_field() }}

            <label for='paragraphs'>Paragraphs: </label>
            <input type='text' maxlength='2' id='paragraphs' name='paragraphs' value='{{ old('paragraphs')}}'> (Max: 99)
            <br>

            @if(count($errors) > 0)
                <ul>
                    @foreach ($errors->all() as $error)
                        <li>{{ $error }}</li>
                        @endforeach
                </ul>
            @endif

            <input class='btn btn-primary' type='submit' value='Generate Lorem Ipsum'>
        </form>

        @if(isset($paragraphs))
            <section class='lorem-ipsum-output container center-block"'>
                <?php 
$generator = new Badcow\LoremIpsum\Generator();
$generatedParagraphs = $generator->getParagraphs($paragraphs);
// Extra p tag needed because implode doesn't add the first one
echo '<p>' . implode('<p>', $generatedParagraphs);
?>
            </section>
        @endif
    </div>

@stop
Exemplo n.º 16
0
@extends('layout.master')

@section('content')
{!! Form::open() !!}
  <?php 
isset($request->numOfParagraphs) ? $n = $request->numOfParagraphs : ($n = 1);
echo Form::selectRange('numOfParagraphs', 1, 20, $n) . "   ";
echo Form::label('lNumOfParagraphs', 'Number of Paragraphs');
echo '<br><br>';
echo Form::submit('Submit');
?>
{!! Form::close() !!}


<p>
  @if(isset($request->numOfParagraphs))
    <?php 
$generator = new Badcow\LoremIpsum\Generator();
$paragraphs = $generator->getParagraphs($request->numOfParagraphs);
echo implode('<p>', $paragraphs);
?>
  @endif
</p>
@stop