Example #1
0
 private static function defineLang()
 {
     $cookieLang = in::getCookie('lang');
     $getLang = in::getGet('lang');
     if (!empty($getLang)) {
         self::$lang = in::getGet('lang');
         out::setCookie('lang', self::$lang, time() + 60 * 60);
     } elseif (!empty($cookieLang)) {
         self::$lang = in::getCookie('lang');
     } else {
         self::$lang = self::defaultLang;
     }
     if (!@(include_once 'includes/langs/' . self::$lang . '.php')) {
         //throw new Exception('includes/langs/'.self::$lang.'.php doesnt exist.');
         @(include_once 'includes/langs/' . self::defaultLang . '.php');
     }
     if (LANGC_DEBUGCHARSET) {
         if (LANGC_LANGCHARSET == 'iso-8859-1' && LANGC_CHARSET == 'utf-8') {
             $sort = null;
             foreach ($STRING as $key => $value) {
                 $sort[$key] = utf8_encode($STRING[$key]);
             }
             $STRING = $sort;
         } elseif (LANGC_LANGCHARSET == 'utf-8' && LANGC_CHARSET == 'iso-8859-1') {
             $sort = null;
             foreach ($STRING as $key => $value) {
                 $sort[$key] = utf8_decode($STRING[$key]);
             }
             $STRING = $sort;
         }
     }
     self::$strings = $STRING;
 }
 public function xtestSetup()
 {
     $db = $this->getDb();
     $table = $this->getTable(__FUNCTION__);
     $_id_list = $this->addRows($db, $table, 5);
     ///$where_criteria = new MingoCriteria();
     ///$where_criteria->ninFoo(1,2);
     ///$where_criteria->is_q('foo:(-1 -2)');
     $list = $db->getQuery('foo NOT foo:(1 2)', array('table' => $table));
     out::e($list);
     $this->assertEquals(3, count($list));
     $this->assureSubset($list, $_id_list);
     return;
     $db = $this->getDb();
     $table = $this->getTable(__FUNCTION__);
     ///$table = new MingoTable(__FUNCTION__);
     $_id_list = array();
     for ($i = 0; $i < 5; $i++) {
         $map = array('foo' => $i);
         $map = $db->set($table, $map);
         $_id_list[] = (string) $map['_id'];
     }
     //for
     out::e($_id_list);
     $c = new MingoCriteria();
     $c->in_id($_id_list);
     $list = $db->get($table, $c);
     out::e($list);
     $count = $db->getCount($table, $c);
     out::e($count);
     ///$db->getQuery('_id:(1z4ddb7b390b5b1759137267 OR 6z4ddb7b39119fc745281592)',array('table' => $table));
 }
Example #3
0
 /**
  *  @since  11-7-11
  */
 public function testCreate()
 {
     $arr = new Arr('one', 'two', 'three');
     $narr = $arr->getArrayCopy();
     $this->assertEquals(array('one', 'two', 'three'), $narr);
     $arr = new Arr(array('one', 'two', 'three'));
     $narr = $arr->getArrayCopy();
     $this->assertEquals(array('one', 'two', 'three'), $narr);
     $arr[] = 'four';
     \out::e($arr->getArrayCopy());
 }
