PHP code example of remithomas / rt-extends

1. Go to this page and download the library: Download remithomas/rt-extends library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

remithomas / rt-extends example snippets



return array(
    'modules' => array(
        'Application',
        'RtExtends',
    )
);

$value = array(
    'user_id' => 2,
    'value' => 'myvalue'
);

$sql = new \RtExtends\Db\Sql($adapter, 'mytable');
        
$DuplicateInsert = $sql->duplicateInsert();
$DuplicateInsert->values($values);
        
$sqlString = $sql->getSqlStringForSqlObject($DuplicateInsert);
$adapter->query($sqlString, Adapter::QUERY_MODE_EXECUTE);


$value = array(
    'user_id' => 2,
    'value' => 'myvalue'
);
            
$DuplicateInsert = new RtExtends\Db\Sql\DuplicateInsert("user");
$DuplicateInsert->values($value);

$statment = $this->dbAdapter->createStatement(); 
$DuplicateInsert->prepareStatement($this->dbAdapter, $statment); 
$statment->execute(); 

public function getInputFilterSpecification()
{
    return array(
        'datestart' => array(
            '\Date\IsLater",
                    'options' => array(
                        'min' => date ("d F Y - H:i", mktime()),
                        'format' => 'd F Y - H:i',
                        'timezone' => 'Europe/London'
                    )
                )
            ),
        ),
    );
}

public function getInputFilterSpecification()
{
    return array(
        'dateend' => array(
            'or\Date\IsEarlier",
                    'options' => array(
                        'max' => date ("d F Y - H:i", mktime()),
                        'format' => 'd F Y - H:i',
                        'timezone' => 'Europe/London'
                    )
                )
            ),
        ),
    );
}

$uri = "http://www.dailymotion.com/video/x9003r_pac-man-remi-gaillard_fun";
$uri = "http://www.youtube.com/watch?v=1VVkIOxRcX0"; // youtube
$thumbUri = new \RtExtends\Uri\Thumb();
var_dump($thumbUri->getThumbs($uri));

// limit the number of thumbnails
var_dump($thumbUri->getThumbs($uri, 2));

$uri = "http://framework.zend.com/blog/"; 
$thumbUri = new \RtExtends\Uri\Thumb();
var_dump($thumbUri->getThumb($uri));

$typeUri = new \RtExtends\Uri\Type();
$typeUri->getType("http://www.youtube.com/watch?v=1VVkIOxRcX0"); // return youtube

$metadataUri = new \RtExtends\Uri\MetaData();
$metadataUri->getMetaData("http://www.youtube.com/watch?v=1VVkIOxRcX0"); 
/*
return array(
    'title' => 'media title',
    'description' => 'media description',
    // ...
)
*/

var_dump(RtExtends\Useful\I18n\Languages::getSimpleCodeLanguages());
// array("fr"=>"Français","en"=>"English",'pt'=>'Português',....)

var_dump(RtExtends\Useful\I18n\Languages::getLanguages());
// array('lv_LV'=>'Latvija - Latviešu','en_LB'=>'Lebanon - English','lt_LT'=>'Lietuva - Lietuvių','fr_LU'=>'Luxembourg - Français',,....)

\RtExtends\Useful\Location\Countries::getCountries();

\RtExtends\Useful\Location\Ziptastic::dataLocation("US", "33330");
/*
Return a stdClass object
object(stdClass)#748 (3) {
  ["city"] => string(15) "Fort Lauderdale"
  ["state"] => string(7) "Florida"
  ["country"] => string(2) "US"
}
*/

\RtExtends\Useful\Location\Country\Us::states();
\RtExtends\Useful\Location\Country\Us::statesFIPS(); // FIPS codes
\RtExtends\Useful\Location\Country\Fr::states();
\RtExtends\Useful\Location\Country\De::states();

\RtExtends\Useful\Location\Country\Fr::counties();
\RtExtends\Useful\Location\Country\Fr::countiesStructured(); // by states
\RtExtends\Useful\Location\Country\Us::counties();
\RtExtends\Useful\Location\Country\Us::countiesStructured(); // by states


