/**
  * @param Controller $controller
  * @param Job $job (optional)
  */
 public function __construct($controller, $job = null)
 {
     if ($job) {
         $fields = $job->getFields();
         $required = $job->getValidator();
     } else {
         $fields = singleton('Job')->getFields();
         $required = singleton('Job')->getValidator();
     }
     $fields->merge(new FieldList(new LiteralField('Conditions', $controller->TermsAndConditionsText), new HiddenField('BackURL', '', $controller->Link('thanks')), new HiddenField('EmailFrom', '', $controller->getJobEmailFromAddress()), new HiddenField('EmailSubject', '', $controller->getJobEmailSubject()), $jobId = new HiddenField('JobID')));
     if ($job) {
         $jobId->setValue($job->ID);
         $actions = new FieldList(new FormAction('doEditJob', _t('Jobboard.EDITLISTING', 'Edit Listing')));
     } else {
         $actions = new FieldList(new FormAction('doAddJob', _t('JobBoard.CONFIRM', 'Confirm')));
     }
     parent::__construct($controller, 'AddJobForm', $fields, $actions, $required);
     $this->setFormAction('JobBoardFormProcessor/doJobForm');
     $this->setFormMethod('POST');
     if ($job) {
         $this->loadDataFrom($job);
     } else {
         $this->enableSpamProtection();
     }
 }
コード例 #2
0
ファイル: KickAssetAdmin.php プロジェクト: heyday/KickAssets
 /**
  * Loads the requirements, checks perms, etc. If an ID is in the URL, that becomes the
  * current folder.
  */
 public function init()
 {
     parent::init();
     if (!Permission::check("ADMIN") && !Permission::check("CMS_ACCESS_BrowseFiles")) {
         return Security::permissionFailure($this, _t('KickAssets.PERMISSIONFAIL', 'You do not have permission to access this section of the CMS.'));
     }
     Requirements::clear();
     Requirements::css('kickassets/css/core.css');
     Requirements::css('kickassets/css/kickassets.css');
     Requirements::javascript('kickassets/javascript/jquery.js');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery-livequery/jquery.livequery.js');
     Requirements::javascript('kickassets/javascript/apprise/apprise-1.5.full.js');
     Requirements::javascript('kickassets/javascript/jquery.tooltip.js');
     Requirements::css('kickassets/javascript/apprise/apprise.css');
     Requirements::javascript('kickassets/javascript/kickassets_ui.js');
     Requirements::javascript('kickassets/javascript/chosen/chosen.jquery.js');
     Requirements::css('kickassets/javascript/chosen/chosen.css');
     Requirements::javascript('kickassets/javascript/jquery.form.js');
     Requirements::javascript('kickassets/javascript/kickassets.js');
     Requirements::css('kickassets/css/kickassets_ui.css');
     if ($this->getRequest()->param('ID')) {
         $this->currentFolder = DataObject::get_by_id("Folder", (int) $this->getRequest()->param('ID'));
         $this->currentPath = KickAssetUtil::relative_asset_dir($this->currentFolder->Filename);
     } else {
         $this->currentFolder = singleton('Folder');
         $this->currentPath = false;
     }
 }
コード例 #3
0
 public function updateEditForm($form)
 {
     $singl = singleton($this->owner->modelClass);
     if ($singl->hasExtension('SoftDeletable')) {
         /* @var $gridfield GridField */
         $gridfield = $form->Fields()->dataFieldByName($this->owner->modelClass);
         $config = $gridfield->getConfig();
         $config->removeComponentsByType('GridFieldDeleteAction');
         if ($this->owner->config()->softdelete_from_list) {
             $config->addComponent(new GridFieldSoftDeleteAction());
         }
         $bulkManager = $config->getComponentByType('GridFieldBulkManager');
         if ($bulkManager && $this->owner->config()->softdelete_from_bulk) {
             $bulkManager->removeBulkAction('delete');
             $bulkManager->addBulkAction('softDelete', 'delete (soft)', 'GridFieldBulkSoftDeleteEventHandler');
         }
         if ($this->filtersOnDeleted()) {
             /* @var $cols GridFieldDataColumns */
             $cols = $gridfield->getConfig()->getComponentByType('GridFieldDataColumns');
             $displayedFields = $cols->getDisplayFields($gridfield);
             $displayedFields['Deleted'] = 'Deleted';
             $cols->setDisplayFields($displayedFields);
         }
     }
     return $form;
 }
