本文整理汇总了PHP中Zend类的典型用法代码示例。如果您正苦于以下问题:PHP Zend类的具体用法?PHP Zend怎么用?PHP Zend使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: regformAction
public function regformAction()
{
// show reg form
$view = Zend::registry("view");
$view->title = "User Registration";
print $view->render('user/regform.php');
}
示例2: addAdvancedRoute
public function addAdvancedRoute($name, $map, $params = array(), $reqs = array())
{
if (!class_exists('Custom_Controller_Router_AdvancedRoute')) {
Zend::loadClass('Custom_Controller_Router_AdvancedRoute');
}
$this->_routes[$name] = new Custom_Controller_Router_AdvancedRoute($map, $params, $reqs);
}
示例3: staticAuthenticate
/**
* Authenticates against the given parameters
*
* $options requires the following key-value pairs:
*
* 'filename' => path to digest authentication file
* 'realm' => digest authentication realm
* 'username' => digest authentication user
* 'password' => password for the user of the realm
*
* @param array $options
* @throws Zend_Auth_Digest_Exception
* @return Zend_Auth_Digest_Token
*/
public static function staticAuthenticate(array $options)
{
$optionsRequired = array('filename', 'realm', 'username', 'password');
foreach ($optionsRequired as $optionRequired) {
if (!isset($options[$optionRequired]) || !is_string($options[$optionRequired])) {
throw Zend::exception('Zend_Auth_Digest_Exception', "Option '{$optionRequired}' is required to be " . 'provided as a string');
}
}
if (false === ($fileHandle = @fopen($options['filename'], 'r'))) {
throw Zend::exception('Zend_Auth_Digest_Exception', "Cannot open '{$options['filename']}' for reading");
}
require_once 'Zend/Auth/Digest/Token.php';
$id = "{$options['username']}:{$options['realm']}";
$idLength = strlen($id);
$tokenValid = false;
$tokenIdentity = array('realm' => $options['realm'], 'username' => $options['username']);
while ($line = trim(fgets($fileHandle))) {
if (substr($line, 0, $idLength) === $id) {
if (substr($line, -32) === md5("{$options['username']}:{$options['realm']}:{$options['password']}")) {
$tokenValid = true;
$tokenMessage = null;
} else {
$tokenMessage = 'Password incorrect';
}
return new Zend_Auth_Digest_Token($tokenValid, $tokenIdentity, $tokenMessage);
}
}
$tokenMessage = "Username '{$options['username']}' and realm '{$options['realm']}' combination not found";
return new Zend_Auth_Digest_Token($tokenValid, $tokenIdentity, $tokenMessage);
}
示例4: loadTests
/**
* recurses through the Test subdir and includes classes in each test group subdir,
* then builds an array of classnames for the tests that will be run
*
*/
public function loadTests($test_path = NULL)
{
$this->resetStats();
if ($test_path === NULL) {
// this seems hackey. is it? dunno.
$test_path = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Security' . DIRECTORY_SEPARATOR . 'Test';
}
$test_root = dir($test_path);
while (false !== ($entry = $test_root->read())) {
if (is_dir($test_root->path . DIRECTORY_SEPARATOR . $entry) && !preg_match('|^\\.(.*)$|', $entry)) {
$test_dirs[] = $entry;
}
}
// include_once all files in each test dir
foreach ($test_dirs as $test_dir) {
$this_dir = dir($test_root->path . DIRECTORY_SEPARATOR . $test_dir);
while (false !== ($entry = $this_dir->read())) {
if (!is_dir($this_dir->path . DIRECTORY_SEPARATOR . $entry) && preg_match('/[A-Za-z]+\\.php/i', $entry)) {
$className = "Zend_Environment_Security_Test_" . $test_dir . "_" . basename($entry, '.php');
Zend::loadClass($className);
$classNames[] = $className;
}
}
}
$this->_tests_to_run = $classNames;
}
示例5: _disconnect
/**
* Disconnects from the peer, closes the socket.
*
* @return void
*/
protected function _disconnect()
{
if (!is_resource($this->_socket)) {
throw Zend::exception('Zend_TimeSync_ProtocolException', "could not close server connection from '{$this->_timeserver}' on port '{$this->_port}'");
}
@fclose($this->_socket);
$this->_socket = null;
}
示例6: autoload
public static function autoload($class)
{
try {
Zend::loadClass($class);
} catch (Zend_Exception $e) {
return false;
}
return true;
}
示例7: testException
public function testException()
{
$this->assertTrue(Zend::exception('Zend_Exception') instanceof Exception);
try {
$e = Zend::exception('Zend_FooBar_Baz', 'should fail');
$this->fail('invalid exception class should throw exception');
} catch (Exception $e) {
// success...
}
}
示例8: __set
/**
* @param string $var
* @param string $value
*/
protected function __set($var, $value)
{
switch ($var) {
case 'updatedMin':
case 'updatedMax':
throw Zend::exception('Zend_Gdata_Exception', "Parameter '{$var}' is not currently supported in Spreadsheets.");
break;
}
parent::__set($var, $value);
}
示例9: routeShutdown
public function routeShutdown($action)
{
$user = Zend::registry('user');
if ($user->getPermission($action->getControllerName(), $action->getActionName())) {
return $action;
} else {
$action->setControllerName('index');
$action->setActionName('unauthorized');
return $action;
}
}
示例10: __construct
function __construct($config = array())
{
// set a Zend_Db_Adapter connection
if (!empty($config['db'])) {
// convenience variable
$db = $config['db'];
// use an object from the registry?
if (is_string($db)) {
$db = Zend::registry($db);
}
// make sure it's a Zend_Db_Adapter
if (!$db instanceof Zend_Db_Adapter_Abstract) {
throw new Varien_Db_Tree_Exception('db object does not implement Zend_Db_Adapter_Abstract');
}
// save the connection
$this->_db = $db;
$conn = $this->_db->getConnection();
if ($conn instanceof PDO) {
$conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
} elseif ($conn instanceof mysqli) {
//TODO: ???
}
} else {
throw new Varien_Db_Tree_Exception('db object is not set in config');
}
if (!empty($config['table'])) {
$this->setTable($config['table']);
}
if (!empty($config['id'])) {
$this->setIdField($config['id']);
} else {
$this->setIdField('id');
}
if (!empty($config['left'])) {
$this->setLeftField($config['left']);
} else {
$this->setLeftField('left_key');
}
if (!empty($config['right'])) {
$this->setRightField($config['right']);
} else {
$this->setRightField('right_key');
}
if (!empty($config['level'])) {
$this->setLevelField($config['level']);
} else {
$this->setLevelField('level');
}
if (!empty($config['pid'])) {
$this->setPidField($config['pid']);
} else {
$this->setPidField('parent_id');
}
}
示例11: getDriver
public function getDriver()
{
// @todo: when the Mysqli adapter moves out of the incubator,
// the following trick to allow it to be loaded should be removed.
$incubator = dirname(dirname(dirname(dirname(dirname(__FILE__))))) . DIRECTORY_SEPARATOR . 'incubator' . DIRECTORY_SEPARATOR . 'library';
Zend::loadClass('Zend_Db_Adapter_Mysqli', $incubator);
// @todo: also load any auxiliary classes if necessary, e.g.:
// Zend_Db_Adapter_Mysqli_Exception
// Zend_Db_Statement_Mysqli
// Zend_Db_Statement_Mysqli_Exception
return 'Mysqli';
}
示例12: __construct
/**
* @param array $config
* @throws LocalizedException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function __construct($config = [])
{
// set a \Zend_Db_Adapter connection
if (!empty($config['db'])) {
// convenience variable
$connection = $config['db'];
// use an object from the registry?
if (is_string($connection)) {
$connection = \Zend::registry($connection);
}
// make sure it's a \Zend_Db_Adapter
if (!$connection instanceof \Zend_Db_Adapter_Abstract) {
throw new LocalizedException(new \Magento\Framework\Phrase('db object does not implement \\Zend_Db_Adapter_Abstract'));
}
// save the connection
$this->_db = $connection;
$conn = $this->_db->getConnection();
if ($conn instanceof \PDO) {
$conn->setAttribute(\PDO::ATTR_EMULATE_PREPARES, true);
}
} else {
throw new LocalizedException(new \Magento\Framework\Phrase('db object is not set in config'));
}
if (!empty($config['table'])) {
$this->setTable($config['table']);
}
if (!empty($config['id'])) {
$this->setIdField($config['id']);
} else {
$this->setIdField('id');
}
if (!empty($config['left'])) {
$this->setLeftField($config['left']);
} else {
$this->setLeftField('left_key');
}
if (!empty($config['right'])) {
$this->setRightField($config['right']);
} else {
$this->setRightField('right_key');
}
if (!empty($config['level'])) {
$this->setLevelField($config['level']);
} else {
$this->setLevelField('level');
}
if (!empty($config['pid'])) {
$this->setPidField($config['pid']);
} else {
$this->setPidField('parent_id');
}
}
示例13: setTimestamp
/**
* Sets a new timestamp
*
* @param $date mixed - OPTIONAL timestamp otherwise actual timestamp is used
* @return boolean
* @throws Zend_Date_Exception
*/
public function setTimestamp($date = false)
{
// no date value, take actual time
if ($date === false) {
$this->_unixtimestamp = time();
return true;
}
if (is_numeric($date)) {
$this->_unixtimestamp = $date;
return true;
}
throw Zend::exception('Zend_Date_Exception', '\'' . $date . '\' is no valid date');
}
示例14: autoload
public static function autoload($class)
{
try {
if (class_exists('Zend_Version')) {
Zend_Loader::loadClass($class);
} else {
Zend::loadClass($class);
}
} catch (Zend_Exception $e) {
return false;
}
return true;
}
示例15: nowaAction
/**
* Tworzy now� ankiet� i przekierowuje do akcji edytujAction
*/
public function nowaAction()
{
$post = new Zend_Filter_Input($_POST);
$user = Zend::registry('user');
$poll = new Ankiety();
$data = array('nazwa' => $post->getRaw('ankieta_nazwa'), 'opis' => $post->getRaw('ankieta_opis'), 'id_uzytkownik' => 1);
try {
$id = $poll->insert($data);
$this->_forward('ankieter', 'edytuj', array('ankieta' => $id));
} catch (Hamster_Validation_Exception $e) {
$this->_forward('ankieter', 'index', array('validationError' => $e->getMessage()));
}
}