Пример #1
0
 /**
  * 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
0
 /**
  * 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
0
 public function __construct()
 {
     global $cms_lang;
     $this->_API_setObjectIsSingleton(TRUE);
     $this->langstrings['default'] = $cms_lang;
     $this->cfg = sf_api('LIB', 'Config');
 }
Пример #4
0
 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
0
 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
0
 /**
  * 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
0
 /**
  * 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
0
 /**
  * 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
0
 /**
  * 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;
 }
 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
0
 /**
  * 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
0
 /**
  * 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
0
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
0
 /**
  * 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
0
 /**
  * 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();
 }
Пример #16
0
function lib_init_settings($name)
{
    global $client;
    //, $val_ct;
    $cfg_name = 'cfg_' . $name;
    global ${$cfg_name};
    //$$cfg_name = $val_ct->get_by_group($name, $client);
    $valcol = sf_api('MODEL', 'ValueSqlCollection');
    $valcol->setIdclient($client);
    $valcol->getByGroup($name);
    ${$cfg_name} = $valcol->getAssocKeyArray();
    unset($valcol);
    return $vars;
}
Пример #17
0
 /**
  * Redirect to the index area. The message code is optional.
  * @param string $msgcode
  * @return void
  */
 protected function _indexRedirect($msgcode = '')
 {
     if (empty($msgcode) == FALSE) {
         $this->url->urlAddModifyParams(array('msgcode' => $msgcode));
     }
     $http_header = sf_api('LIB', 'HttpHeader');
     $http_header->redirect($this->url->urlGet(array('area' => $this->controller_cfg['ctr_name'] . '_index')));
 }
Пример #18
0
 protected function _attrArray2Str($attr = array())
 {
     $html = sf_api('LIB', 'HtmlHelper');
     return $html->attributesArrayToHtmlString($attr);
 }
Пример #19
0
 /**
  * Generate a SQL statement to set the perm limits
  * @return string Returns the piece of the SQL statement.
  * If an error occurs it returns an empty string.
  */
 protected function _getSqlPerms()
 {
     static $sql_perms = '';
     //perms are allready generated, return the string
     if ($sql_perms != '') {
         return $sql_perms;
     }
     //init perms with nothing
     $sql_perms = ' ';
     //Check if permcheck is enabled
     if (!$this->colcfg['perm_check_active']) {
         return $sql_perms;
     }
     //TODO make it for other clients/langs work
     if (TRUE) {
         $perm = $this->cfg->perm();
     } else {
         //TODO $client, $lang
         $perm = new cms_perms($client, $lang, TRUE, $this->cfg->perm()->get_group());
     }
     //admin has all perms, no more actions are needed
     if ($perm->is_admin()) {
         return $sql_perms;
     }
     $fielditem = $this->colcfg['perm_dbfield_id'];
     $fieldparent = $this->colcfg['perm_dbfield_parent'] != '' ? $this->colcfg['perm_dbfield_parent'] : NULL;
     $tablename = $this->tables[0];
     $clientlang = $this->_getSqlClientLang($this->colcfg['client'], $this->colcfg['lang'], array('client' => 'idclient', 'lang' => 'idlang'));
     $timestamp = $this->_getSqlTimestamp('created', $this->colcfg['timestamp_from'], $this->colcfg['timestamp_to']);
     $freefilter = $this->_getSqlFreefilter($this->colcfg['freefilter']);
     $search = $this->_getSqlSearch($this->colcfg['searchterm'], $this->colcfg['fulltextsearchfileds']);
     $item = sf_api($this->colcfg['model_path'], $this->colcfg['model']);
     $idfield = $item->mapFieldToRow('id', $this->tables[0]);
     $sql = $this->_getPermcheckSql($fielditem, $fieldparent, $tablename, $clientlang, $timestamp, $freefilter, $search);
     if ($sql === FALSE) {
         return $sql_perms;
     }
     $rs = $this->db->Execute($sql);
     if ($rs === FALSE || $rs->EOF) {
         return $sql_perms;
     }
     $positives = array();
     $negatives = array();
     //perms with dependancy
     if ($this->colcfg['perm_dbfield_parent'] != NULL) {
         while (!$rs->EOF) {
             if ($perm->have_perm($this->colcfg['perm_nr'], $this->colcfg['perm_type'], $rs->fields['iditem'], $rs->fields['idparent'])) {
                 array_push($positives, $rs->fields['iditem']);
             } else {
                 array_push($negatives, $rs->fields['iditem']);
             }
             $rs->MoveNext();
         }
     } else {
         while (!$rs->EOF) {
             if ($perm->have_perm($this->colcfg['perm_nr'], $this->colcfg['perm_type'], $rs->fields['iditem'])) {
                 array_push($positives, $rs->fields['iditem']);
             } else {
                 array_push($negatives, $rs->fields['iditem']);
             }
             $rs->MoveNext();
         }
     }
     $rs->Close();
     $count_pos = count($positives);
     $count_neg = count($negatives);
     if ($count_pos == 0 && $count_neg == 0) {
         return $sql_perms;
     } else {
         if ($count_pos < $count_neg && $count_pos > 0) {
             $sql_perms = 'AND ' . $this->colcfg['perm_dbfield_id'] . ' IN (' . implode(',', $positives) . ') ';
         } else {
             if ($count_neg > 0) {
                 $sql_perms = 'AND ' . $this->colcfg['perm_dbfield_id'] . ' NOT IN (' . implode(',', $negatives) . ') ';
             }
         }
     }
     return $sql_perms;
 }
