Example #1
0
 private function _makeSlug()
 {
     $name = $this->title;
     $ghost = new self();
     $uniqifier = 0;
     do {
         $ghost->reset();
         $slug = $this->_sluggify($name);
         $slug = $slug . ($uniqifier > 0 ? '-' . $uniqifier : '');
         $ghost->loadBySlug($slug);
         $uniqifier++;
         if ($uniqifier >= 100) {
             throw new Ajde_Controller_Exception('Max recursion depth reached for setting slug');
         }
     } while ($ghost->hasLoaded());
     return $slug;
 }
Example #2
0
 /**
  * Gets the version of the GnuPG binary
  *
  * @return string a version number string containing the version of GnuPG
  *                being used. This value is suitable to use with PHP's
  *                version_compare() function.
  *
  * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
  *         Use the <kbd>debug</kbd> option and file a bug report if these
  *         exceptions occur.
  *
  * @throws Crypt_GPG_UnsupportedException if the provided binary is not
  *         GnuPG or if the GnuPG version is less than 1.0.2.
  */
 public function getVersion()
 {
     if ($this->_version == '') {
         $options = array('homedir' => $this->_homedir, 'binary' => $this->_binary, 'debug' => $this->_debug, 'agent' => $this->_agent);
         $engine = new self($options);
         $info = '';
         // Set a garbage version so we do not end up looking up the version
         // recursively.
         $engine->_version = '1.0.0';
         $engine->reset();
         $engine->setOutput($info);
         $engine->setOperation('--version');
         $engine->run();
         $matches = array();
         $expression = '#gpg \\(GnuPG[A-Za-z0-9/]*?\\) (\\S+)#';
         if (preg_match($expression, $info, $matches) === 1) {
             $this->_version = $matches[1];
         } else {
             throw new Crypt_GPG_Exception('No GnuPG version information provided by the binary "' . $this->_binary . '". Are you sure it is GnuPG?');
         }
         if (version_compare($this->_version, self::MIN_VERSION, 'lt')) {
             throw new Crypt_GPG_Exception('The version of GnuPG being used (' . $this->_version . ') is not supported by Crypt_GPG. The minimum version ' . 'required by Crypt_GPG is ' . self::MIN_VERSION);
         }
     }
     return $this->_version;
 }
Example #3
0
 /**
  * Gets the version of the GnuPG binary
  *
  * @return string a version number string containing the version of GnuPG
  *                being used. This value is suitable to use with PHP's
  *                version_compare() function.
  *
  * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
  *         Use the <kbd>debug</kbd> option and file a bug report if these
  *         exceptions occur.
  *
  * @throws Crypt_GPG_UnsupportedException if the provided binary is not
  *         GnuPG or if the GnuPG version is less than 1.0.2.
  */
 public function getVersion()
 {
     if ($this->_version == '') {
         $options = array('homedir' => $this->_homedir, 'binary' => $this->_binary, 'debug' => $this->_debug);
         $engine = new self($options);
         $info = '';
         // Set a garbage version so we do not end up looking up the version
         // recursively.
         $engine->_version = '1.0.0';
         $engine->reset();
         $engine->setOutput($info);
         $engine->setOperation('--version');
         $engine->run();
         $code = $this->getErrorCode();
         if ($code !== Crypt_GPG::ERROR_NONE) {
             throw new Crypt_GPG_Exception('Unknown error getting GnuPG version information. Please ' . 'use the \'debug\' option when creating the Crypt_GPG ' . 'object, and file a bug report at ' . Crypt_GPG::BUG_URI, $code);
         }
         $matches = array();
         $expression = '/gpg \\(GnuPG\\) (\\S+)/';
         if (preg_match($expression, $info, $matches) === 1) {
             $this->_version = $matches[1];
         } else {
             throw new Crypt_GPG_Exception('No GnuPG version information provided by the binary "' . $this->_binary . '". Are you sure it is GnuPG?');
         }
         if (version_compare($this->_version, self::MIN_VERSION, 'lt')) {
             throw new Crypt_GPG_Exception('The version of GnuPG being used (' . $this->_version . ') is not supported by Crypt_GPG. The minimum version ' . 'required by Crypt_GPG is ' . self::MIN_VERSION);
         }
     }
     return $this->_version;
 }
Example #4
0
 static function fromSlice(array $tokens) : self
 {
     $ts = new self();
     $ts->first = new NodeStart();
     $ts->last = new NodeEnd();
     self::link($ts->first, $ts->last);
     foreach ($tokens as $token) {
         $ts->push($token);
     }
     $ts->reset();
     return $ts;
 }
Example #5
0
 /**
  * Replaces some BBcode with HTML code
  *
  * NOTE: $text should be already escaped for HTML
  *
  * @param string $text html escaped input text
  * @param array $disabledTags
  */
 static function parse($text, $disabledTags = array())
 {
     static $parser = null;
     if ($parser === null) {
         $parser = new self(self::$ig);
     }
     $parser->reset();
     self::$disabledTags = $disabledTags;
     return $parser->bbcode($text);
 }
Example #6
0
 /**
  * Create a new email ready to send.
  * @return module_email
  */
 public static function &new_email()
 {
     $email = new self();
     $email->reset();
     return $email;
 }