本文整理汇总了PHP中Zend_Loader类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Loader类的具体用法?PHP Zend_Loader怎么用?PHP Zend_Loader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Loader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getView
/**
* Get view
*
* @param Zend_Config $config
* @return Zend_View_Interface
*/
public function getView(Zend_Config $config)
{
if (!($view = $this->getCache('view'))) {
$isUseViewRenderer = !Zend_Controller_Front::getInstance()->getParam('noViewRenderer');
$viewRenderer = $isUseViewRenderer ? Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer') : null;
// Use view from view renderer if possible
if ($isUseViewRenderer && $viewRenderer->view instanceof Zend_View_Interface) {
$view = $viewRenderer->view;
} else {
$viewClass = $config->get('class');
Zend_Loader::loadClass($viewClass);
$view = new $viewClass();
// Validate object
if (!$view instanceof Zend_View_Interface) {
/**
* @see Zym_App_Resource_View_Exception
*/
require_once 'Zym/App/Resource/View/Exception.php';
throw new Zym_App_Resource_View_Exception(sprintf('View object must be an instance of Zend_View_Interface an object of %s', get_class($view)));
}
}
// Setup
$this->_setupView($view, $config);
// Save
$this->saveCache($view, 'view');
}
return $view;
}
示例2: connectToGoogleViaZend
private function connectToGoogleViaZend()
{
set_include_path($this->root_directory . "modules/Calendar4You/");
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_AuthSub');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Calendar');
if ($this->user_login != "" && $this->user_password != "") {
try {
$service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
$this->gClient = Zend_Gdata_ClientLogin::getHttpClient($this->user_login, $this->user_password, $service);
$this->status = $this->mod_strings["LBL_OK"];
$this->is_logged = true;
} catch (Zend_Gdata_App_CaptchaRequiredException $cre) {
$this->status = $this->mod_strings["LBL_URL_CAPTCHA_IMAGE"] . ': ' . $cre->getCaptchaUrl() . ', ' . $this->mod_strings["LBL_TOKEN_ID"] . ': ' . $cre->getCaptchaToken();
} catch (Zend_Gdata_App_AuthException $ae) {
$this->status = $this->mod_strings["LBL_AUTH_PROBLEM"] . ': ' . $ae->exception() . "\n";
}
} else {
$this->status = $this->mod_strings["LBL_MISSING_AUTH_DATA"];
}
if ($this->is_logged) {
$this->gService = new Zend_Gdata_Calendar($this->gClient);
try {
$this->gListFeed = $this->gService->getCalendarListFeed();
} catch (Zend_Gdata_App_Exception $e) {
$this->gListFeed = array();
}
}
set_include_path($this->root_directory);
}
示例3: isValid
/**
* Defined by Zend_Validate_Interface
*
* Returns true if the mimetype of the file does not matche the given ones. Also parts
* of mimetypes can be checked. If you give for example "image" all image
* mime types will not be accepted like "image/gif", "image/jpeg" and so on.
*
* @param string $value Real file to check for mimetype
* @param array $file File data from Zend_File_Transfer
* @return boolean
*/
public function isValid($value, $file = null)
{
// Is file readable ?
require_once 'Zend/Loader.php';
if (!Zend_Loader::isReadable($value)) {
return $this->_throw($file, self::NOT_READABLE);
}
if ($file !== null) {
if (class_exists('finfo', false) && defined('MAGIC')) {
$mime = new finfo(FILEINFO_MIME);
$this->_type = $mime->file($value);
unset($mime);
} elseif (function_exists('mime_content_type') && ini_get('mime_magic.magicfile')) {
$this->_type = mime_content_type($value);
} else {
$this->_type = $file['type'];
}
}
if (empty($this->_type)) {
return $this->_throw($file, self::NOT_DETECTED);
}
$mimetype = $this->getMimeType(true);
if (in_array($this->_type, $mimetype)) {
return $this->_throw($file, self::FALSE_TYPE);
}
$types = explode('/', $this->_type);
$types = array_merge($types, explode('-', $this->_type));
foreach ($mimetype as $mime) {
if (in_array($mime, $types)) {
return $this->_throw($file, self::FALSE_TYPE);
}
}
return true;
}
示例4: setUp
public function setUp()
{
if (!class_exists('Archive_Tar')) {
// require_once 'Zend/Loader.php';
try {
Zend_Loader::loadClass('Archive_Tar');
} catch (Zend_Exception $e) {
$this->markTestSkipped('This filter needs PEARs Archive_Tar');
}
}
$files = array(dirname(__FILE__) . '/../_files/zipextracted.txt', dirname(__FILE__) . '/../_files/_compress/Compress/First/Second/zipextracted.txt', dirname(__FILE__) . '/../_files/_compress/Compress/First/Second', dirname(__FILE__) . '/../_files/_compress/Compress/First/zipextracted.txt', dirname(__FILE__) . '/../_files/_compress/Compress/First', dirname(__FILE__) . '/../_files/_compress/Compress/zipextracted.txt', dirname(__FILE__) . '/../_files/_compress/Compress', dirname(__FILE__) . '/../_files/_compress/zipextracted.txt', dirname(__FILE__) . '/../_files/_compress', dirname(__FILE__) . '/../_files/compressed.tar');
foreach ($files as $file) {
if (file_exists($file)) {
if (is_dir($file)) {
rmdir($file);
} else {
unlink($file);
}
}
}
if (!file_exists(dirname(__FILE__) . '/../_files/Compress/First/Second')) {
mkdir(dirname(__FILE__) . '/../_files/Compress/First/Second', 0777, true);
file_put_contents(dirname(__FILE__) . '/../_files/Compress/First/Second/zipextracted.txt', 'compress me');
file_put_contents(dirname(__FILE__) . '/../_files/Compress/First/zipextracted.txt', 'compress me');
file_put_contents(dirname(__FILE__) . '/../_files/Compress/zipextracted.txt', 'compress me');
}
}
示例5: fetchTable
public function fetchTable($table_name, $where = false, $parameters = array())
{
$range = isset($parameters['range']) && !empty($parameters['range']) ? $parameters['range'] : " * ";
$sortColumn = isset($parameters['sortColumn']) && !empty($parameters['sortColumn']) ? $parameters['sortColumn'] : false;
$sortType = isset($parameters['sortType']) && !empty($parameters['sortType']) ? $parameters['sortType'] : "ASC";
$limitOffset = isset($parameters['limitOffset']) && !empty($parameters['limitOffset']) ? $parameters['limitOffset'] : false;
$rowCount = isset($parameters['rowCount']) && !empty($parameters['rowCount']) ? $parameters['rowCount'] : false;
$queryString = "SELECT {$range} FROM {$table_name} ";
if ($where !== false) {
$queryString .= " WHERE " . $where;
}
if ($sortColumn !== false) {
$queryString .= " ORDER BY {$sortColumn} {$sortType} ";
}
if ($rowCount !== false) {
$queryString .= " LIMIT ";
if ($limitOffset !== false) {
$queryString .= " {$limitOffset}, ";
}
$queryString .= " {$rowCount} ";
}
$db = $this->_db->query($queryString);
$dataFetch = $db->fetchAll(Zend_Db::FETCH_ASSOC);
$data = array('table' => $this, 'data' => $dataFetch, 'rowClass' => $this->_rowClass, 'stored' => true);
Zend_Loader::loadClass($this->_rowsetClass);
if (count($dataFetch) < 1) {
return false;
} else {
return new $this->_rowsetClass($data);
}
}
示例6: setAdapter
/**
* Sets new encryption options
*
* @param string|array $options (Optional) Encryption options
* @return Zend_Filter_Encrypt
*/
public function setAdapter($options = null)
{
if (is_string($options)) {
$adapter = $options;
} else {
if (isset($options['adapter'])) {
$adapter = $options['adapter'];
unset($options['adapter']);
} else {
$adapter = 'Mcrypt';
}
}
if (!is_array($options)) {
$options = array();
}
if (Zend_Loader::isReadable('Zend/Filter/Encrypt/' . ucfirst($adapter) . '.php')) {
$adapter = 'Zend_Filter_Encrypt_' . ucfirst($adapter);
}
Zend_Loader::loadClass($adapter);
$this->_adapter = new $adapter($options);
if (!$this->_adapter instanceof Zend_Filter_Encrypt_Interface) {
require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception("Encoding adapter '" . $adapter . "' does not implement Zend_Filter_Encrypt_Interface");
}
return $this;
}
示例7: newAction
public function newAction()
{
$this->view->message = "Nothing is saved";
$req = $this->getRequest();
$item = $req->getParam('guid');
$relatedItem = $req->getParam('relatedGuid');
$as = $req->getParam('relateAs');
Zend_Loader::loadClass('Kutu_Core_Orm_Table_Catalog');
$tblCatalog = new Kutu_Core_Orm_Table_Catalog();
if (empty($relatedItem)) {
$this->view->message = "No relatedGuid specified!";
}
//check if $guid is an array
if (is_array($item)) {
foreach ($item as $guid) {
echo "<br>" . $guid;
$rowCatalog = $tblCatalog->find($guid)->current();
echo $rowCatalog->guid;
$rowCatalog->relateTo($relatedItem, $as);
}
} else {
$rowCatalog = $tblCatalog->find($item)->current();
$rowCatalog->relateTo($relatedItem, $as);
$this->view->message = "Data was successfully saved";
}
}
示例8: 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_Loader::loadClass($className);
$classNames[] = $className;
}
}
}
$this->_tests_to_run = $classNames;
}
示例9: init
function init()
{
parent::init();
$this->view->baseUrl = $this->_request->getBaseUrl();
Zend_Loader::loadClass('Pages');
Zend_Loader::loadClass('Produkty');
}
示例10: init
public function init()
{
Zend_Loader::loadClass('Zend_Validate_Regex');
// translate
$this->translate = Zend_Registry::get('translate');
//Zend_Form::setDefaultTranslator( Zend_Registry::get('translate') );
// login attempt
$defNamespace = new Zend_Session_Namespace('Default');
$use_captcha = $defNamespace->numLoginFails >= self::MAX_LOGIN_ATTEMPT ? TRUE : FALSE;
$this->setMethod('post');
// username
$login = $this->createElement('text', 'login', array('decorators' => $this->elDecorators, 'required' => true, 'label' => $this->translate->_('Username'), 'size' => 25, 'maxlength' => 50));
$login->addDecorator('FormElements', array('tag' => 'div', 'style' => 'width:10em; background-color:#E0F0FF;'));
$login_validator = new Zend_Validate_Regex('/^[a-z0-9\\-_@\\.]+$/i');
$login_validator->setMessage($this->translate->_('Login characters incorrect. Allowed: alphabetical characters, digits, and "- . _ @" characters.'));
$login->addValidator($login_validator)->addValidator('stringLength', false, array(1, 50))->setRequired(true);
// password
$password = $this->createElement('password', 'pwd', array('decorators' => $this->elDecorators, 'required' => true, 'label' => $this->translate->_('Password'), 'size' => 25, 'maxlength' => 50));
$password->addValidator('StringLength', false, array(1, 50))->setRequired(true);
// remember me
$checkbox = $this->createElement('checkbox', 'rememberme', array('decorators' => $this->elDecorators, 'label' => $this->translate->_('Remember me'), 'checked' => 1));
// login
$submit = $this->createElement('submit', 'submit', array('decorators' => array('ViewHelper', 'Errors'), 'class' => 'login-btn', 'id' => 'submit', 'label' => $this->translate->_('Log In')));
// add elements to form
$this->addElement($login)->addElement($password)->addElement($checkbox)->addElement($submit);
if ($use_captcha) {
// create captcha
$captcha = $this->createElement('captcha', 'captcha', array('label' => $this->translate->_('Type the characters:'), 'captcha' => array('captcha' => 'Figlet', 'wordLen' => 3, 'timeout' => 120)));
// And finally add some CSRF protection
$csrf = $this->createElement('hash', 'csrf', array('ignore' => true));
// add captcha to form
$this->addElement($captcha)->addElement($csrf);
}
}
示例11: getById
function getById($jobid)
{
// do Bacula ACLs
Zend_Loader::loadClass('Job');
$table = new Job();
if (!$table->isJobIdExists($jobid)) {
return FALSE;
}
$select = new Zend_Db_Select($this->db);
switch ($this->db_adapter) {
case 'PDO_SQLITE':
// bug http://framework.zend.com/issues/browse/ZF-884
$select->distinct();
$select->from(array('l' => 'Log'), array('logid' => 'LogId', 'jobid' => 'JobId', 'LogTime' => 'Time', 'logtext' => 'LogText'));
$select->where("JobId = ?", $jobid);
$select->order(array('LogId', 'LogTime'));
break;
default:
// mysql, postgresql
$select->distinct();
$select->from(array('l' => 'Log'), array('LogId', 'JobId', 'LogTime' => 'Time', 'LogText'));
$select->where("JobId = ?", $jobid);
$select->order(array('LogId', 'LogTime'));
}
//$sql = $select->__toString(); echo "<pre>$sql</pre>"; exit; // for !!!debug!!!
$stmt = $select->query();
return $stmt->fetchAll();
}
示例12: init
/**
* Método Construtor
*
* @see Contribuinte_Lib_Controller_AbstractController::init()
*/
public function init()
{
parent::init();
// Carrega as classes para geração do PDF
Zend_Loader::loadClass('fpdf', APPLICATION_PATH . '/../library/FPDF/');
Zend_Loader::loadClass('Fpdf2File', APPLICATION_PATH . '/../library/FPDF/');
}
示例13: loginAction
function loginAction()
{
$this->view->message = '';
if ($this->_request->isPost()) {
Zend_Loader::loadClass('Zend_Filter_StripTags');
$f = new Zend_Filter_StripTags();
$username = $f->filter($this->_request->getPost('username'));
$password = md5($f->filter($this->_request->getPost('password')));
if (!empty($username)) {
Zend_Loader::loadClass('Zend_Auth_Adapter_DbTable');
$dbAdapter = Zend_Registry::get('dbAdapter');
$authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
$authAdapter->setTableName('utilisateur');
$authAdapter->setIdentityColumn('login_utilisateur');
$authAdapter->setCredentialColumn('pass_utilisateur');
$authAdapter->setIdentity($username);
$authAdapter->setCredential($password);
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($authAdapter);
if ($result->isValid()) {
$data = $authAdapter->getResultRowObject(null, 'password');
$auth->getStorage()->write($data);
$this->_redirect('/');
}
}
$this->_redirect('auth/loginfail');
}
}
示例14: unserialize
public static function unserialize($cached)
{
if (isset($cached['_class']) && !class_exists($cached['_class'])) {
\Zend_Loader::loadClass($cached['_class']);
}
return unserialize(gzuncompress($cached['content']));
}
示例15: setup
/**
* Setup db
*
*/
public function setup(Zend_Config $config)
{
$sessionConfig = $config->get('config');
$configArray = $sessionConfig->toArray();
// save_path handler
$configArray = $this->_prependSavePath($configArray);
// name handler
$configArray = $this->_parseName($configArray);
// Setup config
Zend_Session::setOptions($configArray);
// Setup save handling?
$saveHandlerConfig = $config->get('save_handler');
if ($className = $saveHandlerConfig->get('class_name')) {
if ($args = $saveHandlerConfig->get('constructor_args')) {
if ($args instanceof Zend_Config) {
$args = $args->toArray();
} else {
$args = (array) $args;
}
} else {
$args = array();
}
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($className);
$saveHandler = new ReflectionClass($className);
$saveHandler = $saveHandler->newInstanceArgs($args);
Zend_Session::setSaveHandler($saveHandler);
}
// Autostart session?
if ($config->get('auto_start')) {
// Start session
Zend_Session::start();
}
}