Пример #20
0
 /**
  * Retrieves all events from the database and stores
  * them to {$events} array.
  * @return boolean Returns TRUE on success or FALSE on failure.
  */
 protected function _loadEvents()
 {
     $evtcol = sf_api('MODEL', 'EventSqlCollection');
     $evtcol->setIdclient($this->cfg->env('idclient'));
     $evtcol->setIdlang($this->cfg->env('idlang'));
     $evtcol->setOrder('name');
     $evtcol->setOrder('sortindex');
     $success = $evtcol->generate();
     $this->events = $evtcol->getItemsAsArray();
     return $success;
 }
Пример #21
0
 /**
  * Adds an advanced search field 
  * @param string $name
  * @param string $value
  * @param string $attributes
  * @return void
  */
 public function addAdvSearchField($name, $value = '', $attributes = '', $tabs = array())
 {
     $this->tpl->setCurrentBlock('ADV_SEARCHFIELD');
     $tplvals['NAME'] = $name;
     $tplvals['VALUE'] = $value;
     $tplvals['ATTRIBUTES'] = $attributes;
     $tplvals['SEARCH'] = $this->lng->get('gen_search');
     $tplvals['SEARCHTERMS'] = $this->lng->get('gen_searchterms');
     $tplvals['ADVANCED_SEARCH'] = $this->lng->get('gen_advanced_search');
     $form = sf_api('VIEW', 'Form');
     $form->loadTemplatefile('form_elements_advsearch.tpl');
     $form->buildFromConfigFields($tabs, 'logs');
     $tplvals['TABS'] = $form->get();
     $this->tpl->setVariable($tplvals);
     $this->tpl->parseCurrentBlock();
     $this->tpl->setCurrentBlock('ACTION');
     $this->tpl->parseCurrentBlock();
 }
Пример #22
0
 /**
  * Constructor
  */
 public function __construct()
 {
     $this->cfg = sf_api('LIB', 'Config');
     $this->lng = sf_api('LIB', 'Lang');
     $this->lng->loadByFile('lang_logs.php', 'logs', 'lang_dir');
 }
Пример #23
0
 /**
  * Constructor sets up {@link $req}
  * 
  * @return void
  */
 public function __construct()
 {
     //init objects
     $this->req = sf_api('LIB', 'WebRequest');
 }
Пример #24
0
 /**
  * repository::_rebuild_ids()
  *
  * { Description }
  *
  */
 function _rebuild_ids()
 {
     // global $val_ct;
     if ($this->_cms_var['repository_auto_version'] == true) {
         lib_build_repository_ids('mod');
         lib_build_repository_ids('plug');
         //$group = 'cfg';
         //$client = 0;
         //$key = 'repository_auto_version';
         //$value = 0;
         //$val_ct->set_value(array('group' => $group, 'client' => $client, 'key' => $key, 'value' => $value));
         $valitem = sf_api('MODEL', 'ValueSqlItem');
         $valitem->setIdclient(0);
         $valitem->loadByGroupAndKeys('cfg', array('key1' => 'repository_auto_version'));
         $valitem->setField('value', 0);
         $valitem->save();
         unset($valitem);
     }
 }
Пример #25
0
 /**
  * Adds custom JavaScript files with the default JS path.
  * If you want to use a custom path, set $use_custom_path to FALSE.
  * Note: This is a wrapper function an calls the addJsLang()
  * in the footer.
  * @param array $files Plain array with filenames
  * @param boolean $use_custom_path 
  * @return void
  */
 public function addJsFiles($files = array(), $use_custom_path = FALSE)
 {
     $footer = sf_api('VIEW', 'Footer');
     $footer->addJsFiles($files, $use_custom_path);
 }
