Overview

Namespaces

  • Charcoal
    • Admin
      • Widget
        • Cms
    • Cms
      • Config
      • Mixin
        • Traits
      • Route
      • Section
      • Service
        • Loader
        • Manager
      • ServiceProvider
      • Support
        • Helpers
        • Interfaces
        • Traits
    • Property

Classes

  • Charcoal\Admin\Widget\Cms\HierarchicalSectionTableWidget
  • Charcoal\Admin\Widget\Cms\SectionTableWidget
  • Charcoal\Cms\AbstractDocument
  • Charcoal\Cms\AbstractEvent
  • Charcoal\Cms\AbstractFaq
  • Charcoal\Cms\AbstractImage
  • Charcoal\Cms\AbstractNews
  • Charcoal\Cms\AbstractSection
  • Charcoal\Cms\AbstractText
  • Charcoal\Cms\AbstractVideo
  • Charcoal\Cms\Config
  • Charcoal\Cms\Config\CmsConfig
  • Charcoal\Cms\Config\EventConfig
  • Charcoal\Cms\Config\NewsConfig
  • Charcoal\Cms\Config\SectionConfig
  • Charcoal\Cms\Document
  • Charcoal\Cms\DocumentCategory
  • Charcoal\Cms\EmptySection
  • Charcoal\Cms\Event
  • Charcoal\Cms\EventCategory
  • Charcoal\Cms\ExternalSection
  • Charcoal\Cms\Faq
  • Charcoal\Cms\FaqCategory
  • Charcoal\Cms\Image
  • Charcoal\Cms\ImageCategory
  • Charcoal\Cms\News
  • Charcoal\Cms\NewsCategory
  • Charcoal\Cms\Route\EventRoute
  • Charcoal\Cms\Route\GenericRoute
  • Charcoal\Cms\Route\NewsRoute
  • Charcoal\Cms\Route\SectionRoute
  • Charcoal\Cms\Section
  • Charcoal\Cms\Section\BlocksSection
  • Charcoal\Cms\Section\ContentSection
  • Charcoal\Cms\Service\Loader\AbstractLoader
  • Charcoal\Cms\Service\Loader\EventLoader
  • Charcoal\Cms\Service\Loader\NewsLoader
  • Charcoal\Cms\Service\Loader\SectionLoader
  • Charcoal\Cms\Service\Manager\AbstractManager
  • Charcoal\Cms\Service\Manager\EventManager
  • Charcoal\Cms\Service\Manager\NewsManager
  • Charcoal\Cms\ServiceProvider\CmsServiceProvider
  • Charcoal\Cms\Support\Helpers\DateHelper
  • Charcoal\Cms\Tag
  • Charcoal\Cms\Text
  • Charcoal\Cms\TextCategory
  • Charcoal\Cms\Video
  • Charcoal\Cms\VideoCategory
  • Charcoal\Property\TemplateOptionsProperty
  • Charcoal\Property\TemplateProperty

Interfaces

  • Charcoal\Cms\DocumentInterface
  • Charcoal\Cms\EventInterface
  • Charcoal\Cms\FaqInterface
  • Charcoal\Cms\ImageInterface
  • Charcoal\Cms\MetatagInterface
  • Charcoal\Cms\Mixin\HasContentBlocksInterface
  • Charcoal\Cms\NewsInterface
  • Charcoal\Cms\SearchableInterface
  • Charcoal\Cms\SectionInterface
  • Charcoal\Cms\Support\Interfaces\EventManagerAwareInterface
  • Charcoal\Cms\Support\Interfaces\NewsManagerAwareInterface
  • Charcoal\Cms\Support\Interfaces\SectionLoaderAwareInterface
  • Charcoal\Cms\TemplateableInterface
  • Charcoal\Cms\TextInterface
  • Charcoal\Cms\VideoInterface