コード例 #4
0
 /**
  * Manipulate search form to add some grouping.
  * 
  * @return void
  *
  * @author Sebastian Diel <*****@*****.**>
  * @since 25.06.2014
  */
 public function SearchForm()
 {
     $searchForm = parent::SearchForm();
     $fields = $searchForm->Fields();
     $order = singleton('SilvercartOrder');
     $basicLabelField = new HeaderField('BasicLabelField', $order->fieldLabel('BasicData'));
     $customerLabelField = new HeaderField('CustomerLabelField', $order->fieldLabel('CustomerData'));
     $positionLabelField = new HeaderField('PositionLabelField', $order->fieldLabel('OrderPositionData'));
     $miscLabelField = new HeaderField('MiscLabelField', $order->fieldLabel('MiscData'));
     $origOrderStatusField = $fields->dataFieldByName('q[SilvercartOrderStatus__ID]');
     $orderStatusField = new SilvercartMultiDropdownField('q[SilvercartOrderStatus__ID]', $origOrderStatusField->Title(), $origOrderStatusField->getSource());
     $positionQuantityField = new TextField('q[OrderPositionQuantity]', $order->fieldLabel('OrderPositionQuantity'));
     $positionIsLimitField = new CheckboxField('q[OrderPositionIsLimit]', $order->fieldLabel('OrderPositionIsLimit'));
     $limitField = new TextField('q[SearchResultsLimit]', $order->fieldLabel('SearchResultsLimit'));
     $fields->insertBefore($basicLabelField, 'q[OrderNumber]');
     $fields->insertAfter($fields->dataFieldByName('q[Created]'), 'q[OrderNumber]');
     $fields->insertAfter($orderStatusField, 'q[IsSeen]');
     $fields->insertBefore($customerLabelField, 'q[Member__CustomerNumber]');
     $fields->insertBefore($positionLabelField, 'q[SilvercartOrderPositions__ProductNumber]');
     $fields->insertAfter($positionQuantityField, 'q[SilvercartOrderPositions__ProductNumber]');
     $fields->insertAfter($positionIsLimitField, 'q[OrderPositionQuantity]');
     $fields->insertAfter($miscLabelField, 'q[OrderPositionIsLimit]');
     $fields->insertAfter($limitField, 'q[MiscLabelField]');
     $fields->dataFieldByName('q[SilvercartOrderStatus__ID]')->setEmptyString(_t('SilvercartOrderSearchForm.PLEASECHOOSE'));
     $fields->dataFieldByName('q[SilvercartPaymentMethod__ID]')->setEmptyString(_t('SilvercartOrderSearchForm.PLEASECHOOSE'));
     $fields->dataFieldByName('q[SilvercartShippingMethod__ID]')->setEmptyString(_t('SilvercartOrderSearchForm.PLEASECHOOSE'));
     $fields->dataFieldByName('q[SilvercartShippingAddress__SilvercartCountry__ID]')->setEmptyString(_t('SilvercartOrderSearchForm.PLEASECHOOSE'));
     return $searchForm;
 }
コード例 #5
0
 public function scaffoldFormField($title = null, $params = null)
 {
     if (empty($this->object)) {
         return null;
     }
     $relationName = substr($this->name, 0, -2);
     $hasOneClass = $this->object->hasOneComponent($relationName);
     if ($hasOneClass && singleton($hasOneClass) instanceof Image) {
         $field = new UploadField($relationName, $title);
         $field->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
     } elseif ($hasOneClass && singleton($hasOneClass) instanceof File) {
         $field = new UploadField($relationName, $title);
     } else {
         $titleField = singleton($hasOneClass)->hasField('Title') ? "Title" : "Name";
         $list = DataList::create($hasOneClass);
         // Don't scaffold a dropdown for large tables, as making the list concrete
         // might exceed the available PHP memory in creating too many DataObject instances
         if ($list->count() < 100) {
             $field = new DropdownField($this->name, $title, $list->map('ID', $titleField));
             $field->setEmptyString(' ');
         } else {
             $field = new NumericField($this->name, $title);
         }
     }
     return $field;
 }
コード例 #6
0
 /**
  * Updates the database of a calitrix wiki from beta 1 to beta 2.
  *
  * @author Johannes Klose <*****@*****.**>
  * @return void
  **/
 function updateWiki()
 {
     $tpl =& singleton('template');
     $setPath = isset($this->post['set_dir']) ? trim($this->post['set_dir']) : '';
     $dbFile = $setPath . '/dbconfig.php';
     $setFile = $setPath . '/stdconfig.php';
     if (!file_exists($dbFile) || !file_exists($setFile)) {
         $tpl->assign('isError', true);
         $tpl->assign('error', $this->lang['updateb1_config_failed']);
         return false;
     }
     include $dbFile;
     mysql_connect(DB_HOST, DB_USER, DB_PASS);
     mysql_select_db(DB_NAME);
     mysql_query('CREATE TABLE ' . DB_PREFIX . 'config(config_section VARCHAR(30) NOT NULL, config_item ' . 'VARCHAR(100) NOT NULL, config_value TEXT NOT NULL, PRIMARY KEY (config_section, config_item))');
     mysql_query('UPDATE ' . DB_PREFIX . 'users SET user_access_mask = -1 WHERE user_access_mask = 0');
     $cfg = $this->createConfigTable($setFile);
     $cfg = $this->createConfigFile($cfg, $setFile);
     if ($cfg === false) {
         $tpl->assign('isError', true);
         $tpl->assign('error', sprintf($this->lang['updateb1_update_failed'], mysql_error()));
         return false;
     }
     $this->lockInstaller();
     $tpl->assign('updated', true);
 }
コード例 #7
0
 public function testHasDatabaseFieldOnDataObject()
 {
     $obj = singleton('CompositeDBFieldTest_DataObject');
     $this->assertTrue($obj->hasDatabaseField('MyMoneyAmount'));
     $this->assertTrue($obj->hasDatabaseField('MyMoneyCurrency'));
     $this->assertFalse($obj->hasDatabaseField('MyMoney'));
 }
コード例 #8
0
 /**
  * Get the DisplayFields
  * 
  * @return array
  * @see GridFieldDataColumns::setDisplayFields
  */
 public function getDisplayFields($gridField)
 {
     if (!$this->displayFields) {
         return singleton($gridField->getModelClass())->summaryFields();
     }
     return $this->displayFields;
 }
