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


PHP craft函数代码示例

本文整理汇总了PHP中craft函数的典型用法代码示例。如果您正苦于以下问题:PHP craft函数的具体用法?PHP craft怎么用?PHP craft使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: actionCheckRequirements

 public function actionCheckRequirements()
 {
     $dependencies = craft()->socialPoster_plugin->checkRequirements();
     if ($dependencies) {
         $this->renderTemplate('socialposter/_special/dependencies', array('dependencies' => $dependencies));
     }
 }
开发者ID:engram-design,项目名称:SocialPoster,代码行数:7,代码来源:SocialPoster_PluginController.php

示例2: actionHandle

 /**
  * Action Handle
  *
  * @param array $variables Variables
  *
  * @return void
  */
 public function actionHandle(array $variables = [])
 {
     $request = craft()->httpMessages->getRequest($variables);
     $response = craft()->httpMessages->getResponse();
     $response = craft()->httpMessages->handle($request, $response);
     $response->send();
 }
开发者ID:airtype,项目名称:craft-httpmessages,代码行数:14,代码来源:HttpMessagesController.php

示例3: updateAdminbarSettings

 private function updateAdminbarSettings(array $settings = array())
 {
     $plugin = craft()->plugins->getPlugin('Adminbar');
     $savedSettings = $plugin->getSettings()->getAttributes();
     $newSettingsRow = array_merge($savedSettings, $settings);
     return craft()->plugins->savePluginSettings($plugin, $newSettingsRow);
 }
开发者ID:codeforamerica,项目名称:oakland-beta,代码行数:7,代码来源:AdminbarService.php

示例4: getTriggerHtml

    /**
     * @inheritDoc IElementAction::getTriggerHtml()
     *
     * @return string|null
     */
    public function getTriggerHtml()
    {
        $js = <<<EOT
(function()
{
\tvar trigger = new Craft.ElementActionTrigger({
\t\thandle: 'View',
\t\tbatch: false,
\t\tvalidateSelection: function(\$selectedItems)
\t\t{
\t\t\tvar \$element = \$selectedItems.find('.element');

\t\t\treturn (
\t\t\t\t\$element.data('url') &&
\t\t\t\t(\$element.data('status') == 'enabled' || \$element.data('status') == 'live')
\t\t\t);
\t\t},
\t\tactivate: function(\$selectedItems)
\t\t{
\t\t\twindow.open(\$selectedItems.find('.element').data('url'));
\t\t}
\t});
})();
EOT;
        craft()->templates->includeJs($js);
    }
开发者ID:scisahaha,项目名称:generator-craft,代码行数:31,代码来源:ViewElementAction.php

示例5: getMinElapsedTime

 protected function getMinElapsedTime()
 {
     if ($elapsedTime = craft()->sproutInvisibleCaptcha->getMethodOption('elapsedTime')) {
         return $elapsedTime;
     }
     return self::MIN_ELAPSED_TIME;
 }
开发者ID:jackmcgreevy,项目名称:fast,代码行数:7,代码来源:SproutInvisibleCaptcha_TimeMethodService.php

示例6: normalizeDataForElementsTable

 /**
  * Normalize Submission For Elements Table
  *
  */
 public function normalizeDataForElementsTable()
 {
     $data = json_decode($this->submission, true);
     // Pop off the first (4) items from the data array
     $data = array_slice($data, 0, 4);
     $newData = '<ul>';
     foreach ($data as $key => $value) {
         $fieldHandle = craft()->fields->getFieldByHandle($key);
         $capitalize = ucfirst($key);
         $removeUnderscore = str_replace('_', ' ', $key);
         $valueArray = is_array($value);
         if ($valueArray == '1') {
             $newData .= '<li class="left icon" style="margin-right:10px;"><strong>' . $fieldHandle . '</strong>: ';
             foreach ($value as $item) {
                 if ($item != '') {
                     $newData .= $item;
                     if (next($value) == true) {
                         $newData .= ', ';
                     }
                 }
             }
         } else {
             if ($value != '') {
                 $newData .= '<li class="left icon" style="margin-right:10px;"><strong>' . $fieldHandle . '</strong>: ' . $value . '</li>';
             }
         }
     }
     $newData .= '</ul>';
     $this->__set('submission', $newData);
     return $this;
 }
开发者ID:daituzhang,项目名称:craft-starter,代码行数:35,代码来源:FormBuilder2_EntryModel.php

示例7: getElementType

 /**
  * Returns an element type.
  *
  * @param string $class
  *
  * @return ElementTypeVariable|null
  */
 public function getElementType($class)
 {
     $elementType = craft()->elements->getElementType($class);
     if ($elementType) {
         return new ElementTypeVariable($elementType);
     }
 }
开发者ID:jmstan,项目名称:craft-website,代码行数:14,代码来源:ElementsVariable.php