Traits

  • Charcoal\Admin\Widget\Cms\SectionTableTrait
  • Charcoal\Cms\MetatagTrait
  • Charcoal\Cms\Mixin\Traits\HasContentBlocksTrait
  • Charcoal\Cms\SearchableTrait
  • Charcoal\Cms\Support\Traits\DateHelperAwareTrait
  • Charcoal\Cms\Support\Traits\EventManagerAwareTrait
  • Charcoal\Cms\Support\Traits\NewsManagerAwareTrait
  • Charcoal\Cms\Support\Traits\SectionLoaderAwareTrait
  • Charcoal\Cms\TemplateableTrait
  • Overview
  • Namespace
  • Class
  1: <?php
  2: 
  3: namespace Charcoal\Cms;
  4: 
  5: // From 'charcoal-object'
  6: use Charcoal\Object\Content;
  7: use Charcoal\Object\CategorizableInterface;
  8: use Charcoal\Object\CategorizableTrait;
  9: 
 10: // From 'charcoal-translator'
 11: use Charcoal\Translator\Translation;
 12: 
 13: // From 'charcoal-cms'
 14: use Charcoal\Cms\DocumentInterface;
 15: 
 16: /**
 17:  * Base document class.
 18:  */
 19: abstract class AbstractDocument extends Content implements
 20:     CategorizableInterface,
 21:     DocumentInterface
 22: {
 23:     use CategorizableTrait;
 24: 
 25:     /**
 26:      * @var Translation|string|null $name
 27:      */
 28:     private $name;
 29: 
 30:     /**
 31:      * @var string $file
 32:      */
 33:     private $file;
 34: 
 35:     /**
 36:      * @var string $basePath
 37:      */
 38:     private $basePath;
 39: 
 40:     /**
 41:      * @var string $baseUrl
 42:      */
 43:     private $baseUrl;
 44: 
 45:     /**
 46:      * @param  mixed $name The document name.
 47:      * @return self
 48:      */
 49:     public function setName($name)
 50:     {
 51:         $this->name = $this->translator()->translation($name);
 52:         return $this;
 53:     }
 54: 
 55:     /**
 56:      * @return Translation|string|null
 57:      */
 58:     public function name()
 59:     {
 60:         return $this->name;
 61:     }
 62: 
 63:     /**
 64:      * @param  string $file The file relative path / url.
 65:      * @return self
 66:      */
 67:     public function setFile($file)
 68:     {
 69:         $this->file = $file;
 70:         return $this;
 71:     }
 72: 
 73:     /**
 74:      * @return string
 75:      */
 76:     public function file()
 77:     {
 78:         return $this->file;
 79:     }
 80: 
 81:     /**
 82:      * @param  string $path The document base path.
 83:      * @return self
 84:      */
 85:     public function setBasePath($path)
 86:     {
 87:         $this->basePath = $path;
 88:         return $this;
 89:     }
 90: 
 91:     /**
 92:      * Get the base path, with a trailing slash.
 93:      *
 94:      * @return string
 95:      */
 96:     public function basePath()
 97:     {
 98:         if (!$this->basePath) {
 99:             return '';
100:         }
101:         return rtrim($this->basePath, '/').'/';
102:     }
103: 
104:     /**
105:      * @param  string $url The document base URL.
106:      * @return self
107:      */
108:     public function setBaseUrl($url)
109:     {
110:         $this->baseUrl = $url;
111:         return $this;
112:     }
113: 
114:     /**
115:      * Get the base url, with a trailing slash.
116:      *
117:      * @return string
118:      */
119:     public function baseUrl()
120:     {
121:         return rtrim($this->baseUrl, '/').'/';
122:     }
123: 
124:     /**
125:      * @return string
126:      */
127:     public function path()
128:     {
129:         return $this->basePath().$this->file();
130:     }
131: 
132:     /**
133:      * @return string
134:      */
135:     public function url()
136:     {
137:         return $this->baseUrl().$this->file();
138:     }
139: 
140:     /**
141:      * @return string
142:      */
143:     public function mimetype()
144:     {
145:         $p = $this->property('file');
146:         return $p->mimetype($this->path());
147:     }
148: 
149:     /**
150:      * Get the fiqlename (basename; without any path segment).
151:      *
152:      * @return string
153:      */
154:     public function filename()
155:     {
156:         return basename($this->file());
157:     }
158: 
159:     /**
160:      * Get the document's file size, in bytes.
161:      *
162:      * @return integer
163:      */
164:     public function filesize()
165:     {
166:         return filesize($this->path());
167:     }
168: }
169: 
API documentation generated by ApiGen