Source of file PageWithImage.php
Size: 2,002 Bytes - Last Modified: 2021-12-23T10:59:01+00:00
/var/www/docs.ssmods.com/process/src/code/PageWithImage.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 | <?php /** * Defines the SupportingProjectPage page type - initial code created by ss generator */ class PageWithImage extends Page implements RenderableAsPortlet, RenderableAsTwitterCard, SeoInformationProvider { // Brief summary to show on facebook and twitter when linking private static $db = array( 'ImageAttribution' => 'Varchar(255)', 'BriefIntroduction' => 'HTMLText' ); static $has_one = array( 'MainImage' => 'Image' ); // for rendering thumbnail when linked in facebook function getOGImage() { return $this->MainImage(); } function getCMSFields() { $fields = parent::getCMSFields(); $imagename = _t('PageWithImage.IMAGE', 'Image'); $fields->addFieldToTab( 'Root.'.$imagename, $uf = new UploadField('MainImage', _t('PageWithImage.MAIN_IMAGE', 'Main Image'))); $dirname = strtolower($this->ClassName).'s'; $uf->setFolderName($dirname); $fields->addFieldToTab('Root.'.$imagename, new TextField('ImageAttribution', 'Image Credit')); $fields->addFieldToTab('Root', new TextAreaField('BriefIntroduction', 'Brief description of the page for Twitter and Facebook purposes'), 'Content'); return $fields; } public function getPortletTitle() { return $this->Title; } public function getPortletImage() { return $this->MainImage(); } public function getPortletCaption() { return $this->BriefIntroduction; } public function getTwitterTitle() { return $this->Title; } public function getTwitterImage() { return $this->MainImage(); } public function getTwitterDescription() { return Convert::html2raw($this->BriefIntroduction); } public function getImagesForSeo() { $result = new ArrayList(); $mainimage = $this->owner->MainImage(); if ($mainimage) { $result->push($mainimage); } return $result; } public function getLinksForSeo() { $result = false; if ($this->hasExtension('LinksExtension')) { $result = $this->Links(); } return $result; } } class PageWithImage_Controller extends Page_Controller { } |