コード例 #9
0
 /**
  * Get the fieldset to display in the administration section
  */
 function getCMSFields()
 {
     $templateSource = singleton("NewsletterAdmin")->templateSource();
     $fields = new FieldSet(new TabSet("Root", new Tab(_t('NewsletterAdmin.NLSETTINGS', 'Newsletter Settings'), new TextField("Title", _t('NewsletterAdmin.NEWSLTYPE', 'Newsletter Type')), new TreeDropdownField('GroupID', _T('NewsletterAdmin.MAILINGGROUP', 'Mailing list group'), 'Group'), new TextField("FromEmail", _t('NewsletterAdmin.FROMEM', 'From email address')), new DropdownField("Template", _t('NewsletterAdmin.TEMPLATE', 'Template'), $templateSource))));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
コード例 #10
0
 public function process()
 {
     $object = $this->getDataObject();
     if ($object) {
         $object->onScheduledExecution();
         // figure out what our rescheduled date should be
         $timeStr = $object->ExecuteFree;
         if ($object->ExecuteEvery) {
             $executeInterval = $object->ExecuteInterval;
             if (!$executeInterval || !is_numeric($executeInterval)) {
                 $executeInterval = 1;
             }
             $timeStr = '+' . $executeInterval . ' ' . $object->ExecuteEvery;
         }
         $next = strtotime($timeStr);
         if ($next > time()) {
             // in the future
             $nextGen = date('Y-m-d H:i:s', $next);
             $nextId = singleton('QueuedJobService')->queueJob(new ScheduledExecutionJob($object, $this->timesExecuted + 1), $nextGen);
             $object->ScheduledJobID = $nextId;
             $object->write();
         }
     }
     $this->currentStep++;
     $this->isComplete = true;
 }
コード例 #11
0
ファイル: weeklyTime.php プロジェクト: cjbayliss/alloc
function show_timeSheetItems($template_name)
{
    global $date_to_view;
    $current_user =& singleton("current_user");
    global $TPL;
    $query = prepare("SELECT * \n                      FROM timeSheetItem \n                           LEFT JOIN timeSheet ON timeSheetItem.timeSheetID = timeSheet.timeSheetID\n                           LEFT JOIN project ON timeSheet.projectID = project.projectID\n                      WHERE dateTimeSheetItem='%s'\n                            AND timeSheet.personID=%d", date("Y-m-d", $date_to_view), $current_user->get_id());
    $db = new db_alloc();
    $db->query($query);
    while ($db->next_record()) {
        $timeSheetItem = new timeSheetItem();
        $timeSheetItem->read_db_record($db);
        $timeSheetItem->set_values();
        if ($timeSheetItem->get_value("unit") == "Hour") {
            $TPL["daily_hours_total"] += $timeSheetItem->get_value("timeSheetItemDuration");
        }
        $project = new project();
        $project->read_db_record($db);
        $project->set_values();
        if ($project->get_value("projectShortName")) {
            $TPL["item_description"] = $project->get_value("projectShortName");
        } else {
            $TPL["item_description"] = $project->get_value("projectName");
        }
        include_template($template_name);
    }
}
コード例 #12
0
 /**
  * A simple Gridfield factory
  * @param  string $model
  * @param  string $relationname
  * @param  DataObject $reference
  * @return GridField
  */
 public static function create_gridfield_for($model, $relationname, $reference)
 {
     if ($relationname != null && ClassInfo::exists($model)) {
         $config = GridFieldConfig_RelationEditor::create();
         $config->addComponent($gridFieldForm = new GridFieldDetailForm());
         if ($items = $reference->{$relationname}()) {
             if (is_a($items, 'ManyManyList') && ClassInfo::exists('GridFieldManyRelationHandler')) {
                 $config->addComponent(new GridFieldManyRelationHandler(), 'GridFieldPaginator');
             } else {
                 $sortable = singleton($model)->hasExtension('SortableDataExtension');
                 if ($sortable) {
                     $config->addComponent(new GridFieldSortableRows('SortOrder'));
                 }
             }
             $gridfield = GridField::create($relationname, $model, $items, $config);
             $datacolumns = $gridfield->getConfig()->getComponentByType('GridFieldDataColumns');
             $cfields = singleton($model)->summaryFields();
             if (singleton($model)->hasExtension('CMSPublishableDataExtension') && !isset($cfields['PublishStatus'])) {
                 $cfields = array('PublishStatus' => 'PublishStatus') + $cfields;
             }
             $datacolumns->setDisplayFields($cfields);
             return $gridfield;
         } else {
             throw new InvalidArgumentException("Couldn't find relation.");
         }
     } else {
         throw new InvalidArgumentException("Couldn't create GridField because wrong parameters passed to the factory.");
     }
 }
コード例 #13
0
 /**
  * Installs the database.
  *
  * @author Johannes Klose <*****@*****.**>
  * @param  bool $defaultPages Enables installation of default wiki pages if set to true
  * @return void
  **/
 function installDatabase($defaultPages)
 {
     $tpl =& singleton('template');
     include CWIKI_INSTALL_DIR . '/mysql.php';
     include CWIKI_SET_DIR . '/dbconfig.php';
     mysql_connect(DB_HOST, DB_USER, DB_PASS);
     mysql_select_db(DB_NAME);
     foreach ($struct as $tbl => $sql) {
         if (!@mysql_query('CREATE TABLE ' . DB_PREFIX . $tbl . $sql)) {
             return false;
         }
     }
     if (count($tableConflict) > 0) {
         $tpl->assign('isError', true);
         $tpl->assign('error', sprintf($this->lang['install_conflict'], join(', ', $tableConflict)));
     }
     foreach ($data['groups'] as $sql) {
         if (!@mysql_query('INSERT INTO ' . DB_PREFIX . 'groups' . $sql)) {
             return false;
         }
     }
     unset($data['groups']);
     if ($defaultPages) {
         foreach ($data as $tbl => $stmts) {
             foreach ($stmts as $sql) {
                 if (!@mysql_query('INSERT INTO ' . DB_PREFIX . $tbl . $sql)) {
                     return false;
                 }
             }
         }
     }
     return $this->createConfigTable();
 }
 function updateImportForm(Form $form)
 {
     /* @var $owner ModelAdmin */
     $owner = $this->owner;
     $class = $owner->modelClass;
     // Overwrite model imports
     $importerClasses = $owner->stat('model_importers');
     if (is_null($importerClasses)) {
         $models = $owner->getManagedModels();
         foreach ($models as $modelName => $options) {
             $importerClasses[$modelName] = 'ExcelBulkLoader';
         }
         $owner->set_stat('model_importers', $importerClasses);
     }
     $modelSNG = singleton($class);
     $modelName = $modelSNG->i18n_singular_name();
     $fields = $form->Fields();
     $content = _t('ModelAdminExcelExtension.DownloadSample', '<div class="field"><a href="{link}">Download sample file</a></div>', array('link' => $owner->Link($class . '/downloadsample')));
     $file = $fields->dataFieldByName('_CsvFile');
     if ($file) {
         $file->setDescription(ExcelImportExport::getValidExtensionsText());
         $file->getValidator()->setAllowedExtensions(ExcelImportExport::getValidExtensions());
     }
     $fields->removeByName("SpecFor{$modelName}");
     $fields->insertAfter('EmptyBeforeImport', new LiteralField("SampleFor{$modelName}", $content));
     if (!$modelSNG->canDelete()) {
         $fields->removeByName('EmptyBeforeImport');
     }
     $actions = $form->Actions();
     $import = $actions->dataFieldByName('action_import');
     if ($import) {
         $import->setTitle(_t('ModelAdminExcelExtension.ImportExcel', "Import from Excel"));
     }
 }
コード例 #15
0
 public function scaffoldFormField($title = null, $params = null)
 {
     if (empty($this->object)) {
         return null;
     }
     $relationName = substr($this->name, 0, -2);
     $hasOneClass = DataObject::getSchema()->hasOneComponent(get_class($this->object), $relationName);
     if (empty($hasOneClass)) {
         return null;
     }
     $hasOneSingleton = singleton($hasOneClass);
     if ($hasOneSingleton instanceof File) {
         $field = new UploadField($relationName, $title);
         if ($hasOneSingleton instanceof Image) {
             $field->setAllowedFileCategories('image/supported');
         }
         return $field;
     }
     // Build selector / numeric field
     $titleField = $hasOneSingleton->hasField('Title') ? "Title" : "Name";
     $list = DataList::create($hasOneClass);
     // Don't scaffold a dropdown for large tables, as making the list concrete
     // might exceed the available PHP memory in creating too many DataObject instances
     if ($list->count() < 100) {
         $field = new DropdownField($this->name, $title, $list->map('ID', $titleField));
         $field->setEmptyString(' ');
     } else {
         $field = new NumericField($this->name, $title);
     }
     return $field;
 }
コード例 #16
0
 public function execute(WorkflowInstance $workflow)
 {
     if (!($target = $workflow->getTarget())) {
         return true;
     }
     if (class_exists('AbstractQueuedJob') && $this->UnpublishDelay) {
         $job = new WorkflowPublishTargetJob($target, "unpublish");
         $days = $this->UnpublishDelay;
         $after = date('Y-m-d H:i:s', strtotime("+{$days} days"));
         singleton('QueuedJobService')->queueJob($job, $after);
     } else {
         if ($target->hasExtension('WorkflowEmbargoExpiryExtension')) {
             // setting future date stuff if needbe
             // set these values regardless
             $target->DesiredUnPublishDate = '';
             $target->DesiredPublishDate = '';
             $target->write();
             if ($target->hasMethod('doUnpublish')) {
                 $target->doUnpublish();
             }
         } else {
             if ($target->hasMethod('doUnpublish')) {
                 $target->doUnpublish();
             }
         }
     }
     return true;
 }
コード例 #17
0
 public function AddNewListboxForm()
 {
     $action = FormAction::create('doSave', 'Save')->setUseButtonTag('true');
     if (!$this->isFrontend) {
         $action->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept');
     }
     $model = $this->getModel();
     $link = singleton($model);
     $fields = $link->getCMSFields();
     $title = $this->getDialogTitle() ? $this->getDialogTitle() : 'New Item';
     $fields->insertBefore(HeaderField::create('AddNewHeader', $title), $fields->first()->getName());
     $actions = FieldList::create($action);
     $form = Form::create($this, 'AddNewListboxForm', $fields, $actions);
     $fields->push(HiddenField::create('model', 'model', $model));
     /*
     if($link){
     	$form->loadDataFrom($link);
     	$fields->push(HiddenField::create('LinkID', 'LinkID', $link->ID));
     }
     
     // Chris Bolt, fixed this
     //$this->owner->extend('updateLinkForm', $form);
     $this->extend('updateLinkForm', $form);
     // End Chris Bolt
     */
     return $form;
 }
 public function getCMSFields()
 {
     $fields = singleton('DataObject')->getCMSFields();
     $fields->addFieldsToTab('Root.Main', array(new ReadonlyField('SubmittedBy', 'Submitted By'), new ReadonlyField('IPAddress', 'IP Address'), new ReadonlyField('Created', 'Time Submitted'), new ReadonlyField('StatusMessages'), $field = new GridField('Values', 'Responses', $this->Values(), new GridFieldConfig_FlexiFormSubmissionValues())));
     $field->addExtraClass('flexiform');
     return $fields;
 }
コード例 #19
0
 public static function handle_shortcode($arguments, $url, $parser, $shortcode)
 {
     // get all registered cdn things, and see if any of them have URLs that
     // need to be handled by US, instead of looked up. _if_ we need to handle it,
     // perform relevant transforms etc.
     $contentService = singleton('ContentService');
     /* @var $contentService ContentService */
     $cdns = $contentService->getStoreTypes();
     foreach ($cdns as $name => $types) {
         $reader = $contentService->getReader($name);
         if ($actualReader = $reader->providerOfUrl($url)) {
             if ($actualReader instanceof ContentReader) {
                 $contentId = $actualReader->getContentId();
                 $file = File::get()->filter('CDNFile', $contentId)->first();
                 if ($file) {
                     if ($file instanceof Image && isset($arguments['width']) && isset($arguments['height'])) {
                         // return the formatted image
                         $cached = $file->ResizedImage($arguments['width'], $arguments['height']);
                         if ($cached) {
                             return $cached->forTemplate();
                         }
                     }
                 }
             }
         }
     }
     return parent::handle_shortcode($arguments, $url, $parser, $shortcode);
 }
 function __construct($controller, $name, $sourceClass, $fieldList = null, $detailFormFields = null, $sourceFilter = "", $sourceSort = "", $sourceJoin = "")
 {
     parent::__construct($controller, $name, $sourceClass, $fieldList, $detailFormFields, $sourceFilter, $sourceSort, $sourceJoin);
     //Sort by heirarchy, depending on number of parents indent
     $classes = array_reverse(ClassInfo::ancestry($this->controllerClass()));
     foreach ($classes as $class) {
         $singleton = singleton($class);
         $manyManyRelations = $singleton->uninherited('many_many', true);
         if (isset($manyManyRelations) && array_key_exists($this->name, $manyManyRelations)) {
             $this->manyManyParentClass = $class;
             $this->manyManyTable = $class . '_' . $this->name;
             break;
         }
         $belongsManyManyRelations = $singleton->uninherited('belongs_many_many', true);
         if (isset($belongsManyManyRelations) && array_key_exists($this->name, $belongsManyManyRelations)) {
             $singleton = singleton($belongsManyManyRelations[$this->name]);
             $manyManyRelations = $singleton->uninherited('many_many', true);
             $this->manyManyParentClass = $class;
             $relation = array_flip($manyManyRelations);
             $this->manyManyTable = $belongsManyManyRelations[$this->name] . '_' . $relation[$class];
             break;
         }
     }
     $tableClasses = ClassInfo::dataClassesFor($this->sourceClass);
     $source = array_shift($tableClasses);
     $sourceField = $this->sourceClass;
     if ($this->manyManyParentClass == $sourceField) {
         $sourceField = 'Child';
     }
     $parentID = $this->controller->ID;
     $this->sourceJoin .= " LEFT JOIN \"{$this->manyManyTable}\" ON (\"{$source}\".\"ID\" = \"{$this->manyManyTable}\".\"{$sourceField}ID\" AND \"{$this->manyManyTable}\".\"{$this->manyManyParentClass}ID\" = '{$parentID}')";
     $this->joinField = 'Checked';
 }
コード例 #21
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     // Main Content tab
     // Carousel tab
     $carouselItemsGrid = null;
     // Manay to many relations can only be established if we have an id. So put a place holder instead of a grid if this is a new object.
     if ($this->ID == 0) {
         $carouselItemsGrid = TextField::create("CarouselItems", "Carousel Items")->setDisabled(true)->setValue("Page must be saved once before adding Carousel Items.");
     } else {
         $carouselItemsGrid = new GridField('CarouselItems', 'Carousel', $this->CarouselItems()->sort('Archived'), GridFieldConfig_RelationEditor::create());
         $carouselItemsGridUploadComponent = new GridFieldBulkUpload("Image");
         $carouselItemsGridUploadComponent->setUfSetup("setFolderName", $this->ImageFolder("carousel"));
         $carouselItemsGrid->setModelClass('CarouselItem')->getConfig()->addComponent($carouselItemsGridUploadComponent)->addComponent(new GridFieldOrderableRows("SortID"));
     }
     $fields->addFieldToTab('Root.Carousel', $carouselItemsGrid);
     // Links
     $fields->addFieldToTab('Root.Links', new TreeDropdownField('LearnMorePageID', 'Page to link the "Learn More" button to:', 'SiteTree'));
     $fields->addFieldToTab('Root.Links', new TextField('LearnMoreButtonText', 'Text to display on the "Learn More" button:', 'SiteTree'));
     $quickLinksGrid = new GridField('Quicklinks', 'Quicklinks', $this->Quicklinks(), GridFieldConfig_RelationEditor::create());
     $quickLinksGrid->setModelClass('Quicklink');
     $quickLinksFieldGroup = FieldGroup::create($quickLinksGrid)->setTitle('Quick Links');
     $quickLinksFieldGroup->setName("QuicklinkGroup");
     $fields->addFieldToTab('Root.Links', $quickLinksFieldGroup);
     $fields->removeByName('Translations');
     $fields->removeByName('Import');
     $fields->addFieldToTab('Root.Features', ToggleCompositeField::create('FeatureOne', _t('SiteTree.FeatureOne', 'Feature One'), array(new TextField('FeatureOneTitle', 'Title'), new DropdownField('FeatureOneCategory', 'Category', singleton('ExpressHomePage')->dbObject('FeatureOneCategory')->enumValues()), new HTMLEditorField('FeatureOneContent', 'Content'), new TreeDropdownField('FeatureOneLinkID', 'Page to link to', 'SiteTree'), new TextField('FeatureOneButtonText', 'Button text')))->setHeadingLevel(3));
     $fields->addFieldToTab('Root.Features', ToggleCompositeField::create('FeatureTwo', _t('SiteTree.FeatureTwo', 'Feature Two'), array(new TextField('FeatureTwoTitle', 'Title'), new DropdownField('FeatureTwoCategory', 'Category', singleton('ExpressHomePage')->dbObject('FeatureTwoCategory')->enumValues()), new HTMLEditorField('FeatureTwoContent', 'Content'), new TreeDropdownField('FeatureTwoLinkID', 'Page to link to', 'SiteTree'), new TextField('FeatureTwoButtonText', 'Button text')))->setHeadingLevel(3));
     return $fields;
 }
 /**
  * SSCompactNavigator first checks if you are allowed to see the navigation bar, and if so, then checks
  * if third party templates have been specified. If so, it loads them, and provides them with the required
  * variables. If not, it loads the defaults instead.
  */
 public function SSCompactNavigator()
 {
     if (Director::isDev() || Permission::check('CMS_ACCESS_CMSMain')) {
         $RenderTemplate = isset(CompactNavigator::$Template) ? CompactNavigator::$Template : $this->class;
         if (isset(CompactNavigator::$CssTheme)) {
             Requirements::css(CompactNavigator::$CssTheme);
         } else {
             Requirements::css('compactnavigator/css/CompactNavigator.css');
         }
         if (isset(CompactNavigator::$JsTheme)) {
             Requirements::javascript(CompactNavigator::$JsTheme);
         } else {
             Requirements::javascript('compactnavigator/scripts/CompactNavigator.js');
         }
         if (class_exists("CMSMain")) {
             $this->owner->cmsLink = Controller::join_links(singleton("CMSMain")->Link("edit"), "show");
         }
         $this->owner->adminLink = self::$adminLink;
         if ($date = Versioned::current_archived_date()) {
             $this->owner->DisplayMode = 'Archived';
             $this->owner->ArDate = Object::create('Datetime', $date, null);
         } else {
             $this->owner->DisplayMode = Versioned::current_stage();
         }
         return $this->owner->renderWith(array($RenderTemplate, 'CompactNavigatior'));
     }
 }
