Esempio n. 1
0
 /**
  * クラス間のデータ交換に使うDataBridgeクラスをインスタンス化し、
  * グローバル変数 dataBridgeに保存する。
  * またアプリのルートディレクトリなどを保存する
  * CmdLib.phpがあるディレクトリがアプリのルートの直下なら$depth=1
  * 
  * @param integer $depth=1 
  */
 public static function setDataBridge($depth = 1)
 {
     global $dataBridge;
     $dataBridge = new DataBridge();
     $APP_ROOT = self::getAppRoot($depth);
     $dataBridge->APP_ROOT = $APP_ROOT;
     $dataBridge->dispatch_path = '/';
     $dataBridge->dispatch_class = 'CmdApp';
     $dataBridge->dispatch_action = 'main';
     self::$APP_ROOT = $APP_ROOT;
 }
Esempio n. 2
0
 /**
  * コマンドライン パラメータを返す
  */
 function getparams()
 {
     $_ = $this;
     $params = array();
     if (!($pageName = CmdLibs::getParam('-p'))) {
         //die($_->getUsage());
         $pageName = "uploadImg";
     }
     echo "Install Upload image set to : {$pageName}.\n";
     $params['pageName'] = $pageName;
     return $params;
 }
Esempio n. 3
0
 /**
  * コマンドライン パラメータを返す
  */
 public function getparams()
 {
     $_ = $this;
     $params = array();
     if (!($pageName = CmdLibs::getParam('-p'))) {
         //die($_->getUsage());
         $pageName = "imgtomap";
     }
     echo "Install Upload Image and locate to map to : {$pageName}.\n";
     $params['pageName'] = $pageName;
     return $params;
 }
Esempio n. 4
0
 /**
  * コマンドライン パラメータを返す
  */
 function getparams()
 {
     $_ = $this;
     $params = array();
     if (!($pageName = CmdLibs::getParam('-p'))) {
         //die($_->getUsage());
         $pageName = "gmap";
     }
     echo "Install Google Maps display set to : {$pageName}.\n";
     $params['pageName'] = $pageName;
     return $params;
 }
Esempio n. 5
0
 /**
  * コマンドライン パラメータを返す
  */
 function getparams()
 {
     $_ = $this;
     $params = array();
     if (!($dbName = CmdLibs::getParam('-d'))) {
         die($_->getUsage());
     } else {
         echo "Install auth set to database: {$dbName}.\n";
         $params['dbName'] = $dbName;
     }
     return $params;
 }
Esempio n. 6
0
 public function testGetById()
 {
     $_ = $this;
     $AmazonSearch = new AmazonSearch();
     CmdLibs::bannerBig('ItemLookup Books', false);
     $conditions = ['SearchIndex' => 'Books', 'IdType' => 'ISBN', 'ResponseGroup' => 'ItemIds,ItemAttributes,SalesRank,Images', 'ItemId' => '9784774174099'];
     $result = $AmazonSearch->getById($conditions);
     foreach ($result as $item) {
         echo $item['Title'] . "\n";
     }
     $this->assertTrue(is_array($result));
     $this->assertNotEquals(0, count($result));
 }
Esempio n. 7
0
 public function main()
 {
     $_ = $this;
     $_->APP_ROOT = CmdLibs::getAppRoot(1);
     $_->initView();
     $_->usage = $_->getUsage();
     $params = $_->getDbParams();
     if (!empty($params['dbName'])) {
         $_->saveDbClassFile($params);
     } else {
         echo "Plaese set database name.\n";
         die($_->usage);
     }
     exit;
 }
Esempio n. 8
0
 public function main()
 {
     $_ = $this;
     if (!($dbname = CmdLibs::getParam('-d'))) {
         die("usage: " . CmdLibs::scriptName() . " -d dbname \n");
     } else {
         echo "use database {$dbname}.\n\n";
     }
     if ($targetTable = CmdLibs::getParam('-t')) {
         echo "target table is '{$targetTable}'.\n\n";
     } else {
         echo "all tables in DB are target.\n\n";
     }
     $_->makeTableFiles($dbname, $targetTable);
 }
Esempio n. 9
0
 public function main()
 {
     CmdLibs::bannerBig('Batch Sample');
     $_ = $this;
     // Smartyの初期化
     $_->initView();
     // DBオブジェクトとテーブルオブジェクトの生成
     $DB = $_->getDB('TEST');
     $TABLE = $_->getTable($DB, 'TEST');
     // データの取得と表示
     $TABLE->reset();
     $list = $TABLE->find()->fetchAll();
     $_->view->assign('list', $list);
     $template = $_->getTemplate();
     echo $_->view->fetch("string:{$template}");
 }
