/** * @todo rename * @param string $sImage * @param string $sOutputFolder * @param int $iBlockSize * @return array - array of cropped images */ protected static function _cropImage($sImage, $sOutputFolder, $iBlockSize, $sPathPostFix = '') { $aFileInfo = pathinfo($sImage); $sCmd = sprintf('nice -n 15 %1$s %2$s -crop %4$dx%4$d -set filename:title "%%[fx:page.y/%4$d+1]_%%[fx:page.x/%4$d+1]" +repage +adjoin %3$s/"resource_%%[filename:title]%6$s.%5$s"', self::getConfig()->bin->convert, $sImage, $sOutputFolder, $iBlockSize, $aFileInfo['extension'], $sPathPostFix); AM_Tools_Standard::getInstance()->passthru($sCmd); $aFiles = AM_Tools_Finder::type('file')->name('resource_*' . $sPathPostFix . '.' . $aFileInfo['extension'])->sort_by_name()->in($sOutputFolder); return $aFiles; }
/** * Convert pdf to png files * @return type */ public function getAllPagesThumbnails() { $sTempDir = AM_Handler_Temp::getInstance()->getDir(); $sPdfDrawBin = $this->_getPadcmsdrawPath(); $sCmd = sprintf('nice -n 15 %s -a -r 200 -o %s/splitted-%%d.png %s > /dev/null 2>&1', $sPdfDrawBin, $sTempDir, $this->_sSourceFile); AM_Tools_Standard::getInstance()->passthru($sCmd); $aFilesPng = AM_Tools_Finder::type('file')->name('splitted-*.png')->sort_by_name()->in($sTempDir); return $aFilesPng; }
/** * Find sql files in fixtures path and execute SQL queries * * @param string $sPath */ protected function _loadFixtures($sPath) { $aSchemaFiles = AM_Tools_Finder::type('file')->name('*.sql')->in($sPath); $this->_echo('Loading fixtures'); foreach ($aSchemaFiles as $sSchemaFilePath) { $sSql = file_get_contents($sSchemaFilePath); $sSql = str_replace('\\n', '', $sSql); $sSql = rtrim($sSql, ';'); $aSqls = explode(';', $sSql); $bHasError = false; foreach ($aSqls as $sSql) { try { $this->_oDbAdapter->query($sSql); } catch (Zend_Db_Statement_Exception $oException) { $bHasError = true; $this->_echo($sSchemaFilePath, 'error'); $this->_echo($oException->getMessage(), 'error'); } } if (!$bHasError) { $this->_echo('Loading fixture: ' . $sSchemaFilePath, 'success'); } } }
/** * Get all tests from dir * * @return array */ protected function _getAllTestFiles() { $aFiles = AM_Tools_Finder::type('file')->name('*Test.php')->in($this->_sPathToTests); sort($aFiles); return (array) $aFiles; }
/** * Get all tests from dir * * @return string */ protected function _getTestFile() { $sCaseName = $this->_getArgument('case'); if (!$sCaseName) { throw new AM_Cli_Task_Exception('Please specify the test file name' . PHP_EOL . PHP_EOL); } $sTestCaseFileName = $sCaseName . '.php'; $sTestCaseFileBasePath = Zend_Registry::get("config")->test->test_folder; $aTestCaseFilesPathes = AM_Tools_Finder::type('file')->name($sTestCaseFileName)->in($sTestCaseFileBasePath); if (empty($aTestCaseFilesPathes)) { throw new AM_Cli_Task_Exception(sprintf('Test file "%s" is not found%s%s', $sTestCaseFileName, PHP_EOL, PHP_EOL)); } return $aTestCaseFilesPathes; }
/** * Get files in temp dirrectory * @todo: refactor * @return array */ public function getFiles($dirName, $sPattern = null) { $sPattern = empty($sPattern) ? '*' : $sPattern; $aFiles = AM_Tools_Finder::type('file')->name($sPattern)->in($dirName); return $aFiles; }
/** * Get compilled files * @param string|null $sName Name pattern ('*_thumb.*' return all thumbnails of static pdfs) * @return type */ public function getFiles($sName = null) { $sName = is_null($sName) ? "*" : $sName; $aFiles = AM_Tools_Finder::type('file')->name($sName)->sort_by_name()->in($this->_getFilesPath()); return $aFiles; }