Example #1
0
 /**
  * Initializes the pager. Must be called before using the component.
  *
  * Takes user configuration and creates pager object ($this->Pager)
  *
  * @access public
  * @param array $config Configuration options for Pager::factory() method
  * @see http://pear.php.net/manual/en/package.html.pager.factory.php
  * @return void
  */
 function init($config)
 {
     // Get the correct URL, even with admin routes
     $here = array();
     if (defined('CAKE_ADMIN') && !empty($this->Controller->params[CAKE_ADMIN])) {
         $here[0] = $this->Controller->params[CAKE_ADMIN];
         $here[2] = substr($this->Controller->params['action'], strlen($this->Controller->params[CAKE_ADMIN]) + 1);
     } else {
         $here[2] = $this->Controller->params['action'];
     }
     $here[1] = Inflector::underscore($this->Controller->params['controller']);
     ksort($here);
     $url = implode('/', $here);
     // Set up the default configuration vars
     $this->params = array('mode' => 'Sliding', 'perPage' => 10, 'delta' => 5, 'totalItems' => '', 'httpMethod' => 'GET', 'currentPage' => 1, 'linkClass' => 'pager', 'altFirst' => 'First page', 'altPrev ' => 'Previous page', 'altNext' => 'Next page', 'altLast' => 'Last page', 'separator' => '', 'spacesBeforeSeparator' => 1, 'spacesAfterSeparator' => 1, 'useSessions' => false, 'firstPagePre' => '', 'firstPagePost' => '', 'firstPageText' => '<img src="' . $this->Controller->base . '/img/first.gif" alt="">', 'lastPagePre' => '', 'lastPagePost' => '', 'lastPageText' => '<img src="' . $this->Controller->base . '/img/last.gif" alt="">', 'prevImg' => '<img src="' . $this->Controller->base . '/img/prev.gif" alt="">', 'nextImg' => '<img src="' . $this->Controller->base . '/img/next.gif" alt="">', 'altPage' => 'Page', 'clearIfVoid' => true, 'append' => false, 'path' => '', 'fileName' => $this->Controller->base . DS . $url . DS . '%d', 'urlVar' => '');
     vendor('Pear/Pager/Pager');
     // Merge with user config
     $this->params = array_merge($this->params, $config);
     // sanitize requested page number
     if (!in_array($this->params['currentPage'], range(1, ceil($this->params['totalItems'] / $this->params['perPage'])))) {
         $this->params['currentPage'] = 1;
     }
     $this->Pager =& Pager::factory($this->params);
     // Set the template vars
     $this->Controller->set('pageLinks', $this->Pager->getLinks());
     $this->Controller->set('currentPage', $this->params['currentPage']);
     $this->Controller->set('isFirstPage', $this->Pager->isFirstPage());
     $this->Controller->set('isLastPage', $this->Pager->isLastPage());
 }
Example #2
0
/**
 * Filter AudioTheme archive requests.
 *
 * Set the number of posts per archive page.
 *
 * @since 1.4.2
 * @todo Refactor to make it easier to retrieve settings and to define defaults in a single location.
 * @todo Implement a "rows" setting for calculating "posts_per_archive_page".
 *
 * @param object $query The main WP_Query object. Passed by reference.
 */
