Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
 /**
  * Initialize singleton instance.
  *
  * @param string $class OPTIONAL Subclass of Zend_Wildfire_Channel_HttpHeaders
  * @return Zend_Wildfire_Channel_HttpHeaders Returns the singleton Zend_Wildfire_Channel_HttpHeaders instance
  * @throws Zend_Wildfire_Exception
  */
 public static function init($class = null)
 {
     if (self::$_instance !== null) {
         require_once LIB_DIR . '/Zend/Wildfire/Exception.php';
         throw new Zend_Wildfire_Exception('Singleton instance of Zend_Wildfire_Channel_HttpHeaders already exists!');
     }
     if ($class !== null) {
         if (!is_string($class)) {
             require_once LIB_DIR . '/Zend/Wildfire/Exception.php';
             throw new Zend_Wildfire_Exception('Third argument is not a class string');
         }
         if (!class_exists($class)) {
             require_once LIB_DIR . '/Zend/Loader.php';
             Zend_Loader::loadClass($class);
         }
         self::$_instance = new $class();
         if (!self::$_instance instanceof Zend_Wildfire_Channel_HttpHeaders) {
             self::$_instance = null;
             require_once LIB_DIR . '/Zend/Wildfire/Exception.php';
             throw new Zend_Wildfire_Exception('Invalid class to third argument. Must be subclass of Zend_Wildfire_Channel_HttpHeaders.');
         }
     } else {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Ejemplo n.º 4
0
 /**
  * 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;
 }
Ejemplo n.º 5
0
 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');
     }
 }
Ejemplo n.º 6
0
 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);
     }
 }
Ejemplo n.º 7
0
 /**
  * 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;
 }
Ejemplo n.º 8
0
 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";
     }
 }
Ejemplo n.º 9
0
 /**
  * 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;
 }
Ejemplo n.º 10
0
 function init()
 {
     parent::init();
     $this->view->baseUrl = $this->_request->getBaseUrl();
     Zend_Loader::loadClass('Pages');
     Zend_Loader::loadClass('Produkty');
 }
Ejemplo n.º 11
0
 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);
     }
 }
Ejemplo n.º 12
0
 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();
 }
 /**
  * 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/');
 }
Ejemplo n.º 14
0
 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');
     }
 }
Ejemplo n.º 15
0
 public static function unserialize($cached)
 {
     if (isset($cached['_class']) && !class_exists($cached['_class'])) {
         \Zend_Loader::loadClass($cached['_class']);
     }
     return unserialize(gzuncompress($cached['content']));
 }
Ejemplo n.º 16
0
 /**
  * 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();
     }
 }
Ejemplo n.º 17
0
 protected function _traverseFolder($folderGuid, $sGuid, $level)
 {
     Zend_Loader::loadClass('Kutu_Core_Orm_Table_Folder');
     $tblFolder = new Kutu_Core_Orm_Table_Folder();
     $rowSet = $tblFolder->fetchChildren($folderGuid);
     $row = $tblFolder->find($folderGuid)->current();
     $sGuid = '';
     if (count($rowSet)) {
         $sGuid = '<li>' . "<a href='" . KUTU_ROOT_URL . "/pages/g/{$row->guid}/h/1'>" . $row->title . '</a><ul>';
     } else {
         $sGuid = '<li>' . "<a href='" . KUTU_ROOT_URL . "/pages/g/{$row->guid}/h/1'>" . $row->title . '</a>';
     }
     if (true) {
         //echo $level;
         foreach ($rowSet as $row) {
             //$sTab = '<ul>';
             //$sTab = '';
             //for($i=0;$i<$level;$i++)
             //$sTab .= '<li>';
             //$option = '<option value="'.$row->guid.'">'.$sTab.$row->title.'</option>';
             //$option = '"'.$row->guid.'" :'.'"'.$sTab.$row->title.'",';
             //$option = $sTab.$row->title;
             $sGuid .= $this->_traverseFolder($row->guid, '', $level + 1) . "";
             //$sGuid .= $sTab.$row->title . '|<br>'. $this->_traverseFolder($row->guid, '', $level+1);
         }
         if (count($rowSet)) {
             return $sGuid . '</ul></li>';
         } else {
             return $sGuid . '</li>';
         }
     }
 }
 function modificarAction()
 {
     $this->view->subtitle = "Modificar Configuración";
     $configuracion = new Configuracion();
     if ($this->_request->isPost()) {
         Zend_Loader::loadClass('Zend_Filter_StripTags');
         $filter = new Zend_Filter_StripTags();
         $id = (int) $this->_request->getPost('id');
         $sitio_color_fondo = trim($filter->filter($this->_request->getPost('sitio_color_fondo')));
         $sitio_color_cabezal = trim($filter->filter($this->_request->getPost('sitio_color_cabezal')));
         $sitio_color_pie = trim($filter->filter($this->_request->getPost('sitio_color_pie')));
         if ($id !== false) {
             $data = array('sitio_color_fondo' => $sitio_color_fondo, 'sitio_color_cabezal' => $sitio_color_cabezal, 'sitio_color_pie' => $sitio_color_pie, 'id_sitio' => $this->session->sitio->id);
             $where = 'id = ' . $id;
             $configuracion->update($data, $where);
             $this->_redirect('/admin/configuracion/');
             return;
         }
     } else {
         $id = (int) $this->_request->getParam('id', 0);
         if ($id > 0) {
             $this->view->configuracion = Configuracion::getConfiguracionSitio($id);
         }
     }
     $this->view->action = "modificar";
     $this->view->buttonText = "Modificar";
     $this->view->scriptJs = "mooRainbow";
 }
Ejemplo n.º 19
0
 /**
  * Get a TestUtil class for the current RDBMS brand.
  */
 protected function _setUpTestUtil()
 {
     $driver = $this->getDriver();
     $utilClass = "ZendX_Db_TestUtil_{$driver}";
     Zend_Loader::loadClass($utilClass);
     $this->_util = new $utilClass();
 }
Ejemplo n.º 20
0
 public static function getActions($filter = false, $module, $controller)
 {
     $controller = ucfirst($controller) . 'Controller.php';
     $loadFile = _BASE_PATH . 'application/modules/' . $module . '/controllers/' . $controller;
     if (Zend_Loader::isReadable($loadFile)) {
         /** @noinspection PhpIncludeInspection */
         include_once $loadFile;
     }
     if ($module == 'default') {
         $controller = substr($controller, 0, -4);
     } else {
         $controller = ucfirst($module) . '_' . substr($controller, 0, -4);
     }
     $res = array();
     try {
         $reflection = new ReflectionClass($controller);
         $methods = $reflection->getMethods(ReflectionMethod::IS_PUBLIC);
         foreach ($methods as $method) {
             $method = $method->name;
             if (false !== strpos($method, 'Action')) {
                 $name = str_replace('Action', '', $method);
                 $res[$name] = $name;
             }
         }
     } catch (ReflectionException $e) {
         //TODO $x = 1;
     }
     return $res;
 }
Ejemplo n.º 21
0
 /**
  * Prepares the environment before running a test.
  */
 protected function setUp()
 {
     parent::setUp();
     Zend_Loader::registerAutoload();
     // TODO Auto-generated UserServiceTest::setUp()
     $this->UserService = new App_UserService();
 }
Ejemplo n.º 22
0
    /**
     * Converts a DOMElement object into the specific class
     *
     * @throws Zend_InfoCard_Xml_Exception
     * @param DOMElement $e The DOMElement object to convert
     * @param string $classname The name of the class to convert it to (must inhert from Zend_InfoCard_Xml_Element)
     * @return Zend_InfoCard_Xml_Element a Xml Element object from the DOM element
     */
    static public function convertToObject(DOMElement $e, $classname)
    {
        if (!class_exists($classname)) {
            require_once 'Zend/Loader.php';
            Zend_Loader::loadClass($classname);
        }

        $reflection = new ReflectionClass($classname);

        if(!$reflection->isSubclassOf('Zend_InfoCard_Xml_Element')) {
            require_once 'Zend/InfoCard/Xml/Exception.php';
            throw new Zend_InfoCard_Xml_Exception("DOM element must be converted to an instance of Zend_InfoCard_Xml_Element");
        }

        $sxe = simplexml_import_dom($e, $classname);

        if(!($sxe instanceof Zend_InfoCard_Xml_Element)) {
            // Since we just checked to see if this was a subclass of Zend_infoCard_Xml_Element this shoudl never fail
            // @codeCoverageIgnoreStart
            require_once 'Zend/InfoCard/Xml/Exception.php';
            throw new Zend_InfoCard_Xml_Exception("Failed to convert between DOM and SimpleXML");
            // @codeCoverageIgnoreEnd
        }

        return $sxe;
    }
Ejemplo n.º 23
0
 /**
  * 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)
 {
     if ($file === null) {
         $file = array('type' => null, 'name' => $value);
     }
     // Is file readable ?
     //require_once 'Zend/Loader.php';
     if (!Zend_Loader::isReadable($value)) {
         return $this->_throw($file, self::NOT_READABLE);
     }
     $this->_type = $this->_detectMimeType($value);
     if (empty($this->_type) && $this->_headerCheck) {
         $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;
 }
Ejemplo n.º 24
0
 public function loginAction()
 {
     $this->view->status = "";
     if ($this->_request->isPost() && $this->_request->getPost('openid_action') == 'login' && $this->_request->getPost('openid_identifier', '') !== '' || $this->_request->isPost() && $this->_request->getPost('openid_mode') !== null || !$this->_request->isPost() && $this->_request->getQuery('openid_mode') != null) {
         // Begin If.
         Zend_Loader::loadClass('Zend_Auth_Adapter_OpenId');
         $auth = Zend_Auth::getInstance();
         $result = $auth->authenticate(new Zend_Auth_Adapter_OpenId($this->_request->getPost('openid_identifier')));
         if ($result->isValid()) {
             $user = User::find($result->getIdentity());
             if (!$user) {
                 $user = new User();
                 $user->setUid($result->getIdentity());
                 $this->getEntityManager()->persist($user);
             }
             $user->setLastLogin();
             $this->getEntityManager()->flush();
             $this->_redirect('admin/index');
         } else {
             $auth->clearIdentity();
             foreach ($result->getMessages() as $message) {
                 $this->view->status .= "{$message}<br>\n";
             }
         }
     }
     $this->render();
 }
Ejemplo n.º 25
0
 /**
  * Defined by Zend_Validate_Interface
  *
  * Returns true if and only if the fileextension of $value is not included in the
  * set extension list
  *
  * @param  string  $value Real file to check for extension
  * @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_FOUND);
     }
     if ($file !== null) {
         $info['extension'] = substr($file['name'], strrpos($file['name'], '.') + 1);
     } else {
         $info = pathinfo($value);
     }
     $extensions = $this->getExtension();
     if ($this->_case and !in_array($info['extension'], $extensions)) {
         return true;
     } else {
         if (!$this->_case) {
             $found = false;
             foreach ($extensions as $extension) {
                 if (strtolower($extension) == strtolower($info['extension'])) {
                     $found = true;
                 }
             }
             if (!$found) {
                 return true;
             }
         }
     }
     return $this->_throw($file, self::FALSE_EXTENSION);
 }
Ejemplo n.º 26
0
 /**
  * Get view instance
  *
  * @access public
  * @return Zend_View
  */
 public function getView()
 {
     if (!isset($this->_config)) {
         throw new Gene_View_Exception('Configs does not set.');
     }
     if (!isset($this->_config['className'])) {
         throw new Gene_View_Exception('Invaild class name.');
     }
     $encode = 'UTF-8';
     if (isset($this->_config['encoding'])) {
         $encode = $this->_config['encoding'];
     }
     if (!class_exists($this->_config['className'])) {
         Zend_Loader::loadClass($this->_config['className']);
     }
     $streamWrapperFlag = false;
     if (isset($this->_config['streamWrapperFlag'])) {
         if (strtolower($this->_config['streamWrapperFlag']) === 'on') {
             $streamWrapperFlag = $this->_config['streamWrapperFlag'];
         }
     }
     $class = $this->_config['className'];
     $view = new $class();
     $view->setEncoding($encode)->setUseStreamWrapper($streamWrapperFlag);
     return $view;
 }
Ejemplo n.º 27
0
 protected function _initView()
 {
     // Start initail view
     $this->bootstrap('layout');
     $config = $this->getOption('views');
     $resources = $this->getOption('resources');
     $view = new Zend_View();
     if (isset($resources['layout']['layoutPath'])) {
         $view->assign('layoutRootPath', $resources['layout']['layoutPath']);
     }
     $this->bootstrap('db');
     Zend_Loader::loadClass('Ht_Utils_SystemSetting');
     $sysSetting = Ht_Utils_SystemSetting::getSettings();
     $view->assign('sysSetting', $sysSetting);
     $view->assign('profile', Zend_Auth::getInstance()->getIdentity());
     Zend_Loader::loadClass("Ht_Model_SystemSetting");
     $this->setSystemLogConfiguration($sysSetting);
     // use the viewrenderer to keep the code DRY
     // instantiate and add the helper in one go
     $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
     $viewRenderer->setView($view);
     $viewRenderer->setViewSuffix('phtml');
     // add it to the action helper broker
     Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
     /**
      * Set inflector for Zend_Layout
      */
     $inflector = new Zend_Filter_Inflector(':script.:suffix');
     $inflector->addRules(array(':script' => array('Word_CamelCaseToDash', 'StringToLower'), 'suffix' => 'phtml'));
     // Initialise Zend_Layout's MVC helpers
     $this->getResource('layout')->setLayoutPath(realpath($resources['layout']['layoutPath']))->setView($view)->setContentKey('content')->setInflector($inflector);
     return $this->getResource('layout')->getView();
 }
 /**
  * Método construtor da classe
  */
 public function init()
 {
     parent::init();
     $oEntityManager = Zend_Registry::get('em');
     $this->oConexao = $oEntityManager->getConnection();
     Zend_Loader::loadClass('Fpdf2File', APPLICATION_PATH . '/../library/FPDF/');
 }
Ejemplo n.º 29
0
 function init()
 {
     $this->view->baseUrl = $this->_request->getBaseUrl();
     Zend_Loader::loadClass('Utilisateur');
     Zend_Loader::loadClass('Avatar');
     Zend_Loader::loadClass('Classe');
     Zend_Loader::loadClass('Case_');
     Zend_Loader::loadClass('Competence');
     Zend_Loader::loadClass('Zone');
     Zend_Loader::loadClass('Equipement');
     Zend_Loader::loadClass('EquipementArme');
     Zend_Loader::loadClass('EquipementArmure');
     Zend_Loader::loadClass('Objet');
     Zend_Loader::loadClass('ObjetMonstre');
     Zend_Loader::loadClass('ZoneMonstre');
     Zend_Loader::loadClass('Monstre');
     Zend_Loader::loadClass('LigneInventaire');
     Zend_Loader::loadClass('ObjetSoin');
     Zend_Loader::loadClass('Niveau');
     Zend_Loader::loadClass('Pnj');
     Zend_Loader::loadClass('Instructeur');
     Zend_Loader::loadClass('Marchand');
     Zend_Loader::loadClass('Ville');
     $this->view->user = Zend_Auth::getInstance()->getIdentity();
 }
Ejemplo n.º 30
-1
 /**
  * Factory method to return a preconfigured Zend_Service_StrikeIron_*
  * instance.
  *
  * @param  null|string  $options  Service options
  * @return object       Zend_Service_StrikeIron_* instance
  * @throws Zend_Service_StrikeIron_Exception
  */
 public function getService($options = array())
 {
     $class = isset($options['class']) ? $options['class'] : 'Base';
     unset($options['class']);
     if (strpos($class, '_') === false) {
         $class = "Zend_Service_StrikeIron_{$class}";
     }
     try {
         if (!class_exists($class)) {
             // require_once 'Zend/Loader.php';
             @Zend_Loader::loadClass($class);
         }
         if (!class_exists($class, false)) {
             throw new Exception('Class file not found');
         }
     } catch (Exception $e) {
         $msg = "Service '{$class}' could not be loaded: " . $e->getMessage();
         /**
          * @see Zend_Service_StrikeIron_Exception
          */
         // require_once 'Zend/Service/StrikeIron/Exception.php';
         throw new Zend_Service_StrikeIron_Exception($msg, $e->getCode(), $e);
     }
     // instantiate and return the service
     $service = new $class(array_merge($this->_options, $options));
     return $service;
 }