コード例 #23
0
	function __construct($controller, $name, $sourceClass, $fieldList = null, $detailFormFields = null, $sourceFilter = "", $sourceSort = "", $sourceJoin = "") {

		Deprecation::notice('3.0', 'Use GridField with GridFieldConfig_RelationEditor');

		parent::__construct($controller, $name, $sourceClass, $fieldList, $detailFormFields, $sourceFilter, $sourceSort, $sourceJoin);
		
		$classes = array_reverse(ClassInfo::ancestry($this->controllerClass()));
		foreach($classes as $class) {
			$singleton = singleton($class);
			$manyManyRelations = $singleton->uninherited('many_many', true);
			if(isset($manyManyRelations) && array_key_exists($this->name, $manyManyRelations)) {
				$this->manyManyParentClass = $class;
				$manyManyTable = $class . '_' . $this->name;
				break;
			}
			$belongsManyManyRelations = $singleton->uninherited( 'belongs_many_many', true );
			 if( isset( $belongsManyManyRelations ) && array_key_exists( $this->name, $belongsManyManyRelations ) ) {
				$this->manyManyParentClass = $class;
				$manyManyTable = $belongsManyManyRelations[$this->name] . '_' . $this->name;
				break;
			}
		}
		$tableClasses = ClassInfo::dataClassesFor($this->sourceClass);
		$source = array_shift($tableClasses);
		$sourceField = $this->sourceClass;
		if($this->manyManyParentClass == $sourceField)
			$sourceField = 'Child';
		$parentID = $this->controller->ID;
		
		$this->sourceJoin .= " LEFT JOIN \"$manyManyTable\" ON (\"$source\".\"ID\" = \"$manyManyTable\".\"{$sourceField}ID\" AND \"{$this->manyManyParentClass}ID\" = '$parentID')";
		
		$this->joinField = 'Checked';
	}
