/** * Return a list of all files in the CVS repository * * This function is like {@link parent::dirList()} except * that instead of retrieving a regular filelist, it first * retrieves a listing of all the CVS/Entries files in * $directory and all of the subdirectories. Then, it * reads the Entries file, and creates a listing of files * that are a part of the CVS repository. No check is * made to see if they have been modified, but newly * added or removed files are ignored. * @return array list of files in a directory * @param string $directory full path to the directory you want the list of * @uses _recurDirList() * @uses _readCVSEntries() */ function dirList($directory) { static $in_recursion = false; if (!$in_recursion) { // include only CVS/Entries files $this->_setupIgnore(array('*/CVS/Entries'), 0); $this->_setupIgnore(array(), 1); $in_recursion = true; $entries = parent::dirList($directory); $in_recursion = false; } else { return parent::dirList($directory); } if (!$entries || !is_array($entries)) { return PEAR_PackageFileManager::raiseError(PEAR_PACKAGEFILEMANAGER_NOCVSENTRIES, $directory); } return $this->_readCVSEntries($entries); }
/** * Return a list of all files in the CVS repository * * This function is like {@link parent::dirList()} except * that instead of retrieving a regular filelist, it first * retrieves a listing of all the CVS/Entries files in * $directory and all of the subdirectories. Then, it * reads the Entries file, and creates a listing of files * that are a part of the CVS repository. No check is * made to see if they have been modified, but newly * added or removed files are ignored. * * @param string $directory full path to the directory you want the list of * * @return array list of files in a directory * @uses _recurDirList() * @uses _readCVSEntries() */ function dirList($directory) { static $in_recursion = false; if ($in_recursion) { return parent::dirList($directory); } // include only CVS/Entries files $this->_setupIgnore(array('*/CVS/Entries'), 0); $this->_setupIgnore(array(), 1); $in_recursion = true; $entries = parent::dirList($directory); $in_recursion = false; if (!$entries || !is_array($entries)) { $code = PEAR_PACKAGEFILEMANAGER_PLUGINS_NOCVSENTRIES; return parent::raiseError($code, $directory); } return $this->_readCVSEntries($entries); }
function getFileList() { $directory = $this->_options['packagedirectory']; $git = $this->_findGitRootDir($directory); if ($git) { $content = null; $content .= file_exists($git . '.gitignore') and file_get_contents($git . '.gitignore'); $content .= file_exists($git . '.git/info/exclude') and file_get_contents($git . '.git/info/exclude'); $content = trim($content, "\n"); $content = explode("\n", $content); $gitignore = array('.git/*', '.gitignore'); $gitinclude = array(); foreach ($content as $pattern) { if (preg_match('/^\\s*#.*$/', $pattern) || preg_match('/^\\s*$/', $pattern)) { continue; } if (preg_match('/^\\s*!(.*)$/', $pattern, $match)) { $gitinclude[] = $match[1]; } else { $gitignore[] = $pattern; } } $this->_options['ignore'] = is_array($this->_options['ignore']) ? array_merge($gitignore, $this->_options['ignore']) : $gitignore; } $fileslist = parent::getFileList(); if (is_array($fileslist) && isset($gitignore) && count($gitinclude)) { // in gitignore you can ignore whole directory then include specified subdirectories // or files with "!" modifier at the begining of patterns. // we have to generate files list and merge it with the main result $this->_options['ignore'] = array(); $this->_options['include'] = array(); foreach ($gitinclude as $entry) { // make sure that entry exists in current include paths if not just ignore it. if ($this->_checkIgnore($entry, $git . $entry, 0)) { continue; } $this->_options['include'][] = $entry; } if (count($this->_options['include'])) { $fileslist = array_merge_recursive($fileslist, parent::getFileList()); } } return $fileslist; }
/** * Build a list of files based on the output of the 'p4 have' command. * * @param string $directory The directory in which to list the files. * * @return mixed An array of full filenames or a PEAR_Error value if * $directory does not exist. */ function dirList($directory) { /* Return an error if the directory does not exist. */ if (@is_dir($directory) === false) { return parent::raiseError(PEAR_PACKAGEFILEMANAGER_PLUGINS_DIR_DOESNT_EXIST, $directory); } /* List the files below $directory that are under Perforce control. */ exec("p4 have {$directory}/...", $output); /* Strip off everything except the filename from each line of output. */ $files = preg_replace('/^.* \\- /', '', $output); /* If we have a list of files to include, remove all other entries. */ if ($this->ignore[0]) { $files = array_filter($files, array($this, '_includeFilter')); } /* If we have a list of files to ignore, remove them from the array. */ if ($this->ignore[1]) { $files = array_filter($files, array($this, '_ignoreFilter')); } return $files; }
/** * Return a list of all files in the SVN repository * * This function is like {@link parent::dirList()} except * that instead of retrieving a regular filelist, it first * retrieves a listing of all the .svn/entries files in * $directory and all of the subdirectories. Then, it * reads the entries file, and creates a listing of files * that are a part of the Subversion checkout. No check is * made to see if they have been modified, but removed files * are ignored. * * @param string $directory full path to the directory you want the list of * * @access protected * @return array list of files in a directory * @uses _recurDirList() * @uses _readSVNEntries() */ function dirList($directory) { static $in_recursion = false; if ($in_recursion) { return parent::dirList($directory); } // include only .svn/entries files // since subversion keeps its data in a hidden // directory we must force PackageFileManager to // consider hidden directories. $this->_options['addhiddenfiles'] = true; $this->_setupIgnore(array('*/.svn/entries'), 0); $this->_setupIgnore(array(), 1); $in_recursion = true; $entries = parent::dirList($directory); $in_recursion = false; if (!$entries || !is_array($entries)) { $code = PEAR_PACKAGEFILEMANAGER_PLUGINS_NOSVNENTRIES; return parent::raiseError($code, $directory); } return $this->_readSVNEntries($entries); }
/** * Return a list of all files in the CVS repository * * This function is like {@link parent::dirList()} except * that instead of retrieving a regular filelist, it first * retrieves a listing of all the CVS/Entries files in * $directory and all of the subdirectories. Then, it * reads the Entries file, and creates a listing of files * that are a part of the CVS repository. No check is * made to see if they have been modified, but newly * added or removed files are ignored. * @return array list of files in a directory * @param string $directory full path to the directory you want the list of * @uses _recurDirList() * @uses _readCVSEntries() */ function dirList($directory) { static $in_recursion = false; if (!$in_recursion) { // include only CVS/Entries files $this->_setupIgnore(array('*/CVS/Entries'), 0); $this->_setupIgnore(array(), 1); $in_recursion = true; $entries = parent::dirList($directory); $in_recursion = false; } else { return parent::dirList($directory); } if (!$entries || !is_array($entries)) { if (strcasecmp(get_class($this->_parent), 'PEAR_PackageFileManager') == 0) { $code = PEAR_PACKAGEFILEMANAGER_NOCVSENTRIES; } else { $code = PEAR_PACKAGEFILEMANAGER2_NOCVSENTRIES; } return $this->_parent->raiseError($code, $directory); } return $this->_readCVSEntries($entries); }
/** * Creates the container and label for the add replacements * page. * * Replacements are install time search and replace strings * that can be used to set certain package variables to * values found on the user's system or that are specific * to the version of the installed package. * * This package uses a replacement to put the proper version * number in the about window so that I don't have to go and * recode that every time. * * @return array The page container and a label for the tab. * @access private */ function _createAddReplacementsPage() { // Create the main box. $mainVBox =& new GtkVBox(); // And the sub boxes $globalVBox =& new GtkVBox(); $globalHBox0 =& new GtkHBox(); $globalHBox1 =& new GtkHBox(); $globalHBox2 =& new GtkHBox(); $globalHBox3 =& new GtkHBox(); $fileVBox =& new GtkVBOX(); $fileHBox0 =& new GtkHBox(); $fileHBox1 =& new GtkHBox(); $fileHBox2 =& new GtkHBox(); $fileHBox3 =& new GtkHBox(); $fileHBox4 =& new GtkHBox(); // Create two success/failure labels. $globalSuccess =& new GtkLabel(''); $fileSuccess =& new GtkLabel(''); // There are two types of replacements: Global and file. // First we will set up the global replacements. // We can do this with a few combo boxes. We will use // one for the type and one for the to value. The to // values are basically predefined sets that won't // change much. I am not concerned about hard coding // these values into the application. // We need to work kind of backwards and create the many // to widgets first. Then we can create the type combo. $globalToPHP =& new GtkEntry(); $globalToPEAR =& new GtkCombo(); $globalToPackage =& new GtkCombo(); $globalToWidgets = array('php-const' => &$globalToPHP, 'pear-config' => &$globalToPEAR, 'package-info' => &$globalToPackage); // We need a box for the to widgets so that we can swap // them out. $globalToWidgetBox =& new GtkHBox(); // The PHP widget is easy. It is just an entry because // there are way to many constants to list. // The PEAR widget on the other hand has a shorter list // of valid values. We will get them using PEAR_Config. $globalToPEARList = $globalToPEAR->list; $globalToPEAREntry = $globalToPEAR->entry; $globalToPEARList->set_selection_mode(GTK_SELECTION_SINGLE); $globalToPEAREntry->set_text('Select One'); $globalToPEAREntry->set_editable(false); // Add the valid values to the list. require_once 'PEAR/Config.php'; $pearConfig =& new PEAR_Config(); foreach ($pearConfig->getKeys() as $pearConfigKey) { $item =& new GtkListItem(); $box =& new GtkHBox(); $label =& new GtkLabel($pearConfigKey); $box->pack_start($label, false, false, 10); $item->add($box); $globalToPEAR->set_item_string($item, $pearConfigKey); $item->set_data('type', $pearConfigKey); $globalToPEARList->add($item); $item->show_all(); } // The package-info widget is a little different. I can't // find a method to get the legal values for this set of // replacements. Therefore, I have to hard code the array. // It will also serve as the array for the file replacements. $globalToPackageList = $globalToPackage->list; $globalToPackageEntry = $globalToPackage->entry; $globalToPackageList->set_selection_mode(GTK_SELECTION_SINGLE); $globalToPackageEntry->set_text('Select One'); $globalToPackageEntry->set_editable(false); $packageOptions = array('name', 'summary', 'description', 'version', 'license', 'state', 'notes', 'date'); foreach ($packageOptions as $option) { $item =& new GtkListItem(); $box =& new GtkHBox(); $label =& new GtkLabel($option); $box->pack_start($label, false, false, 10); $item->add($box); $globalToPackage->set_item_string($item, $option); $item->set_data('type', $option); $globalToPackageList->add($item); $item->show_all(); } // The globalType combo will not change. $globalTypeCombo =& new GtkCombo(); // Set up the combo. $globalTypeList = $globalTypeCombo->list; $globalTypeEntry = $globalTypeCombo->entry; $globalTypeList->set_selection_mode(GTK_SELECTION_SINGLE); $globalTypeEntry->set_text('Select One'); $globalTypeEntry->set_editable(false); // When the entry's value changes, we want to change the // to widget. $globalTypeEntry->connect('changed', array(&$this, '_switchToWidget'), $globalToWidgets, $globalToWidgetBox); // Add the globalTypes to the select box. $globalTypes = array('php-const', 'pear-config', 'package-info'); for ($i = 0; $i < count($globalTypes); $i++) { $item =& new GtkListItem(); $box =& new GtkHBox(); $label =& new GtkLabel($globalTypes[$i]); $box->pack_start($label, false, false, 10); $item->add($box); $globalTypeCombo->set_item_string($item, $globalTypes[$i]); $item->set_data('type', $globalTypes[$i]); $globalTypeList->add($item); $item->show_all(); } // The last part of the global puzzle is the from widget. // This is just an entry that will hold the value in the // package files that should be replaced. // Example: 0.11.0 $globalFromEntry =& new GtkEntry(); // It also helps to have buttons to do the actual work. $globalButtonBox =& new GtkHBox(); $globalAddButton =& new GtkButton('Add Replacement'); $globalAddButton->connect_object('clicked', array($this, '_addReplacement'), NULL, $globalTypeCombo, $globalToWidgetBox, $globalFromEntry, $globalSuccess); $globalButtonBox->pack_end($globalAddButton, false, false, 5); // Next we will set up the file specific replacments. // For this we will need a way to get all of the files // that are to be included in the packaging. If PFM // doesn't have a public method for getting these files // then we will not be able to do this. It will be up to // the developer to edit the file manually. // Until there is a public method, we can use the // PEAR_PackageFileManager_File class to get all of the // files. // Start by creating the widgets for each field. $fileFileCombo =& new GtkCombo(); $fileTypeCombo =& new GtkCombo(); $fileFromEntry =& new GtkEntry(); $fileToWidgetBox =& new GtkHBox(); $fileToPHP =& new GtkEntry(); $fileToPEAR =& new GtkCombo(); $fileToPackage =& new GtkCombo(); $fileToWidgets = array('php-const' => &$fileToPHP, 'pear-config' => &$fileToPEAR, 'package-info' => &$fileToPackage); // Next fill the file combo list. $fileFileList = $fileFileCombo->list; $fileFileEntry = $fileFileCombo->entry; $fileFileList->set_selection_mode(GTK_SELECTION_SINGLE); $fileFileEntry->set_text('Select One'); $fileFileEntry->set_editable(false); // Create a file list generator. // We can't do this until after we have the package options. require_once 'PEAR/PackageFileManager/File.php'; $pfmFile = new PEAR_PackageFileManager_File($this->_packageFileManager, $this->_options); foreach ($pfmFile->dirList($this->_options['packagedirectory']) as $file) { if (PEAR::isError($file)) { $this->_pushWarning($result->getCode(), array()); break; } // Shorten file to a relative path from the package directory. $shortFile = substr($file, strlen($this->_options['packagedirectory'])); $item =& new GtkListItem(); $box =& new GtkHBox(); $label =& new GtkLabel($shortFile); $box->pack_start($label, false, false, 10); $item->add($box); $fileFileCombo->set_item_string($item, $shortFile); $item->set_data('type', $file); $fileFileList->add($item); $item->show_all(); } // The PHP widget is easy. It is just an entry because // there are way to many constants to list. // The PEAR widget on the other hand has a shorter list // of valid values. We will get them using PEAR_Config. $fileToPEARList = $fileToPEAR->list; $fileToPEAREntry = $fileToPEAR->entry; $fileToPEARList->set_selection_mode(GTK_SELECTION_SINGLE); $fileToPEAREntry->set_text('Select One'); $fileToPEAREntry->set_editable(false); // Add the valid values to the list. foreach ($pearConfig->getKeys() as $pearConfigKey) { $item =& new GtkListItem(); $box =& new GtkHBox(); $label =& new GtkLabel($pearConfigKey); $box->pack_start($label, false, false, 10); $item->add($box); $fileToPEAR->set_item_string($item, $pearConfigKey); $item->set_data('type', $pearConfigKey); $fileToPEARList->add($item); $item->show_all(); } // The package-info widget is a little different. I can't // find a method to get the legal values for this set of // replacements. Therefore, I have to hard code the array. // It will also serve as the array for the file replacements. $fileToPackageList = $fileToPackage->list; $fileToPackageEntry = $fileToPackage->entry; $fileToPackageList->set_selection_mode(GTK_SELECTION_SINGLE); $fileToPackageEntry->set_text('Select One'); $fileToPackageEntry->set_editable(false); $packageOptions = array('name', 'summary', 'description', 'version', 'license', 'state', 'notes', 'date'); foreach ($packageOptions as $option) { $item =& new GtkListItem(); $box =& new GtkHBox(); $label =& new GtkLabel($option); $box->pack_start($label, false, false, 10); $item->add($box); $fileToPackage->set_item_string($item, $option); $item->set_data('type', $option); $fileToPackageList->add($item); $item->show_all(); } // The fileType combo will not change. $fileTypeCombo =& new GtkCombo(); // Set up the combo. $fileTypeList = $fileTypeCombo->list; $fileTypeEntry = $fileTypeCombo->entry; $fileTypeList->set_selection_mode(GTK_SELECTION_SINGLE); $fileTypeEntry->set_text('Select One'); $fileTypeEntry->set_editable(false); // When the entry's value changes, we want to change the // to widget. $fileTypeEntry->connect('changed', array(&$this, '_switchToWidget'), $fileToWidgets, $fileToWidgetBox); // Add the fileTypes to the select box. $fileTypes = array('php-const', 'pear-config', 'package-info'); for ($i = 0; $i < count($fileTypes); $i++) { $item =& new GtkListItem(); $box =& new GtkHBox(); $label =& new GtkLabel($fileTypes[$i]); $box->pack_start($label, false, false, 10); $item->add($box); $fileTypeCombo->set_item_string($item, $fileTypes[$i]); $item->set_data('type', $fileTypes[$i]); $fileTypeList->add($item); $item->show_all(); } // The last part of the file puzzle is the from widget. // This is just an entry that will hold the value in the // package files that should be replaced. // Example: 0.11.0 $fileFromEntry =& new GtkEntry(); // It also helps to have buttons to do the actual work. $fileButtonBox =& new GtkHBox(); $fileAddButton =& new GtkButton('Add Replacement'); $fileAddButton->connect_object('clicked', array($this, '_addReplacement'), $fileFileCombo, $fileTypeCombo, $fileToWidgetBox, $fileFromEntry, $fileSuccess); $fileButtonBox->pack_end($fileAddButton, false, false, 5); // Pack every thing up. $globalHBox0->pack_start($globalSuccess, true, true, 5); $globalHBox1->pack_start(new GtkLabel('Type:'), false, false, 5); $globalHBox1->pack_end($globalTypeCombo, false, false, 5); $globalHBox2->pack_start(new GtkLabel('From: (ex: @php_bin@)'), false, false, 5); $globalHBox2->pack_end($globalFromEntry, false, false, 5); $globalHBox3->pack_start(new GtkLabel('To:'), false, false, 5); $globalHBox3->pack_end($globalToWidgetBox, false, false, 5); // The global to widget box starts off the php-const entry. $globalToWidgetBox->pack_start($globalToPHP, false, false, 0); // Put the hBoxes in the vBox. $globalVBox->pack_start($globalHBox0, false, false, 5); $globalVBox->pack_start($globalHBox1, false, false, 5); $globalVBox->pack_start($globalHBox2, false, false, 5); $globalVBox->pack_start($globalHBox3, false, false, 5); $globalVBox->pack_start($globalButtonBox, false, false, 5); // Pack up the file pieces. $fileHBox0->pack_start($fileSuccess, true, true, 5); $fileHBox1->pack_start(new GtkLabel('File:'), false, false, 5); $fileHBox1->pack_end($fileFileCombo, false, false, 5); $fileHBox2->pack_start(new GtkLabel('Type:'), false, false, 5); $fileHBox2->pack_end($fileTypeCombo, false, false, 5); $fileHBox3->pack_start(new GtkLabel('From: (ex: @php_bin@)'), false, false, 5); $fileHBox3->pack_end($fileFromEntry, false, false, 5); $fileHBox4->pack_start(new GtkLabel('To:'), false, false, 5); $fileHBox4->pack_end($fileToWidgetBox, false, false, 5); // The file to widget box starts off the php-const entry. $fileToWidgetBox->pack_start($fileToPHP, false, false, 0); // Put the hBoxes in the vBox. $fileVBox->pack_start($fileHBox0, false, false, 5); $fileVBox->pack_start($fileHBox1, false, false, 5); $fileVBox->pack_start($fileHBox2, false, false, 5); $fileVBox->pack_start($fileHBox3, false, false, 5); $fileVBox->pack_start($fileHBox4, false, false, 5); $fileVBox->pack_start($fileButtonBox, false, false, 5); // Create a pretty frame for the global and file pieces. $globalFrame =& new GtkFrame('Global Replacements'); $fileFrame =& new GtkFrame('File Replacements'); $globalFrame->set_shadow_type(GTK_SHADOW_OUT); $fileFrame->set_shadow_type(GTK_SHADOW_OUT); // Add the global and file boxes to the frames. $globalFrame->add($globalVBox); $fileFrame->add($fileVBox); // Put the global and file frames in the main box. $mainVBox->pack_start($globalFrame, false, false, 5); $mainVBox->pack_start($fileFrame, false, false, 5); return array(&$mainVBox, new GtkLabel('Replacements')); }