Пример #1
0
 /**
  * Gets the custom templates available for the current BlockType
  *
  * @return TemplateFile[]
  */
 function getBlockTypeCustomTemplates()
 {
     $btHandle = $this->getBlockTypeHandle();
     $fh = Loader::helper('file');
     $files = array();
     $dir = DIR_FILES_BLOCK_TYPES . "/{$btHandle}/" . DIRNAME_BLOCK_TEMPLATES;
     if (is_dir($dir)) {
         $files = array_merge($files, $fh->getDirectoryContents($dir));
     }
     // NOW, we check to see if this btHandle has any custom templates that have been installed as separate packages
     foreach (PackageList::get()->getPackages() as $pkg) {
         $dir = (is_dir(DIR_PACKAGES . '/' . $pkg->getPackageHandle()) ? DIR_PACKAGES : DIR_PACKAGES_CORE) . '/' . $pkg->getPackageHandle() . '/' . DIRNAME_BLOCKS . '/' . $btHandle . '/' . DIRNAME_BLOCK_TEMPLATES;
         if (is_dir($dir)) {
             $files = array_merge($files, $fh->getDirectoryContents($dir));
         }
     }
     $dir = DIR_FILES_BLOCK_TYPES_CORE . "/{$btHandle}/" . DIRNAME_BLOCK_TEMPLATES;
     if (is_dir($dir)) {
         $files = array_merge($files, $fh->getDirectoryContents($dir));
     }
     $templates = array();
     foreach (array_unique($files) as $file) {
         $templates[] = new TemplateFile($this, $file);
     }
     return TemplateFile::sortTemplateFileList($templates);
 }
Пример #2
0
 /** Callable function used by sortTemplateFileList.
  * @param TemplateFile $a
  * @param TemplateFile $b
  * @return int
  */
 protected static function sortTemplateFileListSorter($a, $b)
 {
     return strcasecmp($a->getTemplateFileDisplayName('text'), $b->getTemplateFileDisplayName('text'));
 }