function fill_with_random_data() { $gen = new LoremIpsumGenerator('lorem.txt'); $iterations = 10; $rows_per_iteration = 10000; $connection = db_connect(); while ($iterations--) { $query = "INSERT INTO goods (`name`, `description`, `price`, `imgurl`) VALUES "; for ($i = 0; $i < $rows_per_iteration; $i++) { $item = []; $item['name'] = ucfirst(trim($gen->get_sentence())); $item['description'] = trim($gen->get_paragraph()); $item['price'] = rand(1, 10000000) / 100; $item['imgurl'] = get_random_img_name(); $query .= "('{$item['name']}', '{$item['description']}', '{$item['price']}', '{$item['imgurl']}')"; if ($i + 1 != $rows_per_iteration) { $query .= ","; } } $result = mysqli_query($connection, $query); if (!$result) { die('query error: ' . mysqli_error($connection)); } } }
/** * Generate placeholder text. * * Using the famous Lorem Ipsum base text, generate a dummy text based on * specified options. * * @param int $count * The length in words of the dummy text. * @param array $options * (optional) An array of options to manage text generation. Options * available are: * - html: wheter to build HTML content or plain content. Default to false. * - lorem: if the text must start with "Lorem ipsum..." or not. * Default to true. * * @return @e string * The generated dummy text. * * @ingroup helperfunc */ public function placeholder_text($count, $options = array()) { $options = array_merge(array('html' => false, 'lorem' => true), $options); $generator = new LoremIpsumGenerator(); $html_format = $options['html'] ? 'plain' : 'html'; $start_with_lorem_ipsum = $options['lorem']; return ucfirst($generator->getContent($count, $html_format, $start_with_lorem_ipsum)); }
function loremipsum_shortcode($attr, $content = null) { $words = 100; $type = "html"; $generator = new LoremIpsumGenerator(); if (isset($attr["words"])) { $words = $attr["words"]; } if (isset($attr["type"])) { $type = $attr["type"]; } $text = $generator->getContent($words, $type); return $text; }
public function __construct($host = null, $user = null, $pass = null, $dbname = null) { $this->lorem = LoremIpsumGenerator::getInstance(); if (!is_null($host)) { $this->pdo = new \PDO("mysql:host={$host};dbname={$dbname};charset=utf8", $user, $pass); if (!$this->pdo) { throw new Exception("Connection error!"); } return true; } }
/** * Generates a random lorem ipsum tet * * @param integer $min Minimum word count * @param integer $max Maximum word count * @param string $format Output format. Can be "html" or "plain" * * @return string The generated text */ public static function getRandomText($min = 0, $max = 300, $format = 'html') { static $class = null; if (is_null($class)) { $class = new LoremIpsumGenerator(); } $count = rand($min, $max); if ($count == 0) { return '<p></p>'; } return $class->getContent($count); }
<?php // Vars $site_name = "Photo Blog"; $site_url = "http://localhost/phopho"; // Lorem Ipsum require 'lib/LoremIpsum.class.php'; $filler = new LoremIpsumGenerator(); // share links require 'lib/sharelinks.lib.php'; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title><?php echo $site_name; ?> </title> <link rel="stylesheet" href="//brick.a.ssl.fastly.net/Karla:400,700,400i,700i"> <link rel="stylesheet" href="lib/font-awesome-4.1.0/css/font-awesome.min.css"> <link rel="stylesheet" href="css/style.css"> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="lib/packery.pkgd.min.js"></script>
<?php // Vars $site_name = "Photo Blog"; $site_url = "http://localhost/phopho"; // Lorem Ipsum require 'lib/LoremIpsum.class.php'; $filler = new LoremIpsumGenerator(); // share links require 'lib/sharelinks.lib.php'; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title><?php echo $site_name; ?> </title> <link rel="stylesheet" href="//brick.a.ssl.fastly.net/Karla:400,700,400i,700i"> <link rel="stylesheet" href="lib/font-awesome-4.1.0/css/font-awesome.min.css"> <link rel="stylesheet" href="css/style.css"> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="js/phopho-script.js"></script>
function testSave() { //First we need to generate some more TestData(tm) $loremIpsum = new LoremIpsumGenerator(); //First in line is some posts 250 Randomly generated ones, some with mentions. $mentions = 0; $posts = 0; for ($i = 0; $i <= 250; $i++) { $sender = rand(5, 16); $data = $loremIpsum->getContent(17, 'plain'); $postid = rand(1000, 1000000); while (isset($pic[$postid])) { $postid = rand(1000, 1000000); } $pic[$postid] = true; $number = rand(1, 8); if ($number == 1 or $number == 2) { $data = "@jack " . $data; $mentions++; } elseif ($number == 3) { $data = "@jill " . $data; } $q = "INSERT INTO `tt_posts` (`post_id`, `author_user_id`, `post_text`) "; $q .= " VALUES ('" . $postid . "', '" . $sender . "', '" . $data . "');\n"; PDODAO::$PDO->exec($q); if ($sender == 10) { $posts++; } } unset($pic); //Then generate some follows $follows = 0; for ($i = 0; $i <= 150; $i++) { $follow = array("follower" => rand(5, 25), "following" => rand(5, 25)); if (!isset($fd[$follow['following'] . "-" . $follow['follower']])) { $fd[$follow['following'] . "-" . $follow['follower']] = true; $q = "INSERT INTO `tt_follows` (`user_id`, `follower_id`) "; $q .= "VALUES ( '" . $follow['following'] . "', '" . $follow['follower'] . "');\n"; PDODAO::$PDO->exec($q); if ($follow['following'] == 10) { $follows++; } } else { $i = $i - 1; } } //Lastly generate some users $users = array(array('id' => 10, 'name' => 'jack'), array('id' => 12, 'name' => 'jill'), array('id' => 13, 'name' => 'stuart'), array('id' => 15, 'name' => 'Jillian Dickerson'), array('id' => 16, 'name' => 'Paul Clark')); foreach ($users as $user) { $q = "INSERT INTO `tt_users` (`user_id`, `user_name`) "; $q .= " VALUES ('" . $user['id'] . "', '" . $user['name'] . "') "; PDODAO::$PDO->exec($q); } //Now load the instance in question $i = $this->DAO->getByUsername('jack'); //Edit it. $i->last_status_id = 512; $i->last_page_fetched_replies = 2; $i->last_page_fetched_tweets = 17; $i->is_archive_loaded_follows = 1; $i->is_archive_loaded_replies = 1; //First make sure that last run data is correct before we start. $result = $this->DAO->getInstanceOneByLastRun('DESC'); $this->assertIsA($result, "Instance"); $this->assertEqual($result->network_username, 'jill'); $this->assertEqual($result->network_user_id, 12); $this->assertEqual($result->network_viewer_id, 12); //Save it $count = $this->DAO->save($i, 1024); $this->assertEqual($count, 1); //Load it for testing $result = $this->DAO->getByUsername('jack'); $this->assertEqual($result->total_posts_by_owner, 1024); $this->assertEqual($result->last_page_fetched_replies, 2); $this->assertEqual($result->last_status_id, 512); $this->assertEqual($result->last_page_fetched_tweets, 17); $this->assertEqual($result->total_replies_in_system, $mentions); $this->assertEqual($result->total_follows_in_system, $follows); $this->assertEqual($result->total_posts_in_system, $posts); $this->assertEqual($result->total_users_in_system, 5); $this->assertTrue($result->is_archive_loaded_follows); $this->assertTrue($result->is_archive_loaded_replies); //Check if it is the update updated last Run. $result = $this->DAO->getInstanceOneByLastRun('DESC'); $this->assertIsA($result, "Instance"); $this->assertEqual($result->network_username, 'jack'); $this->assertEqual($result->network_user_id, 10); $this->assertEqual($result->network_viewer_id, 10); //Still needs tests for: //earliest_reply_in_system //earliest_post_in_system }
'node:children' => array ( 'comment' => array ( 'label' => 'Comment', 'type' => 'textarea', ), ), ), ), ), ), ), ))) return 'Install Failure: Count not insert example blog pattern.'; //sample posts require('lib/LoremIpsum.class.php'); $gen = new LoremIpsumGenerator; $posts=array(); for($i=0;$i<30;++$i){ $posts['post-'.$i.'-'.random_string()]=array( 'pattern:match'=>'/patterns/blog/post', 'title'=>$gen->getContent(mt_rand(4,15)), 'content'=>$gen->getContent(mt_rand(40,150))); } if(!$node->record_tree2->insert('/',array('myblog'=> array('pattern:children'=>'/patterns/blog/', 'admin:icon'=>'book', 'node:children'=>array('gen'=>array('pattern:match'=>'/patterns/blog/category', 'title'=>'Testing', 'node:children'=>$posts)))))) return 'Install Failure: Could not insert sample blog data.'; return true;
static function lorem_ipsum($num) { static $lorem_ipsum = null; if (!$lorem_ipsum) { require_once MODPATH . "gallery_unit_test/vendor/LoremIpsum.class.php"; $lorem_ipsum = new LoremIpsumGenerator(); } // skip past initial 'lorem ipsum' return substr($lorem_ipsum->getContent($num + 2, "txt"), 13); }
<?//copy+pasta into terminal for 30 blog posts inserted into category at /myblog/gen/ require('lib/LoremIpsum.class.php');$gen = new LoremIpsumGenerator;for($i=0;$i<30;++$i){$node->record_tree2->insert('/myblog/gen/',array('post-#RAND#'=>array('pattern:match'=>'/patterns/blog/post','title'=>$gen->getContent(mt_rand(4,15)),'content'=>$gen->getContent(100))));}