Esempio n. 1
0
 function executeSaveSubscribe()
 {
     $request = $this->getRequest();
     if (!$request->isXmlHttpRequest()) {
         return $this->redirect404();
     }
     try {
         $email = $request->getRequestParameter('email', 'string');
         $iSubscribe = SubscribeManager::getInstance()->cloneRootInstance();
         $m['email'] = $email;
         $m['is_active'] = 1;
         $iSubscribe->updateFromRequest($m);
         if (!$iSubscribe->isValid()) {
             throw new EUserMessageError(fvLang::getInstance()->error_to_send, $iSubscribe, "sub_");
         }
         if (!$iSubscribe->save()) {
             throw new EUserMessageError(fvLang::getInstance()->error_to_send, $iSubscribe, "sub_");
         }
         $this->setHeader('message', json_encode(fvLang::getInstance()->succesfully_sended));
     } catch (EUserMessageError $exc) {
         $this->setHeader('exception', json_encode($exc->getMessage()));
         $this->setHeader('validation', json_encode($exc->getValidationResult()));
     }
     return self::$FV_AJAX_CALL;
 }
Esempio n. 2
0
 public function validateName($value)
 {
     $value = mysql_real_escape_string($value);
     $valid = $this->doValidateEmpty($value);
     $this->setValidationResult("name", $valid, fvLang::getInstance()->form_invalid_notempty);
     return $valid;
 }
Esempio n. 3
0
 function showIndex()
 {
     $captcha = fvCaptcha::getInstance()->generate();
     $this->__assign("captcha", $captcha);
     $this->__assign("lang", fvLang::getInstance());
     return $this->__display("index.tpl");
 }
Esempio n. 4
0
 function executeSave()
 {
     $data = $this->getRequest()->getRequestParameter("m", "array", array());
     $captcha = $this->getRequest()->getRequestParameter("captcha", "array", array());
     $lang = fvLang::getInstance();
     try {
         $ex = FeedbackManager::getInstance()->cloneRootInstance();
         $ex->updateFromRequest($data);
         if (!$ex->isValid($ex)) {
             /*$fields = "\"".implode("\", \"", array_keys($ex->getValidationResult()) )."\"";*/
             throw new EUserMessageError($lang->feedback_valid_error, $ex);
         }
         if (!fvCaptcha::getInstance()->check($captcha['fileName'], $captcha['text'])) {
             throw new EUserMessageError($lang->feedback_invalid_captcha);
         }
         if (!$ex->save()) {
             throw new EUserMessageError($lang->form_save_error, $ex);
         }
     } catch (EUserMessageError $exc) {
         $fieldsArr = array();
         foreach ((array) $exc->getValidationResult() as $field => $val) {
             $fieldsArr[] = "\"" . $lang->__get("form_label_{$field}") . "\"";
         }
         $fields = implode(", ", $fieldsArr);
         $errMessage = preg_replace("#%fields%#si", $fields, $exc->getMessage());
         fvResponce::getInstance()->setHeader('exception', json_encode($errMessage));
         $captcha = fvCaptcha::getInstance()->generate();
         fvResponce::getInstance()->setHeader('captcha', json_encode($captcha->render()));
         fvResponce::getInstance()->setHeader('validation', json_encode($exc->getValidationResult()));
         return self::$FV_AJAX_CALL;
     }
     fvResponce::getInstance()->setHeader('message', json_encode($lang->feedback_success));
     return self::$FV_AJAX_CALL;
 }
Esempio n. 5
0
 function showIndex()
 {
     $this->__assign("langKeys", fvLang::getInstance()->getLangs());
     $this->__assign("langs", fvSite::$fvConfig->get('languages'));
     $this->__assign("keys", fvLang::getInstance()->getKeys());
     $this->__assign("tranliterate", fvLang::getInstance()->getTransliterate());
     return $this->__display("index.tpl");
 }
Esempio n. 6
0
 function executeSave()
 {
     $m = $this->getRequest()->getRequestParameter('m', 'array');
     $result = fvLang::getInstance()->saveConfig($m);
     if ($result) {
         $this->setFlash('Данные успешно сохранены', self::$FLASH_SUCCESS);
     } else {
         $this->setFlash('Ошибка при сохранении данных', self::$FLASH_ERROR);
     }
     return $this->getRequest()->isXmlHttpRequest() ? self::$FV_AJAX_CALL : self::$FV_OK;
 }
/**
 * Smarty {localization} function plugin
 *
 * Type:     function<br>
 * Name:     localization<br>
 * Input:<br>
 *           - object       (required) - object model
 *           - langs       (required) - array langs
 *           - name       (required) - string - value for send name
 * @author Nesterenko Nikita
 * @since 2011/04/20
 * @param array $params, object $smarty
 * @returns lang-compiled html data
 * Назначение: преобразует объект в локализированные данные для редактирования
 */