コード例 #24
0
 /**
  * The LinkForm for the dialog window
  *
  * @return Form
  **/
 public function LinkForm()
 {
     $link = $this->getLinkObject();
     $action = FormAction::create('doSaveLink', _t('Linkable.SAVE', 'Save'))->setUseButtonTag('true');
     if (!$this->isFrontend) {
         $action->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept');
     }
     $link = null;
     if ($linkID = (int) $this->request->getVar('LinkID')) {
         $link = Link::get()->byID($linkID);
     }
     $link = $link ? $link : singleton('Link');
     $link->setAllowedTypes($this->getAllowedTypes());
     $fields = $link->getCMSFields();
     $title = $link ? _t('Linkable.EDITLINK', 'Edit Link') : _t('Linkable.ADDLINK', 'Add Link');
     $fields->insertBefore(HeaderField::create('LinkHeader', $title), _t('Linkable.TITLE', 'Title'));
     $actions = FieldList::create($action);
     $form = Form::create($this, 'LinkForm', $fields, $actions);
     if ($link) {
         $form->loadDataFrom($link);
         $fields->push(HiddenField::create('LinkID', 'LinkID', $link->ID));
     }
     $this->owner->extend('updateLinkForm', $form);
     return $form;
 }
コード例 #25
0
 function testCanView()
 {
     $adminuser = $this->objFromFixture('Member', 'admin');
     $assetsonlyuser = $this->objFromFixture('Member', 'assetsonlyuser');
     $allcmssectionsuser = $this->objFromFixture('Member', 'allcmssectionsuser');
     // anonymous user
     $this->session()->inst_set('loggedInAs', null);
     $menuItems = singleton('LeftAndMain')->MainMenu();
     $this->assertEquals($menuItems->column('Code'), array(), 'Without valid login, members cant access any menu entries');
     // restricted cms user
     $this->session()->inst_set('loggedInAs', $assetsonlyuser->ID);
     $menuItems = singleton('LeftAndMain')->MainMenu();
     $this->assertEquals($menuItems->column('Code'), array('AssetAdmin', 'Help'), 'Groups with limited access can only access the interfaces they have permissions for');
     // all cms sections user
     $this->session()->inst_set('loggedInAs', $allcmssectionsuser->ID);
     $menuItems = singleton('LeftAndMain')->MainMenu();
     $requiredSections = array('CMSMain', 'AssetAdmin', 'SecurityAdmin', 'Help');
     $this->assertEquals(array_diff($requiredSections, $menuItems->column('Code')), array(), 'Group with CMS_ACCESS_LeftAndMain permission can access all sections');
     // admin
     $this->session()->inst_set('loggedInAs', $adminuser->ID);
     $menuItems = singleton('LeftAndMain')->MainMenu();
     $this->assertContains('CMSMain', $menuItems->column('Code'), 'Administrators can access CMS');
     $this->assertContains('AssetAdmin', $menuItems->column('Code'), 'Administrators can access Assets');
     $this->session()->inst_set('loggedInAs', null);
 }