Пример #26
0
 /**
  * If pattern exists in $config_fields, a TableCellFormater is created
  * and the value is formated. The array $values is used as base for formatting.
  * @param array $config_fields Extract of the $config_fields for one field
  * @param array $values An associative array as array('fieldname' => 'value', ...)
  * @return string Returns the ready formated values as string
  */
 protected function _formatValues($config_fields, $values)
 {
     if (array_key_exists('format', $config_fields) == TRUE && array_key_exists('pattern', $config_fields['format']) == TRUE) {
         $formatter = null;
         if (sf_api_exists('VIEW', $config_fields['format']['classname']) == TRUE) {
             $formatter = sf_api('VIEW', $config_fields['format']['classname']);
         } else {
             if (sf_api_exists('VIEW', 'TableCellFormatter') == TRUE) {
                 $formatter = sf_api('VIEW', 'TableCellFormatter');
             }
         }
         if ($formatter instanceof SF_INTERFACE_TableCellFormatter) {
             $formatter->setItem($this->item);
             $value = $formatter->format($config_fields['format']['pattern'], $values);
         }
     } else {
         $value = implode(' ', $values);
         $value = htmlentities($value, ENT_COMPAT, 'UTF-8');
     }
     return $value;
 }
Пример #27
0
 /**
  * Tries to write the backup content to file.
  * 
  * @return boolean Returns TRUE on success or FALSE on failure.
  */
 public function onSaveItemRollback()
 {
     if ($this->isEditorAvailable() == FALSE) {
         return TRUE;
     }
     $fsm = sf_api('LIB', 'FilesystemManipulation');
     if ($fsm->writeContentToFile($this->item->getPath(), $this->backupcontent) == TRUE) {
         $this->item->setContent($this->backupcontent);
         return TRUE;
     } else {
         return FALSE;
     }
 }
Пример #28
0
 function logout()
 {
     $cfg = sf_api('LIB', 'Config');
     $auth = $cfg->authObj();
     $auth->logout();
     $GLOBALS['auth'] = $auth;
     return TRUE;
 }
Пример #29
0
 /**
  * Returns the mapped table row of the id field 
  * @param string $tablename
  * @return string Returns the mapped table row of the id field
  */
 private function _getMappedIdField($tablename)
 {
     $item = sf_api($this->colcfg['model_path'], $this->colcfg['model']);
     return $tablename . "." . $item->mapFieldToRow('id', $tablename);
 }
Пример #30
0
 /**
  * Write an LogItem to the log file.
  * Decides wheter to save the $item.toString() to frontend or backend logfile and write the log.
  * @return bool Returns true if item is saved successful, otherwise false
  * @param SF_MODEL_LogSqlItem $item LogItem
  */
 function _saveLogItemToFile($item)
 {
     // global $cms_lang;
     $fsm = sf_api('LIB', 'FilesystemManipulation');
     $logfile_size = $this->config['logfile_size'];
     $logfile_path = $this->config['logfile_path'];
     // if logfile is to big, rename it and send e-mail or stop writing to logfile
     if (file_exists($fsm->utf8_decode($logfile_path)) == TRUE && filesize($fsm->utf8_decode($logfile_path)) >= $logfile_size) {
         if ($fsm->renameFile($logfile_path, $logfile_path . '.old') === TRUE) {
             // want to send a notification email
             if (strlen($this->config['logfile_mailaddress']) > 0) {
                 // TODO subject und mail body aus der sprachdatei bekommen -> funktioniert nicht, da die Sprachdatei erst sehr spät geladen wird
                 //$subject = $cms_lang['logfile_mail_subject'];
                 //$tpl_email = printf($cms_lang['logfile_mail_body'], $logfile_path, ($logfile_size/1048576), $logfile_path.'.old');
                 $subject = 'Sefrengo: Maximale Dateigröße für Log-Datei überschritten';
                 $tpl_email = 'Die Log-Datei ' . $logfile_path . ' hat die angegebene Dateigröße von ' . $fsm->readablizeBytes($logfile_size) . ' überschritten. Die Log-Datei wurde in ' . $logfile_path . '.old umbenannt, um weiterhin Logs zu speichern. Bitte löschen Sie die umbenannte Datei aus dem Verzeichnis.';
                 // TODO Use mail class from new API
                 $mail = $GLOBALS['sf_factory']->getObject('UTILS', 'Mail');
                 $mail->setFrom('no-reply@' . $_SERVER['SERVER_NAME']);
                 $mail->addTo($this->config['logfile_mailaddress']);
                 $mail->setSubject($subject);
                 $mail->setTxtBody($tpl_email);
                 $result = $mail->process();
             }
         } else {
             return FALSE;
         }
     }
     return $fsm->writeContentToFile($logfile_path, $item, 'a+');
 }