当前位置: 首页>>代码示例>>PHP>>正文


PHP df_translate函数代码示例

本文整理汇总了PHP中df_translate函数的典型用法代码示例。如果您正苦于以下问题:PHP df_translate函数的具体用法?PHP df_translate怎么用?PHP df_translate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了df_translate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _loadActionsINIFile

 function _loadActionsINIFile()
 {
     import('Dataface/ConfigTool.php');
     $configTool =& Dataface_ConfigTool::getInstance();
     $actions =& $configTool->loadConfig('actions', null);
     foreach (array_keys($actions) as $key) {
         $action =& $actions[$key];
         $action['name'] = $key;
         if (!isset($action['id'])) {
             $action['id'] = $action['name'];
         }
         if (!isset($action['label'])) {
             $action['label'] = str_replace('_', ' ', ucfirst($action['name']));
         }
         if (!isset($action['accessKey'])) {
             $action['accessKey'] = substr($action['name'], 0, 1);
         }
         //if ( !isset($action['label_i18n']) ) $action['label_i18n'] = 'action:'.$action['name'].' label';
         //if ( !isset($action['description_i18n'])) $action['description_i18n'] = 'action:'.$action['name'].' description';
         if (isset($action['description'])) {
             $action['description'] = df_translate('actions.' . $action['name'] . '.description', $action['description']);
         }
         if (isset($action['label'])) {
             $action['label'] = df_translate('actions.' . $action['name'] . '.label', $action['label']);
         }
         $this->actions[$key] =& $action;
         unset($action);
     }
     unset($temp);
     $this->actions =& $actions;
 }
开发者ID:promoso,项目名称:HVAC,代码行数:31,代码来源:ActionTool.php

示例2: intval

 function &pushValue(&$record, &$field, &$form, &$element, &$metaValues)
 {
     $table =& $record->_table;
     $formTool =& Dataface_FormTool::getInstance();
     $formFieldName = $element->getName();
     $val = $element->getValue();
     //print_r($val);exit;
     if (is_array($val)) {
         $val = $val[$field['name']];
     }
     if (preg_match('/int/', @$field['Type']) and $val !== '' and $val !== null) {
         //print_r($_POST);
         //echo "Val is $val";exit;
         $out = intval($val);
     } else {
         //echo "Out is $val";exit;
         $out = $val;
     }
     //$res =& $s->setValue($fieldname, $val);
     if (PEAR::isError($val)) {
         $val->addUserInfo(df_translate('scripts.Dataface.QuickForm.pushValue.ERROR_PUSHING_VALUE', "Error pushing value for field '{$field['name']}' in QuickForm::pushWidget() on line " . __LINE__ . " of file " . __FILE__, array('name' => $field['name'], 'file' => __FILE__, 'line' => __LINE__)));
         return $val;
     }
     return $out;
 }
开发者ID:Zunair,项目名称:xataface,代码行数:25,代码来源:radio.php

示例3: handle

 function handle(&$params)
 {
     $app =& Dataface_Application::getInstance();
     $query =& $app->getQuery();
     $this->table =& Dataface_Table::loadTable($query['-table']);
     $translations =& $this->table->getTranslations();
     foreach (array_keys($translations) as $trans) {
         $this->table->getTranslation($trans);
     }
     //print_r($translations);
     if (!isset($translations) || count($translations) < 2) {
         // there are no translations to be made
         trigger_error('Attempt to translate a record in a table "' . $this->table->tablename . '" that contains no translations.', E_USER_ERROR);
     }
     $this->translatableLanguages = array_keys($translations);
     $translatableLanguages =& $this->translatableLanguages;
     $this->languageCodes = new I18Nv2_Language($app->_conf['lang']);
     $languageCodes =& $this->languageCodes;
     $currentLanguage = $languageCodes->getName($app->_conf['lang']);
     if (count($translatableLanguages) < 2) {
         return PEAR::raiseError(df_translate('Not enough languages to translate', 'There aren\'t enough languages available to translate.'), DATAFACE_E_ERROR);
     }
     //$defaultSource = $translatableLanguages[0];
     //$defaultDest = $translatableLanguages[1];
     $options = array();
     foreach ($translatableLanguages as $lang) {
         $options[$lang] = $languageCodes->getName($lang);
     }
     unset($options[$app->_conf['default_language']]);
     $tt = new Dataface_TranslationTool();
     $form = new HTML_QuickForm('StatusForm', 'POST');
     $form->addElement('select', '--language', 'Translation', $options);
     $form->addElement('select', '--status', 'Status', $tt->translation_status_codes);
     //$form->setDefaults( array('-sourceLanguage'=>$defaultSource, '-destinationLanguage'=>$defaultDest));
     $form->addElement('submit', '--set_status', 'Set Status');
     foreach ($query as $key => $value) {
         $form->addElement('hidden', $key);
         $form->setDefaults(array($key => $value));
     }
     if ($form->validate()) {
         $res = $form->process(array(&$this, 'processForm'));
         if (PEAR::isError($res)) {
             return $res;
         } else {
             header('Location: ' . $app->url('-action=list&-sourceLanguage=&-destinationLanguage=&-translate=') . '&--msg=' . urlencode('Translation status successfully set.'));
             exit;
         }
     }
     ob_start();
     $form->display();
     $out = ob_get_contents();
     ob_end_clean();
     $records =& $this->getRecords();
     df_display(array('form' => $out, 'translationTool' => &$tt, 'records' => &$records, 'translations' => &$options, 'context' => &$this), 'Dataface_set_translation_status.html');
 }
