/**
  * Get language definition for error. Function returns text anyway!
  *
  * @param string $key
  * @return string
  */
 public function get_error($key)
 {
     $result = $this->get($key);
     if ($key == $result || trim($result) == '') {
         $backtrace = debug_backtrace();
         $ts = time();
         $log_message = $ts . "- Not described error.\n" . "File: " . $backtrace[0]['file'] . "\n" . "Line: " . $backtrace[0]['line'] . "\n" . "Args: " . var_export($backtrace[0]['args'], true) . "\n";
         $e = new AError($log_message);
         $e->toDebug()->toLog()->toMessages();
         $result = "Not described error happened.";
         if (IS_ADMIN === true) {
             $result .= "Check log for details. Code [" . $ts . "]";
         }
     }
     return $result;
 }
示例#2
0
 /**
  * @param string $title
  * @param string $error
  * @param string $level
  * @return string
  */
 private function processError($title, $error, $level = 'warning')
 {
     $this->message->{'save' . ucfirst($level)}($title, $error);
     $wrn = new AError($error);
     $wrn->toDebug()->toLog();
     return $error;
 }
示例#3
0
 /**
  * Get given field, type, values and selected/default
  *
  * @param string $fname
  * @return array with field data
  */
 public function getField($fname)
 {
     foreach ($this->fields as $field) {
         if ($field['field_name'] == $fname) {
             return array('field_name' => $field['field_name'], 'element_type' => $field['element_type'], 'required' => $field['required'], 'name' => $field['name'], 'value' => $field['value'], 'settings' => $field['settings'], 'description' => $field['description']);
         }
     }
     $err = new AError('NOT EXIST Form field with name ' . $fname);
     $err->toDebug()->toLog();
     return null;
 }
示例#4
0
 /**
  * Process the template
  * @param $filename
  * @return string
  */
 public function fetch($filename)
 {
     ADebug::checkpoint('fetch ' . $filename . ' start');
     //#PR First see if we have full path to template file. Nothing to do. Higher precedence!
     if (is_file($filename)) {
         //#PR set full path
         $file = $filename;
     } else {
         //#PR Build the path to the template file
         $path = DIR_TEMPLATE;
         if (!defined('INSTALL')) {
             $file = $this->_get_template_path($path, '/template/' . $filename, 'full');
         } else {
             $file = $path . $filename;
         }
         if ($this->has_extensions && ($result = $this->extensions->isExtensionResource('T', $filename))) {
             if (is_file($file)) {
                 $warning = new AWarning("Extension <b>" . $result['extension'] . "</b> overrides core template with <b>" . $filename . "</b>");
                 $warning->toDebug();
             }
             $file = $result['file'];
         }
     }
     if (is_file($file)) {
         $content = '';
         $file_pre = str_replace('.tpl', POSTFIX_PRE . '.tpl', $filename);
         if ($result = $this->extensions->isExtensionResource('T', $file_pre)) {
             $content .= $this->_fetch($result['file']);
         }
         $content .= $this->_fetch($file);
         $file_post = str_replace('.tpl', POSTFIX_POST . '.tpl', $filename);
         if ($result = $this->extensions->isExtensionResource('T', $file_post)) {
             $content .= $this->_fetch($result['file']);
         }
         ADebug::checkpoint('fetch ' . $filename . ' end');
         return $content;
     } else {
         $error = new AError('Error: Could not load template ' . $filename . '!', AC_ERR_LOAD);
         $error->toDebug()->toLog();
     }
     return '';
 }
示例#5
0
 /**
  * Process the template
  * @param $filename
  * @return string
  */
 public function fetch($filename)
 {
     ADebug::checkpoint('fetch ' . $filename . ' start');
     //#PR First see if we have full path to template file. Nothing to do. Higher precedence!
     if (is_file($filename)) {
         //#PR set full path
         $file = $filename;
     } else {
         //#PR Build the path to the template file
         $path = DIR_TEMPLATE;
         if (!defined('INSTALL')) {
             $file = $this->_get_template_path($path, '/template/' . $filename, 'full');
         } else {
             $file = $path . $filename;
         }
         if ($this->has_extensions && ($result = $this->extensions->isExtensionResource('T', $filename))) {
             if (is_file($file)) {
                 $warning = new AWarning("Extension <b>" . $result['extension'] . "</b> overrides core template with <b>" . $filename . "</b>");
                 $warning->toDebug();
             }
             $file = $result['file'];
         }
     }
     if (empty($file)) {
         $error = new AError('Error: Unable to identify file path to template ' . $filename . '! Check blocks in the layout or enable debug mode to get more details. ' . AC_ERR_LOAD);
         $error->toDebug()->toLog();
         return '';
     }
     if (is_file($file)) {
         $content = '';
         $file_pre = str_replace('.tpl', POSTFIX_PRE . '.tpl', $filename);
         if ($result = $this->extensions->getAllPrePostTemplates($file_pre)) {
             foreach ($result as $item) {
                 $content .= $this->_fetch($item['file']);
             }
         }
         $content .= $this->_fetch($file);
         $file_post = str_replace('.tpl', POSTFIX_POST . '.tpl', $filename);
         if ($result = $this->extensions->getAllPrePostTemplates($file_post)) {
             foreach ($result as $item) {
                 $content .= $this->_fetch($item['file']);
             }
         }
         ADebug::checkpoint('fetch ' . $filename . ' end');
         //Write HTML Cache if we need and can write
         if ($this->config && $this->config->get('config_html_cache') && $this->html_cache_key) {
             if ($this->cache->save_html_cache($this->html_cache_key, $content) === false) {
                 $error = new AError('Error: Cannot create HTML cache for file ' . $this->html_cache_key . '! Directory to write cache is not writable', AC_ERR_LOAD);
                 $error->toDebug()->toLog();
             }
         }
         return $content;
     } else {
         $error = new AError('Error: Cannot load template ' . $filename . '! File ' . $file . ' is missing or incorrect. Check blocks in the layout or enable debug mode to get more details. ', AC_ERR_LOAD);
         $error->toDebug()->toLog();
     }
     return '';
 }