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


PHP JFactory::getdate方法代码示例

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


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

示例1: getItem

 /**
  * Method to get a single record.
  *
  * @param   integer  $pk  The id of the primary key.
  *
  * @return  mixed    Object on success, false on failure.
  *
  * @since    1.6
  */
 public function getItem($pk = null)
 {
     //error_log("In Model::getItem PK = "  . $pk );
     if ($item = parent::getItem($pk)) {
         // Do any procesing on fields here if needed
         //error_log("Mode::getItem --> " . print_r($item,true));
         //error_log("Item ID is --> " . $item->id);
         $isNew = $item->id ? false : true;
         // ingredients not stored as json
         // if ( is_string($item->ingredients_list)) {
         // 	$ingredients_list_string = $item->ingredients_list;
         // 	$item->ingredients_list = json_decode($ingredients_list_string,true);
         // }
         if (!empty($item->social_media_image)) {
             $social_media_images = json_decode($item->social_media_image, true);
             $item->facebook_image = $social_media_images['facebook_image'];
             $item->twitter_image = $social_media_images['twitter_image'];
             $item->pinterest_image = $social_media_images['pinterest_image'];
         }
         //error_log("In Model::getItem created == " . $item->created);
         //if ( $item->created == null || strlen($item->created) == 0 || $item->created == '' ) {
         if ($isNew) {
             $config = JFactory::getConfig();
             $tzoffset = $config->get('offset');
             //error_log("tzoffset --> " . $tzoffset);
             $datenow = JFactory::getdate('now', $tzoffset);
             //$datenow = JFactory::getdate();
             //error_log("Date Now --> " . print_r($datenow,true));
             $date = JFactory::getdate('now', $tzoffset);
             $item->created = $datenow->toSql();
             $item->publish_up = $datenow->toSql();
         } else {
             $item->modified_by = JFactory::getUser()->id;
             $config = JFactory::getConfig();
             $tzoffset = $config->get('offset');
             //error_log("tzoffset --> " . $tzoffset);
             $datenow = JFactory::getdate('now', $tzoffset);
             $item->modified = $datenow->toSql();
             //get the tags
             $item->tags = new JHelperTags();
             $item->tags->getTagIds($item->id, 'com_akrecipes.recipe');
         }
         if (!$isNew && is_string($item->ingredients_list)) {
             $ingredients = array();
             $ingredients_list = explode("\n", $item->ingredients_list);
             foreach ($ingredients_list as $key => $ingredient) {
                 $ingredient = trim($ingredient);
                 if (trim($ingredient) != '<p>&nbsp;</p>' && !empty($ingredient)) {
                     $ingredients[] = trim(strip_tags($ingredient));
                 }
             }
             $item->ingredients = $ingredients;
         }
         if (!$isNew) {
             $db = JFactory::getDbo();
             $query = $db->getQuery(true);
             $query->select('DISTINCT a.*');
             $query->from('`#__akrecipes_recipe_ingredients` as a');
             $query->select('ing.name as ingredient_name');
             $query->join('LEFT', '#__akrecipes_ingredient AS ing ON ing.id = a.ingredients_id');
             $query->where('a.recipe_id = ' . $item->id);
             $query->order(' a.sequence_no asc ');
             $db->setQuery($query);
             $result = $db->loadObjectList();
             //error_log("Query for ingredient_table -> " . $query->__toString());
             if ($result) {
                 //$item->ingredient_table = $result ;
                 $item->qty = array();
                 $item->unit = array();
                 $item->ingredient = array();
                 $item->ingredient_description = array();
                 foreach ($result as $key => $row) {
                     $item->qty[] = $row->qty;
                     $item->unit[] = $row->unit;
                     $item->ingredient[] = $row->ingredient_name;
                     $item->ingredient_description[] = $row->ingredient_description;
                 }
             }
         }
     }
     return $item;
 }
开发者ID:rutvikd,项目名称:ak-recipes,代码行数:91,代码来源:recipe.php