开发者ID:promoso,项目名称:HVAC,代码行数:55,代码来源:set_translation_status.php

示例4: handle

 function handle($params)
 {
     $app = Dataface_Application::getInstance();
     $query = $app->getQuery();
     $record_id = @$_POST['--record_id'];
     try {
         if (!$record_id) {
             throw new Exception(df_translate('Bad Request', 'Bad Request.  Missing parameter.'), self::BAD_REQUEST);
         }
         $record = df_get_record_by_id($record_id);
         if (PEAR::isError($record)) {
             error_log($record->getMessage());
             throw new Exception(df_translate('Bad Request', 'Bad Request - invalid ID.'), self::BAD_REQUEST);
         }
         if (!$record) {
             throw new Exception(df_translate('No records matched request', 'No records matched the request'), self::NOT_FOUND);
         }
         if (!$record->checkPermission('delete')) {
             throw new Exception(df_translate('scripts.GLOBAL.MESSAGE.PERMISSION_DENIED', 'Permission Denied'), self::PERMISSION_DENIED);
         }
         $res = $record->delete(false);
         // We've already done a security check...
         if (PEAR::isError($res)) {
             error_log($res->getMessage());
             throw new Exception(df_translate('actions.rest_delete.messages.SERVER_ERROR', 'Failed to delete record due to a server error.  See error log for details.'), self::SERVER_ERROR);
         }
         $this->out(array('code' => 200, 'message' => df_translate('actions.rest_delete.messages.SUCCESS', 'Successfully deleted record.'), 'record_id' => $record->getId()));
         exit;
     } catch (Exception $ex) {
         switch ($ex->getCode()) {
             case self::PERMISSION_DENIED:
             case self::NOT_FOUND:
             case self::SERVER_ERROR:
                 $msg = $ex->getMessage();
                 $code = $ex->getCode();
                 break;
             default:
                 $msg = df_translate('actions.rest_delete.messages.SUCCESS', 'Successfully deleted record.');
                 $code = self::SERVER_ERROR;
                 error_log($ex->getMessage());
                 break;
         }
         $this->out(array('code' => $code, 'message' => $msg));
         exit;
     }
 }
开发者ID:minger11,项目名称:Pipeline,代码行数:46,代码来源:rest_delete.php

示例5: handle

 function handle($params)
 {
     if (!isset($params['action']['page'])) {
         trigger_error(df_translate('Page not specified', 'No page specified at ' . Dataface_Error::printStackTrace(), array('stack_trace' => Dataface_Error::printStackTrace())), E_USER_ERROR);
     } else {
         $page = $params['action']['page'];
     }
     $app =& Dataface_Application::getInstance();
     $pages = $app->getCustomPages();
     if (!isset($pages[$page])) {
         trigger_error(df_translate('Custom page not found', "Request for custom page '{$page}' failed because page does not exist in pages directory." . Dataface_Error::printStackTrace(), array('page' => $page, 'stack_trace' => Dataface_Error::printStackTrace())), E_USER_ERROR);
     }
     ob_start();
     include $pages[$page];
     $out = ob_get_contents();
     ob_end_clean();
     df_display(array('content' => $out), 'Dataface_Custom_Template.html');
     return true;
 }
开发者ID:promoso,项目名称:HVAC,代码行数:19,代码来源:custom.php

示例6: array

 /**
  * Loads a module and returns a reference to it.
  * @param string $name The name of the module's class.
  *
  */
 function &loadModule($name)
 {
     $app =& Dataface_Application::getInstance();
     if (isset($this->_modules[$name])) {
         return $this->_modules[$name];
     }
     if (class_exists($name)) {
         $this->_modules[$name] = new $name();
         return $this->_modules[$name];
     }
     if (!@$app->_conf['_modules'] or !is_array($app->_conf['_modules']) or !isset($app->_conf['_modules'][$name])) {
         return PEAR::raiseError(df_translate('scripts.Dataface.ModuleTool.loadModule.ERROR_MODULE_DOES_NOT_EXIST', "The module '{$name}' does not exist.", array('name' => $name)));
     }
     import($app->_conf['_modules'][$name]);
     if (!class_exists($name)) {
         return PEAR::raiseError(df_translate('scripts.Dataface.ModuleTool.loadModule.ERROR_CLASS_DOES_NOT_EXIST', "Attempted to load the module '{$name}' from path '{$app->_conf['_modules'][$name]}' but after loading - no such class was found.  Please check to make sure that the class is defined.  Or you can disable this module by commenting out the line that says '{$name}={$app->_conf['_modules'][$name]}' in the conf.ini file.", array('name' => $name, 'path' => $app->_conf['_modules'][$name])));
     }
     $this->_modules[$name] = new $name();
     return $this->_modules[$name];
 }