function smarty_function_localization($params, &$smarty)
{
    $object = $params['object'];
    $langs = $params['langs'];
    $name = $params['name'];
    if (!$object) {
        if (!$box) {
            $smarty->_trigger_fatal_error("Attribute 'object' doesn't exist");
        }
    }
    if (!is_array($langs)) {
        if (!$box) {
            $smarty->_trigger_fatal_error("Attribute 'langs' not array");
        }
    }
    if (!$name) {
        if (!$name) {
            $smarty->_trigger_fatal_error("Attribute 'name' doesn't exist");
        }
    }
    $fieldList = $object->getLangFields(true);
    $out = '';
    $langNames = fvSite::$fvConfig->get('languages');
    foreach ($langs as $lang) {
        $out .= '<div id="tabs-item-' . $lang . '">';
        foreach ($fieldList as $nameField => $params) {
            $langField = $nameField . "_" . $lang;
            if (!isset($params['field'])) {
                $params['field'] = "input";
            }
            if ($params['field'] == 'input') {
                $out .= '<div class="field">';
                $out .= '<label>' . fvLang::getInstance()->{$nameField} . '</label>';
                $out .= createInputElement($langField, $name, $object->{$langField}, $params);
                $out .= '</div>';
            }
            if ($params['field'] == 'textarea') {
                $out .= '<div class="field">';
                $out .= '<label>' . fvLang::getInstance()->{$nameField} . '</label>';
                $out .= createTextAreaElement($langField, $name, $object->{$langField}, $params);
                $out .= '</div>';
            }
            if ($params['field'] == 'redactor') {
                $out .= '<div class="field">';
                $out .= '<label>' . fvLang::getInstance()->{$nameField} . '</label><div>';
                $out .= createRedactorElement($langField, $name, $object->{$langField}, $params, $smarty);
                $out .= '</div></div>';
            }
        }
        $out .= '</div>';
    }
    return $out;
}
 function __construct()
 {
     $currentUrl = fvRoute::getInstance()->getModuleName();
     list($p) = (array) PageManager::getInstance()->getByPageUrl($currentUrl);
     if (is_object($p)) {
         $this->_pageInstance = $p;
     } else {
         fvDispatcher::redirect(fvSite::$fvConfig->get('page_404', 0, 404));
     }
     $this->_domInstance = new DOMDocument();
     if (!$this->_domInstance->loadXML($this->_pageInstance->getPageContent())) {
         fvDispatcher::redirect(fvSite::$fvConfig->get('page_error', 0, 302));
     }
     $this->setMeta($this->_pageInstance->getMeta());
     fvSite::$Template->assign("Lang", fvLang::getInstance());
     parent::__construct("main.tpl");
 }
 public function __construct()
 {
     fvSite::$Template->assign("Lang", fvLang::getInstance());
     parent::__construct("main.tpl");
 }
 public function getAllLang()
 {
     $args = current((array) func_get_args());
     $where = $order = $limit = "";
     $params = array();
     if (!empty($args[0])) {
         $where = "WHERE (" . $args[0] . ")";
     }
     if (!empty($args[1])) {
         $order = "ORDER BY " . $args[1] . "";
     }
     if (!empty($args[2])) {
         $limit = explode(',', $args[2]);
     }
     if (isset($args[3])) {
         $params = is_array(@$args[3]) ? @$args[3] : array(@$args[3]);
     }
     $langs = fvLang::getInstance()->getLangs();
     $fields = array();
     foreach ($langs as $lang_key) {
         foreach ($this->rootObj->getLangFields() as $lField) {
             $fields[] = "t_{$lang_key}.{$lField} as {$lField}_{$lang_key}";
         }
     }
     $fields = count($fields) ? "," . implode(",", $fields) : "";
     $query = "SELECT t1.* {$fields} FROM " . $this->rootObj->getTableName() . " as t1";
     foreach ($langs as $lang_key) {
         $query .= " LEFT JOIN  " . $this->rootObj->getTableName() . "_" . $lang_key . " as t_{$lang_key} ON t_{$lang_key}.id = t1.id";
     }
     $query .= " {$where} {$order}";
     if (is_array($limit) && count($limit) == 2) {
         $res = fvSite::$DB->limitQuery($query, $limit[0], $limit[1], $params);
     } else {
         $res = fvSite::$DB->query($query, $params);
     }
     $result = array();
     if (!DB::isError($res)) {
         while ($row = $res->fetchRow()) {
             $o = clone $this->rootObj;
             $o->hydrate($row);
             $result[] = $o;
         }
     }
     return $result;
 }
Esempio n. 11
0
 public function getLang($field, $lang = false)
 {
     $lang = $lang ? $lang : fvLang::getInstance()->getCurLang();
     $default = fvLang::getInstance()->getDefaultLang();
     $translate = strlen($this->get($field . "_" . $lang)) ? $this->get($field . "_" . $lang) : $this->get($field . "_" . $default);
     return $translate;
 }