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


PHP JError::raise方法代码示例

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


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

示例1: save

 function save()
 {
     $data = JRequest::getVar('jform', array(), 'post', 'NONE', 4);
     $id = (int) $data['id'];
     if (empty($id)) {
         if (!igGeneralHelper::authorise('core.igalleryfront.create')) {
             return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
         }
     } else {
         if (!igGeneralHelper::authorise('core.igalleryfront.edit', $id)) {
             return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
         }
     }
     $model = $this->getModel();
     $msg = '';
     if (!$model->save($data)) {
         JError::raise(2, 500, $model->getError());
     } else {
         $msg = JText::_('SUCCESSFULLY_SAVED');
     }
     switch ($this->task) {
         case 'apply':
             $url = 'index.php?option=com_igallery&view=icategory&id=' . $id;
             break;
         case 'save':
             $url = 'index.php?option=com_igallery&view=categories';
     }
     $this->setRedirect(JRoute::_($url, false), $msg);
 }
开发者ID:iFactoryDigital,项目名称:gympieradiology,代码行数:29,代码来源:icategory.php

示例2: edit

 public function edit()
 {
     $input = JFactory::getApplication()->input;
     $id = $input->getInt('id');
     $refid = $input->get('refid');
     $adapter = JalangHelper::getHelperContent();
     if ($adapter) {
         $linkEdit = $adapter->getEditLink($id);
         if (!$linkEdit) {
             JError::raise(E_WARNING, 300, $adapter->getError());
             $this->setRedirect(JRoute::_('index.php?option=com_jalang&view=items', false));
             return false;
         }
         /*$return = JRoute::_('index.php?option=com_jalang&view=items', false);
         		$return = urlencode(base64_encode($return));*/
         $linkEdit = JRoute::_($linkEdit . '&jaref=' . $adapter->table . '.' . $refid, false);
         if ($adapter->edit_context) {
             $app = JFactory::getApplication();
             $this->holdEditId($adapter->edit_context, $id);
             $app->setUserState($adapter->edit_context . '.data', null);
         }
         $this->setRedirect($linkEdit);
     } else {
         JError::raise(E_ERROR, 500, JText::_('INVALID_REQUEST'));
     }
 }
开发者ID:thumbs-up-sign,项目名称:TuVanDuAn,代码行数:26,代码来源:item.php

示例3: setlanguage

	/**
	 * Method to set the setup language for the application.
	 *
	 * @return	void
	 * @since	1.6
	 */
	public function setlanguage()
	{
		// Get the application object.
		$app = JFactory::getApplication();

		// Check for potentially unwritable session
		$session = JFactory::getSession();

		if ($session->isNew()) {
			JError::setErrorHandling(E_ERROR, 'message');
			JError::raise(E_ERROR, 500, JText::_('INSTL_COOKIES_NOT_ENABLED'));

			return false;
		}

		// Check for request forgeries.
		JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN'));

		// Get the setup model.
		$model = $this->getModel('Setup', 'JInstallationModel', array('dbo' => null));

		// Get the posted values from the request and validate them.
		$data = JRequest::getVar('jform', array(), 'post', 'array');
		$return	= $model->validate($data, 'language');

		// Check for validation errors.
		if ($return === false) {

			// Get the validation messages.
			$errors	= $model->getErrors();

			// Push up to three validation messages out to the user.
			for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++)
			{
				if (JError::isError($errors[$i])) {
					$app->enqueueMessage($errors[$i]->getMessage(), 'warning');
				} else {
					$app->enqueueMessage($errors[$i], 'warning');
				}
			}

			// Redirect back to the language selection screen.
			$this->setRedirect('index.php?view=language');
			return false;
		}

		// Store the options in the session.
		$vars = $model->storeOptions($return);

		// Redirect to the next page.
		$this->setRedirect('index.php?view=preinstall');
	}
开发者ID:realityking,项目名称:JAJAX,代码行数:58,代码来源:setup.php