示例8: _getParsedown

 /**
  * Returns a new ParsedownExtra instance.
  *
  * @access private
  * @return \ParsedownExtra
  */
 private function _getParsedown()
 {
     if (!class_exists('\\ParsedownExtra')) {
         require_once craft()->path->getPluginsPath() . 'markdown/vendor/autoload.php';
     }
     return new \ParsedownExtra();
 }
开发者ID:ethercreative,项目名称:markdown,代码行数:13,代码来源:MarkdownService.php

示例9: getOptimizedMeta

 /**
  * Prioritize our meta data
  * ------------------------------------------------------------
  *
  * Loop through and select the highest ranking value for each attribute in our SproutSeo_MetaData model
  *
  * 1) Entry Override (Set by adding `id` override in Twig template code and using Meta Fields)
  * 2) On-Page Override (Set in Twig template code)
  * 3) Default (Set in control panel)
  * 4) Global Fallback (Set in control panel)
  * 5) Blank (Automatic)
  *
  * Once we have added all the content we need to be outputting to our array we will loop through that array and create the HTML we will output to our page.
  *
  * While we don't define HTML in our PHP as much as possible, the goal here is to be as easy to use as possible on the front end so we want to simplify the front end code to a single function and wrangle what we need to here.
  *
  * @return array
  * @throws \Exception
  */
 public function getOptimizedMeta()
 {
     $entryOverrideMetaModel = new SproutSeo_MetaModel();
     $codeOverrideMetaModel = new SproutSeo_MetaModel();
     $defaultMetaModel = new SproutSeo_MetaModel();
     $globalFallbackMetaModel = new SproutSeo_MetaModel();
     // Prepare a SproutSeo_MetaModel for each of our levels of priority
     $entryOverrideMetaModel = $entryOverrideMetaModel->setMeta('entry', $this->getMeta());
     $codeOverrideMetaModel = $codeOverrideMetaModel->setMeta('code', $this->getMeta());
     $defaultMetaModel = $defaultMetaModel->setMeta('default', $this->getMeta());
     $globalFallbackMetaModel = $globalFallbackMetaModel->setMeta('fallback');
     $prioritizedMetaModel = new SproutSeo_MetaModel();
     $this->divider = craft()->plugins->getPlugin('sproutseo')->getSettings()->seoDivider;
     // Default to the Current URL
     $prioritizedMetaModel->canonical = SproutSeoMetaHelper::prepareCanonical($prioritizedMetaModel);
     foreach ($prioritizedMetaModel->getAttributes() as $key => $value) {
         // Test for a value on each of our models in their order of priority
         if ($entryOverrideMetaModel->getAttribute($key)) {
             $prioritizedMetaModel[$key] = $entryOverrideMetaModel[$key];
         } elseif ($codeOverrideMetaModel->getAttribute($key)) {
             $prioritizedMetaModel[$key] = $codeOverrideMetaModel[$key];
         } elseif ($defaultMetaModel->getAttribute($key)) {
             $prioritizedMetaModel[$key] = $defaultMetaModel->getAttribute($key);
         } elseif ($globalFallbackMetaModel->getAttribute($key)) {
             $prioritizedMetaModel[$key] = $globalFallbackMetaModel->getAttribute($key);
         } else {
             $prioritizedMetaModel[$key] = $prioritizedMetaModel->getAttribute($key);
         }
     }
     // @todo - reorganize how this stuff works / robots need love.
     $prioritizedMetaModel->title = SproutSeoMetaHelper::prepareAppendedSiteName($prioritizedMetaModel, $defaultMetaModel, $globalFallbackMetaModel);
     $prioritizedMetaModel->robots = SproutSeoMetaHelper::prepRobotsAsString($prioritizedMetaModel->robots);
     return $prioritizedMetaModel;
 }
开发者ID:aladrach,项目名称:Bluefoot-Craft-Starter,代码行数:53,代码来源:SproutSeo_MetaService.php

示例10: setMockElementsService

 /**
  * Mock ElementsService.
  */
 private function setMockElementsService()
 {
     $mock = $this->getMockBuilder('Craft\\ElementsService')->disableOriginalConstructor()->setMethods(array('getCriteria'))->getMock();
     $criteria = $this->getMockElementCriteriaModel();
     $mock->expects($this->any())->method('getCriteria')->willReturn($criteria);
     $this->setComponent(craft(), 'elements', $mock);
 }
开发者ID:boboldehampsink,项目名称:zipassets,代码行数:10,代码来源:ZipAssetsTest.php

示例11: init

 function init()
 {
     if (craft()->request->isCpRequest() && craft()->userSession->isLoggedIn()) {
         craft()->templates->includeJsResource("zipassets/js/zipassets.js");
         craft()->templates->includeCssResource("zipassets/css/zipassets.css");
     }
 }
开发者ID:khalwat,项目名称:zipassets,代码行数:7,代码来源:ZipAssetsPlugin.php

