/** * @param AddSegmentsErrors $errors * @return array */ private function areRequiredCategoryFieldsPresent($errors) { $category = $this->segment->getCategory(); $author = $this->segment->getAuthor(); $album = $this->segment->getAlbum(); $name = $this->segment->getName(); switch ($category) { case 1: case 2: if (!ValidatorUtility::doesFieldExist($author)) { $errors->markAuthorMissing(); } if (!ValidatorUtility::doesFieldExist($album)) { $errors->markAlbumMissing(); } case 3: case 4: if (!ValidatorUtility::doesFieldExist($name)) { $errors->markNameMissing(); } break; case 5: self::isAdNumberValid($errors); } }
/** * Rajoute le segment fusionné au document * * @param Segment $segment * @throws OdfException * @return odf */ public function mergeSegment(Segment $segment) { if (! array_key_exists($segment->getName(), $this->segments)) { throw new OdfException($segment->getName() . 'cannot be parsed, has it been set yet ?'); } $string = $segment->getName(); $reg = '@<text:p[^>]*>\[!--\sBEGIN\s' . $string . '\s--\](.*)\[!--.+END\s' . $string . '\s--\]<\/text:p>@smU'; $this->contentXml = preg_replace($reg, $segment->getXmlParsed(), $this->contentXml); return $this; }
/** * Add the merged segment to the document * * @param Segment $segment * @throws OdfException * @return odf */ public function mergeSegment(Segment $segment) { if (!array_key_exists($segment->getName(), $this->segments)) { throw new OdfException($segment->getName() . 'cannot be parsed, has it been set yet ?'); } $string = $segment->getName(); // $reg = '@<text:p[^>]*>\[!--\sBEGIN\s' . $string . '\s--\](.*)\[!--.+END\s' . $string . '\s--\]<\/text:p>@smU'; $reg = '@\\[!--\\sBEGIN\\s' . $string . '\\s--\\](.*)\\[!--.+END\\s' . $string . '\\s--\\]@smU'; $this->contentXml = preg_replace($reg, $segment->getXmlParsed(), $this->contentXml); foreach ($segment->manif_vars as $val) { $this->manif_vars[] = $val; } //copy all segment image names into current array return $this; }
/** * @param Segment $segmentObject * @return array */ private static function processSegmentForWrite($segmentObject) { $startDateString = formatDateStringForDatabaseWrite($segmentObject->getStartTime()); $columnNames = array(self::START_TIME_COLUMN_NAME, self::DURATION_COLUMN_NAME, self::SEGMENT_NAME_COLUMN_NAME, self::AUTHOR_COLUMN_NAME, self::ALBUM_COLUMN_NAME, self::CATEGORY_COLUMN_NAME, self::CAN_CON_COLUMN_NAME, self::NEW_RELEASE_COLUMN_NAME, self::FRENCH_VOCAL_MUSIC_COLUMN_NAME); $values = array($startDateString, $segmentObject->getDuration(), $segmentObject->getName(), $segmentObject->getAuthor(), $segmentObject->getAlbum(), $segmentObject->getCategory(), $segmentObject->isCanCon(), $segmentObject->isNewRelease(), $segmentObject->isFrenchVocalMusic()); return array($columnNames, $values); }