示例4: reportImage

 function reportImage()
 {
     $model = $this->getModel();
     $msg = '';
     if (!$model->reportImage()) {
         JError::raise(2, 500, $model->getError());
         return false;
     } else {
         $msg = JText::_('YOUR_MESSAGE_SENT');
         $session = JFactory::getSession();
         $url = $session->get('ig_report_url', JURI::root()) . '#!' . $model->urlHash;
         $this->setRedirect($url, $msg);
     }
 }
开发者ID:iFactoryDigital,项目名称:gympieradiology,代码行数:14,代码来源:imagefront.php

示例5: display

 /**
  * Displays the form
  *
  * @param   string  $tpl  - The templates
  *
  * @return  mixed|void
  */
 public function display($tpl = null)
 {
     $orga_id = JFactory::getApplication()->input->get('id', 0);
     $model = $this->getModel();
     $params = JComponentHelper::getParams('com_matukio');
     $menuitemid = JFactory::getApplication()->input->get('Itemid');
     if ($menuitemid) {
         $site = new JSite();
         $menu = $site->getMenu();
         $menuparams = $menu->getParams($menuitemid);
         $params->merge($menuparams);
     }
     if (empty($orga_id)) {
         $orga_id = $params->get('organizerId', 0);
     }
     // Raise error
     if (empty($orga_id)) {
         JError::raise(E_ERROR, 403, JText::_("COM_MATUKIO_NO_ID"));
     }
     $organizer = $model->getOrganizer($orga_id);
     if (!empty($organizer)) {
         // Get the Joomla user obj
         $organizer_user = JFactory::getUser($organizer->userId);
     } else {
         $organizer_user = null;
     }
     $ue_title = $params->get('title', '');
     if (empty($ue_title)) {
         // Set the title to the name
         $ue_title = $organizer->name;
     }
     $title = JFactory::getDocument()->getTitle();
     JFactory::getDocument()->setTitle($title . " - " . JText::_($organizer->name));
     // Plugin support
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('content');
     $this->jevent = new stdClass();
     $results = $dispatcher->trigger('onContentAfterDisplay', array('com_matukio.organizer', &$organizer, &$params, 0));
     $this->jevent->afterDisplayContent = trim(implode("\n", $results));
     $this->organizer = $organizer;
     $this->organizer_user = $organizer_user;
     $this->title = $ue_title;
     $this->user = JFactory::getUser();
     // Upcoming events since 3.1
     if (MatukioHelperSettings::getSettings("organizer_show_upcoming", 1) && !empty($organizer_user)) {
         $this->upcoming_events = $model->getUpcomingEvents($organizer_user->id);
     }
     parent::display($tpl);
 }
开发者ID:JonatanLiecheski,项目名称:MeditecJoomla,代码行数:56,代码来源:view.html.php

