Beispiel #1
0
 /**
  *	Return possible template names that can be used by the nodes
  *	for rendering by listing all files from the node view directory
  *	
  * 	@return array(string)
  */
 public function templateNames()
 {
     $templateNames = new IndexedArray();
     // get correct template directory from appcontroller’s theme
     $r = get_class_vars('AppController');
     if (empty($r['theme'])) {
         $templateDir = VIEW_DIR . 'node/';
     } else {
         $templateDir = VIEW_DIR . 'theme/' . $r['theme'] . '/node/';
     }
     // list files
     $dir = new Dir($templateDir);
     foreach ($dir->read('@\\.php$@') as $file) {
         if (!$file->isFile()) {
             continue;
         }
         // ignore directories
         if (in_array($file->basename(false), array())) {
             continue;
         }
         // ignore files?
         $templateNames[$file->basename(false)] = $file->basename(false);
     }
     return $templateNames->toArray();
 }
Beispiel #2
0
 /**
  * Generate a list of bundle language files
  *
  * @param array $from
  * @param array $to
  * @return array
  */
 protected static function bundles($from, $to)
 {
     // First start with the application dir
     $from_files = Dir::bundles($from);
     $files = array();
     foreach ($from_files as $bundle) {
         $bundle_files = Dir::read($bundle['path'] . $from);
         foreach ($bundle_files as $key => $file) {
             $from_array = (require $file);
             $to_file = str_replace($from, $to, $file);
             $to_array = is_file($to_file) ? require $to_file : array();
             $files['all'][] = array('location' => $bundle['name'], 'name' => str_replace(path('bundle'), '', basename($to_file, '.php')));
             // Do all our keys match?
             if (static::keys($from_array, $to_array)) {
                 $files['missing'][] = array('location' => $bundle['name'], 'name' => str_replace(path('bundle'), '', basename($to_file, '.php')));
             } else {
                 // If all our keys match we need check our values aren't empty.
                 if (static::values($to_array)) {
                     $files['missing'][] = array('location' => $bundle['name'], 'name' => str_replace(path('bundle'), '', basename($to_file, '.php')));
                 }
             }
         }
     }
     return $files;
 }