function FieldHolder() {
		
		
		Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/prototype/prototype.js');
		Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/behaviour/behaviour.js');
		Requirements::javascript(SAPPHIRE_DIR . '/javascript/prototype_improvements.js');
		Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/effects.js');
		Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
		Requirements::javascript(SAPPHIRE_DIR . '/javascript/TableListField.js');
		
		// swap the js file
		Requirements::block(SAPPHIRE_DIR . '/javascript/TableField.js');
		Requirements::javascript('modifiedtablefield/javascript/ModifiedTableField.js');
		
		
		Requirements::css(SAPPHIRE_DIR . '/css/TableListField.css');
		

		$defaults = $this->fieldDefaults;
		if ($this->fieldDefaults == null && !is_array($this->fieldDefaults)) {
			$sourceClass = $this->sourceClass;
			
			$defaults = singleton($sourceClass)->stat('defaults');
		}
		
		if (count($defaults) > 0) {
			Requirements::customScript("var ".$this->name."_fieldDefaults = ".Convert::array2json($defaults));
		}
		
		
		return $this->renderWith($this->template);
	}
 function CreatePackageJson()
 {
     $extensionData = ExtensionData::get();
     $count = 0;
     if ($extensionData && !empty($extensionData)) {
         $count = $extensionData->Count();
         $filename = 'packages.json';
         $repo = array('packages' => array());
         foreach ($extensionData as $extension) {
             // Include only Approved extensions
             if ($extension->Accepted == '1') {
                 $json = new JsonHandler($extension->Url);
                 $jsonData = $json->cloneJson();
                 $packages = $jsonData['AllRelease'];
                 $dumper = new ArrayDumper();
                 foreach ($packages as $package) {
                     $repo['packages'][$package->getPrettyName()][$package->getPrettyVersion()] = $dumper->dump($package);
                 }
             }
         }
         if (!empty($repo['packages'])) {
             $packagesJsonData = Convert::array2json($repo);
             $packageJsonFile = fopen(BASE_PATH . DIRECTORY_SEPARATOR . $filename, 'w');
             fwrite($packageJsonFile, $packagesJsonData);
             fclose($packageJsonFile);
             echo "<br /><br /><strong> package.json file created successfully...</strong><br />";
         } else {
             throw new InvalidArgumentException('package.json file could not be created');
         }
     }
 }
 public function doSearch($gridField, $request)
 {
     $dataClass = $gridField->getList()->dataClass();
     $allList = $this->searchList ? $this->searchList : DataList::create($dataClass);
     $searchFields = $this->getSearchFields() ? $this->getSearchFields() : $this->scaffoldSearchFields($dataClass);
     if (!$searchFields) {
         throw new LogicException(sprintf('GridFieldAddExistingAutocompleter: No searchable fields could be found for class "%s"', $dataClass));
     }
     $params = array();
     foreach ($searchFields as $searchField) {
         $name = strpos($searchField, ':') !== FALSE ? $searchField : "{$searchField}:StartsWith";
         $params[$name] = $request->getVar('gridfield_relationsearch');
     }
     if (!$gridField->getList() instanceof UnsavedRelationList) {
         $allList = $allList->subtract($gridField->getList());
     }
     $results = $allList->filterAny($params)->sort(strtok($searchFields[0], ':'), 'ASC')->limit($this->getResultsLimit());
     $json = array();
     $originalSourceFileComments = Config::inst()->get('SSViewer', 'source_file_comments');
     Config::inst()->update('SSViewer', 'source_file_comments', false);
     foreach ($results as $result) {
         $json[$result->ID] = html_entity_decode(SSViewer::fromString($this->resultsFormat)->process($result));
     }
     Config::inst()->update('SSViewer', 'source_file_comments', $originalSourceFileComments);
     return Convert::array2json($json);
 }
 public function load($request)
 {
     $response = new SS_HTTPResponse();
     $response->addHeader('Content-Type', 'application/json');
     $response->setBody(Convert::array2json(array("_memberID" => Member::currentUserID())));
     return $response;
 }
 public function load($request)
 {
     $response = new SS_HTTPResponse();
     $response->addHeader('Content-Type', 'application/json');
     $response->setBody(Convert::array2json(call_user_func($this->source, $request->getVar('val'))));
     return $response;
 }
 public function search($request)
 {
     $list = DataList::create($this->getConfig('classToSearch'));
     $params = array();
     $searchFields = $this->getConfig('searchFields');
     foreach ($searchFields as $searchField) {
         $name = strpos($searchField, ':') !== false ? $searchField : "{$searchField}:partialMatch";
         $params[$name] = $request->getVar('term');
     }
     $start = (int) $request->getVar('id') ? (int) $request->getVar('id') * $this->getConfig('resultsLimit') : 0;
     $list = $list->filterAny($params)->exclude($this->getConfig('excludes'));
     $filter = $this->getConfig('filter');
     if (count($filter) > 0) {
         $list = $list->filter($filter);
     }
     $total = $list->count();
     $results = $list->sort(strtok($searchFields[0], ':'), 'ASC')->limit($this->getConfig('resultsLimit'), $start);
     $return = array('list' => array(), 'total' => $total);
     $originalSourceFileComments = Config::inst()->get('SSViewer', 'source_file_comments');
     Config::inst()->update('SSViewer', 'source_file_comments', false);
     foreach ($results as $object) {
         $return['list'][] = array('id' => $object->ID, 'resultsContent' => html_entity_decode(SSViewer::fromString($this->getConfig('resultsFormat'))->process($object)), 'selectionContent' => SSViewer::fromString($this->getConfig('selectionFormat'))->process($object));
     }
     Config::inst()->update('SSViewer', 'source_file_comments', $originalSourceFileComments);
     return Convert::array2json($return);
 }
 public function Field($properties = array())
 {
     $config = array('separator' => $this->getConfig('separator') ? $this->getConfig('separator') : ', ', 'showcalendar' => $this->getConfig('showcalendar'), 'isoDateformat' => $this->getConfig('dateformat'), 'jquerydateformat' => DateField_View_JQuery::convert_iso_to_jquery_format($this->getConfig('dateformat')), 'min' => $this->getConfig('min'), 'max' => $this->getConfig('max'));
     // Add other jQuery UI specific, namespaced options (only serializable, no callbacks etc.)
     // TODO Move to DateField_View_jQuery once we have a properly extensible HTML5 attribute system for FormField
     $jqueryUIConfig = array();
     foreach ($this->getConfig() as $k => $v) {
         if (preg_match('/^jQueryUI\\.(.*)/', $k, $matches)) {
             $jqueryUIConfig[$matches[1]] = $v;
         }
     }
     if ($jqueryUIConfig) {
         $config['jqueryuiconfig'] = Convert::array2json(array_filter($jqueryUIConfig));
     }
     $config = array_filter($config);
     foreach ($config as $k => $v) {
         $this->setAttribute('data-' . $k, $v);
     }
     // Three separate fields for day, month and year (not available for multidates)
     if ($this->getConfig('dmyfields')) {
         user_error("MultiDateField doen't work with separate fields for day/month/year");
     }
     // Default text input field
     $html = parent::Field();
     return $html;
 }
 /**
  * Formats JSON so that it is usable by the JS component
  * 
  * @param  SS_List $list The list to format
  * @return string        JSON
  */
 protected function formatJSON(SS_List $list)
 {
     $ret = array();
     foreach ($list as $item) {
         $ret[] = array('id' => $item->{$this->idField}, 'label' => $item->{$this->labelField});
     }
     return Convert::array2json($ret);
 }
 protected function getCartCustomizations()
 {
     $config = self::$cart_config;
     if ($config && is_array($config)) {
         return Convert::array2json($config);
     }
     return;
 }
 /**
  * @return string
  */
 public function process()
 {
     if (isset($_POST['SourceURL'])) {
         $sourceURL = $_POST['SourceURL'];
         $bIsCloudinary = CloudinaryVideo::isCloudinary($sourceURL);
         $bIsYoutube = YoutubeVideo::is_youtube($sourceURL);
         $bIsVimeo = VimeoVideo::is_vimeo($sourceURL);
         $video = null;
         if ($bIsYoutube || $bIsVimeo || $bIsCloudinary) {
             if ($bIsCloudinary) {
                 $filterClass = 'CloudinaryVideo';
                 $fileType = 'video';
             } elseif ($bIsYoutube) {
                 $filterClass = 'YoutubeVideo';
                 $fileType = 'youtube';
             } else {
                 $filterClass = 'VimeoVideo';
                 $fileType = 'vimeo';
             }
             $funcForID = $bIsYoutube ? 'youtube_id_from_url' : 'vimeo_id_from_url';
             $funcForDetails = $bIsYoutube ? 'youtube_video_details' : 'vimeo_video_details';
             if ($bIsCloudinary) {
                 $arr = Config::inst()->get('CloudinaryConfigs', 'settings');
                 if (isset($arr['CloudName']) && !empty($arr['CloudName'])) {
                     $arrPieces = explode('/', $sourceURL);
                     $arrFileName = array_slice($arrPieces, 7);
                     $fileName = implode('/', $arrFileName);
                     $publicID = substr($fileName, 0, strrpos($fileName, '.'));
                     $video = $filterClass::get()->filterAny(array('URL' => $sourceURL, 'PublicID' => $publicID))->first();
                     if (!$video) {
                         $api = new \Cloudinary\Api();
                         $resource = $api->resource($publicID, array("resource_type" => "video"));
                         //qoogjqs9ksyez7ch8sh5
                         $json = json_encode($resource);
                         $arrResource = Convert::json2array($json);
                         $video = new $filterClass(array('Title' => $arrResource['public_id'] . '.' . $arrResource['format'], 'PublicID' => $arrResource['public_id'], 'Version' => $arrResource['version'], 'URL' => $arrResource['url'], 'SecureURL' => $arrResource['secure_url'], 'FileType' => $arrResource['resource_type'], 'FileSize' => $arrResource['bytes'], 'Format' => $arrResource['format'], 'Signature' => isset($arrResource['signature']) ? $arrResource['signature'] : ''));
                         $video->write();
                     }
                 }
             } else {
                 $video = $filterClass::get()->filter('URL', $sourceURL)->first();
                 if (!$video) {
                     $sourceID = $filterClass::$funcForID($sourceURL);
                     $details = $filterClass::$funcForDetails($sourceID);
                     $video = new $filterClass(array('Title' => $details['title'], 'Duration' => $details['duration'], 'URL' => $sourceURL, 'secure_url' => $sourceURL, 'PublicID' => $sourceID, 'FileType' => $fileType));
                     $video->write();
                 }
             }
             if ($video) {
                 $this->value = $iVideoID = $video->ID;
                 $file = $this->customiseCloudinaryFile($video);
                 return Convert::array2json(array('colorselect_url' => $file->UploadFieldImageURL, 'thumbnail_url' => $file->UploadFieldThumbnailURL, 'fieldname' => $this->getName(), 'id' => $file->ID, 'url' => $file->URL, 'buttons' => $file->UploadFieldFileButtons, 'more_files' => $this->canUploadMany(), 'field_id' => $this->ID()));
             }
         }
     }
     return Convert::array2json(array());
 }
 /**
  * Removes a presentation from the user's random list
  * @param  int $id The presentation ID     
  */
 public function removePresentation($id)
 {
     if (!$this->owner->PresentationList) {
         return;
     }
     $ids = Convert::json2array($this->owner->PresentationList);
     unset($ids[$id]);
     $this->owner->PresentationList = Convert::array2json($ids);
     $this->owner->write();
 }
 /**
  * @param array $properties
  * @return HTMLText
  */
 public function Field($properties = array())
 {
     $this->addExtraClass('prettycheckablefield')->setAttribute('data-prettycheckableconfig', Convert::array2json($this->pretty_checkable_config));
     //allow for not including default styles
     if ($this->config()->get('require_css') == true) {
         Requirements::css(PRETTY_CHECKABLE_FIELD_THIRDPARTY . '/prettyCheckable-2.1.2/dist/prettyCheckable.css');
     }
     Requirements::javascript(PRETTY_CHECKABLE_FIELD_THIRDPARTY . '/prettyCheckable-2.1.2/dist/prettyCheckable.min.js');
     Requirements::javascript(PRETTY_CHECKABLE_FIELD_JAVASCRIPT . '/pretty.checkable.box.field.js');
     return parent::Field($properties);
 }
 function Field($properties = array())
 {
     $this->addExtraClass('timepicker')->setAttribute('autocomplete', 'off')->setAttribute('data-jqueryuiconfig', Convert::array2json($this->timePickerConfig));
     Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
     Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
     Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-ui/jquery-ui.js');
     Requirements::javascript(TIMEPICKERFIELD_MODULE . '/javascript/jquery.ui.timepicker.js');
     Requirements::javascript(TIMEPICKERFIELD_MODULE . '/javascript/timepickerfield.js');
     Requirements::css(TIMEPICKERFIELD_MODULE . '/css/jquery.ui.timepicker.css');
     return parent::Field($properties);
 }
 /**
  * @param array $properties
  * @return HTMLText
  */
 public function Field($properties = array())
 {
     $this->addExtraClass('selectboxfield')->setAttribute('data-selectboxconfig', Convert::array2json($this->selectbox_config));
     //allow for not including default styles
     if ($this->config()->get('require_css') == true) {
         Requirements::css(SELECTBOX_DROPDOWN_FIELD_DIR_THIRD_PARTY_DIR . 'jquery.selectbox-0.2/css/jquery.selectbox.css');
     }
     Requirements::javascript(SELECTBOX_DROPDOWN_FIELD_DIR_THIRD_PARTY_DIR . 'jquery.selectbox-0.2/js/jquery.selectbox-0.2.min.js');
     Requirements::javascript(SELECTBOX_DROPDOWN_FIELD_JAVASCRIPT . '/selectbox.dropdown.field.js');
     return parent::Field($properties);
 }
 public function getinfo()
 {
     $publicID = CloudinaryFile::get_public_id($_REQUEST['cloudinary_id']);
     $api = CloudinaryFile::get_api();
     $type = CloudinaryFile::get_resource_type($_REQUEST['cloudinary_id']);
     $data = $api->resource(urlencode($publicID), array('resource_type' => $type));
     if ($data) {
         $data = $data->getArrayCopy();
         return Convert::array2json($data);
     }
     return Convert::array2json(array('Error' => 1));
 }
 public function generateJS()
 {
     $arrConfigs = array('status' => array('lines', 'words', 'cursor'), 'toolbar' => array());
     $buttonConfigs = Config::inst()->get('MarkdownEditorConfig', 'button_configs');
     foreach ($this->buttons as $button) {
         if (array_key_exists($button, $buttonConfigs)) {
             $arrConfigs['toolbar'][] = $buttonConfigs[$button];
         }
     }
     $strJSON = Convert::array2json($arrConfigs);
     return sprintf('markdownEditorConfigs.%s = %s;', $this->identifier, $strJSON);
 }
 public function locationData()
 {
     // Get the locations from the database, exclude any that don't have LatLng's defined
     $infoWindowList = Location::get()->exclude(array('lat' => null, 'lng' => null));
     if ($infoWindowList) {
         $InfoWindows = array();
         foreach ($infoWindowList as $obj) {
             $InfoWindows[] = array('lat' => $obj->lat, 'lng' => $obj->lng, 'info' => $obj->Name . "<br />" . $obj->InfoWindow);
         }
         $InfoWindows = Convert::array2json($InfoWindows);
         // Return a JSON object for GoogleMapConfig.js to use
         return $InfoWindows;
     }
 }
 public function results($data, $form)
 {
     $query = $form->getSearchQuery();
     $results = $form->getResults(5);
     foreach ($results as $item) {
         $item->URL = $item->hasMethod('Link') ? $item->Link() : $item->URLSegment;
     }
     // We want to add a content type so the application knows it will be dealing with json.
     $this->response->addHeader('Content-Type', 'application/json');
     // We require an associative array at the top level, so we'll create this and insert our search results.
     $data = array('list' => $results->toNestedArray(), 'query' => array($query));
     // Convert this list to json so we can interate through using javascript.
     return Convert::array2json($data);
 }
 public function load($request)
 {
     $response = new SS_HTTPResponse();
     $response->addHeader('Content-Type', 'application/json');
     $items = call_user_func($this->source, $request->getVar('val'));
     $results = array();
     if ($items) {
         foreach ($items as $k => $v) {
             $results[] = array('k' => $k, 'v' => $v);
         }
     }
     $response->setBody(Convert::array2json($results));
     return $response;
 }
    public function bookings($request)
    {
        $start = (int) $request->getVar('start');
        $end = (int) $request->getVar('end');
        $result = array();
        // First load standard non-recurring events that fall between the start
        // and end date.
        $events = $this->parent->Events(sprintf('"CalendarEvent"."Recursion" = 0 AND (
					"StartDate" BETWEEN \'%1$s\' AND \'%2$s\'
					OR "EndDate" BETWEEN \'%1$s\' AND \'%2$s\'
					OR ("StartDate" < \'%1$s\' AND "EndDate" > \'%2$s\')
				)', date('Y-m-d', $start), date('Y-m-d', $end)), null, 'INNER JOIN "CalendarEvent" ON "CalendarEvent"."ID" = "CalendarDateTime"."EventID"');
        // Then load every recurring event and see if they fall between the start
        // and end.
        $recurring = $this->parent->Events(sprintf('"CalendarEvent"."Recursion" = 1
				AND ("EndDate" IS NULL OR "EndDate" > \'%s\')
				AND ("StartDate" IS NULL OR "StartDate" < \'%s\')', date('Y-m-d', $start), date('Y-m-d', $end)), null, 'INNER JOIN "CalendarEvent" ON "CalendarEvent"."ID" = "CalendarDateTime"."EventID"');
        // Now loop through each day in the specified date range, and check
        // each recurring date to see if it occurs on that day. Note that
        // recurring events always start and end on the same day.
        if ($recurring) {
            foreach ($recurring as $datetime) {
                $counter = $start;
                $days = 0;
                while ($counter <= $end) {
                    if ($counter > strtotime($datetime->EndDate)) {
                        break;
                    }
                    if ($datetime->Event()->recursionHappensOn($counter)) {
                        $_datetime = clone $datetime;
                        $_datetime->ID = -1;
                        $_datetime->StartDate = date('Y-m-d', $counter);
                        $_datetime->EndDate = date('Y-m-d', $counter);
                        $events->push($_datetime);
                    }
                    $counter = sfTime::add($counter, 1, sfTime::DAY);
                    $days++;
                }
            }
        }
        foreach ($events as $event) {
            $title = $event->EventTitle();
            if ($this->parent->Type != 'Single') {
                $title .= " ({$event->BookingQuantity} {$this->parent->Title})";
            }
            $result[] = array('id' => $event->ID, 'title' => $title, 'start' => $event->getStartTimestamp(), 'end' => $event->getEndTimestamp(), 'allDay' => (bool) $event->is_all_day, 'url' => Controller::join_links('admin/show', $event->EventID));
        }
        return Convert::array2json($result);
    }
 public function update(SS_HTTPRequest $r)
 {
     $ret = array();
     $filter = null;
     if ($filter = $r->requestVar('q')) {
         $filter = "{$this->filteredField} = '" . Convert::raw2sql($filter) . "'";
     }
     $results = DataObject::get($this->sourceClass, $filter);
     if ($results) {
         foreach ($results as $r) {
             $ret[$r->{$this->returnKey}] = $r->{$this->returnLabel};
         }
     }
     return Convert::array2json($ret);
 }
 public function updateDateTimeCMSFields($fields)
 {
     if (!($locations = DataObject::get('EventLocation'))) {
         return;
     }
     $capacities = array();
     foreach ($locations as $location) {
         if ($location->Capacity) {
             $capacities[$location->ID] = (int) $location->Capacity;
         }
     }
     $dropdown = new DropdownField('LocationID', _t('EventLocations.LOCATION', 'Location'), $locations->map('ID', 'Title'), null, null, true);
     $dropdown->addExtraClass('{ capacities: ' . Convert::array2json($capacities) . ' }');
     $fields->addFieldToTab('Root.Main', $dropdown, 'StartDate');
 }
 /**
  * get markdown image url
  *
  * @return string
  */
 public function getImageTag()
 {
     $strRet = '';
     if (isset($_POST['Image']) && $_POST['Image'] && isset($_POST['Width']) && isset($_POST['Height']) && isset($_POST['AltText'])) {
         $arrImages = reset($_POST['Image']);
         $strRet = "[cloudinary_image,id=" . $arrImages[0];
         if (!empty($_POST['Width']) && !empty($_POST['Height'])) {
             $strRet .= ",width=" . $_POST['Width'] . ",height=" . $_POST['Height'];
         }
         if (!empty($_POST['AltText'])) {
             $strRet .= ",alt=" . $_POST['AltText'];
         }
         $strRet .= "]";
     }
     return Convert::array2json(array('Markdown' => $strRet));
 }
 /**
  * Gets any notices relevant to the present time and current users
  * @return JSON
  **/
 public function notices($request)
 {
     $now = SS_Datetime::now()->getValue();
     $member = Member::currentUser();
     $notices = TimedNotice::get()->where("\n\t\t\tStartTime < '{$now}' AND \n\t\t\t(EndTime > '{$now}' OR EndTime IS NULL) \n\t\t");
     if ($notices->count()) {
         $notices = ArrayList::create($notices->toArray());
         foreach ($notices as $notice) {
             if ($notice->CanViewType == 'OnlyTheseUsers') {
                 if ($member && !$member->inGroups($notice->ViewerGroups())) {
                     $notices->remove($notice);
                 }
             }
         }
     }
     return Convert::array2json($notices->toNestedArray());
 }
 /**
  * Handles returning the JSON events data for a time range.
  *
  * @param  SS_HTTPRequest $request
  * @return SS_HTTPResponse
  */
 public function eventsdata($request)
 {
     $start = $request->getVar('start');
     $end = $request->getVar('end');
     // for testing
     if (!$end) {
         $end = '2013-12-12';
     }
     $events = $this->owner->data()->getEventList(sfDate::getInstance($start)->date(), sfDate::getInstance($end)->date(), null, null);
     $result = array();
     if ($events) {
         foreach ($events as $event) {
             $result[] = array('id' => $event->ID, 'title' => $event->getTitle(), 'start' => strtotime("{$event->StartDate} {$event->StartTime}"), 'end' => strtotime("{$event->EndDate} {$event->EndTime}"), 'startTime' => $event->getFormattedStartTime(), 'endTime' => $event->getFormattedEndTime(), 'allDay' => (bool) $event->AllDay, 'url' => $event->Link());
         }
     }
     $this->owner->getRequest()->addHeader('Content-Type', 'application/json');
     return Convert::array2json($result);
 }
 public function index(SS_HTTPRequest $r)
 {
     $username = $r->postVar('username');
     $password = $r->postVar('password');
     if (!$username || !$password) {
         return $this->httpError(400, "You must provide 'username' and 'password' parameters in the request");
     }
     if ($member = Member::get()->filter('Email', $username)->first()) {
         if ($member->checkPassword($password)) {
             $member->assignToken();
             $member->write();
             $response = new SS_HTTPResponse(200);
             $response->addHeader('Content-type', 'application/json')->setBody(Convert::array2json(array('token' => $member->AuthenticationToken)));
             return $response;
         }
     }
     return $this->httpError(403, "Invalid login");
 }
 public function items()
 {
     if ($this->Days == null) {
         $this->Days = 30;
     }
     // Use the pageID to check if this call is the result of some javascript.
     $pageFlag = $this->getRequest()->getVar('pageFlag');
     if (!isset($pageFlag)) {
         return $this->interactions->getPopularInteractions('page-view', 'Page', $this->Days);
     } else {
         // We want to add a content type so the application knows it will be dealing with json.
         $this->response->addHeader('Content-Type', 'application/json');
         // We require an associative array at the top level, so we'll create this and insert our data array.
         $data = array('list' => $this->interactions->getPopularInteractions('page-view', 'Page', $this->Days)->toNestedArray());
         // Convert this array to json so we can interate through using javascript.
         return Convert::array2json($data);
     }
 }
 public function write()
 {
     $writableData = array_intersect_key($this->record, $this->db());
     $id = $this->getID();
     if ($id) {
         $result = self::service()->request('/RestDataObject/' . $id, 'PUT', Convert::array2json($writableData));
         if ($result->getStatusCode() == 200) {
         }
     } else {
         $result = self::service()->request('/RestDataObject/', 'POST', Convert::array2json($writableData));
         if ($result->getStatusCode() == 201) {
             $data = Convert::json2array($result->getBody());
             $this->record['ID'] = $data["ID"];
             $this->getID();
         }
     }
     return $this->ID;
 }
 public function Field($properties = array())
 {
     $config = array('showcalendar' => $this->getConfig('showcalendar'), 'isoDateformat' => $this->getConfig('dateformat'), 'jquerydateformat' => DateDropdownField_View_JQuery::convert_iso_to_jquery_format($this->getConfig('dateformat')), 'min' => $this->getConfig('min'), 'max' => $this->getConfig('max'), 'yearRange' => $this->getConfig('yearRange'));
     // Add other jQuery UI specific, namespaced options (only serializable, no callbacks etc.)
     // TODO Move to DateField_View_jQuery once we have a properly extensible HTML5 attribute system for FormField
     $jqueryUIConfig = array();
     foreach ($this->getConfig() as $k => $v) {
         if (preg_match('/^jQueryUI\\.(.*)/', $k, $matches)) {
             $jqueryUIConfig[$matches[1]] = $v;
         }
     }
     if ($jqueryUIConfig) {
         $config['jqueryuiconfig'] = Convert::array2json(array_filter($jqueryUIConfig));
     }
     $config = array_filter($config);
     foreach ($config as $k => $v) {
         $this->setAttribute('data-' . $k, $v);
     }
     // Three separate fields for day, month and year
     if ($this->getConfig('dmyfields')) {
         // values
         $valArr = $this->valueObj ? $this->valueObj->toArray() : null;
         // fields
         $fieldNames = Zend_Locale::getTranslationList('Field', $this->locale);
         $fieldDay = NumericField::create($this->name . '[day]', false, $valArr ? $valArr['day'] : null)->addExtraClass('day')->setAttribute('placeholder', $this->getConfig('dmyplaceholders') ? $fieldNames['day'] : null)->setMaxLength(2);
         $fieldMonth = NumericField::create($this->name . '[month]', false, $valArr ? $valArr['month'] : null)->addExtraClass('month')->setAttribute('placeholder', $this->getConfig('dmyplaceholders') ? $fieldNames['month'] : null)->setMaxLength(2);
         $fieldYear = NumericField::create($this->name . '[year]', false, $valArr ? $valArr['year'] : null)->addExtraClass('year')->setAttribute('placeholder', $this->getConfig('dmyplaceholders') ? $fieldNames['year'] : null)->setMaxLength(4);
         // order fields depending on format
         $sep = $this->getConfig('dmyseparator');
         $format = $this->getConfig('dateformat');
         $fields = array();
         $fields[stripos($format, 'd')] = $fieldDay->Field();
         $fields[stripos($format, 'm')] = $fieldMonth->Field();
         $fields[stripos($format, 'y')] = $fieldYear->Field();
         ksort($fields);
         $html = implode($sep, $fields);
         // dmyfields doesn't work with showcalendar
         $this->setConfig('showcalendar', false);
     } else {
         $html = parent::Field();
     }
     return $html;
 }
 /**
  * Refresh the attached files box. This method may receive a list of IDs,
  * but it will only accept the last one in the list. 
  *
  * @param SS_HTTPRequest $request
  * @return SSViewer
  */
 public function refresh(SS_HTTPRequest $request)
 {
     ContentNegotiator::disable();
     if ($id = $request->requestVar('FileIDs')) {
         if (!is_numeric($id)) {
             $arr = explode(',', $id);
             if (is_array($arr)) {
                 $id = end($arr);
             }
         }
         $this->setValue($id);
         $name = null;
         if (is_numeric($id)) {
             if ($file = DataObject::get_by_id($this->baseFileClass, Convert::raw2sql($id))) {
                 $name = $file->Name;
             }
         }
     }
     return Convert::array2json(array('html' => $this->renderWith('AttachedFiles'), 'success' => sprintf(_t('Uploadify.SUCCESSFULADDSINGLE', 'Added file "%s" successfully.'), $name)));
 }