示例2: save

 /**
  * Method to save the form data.
  *
  * @param   array  $data  The form data
  *
  * @return bool
  *
  * @throws Exception
  * @since 1.6
  */
 public function save($data)
 {
     //error_log("IN recipeform::save data == " . print_r($data,true) )	;
     $app = JFactory::getApplication('com_akrecipes');
     $params = $app->getParams();
     $id = !empty($data['id']) ? $data['id'] : (int) $this->getState('recipe.id');
     $state = !empty($data['state']) ? 1 : 0;
     $user = JFactory::getUser();
     $isNew = $id ? false : true;
     /*
     if ($isNew) {
     	error_log("Is New Recipe --> " . $id);	
     } else {
     	error_log("NOT a new Recipe --> " . $id);
     }
     */
     if ($id) {
         // Check the user can edit this item
         $authorised = $user->authorise('core.edit', 'com_akrecipes') || ($authorised = $user->authorise('core.edit.own', 'com_akrecipes'));
         if ($user->authorise('core.edit.state', 'com_akrecipes') !== true && $state == 1) {
             // The user cannot edit the state of the item.
             $data['state'] = 0;
         }
     } else {
         // Check the user can create new items in this section
         $authorised = $user->authorise('core.create', 'com_akrecipes');
         if ($user->authorise('core.edit.state', 'com_akrecipes') !== true && $state == 1) {
             // The user cannot edit the state of the item.
             $data['state'] = 0;
         }
     }
     if ($authorised !== true) {
         throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403);
     }
     //error_log("ingredients_list --> " . print_r($data['ingredients_list'],true));
     $table = $this->getTable();
     $imagesavepath = $this->saveImage($data);
     if ($imagesavepath == false) {
         $this->setError("Failed to process image. Try changing the image or reducing its size and try again.");
         return false;
     }
     if (!empty($imagesavepath)) {
         $data['image'] = $imagesavepath;
     }
     if ($isNew) {
         $config = JFactory::getConfig();
         $tzoffset = $config->get('offset');
         $datenow = JFactory::getdate('now', $tzoffset);
         $date = JFactory::getdate('now', $tzoffset);
         $data['created'] = $datenow->toSql();
         $data['publish_up'] = $datenow->toSql();
         if (isset($data['contest_id']) && is_array($data['contest_id'])) {
             $data['contest_id'] = $data['contest_id'][0];
         }
     } else {
         $data['modified_by'] = JFactory::getUser()->id;
         $config = JFactory::getConfig();
         $tzoffset = $config->get('offset');
         $datenow = JFactory::getdate('now', $tzoffset);
         $data['modified'] = $datenow->toSql();
     }
     if ($table->save($data) === true) {
         error_log("Saveing new recipe -> data = " . print_r($data, true));
         if ($params->get('recipeform_sendconfirmationemail', 1) == 1) {
             $this->sendEmail($data, $params);
         }
         return $table->id;
     } else {
         return false;
     }
 }
开发者ID:rutvikd,项目名称:ak-recipes,代码行数:81,代码来源:recipeform.php

示例3: rate

 public function rate()
 {
     // Initialise variables.
     $app = JFactory::getApplication();
     // Checking if the user can remove object
     $user = JFactory::getUser();
     // Get the user data.
     $id = $app->input->getInt('id', 0);
     $rating = $app->input->getInt('rating', 0);
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_akrecipes/tables');
     $stats_table = JTable::getInstance("Rating", "AkrecipesTable", array());
     $stats_table->load(array('content_id' => $id));
     $row = $stats_table->getProperties();
     //if the row does not exist, update the content_id column
     if (!$stats_table->id || $stats_table->content_id == 0) {
         $row['content_id'] = $id;
     }
     $row['lastip'] = $ip = empty($_SERVER['REMOTE_ADDR']) ? 'N/A' : $_SERVER['REMOTE_ADDR'];
     $row['rating_sum'] = $row['rating_sum'] + $rating;
     $row['rating_count']++;
     $config = JFactory::getConfig();
     $tzoffset = $config->get('offset');
     //error_log("tzoffset --> " . $tzoffset);
     $datenow = JFactory::getdate('now', $tzoffset);
     $row['last_updated'] = $datenow->toSql();
     $retVal = new stdClass();
     if ($stats_table->save($row)) {
         $retVal->success = true;
         $retVal->rating_sum = $row['rating_sum'];
         $retVal->rating_count = $row['rating_count'];
         $retVal->message = 'Rating successful';
     } else {
         $retVal->success = false;
         $retVal->message = 'Rating successful';
     }
     echo json_encode($retVal);
     $app->close();
     return;
 }
开发者ID:rutvikd,项目名称:ak-recipes,代码行数:39,代码来源:recipe.php

