Beispiel #1
0
 /**
  * Method to get the field input markup.
  *
  * @return	string	The field input markup.
  * @since	1.6
  */
 public function getInput()
 {
     // Initialize variables.
     $html = array();
     // Initialize some field attributes.
     $class = $this->element['class'] ? ' class="radio ' . (string) $this->element['class'] . '"' : ' class="radio"';
     // Start the radio field output.
     $html[] = '<fieldset id="' . $this->id . '"' . $class . '>';
     // Get the field options.
     $options = $this->getOptions();
     // Build the radio field output.
     foreach ($options as $i => $option) {
         // Initialize some option attributes.
         $checked = (string) $option->value == (string) $this->value ? ' checked="checked"' : '';
         $class = !empty($option->class) ? ' class="' . $option->class . '"' : '';
         $disabled = !empty($option->disable) ? ' disabled="disabled"' : '';
         // Initialize some JavaScript option attributes.
         $onclick = !empty($option->onclick) ? ' onclick="' . $option->onclick . '"' : '';
         $html[] = '<input type="radio" id="' . $this->id . $i . '" name="' . $this->name . '"' . ' value="' . htmlspecialchars($option->value, ENT_COMPAT, 'UTF-8') . '"' . $checked . $class . $onclick . $disabled . '/>';
         $html[] = '<label for="' . $this->id . $i . '"' . $class . '>' . _r($option->text) . '</label>';
     }
     // End the radio field output.
     $html[] = '</fieldset>';
     return implode($html);
 }