示例12: download

 /**
  * Download zipfile.
  *
  * @param array  $files
  * @param string $filename
  *
  * @return string
  */
 public function download($files, $filename)
 {
     // Get assets
     $criteria = craft()->elements->getCriteria(ElementType::Asset);
     $criteria->id = $files;
     $criteria->limit = null;
     $assets = $criteria->find();
     // Set destination zip
     $destZip = craft()->path->getTempPath() . $filename . '_' . time() . '.zip';
     // Create the zipfile
     IOHelper::createFile($destZip);
     // Loop through assets
     foreach ($assets as $asset) {
         // Get asset source
         $source = $asset->getSource();
         // Get asset source type
         $sourceType = $source->getSourceType();
         // Get asset file
         $file = $sourceType->getLocalCopy($asset);
         // Add to zip
         Zip::add($destZip, $file, dirname($file));
     }
     // Return zip destination
     return $destZip;
 }
开发者ID:brammittendorff,项目名称:zipassets,代码行数:33,代码来源:ZipAssetsService.php

示例13: safeUp

 /**
  * Any migration code in here is wrapped inside of a transaction.
  *
  * @return bool
  */
 public function safeUp()
 {
     if (!craft()->db->columnExists('entryversions', 'num')) {
         // Add the `num` column
         $columnConfig = array('maxLength' => 6, 'decimals' => 0, 'column' => 'smallint', 'unsigned' => true);
         $this->addColumnAfter('entryversions', 'num', $columnConfig, 'locale');
         $versionCountsByEntryIdAndLocale = array();
         // Populate it in batches
         $offset = 0;
         do {
             $versions = craft()->db->createCommand()->select('id, entryId, locale')->from('entryversions')->order('dateCreated asc')->offset($offset)->limit(100)->queryAll();
             foreach ($versions as $version) {
                 $entryId = $version['entryId'];
                 $locale = $version['locale'];
                 if (!isset($versionCountsByEntryIdAndLocale[$entryId][$locale])) {
                     $versionCountsByEntryIdAndLocale[$entryId][$locale] = 1;
                 } else {
                     $versionCountsByEntryIdAndLocale[$entryId][$locale]++;
                 }
                 $this->update('entryversions', array('num' => $versionCountsByEntryIdAndLocale[$entryId][$locale]), array('id' => $version['id']));
             }
             $offset += 100;
         } while (count($versions) == 100);
         // Set the `num` column to NOT NULL
         $columnConfig['null'] = false;
         $this->alterColumn('entryversions', 'num', $columnConfig);
     }
     return true;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:34,代码来源:m140603_000002_version_nums.php

示例14: locateEntry

 /**
  * Given a path, look for an obsolete URL from the revisions
  *
  * @return EntryModel or null
  */
 public function locateEntry($path)
 {
     $slug = array_pop($path);
     $prefix = join("/", $path);
     // Check that there's even a slug to work with
     if ($slug === '') {
         return false;
     }
     // Element conditions
     $element_conditions = array('and', 'elements_i18n.enabled = 1', 'elements.enabled = 1', 'elements.archived = 0');
     // Slug conditions
     $slug_conditions = array('like', 'entryversions.data', '%"slug":"' . $slug . '"%');
     // Query for (or against) a path prefix
     if (empty($prefix)) {
         // Ensure the prefixed segments do NOT exist in the URI
         $path_conditions = array('not like', 'elements_i18n.uri', '%/%');
     } else {
         // Ensure the prefixed segments DO exist in the URI
         $path_conditions = array('like', 'elements_i18n.uri', $prefix . '/%');
     }
     // Query for matching revisions
     $query = craft()->db->createCommand()->select('elements.id')->from('elements elements')->join('elements_i18n elements_i18n', 'elements_i18n.elementId = elements.id')->join('entryversions entryversions', 'entryversions.entryId = elements.id')->where($element_conditions)->andWhere($slug_conditions)->andWhere($path_conditions)->order('entryversions.dateUpdated DESC')->limit(1);
     // ObsoleteRedirectPlugin::log($query->text);
     $result = $query->queryRow();
     if ($result) {
         // Get the element's EntryModel
         $criteria = craft()->elements->getCriteria(ElementType::Entry);
         $criteria->id = $result['id'];
         // Return the actual element
         return $criteria->first();
     }
 }
开发者ID:webremote,项目名称:craft-obsolete-url-redirect,代码行数:37,代码来源:ObsoleteRedirectService.php

示例15: safeUp

 public function safeUp()
 {
     $tableName = 'plainform_entries';
     if (!craft()->db->columnExists($tableName, 'ip')) {
         $this->addColumn($tableName, 'ip', array('column' => ColumnType::Varchar, 'null' => true, 'default' => null));
     }
 }
开发者ID:plainlanguage,项目名称:Craft-PlainForm,代码行数:7,代码来源:m151207_000000_plainForm_add_ip_column.php


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