コード例 #26
0
 function visible()
 {
     $current_user =& singleton("current_user");
     if ($current_user->have_role("manage") && $current_user->prefs["showTimeSheetItemHintHome"]) {
         return true;
     }
 }
 protected function getListId()
 {
     if ($this->listId) {
         return $this->listId;
     }
     $listId = singleton('env')->get('infoboxes.wunderlist.list_id');
     $listTitle = singleton('env')->get('infoboxes.wunderlist.list');
     if (!$listId && $listTitle && file_exists($this->listLocation())) {
         $list = json_decode(file_get_contents($this->listLocation()), true);
         $listId = $list['id'];
     }
     if (!$listId && $listTitle) {
         $lists = array_filter($this->provider->get('lists'), function ($list) use($listTitle) {
             return isset($list['title']) && strtolower($list['title']) == strtolower($listTitle) && isset($list['id']);
         });
         if (empty($lists)) {
             throw new Exception(sprintf('No list could be found with the title: %s', $listTitle));
         }
         $list = array_shift($lists);
         file_put_contents($this->listLocation(), json_encode($list));
         $listId = $list['id'];
     }
     $this->listId = $listId;
     return $listId;
 }
 /**
  * Provides a GUI for the insert/edit shortcode popup
  * @return Form
  **/
 public function ShortcodeForm()
 {
     if (!Permission::check('CMS_ACCESS_CMSMain')) {
         return;
     }
     Config::inst()->update('SSViewer', 'theme_enabled', false);
     // create a list of shortcodable classes for the ShortcodeType dropdown
     $classList = ClassInfo::implementorsOf('Shortcodable');
     $classes = array();
     foreach ($classList as $class) {
         $classes[$class] = singleton($class)->singular_name();
     }
     // load from the currently selected ShortcodeType or Shortcode data
     $classname = false;
     $shortcodeData = false;
     if ($shortcode = $this->request->requestVar('Shortcode')) {
         $shortcode = str_replace("", '', $shortcode);
         //remove BOM inside string on cursor position...
         $shortcodeData = singleton('ShortcodableParser')->the_shortcodes(array(), $shortcode);
         if (isset($shortcodeData[0])) {
             $shortcodeData = $shortcodeData[0];
             $classname = $shortcodeData['name'];
         }
     } else {
         $classname = $this->request->requestVar('ShortcodeType');
     }
     if ($shortcodeData) {
         $headingText = _t('Shortcodable.EDITSHORTCODE', 'Edit Shortcode');
     } else {
         $headingText = _t('Shortcodable.INSERTSHORTCODE', 'Insert Shortcode');
     }
     // essential fields
     $fields = FieldList::create(array(CompositeField::create(LiteralField::create('Heading', sprintf('<h3 class="htmleditorfield-shortcodeform-heading insert">%s</h3>', $headingText)))->addExtraClass('CompositeField composite cms-content-header nolabel'), LiteralField::create('shortcodablefields', '<div class="ss-shortcodable content">'), DropdownField::create('ShortcodeType', 'ShortcodeType', $classes, $classname)->setHasEmptyDefault(true)->addExtraClass('shortcode-type')));
     // attribute and object id fields
     if ($classname) {
         if (class_exists($classname)) {
             $class = singleton($classname);
             if (is_subclass_of($class, 'DataObject')) {
                 if (singleton($classname)->hasMethod('get_shortcodable_records')) {
                     $dataObjectSource = $classname::get_shortcodable_records();
                 } else {
                     $dataObjectSource = $classname::get()->map()->toArray();
                 }
                 $fields->push(DropdownField::create('id', $class->singular_name(), $dataObjectSource)->setHasEmptyDefault(true));
             }
             if ($attrFields = $classname::shortcode_attribute_fields()) {
                 $fields->push(CompositeField::create($attrFields)->addExtraClass('attributes-composite'));
             }
         }
     }
     // actions
     $actions = FieldList::create(array(FormAction::create('insert', _t('Shortcodable.BUTTONINSERTSHORTCODE', 'Insert shortcode'))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setUseButtonTag(true)));
     // form
     $form = Form::create($this, "ShortcodeForm", $fields, $actions)->loadDataFrom($this)->addExtraClass('htmleditorfield-form htmleditorfield-shortcodable cms-dialog-content');
     if ($shortcodeData) {
         $form->loadDataFrom($shortcodeData['atts']);
     }
     $this->extend('updateShortcodeForm', $form);
     return $form;
 }
