本文整理汇总了PHP中Utils::defineConstants方法的典型用法代码示例。如果您正苦于以下问题:PHP Utils::defineConstants方法的具体用法?PHP Utils::defineConstants怎么用?PHP Utils::defineConstants使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utils
的用法示例。
在下文中一共展示了Utils::defineConstants方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authControl
public function authControl() {
$config = Config::getInstance();
Utils::defineConstants();
$this->setViewTemplate( THINKUP_WEBAPP_PATH.'plugins/hellothinkup/view/hellothinkup.account.index.tpl');
$this->addToView('message',
'Hello, world! This is the example plugin configuration page for '.$this->owner->email .'.');
/** set option fields **/
// name text field
$name_field = array('name' => 'testname', 'label' => 'Your Name'); // set an element name and label
$name_field['default_value'] = 'ThinkUp User'; // set default value
$this->addPluginOption(self::FORM_TEXT_ELEMENT, $name_field); // add element
// set testname header
$this->addPluginOptionHeader('testname', 'User Info'); // add a header for an element
// set a special required message
$this->addPluginOptionRequiredMessage('testname',
'Please enter a name, because we\'d really like to have one...');
// gender radio field
$gender_field = array('name' => 'testradio', 'label' => 'You Like'); // set an element name and label
$gender_field['values'] = array('Cookies' => 1, 'Cake' => 2, 'Other' => 3);
$gender_field['default_value'] = '3'; // set default value
$this->addPluginOption(self::FORM_RADIO_ELEMENT, $gender_field); // add element
// Birth Year Select
$bday_field = array('name' => 'testbirthyear', 'label' => 'Select The Year You Were Born');
$years = array();
$i = 1900;
while ($i <= 2010) {
$years['Born in ' . $i] = $i;
$i++;
}
$bday_field['values'] = $years;
$bday_field['default_value'] = '2005';
$this->addPluginOption(self::FORM_SELECT_ELEMENT, $bday_field);
// Enable registration stuff
$reg_field = array('name' => 'testregopen', 'label' => 'Open Registration');
$this->addPluginOptionHeader('testregopen', 'Registration Options');
$reg_field['values'] = array('Open' => 1, 'Closed' => 0);
$this->addPluginOption(self::FORM_RADIO_ELEMENT, $reg_field);
// registration key
$reg_key = array('name' => 'RegKey', 'validation_regex' => '^\d+$');
$this->addPluginOption(self::FORM_TEXT_ELEMENT, $reg_key);
$this->setPluginOptionNotRequired('RegKey');
$this->addPluginOptionRequiredMessage('RegKey',
'Please enter interger value for RegKey');
// advanced data
$adv1 = array('name' => 'AdvancedInfo1', 'label' => '1st advanced field', 'advanced' => true);
$this->addPluginOption(self::FORM_TEXT_ELEMENT, $adv1);
$this->setPluginOptionNotRequired('AdvancedInfo1'); // by default not required
$adv2 = array('name' => 'AdvancedInfo2', 'label' => '2nd advanced field', 'advanced' => true);
$this->addPluginOption(self::FORM_TEXT_ELEMENT, $adv2);
return $this->generateView();
}
示例2: authControl
/**
* Launch the crawler, if the latest crawler_last_run date is older than X minutes, then return a valid RSS feed.
* @return string rendered view markup
*/
public function authControl()
{
Utils::defineConstants();
$this->setContentType('application/rss+xml; charset=UTF-8');
$this->setViewTemplate('rss.tpl');
$config = Config::getInstance();
$rss_crawler_refresh_rate = $config->getValue('rss_crawler_refresh_rate');
if (empty($rss_crawler_refresh_rate)) {
$rss_crawler_refresh_rate = 20;
// minutes
}
$protocol = isset($_SERVER['HTTPS']) ? 'https' : 'http';
$base_url = "{$protocol}://" . $_SERVER['HTTP_HOST'] . THINKUP_BASE_URL;
$crawler_launched = false;
$instance_dao = DAOFactory::getDAO('InstanceDAO');
$freshest_instance = $instance_dao->getInstanceFreshestOne();
$crawler_last_run = strtotime($freshest_instance->crawler_last_run);
if ($crawler_last_run < time() - $rss_crawler_refresh_rate * 60) {
$crawler_run_url = $base_url . 'run.php?' . ThinkUpAuthAPIController::getAuthParameters($this->getLoggedInUser());
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $crawler_run_url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
// seconds
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
// seconds
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
$result = curl_exec($ch);
curl_close($ch);
$body = substr($result, strpos($result, "\r\n\r\n") + 4);
if (strpos($result, 'Content-Type: application/json') && function_exists('json_decode')) {
$json = json_decode($body);
if (isset($json->error)) {
$crawler_launched = false;
} else {
if (isset($json->result) && $json->result == 'success') {
$crawler_launched = true;
}
}
} else {
if (strpos($body, 'Error starting crawler') !== FALSE) {
$crawler_launched = false;
} else {
$crawler_launched = true;
}
}
}
$items = array();
if ($crawler_launched) {
$title = 'ThinkUp crawl started on ' . date('Y-m-d H:i:s');
$link = $base_url . 'rss.php?d=' . urlencode(date('Y-m-d H:i:s'));
$description = "Last ThinkUp crawl ended on {$freshest_instance->crawler_last_run}<br />A new crawl " . "was started just now, since it's been more than {$rss_crawler_refresh_rate} minutes since the last run.";
$items[] = self::createRSSItem($title, $link, $description);
}
$items = array_merge($items, $this->getAdditionalItems($base_url));
$this->addToView('items', $items);
$this->addToView('logged_in_user', htmlspecialchars($this->getLoggedInUser()));
$this->addToView('rss_crawler_refresh_rate', htmlspecialchars($rss_crawler_refresh_rate));
return $this->generateView();
}
示例3: authControl
public function authControl()
{
$config = Config::getInstance();
Utils::defineConstants();
$this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/geoencoder/view/geoencoder.account.index.tpl');
$this->view_mgr->addHelp('geoencoder', 'userguide/settings/plugins/geoencoder');
$this->addToView('message', 'This is the GeoEncoder plugin configuration page for ' . $this->owner->email . '.');
/** set option fields **/
// gmaps_api_key text field
$name_field = array('name' => 'gmaps_api_key', 'label' => 'Google Maps API Key', 'size' => 55);
$this->addPluginOption(self::FORM_TEXT_ELEMENT, $name_field);
$this->addPluginOptionRequiredMessage('gmaps_api_key', 'Please enter your Google Maps API Key');
// distance_unit radio field
$distance_unit_field = array('name' => 'distance_unit', 'label' => 'Unit of Distance');
$distance_unit_field['values'] = array('Kilometers' => 'km', 'Miles' => 'mi');
$distance_unit_field['default_value'] = 'km';
$this->addPluginOption(self::FORM_RADIO_ELEMENT, $distance_unit_field);
$plugin = new GeoEncoderPlugin();
if (!$plugin->isConfigured()) {
$this->addInfoMessage('Please complete plugin setup to start using it.', 'setup');
$this->addToView('is_configured', false);
} else {
$this->addToView('is_configured', true);
}
return $this->generateView();
}
示例4: authControl
public function authControl()
{
$config = Config::getInstance();
Utils::defineConstants();
$this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/facebook/view/facebook.account.index.tpl');
/** set option fields **/
// Application ID text field
$this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'facebook_app_id', 'label' => 'Application ID'));
// add element
// set a special required message
$this->addPluginOptionRequiredMessage('facebook_app_id', 'The Facebook plugin requires a valid Application ID.');
// API Key text field
$this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'facebook_api_key', 'label' => 'API Key'));
// add element
// set a special required message
$this->addPluginOptionRequiredMessage('facebook_api_key', 'The Facebook plugin requires a valid API Key.');
// Application Secret text field
$this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'facebook_api_secret', 'label' => 'Application Secret'));
// add element
// set a special required message
$this->addPluginOptionRequiredMessage('facebook_api_secret', 'The Facebook plugin requires a valid Application Secret.');
$plugin_option_dao = DAOFactory::getDAO('PluginOptionDAO');
$options = $plugin_option_dao->getOptionsHash('facebook', true);
//get cached
if (isset($options['facebook_app_id']->option_value) && isset($options['facebook_api_secret']->option_value)) {
$this->setUpFacebookInteractions($options);
} else {
$this->addErrorMessage('Please set your Facebook API key, application ID and secret.');
}
return $this->generateView();
}
示例5: authControl
public function authControl()
{
$config = Config::getInstance();
Utils::defineConstants();
$this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/facebook/view/facebook.account.index.tpl');
$this->view_mgr->addHelp('facebook', 'userguide/settings/plugins/facebook');
/** set option fields **/
// Application ID text field
$this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'facebook_app_id', 'label' => 'App ID', 'size' => 18));
// add element
// set a special required message
$this->addPluginOptionRequiredMessage('facebook_app_id', 'The Facebook plugin requires a valid App ID.');
// Application Secret text field
$this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'facebook_api_secret', 'label' => 'App Secret', 'size' => 37));
// add element
// set a special required message
$this->addPluginOptionRequiredMessage('facebook_api_secret', 'The Facebook plugin requires a valid App Secret.');
$max_crawl_time_label = 'Max crawl time in minutes';
$max_crawl_time = array('name' => 'max_crawl_time', 'label' => $max_crawl_time_label, 'default_value' => '20', 'advanced' => true, 'size' => 3);
$this->addPluginOption(self::FORM_TEXT_ELEMENT, $max_crawl_time);
$facebook_plugin = new FacebookPlugin();
if ($facebook_plugin->isConfigured()) {
$this->setUpFacebookInteractions($facebook_plugin->getOptionsHash());
$this->addToView('is_configured', true);
} else {
$this->addInfoMessage('Please complete plugin setup to start using it.', 'setup');
$this->addToView('is_configured', false);
}
return $this->generateView();
}
示例6: __construct
/**
* Constructor
* @param bool $session_started
* @return ThreadJSController
*/
public function __construct($session_started=false) {
parent::__construct($session_started);
foreach ($this->REQUIRED_PARAMS as $param) {
if (!isset($_GET[$param]) || $_GET[$param] == '' ) {
$this->is_missing_param = true;
}
}
Utils::defineConstants();
$this->setViewTemplate(THINKUP_WEBAPP_PATH.'plugins/embedthread/view/v1.thread_js.tpl');
}
示例7: __construct
public function __construct()
{
$config = Config::getInstance();
if ($config->getValue('recaptcha_enable')) {
$this->type = self::RECAPTCHA_CAPTCHA;
Utils::defineConstants();
require_once THINKUP_WEBAPP_PATH . '_lib/extlib/recaptcha-php-1.10/recaptchalib.php';
} else {
$this->type = self::THINKUP_CAPTCHA;
}
}
示例8: __construct
public function __construct($session_started = false)
{
parent::__construct($session_started);
$config = Config::getInstance();
Utils::defineConstants();
$this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/facebook/view/auth.tpl');
$this->setPageTitle('Authorizing Your Facebook Account');
if (!isset($_GET['sessionKey']) || $_GET['sessionKey'] == '') {
$this->addErrorMessage('No session key specified.');
$this->is_missing_param = true;
}
}
示例9: control
/**
* Generates the calling JavaScript to create embedded thread on calling page.
* @return str JavaScript source
*/
public function control() {
Utils::defineConstants();
$this->setViewTemplate(THINKUP_WEBAPP_PATH.'plugins/embedthread/view/v1.embed.tpl');
$this->setContentType('text/javascript');
if (!$this->is_missing_param) {
$this->addToView('post_id', $_GET['p']);
$this->addToView('network', $_GET['n']);
} else {
$this->addErrorMessage('No ThinkUp thread specified.');
}
return $this->generateView();
}
示例10: __construct
public function __construct($session_started = false)
{
//Explicitly set TZ (before we have user's choice) to avoid date() warning about using system settings
date_default_timezone_set('America/Los_Angeles');
Utils::defineConstants();
//Don't call parent constructor because config.inc.php doesn't exist yet
//Instead, set up the view manager with manual array configuration
$cfg_array = array('site_root_path' => THINKUP_BASE_URL, 'source_root_path' => THINKUP_ROOT_PATH, 'debug' => false, 'app_title' => "ThinkUp", 'cache_pages' => false);
$this->view_mgr = new SmartyThinkUp($cfg_array);
$this->setPageTitle('Install ThinkUp');
$this->disableCaching();
}
示例11: authControl
public function authControl()
{
$config = Config::getInstance();
Utils::defineConstants();
$this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/expandurls/view/expandurls.account.index.tpl');
$links_to_expand = array('name' => 'links_to_expand', 'label' => 'Links to expand per crawl', 'default_value' => 1500);
$this->addPluginOption(self::FORM_TEXT_ELEMENT, $links_to_expand);
/** set option fields **/
// API key text field
$this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'flickr_api_key', 'label' => 'Flickr API key (<a href="http://www.flickr.com/services/api/keys/">Get it here</a>)'));
// add element
return $this->generateView();
}
示例12: authControl
public function authControl() {
$config = Config::getInstance();
Utils::defineConstants();
$this->setViewTemplate( THINKUP_WEBAPP_PATH. 'plugins/expandurls/view/expandurls.account.index.tpl');
$links_to_expand = array( 'name' => 'links_to_expand', 'label' => 'Links to expand per crawl',
'default_value' => 1500
);
$this->addPluginOption(self::FORM_TEXT_ELEMENT, $links_to_expand);
return $this->generateView();
}
示例13: authControl
public function authControl()
{
$this->disableCaching();
// we don't want to cache the rss link with api key as it can get updated
Utils::defineConstants();
$this->setContentType('text/html; charset=UTF-8');
$this->setPageTitle("ThinkUp Crawler");
$this->setViewTemplate('crawler.updatenow.tpl');
$this->addInfoMessage('<b>Hint</b>: You can set up ThinkUp to update automatically. Visit ' . 'Settings → Account to find out how.');
if (isset($_GET['log']) && $_GET['log'] == 'full') {
$this->addToView('log', 'full');
}
return $this->generateView();
}
示例14: __construct
public function __construct()
{
$config = Config::getInstance();
$this->site_root = $config->getValue('site_root_path');
if ($config->getValue('recaptcha_enable')) {
$this->type = 1;
Utils::defineConstants();
require_once THINKUP_WEBAPP_PATH . '_lib/extlib/recaptcha-php-1.10/recaptchalib.php';
$this->pubkey = $config->getValue('recaptcha_public_key');
$this->prikey = $config->getValue('recaptcha_private_key');
} else {
$this->type = 0;
}
}
示例15: authControl
public function authControl()
{
$config = Config::getInstance();
Utils::defineConstants();
$this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/flickrthumbnails/view/flickrthumbnails.account.index.tpl');
/** set option fields **/
// API key text field
$this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'flickr_api_key', 'label' => 'Your Flickr API key'));
// add element
$this->addPluginOptionHeader('flickr_api_key', 'Flickr API key (<a href="http://www.flickr.com/services/api/keys/">Get it here</a>)');
// set a special required message
$this->addPluginOptionRequiredMessage('flickr_api_key', 'The Flickr Thumbnails plugin requires a valid API key.');
return $this->generateView();
}