function audiotheme_archive_query($query)
{
    if (is_admin() || !$query->is_main_query() || !(is_post_type_archive() || is_tax())) {
        return;
    }
    $post_type = get_audiotheme_current_archive_post_type();
    if (empty($post_type)) {
        return;
    }
    // Determine if the 'posts_per_archive_page' setting is active for the current post type.
    $fields = apply_filters('audiotheme_archive_settings_fields', array(), $post_type);
    $columns = 1;
    if (!empty($fields['columns']) && $fields['columns']) {
        $default = empty($fields['columns']['default']) ? 4 : absint($fields['columns']['default']);
        $columns = get_audiotheme_archive_meta('columns', true, $default, $post_type);
    }
    if (!empty($fields['posts_per_archive_page']) && $fields['posts_per_archive_page']) {
        // Get the number of posts to display for this post type.
        $posts_per_archive_page = get_audiotheme_archive_meta('posts_per_archive_page', true, '', $post_type);
        if (!empty($posts_per_archive_page)) {
            $query->set('posts_per_archive_page', intval($posts_per_archive_page));
        }
    }
    if (empty($posts_per_archive_page) && $columns > 1) {
        // Default to three even rows.
        $query->set('posts_per_archive_page', intval($columns * 3));
    }
}
Example #3
0
 /**
  * Register specific services for the module
  *
  * @package     base-app
  * @version     2.0
  *
  * @param object $di dependency Injector
  *
  * @return void
  */
 public function registerServices($di)
 {
     //Registering a dispatcher
     $di->set('dispatcher', function () {
         //Create/Get an EventManager
         $eventsManager = new \Phalcon\Events\Manager();
         //Attach a listener
         $eventsManager->attach("dispatch", function ($event, $dispatcher, $exception) {
             //controller or action doesn't exist
             if ($event->getType() == 'beforeException') {
                 switch ($exception->getCode()) {
                     case \Phalcon\Cli\Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
                     case \Phalcon\Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
                         $dispatcher->forward(array('task' => 'main', 'action' => 'notFound'));
                         return false;
                 }
             }
         });
         //$dispatcher = new \Phalcon\Mvc\Dispatcher();
         $dispatcher = new \Phalcon\Cli\Dispatcher();
         //Set default namespace to frontend module
         $dispatcher->setDefaultNamespace("Baseapp\\Cli\\Tasks");
         //Bind the EventsManager to the dispatcher
         $dispatcher->setEventsManager($eventsManager);
         return $dispatcher;
     });
     //Registering the view component
     $di->set('view', function () use($di) {
         $view = new \Phalcon\Mvc\View();
         $view->setViewsDir(ROOT_PATH . '/app/frontend/views/');
         $view->registerEngines(\Baseapp\Library\Tool::registerEngines($view, $di));
         return $view;
     });
 }
 /**
  * Método construtor
  * @param array $alert ['Classe CSS', 'Título do alerta', 'Mensagem do alerta']
  */
 public function __construct(array $alert)
 {
     //Remoção dos índices associativos
     $alert = array_values($alert);
     //Injeção da Sessão
     $this->storage = new Storage\Session();
     if (count($alert) == 1) {
         return null;
     }
     $alert[2] = !isset($alert[2]) ? '' : $alert[2];
     list($style, $title, $message) = $alert;
     /**
      * Rederiza a mensagem
      * @var string
      */
     $render = $this->render($message);
     /**
      * Recupera o template html ara a mensagem
      * @var html
      */
     $template = $this->getTemplate();
     /**
      * Aplica a mensagem no template
      * @var html
      */
     $content = sprintf($template, $style, $title, $render);
     $this->storage->set('message', $content);
 }
Example #5
0
 /**
  * Displays the view
  *
  * @param		string	$tpl	The name of the template file to parse
  *
  * @return	void
  *
  * @since		2.5
  */
 public function display($tpl = null)
 {
     $doc = JFactory::getDocument();
     $doc->addStyleSheet(JURI::root() . 'media/overrider/css/overrider.css');
     JHtml::_('behavior.framework');
     $doc->addScript(JURI::root() . 'media/overrider/js/overrider.js');
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->state = $this->get('State');
     // Check for errors
     if (count($errors = $this->get('Errors'))) {
         throw new Exception(implode("\n", $errors));
         return;
     }
     // Check whether the cache has to be refreshed
     $cached_time = JFactory::getApplication()->getUserState('com_languages.overrides.cachedtime.' . $this->state->get('filter.client') . '.' . $this->state->get('filter.language'), 0);
     if (time() - $cached_time > 60 * 5) {
         $this->state->set('cache_expired', true);
     }
     // Add strings for translations in Javascript
     JText::script('COM_LANGUAGES_VIEW_OVERRIDE_NO_RESULTS');
     JText::script('COM_LANGUAGES_VIEW_OVERRIDE_REQUEST_ERROR');
     $this->addToolbar();
     parent::display($tpl);
 }
