<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Symfony\Component\HttpFoundation\File\File as HttpFile;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Criteria;
use App\Entity\SiteConfig;
//use Doctrine\Common\Persistence\ObjectManagerAware;
//use Doctrine\Common\Persistence\ObjectManager;
//use Doctrine\Common\Persistence\Mapping\ClassMetadata;
/**
* Content is the primary element of the website
*
* @ORM\Entity(repositoryClass="App\Repository\ContentRepository")
* @Vich\Uploadable
*/
class Content /*implements ObjectManagerAware*/
{
const STATIC_PAGE = 0;
const PAGE = 1;
const POST = 2;
const CLASSIFIED = 3;
const DIRECTORY = 4;
const GALLERY = 5;
const LANDING_PAGE = 6;
const EVENT = 7;
const WEBINAR = 8;
const FORUM = 9;
const FORUM_TOPIC = 10;
const FORUM_REPLY = 11;
const MODULE = 12;
const HTML_AD = 13;
const PROMOS_REBATES = 14;
const THE_HUB = 15; //now known as RLW
const RLW = 15;
const EVENT_ORGANIZER = 16;
const EVENT_VENUE = 17;
const PODCAST = 18;
const EBOOK = 19;
const CONTEST_GAMES = 20;
// only used for migrating the data over
const ACF_FIELD_GROUP = 21;
const ACF_FIELD = 22;
// need to add these
const TRADE_ASSOCIATIONS = 23;
const THANK_YOU_LANDING_PAGE = 24;
const AWARD = 25;
const VIDEO = 26;
const R_CLUB_PERK = 27;
const SCHOLARSHIP = 28;
const TEMPLATE_FULL_WIDTH = 1;
const TEMPLATE_1_COL_SIDE = 2;
const TEMPLATE_2_COL_SIDE = 3;
const TEMPLATE_3_COL_SIDE = 4;
const STATUS_SCHEDULED = 2;
const STATUS_ACTIVE = 1;
const STATUS_INACTIVE = 0;
const STATUS_IN_REVIEW = -1;
const STATUS_EXPIRED = -2;
const STATUS_TRASH = -3;
const STATUS_SPAM = -4;
const STATUS_IN_CUSTOMER_REVIEW = -5;
const SITE_RCS = 1;
const SITE_AAR = 2;
const SITE_MCS = 3;
const SITE_CCS = 4;
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="bigint")
*/
private $id;
/**
* @ORM\Version @ORM\Column(type="integer")
*/
private $version;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Content", inversedBy="children", cascade={"persist"})
* @ORM\JoinColumn(nullable=true)
*/
private $prnt;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Content", mappedBy="prnt")
* @ORM\OrderBy({"published_at" = "DESC"})
*/
private $children;
/**
* @Vich\UploadableField(mapping="content_images", fileNameProperty="featured_image")
* @var File
*/
private $featured_image_data;
/**
* @ORM\Column(type="string", length=255)
*/
private $featured_image;
/**
* @ORM\Column(type="string", length=255)
*/
private $media_url;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Media", cascade={"persist"})
* @ORM\JoinColumn(nullable=true)
*/
private $media;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Media", cascade={"persist"})
* @ORM\JoinColumn(nullable=true)
*/
private $dummy_media; //In sonata admin, can't have multiple ModelListType fields of the same type... even if one is unmapped
//Delete this as soon as it's fixed, really don't want this here as it adds a field to the database
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Media", cascade={"persist"})
* @ORM\JoinColumn(nullable=true)
*/
private $video_media;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Site", inversedBy="content")
*/
private $site;
/**
* @ORM\Column(type="integer")
*/
private $type;
/**
* @ORM\Column(type="string", length=128)
*/
private $template;
/**
* @ORM\Column(type="string", length=255)
*/
private $title;
/**
* @ORM\Column(type="string", length=255)
*/
private $slug;
/**
* @ORM\Column(type="integer")
*/
private $searchable;
/**
* @ORM\Column(type="integer")
*/
private $exclude_from_list;
/**
* @ORM\Column(type="integer")
*/
private $permission;
/**
* @ORM\Column(type="integer")
*/
private $status;
/**
* @ORM\Column(type="integer")
*/
private $members_only;
/**
* @ORM\Column(type="integer")
*/
private $include_author_byline;
/**
* @ORM\Column(type="integer")
*/
private $include_author_bio;
/**
* @ORM\Column(type="integer")
*/
private $include_customer_call_to_action;
/**
* @ORM\Column(type="integer")
*/
private $include_customer_bio;
/**
* @ORM\Column(type="integer")
*/
private $total_impressions;
/**
* @ORM\Column(type="integer")
*/
private $total_clicks;
/**
* @ORM\Column(type="datetime")
*/
private $published_at;
/**
* @ORM\Column(type="datetime")
*/
private $modified_at;
/**
* @ORM\Column(type="datetime")
*/
private $created_at;
/**
* @ORM\Column(type="text")
*/
private $content_intro;
/**
* @ORM\Column(type="text")
*/
private $content_full;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="content")
* @ORM\JoinColumn(name="author_id", referencedColumnName="id", onDelete="SET NULL", nullable=true)
*/
private $author;
/**
* @ORM\OneToMany(targetEntity="App\Entity\ContentMeta", mappedBy="content", orphanRemoval=true, cascade={"persist", "remove"})
* @ O R M\JoinColumn(name="content_id", referencedColumnName="id", nullable=true, onDelete="CASCADE")
*
* I must be using onDeleteCascade incorrectly... - setting from the child now - see if works
*/
private $contentmeta;
/**
* @ORM\Column(type="string", length=255)
*/
private $meta_description;
/**
* @ORM\Column(type="string", length=255)
*/
private $meta_keywords;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Category", inversedBy="content")
*/
private $category;
/**
* Instead of referencing all content - there are more specific content properties below...
*
* @ O R M\ManyToMany(targetEntity="App\Entity\Customer", mappedBy="content")
* /
private $customers;
*/
/**
* @O R M\ManyToMany(targetEntity="App\Entity\Customer", mappedBy="promos_rebates_contests")
* /
private $customers_promos_rebates_contests;
/**
* @O R M\ManyToMany(targetEntity="App\Entity\Customer", mappedBy="hub_content")
* /
private $customers_hub_content;
/**
* @O R M\ManyToMany(targetEntity="App\Entity\Customer", mappedBy="coffee_shop_news")
* /
private $customers_coffee_shop_news;
*/
/**
* The secondary categories should contain ALL the categories assigned to the content object.
* @ORM\ManyToMany(targetEntity="App\Entity\Category", inversedBy="secondary_content")
*/
private $secondary_categories;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Customer", mappedBy="contents", cascade={"persist"})
*/
private $customers;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Customer", inversedBy="primaryContents")
*/
private $primaryCustomer;
/**
* @ O R M\ManyToMany(targetEntity="App\Entity\Content", inversedBy="main_content")
* @O R M\JoinTable(name="content_content",
* joinColumns={@ORM\JoinColumn(name="content_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="related_content_id", referencedColumnName="id")}
* )
* /
protected $related_contents;
*/
/**
* @ORM\OneToMany(targetEntity="App\Entity\Comment", mappedBy="content", orphanRemoval=true)
* @ORM\OrderBy({"created_at" = "ASC"})
*/
private $comments;
/**
* @ORM\Column(type="text")
*/
private $content_builder;
/**
* @ORM\OneToMany(targetEntity="App\Entity\PurchaseItem", mappedBy="content")
* @ORM\OrderBy({"purchase_date" = "DESC"})
*/
private $purchase_items;
/**
* @ORM\Column(type="boolean")
*/
private $showTitle;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $old_id;
/**
* @ORM\Column(type="integer")
*/
private $featured;
/**
* @ORM\Column(type="integer")
*/
private $announcement;
/**
* @ORM\Column(type="string", length=100)
*/
private $announcement_sites;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $expires_at;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Traffic", mappedBy="content", orphanRemoval=true, cascade={"persist", "remove"})
*/
private $traffic;
/**
* @ORM\OneToMany(targetEntity="App\Entity\ContentImpression", mappedBy="content", orphanRemoval=true, cascade={"persist", "remove"})
*/
private $impressions;
/**
* @ORM\OneToMany(targetEntity="App\Entity\ContentView", mappedBy="content", orphanRemoval=true, cascade={"persist", "remove"})
*/
private $views;
/**
* @ORM\OneToMany(targetEntity="App\Entity\ContentLinkClick", mappedBy="content", orphanRemoval=true, cascade={"persist", "remove"})
*/
private $link_clicks;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Lead", mappedBy="content", orphanRemoval=true, cascade={"persist", "remove"})
*/
private $leads;
/**
* @ORM\OneToOne(targetEntity="App\Entity\Customer", mappedBy="directory_content", cascade={"persist"})
*/
private $directory;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\MediaGroup", inversedBy="contents", cascade={"persist"})
*/
private $media_groups;
/* *
* @O R M\ManyToMany(targetEntity="App\Entity\MediaGroupContainer", inversedBy="contents", cascade={"persist"})
* /
private $media_group_containers;
*/
/**
* @ORM\OneToMany(targetEntity="App\Entity\MediaGroupContainer", mappedBy="content", orphanRemoval=true, cascade={"persist", "remove"})
*/
private $media_group_containers;
/**
* @ORM\OneToMany(targetEntity="App\Entity\MediaGroupItem", mappedBy="gallery", orphanRemoval=true, cascade={"persist", "remove"})
* @ORM\OrderBy({"sort" = "ASC"})
*/
private $galleryMediaItems;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Form", cascade={"persist"})
* @ORM\JoinColumn(nullable=true)
*/
private $form;
/**
* @ORM\OneToMany(targetEntity="App\Entity\ContentAnalyticsDaily", mappedBy="content", orphanRemoval=true, cascade={"persist", "remove"})
*/
private $content_analytics_daily;
/**
* @ORM\OneToMany(targetEntity="App\Entity\ContentAnalyticsCorrectionDaily", mappedBy="content", orphanRemoval=true, cascade={"persist", "remove"})
*/
private $content_analytics_correction_daily;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\MediaGroupItem", inversedBy="popout_contents", cascade={"persist"})
* @ORM\JoinColumn(name="popout_ad_id", referencedColumnName="id")
*/
private $popout_ad;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\HootsuiteSocialProfile", inversedBy="contents")
*/
private $hootsuite_social_profiles;
/**
* @ORM\Column(type="text")
*/
private $hootsuite_content;
/**
* @ORM\Column(type="text")
*/
private $hootsuite_facebook_content;
/**
* @ORM\Column(type="text")
*/
private $hootsuite_twitter_content;
/**
* @ORM\Column(type="text")
*/
private $hootsuite_linkedin_content;
/**
* @ORM\Column(type="integer")
*/
private $hootsuite_to_publish;
/**
* @ORM\Column(type="integer")
*/
private $hootsuite_use_post_media;
/**
* @ORM\Column(type="integer")
*/
private $hootsuite_use_post_published_at;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Media", cascade={"persist"})
* @ORM\JoinColumn(nullable=true)
*/
private $hootsuite_media;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $hootsuite_published_at;
/**
* @ORM\OneToMany(targetEntity="App\Entity\HootsuiteMessage", mappedBy="content", orphanRemoval=true, cascade={"persist", "remove"})
*/
private $hootsuite_messages;
public function __construct()
{
$this->title = "";
$this->showTitle = 1;
//$this->site = SELF::SITE_RCS;
$this->site = new ArrayCollection();
$this->type = 1;
$this->status = SELF::STATUS_INACTIVE;
$this->members_only = 0;
$this->include_author_byline = 0;
$this->include_author_bio = 1;
$this->include_customer_call_to_action = 1;
$this->include_customer_bio = 1;
$this->total_impressions = 0;
$this->total_clicks = 0;
$this->template = 2;
$this->searchable = 1;
$this->exclude_from_list = 0;
$this->permission = 0;
$this->slug = "";
$this->content_intro = "";
$this->content_full = "";
$this->published_at = new \DateTime();
$this->modified_at = new \DateTime();
$this->created_at = new \DateTime ();
$this->meta_description = "";
$this->meta_keywords = "";
$this->content_builder = "";
$this->show_title = 0;
$this->old_id = 0;
$this->featured = 0;
$this->announcement = 0;
$this->announcement_sites = "";
$this->contentmeta = new ArrayCollection();
$this->featured_image = "";
/* Multiple?
$this->categories = new ArrayCollection();
*/
/*
$this->customers_promos_rebates_contests = new ArrayCollection();
$this->customers_hub_content = new ArrayCollection();
$this->customers_coffee_shop_news = new ArrayCollection();
*/
$this->customers = new ArrayCollection();
$this->secondary_categories = new ArrayCollection();
$this->children = new ArrayCollection();
$this->comments = new ArrayCollection();
$this->purchase_items = new ArrayCollection();
$this->media_group_containers = new ArrayCollection();
$this->media_groups = new ArrayCollection();
$this->hootsuite_social_profiles = new ArrayCollection();
$this->hootsuite_messages = new ArrayCollection();
$this->hootsuite_content = "";
$this->hootsuite_facebook_content = "";
$this->hootsuite_twitter_content = "";
$this->hootsuite_linkedin_content = "";
$this->hootsuite_to_publish = 0;
$this->hootsuite_use_post_media = 1;
$this->hootsuite_use_post_published_at = 1;
}
public function __clone() {
$this->id = null;
$this->title = $this->title . " - copy";
$this->slug = $this->slug . "-copy";
$this->status = self::STATUS_INACTIVE;
$this->total_impressions = 0;
$this->total_clicks = 0;
$this->customers = new ArrayCollection();
$this->contentmeta = new ArrayCollection();
$this->media_group_containers = new ArrayCollection();
$this->media_groups = new ArrayCollection();
$this->published_at = new \DateTime();
$this->modified_at = new \DateTime();
$this->created_at = new \DateTime ();
}
/*
//Removing interface after update 2021/08/04
//Doesn't seem to be in use anyway
public function injectObjectManager(
ObjectManager $objectManager,
ClassMetadata $classMetadata
) {
$this->em = $objectManager;
}
*/
public function getFeaturedImageData(): ?HttpFile
{
return $this->featured_image_data;
}
public function setFeaturedImageData(HttpFile $data = null): self
{
/* prevent nulls - ... we want nulls
if (!$data) {
$data = "";
}
*/
if ($data == null) {
if ($this->featured_image) {
$this->removeFeaturedImage();
}
}
$this->featured_image_data = $data;
$this->modified_at = new \DateTime("now");
/*
if ($data) {
// $this->extension = $data->guessExtension();
// $this->type = $data->getMimeType();
$this->modified_at = new \DateTime("now");
}
*/
return $this;
}
public function removeFeaturedImage ()
{
$file = $this->featured_image;
if ($file) {
// can't find an easy way to remove the image right away - simple hack should work...
$file = dirname(dirname(dirname(__FILE__)))."/public/uploads/content/{$file}";
if (file_exists($file)) {
unlink($file);
}
$this->featured_image = "";
$this->featured_image_data = null;
}
}
public function getFeaturedImage(): ?string
{
return $this->featured_image;
}
public function setFeaturedImage(string $image = null): self
{
// prevent nulls
if (!$image) {
$image = "";
}
$this->featured_image = $image;
return $this;
}
public function getFeaturedImageURL ()
{
if($this->media) {
return $this->media->getURL();
}
elseif ($this->featured_image) {
return "/uploads/content/{$this->featured_image}";
}
return "";
}
public function getFeaturedImageTag ($class = "", $style = "")
{
if($this->getType() == 4 && $this->getDirectory()) {
if($this->getDirectory()->getMedia()) {
return $this->getDirectory()->getMedia()->getImageTag($class, $style);
}
}
elseif($this->media) {
return $this->media->getImageTag($class, $style);
}
return "";
}
public function hasVideoMedia() {
return $this->video_media ? true : false;
}
public function getVideoMediaURL ()
{
if($this->video_media) {
return $this->video_media->getURL();
}
return "";
}
public function getVideoMediaTag ($class = "", $style = "", $autoplay = false, $controls = true, $muted = false, $thumbnailUrl="")
{
if($this->video_media) {
return $this->video_media->getVideoTag($class, $style, "", "", true, $autoplay, $controls, $muted, $thumbnailUrl);
}
else {
$this->getFeaturedImageTag($class, $style);
}
return "";
}
public function getMediaURL ()
{
return $this->media_url;
}
public function setMediaURL ($url)
{
$this->media_url = $url;
return $this;
}
public function getMedia (): ?Media
{
return $this->media;
}
public function setMedia (Media $media = null): self
{
$this->media = $media;
return $this;
}
public function getDummyMedia (): ?Media
{
return $this->dummy_media;
}
public function setDummyMedia (Media $dummy_media = null): self
{
$this->dummy_media = $dummy_media;
return $this;
}
public function getVideoMedia (): ?Media
{
return $this->video_media;
}
public function setVideoMedia (Media $video_media = null): self
{
$this->video_media = $video_media;
return $this;
}
public function getId ()
{
return $this->id;
}
public function getVersion() {
return $this->version;
}
public function setVersion(int $version): self
{
$this->version = $version;
return $this;
}
public function decrementVersion()
{
$this->version = $this->version - 1;
}
public function getPrnt(): ?self
{
return $this->prnt;
}
public function setPrnt(self $parent = null): self
{
$this->prnt = $parent;
return $this;
}
/*
public function getSite(): ?int
{
return $this->site;
}
public function setSite(int $site): self
{
$this->site = $site;
return $this;
}
public function getSiteTextShort()
{
$site = $this->getSite();
if($site) {
switch($site) {
case SELF::SITE_RCS:
return "RCS";
case SELF::SITE_AAR:
return "AAR";
}
}
return "";
}
*/
/**
* @return Collection|Site[]
*/
public function getSite(): Collection
{
return $this->site;
}
public function getSites(): Collection
{
return $this->site;
}
public function setSites($sites)
{
$this->site = $sites;
return $this;
}
public function addSite(Site $site): self
{
if (!$this->site->contains($site)) {
$this->site[] = $site;
$site->addContent($this);
}
return $this;
}
public function resetSite(): self
{
$this->site = new ArrayCollection();
return $this;
}
public function removeSite(Site $site): self
{
if ($this->site->contains($site)) {
$this->site->removeElement($site);
$site->removeContent($this);
}
return $this;
}
public function getSiteTextShort()
{
$site_texts = [];
foreach($this->getSites() as $s) {
$site_texts[] = $s->getSiteTextShort();
}
return implode(", ", $site_texts);
}
public function getSiteIds()
{
$site_ids = [];
foreach($this->getSites() as $s) {
$site_ids[] = $s->getId();
}
return $site_ids;
}
public function getType(): ?int
{
return $this->type;
}
public static function getTypeTextStatic($type)
{
switch ($type) {
case self::STATIC_PAGE:
return "Static Page";
case self::PAGE:
return "Page";
case self::POST:
return "Post";
case self::CLASSIFIED:
return "Classified Listing";
case self::DIRECTORY:
return "Directory Listing";
case self::GALLERY:
return "Gallery";
case self::LANDING_PAGE:
return "Landing Page";
case self::EVENT:
return "Event";
case self::WEBINAR:
return "Webinar";
case self::FORUM:
return "Forum";
case self::FORUM_TOPIC:
return "Forum Topic";
case self::FORUM_REPLY:
return "Forum Reply";
case self::MODULE:
return "Module";
case self::HTML_AD:
return "HTML Ad";
case self::PROMOS_REBATES:
return "Promos and Rebates";
case self::THE_HUB:
return "Read Listen Watch";
case self::EVENT_ORGANIZER:
return "Event Organizer";
case self::EVENT_VENUE:
return "Event Venue";
case self::PODCAST:
return "Podcast";
case self::EBOOK:
return "Ebook";
case self::CONTEST_GAMES:
return "Contests and Games";
case self::TRADE_ASSOCIATIONS:
return "Trade Associations";
case self::THANK_YOU_LANDING_PAGE:
return "Thank You Page";
case self::AWARD:
return "Award";
case self::VIDEO:
return "Video";
case self::R_CLUB_PERK:
return "R-Club Perk";
case self::SCHOLARSHIP:
return "Scholarship";
}
return "Content";
}
public function getTypeText()
{
switch ($this->type) {
case self::STATIC_PAGE:
return "Static Page";
case self::PAGE:
return "Page";
case self::POST:
return "Post";
case self::CLASSIFIED:
return "Classified Listing";
case self::DIRECTORY:
return "Directory Listing";
case self::GALLERY:
return "Gallery";
case self::LANDING_PAGE:
return "Landing Page";
case self::EVENT:
return "Event";
case self::WEBINAR:
return "Webinar";
case self::FORUM:
return "Forum";
case self::FORUM_TOPIC:
return "Forum Topic";
case self::FORUM_REPLY:
return "Forum Reply";
case self::MODULE:
return "Module";
case self::HTML_AD:
return "HTML Ad";
case self::PROMOS_REBATES:
return "Promos and Rebates";
case self::THE_HUB:
return "Read Listen Watch";
case self::EVENT_ORGANIZER:
return "Event Organizer";
case self::EVENT_VENUE:
return "Event Venue";
case self::PODCAST:
return "Podcast";
case self::EBOOK:
return "Ebook";
case self::CONTEST_GAMES:
return "Contests and Games";
case self::TRADE_ASSOCIATIONS:
return "Trade Associations";
case self::THANK_YOU_LANDING_PAGE:
return "Thank You Page";
case self::AWARD:
return "Award";
case self::VIDEO:
return "Video";
case self::R_CLUB_PERK:
return "R-Club Perk";
case self::SCHOLARSHIP:
return "Scholarship";
}
return "Content";
}
public function getTypeString ()
{
return $this->getTypeText();
}
public function setType(int $type): self
{
$this->type = $type;
return $this;
}
public function getTemplate(): ?string
{
return $this->template;
}
public function setTemplate(string $template): self
{
$this->template = $template;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function getTitleClean()
{
return preg_replace('/[^A-Za-z0-9 \-\.]/', ' ', $this->title); //remove special characters
}
public function setTitle(string $title = null): self
{
$this->title = $title ? preg_replace('~\x{00a0}~siu', ' ', $title) : "";
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug = null): self
{
$this->slug = $slug ? $slug : "";
return $this;
}
public function getSearchable(): ?int
{
return $this->searchable;
}
public function setSearchable(int $searchable): self
{
$this->searchable = $searchable;
return $this;
}
public function getExcludeFromList(): ?int
{
return $this->exclude_from_list;
}
public function setExcludeFromList(int $exclude_from_list): self
{
$this->exclude_from_list = $exclude_from_list;
return $this;
}
public function getPermission(): ?int
{
return $this->permission;
}
public function setPermission(int $permission): self
{
$this->permission = $permission;
return $this;
}
public function getStatus(): ?int
{
return $this->status;
}
public function getStatusText ()
{
switch ($this->status) {
case self::STATUS_SCHEDULED:
return "Scheduled";
case self::STATUS_ACTIVE:
return "Active";
case self::STATUS_INACTIVE:
return "Draft";
case self::STATUS_IN_REVIEW:
return "In Review";
case self::STATUS_EXPIRED:
return "Expired";
case self::STATUS_TRASH:
return "Trash";
case self::STATUS_SPAM:
return "Spam";
}
return "Inactive";
}
public function setStatus(int $status): self
{
$this->status = $status;
return $this;
}
/*
public function getMembersOnly(): ?int
{
return $this->members_only;
}
public function setMembersOnly(int $members_only): self
{
$this->members_only = $members_only;
return $this;
}
*/
public function getMembersOnly(): ?bool
{
return $this->members_only == 1;
}
public function setMembersOnly(bool $value): self
{
$this->members_only = $value ? 1 : 0;
return $this;
}
public function getIncludeAuthorByline(): ?bool
{
return $this->include_author_byline == 1;
}
public function setIncludeAuthorByline(bool $value): self
{
$this->include_author_byline = $value ? 1 : 0;
return $this;
}
public function getIncludeAuthorBio(): ?bool
{
return $this->include_author_bio == 1;
}
public function setIncludeAuthorBio(bool $value): self
{
$this->include_author_bio = $value ? 1 : 0;
return $this;
}
public function getIncludeCustomerCallToAction(): ?bool
{
return $this->include_customer_call_to_action == 1;
}
public function setIncludeCustomerCallToAction(bool $value): self
{
$this->include_customer_call_to_action = $value ? 1 : 0;
return $this;
}
public function getIncludeCustomerBio(): ?bool
{
return $this->include_customer_bio == 1;
}
public function setIncludeCustomerBio(bool $value): self
{
$this->include_customer_bio = $value ? 1 : 0;
return $this;
}
public function getTotalImpressions(): ?int
{
return $this->total_impressions;
}
public function setTotalImpressions(int $total_impressions): self
{
$this->total_impressions = $total_impressions;
return $this;
}
public function incrementTotalImpressions(): self
{
$this->total_impressions = $this->total_impressions + 1;
return $this;
}
public function getTotalClicks(): ?int
{
return $this->total_clicks;
}
public function setTotalClicks(int $total_clicks): self
{
$this->total_clicks = $total_clicks;
return $this;
}
public function incrementTotalClicks(): self
{
$this->total_clicks = $this->total_clicks + 1;
return $this;
}
public function getPublishedAt(): ?\DateTimeInterface
{
return $this->published_at;
}
public function setPublishedAt(\DateTimeInterface $scheduled_for): self
{
$this->published_at = $scheduled_for;
return $this;
}
public function getModifiedAt(): ?\DateTimeInterface
{
return $this->modified_at;
}
public function setModifiedAt(\DateTimeInterface $modified_at): self
{
$this->modified_at = $modified_at;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeInterface $created_at): self
{
$this->created_at = $created_at;
return $this;
}
public function getContentIntro(): ?string
{
return $this->content_intro;
}
public function setContentIntro(string $content_intro = null): self
{
$this->content_intro = $content_intro ? $content_intro : "";
return $this;
}
//Return the raw text of the content_intro if available, or else the start of content_full
public function getIntroText($words = 50): ?string
{
$content = strip_tags($this->content_intro);
$content = preg_replace("~(?:\[/?)[^/\]]+/?\]~s", '', $content); //strip short codes
$content = preg_replace('~\x{00a0}~siu', ' ', $content);
$content = str_replace(' ',' ',$content);
$content = trim($content);
if (!$content) {
$content = strip_tags($this->content_full);
$content = preg_replace("~(?:\[/?)[^/\]]+/?\]~s", '', $content);
$content = preg_replace('~\x{00a0}~siu', ' ', $content);
$content = str_replace(' ',' ',$content);
$content = trim($content);
}
$content = explode(" ", $content);
if ($words < count($content)) {
$content = array_slice($content, 0, $words);
$content[] = "...";
}
$content = implode(" ", $content);
$content = htmlspecialchars_decode($content, ENT_QUOTES);
$content = html_entity_decode($content);
return $content;
}
public function getContentFull(): ?string
{
return $this->content_full;
}
public function getContent_full (): ?string
{
return $this->content_full;
}
public function hasContent ()
{
$content = str_replace(array(" ", " "), "", $this->content_full);
return $content !== "";
}
public function setContentFull(string $content_full = null): self
{
/*
//Can't do this, not safe
if($content_full) {
$content_full = htmlspecialchars_decode($content_full, ENT_QUOTES);
}
*/
$this->content_full = $content_full ? $content_full : "";
return $this;
}
public function getAuthor(): ?User
{
return $this->author;
}
public function setAuthor(?User $author = null): self
{
$this->author = $author;
return $this;
}
/**
* @return Collection|ContentMeta[]
*/
public function getContentmeta(): Collection
{
return $this->contentmeta;
}
/*
public function getContentmetaArray()
{
$return = array();
foreach( $this->contentmeta as meta) {
$return["metakey"] = meta["metavalue"];
}
return $return;
}
*/
//only works with unique keys, otherwise returns the first
public function getContentMetaByKey ($key = "")
{
foreach ($this->contentmeta as $meta) {
if ($meta->getMetakey() == $key) {
return $meta;
}
}
return null;
}
public function getContentMetaValueByKey ($key = "")
{
$meta = $this->getContentMetaByKey($key);
if ($meta) {
return $meta->getMetavalue();
}
return "";
}
// sets the content meta with the provided certain key / value, or changes it if one with that key already exists
public function setContentmetum($key = "", $value = "")
{
$meta = $this->getContentMetaByKey($key);
if ($meta) {
$meta->setMetavalue($value);
}
else {
$meta = new ContentMeta();
$meta->setMetakey($key);
$meta->setMetavalue($value);
$this->addContentMetum($meta);
}
}
// adds content meta with the provided key / value, even if one with that key already exists
public function addContentMetumKV($key = "", $value = ""): self
{
$meta = new ContentMeta();
$meta->setMetakey($key);
$meta->setMetavalue($value);
$this->addContentMetum($meta);
return $this;
}
public function removeContentMetumKV($key = "", $value = ""): self
{
foreach ($this->contentmeta as $meta) {
if ($meta->getMetakey() == $key && $meta->getMetavalue() == $value) {
$this->removeContentmetum($meta);
}
}
return $this;
}
public function addContentMetum(ContentMeta $contentmetum): self
{
if (!$this->contentmeta->contains($contentmetum)) {
$this->contentmeta[] = $contentmetum;
$contentmetum->setContent($this);
}
return $this;
}
public function removeContentmetum(ContentMeta $contentmetum): self
{
if ($this->contentmeta->contains($contentmetum)) {
$this->contentmeta->removeElement($contentmetum);
// set the owning side to null (unless already changed)
if ($contentmetum->getContent() === $this) {
$contentmetum->setContent(null);
}
}
return $this;
}
// value is not required
public function countContentMetum($key = "", $value = ""): int
{
$count = 0;
foreach ($this->contentmeta as $meta) {
if ($meta->getMetakey() == $key) {
if($value) {
if($meta->getMetavalue() == $value) {
$count++;
}
}
else {
$count++;
}
}
}
return $count;
}
public function countLikes()
{
return $this->countContentMetum("_like_user_id");
}
public function __toString ()
{
return $this->title ? $this->title : '';
}
public function getMetaDescription(): ?string
{
return $this->meta_description;
}
public function setMetaDescription(string $meta_description = null): self
{
$this->meta_description = $meta_description ? $meta_description : "";
return $this;
}
public function getMetaKeywords(): ?string
{
return $this->meta_keywords;
}
public function setMetaKeywords(string $meta_keywords = null): self
{
$this->meta_keywords = $meta_keywords ? $meta_keywords : "";
return $this;
}
public function toArray ()
{
$return = [];
foreach ($this as $key => $value) {
$return[$key] = $value;
}
return $return;
}
public function getCategory(): ?Category
{
return $this->category;
}
public function setCategory(?Category $category): self
{
//remove the previous primary category from the list of all categories
//(is there a better way to do this?
if($this->category) {
$this->removeSecondaryCategory($this->category);
}
// also make sure category is set in the secondary categories too.
if($category) {
$this->addSecondaryCategory($category);
}
$this->category = $category;
return $this;
}
/**
* @return Collection|Category[]
*/
public function getSecondaryCategories(): Collection
{
return $this->secondary_categories;
}
public function addSecondaryCategory(Category $secondaryCategory): self
{
if (!$this->secondary_categories->contains($secondaryCategory)) {
$this->secondary_categories[] = $secondaryCategory;
$secondaryCategory->addSecondaryContent($this);
}
return $this;
}
public function resetSecondaryCategories(): self
{
$this->secondary_categories = new ArrayCollection();
// retain the primary category if it exists
if ($this->category) {
$this->addSecondaryCategory($this->category);
}
return $this;
}
public function removeSecondaryCategory(Category $secondaryCategory): self
{
if ($this->secondary_categories->contains($secondaryCategory)) {
$this->secondary_categories->removeElement($secondaryCategory);
$secondaryCategory->removeSecondaryContent($this);
}
return $this;
}
public function getSecondaryCategoriesByTaxonomy ($taxonomy = "")
{
$return = new ArrayCollection();
$categories = $this->secondary_categories;
foreach ($categories as $category) {
if ($category->getTaxonomy() == $taxonomy) {
$return[] = $category;
}
}
return $return;
}
public function getPostCategories()
{
$return = [];
$categories = $this->secondary_categories;
foreach ($categories as $category) {
if ($category->getTaxonomy() == "category" || $category->getTaxonomy() == "aar_category") {
$return[] = $category->getTitle();
}
}
return implode(", ", $return);
}
/**
* @return Collection|Children[]
*/
public function getChildren(): Collection
{
return $this->children;
}
/*
public function getPCDate()
{
$criteria = Criteria::create()
->where(Criteria::expr()->eq("status", "1"))
->orderBy(["published_at" => Criteria::DESC])
->setMaxResults(1)
;
$lc = $this->getChildren()->matching($criteria);
if($lc && $lc->getPublishedAt() > $this->getPublishedAt()) {
$lc->getPublishedAt();
}
return $this->getPublishedAt();
}*/
/**
* This works - but uses a very large amount of memory.
* TODO - move into the controller
* /
public function countActiveGrandchildren() */
public function getActiveChildren(): Collection
{
$criteria = Criteria::create()
->where(Criteria::expr()->eq("status", "1"))
->orderBy(["published_at" => Criteria::DESC])
;
return $this->getChildren()->matching($criteria);
}
public function addChildren(Content $children): self
{
if (!$this->children->contains($children)) {
$this->children[] = $children;
$children->setPrnt($this);
}
return $this;
}
public function removeChildren(Content $children): self
{
if ($this->children->contains($children)) {
$this->children->removeElement($children);
// set the owning side to null (unless already changed)
if ($children->getPrnt() === $this) {
$children->setPrnt(null);
}
}
return $this;
}
/*
public function getRelatedContents(): Collection
{
return $this->related_contents;
}
public function addRelatedContents(Content $content): self
{
// if (!$this->related_contents->contains($content)) {
$this->related_contents[] = $content;
//$children->setPrnt($this);
// }
return $this;
}
public function removeRelatedContents(Content $content): self
{
if ($this->related_contents->contains($content)) {
$this->related_contents->removeElement($content);
// set the owning side to null (unless already changed)
//if ($children->getPrnt() === $this) {
//$children->setPrnt(null);
//}
}
return $this;
}
*/
public function getPrimaryCustomer(): ?Customer
{
return $this->primaryCustomer;
}
public function getPrimaryCustomerTitleClean()
{
return $this->primaryCustomer ? $this->primaryCustomer->getTitleClean() : "";
}
public function setPrimaryCustomer(?Customer $customer): self
{
//remove the previous primary customer from the list of all customers
//if($this->primaryCustomer) {
// $this->removeCustomer($this->primaryCustomer);
//}
// also make sure customer is set in the secondary customers too.
if($customer) {
$this->addCustomer($customer);
}
$this->primaryCustomer = $customer;
return $this;
}
/**
* @return Collection|Customer[]
*/
public function getCustomers(): Collection
{
return $this->customers;
}
public function getCustomerTitles()
{
$titles = [];
foreach($this->customers as $customer) {
$titles[] = $customer->getTitleClean();
}
return implode(", ", $titles);
}
//don't think Sonata is using this
public function addCustomers($customers): self
{
if(is_array($customers)) {
foreach($customers as $customer) {
$this->addCustomer($customer);
}
}
else {
$this->customers->clear();
$this->addCustomer($customers);
}
return $this;
}
public function addCustomer(Customer $customer): self
{
if (!$this->customers->contains($customer)) {
$this->customers[] = $customer;
$customer->addContent($this);
}
return $this;
}
public function removeCustomer(Customer $customer): self
{
if ($this->customers->contains($customer)) {
$this->customers->removeElement($customer);
$customer->removeContent($this);
}
return $this;
}
public function resetCustomers(): self
{
foreach($this->customers as $customer) {
$this->removeCustomer($customer);
}
return $this;
}
public function setCustomers($customers) {
$this->customers = $customers;
return $this;
}
// This is used for the forum replies column
public function countUniqueChildrenAuthors(): int
{
//$authors[] = $this->getAuthor();
$authors = array();
foreach($this->getActiveChildren() as $child) {
$authors[] = $child->getAuthor();
}
return count(array_unique($authors));
}
/**
* @return Collection|Comment[]
*/
public function getComments(): Collection
{
return $this->comments;
}
public function addComment(Comment $comment): self
{
if (!$this->comments->contains($comment)) {
$this->comments[] = $comment;
$comment->setContent($this);
}
return $this;
}
public function removeComment(Comment $comment): self
{
if ($this->comments->contains($comment)) {
$this->comments->removeElement($comment);
// set the owning side to null (unless already changed)
if ($comment->getContent() === $this) {
$comment->setContent(null);
}
}
return $this;
}
public function getAge ()
{
// TODO - ...
// EG has twig function - use that instead
}
public function getContentBuilder(): ?string
{
return $this->content_builder;
}
public function setContentBuilder(string $content_builder): self
{
$this->content_builder = $content_builder;
return $this;
}
/**
* @return Collection|Order[]
*/
public function getPurchaseItems(): Collection
{
return $this->purchase_items;
}
public function addPurchaseItem(PurchaseItem $order): self
{
if (!$this->purchase_items->contains($order)) {
$this->purchase_items[] = $order;
$order->setContent($this);
}
return $this;
}
public function removePurchaseItem(PurchaseItem $order): self
{
if ($this->purchase_items->contains($order)) {
$this->purchase_items->removeElement($order);
// set the owning side to null (unless already changed)
if ($order->getContent() === $this) {
$order->setContent(null);
}
}
return $this;
}
// - is this needed
public function getCurrentPurchase (): ?Purchase
{
$purchase_item = $this->purchase_items->first();
if($purchase_item) {
return $purchase_item->getPurchase();
}
else {
return null;
}
}
public function getCurrentPurchaseItem (): ?PurchaseItem
{
$purchase_item = $this->purchase_items->first();
if($purchase_item) {
return $purchase_item;
}
else {
return null;
}
}
//returns the latest purchase item that HAS an associated Purchase object
public function getCurrentActivePurchaseItem (): ?PurchaseItem
{
$purchase_items = $this->purchase_items;
foreach($purchase_items as $purchase_item) {
$purchase = $purchase_item->getPurchase();
if($purchase) {
return $purchase_item;
}
}
return null;
}
public function getURL ($site_id = "")
{
switch ($this->type) {
case self::STATIC_PAGE:
return "/{$this->slug}";
case self::PAGE:
return "/{$this->slug}";
case self::POST:
return "/post/{$this->slug}";
case self::CLASSIFIED:
return "/listing/{$this->slug}";
case self::DIRECTORY:
return "/directory/{$this->slug}";
case self::GALLERY:
return "/gallery/{$this->slug}";
case self::LANDING_PAGE: //TODO: Handle this better
if($site_id) {
return '/' . SiteConfig::CONFIGS[$site_id]['site_code'] . "/{$this->slug}";
}
else {
if(in_array(SELF::SITE_AAR, $this->getSiteIds())) {
return "/aar/{$this->slug}";
}
elseif(in_array(SELF::SITE_MCS, $this->getSiteIds())) {
return "/mcs/{$this->slug}";
}
elseif(in_array(SELF::SITE_CCS, $this->getSiteIds())) {
return "/ccs/{$this->slug}";
}
return "/rcs/{$this->slug}";
}
case self::THANK_YOU_LANDING_PAGE:
return "/thank-you/{$this->slug}";
case self::FORUM:
return "/forum/{$this->slug}";
case self::FORUM_TOPIC:
return "/forum/topic/{$this->slug}";
case self::FORUM_REPLY:
if ($this->getPrnt()) {
return "/forum/topic/{$this->getPrnt()->getSlug()}";
}
return "/forum/topic/{$this->getSlug()}";
case self::PROMOS_REBATES:
return "/promos-rebates/{$this->slug}";
case self::THE_HUB:
return "/rlw/{$this->slug}";
case self::PODCAST:
return "/podcast/{$this->slug}";
case self::WEBINAR:
return "/webinar/{$this->slug}";
case self::EBOOK:
return "/ebooks/{$this->slug}";
case self::CONTEST_GAMES:
return "/contests-and-games/{$this->slug}";
case self::EVENT:
return "/event/{$this->slug}";
case self::AWARD:
return "/award/{$this->slug}";
case self::VIDEO:
return "/video/{$this->slug}";
case self::R_CLUB_PERK:
return "/r-club-perk/{$this->slug}";
case self::SCHOLARSHIP:
return "/scholarship/{$this->slug}";
}
return "#";
}
public function getFullURL($site_id_preferred = "") {
$site_ids = $this->getSiteIds();
if(in_array($site_id_preferred, $site_ids)) {
return "https://www." . SiteConfig::CONFIGS[$site_id_preferred]['base_url'] . $this->getURL($site_id_preferred);
}
foreach($site_ids as $site_id) {
return "https://www." . SiteConfig::CONFIGS[$site_id]['base_url'] . $this->getURL($site_id);
}
return "";
}
public function getFullURLs($site_id = "") {
$site_ids = $site_id ? [$site_id] : $this->getSiteIds();
$urls = [];
foreach($site_ids as $site_id) {
$urls[] = "https://www." . SiteConfig::CONFIGS[$site_id]['base_url'] . $this->getURL($site_id);
}
return implode(", ", $urls);
}
//Used for getting links from content admin pages
public function getFullURLTags() {
$site_ids = $this->getSiteIds();
$return = "";
foreach($site_ids as $site_id) {
$url = $this->getFullURL($site_id);
$return .= "<a href='{$url}' target='blank'>{$url}</a><br>";
}
return $return;
}
public function getAbsoluteURL() {
return $this->getFullURL();
}
public function getFullDevURL($site_id = "") {
$site_ids = $site_id ? [$site_id] : $this->getSiteIds();
foreach($site_ids as $site_id) {
if($site_id == SELF::SITE_AAR) {
return "https://dev." . SiteConfig::CONFIGS[$site_id]['base_url'] . $this->getURL($site_id);
}
return "https://staging." . SiteConfig::CONFIGS[$site_id]['base_url'] . $this->getURL($site_id);
}
return "";
}
//Used for getting links from content admin pages
public function getFullDevURLTags() {
$site_ids = $this->getSiteIds();
$return = "";
foreach($site_ids as $site_id) {
$url = $this->getFullDevURL($site_id);
$return .= "<a href='{$url}' target='blank'>{$url}</a><br>";
}
return $return;
}
public function getAdminEditURL() {
$type_slug = "content";
switch ($this->type) {
case self::STATIC_PAGE:
$type_slug = "staticpage";
break;
case self::PAGE:
$type_slug = "page";
break;
case self::POST:
$type_slug = "post";
break;
case self::CLASSIFIED:
$type_slug = "classified";
break;
case self::DIRECTORY:
$type_slug = "directory";
break;
case self::GALLERY:
$type_slug = "gallery";
break;
case self::LANDING_PAGE:
$type_slug = "landingpage";
break;
case self::FORUM:
$type_slug = "forum";
break;
case self::FORUM_TOPIC:
$type_slug = "forumtopic";
break;
case self::FORUM_REPLY:
$type_slug = "forumreply";
break;
case self::PROMOS_REBATES:
$type_slug = "promosrebates";
break;
case self::THE_HUB:
$type_slug = "thehub";
break;
case self::PODCAST:
$type_slug = "podcast";
$category = $this->getCategory();
if($category && $category->getSlug() == "partner-podcast") {
$type_slug = "partnerpodcast";
}
break;
case self::WEBINAR:
$type_slug = "webinar";
$category = $this->getCategory();
if($category && $category->getSlug() == "partner-webinar") {
$type_slug = "partnerwebinar";
}
break;
case self::EBOOK:
$type_slug = "ebook";
break;
case self::CONTEST_GAMES:
$type_slug = "contestsgames";
break;
case self::EVENT:
$type_slug = "event";
break;
case self::AWARD:
$type_slug = "award";
break;
case self::VIDEO:
$type_slug = "video";
break;
case self::R_CLUB_PERK:
$type_slug = "rclubperk";
break;
case self::SCHOLARSHIP:
$type_slug = "scholarship";
break;
}
if($type_slug == "directory") {
$customer = $this->getDirectory();
if($customer) {
return "/admin/app/customer/".$customer->getId()."/edit";
}
}
$site_id = $this->getSiteIds();
$site_id = $site_id[0];
return "/admin/{$type_slug}/".$this->getId()."/edit?site=".$site_id; //todo: if not current site, send to master admin view
}
//TODO: clean this up
public static function getSitesForContentType($type) {
switch ($type) {
case self::PAGE:
return [self::SITE_RCS, self::SITE_AAR, self::SITE_MCS, self::SITE_CCS];
case self::POST:
return [self::SITE_RCS, self::SITE_AAR, self::SITE_MCS, self::SITE_CCS];
case self::CLASSIFIED:
return [self::SITE_RCS, self::SITE_MCS, self::SITE_CCS];
case self::DIRECTORY:
return [self::SITE_RCS, self::SITE_MCS, self::SITE_CCS];
case self::GALLERY:
return [self::SITE_RCS, self::SITE_AAR, self::SITE_MCS, self::SITE_CCS]; //TODO: Partner gallery? Handle differently in individual admin pages?
case self::LANDING_PAGE:
return [self::SITE_RCS, self::SITE_AAR, self::SITE_MCS, self::SITE_CCS];
case self::FORUM:
return [self::SITE_RCS, self::SITE_AAR, self::SITE_MCS, self::SITE_CCS];
case self::FORUM_TOPIC:
return [self::SITE_RCS, self::SITE_AAR, self::SITE_MCS, self::SITE_CCS];
case self::FORUM_REPLY:
return [self::SITE_RCS, self::SITE_AAR, self::SITE_MCS, self::SITE_CCS];
case self::PROMOS_REBATES:
return [self::SITE_RCS, self::SITE_MCS, self::SITE_CCS];
case self::THE_HUB:
return [self::SITE_RCS, self::SITE_MCS, self::SITE_CCS];
case self::PODCAST:
return [self::SITE_RCS, self::SITE_AAR, self::SITE_MCS, self::SITE_CCS];
case self::WEBINAR:
return [self::SITE_RCS, self::SITE_MCS, self::SITE_CCS];
case self::EBOOK:
return [self::SITE_RCS, self::SITE_AAR, self::SITE_MCS, self::SITE_CCS];
case self::CONTEST_GAMES:
return [self::SITE_RCS, self::SITE_MCS, self::SITE_CCS];
case self::EVENT:
return [self::SITE_RCS, self::SITE_MCS, self::SITE_CCS];
case self::AWARD:
return [self::SITE_RCS, self::SITE_MCS, self::SITE_CCS];
case self::VIDEO:
return [self::SITE_RCS, self::SITE_MCS, self::SITE_CCS];
case self::R_CLUB_PERK:
return [self::SITE_RCS, self::SITE_MCS, self::SITE_CCS];
case self::SCHOLARSHIP:
return [self::SITE_RCS, self::SITE_MCS, self::SITE_CCS];
}
return [0];
}
public static function getSitesForContentTypeString($type) {
return implode(",", self::getSitesForContentType($type));
}
public function getShowTitle(): ?bool
{
return $this->showTitle == 1;
}
public function setShowTitle(bool $showTitle): self
{
$this->showTitle = $showTitle ? 1 : 0;
return $this;
}
public function getOldId(): ?int
{
return $this->old_id;
}
public function setOldId(int $old_id): self
{
$this->old_id = $old_id;
return $this;
}
/*
public function getFeatured(): ?int
{
return $this->featured;
}
public function setFeatured(int $featured): self
{
$this->featured = $featured;
return $this;
}
*/
public function getFeatured(): ?bool
{
return $this->featured == true;
}
public function setFeatured(bool $featured): self
{
$this->featured = $featured ? 1 : 0;
return $this;
}
public function getAnnouncement(): ?bool
{
return $this->announcement == true;
}
public function setAnnouncement(bool $announcement): self
{
$this->announcement = $announcement ? 1 : 0;
return $this;
}
public function getAnnouncementSites(): ?array
{
return json_decode($this->announcement_sites);
}
public function setAnnouncementSites(array $announcement_sites = null): self
{
if (is_null($announcement_sites)) {
$announcement_sites = "";
}
$this->announcement_sites = json_encode(array_values($announcement_sites));
return $this;
}
public function getExpiresAt(): ?\DateTimeInterface
{
return $this->expires_at;
}
public function setExpiresAt(?\DateTimeInterface $expires_at): self
{
$this->expires_at = $expires_at;
return $this;
}
public function getMediaGroupContainers(): Collection
{
return $this->media_group_containers;
}
public function addMediaGroupContainer(MediaGroupContainer $media_group_container): self
{
if (!$this->media_group_containers->contains($media_group_container)) {
$this->media_group_containers[] = $media_group_container;
$media_group_container->setContent($this);
}
return $this;
}
public function setMediaGroupContainers (Collection $media_group_containers):self
{
$this->media_group_containers = $media_group_containers;
return $this;
}
public function removeMediaGroupContainer(MediaGroupContainer $media_group_container): self
{
if ($this->media_group_containers->contains($media_group_container)) {
$this->media_group_containers->removeElement($media_group_container);
// set the owning side to null (unless already changed)
if ($media_group_container->getContent() === $this) {
$media_group_container->setContent(null);
}
}
return $this;
}
public function getHootsuiteMessages(): Collection
{
return $this->hootsuite_messages;
}
public function addHootsuiteMessage(HootsuiteMessage $hootsuite_message): self
{
if (!$this->hootsuite_messages->contains($hootsuite_message)) {
$this->hootsuite_messages[] = $hootsuite_message;
$hootsuite_message->setContent($this);
}
return $this;
}
public function removeHootsuiteMessage(HootsuiteMessage $hootsuite_message): self
{
if ($this->hootsuite_messages->contains($hootsuite_message)) {
$this->hootsuite_messages->removeElement($hootsuite_message);
// set the owning side to null (unless already changed)
if ($hootsuite_message->getContent() === $this) {
$hootsuite_message->setContent(null);
}
}
return $this;
}
/*public function resetHootsuiteMessages(): self
{
$this->hootsuite_messages = new ArrayCollection();
return $this;
}*/
//removes the mediagroupcontainer and deletes all related media groups / media. generally don't use this.
/*
public function deleteMediaGroupContainer(MediaGroupContainer $media_group_container): self
{
$containers = $this->getMediaGroupContainers();
foreach($containers as $container) {
$group = $container->getMediaGroup();
$items = $group->getMediaGroupItems();
foreach($items as $item) {
$group->removeMediaGroupItem($item);
}
//$container->removeMediaGroup($group);
$this->removeMediaGroupContainer($container);
}
$this->removeMediaGroupContainer($media_group_container);
return $this;
}
*/
public function getDirectory(): ?Customer
{
return $this->directory;
}
public function setDirectory(?Customer $directory): self
{
$this->directory = $directory;
// set (or unset) the owning side of the relation if necessary
$newDirectory = $directory === null ? null : $this;
if ($newDirectory !== $directory->getDirectoryContent()) {
$directory->setDirectoryContent($newDirectory);
}
return $this;
}
/*
public function getMediaGroupContainers(): Collection
{
return $this->media_group_containers;
}
public function addMediaGroupContainer(MediaGroupContainer $mediaGroupContainer): self
{
if (!$this->media_group_containers->contains($mediaGroupContainer)) {
$this->media_group_containers[] = $mediaGroupContainer;
$mediaGroupContainer->addContent($this);
}
return $this;
}
public function removeMediaGroupContainer(MediaGroupContainer $mediaGroupContainer): self
{
if ($this->media_group_containers->contains($mediaGroupContainer)) {
$this->media_group_containers->removeElement($mediaGroupContainer);
$mediaGroupContainer->removeContent($this);
}
return $this;
}
public function setMediaGroupContainers (Collection $mediaGroupContainers): self
{
$this->media_group_containers = $mediaGroupContainers;
return $this;
}
*/
/**
* @return Collection|Lead[]
*/
public function getLeads(): Collection
{
return $this->leads;
}
public function addLead(Lead $lead): self
{
if (!$this->leads->contains($lead)) {
$this->leads[] = $lead;
$lead->setContent($this);
}
return $this;
}
public function removeLead(Lead $lead): self
{
if ($this->leads->contains($lead)) {
$this->leads->removeElement($lead);
// set the owning side to null (unless already changed)
if ($lead->getContent() === $this) {
$lead->setContent(null);
}
}
return $this;
}
public function getLatestLeads(): Collection
{
$criteria = Criteria::create()
->orderBy(["created_at" => Criteria::DESC])
;
return $this->getLeads()->matching($criteria);
}
/**
* @return Collection|Traffic[]
*/
public function getTraffic($year=0, $month=0, $day=0): Collection
{
return $this->traffic;
}
public function addTraffic(Traffic $traffic): self
{
if (!$this->traffic->contains($traffic)) {
$this->traffic[] = $traffic;
$traffic->setContent($this);
}
return $this;
}
public function removeTraffic(Traffic $traffic): self
{
if ($this->traffic->contains($traffic)) {
$this->traffic->removeElement($traffic);
// set the owning side to null (unless already changed)
if ($traffic->getContent() === $this) {
$traffic->setContent(null);
}
}
return $this;
}
public function getImpressions(): Collection
{
return $this->impressions;
}
public function getViews(): Collection
{
return $this->views;
}
public function getLinkClicks(): Collection
{
return $this->link_clicks;
}
public function getContentAnalyticsDaily(): Collection
{
return $this->content_analytics_daily;
}
public function getContentAnalyticsCorrectionDaily(): Collection
{
return $this->content_analytics_correction_daily;
}
/*
//todo: https://stackoverflow.com/questions/32026743/symfony-2-php-comparing-dates-issues
public function getImpressions($year=0, $month=0, $day=0)
{
$criteria = Criteria::create()
->where(Criteria::expr()->eq("type", "2"))
;
return $this->getTraffic()->matching($criteria)->count();
//Every time content is passed to render it is now added to an impression, so there's no need to add clicks.
//return $this->getTraffic()->matching($criteria)->count() + $this->getClicks();
}
*/
public function getClicks($year=0, $month=0, $day=0)
{
$criteria = Criteria::create()
->where(Criteria::expr()->eq("type", "1"))
;
return $this->getTraffic()->matching($criteria)->count();
}
public function getMediaGroups(): Collection
{
return $this->media_groups;
}
public function addMediaGroup(MediaGroup $mediaGroup): self
{
if (!$this->media_groups->contains($mediaGroup)) {
//temp
$mgContainer = new MediaGroupContainer();
$mgContainer->setContent($this);
$mgContainer->setMediaGroup($mediaGroup);
$this->addMediaGroupContainer($mgContainer);
$this->media_groups[] = $mediaGroup;
$mediaGroup->addContent($this);
}
return $this;
}
public function removeMediaGroup(MediaGroup $mediaGroup): self
{
if ($this->media_groups->contains($mediaGroup)) {
$this->media_groups->removeElement($mediaGroup);
$mediaGroup->removeContent($this);
}
return $this;
}
public function setMediaGroups (Collection $mediaGroups): self
{
$this->media_groups = $mediaGroups;
return $this;
}
/*
public function getImpressions(): ?int
{
return $this->impressions;
}
public function setImpressions(int $impressions): self
{
$this->impressions = $impressions;
return $this;
}
*/
public function getHootsuiteSocialProfiles(): Collection
{
return $this->hootsuite_social_profiles;
}
public function addHootsuiteSocialProfile(HootsuiteSocialProfile $hootsuite_social_profile): self
{
if (!$this->hootsuite_social_profiles->contains($hootsuite_social_profile)) {
$this->hootsuite_social_profiles[] = $hootsuite_social_profile;
$hootsuite_social_profile->addContent($this);
}
return $this;
}
public function resetHootsuiteSocialProfiles(): self
{
$this->hootsuite_social_profiles = new ArrayCollection();
return $this;
}
public function removeHootsuiteSocialProfile(HootsuiteSocialProfile $hootsuite_social_profile): self
{
if ($this->hootsuite_social_profiles->contains($hootsuite_social_profile)) {
$this->hootsuite_social_profiles->removeElement($hootsuite_social_profile);
$hootsuite_social_profile->removeContent($this);
}
return $this;
}
public function getHootsuiteContent(): ?string
{
return $this->hootsuite_content;
}
public function setHootsuiteContent(string $hootsuite_content = null): self
{
$this->hootsuite_content = $hootsuite_content ? $hootsuite_content : "";
return $this;
}
public function getHootsuiteFacebookContent(): ?string
{
return $this->hootsuite_facebook_content;
}
public function setHootsuiteFacebookContent(string $hootsuite_facebook_content = null): self
{
$this->hootsuite_facebook_content = $hootsuite_facebook_content ? $hootsuite_facebook_content : "";
return $this;
}
public function getHootsuiteTwitterContent(): ?string
{
return $this->hootsuite_twitter_content;
}
public function setHootsuiteTwitterContent(string $hootsuite_twitter_content = null): self
{
$this->hootsuite_twitter_content = $hootsuite_twitter_content ? $hootsuite_twitter_content : "";
return $this;
}
public function getHootsuiteLinkedinContent(): ?string
{
return $this->hootsuite_linkedin_content;
}
public function setHootsuiteLinkedinContent(string $hootsuite_linkedin_content = null): self
{
$this->hootsuite_linkedin_content = $hootsuite_linkedin_content ? $hootsuite_linkedin_content : "";
return $this;
}
public function getHootsuiteToPublish(): ?bool
{
return $this->hootsuite_to_publish == 1;
}
public function setHootsuiteToPublish(bool $value): self
{
$this->hootsuite_to_publish = $value ? 1 : 0;
return $this;
}
public function getHootsuiteUsePostMedia(): ?bool
{
return $this->hootsuite_use_post_media == 1;
}
public function setHootsuiteUsePostMedia(bool $value): self
{
$this->hootsuite_use_post_media = $value ? 1 : 0;
return $this;
}
public function getHootsuiteUsePostPublishedAt(): ?bool
{
return $this->hootsuite_use_post_published_at == 1;
}
public function setHootsuiteUsePostPublishedAt(bool $value): self
{
$this->hootsuite_use_post_published_at = $value ? 1 : 0;
return $this;
}
public function getHootsuiteMedia (): ?Media
{
return $this->hootsuite_media;
}
public function setHootsuiteMedia (Media $hootsuite_media = null): self
{
$this->hootsuite_media = $hootsuite_media;
return $this;
}
public function getHootsuiteImageURL ()
{
if($this->hootsuite_media) {
return $this->hootsuite_media->getURL();
}
return "";
}
public function getHootsuitePublishedAt(): ?\DateTimeInterface
{
return $this->hootsuite_published_at;
}
public function setHootsuitePublishedAt(?\DateTimeInterface $hootsuite_published_at): self
{
$this->hootsuite_published_at = $hootsuite_published_at;
return $this;
}
// -=-=-=- Virtual Properties for EasyAdmin -=-=-=-
public function getTrafficCount ()
{
return $this->id;
/*
$sql = implode(" ", array (
"SELECT",
"COUNT(t.id)",
"FROM",
"App\Entity\Traffic t",
"WHERE",
"t.user_this_route = :slug",
));
$query = $this->em
->createQuery($sql)
->setParameter("slug", $this->slug);
$count = $query->getResult();
$count = $count[0][1];
return $count;
*/
}
public function getScriptTag()
{
return $this->getContentMetaValueByKey("_custom_script_tag");
}
public function setScriptTag($value = ""): self
{
$this->setContentmetum("_custom_script_tag", $value);
return $this;
}
public function getPopoutAd(): ?MediaGroupItem
{
return $this->popout_ad;
}
public function setPopoutAd(?MediaGroupItem $item): self
{
$this->popout_ad = $item;
return $this;
}
// -----DIRECTORIES-----
public function getDisplayOnPartnersPage(): ?bool
{
$val = $this->getContentMetaValueByKey("_display_on_partners_page");
return $val == "yes";
}
public function setDisplayOnPartnersPage(bool $value): self
{
$this->setContentmetum("_display_on_partners_page", $value ? "yes" : "no");
return $this;
}
public function getDirectoryEmailRecipients()
{
return $this->getContentMetaValueByKey("_directory_email_recipients");
}
public function setDirectoryEmailRecipients($value = ""): self
{
$this->setContentmetum("_directory_email_recipients", $value);
return $this;
}
public function getDirectoryEmailRecipientsArray()
{
$recipients = [];
$valid_recipients = false;
foreach(explode(',', $this->getDirectoryEmailRecipients()) as $recipient) {
if ($recipient && filter_var(trim($recipient), FILTER_VALIDATE_EMAIL)) {
$recipients[] = trim($recipient);
$valid_recipients = true;
}
}
return $recipients;
}
public function getDirectoryAccountManagers()
{
return $this->getContentMetaValueByKey("_directory_account_managers");
}
public function setDirectoryAccountManagers($value = ""): self
{
$this->setContentmetum("_directory_account_managers", $value);
return $this;
}
// -----END DIRECTORIES-----
// -----PAGES-----
public function getZoomMeetingId()
{
return $this->getContentMetaValueByKey("_zoom_meeting_id");
}
public function setZoomMeetingId($value = ""): self
{
$this->setContentmetum("_zoom_meeting_id", $value);
return $this;
}
public function getZoomDisplayMeeting(): ?bool
{
$val = $this->getContentMetaValueByKey("_zoom_display_meeting");
return $val == "yes";
}
public function setZoomDisplayMeeting(bool $value): self
{
$this->setContentmetum("_zoom_display_meeting", $value ? "yes" : "no");
return $this;
}
// -----END PAGES-----
// -----POSTS-----
public function getPostAnnouncementEndDate(): ?\DateTimeInterface
{
if($this->getContentMetaValueByKey("_PostAnnouncementEndDate")) {
return new \DateTime($this->getContentMetaValueByKey("_PostAnnouncementEndDate"));
}
return null;
}
public function setPostAnnouncementEndDate(?\DateTimeInterface $value): self
{
if($value) {
$this->setContentmetum("_PostAnnouncementEndDate", $value->format("Y-m-d H:i:s"));
}
else {
$this->setContentmetum("_PostAnnouncementEndDate", "");
}
return $this;
}
// -----END POSTS-----
// -----CLASSIFIEDS-----
public function getClassifiedLocation()
{
return $this->getContentMetaValueByKey("_job_location");
}
public function setClassifiedLocation($value = ""): self
{
$this->setContentmetum("_job_location", $value);
return $this;
}
public function getClassifiedCompanyName()
{
return $this->getContentMetaValueByKey("_company_name");
}
public function setClassifiedCompanyName($value = ""): self
{
$this->setContentmetum("_company_name", $value);
return $this;
}
public function getClassifiedCompanyPhone()
{
return $this->getContentMetaValueByKey("_company_phone");
}
public function setClassifiedCompanyPhone($value = ""): self
{
$this->setContentmetum("_company_phone", $value);
return $this;
}
public function getClassifiedWebsite()
{
return $this->getContentMetaValueByKey("_company_website");
}
public function setClassifiedWebsite($value = ""): self
{
$this->setContentmetum("_company_website", $value);
return $this;
}
public function getClassifiedContactName()
{
return $this->getContentMetaValueByKey("_company_contact");
}
public function setClassifiedContactName($value = ""): self
{
$this->setContentmetum("_company_contact", $value);
return $this;
}
public function getClassifiedContactEmail()
{
return $this->getContentMetaValueByKey("_application");
}
public function setClassifiedContactEmail($value = ""): self
{
$this->setContentmetum("_application", $value);
return $this;
}
public function getClassifiedFileTitle()
{
return $this->getContentMetaValueByKey("_file_title");
}
public function setClassifiedFileTitle($value = ""): self
{
$this->setContentmetum("_file_title", $value);
//If there is already a file
$containers = $this->getMediaGroupContainers();
foreach($containers as $container) {
$group = $container->getMediaGroup();
if($group->getTitle() == "Classified Listing Files") {
$items = $group->getMediaGroupItems();
foreach($items as $item) {
$media = $item->getMedia();
$media->setTitle($value);
}
}
}
return $this;
}
public function getClassifiedFile()
{
return "";
}
public function getClassifiedFileURL()
{
$containers = $this->getMediaGroupContainers();
foreach($containers as $container) {
$group = $container->getMediaGroup();
if($group->getTitle() == "Classified Listing Files") {
$items = $group->getMediaGroupItems();
foreach($items as $item) {
$media = $item->getMedia();
return $media->getURL();
}
}
}
return "";
}
public function setClassifiedFile(HttpFile $data = null): self
{
if($data) {
// upload the image
// - using a media group in case we need to store more files in the future.
$media = new Media();
$media->setTitle($this->getClassifiedFileTitle() ? $this->getClassifiedFileTitle() : "Classified File");
$media->setData($data);
$media->setDescription("Classified Listing File");
//$media->setName("Classified File");
$continue = true;
//$this->removeClassifiedFile();
$containers = $this->getMediaGroupContainers();
foreach($containers as $container) {
$group = $container->getMediaGroup();
if($group->getTitle() == "Classified Listing Files") {
$items = $group->getMediaGroupItems();
foreach($items as $item) {
$group->removeMediaGroupItem($item);
}
$mediaGroupItem = new MediaGroupItem();
$mediaGroupItem->setTitle("Classified Listing File");
$mediaGroupItem->setDescription("Classified Listing File");
$mediaGroupItem->setMedia($media);
$group->addMediaGroupItem($mediaGroupItem);
$continue = false;
}
}
if($continue) {
$mediaGroupItem = new MediaGroupItem();
$mediaGroupItem->setTitle("Classified Listing File");
$mediaGroupItem->setDescription("Classified Listing File");
$mediaGroupItem->setMedia($media);
$mediaGroup = new MediaGroup();
$mediaGroup->setTitle("Classified Listing Files");
$mediaGroup->setDescription("Classified Listing Files");
$mediaGroup->addMediaGroupItem($mediaGroupItem);
$mediaGroupContainer = new MediaGroupContainer();
$mediaGroupContainer->setMediaGroup($mediaGroup);
$this->addMediaGroupContainer($mediaGroupContainer);
}
}
return $this;
}
public function getClassifiedFileRemove(): ?bool
{
return false;
}
public function setClassifiedFileRemove(bool $var): self
{
return $this;
}
/*
public function removeClassifiedFile(): self
{
$containers = $this->getMediaGroupContainers();
foreach($containers as $container) {
$this->deleteMediaGroupContainer($container);
}
return $this;
}
*/
/* Don't think this will work with easyadmin
public function getClassifiedCategories(): Collection
{
$criteria = Criteria::create()
->where(Criteria::expr()->eq("status", "1"))
->andWhere(Criteria::expr()->eq("taxonomy", "job_listing_category"))
;
return $this->getSecondaryCategories()->matching($criteria);
}
public function addClassifiedCategory(Category $category): self
{
$this->addSecondaryCategory($category);
return $this;
}*/
// -----END CLASSIFIEDS-----
// -----GALLERIES-----
//$galleryMediaItems
public function getGalleryMediaGroup(): ?MediaGroup
{
$mgContainers = $this->getMediaGroupContainers();
$mgContainer = $mgContainers->first();
$mediaGroup = $mgContainer->getMediaGroup();
return $mediaGroup;
}
public function getGalleryMediaItems(): Collection
{
$mediaGroup = $this->getGalleryMediaGroup();
$mgItems = $mediaGroup->getMediaGroupItems();
return $mgItems;
}
public function addGalleryMediaItem(MediaGroupItem $mediaGroupItem): self
{
$mediaGroup = $this->getGalleryMediaGroup();
$mediaGroup->addMediaGroupItem($mediaGroupItem);
return $this;
}
public function setGalleryMediaItems (Collection $mediaGroupItems):self
{
$mediaGroup = $this->getGalleryMediaGroup();
$mediaGroup->setMediaGroupItems($mediaGroupItems)
;
return $this;
}
public function removeGalleryMediaItems(MediaGroupItem $mediaGroupItem): self
{
$mediaGroup = $this->getGalleryMediaGroup();
$mediaGroup->removeMediaGroupItem($mediaGroupItem);
return $this;
}
// -----END GALLERIES-----
// -----EVENTS-----
public function getEventStartDate(): ?\DateTimeInterface
{
if(!empty($this->getContentMetaValueByKey("_EventStartDate"))) {
return new \DateTime($this->getContentMetaValueByKey("_EventStartDate"));
}
return null;
}
public function setEventStartDate(?\DateTimeInterface $value): self
{
if($value) {
$this->setContentmetum("_EventStartDate", $value->format("Y-m-d H:i:s"));
}
else {
$this->setContentmetum("_EventStartDate", "");
}
return $this;
}
public function getEventEndDate(): ?\DateTimeInterface
{
if(!empty($this->getContentMetaValueByKey("_EventEndDate"))) {
return new \DateTime($this->getContentMetaValueByKey("_EventEndDate"));
}
return null;
}
public function setEventEndDate(?\DateTimeInterface $value): self
{
if($value) {
$this->setContentmetum("_EventEndDate", $value->format("Y-m-d H:i:s"));
}
else {
$this->setContentmetum("_EventEndDate", "");
}
return $this;
}
public function getEventAllDay(): ?bool
{
$val = $this->getContentMetaValueByKey("_EventAllDay");
return $val == "yes";
}
public function setEventAllDay(bool $value): self
{
$this->setContentmetum("_EventAllDay", $value ? "yes" : "no");
return $this;
}
public function getEventTimezone()
{
return $this->getContentMetaValueByKey("_EventTimezone");
}
public function setEventTimezone($value = ""): self
{
$this->setContentmetum("_EventTimezone", $value);
return $this;
}
public function getEventCost()
{
return $this->getContentMetaValueByKey("_EventCost");
}
public function setEventCost($value = ""): self
{
$this->setContentmetum("_EventCost", $value);
return $this;
}
public function getEventWebsite()
{
return $this->getContentMetaValueByKey("_EventURL");
}
public function setEventWebsite($value = ""): self
{
$this->setContentmetum("_EventURL", $value);
return $this;
}
// EVENT ORGANIZERS
public function getEventOrganizerTitle()
{
return $this->getContentMetaValueByKey("_OrganizerTitle");
}
public function setEventOrganizerTitle($value = ""): self
{
$this->setContentmetum("_OrganizerTitle", $value);
return $this;
}
public function getEventOrganizerPhone()
{
return $this->getContentMetaValueByKey("_OrganizerPhone");
}
public function setEventOrganizerPhone($value = ""): self
{
$this->setContentmetum("_OrganizerPhone", $value);
return $this;
}
public function getEventOrganizerEmail()
{
return $this->getContentMetaValueByKey("_OrganizerEmail");
}
public function setEventOrganizerEmail($value = ""): self
{
$this->setContentmetum("_OrganizerEmail", $value);
return $this;
}
public function getEventOrganizerWebsite()
{
return $this->getContentMetaValueByKey("_OrganizerWebsite");
}
public function setEventOrganizerWebsite($value = ""): self
{
$this->setContentmetum("_OrganizerWebsite", $value);
return $this;
}
// EVENT VENUES
public function getEventVenueTitle()
{
return $this->getContentMetaValueByKey("_VenueTitle");
}
public function setEventVenueTitle($value = ""): self
{
$this->setContentmetum("_VenueTitle", $value);
return $this;
}
public function getEventVenueAddress()
{
return $this->getContentMetaValueByKey("_VenueAddress");
}
public function setEventVenueAddress($value = ""): self
{
$this->setContentmetum("_VenueAddress", $value);
return $this;
}
public function getEventVenueCity()
{
return $this->getContentMetaValueByKey("_VenueCity");
}
public function setEventVenueCity($value = ""): self
{
$this->setContentmetum("_VenueCity", $value);
return $this;
}
public function getEventVenueState()
{
return $this->getContentMetaValueByKey("_VenueState");
}
public function setEventVenueState($value = ""): self
{
$this->setContentmetum("_VenueState", $value);
return $this;
}
public function getEventVenueZip()
{
return $this->getContentMetaValueByKey("_VenueZip");
}
public function setEventVenueZip($value = ""): self
{
$this->setContentmetum("_VenueZip", $value);
return $this;
}
public function getEventVenueCountry()
{
return $this->getContentMetaValueByKey("_VenueCountry");
}
public function setEventVenueCountry($value = ""): self
{
$this->setContentmetum("_VenueCountry", $value);
return $this;
}
public function getEventVenuePhone()
{
return $this->getContentMetaValueByKey("_VenuePhone");
}
public function setEventVenuePhone($value = ""): self
{
$this->setContentmetum("_VenuePhone", $value);
return $this;
}
public function getEventVenueURL()
{
return $this->getContentMetaValueByKey("_VenueURL");
}
public function setEventVenueURL($value = ""): self
{
$this->setContentmetum("_VenueURL", $value);
return $this;
}
//Used for non-Events (e.g. Webinars) so that they can be displayed as an Event
public function getIsEvent(): ?bool
{
$val = $this->getContentMetaValueByKey("_IsEvent");
return $val == "yes";
}
public function setIsEvent(bool $value): self
{
$this->setContentmetum("_IsEvent", $value ? "yes" : "no");
return $this;
}
// -----END EVENTS-----
// -----FORUMS-----
public function getForumSponsoredURL()
{
return $this->getContentMetaValueByKey("frm_sponsored_url");
}
public function setForumSponsoredURL($value = ""): self
{
$this->setContentmetum("frm_sponsored_url", $value);
return $this;
}
// -----END FORUMS-----
// -----LANDING PAGES-----
public function getForm (): ?Form
{
return $this->form;
}
public function setForm (Form $form = null): self
{
$this->form = $form;
return $this;
}
public function getLPContent()
{
return $this->getContentMetaValueByKey("mtm_content_modules_1_mtm_module_text_area_2");
}
public function setLPContent($value = ""): self
{
$this->setContentmetum("mtm_content_modules_1_mtm_module_text_area_2", $value);
return $this;
}
public function getLPHeader()
{
return $this->getContentMetaValueByKey("_lp_header");
}
public function setLPHeader($value = ""): self
{
$this->setContentmetum("_lp_header", $value);
return $this;
}
public function getLPFooter()
{
return $this->getContentMetaValueByKey("_lp_footer");
}
public function setLPFooter($value = ""): self
{
$this->setContentmetum("_lp_footer", $value);
return $this;
}
public function getLPLeft()
{
return $this->getContentMetaValueByKey("_lp_left");
}
public function setLPLeft($value = ""): self
{
$this->setContentmetum("_lp_left", $value);
return $this;
}
public function getLPRight()
{
return $this->getContentMetaValueByKey("_lp_right");
}
public function setLPRight($value = ""): self
{
$this->setContentmetum("_lp_right", $value);
return $this;
}
public function getLPThankYouContents()
{
return $this->getContentMetaValueByKey("_lp_thank_you_contents");
}
public function setLPThankYouContents($value = ""): self
{
$this->setContentmetum("_lp_thank_you_contents", $value);
return $this;
}
public function getLPRecipients()
{
return $this->getContentMetaValueByKey("lp_recipients");
}
public function setLPRecipients($value = ""): self
{
$this->setContentmetum("lp_recipients", $value);
return $this;
}
//I can't use LPThankYou because the server gives a 403 error when entering a URL...
public function getLPThankyou()
{
return $this->getContentMetaValueByKey("lp_thankyou");
}
public function setLPThankyou($value = ""): self
{
$this->setContentmetum("lp_thankyou", $value);
return $this;
}
//Using LPPage instead for the thank you page URL
public function getLPPage()
{
return $this->getContentMetaValueByKey("lp_thankyou");
}
public function setLPPage($value = ""): self
{
$this->setContentmetum("lp_thankyou", $value);
return $this;
}
public function getLPButtonText()
{
return $this->getContentMetaValueByKey("btn_text");
}
public function setLPButtonText($value = ""): self
{
$this->setContentmetum("btn_text", $value);
return $this;
}
public function getLPOptIn()
{
return $this->getContentMetaValueByKey("lp_opt_in");
}
public function setLPOptIn($value = ""): self
{
$this->setContentmetum("lp_opt_in", $value);
return $this;
}
public function isNewLandingPage(): ?bool
{
$val = $this->getContentMetaValueByKey("_lp_new_site");
return $val == "yes";
}
public function setNewLandingPage(bool $value): self
{
$this->setContentmetum("_lp_new_site", $value ? "yes" : "no");
return $this;
}
public function getLPBgColor()
{
return $this->getContentMetaValueByKey("rcs_body_background_color");
}
public function setLPBgColor($value = ""): self
{
$this->setContentmetum("rcs_body_background_color", $value);
return $this;
}
public function getLPButtonColor()
{
return $this->getContentMetaValueByKey("btn_color");
}
public function setLPButtonColor($value = ""): self
{
$this->setContentmetum("btn_color", $value);
return $this;
}
public function getLPHeaderColor()
{
return $this->getContentMetaValueByKey("_lp_header_color");
}
public function setLPHeaderColor($value = ""): self
{
$this->setContentmetum("_lp_header_color", $value);
return $this;
}
public function getLPFooterColor()
{
return $this->getContentMetaValueByKey("_lp_footer_color");
}
public function setLPFooterColor($value = ""): self
{
$this->setContentmetum("_lp_footer_color", $value);
return $this;
}
public function getLPThankColor()
{
return $this->getContentMetaValueByKey("_lp_thank_color");
}
public function setLPThankColor($value = ""): self
{
$this->setContentmetum("_lp_thank_color", $value);
return $this;
}
public function getLPLeftColor()
{
return $this->getContentMetaValueByKey("_lp_left_color");
}
public function setLPLeftColor($value = ""): self
{
$this->setContentmetum("_lp_left_color", $value);
return $this;
}
public function getLPRightColor()
{
return $this->getContentMetaValueByKey("_lp_right_color");
}
public function setLPRightColor($value = ""): self
{
$this->setContentmetum("_lp_right_color", $value);
return $this;
}
public function getLPFormFirstname(): ?bool
{
$val = $this->getContentMetaValueByKey("_lp_form_firstname");
return $val == "yes";
}
public function setLPFormFirstname(bool $value): self
{
$this->setContentmetum("_lp_form_firstname", $value ? "yes" : "no");
return $this;
}
public function getLPFormLastname(): ?bool
{
$val = $this->getContentMetaValueByKey("_lp_form_lastname");
return $val == "yes";
}
public function setLPFormLastname(bool $value): self
{
$this->setContentmetum("_lp_form_lastname", $value ? "yes" : "no");
return $this;
}
public function getLPFormCompany(): ?bool
{
$val = $this->getContentMetaValueByKey("_lp_form_company");
return $val == "yes";
}
public function setLPFormCompany(bool $value): self
{
$this->setContentmetum("_lp_form_company", $value ? "yes" : "no");
return $this;
}
public function getLPFormAddress1(): ?bool
{
$val = $this->getContentMetaValueByKey("_lp_form_address1");
return $val == "yes";
}
public function setLPFormAddress1(bool $value): self
{
$this->setContentmetum("_lp_form_address1", $value ? "yes" : "no");
return $this;
}
public function getLPFormAddress2(): ?bool
{
$val = $this->getContentMetaValueByKey("_lp_form_address2");
return $val == "yes";
}
public function setLPFormAddress2(bool $value): self
{
$this->setContentmetum("_lp_form_address2", $value ? "yes" : "no");
return $this;
}
public function getLPFormCity(): ?bool
{
$val = $this->getContentMetaValueByKey("_lp_form_city");
return $val == "yes";
}
public function setLPFormCity(bool $value): self
{
$this->setContentmetum("_lp_form_city", $value ? "yes" : "no");
return $this;
}
public function getLPFormState(): ?bool
{
$val = $this->getContentMetaValueByKey("_lp_form_state");
return $val == "yes";
}
public function setLPFormState(bool $value): self
{
$this->setContentmetum("_lp_form_state", $value ? "yes" : "no");
return $this;
}
public function getLPFormZip(): ?bool
{
$val = $this->getContentMetaValueByKey("_lp_form_zip");
return $val == "yes";
}
public function setLPFormZip(bool $value): self
{
$this->setContentmetum("_lp_form_zip", $value ? "yes" : "no");
return $this;
}
public function getLPFormPhone(): ?bool
{
$val = $this->getContentMetaValueByKey("_lp_form_phone");
return $val == "yes";
}
public function setLPFormPhone(bool $value): self
{
$this->setContentmetum("_lp_form_phone", $value ? "yes" : "no");
return $this;
}
public function getLPFormEmail(): ?bool
{
$val = $this->getContentMetaValueByKey("_lp_form_email");
return $val == "yes";
}
public function setLPFormEmail(bool $value): self
{
$this->setContentmetum("_lp_form_email", $value ? "yes" : "no");
return $this;
}
public function getLPFormContractorType(): ?bool
{
$val = $this->getContentMetaValueByKey("_lp_form_contractor_type");
return $val == "yes";
}
public function setLPFormContractorType(bool $value): self
{
$this->setContentmetum("_lp_form_contractor_type", $value ? "yes" : "no");
return $this;
}
public function getLPFormImage(): ?bool
{
$val = $this->getContentMetaValueByKey("_lp_form_image");
return $val == "yes";
}
public function setLPFormImage(bool $value): self
{
$this->setContentmetum("_lp_form_image", $value ? "yes" : "no");
return $this;
}
public function getLPFormCode()
{
return $this->getContentMetaValueByKey("_lp_form_shortcode");
}
public function setLPFormCode($value = ""): self
{
$this->setContentmetum("_lp_form_shortcode", $value);
return $this;
}
public function getLPEmailSend(): ?bool
{
$val = $this->getContentMetaValueByKey("_lp_email_send");
return $val == "yes";
}
public function setLPEmailSend(bool $value): self
{
$this->setContentmetum("_lp_email_send", $value ? "yes" : "no");
return $this;
}
public function getLPEmailContents()
{
return $this->getContentMetaValueByKey("_lp_email_contents");
}
public function setLPEmailContents($value = ""): self
{
$this->setContentmetum("_lp_email_contents", $value);
return $this;
}
//CSS properties are not applied to img tags in an email.
//This fix will set the img tags' width and height attributes based on the width and height of the inline styles.
// (Should move this fix to the EmailHelper so that it applies to all emails. Starting with it here for testing purposes.)
public function getLPEmailContentsImgFix()
{
$html = $this->getContentMetaValueByKey("_lp_email_contents");
$dom = new \DOMDocument;
$dom->loadHTML($html);
$imgs = $dom->getElementsByTagName('img');
foreach($imgs as $img) {
$style = $img->getAttribute('style');
if($style) {
$style_attributes = array();
preg_match_all("/([\w-]+)\s*:\s*([^;]+)\s*;?/", $style, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$style_attributes[$match[1]] = $match[2];
}
if(isset($style_attributes["width"])) {
$tmp = explode('px', $style_attributes["width"]);
$img->setAttribute("width", array_shift($tmp));
}
if(isset($style_attributes["height"])) {
$tmp = explode('px', $style_attributes["height"]);
$img->setAttribute("height", array_shift($tmp));
}
}
}
$html = $dom->saveHTML();
return $html;
}
public function getLPEmailButtonText()
{
return $this->getContentMetaValueByKey("_lp_email_btn_text");
}
public function setLPEmailButtonText($value = ""): self
{
$this->setContentmetum("_lp_email_btn_text", $value);
return $this;
}
/*public function getLPEmailButtonColor()
{
return $this->getContentMetaValueByKey("_lp_email_btn_color");
}
public function setLPEmailButtonColor($value = ""): self
{
$this->setContentmetum("_lp_email_btn_color", $value);
return $this;
}*/
// -----END LANDING PAGES-----
// -----PODCASTS-----
/*
Made a script to move these all into content_full... will probably delete these
public function getPodcastSubtitle()
{
return $this->getContentMetaValueByKey("sub_header");
}
public function setPodcastSubtitle($value = ""): self
{
$this->setContentmetum("sub_header", $value);
return $this;
}
public function getPodcastInThisEpisode()
{
return $this->getContentMetaValueByKey("in_this_episode");
}
public function setPodcastInThisEpisode($value = ""): self
{
$this->setContentmetum("in_this_episode", $value);
return $this;
}
public function getPodcastEmbed()
{
return $this->getContentMetaValueByKey("podcast_embed");
}
public function setPodcastEmbed($value = ""): self
{
$this->setContentmetum("podcast_embed", $value);
return $this;
}
*/
// -----END PODCASTS-----
// -----EBOOKS-----
public function getEbookPinned(): ?bool
{
$val = $this->getContentMetaValueByKey("_ebook_pinned");
return $val == "yes";
}
public function setEbookPinned(bool $value): self
{
$this->setContentmetum("_ebook_pinned", $value ? "yes" : "no");
return $this;
}
// -----END EBOOKS-----
}