开发者ID:promoso,项目名称:HVAC,代码行数:25,代码来源:ModuleTool.php

示例7: handle

 function handle(&$params)
 {
     if (!$_POST) {
         return PEAR::raiseError("This method is only available via POST");
     }
     $app =& Dataface_Application::getInstance();
     $query =& $app->getQuery();
     $records = df_get_selected_records($query);
     $updated = 0;
     $errs = array();
     foreach ($records as $rec) {
         if (!$rec->checkPermission('delete')) {
             $errStr = df_translate("actions.delete_selected.permission_denied", "You do not have permission to delete '%s' because you do not have the 'delete' permission.");
             $errs[] = sprintf($errStr, $rec->getTitle());
             continue;
         }
         $res = $rec->delete(true);
         if (PEAR::isError($res)) {
             $errs[] = $res->getMessage();
         } else {
             $updated++;
         }
     }
     if ($errs) {
         $_SESSION['--msg'] = df_translate('Errors Occurred', 'Errors Occurred') . ':<br/> ' . implode('<br/> ', $errs);
     } else {
         $_SESSION['--msg'] = df_translate('No errors occurred', "No errors occurred");
     }
     $url = $app->url('-action=list');
     if (@$_POST['--redirect']) {
         $url = base64_decode($_POST['--redirect']);
     }
     $msgStr = df_translate('x records were deleted', '%d records were deleted.');
     $msgStr = sprintf($msgStr, $updated);
     $url .= '&--msg=' . urlencode($msgStr);
     $app->redirect($url);
 }
开发者ID:minger11,项目名称:Pipeline,代码行数:37,代码来源:delete_selected.php

示例8: listHtml

 function listHtml($prefix = '')
 {
     $app =& Dataface_Application::getInstance();
     $rs =& $this->_resultSet;
     $pages = array();
     $start = $rs->start();
     $end = $rs->end();
     $limit = max($rs->limit(), 1);
     $found = $rs->found();
     // we show up to 5 pages on either side of the current position
     $pages_before = ceil(floatval($start) / floatval($limit));
     $pages_after = ceil(floatval($found - $end - 1) / floatval($limit));
     $curr_page = $pages_before + 1;
     $total_pages = $pages_before + $pages_after + 1;
     //$i = $curr_page;
     $i_start = $start;
     for ($i = $curr_page; $i > max(0, $curr_page - 5); $i--) {
         $pages[$i] = $app->url('-' . $prefix . 'limit=' . $limit . '&-' . $prefix . 'skip=' . max($i_start, 0));
         if ($this->_baseUrl) {
             $pages[$i] = $this->_baseUrl . '?' . substr($pages[$i], strpos($pages[$i], '?') + 1);
         }
         $i_start -= $limit;
     }
     //$i = $curr_page+1;
     $i_start = $start + $limit;
     for ($i = $curr_page + 1; $i <= min($total_pages, $curr_page + 5); $i++) {
         $pages[$i] = $app->url('-' . $prefix . 'limit=' . $limit . '&-' . $prefix . 'skip=' . $i_start);
         if ($this->_baseUrl) {
             $pages[$i] = $this->_baseUrl . '?' . substr($pages[$i], strpos($pages[$i], '?') + 1);
         }
         $i_start += $limit;
     }
     ksort($pages);
     $pages2 = array();
     if ($curr_page > 1) {
         $pages2[df_translate('scripts.GLOBAL.LABEL_PREV', 'Prev')] = $pages[$curr_page - 1];
     }
     foreach ($pages as $pageno => $pageval) {
         $pages2[$pageno] = $pageval;
     }
     if ($curr_page < $total_pages) {
         $pages2[df_translate('scripts.GLOBAL.LABEL_NEXT', 'Next')] = $pages[$curr_page + 1];
     }
     $out = array('<ul class="resultController">');
     $out[] = '<li class="rs-description">' . df_translate('scripts.GLOBAL.MESSAGE_FOUND', 'Found ' . $found . ' records', array('found' => $found)) . ' </li>';
     foreach ($pages2 as $pageno => $link) {
         if ($pageno == $curr_page) {
             $selected = ' selected';
         } else {
             $selected = '';
         }
         $out[] = '<li class="' . $selected . '"><a href="' . df_escape($link) . '">' . $pageno . '</a></li>';
     }
     $appurl = $app->url('');
     $appurl = preg_replace('/[&\\?]' . preg_quote('-' . $prefix . 'limit=') . '[^&]*/', '', $appurl);
     $appurl = preg_replace('/[&\\?]' . preg_quote('-' . $prefix . 'skip=') . '[^&]*/', '', $appurl);
     $urlprefix = $this->_baseUrl ? $this->_baseUrl . '?' . substr($appurl, strpos($appurl, '?') + 1) : $appurl;
     $out[] = '<li class="results-per-page"> ' . df_translate('scripts.GLOBAL.LABEL_SHOWING', 'Showing') . ' <input type="text" value="' . $limit . '" onchange="window.location = \'' . $urlprefix . '&-' . $prefix . 'limit=\'+this.value" size="3"/>' . df_translate('scripts.GLOBAL.MESSAGE_RESULTS_PER_PAGE', 'Results per page');
     $out[] = '</ul>';
     return implode("\n", $out);
 }
