Beispiel #1
0
 /**
  * Renders a chunk of text
  * 
  * @param mixed $Identify ChunckID.
  * @param mixed $Options type of chunk (Textarea [default], Text)
  * @return mixed $Result.
  */
 function Chunk($Identify, $Options = False)
 {
     static $ChunkModel;
     if (is_null($ChunkModel)) {
         $ChunkModel = new ChunkModel();
     }
     static $PermissionChunksEdit;
     if (is_null($PermissionChunksEdit)) {
         $PermissionChunksEdit = CheckPermission('Candy.Chunks.Edit');
     }
     $Data = $ChunkModel->GetID($Identify);
     if ($Data != False) {
         $String = Gdn_Format::To($Data->Body, $Data->Format);
         $Type = ArrayValueI('type', $Options, 'Textarea');
         $Class = ArrayValueI('class', $Options, '');
         if ($Type) {
             if ($PermissionChunksEdit) {
                 $Class .= ' Editable Editable' . $Type;
             }
             $String = Wrap($String, 'div', array('class' => trim($Class), 'id' => 'Chunk' . $Data->ChunkID));
         }
         return $String;
     }
 }
Beispiel #2
0
<?php

require_once dirname(__FILE__) . '/../../../plugins/UsefulFunctions/bootstrap.console.php';
$SQL = Gdn::SQL();
$Px = $SQL->Database->DatabasePrefix;
$ChunkModel = new ChunkModel();
$Limit = Console::Argument('limit', 5);
if (!is_numeric($Limit) || $Limit <= 0) {
    $Limit = 5;
}
Gdn::Config()->Set('Plugins.UsefulFunctions.LoremIpsum.Language', 'noIpsum', True, False);
/**
* Examples:
* 
*/
Console::Message("Start.");
for ($i = 0; $i < $Limit; $i++) {
    $Format = 'xHtml';
    $Name = LoremIpsum(2);
    $Body = LoremIpsum('p' . rand(2, 3));
    $InsertUserID = rand(1, 5);
    $Fields = compact('Format', 'Name', 'Body', 'InsertUserID');
    $ChunkID = $ChunkModel->Save($Fields);
    if (!$ChunkID) {
        Console::Message('^1Error: %s', VarDump($ChunkModel->Validation->Results()));
        return;
    }
    Console::Message("Saved ^3%s (%s)", $ChunkID, $Name);
}