Example #6
0
 /**
  * 设置一个key的值
  * @param string $key
  * @param string $value
  * @param int $expire
  */
 public static function set($key, $value, $expire = 0)
 {
     if (ctype_digit((string) $expire) && $expire) {
         return self::$instance->setex($key, $expire, $value);
     } else {
         return self::$instance->set($key, $value);
     }
 }
 /**
  * Flash a piece of data to the session.
  *
  * @param   string  $key
  * @param   mixed   $value
  * @return  object
  */
 public function with($key, $value = null)
 {
     $key = is_array($key) ? $key : [$key => $value];
     foreach ($key as $k => $v) {
         $this->session->set($k, $v);
     }
     return $this;
 }
Example #8
0
 /**
  * Adds a new item that is to be cached
  *
  * @param string $key
  * @param mixed $data
  * @param bool $overwrite
  * @return bool
  */
 public function add($key, $data, $overwrite = false)
 {
     if ($overwrite == false) {
         return $this->memcached->add($key, $data, $this->ttl());
     } else {
         return $this->memcached->set($key, $data, $this->ttl());
     }
 }
Example #9
0
 /**
  * tearDown
  *
  * @since 3.0.0
  */
 public function tearDown()
 {
     $installer = new Installer($this->_config);
     $installer->init();
     $installer->rawDrop();
     $this->_request->setServer('argv', null);
     $this->_config->set('dbPrefix', $this->_configArray['dbPrefix']);
 }
