public function init() { parent::init(); $client = Pimcore_Google_Api::getServiceClient(); if (!$client) { die("Google Analytics is not configured"); } $this->service = new apiAnalyticsService($client); }
/** * */ public function load() { $client = Pimcore_Google_Api::getSimpleClient(); $config = $this->getConfig(); $perPage = $this->getPerPage(); $offset = $this->getOffset(); $query = $this->getQuery(); if ($client) { $search = new apiCustomsearchService($client); // determine language $language = ""; if (Zend_Registry::isRegistered("Zend_Locale")) { $locale = Zend_Registry::get("Zend_Locale"); $language = $locale->getLanguage(); } if (!array_key_exists("hl", $config) && !empty($language)) { $config["hl"] = $language; } if (!array_key_exists("lr", $config) && !empty($language)) { $config["lr"] = "lang_" . $language; } if ($query) { if ($offset) { $config["start"] = $offset + 1; } if ($perPage) { $config["num"] = $perPage; } $cacheKey = "google_cse_" . md5($query . serialize($config)); if (!($result = Pimcore_Model_Cache::load($cacheKey))) { $result = $search->cse->listCse($query, $config); Pimcore_Model_Cache::save($result, $cacheKey, array("google_cse"), 3600, 999); } $this->readGoogleResponse($result); return $this->getResults(); } return array(); } else { throw new Exception("Google Simple API Key is not configured in System-Settings."); } }
public function getSystemAction() { if ($this->getUser()->isAllowed("system_settings")) { $values = Pimcore_Config::getSystemConfig(); if (($handle = fopen(PIMCORE_PATH . "/config/timezones.csv", "r")) !== FALSE) { while (($rowData = fgetcsv($handle, 10000, ",", '"')) !== false) { $timezones[] = $rowData[0]; } fclose($handle); } $languages = Zend_Locale::getTranslationList('language'); asort($languages); $languageOptions = array(); $validLanguages = array(); foreach ($languages as $short => $translation) { if (strlen($short) == 2 or strpos($short, "_") == 2) { $languageOptions[] = array("language" => $short, "display" => $translation . " ({$short})"); $validLanguages[] = $short; } } $valueArray = $values->toArray(); $valueArray['general']['validLanguage'] = explode(",", $valueArray['general']['validLanguages']); //for "wrong" legacy values if (is_array($valueArray['general']['validLanguage'])) { foreach ($valueArray['general']['validLanguage'] as $existingValue) { if (!in_array($existingValue, $validLanguages)) { $languageOptions[] = array("language" => $existingValue, "display" => $existingValue); } } } //debug email addresses - add as array ckogler if (!empty($valueArray['email']['debug']['emailaddresses'])) { $emailAddresses = explode(",", $valueArray['email']['debug']['emailaddresses']); if (is_array($emailAddresses)) { foreach ($emailAddresses as $emailAddress) { $valueArray['email']['debug']['emaildebugaddressesArray'][] = array("value" => $emailAddress); } } } else { $valueArray['email']['debug']['emaildebugaddressesArray'][] = array("value" => ''); } //cache exclude patterns - add as array if (!empty($valueArray['cache']['excludePatterns'])) { $patterns = explode(",", $valueArray['cache']['excludePatterns']); if (is_array($patterns)) { foreach ($patterns as $pattern) { $valueArray['cache']['excludePatternsArray'][] = array("value" => $pattern); } } } //remove password from values sent to frontend $valueArray['database']["params"]['password'] = "******"; //admin users as array $adminUsers = array(); $userList = new User_List(); $userList->setCondition("admin = 1 and email is not null and email != ''"); $users = $userList->load(); if (is_array($users)) { foreach ($users as $user) { $adminUsers[] = array("id" => $user->getId(), "username" => $user->getName()); } } $adminUsers[] = array("id" => "", "username" => "-"); $response = array("values" => $valueArray, "adminUsers" => $adminUsers, "config" => array("timezones" => $timezones, "languages" => $languageOptions, "client_ip" => Pimcore_Tool::getClientIp(), "google_private_key_exists" => file_exists(Pimcore_Google_Api::getPrivateKeyPath()), "google_private_key_path" => Pimcore_Google_Api::getPrivateKeyPath())); $this->_helper->json($response); } else { if ($this->getUser() != null) { Logger::err("user [" . $this->getUser()->getId() . "] attempted to view system settings, but has no permission to do so."); } else { Logger::err("attempt to view system settings, but no user in session."); } } $this->_helper->json(false); }