当前位置: 首页>>代码示例>>PHP>>正文


PHP Model::getContainer方法代码示例

本文整理汇总了PHP中Frontend\Core\Engine\Model::getContainer方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::getContainer方法的具体用法?PHP Model::getContainer怎么用?PHP Model::getContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Frontend\Core\Engine\Model的用法示例。


在下文中一共展示了Model::getContainer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getImagesForAlbum

    /**
     * Get the images for an album
     *
     * @param int $id
     *
     * @return bool
     */
    public static function getImagesForAlbum($id, $limit = 0, $random = false)
    {
        if ($random == true) {
            $orderBy = "RAND()";
        } else {
            $orderBy = "sequence";
        }
        if ($limit > 0) {
            $records = (array) FrontendModel::getContainer()->get('database')->getRecords('SELECT i.*
			 FROM gallery_images AS i
			 WHERE i.language = ? AND i.album_id = ?
			 ORDER BY ' . $orderBy . '
			 LIMIT ?', array(FRONTEND_LANGUAGE, (int) $id, $limit));
        } else {
            $records = (array) FrontendModel::getContainer()->get('database')->getRecords('SELECT i.*
			 FROM gallery_images AS i
			 WHERE i.language = ? AND i.album_id = ?
			 ORDER BY ' . $orderBy, array(FRONTEND_LANGUAGE, (int) $id));
        }
        //--Loop records
        if (!empty($records)) {
            //--Get the thumbnail-folders
            $folders = FrontendModel::getThumbnailFolders(FRONTEND_FILES_PATH . '/Gallery/Images', true);
            //--Create the image-links to the thumbnail folders
            foreach ($records as &$row) {
                foreach ($folders as $folder) {
                    $row['image_' . $folder['dirname']] = $folder['url'] . '/' . $folder['dirname'] . '/' . $row['filename'];
                }
            }
            //--Destroy the last $image (because of the reference) -- sugested by http://php.net/manual/en/control-structures.foreach.php
            unset($row);
        }
        return $records;
    }
开发者ID:Comsa,项目名称:modules,代码行数:41,代码来源:Model.php

示例2: set

 /**
  * Stores a value in a cookie, by default the cookie will expire in one day.
  *
  * @param string $key      A name for the cookie.
  * @param mixed  $value    The value to be stored. Keep in mind that they will be serialized.
  * @param int    $time     The number of seconds that this cookie will be available, 30 days is the default.
  * @param string $path     The path on the server in which the cookie will
  *                         be available. Use / for the entire domain, /foo
  *                         if you just want it to be available in /foo.
  * @param string $domain   The domain that the cookie is available on. Use
  *                         .example.com to make it available on all
  *                         subdomains of example.com.
  * @param bool   $secure   Should the cookie be transmitted over a
  *                         HTTPS-connection? If true, make sure you use
  *                         a secure connection, otherwise the cookie won't be set.
  * @param bool   $httpOnly Should the cookie only be available through
  *                         HTTP-protocol? If true, the cookie can't be
  *                         accessed by Javascript, ...
  * @return bool    If set with success, returns true otherwise false.
  */
 public static function set($key, $value, $time = 2592000, $path = '/', $domain = null, $secure = null, $httpOnly = true)
 {
     // redefine
     $key = (string) $key;
     $value = serialize($value);
     $time = time() + (int) $time;
     $path = (string) $path;
     $httpOnly = (bool) $httpOnly;
     // when the domain isn't passed and the url-object is available we can set the cookies for all subdomains
     if ($domain === null && FrontendModel::getContainer()->has('request')) {
         $domain = '.' . FrontendModel::getContainer()->get('request')->getHost();
     }
     // when the secure-parameter isn't set
     if ($secure === null) {
         /*
         detect if we are using HTTPS, this wil only work in Apache, if you are using nginx you should add the
         code below into your config:
             ssl on;
            fastcgi_param HTTPS on;
         
         for lighttpd you should add:
             setenv.add-environment = ("HTTPS" => "on")
         */
         $secure = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on';
     }
     // set cookie
     $cookie = setcookie($key, $value, $time, $path, $domain, $secure, $httpOnly);
     // problem occurred
     return $cookie === false ? false : true;
 }
开发者ID:bwgraves,项目名称:forkcms,代码行数:50,代码来源:Cookie.php

示例3: get

 /**
  * Get an item.
  *
  * @param string $id The id of the item to fetch.
  *
  * @return array
  *
  * @deprecated use doctrine instead
  */
 public static function get($id)
 {
     trigger_error('Frontend\\Modules\\ContentBlocks\\Engine is deprecated.
          Switch to doctrine instead.', E_USER_DEPRECATED);
     return (array) FrontendModel::getContainer()->get('database')->getRecord('SELECT i.title, i.text, i.template
          FROM content_blocks AS i
          WHERE i.id = ? AND i.status = ? AND i.hidden = ? AND i.language = ?', array((int) $id, 'active', 'N', LANGUAGE));
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:17,代码来源:Model.php

示例4: getRoom

 public static function getRoom($room_id)
 {
     $room = (array) FrontendModel::getContainer()->get('database')->getRecord('SELECT hr.id, hr.title, hr.price, hr.image, hr.count
          FROM hotels_rooms AS hr
          WHERE hr.id = ?', array($room_id));
     if ($room) {
         $room['image'] = HOTELS_API_URL . FRONTEND_FILES_URL . '/rooms/images/source/' . $room['image'];
     }
     return $room;
 }
开发者ID:andsci,项目名称:hotels,代码行数:10,代码来源:Model.php

示例5: delete

 /**
  * Deletes one or more cookies.
  *
  * This overwrites the spoon cookie method and adds the same functionality
  * as in the set method to automatically set the domain.
  */
 public static function delete()
 {
     $domain = null;
     if (FrontendModel::getContainer()->has('request')) {
         $domain = '.' . FrontendModel::getContainer()->get('request')->getHost();
     }
     foreach (func_get_args() as $argument) {
         // multiple arguments are given
         if (is_array($argument)) {
             foreach ($argument as $key) {
                 self::delete($key);
             }
         } else {
             // delete the given cookie
             unset($_COOKIE[(string) $argument]);
             setcookie((string) $argument, null, 1, '/', $domain);
         }
     }
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:25,代码来源:Cookie.php

示例6: __construct

 /**
  * @param string $name     Name of the form.
  * @param string $action   The action (URL) whereto the form will be submitted, if not provided it will
  *                         be auto generated.
  * @param string $method   The method to use when submitting the form, default is POST.
  * @param string $hash     The id of the anchor to append to the action-URL.
  * @param bool   $useToken Should we automagically add a form token?
  */
 public function __construct($name, $action = null, $method = 'post', $hash = null, $useToken = true)
 {
     $this->URL = Model::getContainer()->get('url');
     $this->header = Model::getContainer()->get('header');
     $name = (string) $name;
     if ($hash !== null && strlen($hash) > 0) {
         $hash = (string) $hash;
         // check if the # is present
         if ($hash[0] !== '#') {
             $hash = '#' . $hash;
         }
     } else {
         $hash = null;
     }
     $useToken = (bool) $useToken;
     $action = $action === null ? '/' . $this->URL->getQueryString() : (string) $action;
     // call the real form-class
     parent::__construct((string) $name, $action . $hash, $method, (bool) $useToken);
     // add default classes
     $this->setParameter('id', $name);
     $this->setParameter('class', 'forkForms submitWithLink');
 }
开发者ID:bwgraves,项目名称:forkcms,代码行数:30,代码来源:Form.php

示例7: __construct

 /**
  * The constructor will store the instance in the reference, preset some settings and map the custom modifiers.
  */
 public function __construct()
 {
     parent::__construct(func_get_arg(0), func_get_arg(1), func_get_arg(2));
     $this->debugMode = Model::getContainer()->getParameter('kernel.debug');
     $this->forkSettings = Model::get('fork.settings');
     // fork has been installed
     if ($this->forkSettings) {
         $this->themePath = FRONTEND_PATH . '/Themes/' . $this->forkSettings->get('Core', 'theme', 'default');
         $loader = $this->environment->getLoader();
         $loader = new \Twig_Loader_Chain(array($loader, new \Twig_Loader_Filesystem($this->getLoadingFolders())));
         $this->environment->setLoader($loader);
         // connect symphony forms
         $formEngine = new TwigRendererEngine($this->getFormTemplates('FormLayout.html.twig'));
         $formEngine->setEnvironment($this->environment);
         $this->environment->addExtension(new SymfonyFormExtension(new TwigRenderer($formEngine, Model::get('security.csrf.token_manager'))));
     }
     $this->environment->disableStrictVariables();
     // init Form extension
     new FormExtension($this->environment);
     // start the filters / globals
     TwigFilters::getFilters($this->environment, 'Frontend');
     $this->startGlobals($this->environment);
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:26,代码来源:TwigTemplate.php

示例8: get

 public static function get($id)
 {
     $db = FrontendModel::getContainer()->get('database');
     return $db->getRecord("SELECT * FROM media WHERE id = ?", array($id));
 }
开发者ID:Comsa,项目名称:modules,代码行数:5,代码来源:Helper.php

示例9: loadProfileByUrl

 /**
  * Load a profile by URL
  *
  * @param string $url
  */
 public function loadProfileByUrl($url)
 {
     // get profile data
     $profileData = (array) FrontendModel::getContainer()->get('database')->getRecord('SELECT p.id, p.email, p.status, p.display_name, UNIX_TIMESTAMP(p.registered_on) AS registered_on
          FROM profiles AS p
          WHERE p.url = ?', (string) $url);
     // set properties
     $this->setId($profileData['id']);
     $this->setEmail($profileData['email']);
     $this->setStatus($profileData['status']);
     $this->setDisplayName($profileData['display_name']);
     $this->setRegisteredOn($profileData['registered_on']);
     // get the groups (only the ones we still have access to)
     $this->groups = (array) FrontendModel::getContainer()->get('database')->getPairs('SELECT pg.id, pg.name
          FROM profiles_groups AS pg
          INNER JOIN profiles_groups_rights AS pgr ON pg.id = pgr.group_id
          WHERE pgr.profile_id = :id AND (pgr.expires_on IS NULL OR pgr.expires_on >= NOW())', array(':id' => (int) $this->getId()));
     $this->settings = (array) FrontendModel::getContainer()->get('database')->getPairs('SELECT i.name, i.value
          FROM profiles_settings AS i
          WHERE i.profile_id = ?', $this->getId());
     foreach ($this->settings as &$value) {
         $value = unserialize($value);
     }
 }
开发者ID:bwgraves,项目名称:forkcms,代码行数:29,代码来源:Profile.php

示例10: logout

 /**
  * Logout a profile.
  */
 public static function logout()
 {
     // delete session records
     FrontendModel::getContainer()->get('database')->delete('profiles_sessions', 'session_id = ?', array(\SpoonSession::getSessionId()));
     // set is_logged_in to false
     \SpoonSession::set('frontend_profile_logged_in', false);
     // delete cookie
     CommonCookie::delete('frontend_profile_secret_key');
 }
开发者ID:bwgraves,项目名称:forkcms,代码行数:12,代码来源:Authentication.php

示例11: get

 /**
  * Get an item.
  *
  * @param string $id The id of the item to fetch.
  * @return array
  */
 public static function get($id)
 {
     return (array) FrontendModel::getContainer()->get('database')->getRecord('SELECT i.title, i.text, i.template
          FROM content_blocks AS i
          WHERE i.id = ? AND i.status = ? AND i.hidden = ? AND i.language = ?', array((int) $id, 'active', 'N', FRONTEND_LANGUAGE));
 }
开发者ID:bwgraves,项目名称:forkcms,代码行数:12,代码来源:Model.php

示例12: update

 /**
  * Update a profile.
  *
  * @param  int   $id     The profile id.
  * @param  array $values The values to update.
  * @return int
  */
 public static function update($id, array $values)
 {
     return (int) FrontendModel::getContainer()->get('database')->update('profiles', $values, 'id = ?', (int) $id);
 }
开发者ID:bwgraves,项目名称:forkcms,代码行数:11,代码来源:Model.php

示例13: validateSearch

 /**
  * Validate searches: check everything that has been marked as 'inactive', if should still be inactive
  */
 public static function validateSearch()
 {
     // we'll iterate through the inactive search indices in little batches
     $offset = 0;
     $limit = 50;
     while (1) {
         // get the inactive indices
         $searchResults = (array) FrontendModel::getContainer()->get('database')->getRecords('SELECT module, other_id
             FROM search_index
             WHERE language = ? AND active = ?
             GROUP BY module, other_id
             LIMIT ?, ?', array(FRONTEND_LANGUAGE, 'N', $offset, $limit));
         // none found? good news!
         if (!$searchResults) {
             return;
         }
         // prepare to send to modules
         $moduleResults = array();
         // loop the result set
         foreach ($searchResults as $searchResult) {
             $moduleResults[$searchResult['module']][] = $searchResult['other_id'];
         }
         // pass the results to the modules
         foreach ($moduleResults as $module => $otherIds) {
             // check if this module actually is prepared to handle searches
             $class = 'Frontend\\Modules\\' . $module . '\\Engine\\Model';
             if (is_callable(array($class, 'search'))) {
                 $moduleResults[$module] = call_user_func(array($class, 'search'), $otherIds);
                 // update the ones that are allowed to be searched through
                 self::statusIndex($module, array_keys($moduleResults[$module]), true);
             }
         }
         // didn't even get the amount of result we asked for? no need to ask again!
         if (count($searchResults) < $offset) {
             return;
         }
         $offset += $limit;
     }
 }
开发者ID:bwgraves,项目名称:forkcms,代码行数:42,代码来源:Model.php

示例14: insertDataField

 /**
  * Insert data fields.
  *
  * @param array $data The data to insert.
  * @return int
  */
 public static function insertDataField(array $data)
 {
     return FrontendModel::getContainer()->get('database')->insert('forms_data_fields', $data);
 }
开发者ID:newaltcoin,项目名称:forkcms,代码行数:10,代码来源:Model.php

示例15: setLanguage

 /**
  * Set the language
  *
  * @param string $value The (interface-)language, will be used to parse labels.
  */
 public function setLanguage($value)
 {
     // get the possible languages
     $possibleLanguages = Language::getActiveLanguages();
     // validate
     if (!in_array($value, $possibleLanguages)) {
         // only 1 active language?
         if (!Model::getContainer()->getParameter('site.multilanguage') && count($possibleLanguages) == 1) {
             $this->language = array_shift($possibleLanguages);
         } else {
             // multiple languages available but none selected
             throw new Exception('Language invalid.');
         }
     } else {
         // language is valid: set property
         $this->language = (string) $value;
     }
     // define constant
     defined('FRONTEND_LANGUAGE') || define('FRONTEND_LANGUAGE', $this->language);
     // set the locale (we need this for the labels)
     Language::setLocale($this->language);
 }
开发者ID:bwgraves,项目名称:forkcms,代码行数:27,代码来源:Ajax.php


注:本文中的Frontend\Core\Engine\Model::getContainer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。