<commit_before><?php

class Page {
  
  private $url = ''; // Includes BASE_URL, the "folder" (if applicable), and a trailing slash
  private $uri = ''; // Between $this->url and '?'
  private $type = ''; // $this->uri's file extension (if any)
  private $query = ''; // A string beginning with '?' (if any params)
  private $domain = ''; // The $website as defined in the main index.php page. 
  private $folder = null; // A "folder" (directory) that shifts the relative context of the $this->url and $this->uri
  private $theme = 'default';
  public $language = 'en';
  public $charset = 'UTF-8';
  public $title = '';
  public $description = '';
  public $keywords = '';
  public $robots = true;
  public $body = '';
  public $vars = array(); // an extra array that can be stuffed with whatever values you please - for themes mainly
  private $data = array(); // meta, ico, apple, css, style, other, js, script
  private $saved = array(); // managed in $this->save($name), and retrieved in $this->info($name) - for filters mainly
  private $filters = array(); // managed in $this->filter() (public), and retrieved in $this->customize() (private)
  private $loaded = array(); // include(ed) files from $this->load()
  
  private $params = array(); // remove along with $this->get()
  
  public function __construct () {
    global $ci;	
    $this->url = BASE_URL;
    $this->uri = $ci->uri->uri_string();
    $this->type = pathinfo($this->uri, PATHINFO_EXTENSION);
    if (empty($this->type)) $this->type = 'html';
    $this->query = strstr($_SERVER['REQUEST_URI'], '?');
    $path = $ci->config->item('cache_path');
    $this->domain = substr($path, strrpos(rtrim($path, '/'), '/') + 1, -1);
    $this->charset = $ci->config->item('charset');
  }
  
  public function folder ($folders='') {
    global $ci;
    if (is_null($this->folder) && !empty($folders)) {
      $this->folder = false;
      if (empty($this->uri) && is_file($folders . 'index/index.php')) {
        $this->folder = $folders . 'index/';
      } elseif (($folder = $ci->input->get('page')) && !preg_match('/(\?|&)page=/i', $this->query) && is_file($folders . $folder . '/index.php')) {
        $this->folder = $folders . $folder . '/';
      } else {
        $paths = explode('/', $this->uri);
        for ($count=count($paths); $count>0; $count--) {
          $path = implode('/', $paths);
          if (is_file($folders . $path . '/index.php')) {
            $this->url .= $path . '/';
            $this->uri = substr($this->uri, strlen($path . '/'));
            $this->folder = $folders . $path . '/';
            break;
          }
          array_pop($paths);
        }
      }
    }
    return $this->folder;
  }
  
  public function set ($var, $value='') {
    global $ci;
    if (!is_array($var)) $var = array($var => $value);
    foreach ($var as $key => $value) {
      switch ($key) {
        case 'theme':
        case 'language':
        case 'charset':
        case 'title':
        case 'description':
        case 'keywords':
        case 'robots':
        case 'body':
          $this->$key = $value;
          if ($key == 'theme' && isset($ci->blog)) $ci->blog->setup();
          break;
        default:
          $this->vars[$key] = $value;
          break;
      }
    }
  }
  
  public function __set ($name, $value) {
    global $ci;
    if ($name == 'theme') {
      $this->theme = $value;
      if ($value != 'admin' && isset($ci->blog)) $ci->blog->setup();
    } else {
      
      
      if ($name == 'post' && !empty($value)) {
        print_r(debug_backtrace());
        exit;
      }
      
      
      $this->vars[$name] = $value;
    }
  }
  
  public function __isset ($name) {
    // http://stackoverflow.com/questions/2045791/php-empty-on-get-accessor
    return ($this->__get($name) !== null) ? true : false;
  }
  