$files=array('file1.jpg', 'file2.jpg', 'file3.gif');
/**
 *
 * @param array $files
 * @param string $destination
 * @param bool $overwrite
 * @return boolean 
 */
RtExtends\Useful\File\Zip::createZip($files, 'path/destination/myzipfile.zip', true); 


RtExtends\Useful\File\Zip::unzip('path/to/archive', 'path/destination'); 

 
// simple use : generate only one paragraph (element p)
echo \RtExtends\Useful\Data\Fake::getParagraphLoremIpsum(); 

// generate 3 paragraphs (element <p>) with class 'lead'
echo \RtExtends\Useful\Data\Fake::getParagraphLoremIpsum(3,"p",array("class"=>"lead")); 

// generate 2 divs (element <div>) with class 'alert alert-info'
echo \RtExtends\Useful\Data\Fake::getParagraphLoremIpsum(2,"div",array("class"=>"alert alert-info")); 

echo \RtExtends\Useful\Data\Fake::getParagraphLoremIpsum(2,"div",array("class"=>"alert alert-info"),false); 

// simple use : 10 words
echo \RtExtends\Useful\Data\Fake::getWordLoremIpsum(10);

// );

// no random option
echo \RtExtends\Useful\Data\Fake::getWordLoremIpsum(10,"p",array("class"=>"lead"),"!", false);

// no random option but a special line
echo \RtExtends\Useful\Data\Fake::getWordLoremIpsum(10,"p",array("class"=>"lead"),"!", 3);

$data = array("this", "cool");
echo RtExtends\Useful\Php\String::sprintfArray("%s is %s", $data);

$data = array(
    "otherway" => "Or",
    "second" => "like that"
);
echo RtExtends\Useful\Php\String::sprintfArray("%(otherway)s maybe %(second)s !", $data);

echo $this->extendedFlashMessenger(true); // true is to get also current messages

// Success !
$flashMessage = new FlashMessage();
$flashMessage->setTitle("bravo");
$flashMessage->setMessages("Yes you did");

$this->flashmessenger()->addSuccessMessage($flashMessage);

// Error !
$flashMessage = new FlashMessage();
$flashMessage->setTitle("Ups");
$flashMessage->setMessages("This is wrong");

$this->flashmessenger()->addErrorMessage($flashMessage);

    
// Ups error ! (with sub messages
$subMessage = new FlashMessageSub();
$subMessage->setMessage("Ups %(name)s"); // first message
$subMessage->setVariables(array(
    'name' => "John Doe"
));

$subMessageSecond = new FlashMessageSub();
$subMessageSecond->setMessage("Please  check here %(url)s"); // first message
$subMessageSecond->setVariables(array(
    'url' => "http://php.net"
));

$flashMessage = new FlashMessage();
$flashMessage->setTitle("Sorry");
$flashMessage->setMessages(array($subMessage,$subMessageSecond));
                
$this->flashmessenger()->addErrorMessage($flashMessage);

date_default_timezone_set('America/Montreal');
$date = new \DateTime('NOW');

// countdown result in ARRAY
$countDown = $this->rtCountDown($date->getTimestamp()+167890, $date->getTimestamp(), true);

// string (is default param)
$countDown = $this->rtCountDown($date->getTimestamp()+167890, $date->getTimestamp(), false);
<<<<<<< HEAD

$this->BodyClasses()->addClass("my-css-class");
$this->BodyClasses()->addClass(array("my-css-class", "blue-bck"));

$form = new Form('my-form');
$form->add(\RtExtends\Snippets\Form\Element\Csrf::getCreateElementArray("crsf", 60*60));
/* generate
$form->add(array(
    'type' => 'Zend\Form\Element\Csrf',
    'name' => 'crsf',
    'options' => array(
        'csrf_options' => array(
            'timeout' => '3600'
        )
    )
));*/

 
echo \RtExtends\Snippets\Js\Jquery::getUrl(); 
echo "http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js";

echo \RtExtends\Snippets\Js\Jquery::getUrl("2.0.0"); 
echo "http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js";

 
echo \RtExtends\Snippets\Js\Jqueryui::getUrl(); 
echo "http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js";