示例6: applyJob

 function applyJob($options)
 {
     $query = "Insert into candidate (candidate_id,site_id,last_name,first_name,phone_home,phone_cell,phone_work,address,city,state,zip,key_skills,entered_by,owner,date_created,email1,best_time_to_call) values (NULL,'1','" . $options['lastname'] . "','" . $options['firstname'] . "','" . $options['homephone'] . "','" . $options['mobilephone'] . "','" . $options['workphone'] . "','" . $options['mailingaddress'] . "','" . $options['city'] . "','" . $options['state'] . "','" . $options['zip'] . "','" . $options['skill'] . "','" . $user->id . "','" . $user->id . "','" . date('Y-m-d H:i:s') . "','" . $options['email_address'] . "','" . $options['besttimetocall'] . "')";
     $this->CatsDb->setQuery($query);
     $this->CatsDb->query();
     $id = $this->CatsDb->insertID();
     $query1 = "Insert into candidate_joborder (candidate_joborder_id,candidate_id,joborder_id,site_id,status,date_submitted,date_created,rating_value) values (NULL,'" . $id . "','" . $options['joborder_id'] . "','1','100','" . date('Y-m-d H:i:s') . "','" . date('Y-m-d H:i:s') . "','-1')";
     $this->CatsDb->setQuery($query1);
     $this->CatsDb->query();
     include_once JPATH_COMPONENT . DS . 'lib' . DS . 'Attachments.php';
     $attachmentCreator = new AttachmentCreator(1, $this->CatsDb);
     if (!$attachmentCreator->createFromUpload('100', $id, 'cv', false, 1)) {
         jimport('joomla.error.error');
         JError::raise(E_WARNING, 500, 'Problem uploading attachment<br>' . $attachmentCreator->getError(), $attachmentCreator->getError());
     }
     //Inset vao bang activity
     $this->CatsDb->setQuery("Insert into activity (activity_id,data_item_id,data_item_type,joborder_id,site_id,entered_by,date_created,type,notes,date_modified) values (NULL,'" . $id . "','100','" . $options['joborder_id'] . "','1','1250','" . date('Y-m-d H:i:s') . "','400','User applied through candidate portal','" . date('Y-m-d H:i:s') . "')");
     $this->CatsDb->query();
     //Send mail to the manager job is to inform new people apply
     //fetch recruiter
     $this->CatsDb->setQuery("Select recruiter,title from joborder where joborder_id = '" . $options['joborder_id'] . "'");
     $r = $this->CatsDb->loadObjectList();
     $r = $r[0];
     $this->CatsDb->setQuery("Select * from user where user_id = '" . $r->recruiter . "'");
     $userRow = $this->CatsDb->loadObjectList();
     $userRow = $userRow[0];
     $htmlMessage = "<html><head><title>Recruiter Notification</title></head><body>";
     $htmlMessage .= "<table cellpadding=0 cellspacing=0 width=100% style='border:1px solid #cccccc;padding:20px;'>";
     $htmlMessage .= "<tr><td width=100%>";
     $htmlMessage .= "<b>Dear " . $userRow->last_name . "</b>";
     $htmlMessage .= "<br>This e-mail is a confirmation that new candidates have applied to your vacancy through our online recruitment system ..";
     $htmlMessage .= "<br><Br><b>Vacancy name:</b>&nbsp;" . $r->title;
     $htmlMessage .= "<br><b>Applicant Name :&nbsp;</b>" . $options['firstname'] . " " . $options['lastname'] . ".";
     $htmlMessage .= "<br><b>Candidate URL :&nbsp;</b> <a href='" . $this->Cats_install . "index.php?m=candidates&a=show&candidateID=" . $id . "'>" . $this->Cats_install . "index.php?m=candidates&a=show&candidateID=" . $id . "</a>.";
     $htmlMessage .= "<br><b>Job Order URL :&nbsp;</b> <a href='" . $this->Cats_install . "index.php?m=joborders&a=show&jobOrderID=" . $options['joborder_id'] . "'>" . $this->Cats_install . "index.php?m=joborders&a=show&jobOrderID=" . $options['joborder_id'] . "</a>.";
     $htmlMessage .= "<br><br>Administrator<br>Recruiter notification.";
     $htmlMessage .= "</td></tr></table></body></html>";
     //Gui mail
     JUtility::sendMail($this->email, 'Recruiter notification', $userRow->email, 'Administrator - Candidate applied to an OpenCATS vacancy.', $htmlMessage, 1);
     $this->CatsDb->setQuery("Select questionnaire_id from joborder where joborder_id = '" . $options['joborder_id'] . "'");
     $question = $this->CatsDb->loadResult();
     $q['question'] = $question;
     $q['id'] = $id;
     return $q;
 }
开发者ID:HTApplications,项目名称:OpenCATS,代码行数:45,代码来源:apply.php