Example #10
0
 /**
  * @param int $userId
  * @return void
  */
 public function login($userId)
 {
     $this->session->set('user_id', $this->generateHash($userId));
     $this->session->set('uid', $userId);
     $this->session->set('user_agent', $this->getUserAgent());
     $this->setUser($userId);
     $this->loggedIn = true;
 }
 /**
  * Autentica o usuário
  * @param  integet $user_id  ID do usuário
  * @param  string $username  Nome de usuário
  */
 public function login($user_id, $username)
 {
     $this->storage->set('user_id', preg_replace("/[^0-9]+/", "", $user_id));
     $this->storage->set('username', preg_replace("/[^a-zA-Z0-9_\\-]+/", "", $username));
     $this->storage->set('login_string', hash('sha512', $username . $_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']));
     if ($this->redirect === true) {
         return $this->response->redirectTo($this->url_redirect_after_login);
     }
 }
Example #12
0
 /**
  * testGlobal
  *
  * @since 2.2.0
  */
 public function testGlobal()
 {
     /* setup */
     $this->_request->set('testKey', 'testValue');
     /* actual */
     $actual = $this->_request->get('testKey');
     /* compare */
     $this->assertEquals('testValue', $actual);
 }
 /**
  * testGetAndSet
  *
  * @since 2.4.0
  */
 public function testGetAndSet()
 {
     /* setup */
     $this->_language->set('testKey', 'testValue');
     /* actual */
     $actual = $this->_language->get('testKey');
     /* compare */
     $this->assertEquals('testValue', $actual);
 }
Example #14
0
 /**
  * {@inheritDoc}
  *
  * @param mixed $key   Key
  * @param mixed $value Value
  */
 protected function setPersistentData($key, $value)
 {
     if (!in_array($key, self::$kSupportedKeys)) {
         self::errorLog('Unsupported key passed to setPersistentData.');
         return;
     }
     $sessionVarName = $this->constructSessionVariableName($key);
     $this->session->set($sessionVarName, $value);
 }
Example #15
0
 /**
  * testGetAll
  *
  * @since 2.2.0
  */
 public function testGetAll()
 {
     /* setup */
     $this->_registry->set('testAll', 'testAll');
     /* result */
     $result = $this->_registry->get();
     /* compare */
     $this->assertArrayHasKey('testAll', $result);
 }
 /**
  * testGetAll
  *
  * @since 2.2.0
  */
 public function testGetAll()
 {
     /* setup */
     $this->_registry->set('testAll', 'testAll');
     /* actual */
     $actual = $this->_registry->get();
     /* compare */
     $this->assertArrayHasKey('testAll', $actual);
 }
 /**
  * testSetAndGet
  *
  * @since 2.2.0
  */
 public function testSetAndGet()
 {
     /* setup */
     $this->_config->set('dbHost', 'localhost');
     /* actual */
     $actual = $this->_config->get('dbHost');
     /* compare */
     $this->assertEquals('localhost', $actual);
 }
Example #18
0
 /**
  * Save
  *
  * @param	string	unique identifier
  * @param	mixed	data being cached
  * @param	int	time to live
  * @return	bool	true on success, false on failure
  */
 public function save($id, $data, $ttl = 60)
 {
     if (get_class($this->_memcached) === 'Memcached') {
         return $this->_memcached->set($id, array($data, time(), $ttl), $ttl);
     } elseif (get_class($this->_memcached) === 'Memcache') {
         return $this->_memcached->set($id, array($data, time(), $ttl), 0, $ttl);
     }
     return FALSE;
 }
Example #19
0
 /**
  * Filter on the user query to change the users loaded.
  *
  * @since  1.0.0
  * @access public
  * @param  object  $query
  * @return void
  */
 public function pre_get_users($query)
 {
     if ('topic_count' === $query->get('orderby')) {
         $query->set('orderby', 'meta_value_num');
         $query->set('meta_key', mb_get_user_topic_count_meta_key());
     } elseif ('reply_count' === $query->get('orderby')) {
         $query->set('orderby', 'meta_value_num');
         $query->set('meta_key', mb_get_user_reply_count_meta_key());
     }
 }
Example #20
0
 /**
  * testInit
  *
  * @since 2.2.0
  *
  * @param string $dbType
  *
  * @dataProvider providerDb
  */
 public function testInit($dbType = null)
 {
     /* setup */
     $this->_config->set('dbType', $dbType);
     Db::init($this->_config);
     /* actual */
     $actual = Db::getDb();
     /* compare */
     $this->assertInstanceOf('PDO', $actual);
 }
 /**
  * Fetch a reference to the templating object
  * thats floating around in Aether
  *
  * @access public
  * @return AetherTemplate A template object
  */
 public function getTemplate()
 {
     if ($this->template == null) {
         $this->template = AetherTemplate::get('smarty', $this);
     }
     // Add global stuff
     $providers = $this->getVector('aetherProviders');
     $this->template->set('aether', array_merge(array('providers' => $providers), $this->getVector('templateGlobals')->getAsArray()));
     return $this->template;
 }
Example #22
0
 public function processTemplate($file)
 {
     $tempPath = RESOURCE_PATH . '/data/pres/template';
     $this->__Document->set('TemplatePath', $tempPath);
     if (is_dir($tempPath)) {
         $this->__Document->process($file);
     } else {
         trigger_error('The current working directory "' . $directory . '" can not be opened.', E_USER_ERROR);
     }
     // end function
 }
 /**
  * Display only video post type in video search results
  *
  * @param object $query
  * @return object $query
  */
 function wolf_video_search_results($query)
 {
     if (isset($_GET['post-type']) && 'video' == $_GET['post-type'] && class_exists('Wolf_Videos')) {
         if ($query->is_search) {
             $posts_per_page = wolf_get_theme_option('video_posts_per_page') ? wolf_get_theme_option('video_posts_per_page') : 12;
             $query->set('post_type', 'video');
             $query->set('posts_per_page', $posts_per_page);
         }
     }
     return $query;
 }
 /**
  * Authorization in Imap service
  * @param array $options setting authorization
  * @access public
  * @return bool
  * @throws Exception
  */
 public function connect(array $options = array())
 {
     $this->setting->set($options);
     if ($this->_connection == null) {
         $this->_connection = $this->_connect();
     }
     if ($this->_connection) {
         return true;
     }
     return false;
 }
Example #25
0
 /**
  * Gets a list of the actions that can be performed.
  *
  * @return  object  Object
  */
 public static function getActions()
 {
     if (empty(self::$actions)) {
         self::$actions = new Object();
         $actions = \JAccess::getActions('com_members');
         foreach ($actions as $action) {
             self::$actions->set($action->name, User::authorise($action->name, 'com_members'));
         }
     }
     return self::$actions;
 }
Example #26
0
/**
 * Make group taxonomy archive order manually (like People template)
 *
 * Use add_theme_support( 'ctfw-people-group-manual-order' ); to enable
 *
 * @since 0.9.1
 * @param object $query Query object to modify
 * @return object Modified query
 */
function ctfw_people_group_order($query)
{
    // Theme supports this?
    if (current_theme_supports('ctfw-people-group-manual-order')) {
        // On group archive
        if ($query->is_archive && !empty($query->query['ctc_person_group'])) {
            $query->set('orderby', 'menu_order');
            $query->set('order', 'ASC');
        }
    }
    return $query;
}
Example #27
0
 /**
  * Save
  *
  * @param    string $id Cache ID
  * @param    mixed $data Data being cached
  * @param    int $ttl Time to live
  * @param    bool $raw Whether to store the raw value
  * @return    bool    TRUE on success, FALSE on failure
  */
 public function save($id, $data, $ttl = 60, $raw = FALSE)
 {
     if ($raw !== TRUE) {
         $data = array($data, time(), $ttl);
     }
     if (get_class($this->_memcached) === 'Memcached') {
         return $this->_memcached->set($id, $data, $ttl);
     } elseif (get_class($this->_memcached) === 'Memcache') {
         return $this->_memcached->set($id, $data, 0, $ttl);
     }
     return FALSE;
 }
Example #28
0
 /**
  * Adjust orderby query
  *
  * @since   2.6.3
  * @change  2.6.3
  *
  * @param   object  $query  Current WordPress query
  */
 public static function set_orderby_query($query)
 {
     /* Order by value */
     $orderby = $query->get('orderby');
     /* Skip if not our case */
     if (empty($orderby) or $orderby !== 'antispam_bee_reason') {
         return;
     }
     /* Set orderby values */
     $query->set('meta_key', 'antispam_bee_reason');
     $query->set('orderby', 'meta_value');
 }
Example #29
0
 /**
  * Autentica o usuário
  * @param  integet $user_id  ID do usuário
  * @param  string $username  Nome de usuário
  */
 public function login($user_id, $username)
 {
     $user_id = intval(preg_replace("/[^0-9]+/", "", $user_id));
     $username = preg_replace("/[^a-zA-Z0-9_\\-]+/", "", $username);
     $login_string = hash('sha512', $username . $this->request->server('REMOTE_ADDR') . $this->request->server('HTTP_USER_AGENT'));
     $this->storage->set('user_id', $user_id);
     $this->storage->set('username', $username);
     $this->storage->set('login_string', $login_string);
     if ($this->redirect === true) {
         return $this->response->redirectTo($this->url_redirect_after_login);
     }
 }
 /**
  * Speicherung im Cache
  *
  * @since   2.0.7
  * @change  2.0.7
  *
  * @param   string   $hash      Hash des Eintrags
  * @param   string   $data      Inhalt des Eintrags
  * @param   integer  $lifetime  Lebensdauer des Eintrags
  */
 public static function store_item($hash, $data, $lifetime)
 {
     /* Empty? */
     if (empty($data)) {
         wp_die('MEMCACHE add item: Empty input.');
     }
     /* Server connect */
     if (!self::_connect_server()) {
         return;
     }
     /* Add item */
     self::$_memcached->set(self::_file_path(), $data . self::_cache_signatur(), $lifetime);
 }