Example #4
0
 /**
  *  get the response of a $resource
  *  
  *  this will block (ie, wait for a response      
  *
  *  @param  resource  $resource the process to read from
  *  @return array the response      
  */
 protected function getResponse($resource)
 {
     $ret_map = array();
     $ret_str = '';
     $ret_str = stream_get_contents($resource);
     ///out::e($ret_str);
     $ret_map = unserialize($ret_str);
     if ($ret_map === false) {
         out::e($ret_str);
     }
     //if
     return $ret_map;
 }
 public function testParse()
 {
     $test_list = array();
     $test_list[] = array('in' => '/' . '**
   * this is the variable description
   * 
   * @var  \\Path\\To\\The\\Class                              
   ********************************************************************' . '/', 'out' => array());
     $test_list[] = array('in' => '/' . '**
   * this is the variable description
   * 
   * @var  \\Path\\To\\The\\Class                              
   *' . '/', 'out' => array());
     $test_list[] = array('in' => '/' . '**
   * 
   * @param  boolean $one  this is a mutli-line description
   *                       that has some more text
   *                       
   * and a little more text                  
   * 
   * @param  string $two  description                  
   *' . '/', 'out' => array());
     $test_list[] = array('in' => '/' . '**
   * 
   * @param  boolean $one  this is a mutli-line description
   *                       that has some more text      
   * 
   * @param  string $two  description                  
   *' . '/', 'out' => array());
     $test_list[] = array('in' => '/' . '**
   * this is the short description
   * 
   * this is the long description.
   * and this also.
   * 
   * and also this.
   *                      
   * @param  boolean $one  this is a mutli-line description
   *                       that has some more text      
   * @param  string $two  description                  
   *' . '/', 'out' => array());
     $test_list[] = array('in' => '/' . '**
   * this is the short description
   * 
   * this is the long description.
   * and this also.
   * 
   * and also this.
   *                      
   * @param  boolean $one  description
   * @param  string $two  description                  
   *' . '/', 'out' => array());
     $test_list[] = array('in' => '/' . '** 
   * @param  boolean $is_there true if there, false otherwise            
   *' . '/', 'out' => array());
     $test_list[] = array('in' => '/' . '** 
   * this will be the multi-line long description
   * and here is the second line
   * and the third            
   *' . '/', 'out' => array());
     $test_list[] = array('in' => '/' . '** 
   * this will be the short description
   *' . '/', 'out' => array());
     $test_list[] = array('in' => '/' . '** 
   *
   *
   *       
   *' . '/', 'out' => array());
     $test_list[] = array('in' => '/' . '** *' . '/', 'out' => array());
     foreach ($test_list as $i => $test_map) {
         $rdc = new ReflectionDocBlock($test_map['in']);
         \out::i($rdc);
         ///$this->assertEquals($test_map['out'],$rfile->getClasses(),$i);
     }
     //foreach
 }
Example #6
0
 /**
  *  handles output of the $call_handler
  *  
  *  @param  out_call  $call_handler the call object with all the call's info to be output 
  *  @param  integer $out_type how you want the output handled       
  *  @return mixed
  */
 private static function put($call_handler, $out_type = self::OUT_SCREEN)
 {
     // canary...
     if (empty($call_handler)) {
         return false;
     }
     //if
     $ret_mix = true;
     switch ($out_type) {
         case self::OUT_SCREEN:
             if ($call_handler->config()->isCli()) {
                 // if we're in cli write to std_err instead of std_out...
                 $fp = fopen('php://stderr', 'a+');
                 fwrite($fp, $call_handler->out());
                 fclose($fp);
             } else {
                 echo $call_handler;
             }
             //if/else
             break;
         case self::OUT_FILE:
             // we want plain text for the file...
             $call_handler->config()->outType(out_config::OUT_TXT);
             if (self::$first_file_call) {
                 // first get the args from the call handler...
                 $arg_list = $call_handler->get();
                 // now combine the args with a generated break with the date as a title for a nice timestamp in the output file...
                 $b_call_handler = self::bHandle(__METHOD__, array(date(DATE_RFC822), 3));
                 $arg_list = array_merge($b_call_handler->get(), $arg_list);
                 $call_handler->set($arg_list);
                 self::$first_file_call = false;
                 // after this, all other file calls are not the first
             }
             //if
             file_put_contents(self::$OUT_TO, $call_handler->out(), FILE_APPEND | LOCK_EX);
             break;
         case self::OUT_STR:
             // we want plain text for the file...
             $call_handler->config()->outType(out_config::OUT_TXT);
             $ret_mix = $call_handler->out();
             break;
         case self::OUT_LOG:
             // http://www.php.net/manual/en/function.error-log.php
             error_log($call_handler->out(), 0);
             break;
     }
     //switch
     return $ret_mix;
 }
Example #7
0
 public function xtestPathStuff()
 {
     ///$path = new Path('E:\Projects\sandbox\montage\_active\test\fixtures\Path');
     $path = new Path('E:\\Projects\\sandbox\\montage\\_active\\test\\fixtures\\Path\\che.txt');
     foreach ($path as $p) {
         \out::e($p);
     }
     //foreach
     return;
     \out::b();
     \out::p('iterate');
     foreach ($path->createIterator() as $p) {
         \out::e($p->getFilename());
         \out::e($p->getBasename());
     }
     //foreach
     \out::p();
 }
Example #8
0
 public static function getLogout()
 {
     $returnS = out::setCookie('session', '', time() + 0);
     $returnV = out::setCookie('v', '', time() + 0);
     if ($returnS || $returnV) {
         return true;
     } else {
         return false;
     }
 }
Example #9
0
try {
    $_site = new site('../xml/site.xml');
    $_struct = new structure('xml/structure.xml', 'xml/data', 'xml/templates');
    $_out = new out();
    $_events = new events('xml/events.xml');
    $_events->addEvent('SectionReady');
    $_events->addEvent('PageReady');
    $_site->setModules(new modules($_site, 'apModules'));
    $modules = $_site->getModules();
    if (!$modules->hasModule('ap')) {
        $modules->move($modules->add('ap'), 1);
    }
    $modules->run();
    $_sec = $_struct->getCurrentSection();
    $_events->happen('SectionReady');
    $_sec->getModules()->run();
    $_out->xmlInclude($_struct);
    $_out->xmlInclude($_site);
    $_events->happen('PageReady');
    $_tpl = $_sec->getTemplate();
    //$_out->save('temp.xml');
    $tmp = explode('/', trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/'));
    array_pop($tmp);
    $_out->de()->setAttribute('base_url', '/' . implode('/', $tmp) . '/');
    echo $_tpl->transform($_out);
} catch (Exception $e) {
    $_out = new out();
    $_out->addSectionContent('Exception: ' . $e->getMessage());
    $_tpl = new template('xml/templates/error.xsl');
    echo $_tpl->transform($_out);
}
Example #10
0
out::prntln("Last index of 'o': " . ((!$hello->lastIndexOf("o")) ? 'false' :  $hello->lastIndexOf("o")));

// ----------------------------------------------------- //

// New Section
out::prntln();

// ----------------------------------------------------- //

// Initialize a File
$file = new File("index.php");

// Get the name
out::prntln("Filename? " . $file->getName());

// Is it a file?
out::prntln("File? " . (($file->isFile()) ? 'true' : 'false'));

// Check validation.
out::prntln("Does it exist? " . (($file->exists()) ? 'true' : 'false'));

// Attempt creation
out::prntln("Creation? " . (($file->createNewFile()) ? 'true' : 'false'));

// Size?
out::prntln("Size: " . $file->length());

// Last modified?
out::prntln("Last modified: " . $file->lastModified());

// ----------------------------------------------------- //
Example #11
0
    $_struct = new structure('xml/structure.xml');
    $_out = new out();
    $_sec = $_struct->getCurrentSection();
    $m = new modules($_site, 'modules');
    $m->run();
    $_sec->getModules()->run();
    $_out->xmlInclude($_struct);
    $_out->xmlInclude($_site->getSiteInfo());
    $_tpl = $_sec->getTemplate();
    //$_out->save('temp.xml');
    echo $_tpl->transform($_out);
} catch (Exception $e) {
    switch ($e->getCode()) {
        case EXCEPTION_404:
            header("HTTP/1.0 404 Not Found");
            $_site = new site('xml/site.xml');
            $_struct = new structure('xml/structure.xml');
            $_out = new out();
            $_out->setMeta('title', '404 Page not found');
            $_sec = $_struct->addSection('error404', '404');
            $_sec->setSelected(true);
            $_out->xmlInclude($_struct);
            $_out->xmlInclude($_site->getSiteInfo());
            $_tpl = new template($_struct->getTemplatePath() . 'default.xsl');
            $_tpl->addTemplate($_struct->getTemplatePath() . '404.xsl');
            echo $_tpl->transform($_out);
            break;
        default:
            echo 'Exception: ' . $e->getMessage();
    }
}
Example #12
0
 /**
  *  check for infinite recursion, throw an exception if found
  *  
  *  this is done by keeping an internal count of how many times this method has been called, 
  *  if that count reaches the max count then an exception is thrown
  *  
  *  @deprecated I've removed catching exceptions from handleError, so this is no longer needed, I'll remove next pass
  *  @return integer the current count
  */
 protected function handleRecursion(\Exception $e)
 {
     $max_ir_count = $this->getField('framework.recursion_max_count');
     $ir_field = 'framework.recursion_count';
     $ir_count = $this->getField($ir_field, 0);
     if ($ir_count > $max_ir_count) {
         $e_msg = sprintf('Infinite recursion suspected! The error handler has been called more than %s times, last exception (%s): %s', $max_ir_count, get_class($e), $e->getMessage());
         \out::i($this);
         ///trigger_error($e_msg,E_USER_ERROR);
         throw new \RuntimeException($e_msg, $e->getCode());
     } else {
         $ir_count += 1;
         $this->setField($ir_field, $ir_count);
     }
     //if/else
     return $ir_count;
 }