public function render()
 {
     $params = array($this->_pageID, &$this->_data);
     ptc_log($params, 'Website metatags are been compiled!', \App::option('website.debug_category') . ' Action');
     if ($this->_callback) {
         ptc_log($params, 'Website metatags is beeing fired!', \App::option('website.debug_category') . ' Action');
         \Event::fire('metatags.callback', $params);
     }
     if (empty($this->_data)) {
         return null;
     }
     $tag = null;
     foreach ($this->_data as $k => $v) {
         if (!$v) {
             continue;
         }
         $v = preg_replace('/\\s+/', ' ', $v);
         if ('title' === $k) {
             $tag .= "\t" . '<title>' . trim($v) . '</title>' . "\n";
         } else {
             if (0 === strpos(strtolower($k), 'og:')) {
                 $tag .= "\t" . '<meta property="' . $k . '" content="' . trim($v) . '">' . "\n";
             } else {
                 $tag .= "\t" . '<meta name="' . $k . '" content="' . trim($v) . '">' . "\n";
             }
         }
     }
     return $tag;
 }
Example #2
0
 public static function merge($file)
 {
     if (empty(static::$_modules)) {
         return require_once $file;
     }
     $option_name = @end(explode('/', str_replace('.php', '', $file)));
     $options = file_exists($file) ? require_once $file : array();
     foreach (static::$_modules as $module) {
         $m_path = $module->path();
         $newfile = str_replace(ptc_path('root') . '/app/config', $m_path . '/config', $file);
         $module_options = @$module->option($option_name);
         if ($newfile != $file && $module_options) {
             foreach ($module_options as $k => $v) {
                 if (is_array($v) && array_key_exists($k, $options)) {
                     $val = array_merge($options[$k], $v);
                     //$options[ $k ] = array_unique( $val );
                     $options[$k] = array_map('unserialize', array_unique(array_map('serialize', $val)));
                 } else {
                     $options[$k] = $v;
                 }
             }
             ptc_log([$newfile, $options], 'Module "' . $module->name() . '" merged config file!', 'Modules Manager Action');
         }
     }
     return $options;
 }
Example #3
0
 /**
  *
  */
 public function __construct($xml, $fallbackFile = null)
 {
     $this->_addValues($this->_loadXML($xml));
     if ($fallbackFile) {
         $this->_addValues($this->_loadXML($fallbackFile));
     }
     $debug = array('file' => $xml, 'fallback' => $fallbackFile, 'data' => $this->_data);
     ptc_log($debug, 'Translation xml file loaded!', 'Translator Helper Config');
 }
Example #4
0
 /**
  *
  */
 public function __construct()
 {
     $class = get_called_class();
     $event = Event::getEvent('app');
     if (is_array($event) && ptc_array_get($event, 'start', false)) {
         ptc_fire('app.start', array(&$class::$_config, &$this));
     }
     $this->_appConfig = $class::$_config;
     ptc_log($this->_appConfig, 'Started the application', 'App Config');
 }
 /**
  *
  */
 public static function controller($id, $xml)
 {
     $msg = 'Adding controller "' . $id . '" routes with website router helper!';
     ptc_log($msg, '', \App::option('website.debug_category') . ' Config');
     $listeners = \Event::get('website');
     if (is_array($listeners) && isset($listeners['load_routes_xml'])) {
         ptc_fire('website.load_routes_xml', array($id, &$xml));
     }
     $routes = new Routes($id, $xml);
     $routes->compile();
 }
 public static function intercept($path, $type = 'file', $debug = false)
 {
     $modules = Manager::all();
     foreach ($modules as $module) {
         $m_path = $module->path();
         if (false !== strpos($path, ptc_path('root') . '/app/config')) {
             continue;
             // do nothing
         } else {
             if (false !== strpos($path, ptc_path('root') . '/app') && false === strpos($path, $m_path)) {
                 $file = str_replace(ptc_path('root') . '/app', $m_path, $path);
                 if ('realpath' === $type && ($f = realpath($file))) {
                     $path = $f;
                     break;
                     // load the first file found
                 } else {
                     if ('file' === $type && file_exists($file)) {
                         if ($debug) {
                             ptc_log([$file, $path], 'StreamWrapper intercepted module file!', 'StreamWrapper Config');
                         }
                         $path = $file;
                         break;
                         // load the first file found
                     }
                 }
             }
         }
     }
     return $path;
 }
}
/* STOP CODE COVERAGE ANALYSIS */
ptc_stop_coverage();
// PtcDebug::stopCoverage( )
/* STOP FUNCTION CALLS TRACING */
ptc_stop_trace();
// PtcDebug::stopTrace( )
/*** PTC HANDYMAN HELPERPS ****************************************************/
/* ADDING APPLICATION PATHS FOR LATER USAGE ( PtcHandMan::addAppPath( ) ) */
ptc_add_path(array('lib' => dirname(__FILE__) . '/autoloader-example-files'));
/* ADDING CLASS FILES ( PtcHandMan::addFile( ) ) */
ptc_add_file(array('HmTestClassFile' => ptc_path('lib') . '/class-file.php', 'ns\\HmTestClassFile' => ptc_path('lib') . '/ns-class-file.php'));
/* ADDING DIRECTORIES WITH CLASSES TO THE AUTOLOADER ( PtcHandMan::addDir( ) ) */
ptc_add_dir(ptc_path('lib'));
// PtcHandMan::getAppPath(
/* ADDING A NAMESPACED DIRECTORY WITH CLASSES TO THE AUTOLOADER */
ptc_add_dir(array('nsTest' => ptc_path('lib') . '/namespaceTest'));
/* GETTING THE DIRECTORIES OF THE AUTOLOADER ( PtcHandyMan::getDirs( ) )*/
$dirs = ptc_dir();
// PtcHandyMan::getDirs( ) params: ( files , directories , ns )
ptc_log($dirs, 'getting all directories and files to be autoloaded');
//PtcDebug::bufferLog( );
/*** PTC EVENT HELPERPS ****************************************************/
/* ADDING EVENT LISTENERS ( PtcEvent::listen( ) ) */
ptc_listen('some.event', function ($data) {
    // do some stuff
    ptc_log($data, 'Called event with closure as call back');
    // PtcDebug::bufferLog( )
});
/* FIRING EVENTS ( PtcEvent::fire( ) ) */
PtcEvent::fire('some.event', array('some data'));