/** * Removes the base path of the URL to HTML resources * * @param string $html * @return string|bool If error, then output FALSE */ protected function deleteBasePathUrl($html) { //$domHtml $str_begin = '<?xml version="1.0" encoding="utf-8"?>' . "\n" . '<body>'; $str_end = '</body>'; //--------------------------- $filtrHtmlEntities = new Default_Form_Filter_HtmlEntities(); $html = $filtrHtmlEntities->filter($html); $html = $str_begin . $html . $str_end; // Check for correct XML $domDoc = new DOMDocument('1.0', 'utf-8'); $success = $domDoc->loadXML($html); if (!$success) { return FALSE; } // Correct code $domQuery = new Zend_Dom_Query(); $domQuery->setDocumentXml($html, "utf-8"); foreach (self::$tags as $tag => $attr) { $results = $domQuery->query($tag); if ($results->count()) { foreach ($results as $result) { // $result variable is of DOMElement type if ($result->hasAttribute($attr)) { $value = $result->getAttribute($attr); $st = new Default_Plugin_String($value); if ($st->beginsWith('/')) { // it was: /zf-myblog/public/pic/1.gif // it is: /pic/1.gif $baseURL = Default_Plugin_SysBox::getBaseURL(); $value = str_replace($baseURL, '', $value); $result->setAttribute($attr, $value); } else { // it was: https://mysite.com:8080/zf-myblog/public/pic/1.gif // it is: /pic/1.gif $hostPortBaseURL = Default_Plugin_SysBox::getHostPortBaseURL(); $value = str_replace($hostPortBaseURL, '', $value); $result->setAttribute($attr, $value); } } } $domDoc = $results->getDocument(); $html = $domDoc->saveXml(); $domQuery->setDocumentXml($html, "utf-8"); } } $html = str_replace($str_begin, '', $html); $html = str_replace($str_end, '', $html); return $html; }
/** * Initialization form */ public function init() { parent::init(); //---------------- Форма ---------------- // Указываем action формы $urlAction = $this->getUrl('register', 'account'); $this->setAction($urlAction); // Указываем метод формы $this->setMethod('post'); // Задаем атрибут class для формы //$this->setAttrib('class', 'register'); $this->setAttrib('class', 'myfrm span5'); $this->setAttrib('id', 'registration-form'); //---------------- Username ---------------- // Text элемент "Имя входа пользователя". Проверяется на алфавитные символы и цифры, а также на длину // Валидатор Alnum использует установленную локаль для определения алфавита символов. $username = new Zend_Form_Element_Text('username', array('required' => true, 'label' => $this->Translate('Имя входа пользователя') . ' (Login)', 'maxlength' => '30', 'validators' => array(array('Alnum', true, array(true)), array('UserName'), array('NoDbRecordExists', true, array('users', 'username'))), 'filters' => array('StringTrim'))); $this->addElement($username); //---------------- Email ---------------- // Используемый собственный элемент App_Form_Element_Email $email = new Default_Form_Element_Email('email', array('required' => true)); // Добавление элемента в форму $this->addElement($email); //---------------- First name user ---------------- // Text элемент "Имя пользователя". Проверяется на алфавитные символы и цифры, а также на длину // Валидатор Alnum использует установленную локаль для определения алфавита символов. $first_name = new Zend_Form_Element_Text('first_name', array('label' => 'Имя пользователя', 'maxlength' => '150', 'size' => '60', 'validators' => array(array('Alnum', true, array(true)), array('StringLength', true, array(0, 150))), 'filters' => array('StringTrim'))); $this->addElement($first_name); //---------------- Last name user ---------------- // Text элемент "Фамилия пользователя". Проверяется на алфавитные символы и цифры, а также на длину // Валидатор Alnum использует установленную локаль для определения алфавита символов. $last_name = new Zend_Form_Element_Text('last_name', array('label' => 'Фамилия пользователя', 'maxlength' => '150', 'size' => '60', 'validators' => array(array('Alnum', true, array(true)), array('StringLength', true, array(0, 150))), 'filters' => array('StringTrim'))); $this->addElement($last_name); //---------------- Captcha ---------------- // Элемент CAPTCHA, защита от спама $urlBase = Default_Plugin_SysBox::getBaseURL(); $captcha = new Zend_Form_Element_Captcha('captcha', array('label' => 'Введите символы', 'captcha' => array('captcha' => 'Image', 'wordLen' => 4, 'width' => 260, 'timeout' => 120, 'expiration' => 300, 'font' => APPLICATION_PUBLIC . '/fonts/arial.ttf', 'imgDir' => APPLICATION_PUBLIC . '/images/captcha/', 'imgUrl' => $urlBase . '/images/captcha/', 'gcFreq' => 5))); $this->addElement($captcha); //---------------- Submit ---------------- // Кнопка Submit $submit = new Zend_Form_Element_Submit('send', array('label' => 'Зарегистрироваться')); $submit->setAttrib('class', 'btn btn-primary'); // Перезаписываем декораторы, что-бы //перезаписать стандартный набор декораторов для кнопки 'submit' $submit->setDecorators(array('ViewHelper')); $this->addElement($submit); //---------------- Reset ---------------- // Кнопка Reset, возвращает форму в начальное состояние $reset = new Zend_Form_Element_Reset('reset', array('label' => 'Очистить')); $reset->setAttrib('class', 'btn'); // Перезаписываем декораторы, что-бы выставить две кнопки в ряд $reset->setDecorators(array('ViewHelper')); $this->addElement($reset); //---------------- Группа Авторизационные данные ---------------- // Группируем элементы // Группа полей связанных с авторизационными данными $this->addDisplayGroup(array('username', 'email'), 'authDataGroup', array('legend' => 'Авторизационные данные')); //---------------- Группа Личная информация ---------------- // Группа полей связанных с личной информацией $this->addDisplayGroup(array('first_name', 'last_name'), 'privateDataGroup', array('legend' => 'Личная информация')); //---------------- Группа Защита от спама ---------------- // Защита от спама $this->addDisplayGroup(array('captcha'), 'captchaGroup', array('legend' => 'Защита от спама')); //---------------- Группа полей кнопок ---------------- $this->addDisplayGroup(array('send', 'reset'), 'buttonsGroup'); }
/** * Get the URL to the image by its physical path and name of the user * * @param string $imagePath * @param string $username * @return string */ static function getImageURL($imagePath, $username = '', $isThumbnail = true) { if ($isThumbnail) { $imageURL = self::GetThumbnailURL($username); } else { $imageURL = self::GetUploadUrl($username); } $path_parts = pathinfo($imagePath); $imageURL = $imageURL . '/' . $path_parts['basename']; $baseURL = Default_Plugin_SysBox::getBaseURL(); if ($baseURL !== '/') { $imageURL = $baseURL . '/' . $imageURL; } return $imageURL; }