예제 #1
0
파일: Cli.php 프로젝트: henvic/MediaLab
 public function route(Zend_Controller_Request_Abstract $dispatcher)
 {
     try {
         $opts = new Zend_Console_Getopt(array('help|h' => 'prints this usage information', 'action|a=s' => 'action name (default: index)', 'controller|c=s' => 'controller name  (default: index)', 'verbose|v' => 'explain what is being done'));
         $opts->parse();
     } catch (Zend_Console_Getopt_Exception $e) {
         echo $e->getMessage() . "\n\n" . $e->getUsageMessage();
         exit(1);
     }
     if ($opts->getOption("help")) {
         echo $opts->getUsageMessage();
         exit;
     }
     if (!$opts->getOption("action")) {
         $opts->setOption("action", "index");
     }
     if (!$opts->getOption("controller")) {
         $opts->setOption("controller", "index");
     }
     $dispatcher->setControllerName($opts->getOption("controller"))->setActionName($opts->getOption("action"));
 }
예제 #2
0
<?php

$path = dirname(__FILE__);
require_once $path . '/../setup.php';
error_reporting(E_ALL);
// get the options and run CLIerror_repo()
try {
    $opts = new Zend_Console_Getopt('e');
    $opts->setOption('ignoreCase', true);
    $options = $opts->parse();
    $new = argsToArray($options);
    print_r($new);
    if (isset($opts->e)) {
        echo "I got the a option " . $new["e"] . " \n";
        $subject = "Teste zend " . Zend_Date::now();
        $message = "<h2>Uma menssagem de teste em " . Zend_Date::now() . "</h2>";
        //$tr = new Zend_Mail_Transport_Sendmail('*****@*****.**');
        //Zend_Mail::setDefaultTransport($tr);
        $mail = new Zend_Mail('utf-8');
        $mail->addTo($new["e"]);
        $mail->setSubject($subject);
        $mail->setBodyHtml($message);
        $mail->setFrom('*****@*****.**', 'Voluntário');
        $mail->setHeaderEncoding(Zend_Mime::ENCODING_BASE64);
        //print_r($mail);exit;
        //Send it!
        $sent = true;
        try {
            $mail->send();
            echo "send teste \n";
        } catch (Exception $e) {
예제 #3
0
 public function getOptions()
 {
     $opts = new Zend_Console_Getopt(array('verbose|v=i' => 'This option specifies verbose output at some level from 1-3', 'help|h' => 'This option prints out help for the command'), array());
     // Don't parse the entire line here
     $opts->setOption('parseAll', false);
     return $opts;
 }
예제 #4
0
 *  <li>
 *      <kbd>--help</kbd> or <kbd>-h</kbd> is an alias to <kbd>--usage</kbd>
 *  </li>
 *  <li>
 *      <kbd>--copyright</kbd> or <kbd>-c</kbd> prints out a copyright statement
 *  </li>
 *  <li>
 *      All additional arguments will be threaten as file names
 *  </ul>
 */
try {
    $options = array('usage|u' => 'Usage - this text', 'help|h' => 'Help (alias for --usage|-u)', 'copyright|c' => 'Copyright statement');
    //  $objOptions will be a Zend_Console_Getopt object
    $getopt = new \Zend_Console_Getopt($options);
    //  set explict case sensitiveness
    $getopt->setOption('ignoreCase', false);
    //  Parse options
    $getopt->parse();
} catch (\Zend_Console_Getopt_Exception $exception) {
    echo $exception->getUsageMessage();
    exit(3);
}
//  Should the help or the usage be shown?
if (true === isset($getopt->u) or true === isset($getopt->h)) {
    echo Application::getUsage($getopt);
    exit(0);
}
//  Should the copyright statement be shown?
if (true === isset($getopt->c)) {
    echo Application::getCopyright();
    exit(0);