开发者ID:minger11,项目名称:Pipeline,代码行数:61,代码来源:ResultController.php

示例9: preg_replace

 /**
  * Loads a module and returns a reference to it.
  * @param string $name The name of the module's class.
  *
  */
 function &loadModule($name, $path = null)
 {
     if (!isset($path)) {
         if (preg_match('/^modules_/', $name)) {
             $s = DIRECTORY_SEPARATOR;
             $path = preg_replace('/^modules_/', 'modules' . $s, $name) . $s . substr($name, strpos($name, '_') + 1) . '.php';
         }
     }
     $app =& Dataface_Application::getInstance();
     if (isset($this->_modules[$name])) {
         return $this->_modules[$name];
     }
     if (class_exists($name)) {
         $this->_modules[$name] = new $name();
         return $this->_modules[$name];
     }
     if (!isset($path) and (!@$app->_conf['_modules'] or !is_array($app->_conf['_modules']) or !isset($app->_conf['_modules'][$name]))) {
         return PEAR::raiseError(df_translate('scripts.Dataface.ModuleTool.loadModule.ERROR_MODULE_DOES_NOT_EXIST', "The module '{$name}' does not exist.", array('name' => $name)));
     }
     if (!isset($app->_conf['_modules'][$name]) and isset($path)) {
         $app->_conf['_modules'][$name] = $path;
         import($path);
         if ($this->getFsVersion($name, $path) > $this->getDbVersion($name)) {
             $this->updateModule($name, $path);
         }
     } else {
         import($app->_conf['_modules'][$name]);
         if ($this->getFsVersion($name, $app->_conf['_modules'][$name]) > $this->getDbVersion($name)) {
             $this->updateModule($name, $app->_conf['_modules'][$name]);
         }
     }
     if (!class_exists($name)) {
         return PEAR::raiseError(df_translate('scripts.Dataface.ModuleTool.loadModule.ERROR_CLASS_DOES_NOT_EXIST', "Attempted to load the module '{$name}' from path '{$app->_conf['_modules'][$name]}' but after loading - no such class was found.  Please check to make sure that the class is defined.  Or you can disable this module by commenting out the line that says '{$name}={$app->_conf['_modules'][$name]}' in the conf.ini file.", array('name' => $name, 'path' => $app->_conf['_modules'][$name])));
     }
     $this->_modules[$name] = new $name();
     return $this->_modules[$name];
 }
开发者ID:Zunair,项目名称:xataface,代码行数:42,代码来源:ModuleTool.php