示例4: addDefaultRating

 protected function addDefaultRating($recipe_id)
 {
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_akrecipes/tables');
     $stats_table = JTable::getInstance("Rating", "AkrecipesTable", array());
     $stats_table->load(array('content_id' => $recipe_id));
     $row = $stats_table->getProperties();
     //error_log("Default rating row = " . print_r($row,true));
     //if the row does not exist, update the content_id column
     if (!$stats_table->id || $stats_table->content_id == 0) {
         $row['content_id'] = $recipe_id;
         $row['lastip'] = empty($_SERVER['REMOTE_ADDR']) ? 'N/A' : $_SERVER['REMOTE_ADDR'];
         $row['rating_sum'] = 5;
         $row['rating_count'] = 1;
         $config = JFactory::getConfig();
         $tzoffset = $config->get('offset');
         //error_log("tzoffset --> " . $tzoffset);
         $datenow = JFactory::getdate('now', $tzoffset);
         $row['last_updated'] = $datenow->toSql();
         $retval = $stats_table->save($row);
         // error_log("Saved rating row : " . print_r($row,true));
         // error_log("Saved rating retval : " . print_r($retval,true));
         // 		} else {
         // error_log("Not saving : " .$recipe_id );
     }
 }
开发者ID:rutvikd,项目名称:ak-recipes,代码行数:25,代码来源:recipe.php

示例5: hit

 public function hit($pk = null)
 {
     if (is_null($pk)) {
         $pk = array();
         foreach ($this->_tbl_keys as $key) {
             $pk[$key] = $this->{$key};
         }
     } elseif (!is_array($pk)) {
         $pk = array($this->_tbl_key => $pk);
     }
     foreach ($this->_tbl_keys as $key) {
         $pk[$key] = is_null($pk[$key]) ? $this->{$key} : $pk[$key];
         if ($pk[$key] === null) {
             throw new UnexpectedValueException('Null primary key not allowed.');
         }
     }
     $config = JFactory::getConfig();
     $tzoffset = $config->get('offset');
     $datenow = JFactory::getdate('now', $tzoffset);
     $raw_stats = $this->raw_stats;
     $date = $datenow->format('Y-m-d');
     if ($raw_stats) {
         $raw_stats = unserialize($raw_stats);
     } else {
         $raw_stats = array();
     }
     $count_1 = $this->_calculate_1_day_stats($raw_stats, $date);
     $count_7 = $this->_calculate_days_stats(7, $raw_stats, $date);
     $count_30 = $this->_calculate_days_stats(30, $raw_stats, $date);
     if (isset($raw_stats) && count($raw_stats) >= 30) {
         array_shift($raw_stats);
         $raw_stats[$date] = 1;
     } else {
         if (!isset($raw_stats[$date])) {
             $raw_stats[$date] = 1;
         } else {
             $raw_stats[$date]++;
         }
     }
     $last_updated = $datenow->toSql();
     $update_fields = array($this->_db->quoteName($this->getColumnAlias('all_time_stats')) . ' = (' . $this->_db->quoteName($this->getColumnAlias('all_time_stats')) . ' + 1)', $this->_db->quoteName($this->getColumnAlias('last_updated')) . ' = ' . $this->_db->quote($last_updated), $this->_db->quoteName($this->getColumnAlias('1_day_stats')) . ' = ' . $count_1, $this->_db->quoteName($this->getColumnAlias('7_day_stats')) . ' = ' . $count_7, $this->_db->quoteName($this->getColumnAlias('30_day_stats')) . ' = ' . $count_30, $this->_db->quoteName($this->getColumnAlias('raw_stats')) . ' = ' . $this->_db->quote(serialize($raw_stats)));
     // Check the row in by primary key.
     $query = $this->_db->getQuery(true)->update($this->_tbl)->set($update_fields);
     $this->appendPrimaryKeys($query, $pk);
     $this->_db->setQuery($query);
     $this->_db->execute();
     // Set table values in the object.
     $this->all_time_stats++;
     return true;
 }
开发者ID:rutvikd,项目名称:ak-recipes,代码行数:50,代码来源:stats.php

示例6: array_reverse

$listDirn = $this->escape($this->state->get('list.direction'));
?>


			<?php 
if ($listDirn == 'asc') {
    $this->items[$this->i] = array_reverse($this->items[$this->i]);
}
foreach ($this->items[$this->i] as $i => $item) {
    echo ' ';
    ?>
				
				<div class="well span2">
					<div class="nowrap">
						<?php 
    echo JFactory::getdate($this->escape($item->tdate))->format('Y-m-d');
    ?>
					</div>
					<div class="">
						<?php 
    $ext = strtolower(JFile::getExt($item->filename));
    $mediapath = '/media/com_htraininglogs/images/';
    $target = ' target="_blank" ';
    switch ($ext) {
        case 'pdf':
            $mediafilethumb = $mediapath . 'pdf.png';
            break;
        case 'doc':
        case 'docx':
            $mediafilethumb = $mediapath . 'doc.png';
            break;
开发者ID:hogeh,项目名称:htraininglogs2,代码行数:31,代码来源:default_mediapreview.php


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