public function current() { Timer::start('iterator::' . get_class($this) . '::current'); $content = $this->get_next_record(); $separator = "**********\n"; //split the file at the separator $meta = substr($content, 0, strpos($content, $separator)); $source = substr(strstr($content, $separator), strlen($separator)); Logger::info($meta); $fp = fopen($this->currentArticleFile, "w"); fwrite($fp, $meta); fclose($fp); $fp = fopen($this->currentArticleFile, "r"); $p = new Properties(); $p->load($fp); $meta = array(); $names = $p->propertyNames(); foreach ($names as $key) { $meta[$key] = $p->getProperty($key); } fclose($fp); $source = html_entity_decode($source); $fp = fopen($this->currentArticleFile, "w"); fwrite($fp, $source); fclose($fp); Timer::stop('iterator::' . get_class($this) . '::current'); //$meta['title'] = urldecode($meta['title']); $meta['pageTitle'] = urldecode($meta['pageTitle']); $this->key = $meta['pageTitle']; // return urldecode($pageID); return $meta; }
/** inits the project, called from main app */ public function init() { // set builtin properties $this->setSystemProperties(); // load default tasks $taskdefs = Phing::getResourcePath("phing/tasks/defaults.properties"); try { // try to load taskdefs $props = new Properties(); $in = new PhingFile((string) $taskdefs); if ($in === null) { throw new BuildException("Can't load default task list"); } $props->load($in); $enum = $props->propertyNames(); foreach ($enum as $key) { $value = $props->getProperty($key); $this->addTaskDefinition($key, $value); } } catch (IOException $ioe) { throw new BuildException("Can't load default task list"); } // load default tasks $typedefs = Phing::getResourcePath("phing/types/defaults.properties"); try { // try to load typedefs $props = new Properties(); $in = new PhingFile((string) $typedefs); if ($in === null) { throw new BuildException("Can't load default datatype list"); } $props->load($in); $enum = $props->propertyNames(); foreach ($enum as $key) { $value = $props->getProperty($key); $this->addDataTypeDefinition($key, $value); } } catch (IOException $ioe) { throw new BuildException("Can't load default datatype list"); } }
/** * Determines if this object contains the exact same property name and value pairs as the given object. * Part of the java.util.Hashtable API. * * @param other Properties object. * @return boolean */ public function equals(Properties $other) { $other_names = $other->propertyNames(); $my_names = $this->propertyNames(); if (count($other_names) != count($my_names) || count(array_diff($other_names, $my_names))) { return false; } for ($i = 0; $i < count($my_names); $i++) { if ($this->getProperty($my_names[$i]) !== $other->getProperty($my_names[$i])) { return false; } } return true; }
public function getEstadoSistema() { $status = new status_class(); $status->checkStatus(); $properties = new Properties(); $properties->load(file_get_contents("./sinta.properties")); $dispositivos = array(); foreach ($properties->propertyNames() as $property) { $pos = stripos($property, "."); $disp = substr($property, 0, $pos); $parent = $properties->getProperty($disp . ".parent"); $parentStatus = $properties->getProperty($parent . ".status"); if (!in_array($disp, $dispositivos) && $properties->getProperty($disp . ".status") == 1 && (empty($parent) || $parentStatus == 0)) { $dispositivos[] = $disp; } } if (count($dispositivos) == 0) { return ''; } $alert_messages = array(); // $dispositivos=array("CamaraPresidencia","CamaraAlumnos1","CamaraAlumnos2","FocoMovil","Dvd","DvdGrabador","GeneradorMultiventanas","MatrizVGA","MatrizVideo","MesaMezclas","Pantalla","PantallaPresidencia","PantallaEntrada","Plasma","ProyectorCentral","ProyectorPizarra","Videoconferencia","VisorOpacos","Luces","Automata"); foreach ($dispositivos as $dispositivo) { $errorMsg = $properties->getProperty($dispositivo . ".error"); if (empty($errorMsg)) { $alert_messages[] = "ERROR {$dispositivo}"; } else { $alert_messages[] = $properties->getProperty($dispositivo . ".error"); } } $alert_message = implode("\n", $alert_messages); echo "ALERT::: " . $alert_message; $alert_message = str_replace('"', '', $alert_message); return $alert_message; }
/** Main entry point */ public function main() { if ($this->typeFile === null && ($this->name === null || $this->classname === null)) { throw new BuildException("You must specify name and class attributes for <taskdef>."); } if ($this->typeFile == null) { $this->log("Task " . $this->name . " will be handled by class " . $this->classname, Project::MSG_VERBOSE); $this->project->addTaskDefinition($this->name, $this->classname, $this->classpath); } else { try { // try to load taskdefs given in file $props = new Properties(); $in = new PhingFile((string) $this->typeFile); if ($in === null) { throw new BuildException("Can't load task list {$this->typeFile}"); } $props->load($in); $enum = $props->propertyNames(); foreach ($enum as $key) { $value = $props->getProperty($key); $this->project->addTaskDefinition($key, $value, $this->classpath); } } catch (IOException $ioe) { throw new BuildException("Can't load task list {$this->typeFile}"); } } }
<?php include_once './Properties.php'; $cameraStatus = new Properties(); $cameraStatus->load(file_get_contents("./sinta.properties")); $dispositivos = array(); foreach ($cameraStatus->propertyNames() as $property) { $pos = stripos($property, "."); $disp = substr($property, 0, $pos); if (!in_array($disp, $dispositivos) && $cameraStatus->getProperty($disp . ".check") == 1) { $dispositivos[] = $disp; } } print_r($dispositivos);
/** Main entry point */ public function main() { if ($this->typeFile === null && ($this->name === null || $this->classname === null)) { throw new BuildException("You must specify name and class attributes for <taskdef>."); } if ($this->typeFile !== null) { try { // try to load taskdefs given in file $props = new Properties(); $in = new PhingFile((string) $this->typeFile); if ($in === null) { throw new BuildException("Can't load task list {$this->typeFile}"); } $props->load($in); $enum = $props->propertyNames(); foreach ($enum as $key) { $value = $props->getProperty($key); $this->project->addTaskDefinition($key, $value, $this->classpath); } } catch (IOException $ioe) { throw new BuildException("Can't load task list {$this->typeFile}"); } return; } $this->log("Task {$this->name} will be handled by class {$this->classname}", Project::MSG_VERBOSE); try { $this->project->addTaskDefinition($this->name, $this->classname, $this->classpath); } catch (ConfigurationException $ce) { /** * If the class can't be loaded but requiredWithoutComposer = false * and there isn't a composer autoloader file, we silent it. It * happens when a phing task is executed in composer pre-install-cmd * * * Handle if the exception should be throwed when... * * PHP version is <= 5.2, Composer requires 5.3 */ if (PHP_MAJOR_VERSION . PHP_MINOR_VERSION <= 52) { throw new BuildException("Can't load task {$this->name} at {$this->classname}"); } elseif ($this->requiredWithoutComposer) { /** * the value for argument requiredWithoutComposer is true (default) */ throw new BuildException("Can't load task {$this->name} at {$this->classname}"); } elseif (defined('PHING_COMPOSER_AUTOLOAD_FILE')) { /** * It's not mandatory if doesn't exists composer autoloader * but yes if it exists. */ throw new BuildException("Can't autoload task {$this->name} at {$this->classname}. Try with composer update."); } unset($ce); } }