示例#1
0
 /**
  * Check if a string contains naughty words
  * @param string $string
  * @return bool
  */
 public function isDirty(string $string) : bool
 {
     foreach ($this->dictionary->get() as $naughtyWord) {
         if (substr_count($string, $naughtyWord) > 0) {
             return true;
         }
     }
     return false;
 }
示例#2
0
 public static function &all($key = null)
 {
     static::init();
     if ($key) {
         $all = parent::get($key, []);
         parent::delete($key);
         Session::set('_messages', parent::all());
     } else {
         $all = parent::all();
         static::clear();
     }
     return $all;
 }
示例#3
0
文件: view.php 项目: serghei/wmvc
 function display()
 {
     $content = $this->render();
     // translation
     if (preg_match_all('/{([\\^a-z0-9-]+)}/', $content, $matches)) {
         $codes = array_unique($matches[1]);
         foreach ($codes as $code) {
             if ($replace = Dictionary::get($code)) {
                 $content = str_replace("{" . $code . "}", $replace, $content);
             }
         }
     }
     echo str_replace(array("\t", "\n\n"), "", $content);
 }
示例#4
0
 public function current()
 {
     $k = $this->it->current();
     $v = $this->dict->get($k);
     return new KeyValuePair($k, $v);
 }
示例#5
0
文件: bean.php 项目: dapepe/tymio
 /**
  * This function evaluates a datapath relativ to the given dataset.
  *
  * @param string $strDataPath The XML data path
  * @param Xily\Xml $mxtDataset The dataset on which the datapath should be applied
  * @param bool $bolStringOnly If true, the function will only return results of type string
  * @param bool $bolStrict If strict mode is of, the function will try to convert unfitting object to strings (e.g. XML files)
  * @return string|array|Xily\Xml|mixed
  */
 private function xdr_data($strDataPath, $mxtDataset, $bolStringOnly = true, $bolStrict = false)
 {
     // TESTING: $this->probe('xdr_data', "STEP3: Evaluating datapath", 7);
     // TESTING: $this->probe('xdr_data', "Only Strings: ".($bolStringOnly?'on':'off'), 7);
     // TESTING: $this->probe('xdr_data', "Path: ".$strDataPath, 7);
     if (is_array($mxtDataset)) {
         // TESTING: $this->probe('xdr_data', "Dataset is an array", 8);
         $xlyArray = new Dictionary($mxtDataset);
         return $xlyArray->get($strDataPath, false);
     } elseif ($mxtDataset instanceof Xml || $mxtDataset instanceof Bean) {
         // TESTING: $this->probe('xdr_data', "Dataset is an XML/Bean document", 8);
         if ($bolStringOnly) {
             // TESTING: $this->probe('xdr_data', "Tracing the datapath now: ".$strDataPath, 9);
             return $mxtDataset->trace($strDataPath);
         } else {
             // TESTING: $this->probe('xdr_data', "Retrieving the object now: ".$strDataPath, 9);
             $mxtData = $mxtDataset->getNodesByPath($strDataPath);
             if (isset($mxtData[1])) {
                 return $mxtData;
             } elseif (isset($mxtData[0])) {
                 return $mxtData[0];
             } else {
                 return false;
             }
         }
     } else {
         // TESTING: $this->probe('xdr_data', "Invalid dataset: Dataset must be an array or XML/Bean object.", 8);
         return false;
     }
 }
 /**
  * Retrieves endpoint information.
  * @return mixed 	Information about endpoint
  */
 public function endpoint_info()
 {
     if (ENVIRONMENT !== "dev") {
         return NULL;
     }
     $og_endpoint = $this->server->original_endpoint;
     $og_exists = Dictionary::exists($og_endpoint);
     if ($og_exists) {
         $endpoint = Dictionary::get($og_exists);
     }
     return Output::encode($endpoint, $this->server->output);
 }
示例#7
0
<?php

namespace Util;

require_once __DIR__ . '/../vendor/autoload.php';
$dict = new Dictionary(array('testing.this' => 'test1', 'testing.t' => 'test', 'testing.te' => 'test', 'testing.tes.flip' => 'test'));
$dict['testing.it.some.more'] = 'ssssss';
$dict['testing.test'] = '1';
$dict['testing.tea'] = '1';
$dict['banana.tea'] = '1';
$dict['banana.te.a'] = '1';
$dict['banana.te'] = 'a';
$dict->merge(array('test.again' => 'a', 'test.another' => 'b', 'banana.tea.chai' => 'good'));
echo '<pre>';
print_r($dict->get());
print_r($dict['test.again']);