/** * * @param ContentController $controller * The controller of the page we're attached to * @param DataObject $context * The object we're being bound against * @param String $commentOn * The jQuery string we're going to match to show 'comment' icons. */ public function __construct($controller, $name, $context, $commentOn = 'h1') { $this->context = $context; if (!$this->context || !$this->context->ID) { if (isset($_POST['TargetType']) && $_POST['TargetID']) { $this->context = DataObject::get_by_id($_POST['TargetType'], $_POST['TargetID']); } if (!$this->context || !$this->context->exists()) { throw new Exception("Invalid context object for inline commenting form"); } } $fields = new FieldSet(); $fields->push(new TextareaField('Comment', _t('InlineComment.COMMENT', 'Add Comment'))); $fields->push(new HiddenField('CommentOnElement')); $fields->push(new HiddenField('TargetType', '', $this->context->ClassName)); $fields->push(new HiddenField('TargetID', '', $this->context->ID)); $actions = new FieldSet(new FormAction('add', _t('InlineComment.ADD', 'Add')), new FormAction('deleteinlinecomment', _t('InlineComment.DELETE', 'Delete'))); $this->addExtraClass('inlineCommentForm'); parent::__construct($controller, $name, $fields, $actions); Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js'); Requirements::javascript(THIRDPARTY_DIR . '/jquery-form/jquery.form.js'); Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery-ui-1.8rc3.custom.js'); Requirements::javascript('inlinecomments/javascript/inline-comments.js'); Requirements::javascript('inlinecomments/javascript/jquery-getpath.js'); Requirements::themedCSS('inline-comments'); // load the existing items for the given context $filter = singleton('ICUtils')->dbQuote(array('TargetType =' => $this->context->ClassName, 'TargetID =' => $this->context->ID)); $comments = DataObject::get('InlineComment', $filter); $toLoad = array(); if ($comments) { foreach ($comments as $comment) { $toLoad[] = $comment->toMap(); } } $opts = array('form' => '#' . $this->FormName(), 'load' => $toLoad); Requirements::customScript('jQuery("' . $commentOn . '").inlineComment(' . Convert::array2json($opts) . ')'); }
/** * A file only exists if the file_exists() and is in the DB as a record * * @return bool */ public function exists() { return parent::exists() && file_exists($this->getFullPath()); }
/** * A file only exists if the file_exists() and is in the DB as a record * * Use $file->isInDB() to only check for a DB record * Use $file->File->exists() to only check if the asset exists * * @return bool */ public function exists() { return parent::exists() && $this->File->exists(); }
/** * A File exists if it has ID and S3 URL * Does not do any filesystem checks. * * @return boolean */ public function exists() { return parent::exists() && $this->URL; }
/** * adds additional info to current session * @param String $action * @param DataObject $copyFrom * @param DataObject $copyInto */ protected static function add_to_session($action, $copyFrom = null, $copyInto = null) { $obj = new CopyFactoryLog(); $obj->Type = Config::inst()->get("CopyFactory", "for_real") ? "Real" : "Fake"; $obj->StartTime = Config::inst()->get("CopyFactory", "start_time"); $obj->CopyCausingClassName = Config::inst()->get("CopyFactory", "dry_run_for_class_name"); $obj->CopyCausingClassNameID = Config::inst()->get("CopyFactory", "dry_run_for_id"); if ($copyFrom) { $obj->CopyFromClassNameID = $copyFrom->ID; } if ($copyInto) { $obj->CopyIntoClassName = $copyInto->ClassName; $obj->CopyIntoClassNameID = $copyInto->ID; } $obj->Action = $action; $obj->write(); if (Config::inst()->get("CopyFactory", "debug")) { $copyFromLine = ""; if ($copyFrom && $copyFrom->exists()) { $copyFromLine = "FROM: " . self::title_for_object($copyFrom) . " - " . $copyFrom->ClassName . "." . $copyFrom->ID . "\n"; } $copyIntoLine = ""; if ($copyInto && $copyInto->exists()) { $copyIntoLine = "INTO: " . self::title_for_object($copyInto) . " - " . $copyInto->ClassName . "." . $copyInto->ID . "\n"; } debug::log($copyFromLine . $copyIntoLine . $action); } }