示例10: getResultFilters

    function getResultFilters()
    {
        ob_start();
        $app =& Dataface_Application::getInstance();
        $query =& $app->getQuery();
        echo '<div class="resultlist-filters">
		<h3>' . df_translate('scripts.Dataface_ResultList.MESSAGE_FILTER_RESULTS', 'Filter Results') . ':</h3>
		<script language="javascript"><!--
		
		function resultlist__updateFilters(col,select){
			var currentURL = "' . $app->url('') . '";
			var currentParts = currentURL.split("?");
			var currentQuery = "?"+currentParts[1];
			var value = select.options[select.selectedIndex].value;
			var regex = new RegExp(\'([?&])\'+col+\'={1,2}[^&]*\');
			if ( currentQuery.match(regex) ){
				if ( value ){
					prefix = "=";
				} else {
					prefix = "";
				}
				currentQuery = currentQuery.replace(regex, \'$1\'+col+\'=\'+prefix+encodeURIComponent(value));
			} else {
				currentQuery += \'&\'+col+\'==\'+encodeURIComponent(value);
			}
			window.location=currentParts[0]+currentQuery;
		}
		//--></script>
		<ul>';
        $qb = new Dataface_QueryBuilder($this->_table->tablename, $query);
        foreach ($this->_filterCols as $col) {
            $field =& $this->_table->getField($col);
            unset($vocab);
            if (isset($field['vocabulary'])) {
                $vocab =& $this->_table->getValuelist($field['vocabulary']);
            } else {
                $vocab = null;
            }
            echo '<li> ' . htmlspecialchars($field['widget']['label']) . ' <select onchange="resultlist__updateFilters(\'' . addslashes($col) . '\', this);"><option value="">' . df_translate('scripts.GLOBAL.LABEL_ALL', 'All') . '</option>';
            $res = df_query("select `{$col}`, count(*) as `num` " . $qb->_from() . " " . $qb->_secure($qb->_where(array($col => null))) . " group by `{$col}`", null, true);
            if (!$res and !is_array($res)) {
                trigger_error(mysql_error(df_db()), E_USER_ERROR);
            }
            if (@$query[$col] and $query[$col][0] == '=') {
                $queryColVal = substr($query[$col], 1);
            } else {
                $queryColVal = @$query[$col];
            }
            //while ( $row = mysql_fetch_assoc($res) ){
            foreach ($res as $row) {
                if (isset($vocab) and isset($vocab[$row[$col]])) {
                    $val = $vocab[$row[$col]];
                } else {
                    $val = $row[$col];
                }
                if ($queryColVal == $row[$col]) {
                    $selected = ' selected';
                } else {
                    $selected = '';
                }
                echo '<option value="' . htmlspecialchars($row[$col]) . '"' . $selected . '>' . htmlspecialchars($val) . ' (' . $row['num'] . ')</option>';
            }
            //@mysql_free_result($res);
            echo '</select></li>';
        }
        echo '</ul></div>';
        $out = ob_get_contents();
        ob_end_clean();
        return $out;
    }
开发者ID:promoso,项目名称:HVAC,代码行数:70,代码来源:ResultList.php

示例11: createRecordButtons

 /**
  * @brief Creates and HTML_QuickForm group that can be added a a QuickForm object
  * to serve as the submit buttons for edit (or new record) forms. 
  * By default this will create buttons for each tab, a back, next, and 
  * save buttons.
  *
  * CSS is used to hide the tabs by default.
  *
  * @return array(HTML_QuickForm_element) An array of submit elements.
  *
  */
 function createRecordButtons($record, $currentTab = null)
 {
     $factory =& self::factory();
     $out = array();
     $tabs = $record->tabs();
     $tabnames = array_keys($tabs);
     if (count($tabnames) > 0 and !isset($currentTab)) {
         $currentTab = $tabnames[0];
     }
     $saveButtonLabel = df_translate('tables.' . $record->table()->tablename . '.save_button_label', '');
     if (!$saveButtonLabel) {
         $saveButtonLabel = df_translate('save_button_label', 'Save');
     }
     $out[] = $factory->createElement('submit', '--session:save', $saveButtonLabel);
     if (isset($currentTab) and count($tabnames) > 1) {
         if (isset($tabs[$currentTab]['actions']['default'])) {
             $default = $tabs[$currentTab]['actions']['default'];
         } else {
             $default = '__save__';
         }
         $out[] = $factory->createElement('submit', '--session:target:__default__', $default, array('style' => 'display:none'));
         $currIndex = array_search($currentTab, $tabnames);
         $next = isset($tabnames[$currIndex + 1]) ? $tabnames[$currIndex + 1] : null;
         $prev = isset($tabnames[$currIndex - 1]) ? $tabnames[$currIndex - 1] : null;
         if (isset($tabs[$currentTab]['actions']['next'])) {
             $next = $tabs[$currentTab]['actions']['next'];
         }
         if (isset($tabs[$currentTab]['actions']['back'])) {
             $prev = $tabs[$currentTab]['actions']['back'];
         }
         $default = null;
         if (isset($tabs[$currentTab]['actions']['default'])) {
             $default = $tabs[$currentTab]['actions']['default'];
         }
         foreach ($tabs as $tab) {
             if (@$params['tab'] == $tab['name']) {
                 continue;
             }
             // we don't include a button to the current tab
             $tabname = $tab['name'];
             $atts = array();
             if (isset($tab['button']['atts'])) {
                 $atts = $tab['button']['atts'];
             }
             if (isset($params['atts']['__global__'])) {
                 $atts = array_merge($atts, $params['atts']['__global__']);
             }
             if (isset($params['atts'][$tab])) {
                 $atts = array_merge($atts, $params['atts'][$tab]);
             }
             if (!isset($atts['style'])) {
                 $atts['style'] = 'display: none';
             }
             $out[] = $factory->createElement('submit', '--session:target:' . $tabname, $tab['label'], $atts);
         }
     }
     if (isset($prev)) {
         $out[] = $factory->createElement('submit', '--session:target:__back__', df_translate('scripts.GLOBAL.LABEL_BACK', 'Back'));
     }
     if (isset($next)) {
         $out[] = $factory->createElement('submit', '--session:target:__next__', df_translate('scripts.GLOBAL.LABEL_NEXT', 'Next'));
     }
     return $out;
 }
开发者ID:Zunair,项目名称:xataface,代码行数:75,代码来源:FormTool.php

示例12: handle


//.........这里部分代码省略.........
             } else {
                 // If we are using tabs, we will use the formtool's
                 // session aware saving function
                 $result = $formTool->saveSession($currentRecord);
             }
             $success = true;
             $response =& Dataface_Application::getResponse();
             if (!$result) {
                 error_log("Error occurred in save: " . xf_db_error($app->db()) . Dataface_Error::printStackTrace());
                 throw new Exception("An error occurred while attempting to save the record.  See error log for details.", E_USER_ERROR);
             } else {
                 if (PEAR::isError($result) && !Dataface_Error::isNotice($result)) {
                     if (Dataface_Error::isDuplicateEntry($result)) {
                         $app->addError($result);
                         $success = false;
                     } else {
                         error_log($result->toString() . implode("\n", $result->getBacktrace()));
                         throw new Exception("An error occurred while attempting to save the record.  See error log for details.", E_USER_ERROR);
                     }
                 } else {
                     if (Dataface_Error::isNotice($result)) {
                         $app->addError($result);
                         //$response['--msg'] = @$response['--msg'] ."\n".$result->getMessage();
                         $success = false;
                     }
                 }
             }
             if ($success) {
                 if (@$query['-response'] == 'json') {
                     //header('Content-type: text/html; charset="'.$app->_conf['oe'].'"');
                     $rvals = $currentRecord->strvals();
                     $rvals['__title__'] = $currentRecord->getTitle();
                     $rvals['__id__'] = $currentRecord->getId();
                     echo df_escape(json_encode(array('response_code' => 200, 'record_data' => $rvals, 'response_message' => df_translate('Record Successfully Saved', 'Record Successfully Saved'))));
                     return;
                 }
                 import('Dataface/Utilities.php');
                 Dataface_Utilities::fireEvent('after_action_edit', array('record' => $form->_record));
                 /*
                  *
                  * The original query string will have the -new flag set.  We need to remove this 
                  * flag so that we don't redirect the user to create another new record.
                  *
                  */
                 $vals = $form->exportValues();
                 $vals['-query'] = preg_replace('/[&\\?]-new=[^&]+/i', '', $vals['-query']);
                 $_SESSION['--last_modified_record_url'] = $form->_record->getURL();
                 $_SESSION['--last_modified_record_title'] = $form->_record->getTitle();
                 $msg = implode("\n", $app->getMessages());
                 //$msg =@$response['--msg'];
                 $msg = urlencode(Dataface_LanguageTool::translate('Record successfully saved', "Record successfully saved.<br>") . $msg);
                 if (preg_match('/[&\\?]-action=edit&/', $vals['-query']) and !$form->_record->checkPermission('edit')) {
                     $vals['-query'] = preg_replace('/([&\\?])-action=edit&/', '$1-action=view&', $vals['-query']);
                 } else {
                     if (preg_match('/[&\\?]-action=edit$/', $vals['-query']) and !$form->_record->checkPermission('edit')) {
                         $vals['-query'] = preg_replace('/([&\\?])-action=edit$/', '$1-action=view', $vals['-query']);
                     }
                 }
                 $vals['-query'] = preg_replace('/&?--msg=[^&]*/', '', $vals['-query']);
                 if (@$query['--lang']) {
                     $vals['-query'] .= '&--lang=' . $query['--lang'];
                 }
                 $link = $_SERVER['HOST_URI'] . DATAFACE_SITE_HREF . '?' . $vals['-query'] . '&--saved=1&--msg=' . $msg;
                 /*
                  *
                  * Redirect the user to the appropriate record.
开发者ID:minger11,项目名称:Pipeline,代码行数:67,代码来源:edit.php

示例13: reset_password_with_uuid

    public function reset_password_with_uuid($uuid)
    {
        $auth = Dataface_AuthenticationTool::getInstance();
        $app = Dataface_Application::getInstance();
        $del = $app->getDelegate();
        $this->create_reset_password_table();
        $this->clear_expired();
        $table = self::$TABLE_RESET_PASSWORD;
        $res = xf_db_query("select * from `{$table}` where request_uuid='" . addslashes($uuid) . "' limit 1", df_db());
        if (!$res) {
            throw new Exception(xf_db_error(df_db()));
        }
        $row = xf_db_fetch_assoc($res);
        if (!$row) {
            throw new Exception(df_translate('actions.forgot_password.no_such_reset_request_found', "No such reset request could be found"), self::$EX_NO_SUCH_UUID);
        }
        if (!$row['username']) {
            throw new Exception(df_translate('actions.forgot_password.attempt_to_reset_for_null_username', "Attempt to reset password for user with null username"), self::$EX_NO_USERNAME_FOR_USER);
        }
        $username = $row['username'];
        @xf_db_free_result($res);
        // now that we have the username, let's reset the password.
        //$rand = strval(rand())."".$uuid;
        $rand = md5($uuid);
        error_log("Rand is " . $rand);
        $pw = '';
        for ($i = 0; $i <= 16; $i += 2) {
            $pw .= $rand[$i];
        }
        $password = $pw;
        if (isset($del) and method_exists($del, 'generateTemporaryPassword')) {
            $pw = $del->generateTemporaryPassword();
            if ($pw) {
                $password = $pw;
            }
        }
        //error_log("Password is $password");
        $user = df_get_record($auth->usersTable, array($auth->usernameColumn => '=' . $username));
        if (!$user) {
            throw new Exception(df_translate('actions.forgot_password.no_account_for_username', "No user account found with that username"), self::$EX_USER_NOT_FOUND);
        }
        $emailColumn = $auth->getEmailColumn();
        if (!$emailColumn) {
            throw new Exception(df_translate('actions.forgot_password.no_email_column_found_short', "No email column found in the users table"), self::$EX_NO_EMAIL_COLUMN_FOUND);
        }
        $email = $user->val($emailColumn);
        if (!$email) {
            throw new Exception(df_translate('actions.forgot_password.user_without_email_long', "User has account has no email address on record.  Please contact support to reset the password"), self::$EX_NO_EMAIL_FOR_USER);
        }
        $user->setValue($auth->passwordColumn, $password);
        $res = $user->save();
        if (PEAR::isError($res)) {
            throw new Exception($res->getMessage());
        }
        // Let's delete this request from the password reset requests.
        $this->delete_request_with_uuid($uuid);
        // Now let's send the email.
        $del = $app->getDelegate();
        $info = array();
        if (isset($del) and method_exists($del, 'getPasswordChangedEmailInfo')) {
            $info = $del->getPasswordChangedEmailInfo($user, $password);
        }
        $subject = df_translate('actions.forgot_password.password_changed', "Password Changed");
        if (isset($info['subject'])) {
            $subject = $info['subject'];
        }
        $site_url = df_absolute_url(DATAFACE_SITE_HREF);
        $msg = df_translate('actions.forgot_password.new_temporary_password_email_body', <<<END
Your new temporary password is
{$password}

You can change your password as follows:

1. Log in with your temporary password at <{$site_url}?-action=login>
2. Click on the "My Profile" link in the upper right of the page
3. Click on the "Edit" tab.
4. Change your password in the edit form and click "Save" when done.
END
, array('password' => $password, 'site_url' => $site_url));
        if (isset($info['message'])) {
            $msg = $info['message'];
        }
        $parameters = null;
        if (isset($info['parameters'])) {
            $parameters = $info['parameters'];
        }
        $site_title = $app->getSiteTitle();
        $support_email = $_SERVER['SERVER_ADMIN'];
        if (isset($app->_conf['admin_email'])) {
            $support_email = $app->_conf['admin_email'];
        }
        if (isset($app->_conf['support_email'])) {
            $support_email = $app->_conf['support_email'];
        }
        $headers = 'From: ' . $site_title . ' <' . $support_email . '>' . "\r\nReply-to: " . $site_title . " <" . $support_email . ">" . "\r\nContent-type: text/plain; charset=" . $app->_conf['oe'];
        if (isset($info['headers'])) {
            $headers = $info['headers'];
        }
        if (@$app->_conf['_mail']['func']) {
            $func = $app->_conf['_mail']['func'];
//.........这里部分代码省略.........
开发者ID:Zunair,项目名称:xataface,代码行数:101,代码来源:forgot_password.php

示例14: handle

 function handle(&$params)
 {
     import('Dataface/ExistingRelatedRecordForm.php');
     $app =& Dataface_Application::getInstance();
     $query =& $app->getQuery();
     $resultSet =& $app->getResultSet();
     //$record =& $app->getRecord();	// loads the current record
     if (!isset($query['-relationship'])) {
         return PEAR::raiseError(Dataface_LanguageTool::translate('Error: No relationship specified', 'Error.  No relationship was specified when trying to add existing related record.'), DATAFACE_E_NOTICE);
     }
     $record = null;
     $form = new Dataface_ExistingRelatedRecordForm($record, $query['-relationship']);
     $res = $form->_build();
     if (PEAR::isError($res)) {
         return Dataface_Error::permissionDenied($res->getMessage());
     }
     /*
      *
      * We need to add the current GET parameter flags (the GET vars starting with '-') so
      * that the controller knows to pass control to this method again upon form submission.
      *
      */
     foreach ($query as $key => $value) {
         if (strpos($key, '-') === 0) {
             $form->addElement('hidden', $key);
             $form->setDefaults(array($key => $value));
         }
     }
     /*
      * Store the current query string (the portion after the '?') in the form, so we 
      * can retrieve it after and redirect back to our original location.
      */
     $form->addElement('hidden', '-query');
     $form->setDefaults(array('-action' => $query['-action'], '-query' => $_SERVER['QUERY_STRING']));
     if (!$form->_record || !is_a($form->_record, 'Dataface_Record')) {
         trigger_error(Dataface_LanguageTool::translate('Fatal Error', 'Fatal Error: Form should have loaded record but the record was null. ' . Dataface_Error::printStackTrace(), array('stack_trace' => Dataface_Error::printStackTrace(), 'msg' => 'Form should have loaded record but the record was null.')), E_USER_ERROR);
     }
     if (!Dataface_PermissionsTool::checkPermission('add existing related record', $form->_record)) {
         return Dataface_Error::permissionDenied(Dataface_LanguageTool::translate('Error: Permission denied adding existing related record', 'Permission Denied.  You do not have sufficient permissions to add an existing related record.  Required permission: "add existing related record", but you have only been granted permissions: "' . implode(',', $form->_record->getPermissions()) . '".', array('required_permission' => 'add existing related record', 'granted_permissions' => implode(',', $form->_record->getPermissions()))));
     }
     if ($form->validate()) {
         $res = $form->process(array(&$form, 'save'), true);
         $response =& Dataface_Application::getResponse();
         if (PEAR::isError($res) && !Dataface_Error::isNotice($res)) {
             return $res;
         } else {
             if (Dataface_Error::isNotice($res)) {
                 //$response['--msg'] = @$response['--msg'] . "\n".$res->getMessage();
                 $app->addError(PEAR::raiseError(df_translate('Failed to add record because of errors', 'Failed to add record to relationship because of the following errors:'), DATAFACE_E_NOTICE));
                 $app->addError($res);
                 $success = false;
             } else {
                 $success = true;
             }
         }
         if ($success) {
             import('Dataface/Utilities.php');
             Dataface_Utilities::fireEvent('after_action_existing_related_record');
             $fquery = array('-action' => 'browse');
             $msg = Dataface_LanguageTool::translate('Record successfully added to relationship', "The record has been successfully added to the " . $query['-relationship'] . " relationship.\n", array('relationship' => $query['-relationship']));
             $msg = urlencode(trim(($success ? $msg : '') . @$response['--msg']));
             $vals = $form->exportValues();
             if (isset($vals['--redirect'])) {
                 $qmark = strpos($vals['--redirect'], '?') !== false ? '&' : '?';
                 header('Location: ' . $vals['--redirect'] . $qmark . '--msg=' . $msg);
                 exit;
             }
             foreach ($vals['__keys__'] as $key => $value) {
                 $fquery[$key] = "=" . $value;
             }
             $link = Dataface_LinkTool::buildLink($fquery);
             header("Location: {$link}" . "&--msg=" . $msg);
             exit;
         }
     }
     ob_start();
     $form->display();
     $out = ob_get_contents();
     ob_end_clean();
     $context = array('form' => $out);
     if (isset($query['-template'])) {
         $template = $query['-template'];
     } else {
         if (isset($params['action']['template'])) {
             $template = $params['action']['template'];
         } else {
             $template = 'Dataface_Add_Existing_Related_Record.html';
         }
     }
     df_display($context, $template, true);
 }
开发者ID:promoso,项目名称:HVAC,代码行数:91,代码来源:existing_related_record.php

示例15: df_offset

 function df_offset($date)
 {
     if (!$date) {
         return df_translate('scripts.global.MESSAGE_UNKNOWN', 'Unknown');
     }
     $date = strtotime($date);
     $offset = strftime("%j") + strftime("%Y") * 365 - (strftime("%j", $date) + strftime("%Y", $date) * 365);
     if ($offset > 7) {
         $offset = strftime("%W") + strftime("%Y") * 52 - (strftime("%W", $date) + strftime("%Y", $date) * 52);
         $end = $offset != 0 ? $offset > 1 ? $offset . " weeks ago" : "a week ago" : "Today";
     } else {
         $end = $offset != 0 ? $offset > 1 ? "{$offset} days ago" : "Yesterday" : "Today";
     }
     return strftime("%A, %B %d, %Y", $date) . " - " . $end;
 }
开发者ID:promoso,项目名称:HVAC,代码行数:15,代码来源:dataface-public-api.php


注:本文中的df_translate函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。