Beispiel #2
0
 public function __construct($project_id, $options = null)
 {
     parent::__construct($options);
     $this->setName('deploymentSetup');
     $servers_map = new GD_Model_ServersMapper();
     $servers = $servers_map->getServersByProject($project_id);
     if (!is_array($servers) || count($servers) == 0) {
         throw new GD_Exception("There are no servers configured for this project.");
     }
     $server_id = new Zend_Form_Element_Select('serverId');
     $server_id->setLabel(_r('Server'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     foreach ($servers as $server) {
         $server_id->addMultiOption($server->getId(), $server->getDisplayName());
     }
     $from_revision = new Zend_Form_Element_Text('fromRevision');
     $from_revision->setLabel(_r('Current revision'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->setAttrib('readonly', 'readonly')->setAttrib('disabled', 'disabled');
     $to_revision = new Zend_Form_Element_Text('toRevision');
     $to_revision->setLabel(_r('Deploy revision or tag'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->setDescription('<a href="javascript:;" onclick="getLatestRevision();">Click to get latest revision</a><span id="get_latest_revision_status"></span>');
     $comment = new Zend_Form_Element_Text('comment');
     $comment->setLabel(_r('Comment (optional)'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim');
     $submitRun = new Zend_Form_Element_Image('submitRun');
     $submitRun->setImage('/images/buttons/small/deploy.png');
     $submitRun->class = "processing_btn size_small";
     $submitPreview = new Zend_Form_Element_Image('submitPreview');
     $submitPreview->setImage('/images/buttons/small/inverted/preview.png');
     $submitPreview->class = "preview processing_btn size_small";
     $this->addElements(array($server_id, $from_revision, $to_revision, $comment, $submitRun, $submitPreview));
 }
 /**
  * Dispatches the current URL and executes an assigned callback
  */
 public static function dispatch()
 {
     $method = 'default';
     if (isset($_REQUEST['method'])) {
         $method = preg_replace('/[^-_.0-9a-zA-Z]/', '', $_REQUEST['method']);
     }
     $method = apply_filters('controller-method', $method);
     define('LILINA_PAGE', $method);
     try {
         if (!$method || empty(Controller::$methods[$method])) {
             // Dynamically load method if possible
             if (file_exists(LILINA_INCPATH . '/core/method-' . $method . '.php')) {
                 require_once LILINA_INCPATH . '/core/method-' . $method . '.php';
             }
         }
         // Check again, in case we loaded it last time
         if (!$method || empty(Controller::$methods[$method])) {
             // No or invalid method
             throw new Exception(sprintf(_r('Unknown method: %s'), $method));
         }
         $callback = Controller::$methods[$method];
         call_user_func($callback);
     } catch (Exception $e) {
         lilina_nice_die('<p>' . sprintf(_r('An error occured dispatching a method: %s'), $e->getMessage()) . '</p>');
     }
 }
 /**
  * Process a single feed
  *
  * @param array $feed Feed information (required elements are 'name' for error reporting, 'feed' for the feed URL and 'id' for the feed's unique internal ID)
  * @return int Number of items added
  */
 public static function process_single($feed)
 {
     do_action('iu-feed-start', $feed);
     $sp =& self::load_feed($feed);
     if ($error = $sp->error()) {
         self::log(sprintf(_r('An error occurred with "%2$s": %1$s'), $error, $feed['name']), Errors::get_code('api.itemupdater.itemerror'));
         do_action('iu-feed-finish', $feed);
         return -1;
     }
     $count = 0;
     $items = $sp->get_items();
     foreach ($items as $item) {
         $new_item = self::normalise($item, $feed['id']);
         $new_item = apply_filters('item_data_precache', $new_item, $feed);
         if (Items::get_instance()->check_item($new_item)) {
             $count++;
             do_action('iu-item-add', $new_item, $feed);
         } else {
             do_action('iu-item-noadd', $new_item, $feed);
         }
     }
     $sp->__destruct();
     unset($sp);
     do_action('iu-feed-finish', $feed);
     return $count;
 }
Beispiel #5
0
 public function getInput()
 {
     global $gantry;
     $buffer = '';
     $buffer .= "<div class='wrapper'>\n";
     foreach ($this->fields as $field) {
         if ($field->element['enabler'] && strtolower((string) $field->element['enabler']) == 'true') {
             $this->enabler = $field;
         }
     }
     foreach ($this->fields as $field) {
         $itemName = $this->fieldname . "-" . $field->fieldname;
         $field->detached = false;
         if ($field != $this->enabler && isset($this->enabler) && (int) $this->enabler->value == 0) {
             $field->detached = true;
         }
         if ($field->basetype == 'select') {
             $basetype = ' base-selectbox';
         } else {
             $basetype = ' base-' . $field->basetype;
         }
         $buffer .= '<div class="chain ' . $itemName . ' chain-' . strtolower($field->type) . $basetype . '">' . "\n";
         if (strlen($field->getLabel())) {
             $buffer .= '<span class="chain-label">' . _r($field->getLabel()) . '</span>' . "\n";
         }
         $buffer .= $field->getInput();
         $buffer .= "</div>" . "\n";
     }
     $buffer .= "</div>" . "\n";
     return $buffer;
 }
Beispiel #6
0
 public function errorAction()
 {
     $errors = $this->_getParam('error_handler');
     if (!$errors) {
         $this->view->message = 'You have reached the error page';
         return;
     }
     switch ($errors->type) {
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
             // 404 error -- controller or action not found
             $this->getResponse()->setHttpResponseCode(404);
             $this->view->message = _r("Could not find the page you were looking for...");
             break;
         default:
             // application error
             $this->getResponse()->setHttpResponseCode(500);
             $this->view->message = 'Application error';
             if ($errors->exception instanceof GD_Exception) {
                 $this->view->extended_information = $errors->exception->getMessage();
             }
             break;
     }
     // Log exception
     GD_Debug::Log("Exception: " . $this->view->message, GD_Debug::DEBUG_BASIC);
     // conditionally display exceptions
     if ($this->getInvokeArg('displayExceptions') == true) {
         $this->view->exception = $errors->exception;
     }
     $this->view->request = $errors->request;
 }
Beispiel #7
0
/**
 * feed_list_table() - {@internal Missing Short Description}}
 *
 * {@internal Missing Long Description}}
 */
function feed_list_table()
{
    //Defined in admin panel
    $feeds = get_feeds();
    $j = 0;
    $table = '';
    if (is_array($feeds) && !empty($feeds)) {
        foreach ($feeds as $this_feed) {
            $table .= '
		<tr id="feed-' . $j . '" class="' . ($j % 2 ? 'alt' : '') . '">
			<td class="name-col">' . stripslashes($this_feed['name']) . '</td>
			<td class="url-col">' . $this_feed['feed'] . '</td>
			<td class="cat-col">' . $this_feed['cat'] . '</td>
			' . apply_filters('admin-feeds-infocol', '', $this_feed, $j) . '
			<td class="change-col"><a href="feeds.php?change=' . $j . '&amp;action=change" class="change_link">' . _r('Change') . '</a></td>
			<td class="remove-col"><a href="feeds.php?remove=' . $j . '&amp;action=remove">' . _r('Remove') . '</a></td>
			' . apply_filters('admin-feeds-actioncol', '', $this_feed, $j) . '
		</tr>';
            ++$j;
        }
    } else {
        $table = '<tr id="nofeeds"><td>' . _r('You don\'t currently have any feeds. Try <a href="#add_form">adding some</a>.') . '</td></tr>';
    }
    return $table;
}
	public function introduction() {
		admin_header(_r('Google Reader Importer'));
?>
<h1><?php _e('Google Reader Importer') ?></h1>
<p><?php _e('There are several ways to import from Google Reader.'); ?></p>
<h2><?php _e('Method 1'); ?></h2>
<p><?php printf(
	_r('<a href="%1$s">Export</a> your feeds from Google reader and then use the <a href="%2$s">OPML importer</a>.'),
	'http://www.google.com/reader/subscriptions/export',
	'feed-import.php?service=opml'
	); ?></p>
<h2><?php _e('Method 2'); ?></h2>
<p><?php _e("We can grab your OPML file for you, but we'll need your username and password. This information won't be stored anywhere and is only used once. (It sucks, we know, but Google doesn't offer any other way.)"); ?>
<form action="feed-import.php" method="POST">
	<button id="continue"><?php _e('Start Method 2'); ?></button>
	<fieldset id="greader">
		<legend><?php _e('Import Feeds'); ?></legend>
		<div class="row">
			<label for="user"><?php _e('Username (Email address)'); ?>:</label>
			<input type="text" name="user" id="user" />
		</div>
		<div class="row">
			<label for="pass"><?php _e('Password'); ?>:</label>
			<input type="password" name="pass" id="pass" />
		</div>
		<input type="submit" value="<?php _e('Import'); ?>" class="submit" name="submit" />
		<input type="hidden" name="step" value="1" />
		<input type="hidden" name="service" value="opml" />
	</fieldset>
</form>
<?php
		admin_footer();
	}
Beispiel #9
0
 public static function process()
 {
     header('Content-Type: text/plain; charset=utf-8');
     require_once LILINA_INCPATH . '/contrib/simplepie.class.php';
     $updated = false;
     foreach (self::$feeds as $feed) {
         do_action('iu-feed-start', $feed);
         $sp = self::load_feed($feed);
         if ($error = $sp->error()) {
             self::log(sprintf(_r('An error occurred with "%2$s": %1$s'), $error, $feed['name']), Errors::get_code('api.itemupdater.itemerror'));
             continue;
         }
         $count = 0;
         $items = $sp->get_items();
         foreach ($items as $item) {
             $new_item = self::normalise($item, $feed['id']);
             $new_item = apply_filters('item_data_precache', $new_item);
             if (Items::get_instance()->check_item($new_item)) {
                 $count++;
                 $updated = true;
             }
         }
         do_action('iu-feed-finish', $feed);
     }
     Items::get_instance()->sort_all();
     if ($updated) {
         Items::get_instance()->save_cache();
     }
 }
Beispiel #10
0
    protected static function submit()
    {
        $id = $_GET['item'];
        $item = Items::get_instance()->get_item($id);
        if (false === $item) {
            throw new Exception(_r('Invalid item ID specified', 'instapaper'));
        }
        $user = get_option('instapaper_user');
        if (empty($user)) {
            throw new Exception(sprintf(_r('Please set your username and password in the <a href="%s">settings</a>.', 'instapaper'), get_option('baseurl') . 'admin/settings.php'));
        }
        if (!check_nonce('instapaper-submit', $_GET['_nonce'])) {
            throw new Exception(_r('Nonces did not match. Try again.', 'instapaper'));
        }
        $data = array('username' => get_option('instapaper_user', ''), 'password' => get_option('instapaper_pass', ''), 'url' => $item->permalink, 'title' => apply_filters('the_title', $item->title));
        $request = new HTTPRequest('', 2);
        $response = $request->post("https://www.instapaper.com/api/add", array(), $data);
        switch ($response->status_code) {
            case 400:
                throw new Exception(_r('Internal error. Please report this.', 'instapaper'));
            case 403:
                throw new Exception(sprintf(_r('Invalid username/password. Please check your details in the <a href="%s">settings</a>.', 'instapaper'), get_option('baseurl') . 'admin/settings.php'));
            case 500:
                throw new Exception(_r('An error occurred when contacting Instapaper. Please try again later.', 'instapaper'));
        }
        Instapaper::page_head();
        ?>
		<div id="message">
			<h1><?php 
        _e('Success!');
        ?>
</h1>
			<p class="sidenote"><?php 
        _e('Closing window in...', 'instapaper');
        ?>
</p>
			<p class="sidenote" id="counter">3</p>
		</div>
		<script>
			$(document).ready(function () {
				setInterval(countdown, 1000);
			});

			function countdown() {
				if(timer > 0) {
					$('#counter').text(timer);
					timer--;
				}
				else {
					self.close();
				}
			}

			var timer = 2;
		</script>
	<?php 
        Instapaper::page_foot();
        die;
    }
Beispiel #11
0
 public function __construct()
 {
     $this->db = _r('db');
     $this->params = array();
     $this->results = null;
     $this->where = array();
     $this->distinct = false;
 }
Beispiel #12
0
 public function __construct()
 {
     $this->db = _r('db');
     if (!empty($this->sql)) {
         $content = file_get_contents('sql/' . $this->sql, 'r');
         $tabSql = explode(';', $content);
         foreach ($tabSql as $sql) {
             $sql = trim($sql);
             if (!empty($sql)) {
                 $this->db->query($sql);
             }
         }
     }
 }
Beispiel #13
0
 public function __construct($options = null)
 {
     parent::__construct($options);
     $this->setName('adminsetup_form');
     $username = new Zend_Form_Element_Text('username');
     $username->setLabel(_r('Username'))->setValue("admin")->setRequired(true)->addFilter('StripTags')->addValidator('NotEmpty');
     $password = new Zend_Form_Element_Password('password');
     $password->setLabel(_r('Password'))->setRequired(true)->addFilter('StripTags')->addValidator('NotEmpty');
     $passwordConfirm = new Zend_Form_Element_Password('passwordconf');
     $passwordConfirm->setLabel(_r('Confirm Password'))->setRequired(true)->addFilter('StripTags')->addValidator('NotEmpty')->addValidator('Identical', false, array('token' => 'password'));
     $submit = new Zend_Form_Element_Image('btn_submit');
     $submit->setImage('/images/buttons/small/next.png')->setAttrib('style', 'float: right;');
     $this->addElements(array($username, $password, $passwordConfirm, $submit));
 }
Beispiel #14
0
 protected function authenticate()
 {
     $data = array('service' => 'reader', 'continue' => 'http://www.google.com/', 'Email' => $this->id, 'Passwd' => $this->pass, 'source' => 'Lilina/' . LILINA_CORE_VERSION);
     $response = $this->request->post($this->urls['auth'], array(), $data);
     if ($response->success !== true) {
         if ($response->status_code == 403) {
             // Error text from Google
             throw new Exception(_r('The username or password you entered is incorrect.'), Errors::get_code('admin.importer.greader.invalid_auth'));
         }
     }
     preg_match('#SID=(.*)#i', $response->body, $results);
     // so we've found the SID
     // now we can build the cookie that gets us in the door
     $this->cookie = 'SID=' . $results[1];
 }
Beispiel #15
0
 /**
  * Parse feeds into an array, ready to pass to the Javascript importer
  *
  * @param string $opml OPML standard file.
  * @return array Associative array containing feed URL, title and category (if applicable)
  */
 protected function import_opml($opml)
 {
     if (empty($opml)) {
         throw new Exception(_r('No OPML specified'));
         return false;
     }
     $opml = new OPMLParser($opml);
     if (!empty($opml->error) || empty($opml->data)) {
         throw new Exception(sprintf(_r('The OPML file could not be read. The parser said: %s'), $opml->error));
         return false;
     }
     $feeds_num = 0;
     $feeds = $this->parse($opml->data);
     MessageHandler::add(sprintf(Locale::ngettext('Adding %d feed', 'Adding %d feeds', $feeds_num), $feeds_num));
     return $feeds;
 }
Beispiel #16
0
 public function __construct($options = null)
 {
     parent::__construct($options);
     $this->setName('changepassword_form');
     $password = new Zend_Form_Element_Password('password');
     $password->setLabel(_r('New Password'))->setRequired(true)->addFilter('StripTags');
     $not_empty = new Zend_Validate_NotEmpty();
     $password->addValidators(array($not_empty));
     $passwordConfirm = new Zend_Form_Element_Password('passwordconf');
     $passwordConfirm->setLabel(_r('Confirm Password'))->setRequired(true)->addFilter('StripTags');
     $passwordConfirm->addValidators(array($not_empty));
     $passwordConfirm->addValidator('Identical', false, array('token' => 'password'));
     $submit = new Zend_Form_Element_Image('btn_submit');
     $submit->setImage('/images/buttons/small/save-changes.png');
     $this->addElements(array($password, $passwordConfirm, $submit));
 }
Beispiel #17
0
 public function __construct($options = null)
 {
     parent::__construct($options);
     $this->setName('databasesetup_form');
     $hostname = new Zend_Form_Element_Text('hostname');
     $hostname->setLabel(_r('Hostname'))->setRequired(true)->addFilter('StripTags')->addValidator('NotEmpty');
     $username = new Zend_Form_Element_Text('db_username');
     $username->setLabel(_r('Username'))->setRequired(true)->addFilter('StripTags')->addValidator('NotEmpty');
     $password = new Zend_Form_Element_Password('db_password');
     $password->setLabel(_r('Password'))->setRequired(true)->addFilter('StripTags')->addValidator('NotEmpty');
     $dbname = new Zend_Form_Element_Text('dbname');
     $dbname->setLabel(_r('Database Name'))->setRequired(true)->addFilter('StripTags')->addValidator('NotEmpty');
     $submit = new Zend_Form_Element_Image('btn_submit');
     $submit->setImage('/images/buttons/small/next.png')->setAttrib('style', 'float: right;');
     $this->addElements(array($hostname, $username, $password, $dbname, $submit));
 }
 public function __construct()
 {
     if (empty($this->name)) {
         $this->name = _r('Unnamed Service');
     }
     if (empty($this->description)) {
         $this->description = sprintf(_r('No description for %s'), $this->name);
     }
     if (empty($this->label)) {
         $this->label = sprintf(_r('Send to %s'), $this->name);
     }
     if (empty($this->nonce)) {
         $this->nonce = $this->name;
     }
     $nonce = generate_nonce($this->nonce);
     $this->action = get_option('baseurl') . '?method=' . $this->method . '&item={hash}&_nonce=' . $nonce;
 }
Beispiel #19
0
 public function __construct($options = null)
 {
     parent::__construct($options);
     $username = new Zend_Form_Element_Text('username');
     $username->setLabel(_r('Username'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->addValidator(new GD_Validate_UniqueUser($options['current_user']));
     $password = new Zend_Form_Element_Password('password');
     $password->setLabel(_r('Password'))->setAttrib('autocomplete', 'off')->setDescription('To leave the user\'s password unchanged, leave this empty.');
     $passwordConfirm = new Zend_Form_Element_Password('passwordconf');
     $passwordConfirm->setLabel(_r('Confirm Password'))->addValidator('Identical', false, array('token' => 'password'))->setAttrib('autocomplete', 'off');
     $admin = new Zend_Form_Element_Checkbox('admin');
     $admin->setLabel(_r('Is this user an admin?'));
     $active = new Zend_Form_Element_Checkbox('active');
     $active->setLabel(_r('Is this user active?'));
     $submit = new Zend_Form_Element_Image('btn_submit');
     $submit->setImage('/images/buttons/small/login.png');
     $this->addElements(array($username, $password, $passwordConfirm, $admin, $active, $submit));
 }
Beispiel #20
0
 public function __construct($options = null)
 {
     parent::__construct($options);
     $this->setName('serverSettings');
     $server_name = new Zend_Form_Element_Text('name');
     $server_name->setLabel(_r('Name'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim');
     $not_empty = new Zend_Validate_NotEmpty();
     $not_empty->setMessage(_r('Please enter the Server Name'));
     $server_name->addValidators(array($not_empty));
     $hostname = new Zend_Form_Element_Text('hostname');
     $hostname->setLabel(_r('Hostname'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim');
     $not_empty = new Zend_Validate_NotEmpty();
     $not_empty->setMessage(_r('Please enter the Hostname'));
     $hostname->addValidators(array($not_empty));
     $ct_map = new GD_Model_ConnectionTypesMapper();
     $connection_types = $ct_map->fetchAll();
     $connection_type_id = new Zend_Form_Element_Select('connectionTypeId');
     $connection_type_id->setLabel(_r('Connection Type'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim');
     $not_empty = new Zend_Validate_NotEmpty();
     $not_empty->setMessage(_r('Please choose a Connection Type'));
     $connection_type_id->addValidators(array($not_empty));
     foreach ($connection_types as $connection_type) {
         $connection_type_id->addMultiOption($connection_type->getId(), $connection_type->getName());
     }
     $port = new Zend_Form_Element_Text('port');
     $port->setLabel(_r('Port'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim');
     $not_empty = new Zend_Validate_NotEmpty();
     $not_empty->setMessage(_r('Please enter the Port Number'));
     $port->addValidators(array($not_empty));
     $username = new Zend_Form_Element_Text('username');
     $username->setLabel(_r('Username'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->setAttrib('autocomplete', 'off');
     $not_empty = new Zend_Validate_NotEmpty();
     $not_empty->setMessage(_r('Please enter the Username'));
     $username->addValidators(array($not_empty));
     $password = new Zend_Form_Element_Password('password');
     $password->setLabel('Password')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->setAttrib('autocomplete', 'off')->setAttrib('renderPassword', true);
     $not_empty = new Zend_Validate_NotEmpty();
     $not_empty->setMessage(_r('Please enter the Password'));
     $password->addValidators(array($not_empty));
     $report_path = new Zend_Form_Element_Text('remotePath');
     $report_path->setLabel(_r('Remote Path'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim');
     $submit = new Zend_Form_Element_Image('btn_submit');
     $submit->setImage('/images/buttons/small/save-changes.png');
     $this->addElements(array($server_name, $hostname, $connection_type_id, $port, $username, $password, $report_path, $submit));
 }
Beispiel #21
0
 public function getInput()
 {
     global $gantry;
     $name = (string) $this->element['name'];
     $class = $this->element['class'] ? 'class="' . $this->element['class'] . '"' : 'class="inputbox"';
     $mode = $this->element['mode'];
     if (!isset($mode)) {
         $mode = 'dropdown';
     }
     $options = array();
     if (!array_key_exists($name, $gantry->presets)) {
         return 'Unable to find the preset information';
     }
     foreach ($gantry->presets[$name] as $preset_name => $preset_value) {
         $val = $preset_name;
         $text = $preset_value['name'];
         if (!array_key_exists('disabled', $preset_value)) {
             $preset_value['disabled'] = 'false';
         }
         $options[] = GantryHtmlSelect::option((string) $val, _r(trim((string) $text)), 'value', 'text', (string) $preset_value['disabled'] == 'true');
     }
     if (!defined('GANTRY_PRESET')) {
         gantry_import('core.gantryjson');
         $this->template = end(explode(DS, $gantry->templatePath));
         $gantry->addScript($gantry->gantryUrl . '/admin/widgets/preset/js/preset.js');
         $gantry->addScript($gantry->gantryUrl . '/admin/widgets/preset/js/preset-saver.js');
         $gantry->addInlineScript('var Presets = {};var PresetsKeys = {};');
         if (isset($gantry->customPresets[$name])) {
             $gantry->addInlineScript('var CustomPresets = ' . GantryJSON::encode($gantry->customPresets[$name]) . ';');
         }
         define('GANTRY_PRESET', 1);
     }
     $this->presets = $gantry->originalPresets[$name];
     $gantry->addInlineScript($this->populatePresets((string) $this->element['name']));
     if ($mode == 'dropdown') {
         include_once 'selectbox.php';
         $gantry->addDomReadyScript("PresetDropdown.init('" . $name . "');");
         $selectbox = new JElementSelectBox();
         $node->addAttribute('preset', true);
         return $selectbox->fetchElement($name, $value, $node, $control_name, $options);
     } else {
         $gantry->addDomReadyScript("Scroller.init('" . $name . "');");
         return $this->scrollerLayout($this->element);
     }
 }
Beispiel #22
0
 public function __construct($options = null)
 {
     parent::__construct($options);
     $this->setName('login_form')->setAction('/auth/login')->setMethod('post');
     $username = new Zend_Form_Element_Text('username');
     $username->setLabel(_r('Username'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim');
     $not_empty = new Zend_Validate_NotEmpty();
     $not_empty->setMessage(_r('Please enter your User Name'));
     $username->addValidators(array($not_empty));
     $password = new Zend_Form_Element_Password('password');
     $password->setLabel(_r('Password'))->setRequired(true)->addFilter('StripTags');
     $not_empty = new Zend_Validate_NotEmpty();
     $not_empty->setMessage(_r('Please enter your Password'));
     $password->addValidators(array($not_empty));
     $submit = new Zend_Form_Element_Image('btn_submit');
     $submit->setImage('/images/buttons/small/login.png');
     $this->addElements(array($username, $password, $submit));
 }
 public function step1Action()
 {
     $this->view->headTitle('Step 1');
     $this->view->headLink()->appendStylesheet("/css/template/table.css");
     $sh = new MAL_Util_Shell();
     $requirements = array();
     $requirements[_r("PHP version greater than 5.3.2")] = array("ACTUAL" => PHP_VERSION, "RESULT" => PHP_VERSION_ID >= 50302);
     $requirements[_r("PHP mcrypt module installed")] = array("ACTUAL" => extension_loaded("mcrypt") ? _r("OK") : _r("Not installed"), "RESULT" => extension_loaded("mcrypt"));
     $requirements[_r("PHP ftp module installed")] = array("ACTUAL" => extension_loaded("ftp") ? _r("OK") : _r("Not installed"), "RESULT" => extension_loaded("ftp"));
     $requirements[_r("PHP Safe mode is disabled")] = array("ACTUAL" => ini_get('safe_mode') ? "safe_mode = " . ini_get('safe_mode') : _r("Not set"), "RESULT" => ini_get('safe_mode') != '1');
     $requirements[_r("MySQL installed")] = array("ACTUAL" => extension_loaded("pdo_mysql") ? _r("OK") : _r("Not installed"), "RESULT" => extension_loaded("pdo_mysql"));
     $sh->Exec("echo test");
     $requirements[_r("Permission to run 'exec' function")] = array("ACTUAL" => $sh->getLastOutput() == array("test") ? _r("OK") : _r("Could not run"), "RESULT" => $sh->getLastOutput() == array("test"));
     $sh->Exec("ssh -v");
     $r = $sh->getLastOutput();
     $requirements[_r("OpenSSH installed")] = array("ACTUAL" => $r[0], "RESULT" => strpos($r[0], "OpenSSH") !== false);
     $sh->Exec("git --version");
     $r = $sh->getLastOutput();
     $requirements[_r("Git installed")] = array("ACTUAL" => $r[0], "RESULT" => strpos($r[0], "git version ") !== false);
     $requirements[_r("May not work with Suhosin")] = array("ACTUAL" => $this->hasSuhosin() ? _r("Suhosin is enabled") . " - <strong>" . _r("GoDeploy may not function correctly") . "</strong>" : _r("Suhosin not enabled"), "RESULT" => !$this->hasSuhosin(), "NOT_CRITICAL" => true);
     $cfg_test = APPLICATION_PATH . "/configs/config.ini";
     $fh = @fopen($cfg_test, "a+");
     $requirements[_r("Config file writable")] = array("ACTUAL" => $cfg_test . " " . _r("is") . " " . ($fh === false ? "<strong>" . _r("not writable") . "</strong>" : _r("writable")), "RESULT" => $fh !== false, "NOT_CRITICAL" => true);
     if ($fh !== false) {
         fclose($fh);
         @unlink($cfg_test);
     }
     $cache_test = str_replace("/application", "/gitcache/.test", APPLICATION_PATH);
     $fh = @fopen($cache_test, "a+");
     $requirements[_r("gitcache directory writable")] = array("ACTUAL" => $cache_test . " " . _r("is") . " " . ($fh === false ? "<strong>" . _r("not writable") . "</strong>" : _r("writable")), "RESULT" => $fh !== false);
     if ($fh !== false) {
         fclose($fh);
         @unlink($cache_test);
     }
     // Check we've passed everything
     $passed = true;
     foreach ($requirements as $rq) {
         if ($rq["RESULT"] === false && !isset($rq["NOT_CRITICAL"])) {
             $passed = false;
         }
     }
     $this->view->passed = $passed;
     $this->view->requirements = $requirements;
 }
Beispiel #24
0
 public function getInput()
 {
     global $gantry;
     $clean_name = (string) $this->element['name'];
     $position_info = $gantry->getPositionInfo($clean_name);
     $buffer = '';
     $buffer .= "<div class='wrapper'>\n";
     foreach ($this->fields as $field) {
         if (!empty($position_info) && array_key_exists('position_info', get_object_vars($field))) {
             $field->position_info = $position_info;
         }
         $itemName = $this->fieldname . "-" . $field->fieldname;
         $buffer .= '<div class="chain ' . $itemName . ' chain-' . strtolower($field->type) . '">' . "\n";
         $buffer .= '<span class="chain-label">' . _r($field->getLabel()) . '</span>' . "\n";
         $buffer .= $field->getInput();
         $buffer .= "</div>" . "\n";
     }
     $buffer .= "</div>" . "\n";
     return $buffer;
 }
Beispiel #25
0
 /**
  * Method to get the field options.
  *
  * @return	array	The field option objects.
  * @since	1.6
  */
 protected function getOptions()
 {
     // Initialize variables.
     $options = array();
     foreach ($this->element->children() as $option) {
         // Only add <option /> elements.
         if ($option->getName() != 'option') {
             continue;
         }
         // Create a new option object based on the <option /> element.
         $tmp = GantryHtmlSelect::option((string) $option['value'], _r(trim((string) $option)), 'value', 'text', (string) $option['disabled'] == 'true');
         // Set some option attributes.
         $tmp->class = (string) $option['class'];
         // Set some JavaScript option attributes.
         $tmp->onclick = (string) $option['onclick'];
         // Add the option object to the result set.
         $options[] = $tmp;
     }
     reset($options);
     return $options;
 }
Beispiel #26
0
 protected function getOptions()
 {
     global $gantry;
     $options = array();
     $options = parent::getOptions();
     if (!defined("GANTRY_FONTS")) {
         $gantry->addScript($gantry->gantryUrl . '/admin/widgets/fonts/js/fonts.js');
         $gantry->addDomReadyScript("GantryFonts.init('webfonts_enabled', 'webfonts_source', 'font_family');");
         define("GANTRY_FONTS", 1);
     }
     // only google right now
     if ($gantry->get('webfonts-source') == 'google') {
         $webfonts = $this->_google_fonts;
     }
     if ($gantry->get('webfonts-enabled')) {
         $disabled = false;
     } else {
         $disabled = true;
     }
     foreach ($webfonts as $webfont) {
         $webfontsData = $webfont;
         $webfontsValue = $webfont;
         $text = $webfontsData;
         // Create a new option object based on the <option /> element.
         $tmp = GantryHtmlSelect::option((string) $webfontsValue, _r(trim((string) $text)), 'value', 'text', $disabled);
         // adding reference source class
         if (in_array($webfont, $this->_google_fonts)) {
             $option['class'] = 'google';
         } else {
             $option['class'] = 'native';
         }
         // Set some option attributes.
         $tmp->class = (string) $option['class'];
         // Set some JavaScript option attributes.
         $tmp->onclick = isset($option['onclick']) ? (string) $option['onclick'] : '';
         // Add the option object to the result set.
         $options[] = $tmp;
     }
     return $options;
 }
/**
 * Standard importing interface, to be called by an importer
 *
 * @param array $feeds Associative array containing 'url', 'title' and 'cat'
 */
function import($feeds)
{
    ?>
<p><?php 
    _e('Currently importing feeds. Please keep this page open in your browser until all feeds have been processed.');
    ?>
</p>
<p class="sidenote"><?php 
    _e('Please note: Javascript must be enabled to import feeds.');
    ?>
</p>
<p id="import-progress"><?php 
    printf(_r('Imported <span class="done">0</span> of <span class="total">%d</span> so far.'), count($feeds));
    ?>
 <img src="loading.gif" alt="" /></p>
<ul id="log">
</ul>
<script type="text/javascript" src="<?php 
    echo get_option('baseurl');
    ?>
admin/importer.js"></script>
<script type="text/javascript">
var feeds_to_add = <?php 
    echo json_encode($feeds);
    ?>
;
$(document).ready(function (){
	importer.init(feeds_to_add);
	importer.end_callback = function () {
		$("#main").append("<p><?php 
    _e('Finished importing feeds.');
    ?>
</p>");
	};
});
</script>
<?php 
}
 public function __construct(GD_Model_Project $project, $options = null, $new_project = false)
 {
     parent::__construct($options);
     $this->setName('projectSettings');
     $project_name = new Zend_Form_Element_Text('name');
     $project_name->setLabel(_r('Project Name'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim');
     $not_empty = new Zend_Validate_NotEmpty();
     $not_empty->setMessage(_r('Please enter the project name'));
     $project_name->addValidators(array($not_empty));
     // if we're adding a new project, we need to make sure it's unique
     if ($new_project) {
         $unique_name = new GD_Validate_UniqueName();
         $project_name->addValidators(array($unique_name));
     }
     $git_validator = new GD_Validate_GitUrl();
     $repository_url = new Zend_Form_Element_Text('repositoryUrl');
     $repository_url->setLabel(_r('Repository URL'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim');
     $not_empty = new Zend_Validate_NotEmpty();
     $not_empty->setMessage(_r('Please enter the Repository URL'));
     $repository_url->addValidators(array($not_empty, $git_validator));
     $deployment_branch = new Zend_Form_Element_Text('deploymentBranch');
     $deployment_branch->setLabel(_r('Deployment Branch'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim');
     $not_empty = new Zend_Validate_NotEmpty();
     $not_empty->setMessage(_r('Please enter the name of the Deployment Branch'));
     $deployment_branch->addValidators(array($not_empty));
     if (!$new_project) {
         $deployment_branch->addValidator(new GD_Validate_GitBranch($project));
     }
     $public_key = new Zend_Form_Element_Textarea('publicKey');
     $public_key->setLabel(_r('Public Key'))->setRequired(false)->setAttrib('readonly', 'readonly');
     $not_empty = new Zend_Validate_NotEmpty();
     $not_empty->setMessage(_r('Please enter the Public Key'));
     $public_key->addValidators(array($not_empty));
     $submit = new Zend_Form_Element_Image('btn_submit');
     $submit->setImage('/images/buttons/small/save-changes.png');
     $submit->class = "processing_btn size_small";
     $this->addElements(array($project_name, $repository_url, $deployment_branch, $public_key, $submit));
 }
Beispiel #29
0
/**
 * Validate a plugin filename
 *
 * Checks that the file exists and {@link validate_file() is valid file}. If
 * it either condition is not met, returns false and adds an error to the
 * {@see MessageHandler} stack.
 *
 * @since 1.0
 *
 * @param $filename Path to plugin
 * @return bool True if file exists and is valid, otherwise an exception will be thrown
 */
function validate_plugin($filename)
{
    switch (validate_file($filename)) {
        case 1:
        case 2:
            throw new Exception(_r('Invalid plugin path.'), Errors::get_code('admin.plugins.invalid_path'));
            break;
        default:
            if (file_exists(get_plugin_dir() . $filename)) {
                return true;
            } else {
                throw new Exception(_r('Plugin file was not found.'), Errors::get_code('admin.plugins.not_found'));
            }
    }
    return false;
}
Beispiel #30
0
error_reporting(E_ALL);
// Fool the authentication so we can handle it ourselves
define('LILINA_LOGIN', true);
require_once 'admin.php';
require_once LILINA_PATH . '/admin/includes/feeds.php';
require_once LILINA_PATH . '/admin/includes/class-ajaxhandler.php';
//header('Content-Type: application/javascript');
header('Content-Type: application/json');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
if (defined('LILINA_AUTH_ERROR')) {
    header('HTTP/1.1 401 Unauthorized');
    echo json_encode(array('error' => 1, 'msg' => _r('You are not currently logged in'), 'code' => Errors::get_code('auth.none')));
    die;
}
class AdminAjax
{
    /**
     * Initialise the Ajax interface
     */
    public static function init()
    {
        $handler = new AjaxHandler();
        $handler->registerMethod('feeds.add', array('AdminAjax', 'feeds_add'));
        $handler->registerMethod('feeds.change', array('AdminAjax', 'feeds_change'));
        $handler->registerMethod('feeds.remove', array('AdminAjax', 'feeds_remove'));
        $handler->registerMethod('feeds.list', array('AdminAjax', 'feeds_list'));
        $handler->registerMethod('feeds.get', array('AdminAjax', 'feeds_get'));