コード例 #29
0
 public function updateCMSFields(FieldList $fields)
 {
     $gridConfig = singleton('Block')->has_extension('Sortable') ? GridFieldConfig_BlockEditor::create('SortOrder') : GridFieldConfig_BlockEditor::create();
     $gridField = GridField::create('Blocks', _t('PageBlocks.BLOCK', 'Block', 'GridField Title'), $this->owner->Blocks(), $gridConfig);
     $gridField->setModelClass('Block');
     $fields->addFieldsToTab('Root.Main', array($gridField), 'Metadata');
 }
コード例 #30
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     if ($this->ID) {
         // Summit Images
         $summitImageField = singleton('SummitImage')->getCMSFields();
         $config = GridFieldConfig_RelationEditor::create();
         $config->getComponentByType('GridFieldDetailForm')->setFields($summitImageField);
         $gridField = new GridField('SummitImage', 'SummitImage', SummitImage::get(), $config);
         $fields->addFieldToTab('Root.SummitPageImages', $gridField);
         // Summit Image has_one selector
         $dropdown = DropdownField::create('SummitImageID', 'Please choose an image for this page', SummitImage::get()->map("ID", "Title", "Please Select"))->setEmptyString('(None)');
         $fields->addFieldToTab('Root.Main', $dropdown);
         $fields->addFieldsToTab('Root.Main', $ddl_summit = new DropdownField('SummitID', 'Summit', Summit::get()->map('ID', 'Name')));
         $ddl_summit->setEmptyString('(None)');
     }
     $fields->addFieldsToTab('Root.Main', new TextField('HeroCSSClass', 'Hero CSS Class'));
     //Google Conversion Tracking params
     $fields->addFieldToTab("Root.GoogleConversionTracking", new TextField("GAConversionId", "Conversion Id", "994798451"));
     $fields->addFieldToTab("Root.GoogleConversionTracking", new TextField("GAConversionLanguage", "Conversion Language", "en"));
     $fields->addFieldToTab("Root.GoogleConversionTracking", new TextField("GAConversionFormat", "Conversion Format", "3"));
     $fields->addFieldToTab("Root.GoogleConversionTracking", new ColorField("GAConversionColor", "Conversion Color", "ffffff"));
     $fields->addFieldToTab("Root.GoogleConversionTracking", new TextField("GAConversionLabel", "Conversion Label", "IuM5CK3OzQYQ89at2gM"));
     $fields->addFieldToTab("Root.GoogleConversionTracking", new TextField("GAConversionValue", "Conversion Value", "0"));
     $fields->addFieldToTab("Root.GoogleConversionTracking", new CheckboxField("GARemarketingOnly", "Remarketing Only"));
     //Facebook Conversion Params
     $fields->addFieldToTab("Root.FacebookConversionTracking", new TextField("FBPixelId", "Pixel Id", "6013247449963"));
     $fields->addFieldToTab("Root.FacebookConversionTracking", new TextField("FBValue", "Value", "0.00"));
     $fields->addFieldToTab("Root.FacebookConversionTracking", new TextField("FBCurrency", "Currency", "USD"));
     //Twitter
     $fields->addFieldToTab("Root.TwitterConversionTracking", new TextField("TwitterPixelId", "Pixel Id", "l5lav"));
     return $fields;
 }