  public function &__get ($name) {
    // This method must return a reference and not use ternary operators for multidimensional arrays to work
    // http://stackoverflow.com/questions/4310473/using-set-with-arrays-solved-but-why
    // http://stackoverflow.com/questions/5966918/return-null-by-reference-via-get
    switch ($name) {
      case 'url':
      case 'uri':
      case 'type':
      case 'query':
      case 'domain':
      case 'theme':
        return $this->$name;
        break;
    }
    if (isset($this->vars[$name])) return $this->vars[$name];
    return null;<commit_msg>Removed debug code from previous commit<commit_after><?php

class Page {
  
  private $url = ''; // Includes BASE_URL, the "folder" (if applicable), and a trailing slash
  private $uri = ''; // Between $this->url and '?'
  private $type = ''; // $this->uri's file extension (if any)
  private $query = ''; // A string beginning with '?' (if any params)
  private $domain = ''; // The $website as defined in the main index.php page. 
  private $folder = null; // A "folder" (directory) that shifts the relative context of the $this->url and $this->uri
  private $theme = 'default';
  public $language = 'en';
  public $charset = 'UTF-8';
  public $title = '';
  public $description = '';
  public $keywords = '';
  public $robots = true;
  public $body = '';
  public $vars = array(); // an extra array that can be stuffed with whatever values you please - for themes mainly
  private $data = array(); // meta, ico, apple, css, style, other, js, script
  private $saved = array(); // managed in $this->save($name), and retrieved in $this->info($name) - for filters mainly
  private $filters = array(); // managed in $this->filter() (public), and retrieved in $this->customize() (private)
  private $loaded = array(); // include(ed) files from $this->load()
  
  private $params = array(); // remove along with $this->get()
  
  public function __construct () {
    global $ci;	
    $this->url = BASE_URL;
    $this->uri = $ci->uri->uri_string();
    $this->type = pathinfo($this->uri, PATHINFO_EXTENSION);
    if (empty($this->type)) $this->type = 'html';
    $this->query = strstr($_SERVER['REQUEST_URI'], '?');
    $path = $ci->config->item('cache_path');
    $this->domain = substr($path, strrpos(rtrim($path, '/'), '/') + 1, -1);
    $this->charset = $ci->config->item('charset');
  }
  
  public function folder ($folders='') {
    global $ci;
    if (is_null($this->folder) && !empty($folders)) {
      $this->folder = false;
      if (empty($this->uri) && is_file($folders . 'index/index.php')) {
        $this->folder = $folders . 'index/';
      } elseif (($folder = $ci->input->get('page')) && !preg_match('/(\?|&)page=/i', $this->query) && is_file($folders . $folder . '/index.php')) {
        $this->folder = $folders . $folder . '/';
      } else {
        $paths = explode('/', $this->uri);
        for ($count=count($paths); $count>0; $count--) {
          $path = implode('/', $paths);
          if (is_file($folders . $path . '/index.php')) {
            $this->url .= $path . '/';
            $this->uri = substr($this->uri, strlen($path . '/'));
            $this->folder = $folders . $path . '/';
            break;
          }
          array_pop($paths);
        }
      }
    }
    return $this->folder;
  }
  
  public function set ($var, $value='') {
    global $ci;
    if (!is_array($var)) $var = array($var => $value);
    foreach ($var as $key => $value) {
      switch ($key) {
        case 'theme':
        case 'language':
        case 'charset':
        case 'title':
        case 'description':
        case 'keywords':
        case 'robots':
        case 'body':
          $this->$key = $value;
          if ($key == 'theme' && isset($ci->blog)) $ci->blog->setup();
          break;
        default:
          $this->vars[$key] = $value;
          break;
      }
    }
  }
  
  public function __set ($name, $value) {
    global $ci;
    if ($name == 'theme') {
      $this->theme = $value;
      if ($value != 'admin' && isset($ci->blog)) $ci->blog->setup();
    } else {
      $this->vars[$name] = $value;
    }
  }
  
  public function __isset ($name) {
    // http://stackoverflow.com/questions/2045791/php-empty-on-get-accessor
    return ($this->__get($name) !== null) ? true : false;
  }
  
  public function &__get ($name) {
    // This method must return a reference and not use ternary operators for multidimensional arrays to work
    // http://stackoverflow.com/questions/4310473/using-set-with-arrays-solved-but-why
    // http://stackoverflow.com/questions/5966918/return-null-by-reference-via-get
    switch ($name) {
      case 'url':
      case 'uri':
      case 'type':
      case 'query':
      case 'domain':
      case 'theme':
        return $this->$name;
        break;
    }
    if (isset($this->vars[$name])) return $this->vars[$name];
    return null;
{'fraction_non_alphanumeric': 0.19234734792072403, 'fraction_numerical': 0.005728032993470042, 'mean_word_length': 2.4670373312152503, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 115, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1280560', 'n_tokens_mistral': 2813, 'n_tokens_neox': 2753, 'n_words': 722}