public function __construct($name, $options = array()) { // Set map defaults $defaults = ["width" => "100%", "height" => "500px", "heading" => "", "lng_field" => "Form_ItemEditForm_Lng", "lat_field" => "Form_ItemEditForm_Lat", "tab" => "Root_Location", "address_field" => "Address", "map_zoom" => 18, "start_lat" => "51.508515", "start_lng" => "-0.125487"]; // Merge provided options with defaults to create params $params = array_replace_recursive($defaults, $options); // Set css of map $css = "style='width: " . $params['width'] . "; height: " . $params['height'] . ";'"; if (defined('GOOGLE_MAP_KEY') && empty($google_map_api_key)) { $google_map_api_key = GOOGLE_MAP_KEY; } if (empty($google_map_api_key)) { throw new InvalidArgumentException('you must provide a valid google maps api key!'); } // Set up array to be fed to the JS $js = ["lat_field" => $params['lat_field'], "lng_field" => $params['lng_field'], "tab" => $params['tab'], "address_field" => $params['address_field'], "zoom" => $params['map_zoom'], "start_lat" => $params['start_lat'], "start_lng" => $params['start_lng'], "key" => $google_map_api_key]; // Build content of form field $content = ""; if ($params['heading']) { $content .= "<h4>" . $params['heading'] . "</h4>"; } $content .= "<div id='admin-map-" . $name . "' class='admin-google-map' " . $css . " data-setup='" . json_encode($js) . "'></div>"; $this->content = $content; // Establish requirements Requirements::javascript(ADMIN_GOOGLE_MAP_DIR . "/js/admin-google-map.js"); if (!$this->stat('jquery_included')) { Requirements::javascript(THIRDPARTY_DIR . "/jquery/jquery.js"); } parent::__construct($name, $this->content); }
public function __construct($content, $type = 'info', $name = null) { self::$count++; if ($name === null) { $name = 'AlertMessageField' . self::$count; } $content = '<div class="message ' . $type . '" id="' . $name . '">' . $content . '</div>'; parent::__construct($name, $content); }
function __construct($name, $title = "") { $totalNumberOfDaysBack = $this->numberOfDays + $this->endingDaysBack; $data = DB::query("\n\t\t\tSELECT COUNT(ID) myCount, \"Title\"\n\t\t\tFROM \"GoogleCustomSearchPage_Record\"\n\t\t\tWHERE Created > ( NOW() - INTERVAL " . $totalNumberOfDaysBack . " DAY )\n\t\t\t\tAND Created < ( NOW() - INTERVAL " . $this->endingDaysBack . " DAY )\n\t\t\tGROUP BY \"Title\"\n\t\t\tHAVING COUNT(\"ID\") >= {$this->minimumCount}\n\t\t\tORDER BY myCount DESC\n\t\t"); if (!$this->minimumCount) { $this->minimumCount++; } $content = ""; if ($title) { $content .= "<h2>" . $title . "</h2>"; } $content .= "\n\t\t<div id=\"SearchHistoryTableForCMS\">\n\t\t\t<h3>Search Phrases entered at least " . $this->minimumCount . " times between " . date("Y-M-d", strtotime("-" . $totalNumberOfDaysBack . " days")) . " and " . date("Y-M-d", strtotime("-" . $this->endingDaysBack . " days")) . "</h3>\n\t\t\t<table class=\"highToLow\" style=\"width: 100%;\">"; $list = array(); foreach ($data as $key => $row) { if (!$key) { $maxWidth = $row["myCount"]; } $multipliedWidthInPercentage = floor($row["myCount"] / $maxWidth * 100); $list[$row["myCount"] . "-" . $key] = $row["Title"]; $content .= ' <tr> <td style="text-align: right; width: 30%; padding: 5px;"> ' . $row["Title"] . ' </td> <td style="background-color: silver; padding: 5px; width: 70%;"> <div style="width: ' . $multipliedWidthInPercentage . '%; background-color: #0066CC; color: #fff;">' . $row["myCount"] . '</div> </td> </tr>'; } $content .= ' </table>'; //a - z asort($list); $content .= "\n\t\t\t<h3>A - Z with favourite links clicked</h3>\n\t\t\t<table class=\"aToz\" style=\"width: 100%;\">"; foreach ($list as $key => $title) { $array = explode("-", $key); $multipliedWidthInPercentage = floor($array[0] / $maxWidth * 100); $titleData = DB::query("\n\t\t\t\tSELECT COUNT(ID) myCount, \"URL\"\n\t\t\t\tFROM \"GoogleCustomSearchPage_Record\"\n\t\t\t\tWHERE Created > ( NOW() - INTERVAL " . $totalNumberOfDaysBack . " DAY )\n\t\t\t\t\tAND Created < ( NOW() - INTERVAL " . $this->endingDaysBack . " DAY )\n\t\t\t\t\tAND \"Title\" = '" . $title . "'\n\t\t\t\tGROUP BY \"URL\"\n\t\t\t\tHAVING COUNT(\"ID\") >= {$this->minimumCount}\n\t\t\t\tORDER BY myCount DESC\n\t\t\t\tLIMIT 3;\n\t\t\t"); unset($urlArray); $urlArray = array(); foreach ($titleData as $urlRow) { $urlArray[] = "<li>" . $urlRow["myCount"] . ": " . $urlRow["URL"] . "</li>"; } $content .= ' <tr> <td style="text-align: right; width: 30%; padding: 5px;">' . $title . '</td> <td style="background-color: silver; padding: 5px; width: 70%"> <div style="width: ' . $multipliedWidthInPercentage . '%; background-color: #0066CC; color: #fff;">' . trim($array[0]) . '</div> <ul style="font-size: 10px">' . implode($urlArray) . '</ul> </td> </tr>'; } $content .= ' </table> </div>'; return parent::__construct($name, $content); }
function __construct($controller, $name, $class = 'Page', $limit = 30) { Requirements::javascript(ABC_PATH . '/javascript/child-list.js'); Requirements::css(ABC_PATH . '/css/child-list.css'); $do = new DataObject(); $do->DataSet = AddPaginator::get($limit)->fetch($class, "SiteTree.ParentID = " . $controller->ID, "PublicationDate DESC, Created DESC"); $do->Paginator = $do->DataSet->Paginator->dataForTemplate(null, null, '/admin/getitem?ID=' . $controller->ID); $parser = SSViewer::fromString(SSViewer::getTemplateContent('ChildList')); $str = $parser->process($do); parent::__construct($name, $str); }
function __construct($name, $ClassName) { Requirements::javascript(THIRDPARTY_DIR . "/jquery/jquery.js"); //Requirements::block(THIRDPARTY_DIR."/jquery/jquery.js"); //Requirements::javascript(Director::protocol()."ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"); Requirements::javascript("dataobjectsorter/javascript/jquery-ui-1.7.2.custom.min.js"); Requirements::themedCSS("dataobjectsorter", "dataobjectsorter"); $objects = $ClassName::get(); $arrayList = new ArrayList(); $dos->Children = $objects; $content = $this->customise($arrayList)->renderWith("DataObjectSorterField"); parent::__construct($name, $content); }
function __construct($name, $title = "") { $totalNumberOfDaysBack = $this->numberOfDays + $this->endingDaysBack; $data = DB::query("\n\t\t\tSELECT COUNT(ID) myCount, \"Title\"\n\t\t\tFROM \"SearchHistory\"\n\t\t\tWHERE Created > ( NOW() - INTERVAL " . $totalNumberOfDaysBack . " DAY )\n\t\t\t\tAND Created < ( NOW() - INTERVAL " . $this->endingDaysBack . " DAY )\n\t\t\tGROUP BY \"Title\"\n\t\t\tHAVING COUNT(\"ID\") >= {$this->minimumCount}\n\t\t\tORDER BY myCount DESC\n\t\t"); if (!$this->minimumCount) { $this->minimumCount++; } $content = ""; if ($title) { $content .= "<h2>" . $title . "</h2>"; } $content .= "\n\t\t<div id=\"SearchHistoryTableForCMS\">\n\t\t\t<h3>Search Phrases entered at least " . $this->minimumCount . " times between " . date("Y-M-d", strtotime("-" . $totalNumberOfDaysBack . " days")) . " and " . date("Y-M-d", strtotime("-" . $this->endingDaysBack . " days")) . "</h3>\n\t\t\t<table class=\"highToLow\" style=\"widht: 100%\">"; $list = array(); foreach ($data as $key => $row) { //for the highest count, we work out a max-width if (!$key) { $maxWidth = $row["myCount"]; } $multipliedWidthInPercentage = floor($row["myCount"] / $maxWidth * 100); $list[$row["myCount"] . "-" . $key] = $row["Title"]; $content .= ' <tr> <td style="text-align: right; width: 30%; padding: 5px;">' . $row["Title"] . '</td> <td style="background-color: silver; padding: 5px; width: 70%;"> <div style="width: ' . $multipliedWidthInPercentage . '%; background-color: #0066CC; color: #fff;">' . $row["myCount"] . '</div> </td> </tr>'; } $content .= ' </table>'; asort($list); $content .= "\n\t\t\t<h3>A - Z</h3>\n\t\t\t<table class=\"aToz\" style=\"widht: 100%\">"; foreach ($list as $key => $title) { $array = explode("-", $key); $multipliedWidthInPercentage = floor($array[0] / $maxWidth * 100); $content .= ' <tr> <td style="text-align: right; width: 30%; padding: 5px;">' . $title . '</td> <td style="background-color: silver; padding: 5px; width: 70%"> <div style="width: ' . $multipliedWidthInPercentage . '%; background-color: #0066CC; color: #fff;">' . trim($array[0]) . '</div> </td> </tr>'; } $content .= ' </table> </div>'; return parent::__construct($name, $content); }
public function __construct($name, $content, $label = '') { parent::__construct($name, $content); $this->title = $label; }
public function __construct($name, $content, $class = 'notice') { $content = '<p class="noticefield message ' . $class . '">' . $content . '</p>'; parent::__construct($name, $content); }
/** * Builds the action * @param string $text The text to appear on the button */ public function __construct($text = null) { $this->buttonText = $text; parent::__construct($this->getButtonName(), ""); }
public function __construct($name) { parent::__construct($name, ''); }
function __construct($name, $additionalContent = '', $productID) { Requirements::themedCSS("CreateEcommerceVariationsField"); $additionalContent .= $this->renderWith("CreateEcommerceVariations_Field"); parent::__construct($name, $additionalContent); }
public function __construct($name, $content, $link) { $this->link = $link; parent::__construct($name, $content); }
function __construct($name, $title = "") { return parent::__construct($name, $title); }
function __construct($name, $title, $content) { parent::__construct($name, $content); $this->setTitle($title); }
public function __construct($name, $content, $type = 'good') { $this->type = $type; parent::__construct($name, $content); }
public function __construct(\Form $form, \GridFieldDetailForm_ItemRequest $request) { $html = ""; $parameter = ''; if (isset($_REQUEST['q']) && !empty($_REQUEST['q'])) { $parameter .= '?'; foreach ($_REQUEST['q'] as $key => $val) { if (is_array($val)) { foreach ($val as $subVal) { $parameter .= 'q[' . $key . '][]' . '=' . $subVal . '&'; } } else { $parameter .= 'q[' . $key . ']' . '=' . $val . '&'; } } $parameter .= 'action_search=Apply+Filter'; } // Prev/next links. Todo: This doesn't scale well. $previousRecordID = $request->getPreviousRecordID(); $cssClass = $previousRecordID ? "cms-panel-link" : "disabled"; $prevLink = $previousRecordID ? \Controller::join_links($request->gridField->Link(), "item", $previousRecordID . $parameter) : "javascript:void(0);"; $linkTitle = $previousRecordID ? _t('GridFieldBetterButtons.PREVIOUSRECORD', 'Go to the previous record') : ""; $linkText = $previousRecordID ? _t('GridFieldBetterButtons.PREVIOUS', 'Previous') : ""; $html .= sprintf("<a class='ss-ui-button gridfield-better-buttons-prevnext gridfield-better-buttons-prev %s' href='%s' title='%s'><img src='" . BETTER_BUTTONS_DIR . "/images/prev.png' alt='previous' /> %s</a>", $cssClass, $prevLink, $linkTitle, $linkText); $nextRecordID = $request->getNextRecordID(); $cssClass = $nextRecordID ? "cms-panel-link" : "disabled"; $prevLink = $nextRecordID ? \Controller::join_links($request->gridField->Link(), "item", $nextRecordID . $parameter) : "javascript:void(0);"; $linkTitle = $nextRecordID ? _t('GridFieldBetterButtons.NEXTRECORD', 'Go to the next record') : ""; $linkText = $nextRecordID ? _t('GridFieldBetterButtons.NEXT', 'Next') : ""; $html .= sprintf("<a class='ss-ui-button gridfield-better-buttons-prevnext gridfield-better-buttons-prev %s' href='%s' title='%s'>%s <img src='" . BETTER_BUTTONS_DIR . "/images/next.png' alt='next' /></a>", $cssClass, $prevLink, $linkTitle, $linkText); parent::__construct("prev_next", $html); }