public function testGetPluginIni() { $iniReader = $this->getMock('Omeka_Plugin_Ini', array(), array(), '', false); $iniReader->expects($this->once())->method('hasPluginIniFile')->with('foobar')->will($this->returnValue(true)); $iniReader->expects($this->once())->method('getPluginIniValue')->with('foobar', 'foo')->will($this->returnValue('returned ini value')); Zend_Registry::set('plugin_ini_reader', $iniReader); $this->assertEquals('returned ini value', get_plugin_ini('foobar', 'foo')); }
private function _getUserAgent() { try { $version = get_plugin_ini('OaipmhHarvester', 'version'); } catch (Zend_Exception $e) { $version = ''; } return 'Omeka OAI-PMH Harvester/' . $version; }
<?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * Define constants and instantiate the mamanger class. * * @package omeka * @subpackage neatline * @author Scholars' Lab <> * @author David McClure <*****@*****.**> * @copyright 2012 The Board and Visitors of the University of Virginia * @license http://www.apache.org/licenses/LICENSE-2.0.html Apache 2 License */ // defines {{{ if (!defined('NLMAPS_PLUGIN_VERSION')) { define('NLMAPS_PLUGIN_VERSION', get_plugin_ini('NeatlineMaps', 'version')); } if (!defined('NLMAPS_PLUGIN_DIR')) { define('NLMAPS_PLUGIN_DIR', dirname(__FILE__)); } // }}} // requires {{{ require_once NLMAPS_PLUGIN_DIR . '/NeatlineMapsPlugin.php'; require_once NLMAPS_PLUGIN_DIR . '/helpers/NeatlineMapsFunctions.php'; require_once NLMAPS_PLUGIN_DIR . '/forms/ServerForm.php'; require_once NLMAPS_PLUGIN_DIR . '/forms/Validate/isUrl.php'; require_once NLMAPS_PLUGIN_DIR . '/lib/GeoserverMap_Abstract.php'; require_once NLMAPS_PLUGIN_DIR . '/lib/GeoserverMap_WMS.php'; // }}} /* * Run.
/** * Determine if the CsvImport Full is installed. * * Some import options are unailable if CsvImport Full is not installed. * * @return boolean */ public static function isFullCsvImport() { return substr(get_plugin_ini('CsvImport', 'version'), -5) == '-full'; }
/** * Apply a xslt stylesheet on a xml file. * * @param string $xml_file * Path of xml file. * @param string $xsl_file * Path of the xslt file. * @param string $output * Path of the output file. If none, a temp file will be used. * @param array $parameters * Parameters array. * * @return string|null * Path to the output file if ok, null else. */ private function _apply_xslt_and_save($xml_file, $xsl_file, $output = '', $parameters = array()) { if (empty($output)) { $output = tempnam(sys_get_temp_dir(), 'xmlimport_'); } $processor = basename(get_option('xml_import_xslt_processor')); switch ($processor) { // Saxon-B on Debian/Ubuntu/Mint. case 'saxonb-xslt': // Saxon on RedHat/Fedora/Centos/Mandriva. // Saxon on RedHat/Fedora/Centos/Mandriva. case 'saxon': $command = array($processor, '-ext:on', '-versionmsg:off', '-s:' . escapeshellarg($xml_file), '-xsl:' . escapeshellarg($xsl_file), '-o:' . escapeshellarg($output)); foreach ($parameters as $name => $parameter) { $command[] = escapeshellarg($name . '=' . $parameter); } $command = implode(' ', $command); $result = (int) shell_exec($command . ' 2>&- || echo 1'); @chmod(escapeshellarg($output), 0644); // In Shell, 0 is a correct result. return $result == 1 ? NULL : $output; // Php default. // Php default. default: try { $DomXml = $this->_domXmlLoad($xml_file); $DomXsl = $this->_domXmlLoad($xsl_file); } catch (Exception $e) { throw new Exception($e->getMessage()); } $proc = new XSLTProcessor(); // Php functions are needed, because php doesn't use XSLT 2.0 // and because we need to check existence of a file. if (get_plugin_ini('XmlImport', 'xml_import_allow_php_in_xsl') == 'TRUE') { $proc->registerPHPFunctions(); } $proc->importStyleSheet($DomXsl); $proc->setParameter('', $parameters); $result = $proc->transformToURI($DomXml, $output); @chmod(escapeshellarg($output), 0644); return $result === FALSE ? NULL : $output; } }
/** * Construct exhibit globals array. * * @param NeatlineExhibit $exhibit The exhibit. * @return array The array of globals. */ function nl_globals($exhibit) { // Get style defaults from `styles.ini`. $styles = new Zend_Config_Ini(NL_DIR . '/styles.ini'); return array('neatline' => array('exhibit' => $exhibit->toArray(), 'record_api' => public_url('neatline/records'), 'exhibit_api' => public_url('neatline/exhibits/' . $exhibit->id), 'item_search_api' => public_url('items/browse'), 'item_body_api' => public_url('neatline/items'), 'per_page' => (int) get_plugin_ini('Neatline', 'per_page'), 'styles' => $styles->toArray(), 'spatial_layers' => nl_getLayersForExhibit($exhibit), 'strings' => nl_getStrings(NL_DIR . '/strings.json'), 'openlayers_theme' => nl_getOpenLayersThemeDir())); }
/** * Apply a process (xslt stylesheet) on an input (xml file) and save output. * * @param string $input Path of input file. * @param string $stylesheet Path of the stylesheet. * @param string $output Path of the output file. If none, a temp file will * be used. * @param array $parameters Parameters array. * @return string|null Path to the output file if ok, null else. */ private function _processXsltViaPhp($input, $stylesheet, $output = '', $parameters = array()) { if (empty($output)) { $output = tempnam(sys_get_temp_dir(), 'omk_'); } try { $domXml = $this->_domXmlLoad($input); $domXsl = $this->_domXmlLoad($stylesheet); } catch (Exception $e) { throw new Exception($e->getMessage()); } $proc = new XSLTProcessor(); // Php functions are needed, because php doesn't use XSLT 2.0 // and because we need to check existence of a file. if (get_plugin_ini('XmlImport', 'xml_import_allow_php_in_xsl') == 'TRUE') { $proc->registerPHPFunctions(); } $proc->importStyleSheet($domXsl); $proc->setParameter('', $parameters); $result = $proc->transformToURI($domXml, $output); @chmod($output, 0640); return $result === FALSE ? NULL : $output; }
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by * applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS * OF ANY KIND, either express or implied. See the License for the specific * language governing permissions and limitations under the License. * * @package omeka * @subpackage GoogleAnalyticsErr * @author Eric Rochester (erochest@gmail.com) * @copyright 2011 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache 2.0 * @version 0.1 * @link http://www.ericrochester.com/ * */ define('GOOGLE_ANALYTICS_PLUGIN_VERSION', get_plugin_ini('GoogleAnalytics', 'version')); define('GOOGLE_ANALYTICS_PLUGIN_DIR', dirname(__FILE__)); define('GOOGLE_ANALYTICS_ACCOUNT_OPTION', 'googleanalytics_account_id'); class GoogleAnalyticsPlugin extends Omeka_Plugin_AbstractPlugin { protected $_hooks = array('install', 'uninstall', 'public_footer', 'config', 'config_form'); protected $_filters = array(); public function hookInstall() { set_option('googleanalytics_version', GOOGLE_ANALYTICS_PLUGIN_DIR); } public function hookUninstall() { delete_option('googleanalytics_version'); delete_option(GOOGLE_ANALYTICS_ACCOUNT_OPTION); }
/** * This returns the name of the minified JS file for passing to queue_js_file. * * @return string * @author Eric Rochester <*****@*****.**> **/ private function _nlMinJs() { $version = get_plugin_ini('NeatlineFeatures', 'version'); return "neatline-features-{$version}-min"; }