Esempio n. 10
0
 public function __construct()
 {
     CmdLibs::setDataBridge();
     parent::__construct();
 }
Esempio n. 11
0
 public function makeBlankModel($pageName)
 {
     $_ = $this;
     $_->APP_ROOT = CmdLibs::getAppRoot(1);
     $_->initView();
     $dirPath = $_->APP_ROOT . "/model/{$pageName}";
     if (!file_exists($dirPath)) {
         mkdir($dirPath, 0777, true);
     }
     $className = ucfirst($pageName) . 'Model';
     $_->view->assign('pageName', $pageName);
     $_->view->assign('className', $className);
     $filePath = $dirPath . '/' . $className . ".php";
     // model file
     if (file_exists($filePath)) {
         echo "error: {$filePath} is exists. can not save file.\n\n";
     } else {
         $templateFile = $_->APP_ROOT . '/etc/template/model/blankModel.php';
         $classCode = $_->view->fetch($templateFile);
         file_put_contents($filePath, $classCode);
         echo "------------------------------\n";
         echo "save class file {$className}.php\n";
         echo "\n";
         //echo $classCode;
         //echo "\n";
     }
     // Blank Model Test
     $testDirPath = $_->APP_ROOT . "/test/model/{$pageName}";
     if (!file_exists($testDirPath)) {
         mkdir($testDirPath, 0777, true);
     }
     $filePath = $testDirPath . '/' . $className . "Test.php";
     if (file_exists($filePath)) {
         echo "error: {$filePath} is exists. can not save file.\n\n";
     } else {
         $templateFile = $_->APP_ROOT . '/etc/template/test/model/blankModelTest.php';
         $classCode = $_->view->fetch($templateFile);
         file_put_contents($filePath, $classCode);
         echo "------------------------------\n";
         echo "save class file {$className}" . "Test.php\n";
         echo "\n";
         //echo $classCode;
         //echo "\n";
     }
 }
Esempio n. 12
0
 */
function searchClassInDir($dir, $classFile)
{
    $files = glob("{$dir}/*");
    if (!empty($files)) {
        foreach ($files as $subFilePath) {
            if (is_dir($subFilePath)) {
                if (searchClassInDir($subFilePath, $classFile)) {
                    return true;
                }
            } else {
                $fileName = basename($subFilePath);
                if ($fileName == $classFile) {
                    require_once $subFilePath;
                    return true;
                }
            }
        }
    }
    return false;
}
/**
 * オートローディング関数を登録
 */
spl_autoload_register("autoLoadClass");
/**
 * バッチ実行時に$dataBridgeをセット
 */
if (!isset($dataBridge)) {
    CmdLibs::setDataBridge();
}
Esempio n. 13
0
 /**
  * コマンドライン パラメータを返す
  */
 public function getparams()
 {
     $_ = $this;
     $params = array();
     if (!($appName = CmdLibs::getParam('-a'))) {
         die($_->getUsage());
     } else {
         echo "make application : {$appName}.\n";
         $params['appName'] = $appName;
         $params['rootDir'] = CmdLibs::getParam('-r');
     }
     $params = array_merge($params, $_->getDbParams());
     return $params;
 }
Esempio n. 14
0
 /**
  * 使い方の文字列(usage)を返す
  *
  */
 public function getUsage()
 {
     $_ = $this;
     //$usages = array_merge($_->getAppUsage(), $_->getDbUsage());
     $usages = $_->getAppUsage();
     $usage = "usage: " . CmdLibs::scriptName() . "\n";
     foreach ($usages as $switch => $value) {
         $usage .= ' ' . $switch . ' ' . $value . "\n";
     }
     return $usage;
 }
Esempio n. 15
0
 /**
  * ファイルの保存
  * @param boolean $altDelimiter
  */
 public function saveFile($altDelimiter = false)
 {
     $_ = $this;
     if (file_exists($_->filePath) && !$_->overWrite) {
         echo "Warning: '" . $_->filePath . "' is exists. You should set parameter '-o yes'.\n";
         return false;
     }
     if (!file_exists($_->dirPath)) {
         mkdir($_->dirPath, 0777, true);
     }
     if ($altDelimiter == true) {
         $_->view->left_delimiter = '<!--{';
         $_->view->right_delimiter = '}-->';
         $code = $_->view->fetch($_->templateFile);
         $_->view->left_delimiter = '{';
         $_->view->right_delimiter = '}';
     } else {
         $code = $_->view->fetch($_->templateFile);
     }
     file_put_contents($_->filePath, $code);
     CmdLibs::bannerBig($_->message);
     CmdLibs::bannerMid($code);
 }