示例7: remove

 function remove()
 {
     if (!igGeneralHelper::authorise('core.admin')) {
         return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     if (!igGeneralHelper::authorise('core.delete')) {
         return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     $model = $this->getModel();
     if (!$model->checkAssigned()) {
         $this->setRedirect('index.php?option=com_igallery&view=profiles');
         return;
     }
     if (!$model->delete()) {
         $msg = '';
         JError::raise(2, 500, $model->getError());
     } else {
         $msg = JText::_('SUCCESSFULLY_SAVED');
     }
     $this->setRedirect('index.php?option=com_igallery&view=profiles', $msg);
 }
开发者ID:iFactoryDigital,项目名称:gympieradiology,代码行数:21,代码来源:profile.php

示例8: display


//.........这里部分代码省略.........
                 $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
                 $document->addHeadLink(JRoute::_($link . '&type=rss', FALSE), 'alternate', 'rel', $attribs);
                 $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
                 $document->addHeadLink(JRoute::_($link . '&type=atom', FALSE), 'alternate', 'rel', $attribs);
             }
             $user = JFactory::getUser();
             $this->showBasePrice = (vmAccess::manager() or vmAccess::isSuperVendor());
         }
         //No redirect here, for category id = 0 means show ALL categories! note by Max Milbers
         if (!empty($this->categoryId) and $this->categoryId !== -1 and (empty($category->slug) or !$category->published)) {
             if (empty($category->slug)) {
                 vmInfo(vmText::_('COM_VIRTUEMART_CAT_NOT_FOUND'));
             } else {
                 if ($category->virtuemart_id !== 0 and !$category->published) {
                     vmInfo('COM_VIRTUEMART_CAT_NOT_PUBL', $category->category_name, $this->categoryId);
                 }
             }
             //Fallback
             $categoryLink = '';
             if ($category->category_parent_id) {
                 $categoryLink = '&view=category&virtuemart_category_id=' . $category->category_parent_id;
             } else {
                 $last_category_id = shopFunctionsF::getLastVisitedCategoryId();
                 if (!$last_category_id or $this->categoryId == $last_category_id) {
                     $last_category_id = vRequest::getInt('virtuemart_category_id', false);
                 }
                 if ($last_category_id and $this->categoryId != $last_category_id) {
                     $categoryLink = '&view=category&virtuemart_category_id=' . $last_category_id;
                 }
             }
             if (VmConfig::get('handle_404', 1)) {
                 $app->redirect(JRoute::_('index.php?option=com_virtuemart' . $categoryLink . '&error=404', FALSE));
             } else {
                 JError::raise(E_ERROR, '404', 'Not found');
             }
             return;
         }
         shopFunctionsF::setLastVisitedCategoryId($this->categoryId);
         shopFunctionsF::setLastVisitedManuId($virtuemart_manufacturer_id);
         // Add the category name to the pathway
         if ($category->parents) {
             foreach ($category->parents as $c) {
                 $pathway->addItem(strip_tags(vmText::_($c->category_name)), JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $c->virtuemart_category_id, FALSE));
             }
         }
         $catImgAmount = VmConfig::get('catimg_browse', 1);
         $categoryModel->addImages($category, $catImgAmount);
         if (!isset($menu->query['showcategory'])) {
             $menu->query['showcategory'] = 1;
         }
         $this->showcategory = vRequest::getInt('showcategory', $menu->query['showcategory']);
         //$this->showcategory = vRequest::getInt('showcategory',true);
         if ($this->showcategory) {
             //if($category->category_layout == 'categories' or ($this->categoryId >0 and $virtuemart_manufacturer_id <1)){
             $category->children = $categoryModel->getChildCategoryList($vendorId, $this->categoryId, $categoryModel->getDefaultOrdering(), $categoryModel->_selectedOrderingDir);
             $categoryModel->addImages($category->children, $catImgAmount);
         } else {
             $category->children = false;
         }
         if (VmConfig::get('enable_content_plugin', 0)) {
             shopFunctionsF::triggerContentPlugin($category, 'category', 'category_description');
         }
         $metadesc = '';
         $metakey = '';
         $metarobot = '';
         if (isset($menu->params)) {
开发者ID:virtuemart-fr,项目名称:virtuemart-fr,代码行数:67,代码来源:view.html.php

示例9: assign

 /**
  * Method to store item(s)
  *
  * @access  public
  *
  * @param array the project round ids to copy
  * @param int   the destination project id
  *
  * @return  boolean True on success
  * @since   1.5
  */
 public function assign($cids, $project_id)
 {
     $row = $this->getTable();
     $i = 0;
     for ($i = 0, $n = count($cids); $i < $n; $i++) {
         $cid =& $cids[$i];
         $query = 'SELECT *' . ' FROM #__tracks_projects_rounds ' . ' WHERE id = ' . intval($cid);
         $this->_db->setQuery($query);
         $round = $this->_db->loadObject();
         if (!$round) {
             JError::raise(500, 'Round not found. ' . $this->_db->getErrorMsg());
         }
         if (!$round) {
             // not found...
             break;
         }
         $row->reset();
         $row->bind($round);
         $row->id = null;
         $row->project_id = $project_id;
         $row->checked_out = 0;
         $row->checked_out_time = null;
         // Store the item to the database
         if (!$row->store()) {
             $this->setError($this->_db->getErrorMsg());
             JError::raise(500, 'Failed to copy round. ' . $this->_db->getErrorMsg());
         }
         // now copy subrounds
         $query = ' SELECT * ' . ' FROM #__tracks_projects_subrounds' . ' WHERE projectround_id = ' . $cid;
         $this->_db->setQuery($query);
         $subrounds = $this->_db->loadObjectList();
         if (is_array($subrounds)) {
             $subround = $this->getTable('Subround');
             foreach ($subrounds as $s) {
                 $subround->reset();
                 $subround->bind($s);
                 $subround->id = null;
                 $subround->projectround_id = $row->id;
                 $subround->checked_out = 0;
                 $subround->checked_out_time = null;
                 if (!$subround->store()) {
                     $this->setError($this->_db->getErrorMsg());
                     JError::raise(500, 'Failed to copy subround. ' . $this->_db->getErrorMsg());
                 }
             }
         }
     }
     return true;
 }
开发者ID:julienV,项目名称:Joomla-Tracks,代码行数:60,代码来源:projectrounds.php

示例10: customErrorHandler

 /**
  * Display a message to the user
  *
  * @param   integer  $level  The error level - use any of PHP's own error levels
  *                   for this: E_ERROR, E_WARNING, E_NOTICE, E_USER_ERROR,
  *                   E_USER_WARNING, E_USER_NOTICE.
  * @param   string   $msg    Error message, shown to user if need be.
  *
  * @return  void
  *
  * @deprecated  12.1
  * @since   11.1
  */
 public static function customErrorHandler($level, $msg)
 {
     // Deprecation warning.
     JLog::add('JError::customErrorHandler() is deprecated.', JLog::WARNING, 'deprecated');
     JError::raise($level, '', $msg);
 }
开发者ID:NavaINT1876,项目名称:ccustoms,代码行数:19,代码来源:error.php

示例11: save

 function save($data)
 {
     $db = $this->getDbo();
     $row = $this->getTable('igallery_img');
     if (!$row->bind($data)) {
         $this->setError($db->getErrorMsg());
         return false;
     }
     if (strpos($row->description, 'class="des_div"') > 0) {
         JError::raise(2, 500, 'Error: Html formatting has been copied from the gallery frontend into the description, please paste plain text');
     }
     $row->alt_text = htmlspecialchars($row->alt_text, ENT_QUOTES);
     $raw = JRequest::getVar('jform', array(), 'post', 'NONE', JREQUEST_ALLOWRAW);
     $row->description = JComponentHelper::filterText($raw['description']);
     if (!$row->store()) {
         $this->setError($db->getErrorMsg());
         return false;
     }
     if (JFactory::getApplication()->isSite()) {
         $data = JRequest::getVar('jform', array(), 'post', 'NONE', 4);
         $id = (int) $data['id'];
     } else {
         $id = JRequest::getInt('id', 0);
     }
     $query = 'SELECT gallery_id, ordering from #__igallery_img WHERE id = ' . (int) $id;
     $db->setQuery($query);
     $currentRow = $db->loadObject();
     $nextOrdering = $currentRow->ordering + 1;
     $query = 'SELECT id from #__igallery_img WHERE gallery_id = ' . (int) $currentRow->gallery_id . ' AND ordering = ' . (int) $nextOrdering . ' LIMIT 1';
     $db->setQuery($query);
     $nextRow = $db->loadObject();
     return $nextRow->id;
 }
开发者ID:iFactoryDigital,项目名称:gympieradiology,代码行数:33,代码来源:image.php

示例12: customErrorHandler

 /**
  * Display a custom error page and exit gracefully
  *
  * @param   integer   $level The error level - use any of PHP's own error levels for this: E_ERROR, E_WARNING, E_NOTICE, E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE.
  * @param   string    $msg   Error message, shown to user if need be.
  *
  * @return  void
  *
  * @deprecated
  * @since   11.1
  */
 public static function customErrorHandler($level, $msg)
 {
     JError::raise($level, '', $msg);
 }
开发者ID:carmerin,项目名称:cesae-web,代码行数:15,代码来源:error.php

示例13: defined

defined('_JEXEC') or die('Restricted Access');

// Check for PHP4
if(defined('PHP_VERSION')) {
	$version = PHP_VERSION;
} elseif(function_exists('phpversion')) {
	$version = phpversion();
} else {
	// No version info. I'll lie and hope for the best.
	$version = '5.0.0';
}

// Old PHP version detected. EJECT! EJECT! EJECT!
if(!version_compare($version, '5.2.0', '>='))
{
	return JError::raise(E_ERROR, 500, 'PHP 4.x, 5.0 and 5.1 is no longer supported by Akeeba Backup.','The version of PHP used on your site is obsolete and contains known security vulenrabilities. Moreover, it is missing features required by Akeeba Backup to work properly or at all. Please ask your host to upgrade your server to the latest PHP 5.2 or 5.3 release. Thank you!');
}

// Timezone fix; avoids errors printed out by PHP 5.3.3+ (thanks Yannick!)
if(function_exists('date_default_timezone_get') && function_exists('date_default_timezone_set')) {
	if(function_exists('error_reporting')) {
		$oldLevel = error_reporting(0);
	}
	$serverTimezone = @date_default_timezone_get();
	if(empty($serverTimezone) || !is_string($serverTimezone)) $serverTimezone = 'UTC';
	if(function_exists('error_reporting')) {
		error_reporting($oldLevel);
	}
	@date_default_timezone_set( $serverTimezone);
}
开发者ID:rkern21,项目名称:videoeditor,代码行数:30,代码来源:akeeba.php

示例14: defined

 * @copyright   Copyright (C) 2010 - 2011 ThemeXpert
 * @license     http://www.gnu.org/licenses/gpl-3.0.html GNU/GPLv3
 **/
// Protect from unauthorized access
defined('_JEXEC') or die('Restricted Access');
// Check for PHP4
if (defined('PHP_VERSION')) {
    $version = PHP_VERSION;
} elseif (function_exists('phpversion')) {
    $version = phpversion();
} else {
    $version = '5.0.0';
}
// if older version detect, raise an error
if (!version_compare($version, '5.0.0', '>=')) {
    return JError::raise(E_ERROR, 500, 'PHP 4 is not supported by Expose Framework');
}
if (!defined('EXPOSE_VERSION')) {
    // Define framework version.
    define('EXPOSE_VERSION', '4.2.3');
    //define directory separator
    defined('DS') or define('DS', '/');
    if (version_compare(JVERSION, '2.5', 'ge') && version_compare(JVERSION, '3.0', 'lt')) {
        define('EXPOSE_JVERSION', '25');
    } else {
        define('EXPOSE_JVERSION', '30');
    }
    //declare global ver
    global $expose;
    expose_import('core.core');
    $expose = ExposeCore::getInstance();
开发者ID:pguilford,项目名称:vcomcc,代码行数:31,代码来源:expose.php

示例15: saveCategoryImage

 public function saveCategoryImage($pk, $table, &$data)
 {
     $app = JFactory::getApplication();
     $jInput = $app->input;
     if ($pk > 0) {
         if ($jInput->post->getInt('remove_jform_images_intro_image', 0) == 1 || $jInput->post->getInt('remove_jform_images_detail_image', 0) == 1 && $jInput->post->getInt('use_detail_image', 0) == 1) {
             $intro_image_dir = JPATH_ROOT . "/" . JUDownloadFrontHelper::getDirectory("category_intro_image_directory", "media/com_judownload/images/category/intro/") . $data['images']['intro_image'];
             $ori_intro_image_dir = JPATH_ROOT . "/" . JUDownloadFrontHelper::getDirectory("category_intro_image_directory", "media/com_judownload/images/category/intro/") . 'original/' . $data['images']['intro_image'];
             $data['images']['intro_image'] = '';
             $data['images']['intro_image_alt'] = '';
             $data['images']['intro_image_caption'] = '';
             JFile::delete($ori_intro_image_dir);
             JFile::delete($intro_image_dir);
         }
         if ($jInput->post->getInt('remove_jform_images_detail_image', 0) == 1) {
             $full_image_dir = JPATH_ROOT . "/" . JUDownloadFrontHelper::getDirectory("category_detail_image_directory", "media/com_judownload/images/category/detail/") . $data['images']['detail_image'];
             $ori_full_image_dir = JPATH_ROOT . "/" . JUDownloadFrontHelper::getDirectory("category_detail_image_directory", "media/com_judownload/images/category/detail/") . "original/" . $data['images']['detail_image'];
             $data['images']['detail_image'] = '';
             $data['images']['detail_image_alt'] = '';
             $data['images']['detail_image_caption'] = '';
             JFile::delete($full_image_dir);
             JFile::delete($ori_full_image_dir);
         }
     }
     $mime_types = array("image/jpeg", "image/pjpeg", "image/png", "image/gif", "image/bmp", "image/x-windows-bmp");
     $num_files_failed_mime_type = 0;
     $images = $app->input->files->get('images', array());
     $old_ori_intro_image_path = isset($data['images']['intro_image']) && $data['images']['intro_image'] ? JUDownloadFrontHelper::getDirectory("category_intro_image_directory", "media/com_judownload/images/category/intro/") . 'original/' . $data['images']['intro_image'] : '';
     $old_intro_image_path = $old_ori_intro_image_path ? JUDownloadFrontHelper::getDirectory("category_intro_image_directory", "media/com_judownload/images/category/intro/") . $data['images']['intro_image'] : '';
     $old_ori_detail_image_path = isset($data['images']['detail_image']) && $data['images']['detail_image'] ? JUDownloadFrontHelper::getDirectory("category_detail_image_directory", "media/com_judownload/images/category/detail/") . 'original/' . $data['images']['detail_image'] : '';
     $old_detail_image_path = $old_ori_detail_image_path ? JUDownloadFrontHelper::getDirectory("category_detail_image_directory", "media/com_judownload/images/category/detail/") . $data['images']['detail_image'] : '';
     foreach ($images as $key => $image) {
         if ($image['name']) {
             if (!in_array($image['type'], $mime_types)) {
                 $num_files_failed_mime_type++;
                 continue;
             }
             $info = pathinfo($image['name']);
             $replace = array('id' => $table->id, 'document' => '', 'category' => $table->title, 'image_name' => $info['filename']);
             $image['name'] = JUDownloadHelper::parseImageNameByTags($replace, 'category', $table->id, null) . '.' . $info['extension'];
             if ($key == 'intro' && $app->input->post->get('use_detail_image', 0) != 1) {
                 $new_ori_image_path = JUDownloadFrontHelper::getDirectory("category_intro_image_directory", "media/com_judownload/images/category/intro/") . 'original/' . $image['name'];
                 $new_image_path = JUDownloadFrontHelper::getDirectory("category_intro_image_directory", "media/com_judownload/images/category/intro/") . $image['name'];
                 if (!JFile::upload($image['tmp_name'], JPATH_ROOT . "/" . $new_ori_image_path) || !JUDownloadHelper::renderImages(JPATH_ROOT . "/" . $new_ori_image_path, JPATH_ROOT . "/" . $new_image_path, "category_intro", true, $table->id)) {
                     unset($images['intro']);
                 } else {
                     $delete_old_intro_image = $data['images']['intro_image'] && $data['images']['intro_image'] !== $image['name'] ? true : false;
                     $data['images']['intro_image'] = $image['name'];
                 }
                 if ($delete_old_intro_image) {
                     if ($old_intro_image_path && JFile::exists(JPATH_ROOT . "/" . $old_intro_image_path)) {
                         JFile::delete(JPATH_ROOT . "/" . $old_ori_intro_image_path);
                         JFile::delete(JPATH_ROOT . "/" . $old_intro_image_path);
                     }
                 }
             }
             if ($key == 'detail') {
                 $new_ori_image_path = JUDownloadFrontHelper::getDirectory("category_detail_image_directory", "media/com_judownload/images/category/detail/") . 'original/' . $image['name'];
                 $new_image_path = JUDownloadFrontHelper::getDirectory("category_detail_image_directory", "media/com_judownload/images/category/detail/") . $image['name'];
                 if (!JFile::upload($image['tmp_name'], JPATH_ROOT . "/" . $new_ori_image_path) || !JUDownloadHelper::renderImages(JPATH_ROOT . "/" . $new_ori_image_path, JPATH_ROOT . "/" . $new_image_path, "category_detail", true, $table->id)) {
                     unset($images['detail']);
                 } else {
                     if ($data['images']['detail_image'] && $data['images']['detail_image'] !== $image['name']) {
                         if ($old_detail_image_path && JFile::exists(JPATH_ROOT . "/" . $old_detail_image_path)) {
                             JFile::delete(JPATH_ROOT . "/" . $old_ori_detail_image_path);
                             JFile::delete(JPATH_ROOT . "/" . $old_detail_image_path);
                         }
                     }
                     $data['images']['detail_image'] = $image['name'];
                 }
             }
         }
     }
     if ($num_files_failed_mime_type) {
         JError::raise(E_NOTICE, 500, JText::plural('COM_JUDOWNLOAD_N_IMAGES_ARE_NOT_VALID_MIMETYPE', $num_files_failed_mime_type, implode(",", $mime_types)));
     }
     if ($app->input->post->get('use_detail_image', 0) == 1 && $data['images']['detail_image']) {
         $old_ori_detail_image_path = JUDownloadFrontHelper::getDirectory("category_detail_image_directory", "media/com_judownload/images/category/detail/") . 'original/' . $data['images']['detail_image'];
         $new_ori_intro_image_path = JUDownloadFrontHelper::getDirectory("category_intro_image_directory", "media/com_judownload/images/category/intro/") . 'original/' . $data['images']['detail_image'];
         $new_image_path = JUDownloadFrontHelper::getDirectory("category_intro_image_directory", "media/com_judownload/images/category/intro/") . $data['images']['detail_image'];
         if (JFile::copy(JPATH_ROOT . "/" . $old_ori_detail_image_path, JPATH_ROOT . "/" . $new_ori_intro_image_path) && JUDownloadHelper::renderImages(JPATH_ROOT . "/" . $new_ori_intro_image_path, JPATH_ROOT . "/" . $new_image_path, 'category_intro', true, $table->id)) {
             if ($data['images']['intro_image'] && $data['images']['intro_image'] !== $data['images']['detail_image']) {
                 if (JFile::exists(JPATH_ROOT . "/" . $old_ori_intro_image_path)) {
                     JFile::delete(JPATH_ROOT . "/" . $old_ori_intro_image_path);
                 }
                 if (JFile::exists(JPATH_ROOT . "/" . $old_intro_image_path)) {
                     JFile::delete(JPATH_ROOT . "/" . $old_intro_image_path);
                 }
             }
             $data['images']['intro_image'] = $data['images']['detail_image'];
         }
     }
     if (!empty($data['images'])) {
         $registry = new JRegistry();
         $registry->loadArray($data['images']);
         $table->images = (string) $registry;
         $table->store();
     }
 }
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:99,代码来源:category.php


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