public function __construct($key, $name = null, $description = null) { $this->key = $key; if ($name === null) { $name = Strings::humanize($key); } $this->name = $name; if ($description === null) { $description = Strings::humanize($name); } $this->description = $description; }
/** * @return DataCollectionAttribute[] */ public function getAttributes() { $attrs = []; $source = $this->_getMapper(); if ($source !== null) { $attributes = $source->getRawAttributes(); if ($attributes) { foreach ($attributes as $attribute) { $attrs[] = new DataCollectionAttribute($attribute->sourceProperty(), Strings::humanize($attribute->name()), $attribute->getDescription()); } } } return $attrs; }
public static function getDiffuseVersionInfo() { if (!self::$_versionInfo) { $info = []; $versionFile = build_path(CUBEX_PROJECT_ROOT, 'DIFFUSE.VERSION'); if (file_exists($versionFile)) { $data = file($versionFile); foreach ($data as $line) { $line = trim($line); if (starts_with($line, '== Change Log ==', true)) { break; } else { if (!empty($line)) { list($key, $value) = exploded(':', $line, ['unknown', 'unknown'], 2); $info[Strings::variableToUnderScore($key)] = $value; } } } } self::$_versionInfo = $info; } return self::$_versionInfo; }
/** * Show a paginated list of campaigns * * @param int $page * * @return \Qubes\Defero\Applications\Defero\Views\Campaigns\CampaignsView */ public function renderIndex($page = 1) { $db = (new Campaign())->connection(); $postData = $this->request()->postVariables(); $where = []; if ($postData) { if ($postData['label'] != "") { $where['label'] = $postData['label']; } if ($postData['active'] != "") { $where['active'] = $postData['active']; } if ($postData['sendType'] != "") { $where['send_type'] = $postData['sendType']; } } $query = "SELECT c.id, c.name, c.data_source, t.subject, c.send_type, c.label,\n c.available_languages, c.active\n FROM defero_campaign_campaigns c\n INNER JOIN defero_messages m ON c.id=m.campaign_id\n INNER JOIN defero_message_translations t ON m.id=t.source_id\n WHERE t.language='en'"; foreach ($where as $field => $value) { $query .= ' AND c.' . $db->escapeColumnName($field) . "='" . $db->escapeString($value) . "'"; } $query .= ' ORDER BY sort_order'; /** * @var \mysqli_result $results */ $results = $db->query($query); $campaigns = []; while ($row = $results->fetch_object()) { $row->titledSendType = Strings::titleize((new SendType())->constFromValue((string) $row->send_type)); $row->availableLanguages = json_decode($row->available_languages); $campaigns[] = $row; } $options['sendTypeOptions'] = array_flip((new SendType())->getConstList()); $options['activeOptions'] = [1 => 'Yes', 0 => 'No']; $options['labelOptions'] = Campaign::labels(); return new CampaignsView($campaigns, $options, $postData); }
public function addStartStopEvent($startEvent, $stopEvent) { $timerName = rtrim(Strings::commonPrefix($startEvent, $stopEvent), '.'); $this->_stopwatchCollection->newEventStopwatch($timerName, $startEvent, $stopEvent); }
/** * Add videos * * @return $this */ protected function _addVideos() { echo 'Adding Videos: '; $count = 0; $captionCount = 0; /** @var Category[] $categories */ $categories = Category::collection(); foreach ($categories as $category) { if (rand(1, 3)) { $videoTitles = $this->_getTitleArray('Video', rand(1, 3)); foreach ($videoTitles as $videoTitle) { $video = new Video(); $video->title = $videoTitle; $video->slug = Strings::urlize($videoTitle); $video->subTitle = $this->_getExampleContent(rand(3, 15)); $video->categoryId = $category->id(); $video->url = 'http://content.bitsontherun.com/videos/lWMJeVvV-364767.mp4'; $video->saveChanges(); // Add Annotations $videoCaptionCount = rand(20, 30); $i = 1; $lastSecond = 0; do { $caption = new VideoCaption(); $caption->videoId = $video->id(); $caption->text = $this->_getExampleContent(rand(2, 6)); $caption->startSecond = $lastSecond; $lastSecond += rand(3, 6); $caption->endSecond = $lastSecond; $caption->saveChanges(); $captionCount++; $i++; } while ($i <= $videoCaptionCount); $count++; } } } echo sprintf('%d (%d Total Captions)%s', $count, $captionCount, PHP_EOL); return $this; }
public function getTitledSendType() { return Strings::titleize($this->sendTypes()->constFromValue((string) $this->sendType)); }