本文整理汇总了PHP中sf_api函数的典型用法代码示例。如果您正苦于以下问题:PHP sf_api函数的具体用法?PHP sf_api怎么用?PHP sf_api使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sf_api函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formatValue
/**
* Format the output by the given format $pattern. If $fieldname is empty the $this->current_fieldname
* is taken to replace the pattern. If pattern is found the $returnval will be replaced. Otherwise
* it is returned directly, as given.
* @param string $returnval
* @param string $format_func
* @param string $fieldname
* @return string Returns the modified $returnval
*/
public function formatValue($returnval, $format_func, $fieldname = '')
{
switch ($format_func) {
case 'date':
$returnval = $fieldname == 'created' ? $this->item->getCreatedDate() : $returnval;
$returnval = $fieldname == 'lastmodified' ? $this->item->getLastmodifiedDate() : $returnval;
break;
case 'time':
$returnval = $fieldname == 'created' ? $this->item->getCreatedTime() : $returnval;
$returnval = $fieldname == 'lastmodified' ? $this->item->getLastmodifiedTime() : $returnval;
break;
case 'author':
$returnval = $fieldname == 'created' ? $this->item->getCreatedAuthor('', 'username') : $returnval;
$returnval = $fieldname == 'lastmodified' ? $this->item->getLastmodifiedAuthor('', 'username') : $returnval;
break;
case 'tostring':
$returnval = print_r($returnval, TRUE);
break;
case 'lang':
$lng = sf_api('LIB', 'Lang');
$langval = $lng->get($returnval);
$returnval = $langval == '' ? $returnval : $langval;
break;
case 'asInt':
$returnval = (int) $returnval;
break;
}
return htmlentities($returnval, ENT_COMPAT, 'UTF-8');
}
示例2: addMessage
/**
* Add message to right pane in backend area template
* @param string $type (ERROR,WARNING,OK)
* @param string $message
* @param array $moreinfo
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function addMessage($type, $message, $moreinfo = array())
{
if ($message == '') {
return FALSE;
}
$messages = sf_api('VIEW', 'Messages');
$type = strtolower($type);
switch ($type) {
case 'error':
$messages->addError($message, $moreinfo);
break;
case 'warning':
$messages->addWarning($message, $moreinfo);
break;
case 'ok':
$messages->addOk($message, $moreinfo);
break;
case 'info':
$messages->addInfo($message, $moreinfo);
break;
default:
return FALSE;
break;
}
$this->addTemplateVar('MESSAGE', $messages, 'RIGHTPANE');
return TRUE;
}
示例3: __construct
public function __construct()
{
global $cms_lang;
$this->_API_setObjectIsSingleton(TRUE);
$this->langstrings['default'] = $cms_lang;
$this->cfg = sf_api('LIB', 'Config');
}
示例4: generate
public function generate()
{
$auth = $this->cfg->authObj();
$perm = $this->cfg->perm();
//check dependencies
if ($this->config['idlang'] < 1 || $this->config['is_generated']) {
return false;
}
$this->catinfos = sf_api('LIB', 'Catinfos');
if ($this->catinfos->getIdlang() != $this->getIdlang()) {
$this->catinfos = sf_api('LIB', 'CatinfosCustom');
$this->catinfos->setIdlang($this->getIdlang());
$this->catinfos->generate();
}
$catinfos = $this->catinfos->getCatinfoDataArray();
//check perm: user have perm to see pages with the protected flag
//$sql_hide_protected_pages = ( $perm->have_perm(2, 'area_frontend', 0) || $this->config['check_frontend_prems']) ? '': 'AND (F.online & 0x04) = 0x00';
$sql_hide_protected_pages = '';
if ($auth->auth['uid'] == 'nobody') {
$sql_hide_protected_pages = 'AND (F.online & 0x04) = 0x00';
}
//check perms for user with advanced frontend perms
$check_frontendperms_in_page = $auth->auth['uid'] != 'nobody' && $this->config['check_frontend_prems'];
$check_backendperms_in_page = $this->config['check_backend_prems'];
$sql = "SELECT\n\t\t\t\t\tD.idcatside, D.idcat, D.sortindex, D.is_start,\n\t\t\t\t\tE.idside,\n\t\t\t\t\tIF ((F.online & 0x03) = 0x01 OR ((F.online & 0x02) = 0x02 AND (UNIX_TIMESTAMP(NOW()) BETWEEN F.start AND F.end)) ,'1' ,'0') AS online,\n\t\t\t\t\tIF ( ((F.online & 0x04) = 0x04) ,'1' ,'0') AS protected,\n\t\t\t\t\tF.title, F.start, F.rewrite_use_automatic, F.rewrite_url, F.end, F.idsidelang, F.created, F.lastmodified,\n\t\t\t\t\tF.idtplconf, F.is_https\n\t\t\t\tFROM\n\t\t\t\t\t" . $this->cfg->db('cat_side') . " D LEFT JOIN\n\t\t\t\t\t" . $this->cfg->db('side') . " E USING(idside) LEFT JOIN\n\t\t\t\t\t" . $this->cfg->db('side_lang') . " F USING(idside)\n\t\t\t\tWHERE \n\t\t\t\t\tD.idcat IN (" . implode(',', array_keys($catinfos)) . ")\n\t\t\t\t\tAND F.idlang = '" . $this->config['idlang'] . "'\n\t\t\t\t\t{$sql_hide_protected_pages}\n\t\t\t\t\tORDER BY D.idcatside";
//try cache - on success jump out with return true
$cache_key = $sql . '|' . $this->config['link_extra_urlstring'] . '|' . implode(',', $perm->get_group()) . '|' . $this->config['check_frontend_prems'] . '|' . $this->config['check_backend_prems'];
$data = false;
if ($data = $this->cache->getCacheEntry($cache_key)) {
$this->data = $data;
return true;
}
$rs = $this->db->Execute($sql);
if ($rs === false) {
return true;
}
while (!$rs->EOF) {
$idcatside_loop = $rs->fields['idcatside'];
$idcat_loop = $rs->fields['idcat'];
if ($check_frontendperms_in_page) {
if ($rs->fields['protected'] == 1 && !$perm->have_perm(18, 'frontendpage', $idcatside_loop, $idcat_loop)) {
$rs->MoveNext();
continue;
}
}
if ($check_backendperms_in_page) {
if (!$perm->have_perm(17, 'side', $idcatside_loop, $idcat_loop)) {
$rs->MoveNext();
continue;
}
}
$link_loop = 'cms://idcatside=' . $idcatside_loop;
$this->data['data'][$idcatside_loop] = array('link' => $link_loop, 'idcat' => $idcat_loop, 'sortindex' => $rs->fields['sortindex'], 'idside' => $rs->fields['idside'], 'name' => $rs->fields['title'], 'created' => $rs->fields['created'], 'lastmodified' => $rs->fields['lastmodified'], 'online' => $rs->fields['online'], 'idsidelang' => $rs->fields['idsidelang'], 'is_start' => $rs->fields['is_start'], 'idtplconf' => $rs->fields['idtplconf'], 'rewrite_use_automatic' => $rs->fields['rewrite_use_automatic'], 'rewrite_url' => $rs->fields['rewrite_url'], 'user_protected' => $rs->fields['user_protected']);
$rs->MoveNext();
}
//insert cache
$this->cache->insertCacheEntry($cache_key, $this->data, 'frontend', 'tree');
return true;
}
示例5: get
public function get($arr, $tpl, $options = array())
{
if (empty($tpl)) {
return FALSE;
}
// set keywords
$this->_setKeywords();
// Set Options
$this->tpl = $tpl;
$this->tpl_vars = empty($arr) ? array() : $arr;
$options_def = array('delimiter_left' => '{', 'delimiter_right' => '}', 'delete_empty' => false);
$this->options = array_merge($options_def, $options);
// Quote delimiter - TODO: get sure that quted delimiters are only used on reg expressions
//$this->options['delimiter_left'] = preg_quote($this->options['delimiter_left'], '#');
//$this->options['delimiter_right'] = preg_quote($this->options['delimiter_right'], '#');
//{{{ Load classes
if (stripos($tpl, 'sf_page')) {
if (!is_object($this->page)) {
$this->page = sf_api('LIB', 'Pageinfos');
}
}
if (stripos($tpl, 'sf_cat')) {
if (!is_object($this->cat)) {
$this->cat = sf_api('LIB', 'Catinfos');
}
}
if (stripos($tpl, 'sf_content')) {
if (!is_object($this->cf)) {
$this->cf = sf_api('PAGE', 'ContentFactory');
}
}
//}}}
// parse template
$this->_parseTemplate();
// if delete_empty is set, delete all unused template variables
if ($this->options['delete_empty']) {
$delimiter_left = preg_quote($this->options['delimiter_left'], '#');
$delimiter_right = preg_quote($this->options['delimiter_right'], '#');
//{{{ delete all blocks
// recognize blocks
$pattern = '#' . $delimiter_left . '/(.+?)' . $delimiter_right . '#s';
preg_match_all($pattern, $this->tpl, $match);
// delete blocks
if (!empty($match[1])) {
foreach ($match[1] as $value) {
$pattern = '#' . $delimiter_left . $value . $delimiter_right . '(.*?)' . $delimiter_left . '/' . $value . $delimiter_right . '#s';
$replace = '';
$this->tpl = preg_replace($pattern, $replace, $this->tpl);
}
}
//}}}
// Delete the rest
$pattern = '#' . $delimiter_left . '.*?' . $delimiter_right . '#';
$replace = '';
$this->tpl = preg_replace($pattern, $replace, $this->tpl);
}
return $this->tpl;
}
示例6: __construct
/**
* Constructor sets up {@link $cfg}, {@link lng}, {@link url}, {@link tpl}
* @return void
*/
public function __construct()
{
$this->cfg = sf_api('LIB', 'Config');
$this->lng = sf_api('LIB', 'Lang');
$this->url = sf_api('LIB', 'UrlBuilder');
//$this->tpl = $this->cfg->tpl();
$this->tpl = new HTML_Template_IT($this->cfg->env('path_backend') . $this->getSkinPath());
$this->_addCommonTemplateVars();
}
示例7: __construct
/**
* Constructor
* @return void
*/
public function __construct()
{
$this->_API_setObjectIsSingleton(TRUE);
$path = str_replace('\\', '/', dirname(__FILE__) . '/');
$path .= '../../external/phpthumb/phpthumb.class.php';
include_once $path;
$this->phpthumb = new phpthumb();
$cfg = sf_api('LIB', 'Config');
$this->phpthumb->setParameter('config_temp_directory', $cfg->env('path_backend') . 'upload/out');
}
示例8: _getContentTypeByExtension
/**
* Get the mime-type from the filetype table.
* @param string $filename
* @return Returns the mimetype for the file. If not found returns an empty string.
*/
private function _getContentTypeByExtension($extension)
{
if ($extension != '') {
$filetype = sf_api('MODEL', 'FiletypeSqlItem');
if ($filetype->loadByFiletype(array('filetype' => $extension)) != FALSE) {
return $filetype->getField('mimetype');
}
}
return '';
}
示例9: formatValue
/**
* Modifies the $returnval. Switches action by the given $format_func and $fieldname
* @param string $returnval
* @param string $format_func
* @param string $fieldname
* @return string Returns the modified $returnval
*/
public function formatValue($returnval, $format_func, $fieldname = '')
{
switch ($format_func) {
case 'filesize':
$fsm = sf_api('LIB', 'FilesystemManipulation');
$returnval = $fsm->readablizeBytes($returnval);
break;
default:
$returnval = parent::formatValue($returnval, $format_func, $fieldname);
}
return $returnval;
}
示例10: __construct
public function __construct()
{
global $db, $cms_db;
//set singelton
$this->_API_setObjectIsSingleton(TRUE);
$this->cfg = sf_api('LIB', 'Config');
$this->lng = sf_api('LIB', 'Lang');
$this->adb = sf_api('LIB', 'Ado');
//db object
$this->db = $db;
//db names
$this->dbnames = $cms_db;
}
示例11: _setupLogger
/**
* Sets up the {@link $logger}
* @return void
*/
protected function _setupLogger()
{
//$cfg = sf_api('LIB', 'Config');
$this->logger = sf_api('LIB', 'Logger');
/*$this->logger->setIsBackend(TRUE);
$this->logger->setLogfilePath($cfg->cms('log_path'));
$this->logger->setLogfileSize($cfg->cms('log_size'));
$this->logger->setLogfileMailAddress($cfg->cms('logfile_mailaddress'));
$this->logger->setIdclient($cfg->env('idclient'));
$this->logger->setIdlang($cfg->env('idlang'));
$this->logger->setStorage('screen', $cfg->cms('logs_storage_screen'));
$this->logger->setStorage('logfile', $cfg->cms('logs_storage_logfile'));
$this->logger->setStorage('database', $cfg->cms('logs_storage_database'));*/
}
示例12: formatValue
/**
* Modifies the $returnval. Switches action by the given $format_func and $fieldname
* @param string $returnval
* @param string $format_func
* @param string $fieldname
* @return string Returns the modified $returnval
*/
public function formatValue($returnval, $format_func, $fieldname = '')
{
switch ($format_func) {
// overwritten from parent function
case 'lang':
$lng = sf_api('LIB', 'Lang');
$langval = $lng->get('logs_messages_' . $returnval);
if ($this->item instanceof SF_MODEL_LogSqlItem) {
$params = $this->item->getField('param');
if (is_array($params)) {
foreach ($params as $key => $val) {
$langval = str_replace('{' . $key . '}', $val, $langval);
}
}
}
$returnval = $langval == '' ? $returnval : $langval;
break;
default:
$returnval = parent::formatValue($returnval, $format_func, $fieldname);
}
return $returnval;
}
示例13: _type_check_local_tag_perm
function _type_check_local_tag_perm($string_to_check)
{
$cfg = sf_api('LIB', 'Config');
$perm = $cfg->perm();
$string_to_check = str_replace(' ', '', $string_to_check);
if ($string_to_check == 'false') {
return FALSE;
}
if (stristr($string_to_check, ',') || is_numeric($string_to_check)) {
$checkme = explode(',', $string_to_check);
if ($perm->is_admin()) {
return TRUE;
}
foreach ($checkme as $val) {
if (in_array($val, $perm->idgroup)) {
return TRUE;
}
}
return FALSE;
}
return TRUE;
}
示例14: _sanitizeDirectoryname
/**
* Modify the given $filename accordingly to the
* client setting 'allow_invalid_dirnames':
* 0 = returns FALSE
* 1 = does nothing and returns the given $directoryname
* 2 = sanitize the $directoryname and returns it
* @param string $directoryname
* @return string|boolean Returns the sanitized $directoryname or FALSE.
*/
protected function _sanitizeDirectoryname($directoryname)
{
// check if invalid directorynames are allowed
switch (self::$client_settings['allow_invalid_dirnames']) {
// no: return FALSE
case 0:
$validator = sf_api('LIB', 'Validation');
if ($validator->directoryname($directoryname) == FALSE) {
$directoryname = FALSE;
}
unset($validator);
break;
// yes: use current filename
// yes: use current filename
case 1:
//$directoryname = $directoryname;
break;
// correct filename: use the corrected filename
// correct filename: use the corrected filename
case 2:
$fsm = sf_api('LIB', 'FilesystemManipulation');
$directoryname = $fsm->cleanDirectoryname($directoryname);
unset($fsm);
break;
}
return $directoryname;
}
示例15: _getIduplByStatus
/**
* Retrieves a collection of files by given $status and $mask and
* return only the ids of the results.
* @param integer $status The result of (status & $mask)
* @param integer $mask Modify the current status
* @return array Returns an array with the IDs of found files.
*/
protected function _getIduplByStatus($status, $mask)
{
$filecol = sf_api('MODEL', 'FileSqlCollection');
$filecol->setIdclient($this->config_area['idclient']);
$filecol->setIdlang($this->config_area['idlang']);
$filecol->setFreefilter('area', $this->config_area['parent_area_name']);
$filecol->setFreefilter('(status & ' . $mask . ')', $status);
$filecol->generate(TRUE);
// TRUE = generate only IDs, no items
return $filecol->getIdsAsArray();
}