本文整理汇总了PHP中sfFinder::in方法的典型用法代码示例。如果您正苦于以下问题:PHP sfFinder::in方法的具体用法?PHP sfFinder::in怎么用?PHP sfFinder::in使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfFinder
的用法示例。
在下文中一共展示了sfFinder::in方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
protected function execute($arguments = array(), $options = array())
{
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'])->getConnection();
$visiteurs_dir = sfConfig::get('sf_root_dir') . '/web/visiteur/';
$interactifs_dir = sfConfig::get('sf_root_dir') . '/web/interactif';
$finder = new sfFinder();
$fileSystem = new sfFilesystem();
foreach ($finder->in($visiteurs_dir) as $file) {
//echo 'search in '. $file;
if (is_file($file) && basename($file) != '.DS_Store') {
$realpath = str_replace($visiteurs_dir, "", $file);
$split = explode('/', $realpath);
if (count($split) > 2) {
//print_r($split);
//exit;
$visiteur_id = $split[0];
$interactif_id = $split[1];
$filename = basename($file);
// check if symlink exist
if (Doctrine::getTable('Interactif')->symlinkDocument($interactif_id, $visiteur_id, $filename, $file)) {
$this->logSection("INFO", "Symlink " . $interactifs_dir . '/' . $interactif_id . '/' . $visiteur_id . '/' . $filename);
}
}
}
}
$this->logSection("INFO", "END Symlink interactif directory");
}
示例2: execute
/**
* @see sfBaseTask
*/
protected function execute($arguments = array(), $options = array())
{
if (($arguments['stability'] == 'beta' || $arguments['stability'] == 'alpha') && count(explode('.', $arguments['version'])) < 2) {
list($stdout, $stderr) = $this->getFilesystem()->execute('svn status -u ' . sfConfig::get('sf_root_dir'));
if (0 < strlen($stderr) || preg_match('/Status against revision\\:\\s+(\\d+)\\s*$/im', $stdout, $matches) < 1) {
throw new Exception('Unable to find last svn revision');
}
// make a PEAR compatible version
$arguments['version'] .= $matches[1];
}
$doc = new DOMDocument();
$doc->load(sfConfig::get('sf_config_dir') . '/package.xml');
$xpath = new DOMXPath($doc);
$xpath->registerNamespace('p', 'http://pear.php.net/dtd/package-2.0');
$name = $xpath->evaluate('string(p:name)', $doc->documentElement);
print 'Releasing ' . $name . ' version "' . $arguments['version'] . "\"\n";
// All lines which start with a character other than 'P' ('Performing...'),
// 'S' ('Status...'), or 'X' (externals definition) are local changes.
list($stdout, $stderr) = $this->getFilesystem()->execute('svn status --no-ignore -u ' . sfConfig::get('sf_root_dir'));
if (0 < strlen($stderr)) {
throw new Exception("svn error: {$stderr}");
} else {
if (preg_match('/^[^PSX\\n]/m', $stdout) > 0) {
throw new Exception('Local modifications. Release process aborted!');
}
}
if (!$xpath->evaluate('boolean(p:date)', $doc->documentElement)) {
$dateNode = $doc->createElement('date', date('Y-m-d'));
// Date element must immediately precede the optional time element or the
// mandatory version element
$timeOrVersionNode = $xpath->query('p:time | p:version', $doc->documentElement)->item(0);
$doc->documentElement->insertBefore($dateNode, $timeOrVersionNode);
}
if (!$xpath->evaluate('boolean(p:version/p:release)', $doc->documentElement)) {
$releaseNode = $doc->createElement('release', $arguments['version']);
$apiNode = $xpath->query('p:version/p:api', $doc->documentElement)->item(0);
$apiNode->parentNode->insertBefore($releaseNode, $apiNode);
}
if (null === ($stabilityNode = $xpath->query('p:stability', $doc->documentElement)->item(0))) {
$stabilityNode = $doc->createElement('stability');
$licenseNode = $xpath->query('p:license', $doc->documentElement)->item(0);
$doc->documentElement->insertBefore($stabilityNode, $licenseNode);
}
if (null === ($apiNode = $xpath->query('p:api', $stabilityNode)->item(0))) {
$apiNode = $doc->createElement('api', $arguments['stability']);
$stabilityNode->appendChild($apiNode);
}
if (!$xpath->evaluate('boolean(p:release)', $stabilityNode)) {
$releaseNode = $doc->createElement('release', $arguments['stability']);
$stabilityNode->insertBefore($releaseNode, $apiNode);
}
// add class files
if (null === ($dirNode = $xpath->query('p:contents/p:dir', $doc->documentElement)->item(0))) {
$dirNode = $doc->createElement('dir');
$dirNode->setAttribute('name', '/');
$contentsNode = $xpath->query('p:contents', $doc->documentElement)->item(0);
$contentsNode->appendChild($dirNode);
}
$patternNodes = array();
foreach ($xpath->query('p:contents//p:file', $doc->documentElement) as $patternNode) {
// Globs like //foo/... must be matched against paths with a leading
// slash, while globs like foo/... must be matched against paths without
// a leading slash. Consequently, prefix all globs with slash, if
// necessary, and always match against paths with a leading slash.
if (strncmp($glob = $patternNode->getAttribute('name'), '/', 1) != 0) {
$glob = '/' . $glob;
}
$pattern = AuditTask::globToPattern($glob);
$patternNodes[$pattern] = $patternNode;
$patternNode->parentNode->removeChild($patternNode);
}
// FIXME: Switch back to SvnFinder when it supports externals
$finder = new sfFinder();
foreach ($finder->in(sfConfig::get('sf_root_dir')) as $path) {
if (strncmp($path, sfConfig::get('sf_root_dir'), $len = strlen(sfConfig::get('sf_root_dir'))) == 0) {
$path = substr($path, $len);
}
unset($fileNode);
foreach ($patternNodes as $pattern => $patternNode) {
if (preg_match('/^' . str_replace('/', '\\/', $pattern) . '$/', $path) > 0) {
if (!isset($fileNode)) {
$fileNode = $doc->createElement('file');
}
foreach ($patternNode->attributes as $attrNode) {
$fileNode->setAttributeNode(clone $attrNode);
}
}
}
if (isset($fileNode)) {
$fileNode->setAttribute('name', ltrim($path, '/'));
$dirNode->appendChild($fileNode);
}
}
$packageXmlPath = sfConfig::get('sf_root_dir') . '/package.xml';
$doc->save($packageXmlPath);
list($stdout, $stderr) = $this->getFilesystem()->execute('pear package');
if (0 < strlen($stderr)) {
//.........这里部分代码省略.........
示例3: browseDocuments
public function browseDocuments($visiteur_id, $interactif_id_param = "", $params = array('page_size' => 100, 'offset' => 1))
{
$sf_root_dir = sfConfig::get('sf_root_dir') . '/web/visiteur';
$host_url = 'http://' . sfConfig::get('app_front_url') . '/visiteur';
$finder = new sfFinder();
$dirs = array();
$interactif_id = '';
$path = '/' . $visiteur_id . '/';
//die($sf_root_dir.$path);
$cpt_offset = 0;
$cpt_page_size = 0;
$old_interactif = '';
foreach ($finder->in($sf_root_dir . $path . '/' . $interactif_id_param) as $file) {
//echo 'search in '. $file;
if (is_file($file)) {
//echo $file .' == ' . filectime($file) .'<br>';
$filepath = str_replace($sf_root_dir . $path, "", $file);
//echo $filepath. ' <br>';
$split = explode("/", $filepath);
//print_r($split);
if (count($split) < 2) {
continue;
}
$cpt_offset++;
//echo "\n OFFSET= ".$cpt_offset . ' <= '.$params['offset'];
if ($cpt_offset <= $params['offset']) {
continue;
}
if (count($split) > 1) {
if ($cpt_page_size < $params['page_size']) {
if ($interactif_id_param == '') {
$interactif_id = $split[0];
} else {
$interactif_id = $interactif_id_param;
}
$filename = $split[1];
if ($filename == '.DS_Store') {
continue;
}
$url_path = str_replace('//', '/', $path . '/' . $interactif_id . '/' . $filename);
$result = array("url" => $host_url . $url_path, "creation_date" => date("Y-m-d H:i:s", filemtime($file)));
$interactif = array();
if ($old_interactif != $interactif_id) {
$interactif_info = Doctrine::getTable('Interactif')->findOneByGuid($interactif_id);
if ($interactif_info) {
$query = 'SELECT e.guid AS guid, e.libelle AS libelle';
$query .= ' FROM exposition e, exposition_parcours e2, parcours_interactif p, interactif i';
$query .= ' WHERE (';
$query .= ' e.guid = e2.exposition_id';
$query .= ' AND e2.parcours_id = p.parcours_id';
$query .= ' AND p.interactif_id = i.guid';
$query .= ' AND i.guid = "' . $interactif_id . '"';
$query .= ' ) group by guid';
$expo_info = Doctrine_Manager::getInstance()->getCurrentConnection()->fetchAssoc($query);
$interactif = array('libelle' => $interactif_info->getLibelle(), 'url_illustration' => $interactif_info->getUrlIllustration(), 'expositions' => $expo_info);
}
}
$old_interactif = $interactif_id;
$dirs["interactifs"][$interactif_id][] = array_merge($interactif, $result);
}
$cpt_page_size++;
}
}
}
//print_r($dirs);
return $dirs;
}
示例4: browseDocuments
public function browseDocuments($interactif_id, $visiteur_id_param = "", $params = array('page_size' => 100, 'offset' => 1))
{
$sf_root_dir = sfConfig::get('sf_root_dir') . '/web/interactif';
$host_url = 'http://' . sfConfig::get('app_front_url') . '/interactif';
$finder = new sfFinder();
$finder->follow_link();
$dirs = array();
$visiteur_id = '';
$path = '/' . $interactif_id . '/';
//die($sf_root_dir.$path);
$cpt_offset = 0;
$cpt_page_size = 0;
$old_visiteur = '';
foreach ($finder->in($sf_root_dir . $path . '/' . $visiteur_id_param) as $file) {
//echo 'search in '. $file;
if (is_file($file)) {
//echo $file .' == ' . $sf_root_dir.$path .'<br>';
$filepath = str_replace($sf_root_dir . $path, "", $file);
//echo $filepath. ' <br>';
$split = explode("/", $filepath);
//print_r($split);
if (count($split) < 2) {
continue;
}
$cpt_offset++;
//echo "\n OFFSET= ".$cpt_offset . ' <= '.$params['offset'];
if ($cpt_offset <= $params['offset']) {
continue;
}
if (count($split) > 1) {
if ($cpt_page_size < $params['page_size']) {
//echo "\n PAGESIZE= ".$cpt_page_size . ' < '.$params['page_size'];
if ($visiteur_id_param == '') {
$visiteur_id = $split[0];
} else {
$visiteur_id = $visiteur_id_param;
}
$visiteur = array();
if ($old_visiteur != $visiteur_id) {
$visiteur_info = Doctrine::getTable('Visiteur')->findOneByGuid($visiteur_id);
if ($visiteur_info) {
$visiteur = array('pseudo_son' => $visiteur_info->getPseudoSon());
}
}
$old_visiteur = $visiteur_id;
$filename = $split[1];
if ($filename == '.DS_Store') {
continue;
}
$url_path = str_replace('//', '/', $path . '/' . $visiteur_id . '/' . $filename);
$result = array("url" => $host_url . $url_path, "creation_date" => date("Y-m-d H:i:s", filemtime($file)));
$dirs["visiteurs"][$visiteur_id][] = array_merge($visiteur, $result);
}
$cpt_page_size++;
}
}
}
//print_r($dirs);
return $dirs;
}